1 1.3 jdc /* $NetBSD: tadpmureg.h,v 1.3 2020/05/16 07:16:14 jdc Exp $ */ 2 1.1 macallan 3 1.1 macallan /*- 4 1.1 macallan * Copyright (c) 2018 Michael Lorenz <macallan (at) netbsd.org> 5 1.1 macallan * All rights reserved. 6 1.1 macallan * 7 1.1 macallan * Redistribution and use in source and binary forms, with or without 8 1.1 macallan * modification, are permitted provided that the following conditions 9 1.1 macallan * are met: 10 1.1 macallan * 1. Redistributions of source code must retain the above copyright 11 1.1 macallan * notice, this list of conditions and the following disclaimer. 12 1.1 macallan * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 macallan * notice, this list of conditions and the following disclaimer in the 14 1.1 macallan * documentation and/or other materials provided with the distribution. 15 1.1 macallan * 16 1.1 macallan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 1.1 macallan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 1.1 macallan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 1.1 macallan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 1.1 macallan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 1.1 macallan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 1.1 macallan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 1.1 macallan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 1.1 macallan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 1.1 macallan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 1.1 macallan * POSSIBILITY OF SUCH DAMAGE. 27 1.1 macallan */ 28 1.1 macallan 29 1.3 jdc /* registers and commands for the PMU found in Tadpole SPARCle/Viper laptops */ 30 1.1 macallan 31 1.1 macallan #ifndef TADPMUREG_H 32 1.1 macallan #define TADPMUREG_H 33 1.1 macallan 34 1.1 macallan /* all values were found by looking at OF methods on the tadpmu node */ 35 1.1 macallan 36 1.1 macallan /* these registers live in the pckbc's address space */ 37 1.1 macallan #define TADPMU_CMD 0x6 38 1.1 macallan #define TADPMU_STATUS 0x6 39 1.1 macallan #define TADPMU_DATA 0x2 40 1.1 macallan 41 1.2 macallan #define STATUS_HAVE_DATA 0x01 /* response from command */ 42 1.1 macallan #define STATUS_CMD_IN_PROGRESS 0x02 43 1.2 macallan #define STATUS_INTR 0x04 /* interrupt happened, read data to ack */ 44 1.2 macallan #define STATUS_SEND_DATA 0x08 /* cmd waiting for data */ 45 1.1 macallan 46 1.1 macallan #define CMD_SET_OPMODE 0x41 /* not sure what exactly this does... */ 47 1.1 macallan #define OPMODE_UNIX 0x75 /* other than toggling the UNIX mode */ 48 1.1 macallan #define OPMODE_OF 0x67 /* bit in the GENSTAT register */ 49 1.3 jdc #define OPMODE_DBG_ON 0x64 /* Debug ON */ 50 1.3 jdc #define OPMODE_DBG_OFF 0x6E /* Debug OFF */ 51 1.3 jdc #define OPMODE_OBP 0x6F 52 1.3 jdc #define CMD_CHRGCTL 0x42 53 1.1 macallan #define CMD_SET_BACKLIGHT 0x43 /* apparently 0 - 1f */ 54 1.1 macallan #define CMD_SET_CPUSPEED 0x44 /* in 10MHz, so 120 == 1.2GHz */ 55 1.3 jdc #define CMD_SET_SPREADCLK 0x45 56 1.3 jdc #define CMD_SET_FANSPEED 0x46 57 1.1 macallan #define CMD_SET_VOLUME 0x48 /* beeper volume */ 58 1.3 jdc #define CMD_SET_DIR_CLK 0x80 59 1.3 jdc #define CMD_WRITE 0xC0 60 1.1 macallan 61 1.1 macallan #define CMD_READ_GENSTAT 0x10 62 1.1 macallan #define CMD_READ_BACKLIGHT 0x11 63 1.1 macallan #define CMD_READ_SYSTEMP 0x12 /* temperature */ 64 1.1 macallan #define CMD_READ_VOLUME 0x13 65 1.3 jdc #define CMD_READ_VBATT 0x14 /* Voltage * 10 (e.g. 120 = 12.0v) */ 66 1.1 macallan #define CMD_READ_VERSION 0x15 67 1.1 macallan #define CMD_READ_CPUSPEED 0x16 68 1.3 jdc #define CMD_READ_KEYSTAT 0x17 /* Pause-A, D, N, O, R */ 69 1.3 jdc #define CMD_READ_FAN_EN 0x18 /* Fan(s): off=0x00, full=0x77 */ 70 1.1 macallan #define CMD_READ_GENSTAT2 0x19 71 1.3 jdc #define READ_DIPSWITCH 0x1A 72 1.3 jdc 73 1.1 macallan #define CMD_READ_FANSPEED 0x50 /* takes a parameter, returns nothing? */ 74 1.1 macallan 75 1.3 jdc #define CMD_SHUTDOWN 0x40 76 1.3 jdc #define CMD_BEEP 0x47 /* Start/stop beep, param is freq */ 77 1.3 jdc #define CMD_READ_BMU 0x70 78 1.3 jdc #define CMD_REFLASH 0x49 79 1.3 jdc #define CMD_READ 0x89 80 1.3 jdc #define CMD_WRITE 0xC0 81 1.3 jdc #define CMD_WRITE_BMU 0xC1 82 1.3 jdc 83 1.1 macallan /* these are according to the ROM methods 84 1.1 macallan #define GENSTAT_DC_PRESENT 0x01 85 1.1 macallan #define GENSTAT_DC_ENABLE 0x02 86 1.1 macallan #define GENSTAT_BATTERY_PRESENT 0x04 87 1.1 macallan #define GENSTAT_BATTERY_CHARGING 0x08 88 1.1 macallan #define GENSTAT_LID_CLOSED 0x10 89 1.1 macallan #define GENSTAT_UNIX_MODE 0x20 90 1.1 macallan #define GENSTAT_SPREADSPECTRUM 0x40 91 1.1 macallan 92 1.3 jdc Values of genstat (from observation) 93 1.3 jdc 0b = on battery 94 1.3 jdc 3b = battery charging 95 1.3 jdc 1f = battery full 96 1.3 jdc 1b = no battery 97 1.3 jdc */ 98 1.1 macallan #define GENSTAT_UNIX_MODE 0x01 99 1.3 jdc #define GENSTAT_BATTERY_PRESENT 0x04 /* only valid if DC present? */ 100 1.3 jdc #define GENSTAT_BATTERY_CHARGED 0x08 101 1.3 jdc #define GENSTAT_DC_PRESENT 0x10 102 1.3 jdc #define GENSTAT_BATTERY_CHARGING 0x20 103 1.1 macallan #define GENSTAT_LID_CLOSED 0x80 104 1.1 macallan 105 1.3 jdc #define GENSTAT_STATE_BATTERY_FULL 0x1f 106 1.3 jdc #define GENSTAT_STATE_BATTERY_DISCHARGE 0x0b 107 1.3 jdc #define GENSTAT_STATE_BATTERY_CHARGE 0x3b 108 1.3 jdc 109 1.3 jdc #define GENSTAT2_DEBUG 0x01 /* PMU debug enable? */ 110 1.1 macallan #define GENSTAT2_MUTE 0x02 111 1.1 macallan 112 1.2 macallan /* messages from interrupts */ 113 1.3 jdc #define TADPMU_INTR_BATTERY_CHARGED 0x03 114 1.3 jdc #define TADPMU_INTR_DCPOWER 0x04 115 1.3 jdc #define TADPMU_INTR_LID 0x05 116 1.3 jdc #define TADPMU_INTR_POWERBUTTON 0x06 117 1.3 jdc #define TADPMU_INTR_BATTERY_VOLT 0xcd /* Voltage change */ 118 1.3 jdc #define TADPMU_INTR_BATTERY_STATE 0xd6 /* e.g. warn -> crit */ 119 1.3 jdc /* Other observed values: 120 1.3 jdc 0xc9 121 1.3 jdc 0xcb 122 1.3 jdc 0xd2 123 1.3 jdc */ 124 1.1 macallan 125 1.3 jdc #endif /* TADPMUREG_H */ 126