#define ASMC_MAXFANS 6
#define ASMC_MAXVAL 32
#define ASMC_KEYLEN 4
#define ASMC_TYPELEN 4
#define ASMC_MAX_SENSORS 64
#define ASMC_TEMP_MAX 80
struct asmc_softc {
device_t sc_dev;
struct mtx sc_mtx;
int sc_nfan;
int sc_nkeys;
int16_t sms_rest_x;
int16_t sms_rest_y;
int16_t sms_rest_z;
struct sysctl_oid *sc_fan_tree[ASMC_MAXFANS+1];
struct sysctl_oid *sc_temp_tree;
struct sysctl_oid *sc_sms_tree;
struct sysctl_oid *sc_light_tree;
int sc_rid_port;
int sc_rid_irq;
struct resource *sc_ioport;
struct resource *sc_irq;
void *sc_cookie;
int sc_rid_mem;
struct resource *sc_iomem;
bool sc_is_mmio;
int sc_is_t2;
int sc_sms_intrtype;
struct taskqueue *sc_sms_tq;
struct task sc_sms_task;
uint8_t sc_sms_intr_works;
struct cdev *sc_kbd_bkl;
uint32_t sc_kbd_bkl_level;
#ifdef ASMC_DEBUG
struct sysctl_oid *sc_raw_tree;
char sc_rawkey[ASMC_KEYLEN + 1];
uint8_t sc_rawval[ASMC_MAXVAL];
uint8_t sc_rawlen;
char sc_rawtype[ASMC_TYPELEN + 1];
#endif
char *sc_voltage_sensors[ASMC_MAX_SENSORS];
int sc_voltage_count;
char *sc_current_sensors[ASMC_MAX_SENSORS];
int sc_current_count;
char *sc_power_sensors[ASMC_MAX_SENSORS];
int sc_power_count;
char *sc_light_sensors[ASMC_MAX_SENSORS];
int sc_light_count;
char *sc_temp_sensors[ASMC_TEMP_MAX];
int sc_temp_count;
int sc_has_sms;
int sc_has_light;
int sc_light_len;
int sc_has_safespeed;
int sc_has_alsl;
};
#define ASMC_DATAPORT_READ(sc) bus_read_1(sc->sc_ioport, 0x00)
#define ASMC_DATAPORT_WRITE(sc, val) \
bus_write_1(sc->sc_ioport, 0x00, val)
#define ASMC_STATUS_MASK 0x0f
#define ASMC_CMDPORT_READ(sc) bus_read_1(sc->sc_ioport, 0x04)
#define ASMC_CMDPORT_WRITE(sc, val) \
bus_write_1(sc->sc_ioport, 0x04, val)
#define ASMC_CMDREAD 0x10
#define ASMC_CMDWRITE 0x11
#define ASMC_CMDGETBYINDEX 0x12
#define ASMC_CMDGETINFO 0x13
#define ASMC_STATUS_AWAIT_DATA 0x04
#define ASMC_STATUS_DATA_READY 0x05
#define ASMC_KEYINFO_RESPLEN 6
#define ASMC_MAXRETRIES 10
#define ASMC_INTPORT_READ(sc) bus_read_1(sc->sc_ioport, 0x1f)
#define ASMC_NKEYS "#KEY"
#define ASMC_KEY_REV "REV "
#define ASMC_KEY_FANCOUNT "FNum"
#define ASMC_KEY_FANMANUAL "FS! "
#define ASMC_KEY_FANID "F%dID"
#define ASMC_KEY_FANSPEED "F%dAc"
#define ASMC_KEY_FANMINSPEED "F%dMn"
#define ASMC_KEY_FANMAXSPEED "F%dMx"
#define ASMC_KEY_FANSAFESPEED "F%dSf"
#define ASMC_KEY_FANTARGETSPEED "F%dTg"
#define ASMC_SMS_INIT1 0xe0
#define ASMC_SMS_INIT2 0xf8
#define ASMC_KEY_SMS "MOCN"
#define ASMC_KEY_SMS_X "MO_X"
#define ASMC_KEY_SMS_Y "MO_Y"
#define ASMC_KEY_SMS_Z "MO_Z"
#define ASMC_KEY_SMS_LOW "MOLT"
#define ASMC_KEY_SMS_HIGH "MOHT"
#define ASMC_KEY_SMS_LOW_INT "MOLD"
#define ASMC_KEY_SMS_HIGH_INT "MOHD"
#define ASMC_KEY_SMS_FLAG "MSDW"
#define ASMC_SMS_INTFF 0x60
#define ASMC_SMS_INTHA 0x6f
#define ASMC_SMS_INTSH 0x80
#define ASMC_ALSL_INT2A 0x2a
#define ASMC_LIGHT_SHORTLEN 6
#define ASMC_LIGHT_LONGLEN 10
#define ASMC_KEY_LIGHTLEFT "ALV0"
#define ASMC_KEY_LIGHTRIGHT "ALV1"
#define ASMC_KEY_LIGHTVALUE "LKSB"
#define ASMC_KEY_LIGHTSRC "ALSL"
#define ASMC_KEY_FANSAFESPEED0 "F0Sf"
#define ASMC_KEY_CLAMSHELL "MSLD"
#define ASMC_KEY_AUPO "AUPO"
#define ASMC_KEY_INTOK "NTOK"
#define ASMC_KEY_CLKT "CLKT"
#define ASMC_KEY_MSSD "MSSD"
#define ASMC_KEY_MSSP "MSSP"
#define ASMC_KEY_MSAL "MSAL"
#define ASMC_KEY_MSPS "MSPS"
#define ASMC_KEY_MSTS "MSTS"
#define ASMC_MSAL_TSS 0x01
#define ASMC_MSAL_THERM_VALID 0x02
#define ASMC_MSAL_CALIB_VALID 0x08
#define ASMC_MSAL_PROCHOT 0x40
#define ASMC_MSAL_PLIMITS 0x80
#define ASMC_KEY_RPLT "RPlt"
#define ASMC_KEY_RGEN "RGEN"
#define ASMC_RPLT_MAXLEN 8
struct asmc_cause {
int8_t code;
const char *desc;
const char *sleep_desc;
};
#define ASMC_CAUSE_BUFLEN 48
static const struct asmc_cause asmc_cause_table[] = {
{ 5, "good-shutdown", "good-sleep" },
{ 3, "power-button", NULL },
{ 2, "low-battery-sleep", NULL },
{ 1, "overtemp-sleep", NULL },
{ 0, "initial", NULL },
{ -1, "health-check", NULL },
{ -2, "power-supply", NULL },
{ -3, "temperature-multisleep", NULL },
{ -4, "sensor-fan", NULL },
{ -30, "temperature-overlimit-timeout",NULL },
{ -40, "pswr-smrst", NULL },
{ -50, "unmapped", NULL },
{ -60, "low-battery", NULL },
{ -61, "ninja-shutdown", NULL },
{ -62, "ninja-restart", NULL },
{ -70, "palm-rest-temperature", NULL },
{ -71, "sodimm-temperature", NULL },
{ -72, "heatpipe-temperature", NULL },
{ -74, "battery-temperature", NULL },
{ -75, "adapter-timeout", NULL },
{ -77, "manual-temperature", NULL },
{ -78, "adapter-current", NULL },
{ -79, "battery-current", NULL },
{ -82, "skin-temperature", NULL },
{ -83, "skin-temperature-sensors", NULL },
{ -84, "backup-temperature", NULL },
{ -86, "cpu-proximity-temperature", NULL },
{ -95, "cpu-temperature", NULL },
{ -100, "power-supply-temperature", NULL },
{ -101, "lcd-temperature", NULL },
{ -102, "rsm-power-fail", NULL },
{ -103, "battery-cuv", NULL },
{ -127, "pmu-forced-shutdown", NULL },
{ -128, "unknown", NULL },
};