Index: asmc.c =================================================================== --- asmc.c (revision 260484) +++ asmc.c (working copy) @@ -196,6 +196,12 @@ ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, ASMC_MBP4_TEMPS, ASMC_MBP4_TEMPNAMES, ASMC_MBP4_TEMPDESCS }, + + { + "MacBookPro5,5", "Apple SMC MacBook Pro Core 2 Duo (Penryn)", + ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS, + ASMC_MBP5_TEMPS, ASMC_MBP5_TEMPNAMES, ASMC_MBP5_TEMPDESCS + }, /* The Mac Mini has no SMS */ { @@ -256,6 +262,8 @@ #else #define ASMC_DPRINTF(str) #endif +static int light_debug = 0; +static int sms_debug = 0; /* NB: can't be const */ static char *asmc_ids[] = { "APP0001", NULL }; @@ -356,12 +364,15 @@ dev, j, model->smc_fan_speed, "I", "Fan speed in RPM"); - SYSCTL_ADD_PROC(sysctlctx, - SYSCTL_CHILDREN(sc->sc_fan_tree[i]), - OID_AUTO, "safespeed", - CTLTYPE_INT | CTLFLAG_RD, - dev, j, model->smc_fan_safespeed, "I", - "Fan safe speed in RPM"); + /* Not present in all models */ + if(strncmp(getenv("smbios.system.product"), "MacBookPro5,5", 13)) { + SYSCTL_ADD_PROC(sysctlctx, + SYSCTL_CHILDREN(sc->sc_fan_tree[i]), + OID_AUTO, "safespeed", + CTLTYPE_INT | CTLFLAG_RD, + dev, j, model->smc_fan_safespeed, "I", + "Fan safe speed in RPM"); + } SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_fan_tree[i]), @@ -415,11 +426,14 @@ dev, 0, model->smc_light_left, "I", "Keyboard backlight left sensor"); - SYSCTL_ADD_PROC(sysctlctx, + /* not present in mbp5,5? */ + if(strncmp(getenv("smbios.system.product"), "MacBookPro5,5", 13)) { + SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_light_tree), OID_AUTO, "right", CTLTYPE_INT | CTLFLAG_RD, dev, 0, model->smc_light_right, "I", "Keyboard backlight right sensor"); + } SYSCTL_ADD_PROC(sysctlctx, SYSCTL_CHILDREN(sc->sc_light_tree), @@ -427,6 +441,13 @@ CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY, dev, 0, model->smc_light_control, "I", "Keyboard backlight brightness control"); + + SYSCTL_ADD_INT(sysctlctx, + SYSCTL_CHILDREN(sc->sc_light_tree), + OID_AUTO, "debug", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY, + &light_debug, sizeof(light_debug), + "Show when an interrupt occurs"); } if (model->smc_sms_x == NULL) @@ -457,6 +478,13 @@ dev, 0, model->smc_sms_z, "I", "Sudden Motion Sensor Z value"); + SYSCTL_ADD_INT(sysctlctx, + SYSCTL_CHILDREN(sc->sc_sms_tree), + OID_AUTO, "debug", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_ANYBODY, + &sms_debug, sizeof(sms_debug), + "Show when an interrupt occurs"); + /* * Need a taskqueue to send devctl_notify() events * when the SMS interrupt us. @@ -1097,16 +1125,23 @@ switch (type) { case ASMC_SMS_INTFF: - device_printf(dev, "WARNING: possible free fall!\n"); + if(sms_debug) + device_printf(dev, "WARNING: possible free fall!\n"); break; case ASMC_SMS_INTHA: - device_printf(dev, "WARNING: high acceleration detected!\n"); + if(sms_debug) + device_printf(dev, "WARNING: high acceleration detected!\n"); break; case ASMC_SMS_INTSH: - device_printf(dev, "WARNING: possible shock!\n"); + if(light_debug) + device_printf(dev, "WARNING: possible shock!\n"); break; + case ASMC_SMS_INTAL: + if(light_debug) + device_printf(dev, "WARNING: change in ambient lighting!\n"); + break; default: - device_printf(dev, "%s unknown interrupt\n", __func__); + device_printf(dev, "%s unknown interrupt: %d\n", __func__, type); } } @@ -1184,12 +1219,22 @@ asmc_mbp_sysctl_light_left(SYSCTL_HANDLER_ARGS) { device_t dev = (device_t) arg1; - uint8_t buf[6]; + uint8_t buf[10]; int error; int32_t v; + int data_length; + int data_index; - asmc_key_read(dev, ASMC_KEY_LIGHTLEFT, buf, 6); - v = buf[2]; + if(!strncmp(getenv("smbios.system.product"), "MacBookPro5,5", 13)) { + data_length = 10; + data_index = 5; + } else { + data_length = 6; + data_index = 2; + } + + asmc_key_read(dev, ASMC_KEY_LIGHTLEFT, buf, data_length); + v = buf[data_index]; error = sysctl_handle_int(oidp, &v, sizeof(v), req); return (error); @@ -1199,7 +1244,7 @@ asmc_mbp_sysctl_light_right(SYSCTL_HANDLER_ARGS) { device_t dev = (device_t) arg1; - uint8_t buf[6]; + uint8_t buf[10]; int error; int32_t v; Index: asmcvar.h =================================================================== --- asmcvar.h (revision 260484) +++ asmcvar.h (working copy) @@ -86,7 +86,7 @@ #define ASMC_KEY_FANSPEED "F%dAc" /* RO; 2 bytes */ #define ASMC_KEY_FANMINSPEED "F%dMn" /* RO; 2 bytes */ #define ASMC_KEY_FANMAXSPEED "F%dMx" /* RO; 2 bytes */ -#define ASMC_KEY_FANSAFESPEED "F%dSf" /* RO; 2 bytes */ +#define ASMC_KEY_FANSAFESPEED "F%dSf" /* RO; 2 bytes - not all models*/ #define ASMC_KEY_FANTARGETSPEED "F%dTg" /* RW; 2 bytes */ /* @@ -106,6 +106,7 @@ #define ASMC_SMS_INTFF 0x60 /* Free fall Interrupt */ #define ASMC_SMS_INTHA 0x6f /* High Acceleration Interrupt */ #define ASMC_SMS_INTSH 0x80 /* Shock Interrupt */ +#define ASMC_SMS_INTAL 0x2a /* Change in ambient lighting */ /* * Keyboard backlight. @@ -175,6 +176,21 @@ "Unknown", "Unknown", \ "Wireless Module", } +#define ASMC_MBP5_TEMPS { "TB0T", "TB1T", "TB2T", "TB3T", \ + "TN0P", "TN0D", "TC0D", \ + "TC0P", "Ts0P", "Th1H", NULL } + +#define ASMC_MBP5_TEMPNAMES { "battery0", "battery1", "battery3", \ + "battery4", "northbridge0", \ + "northbridge1", "cpu", "cpu2", \ + "topcase", "finstack", } + +#define ASMC_MBP5_TEMPDESCS { "Battery TS_MAX Temp", "Battery TS1 Temp", \ + "Battery TS2 Temp", "Battery Temp", \ + "CPU 0 Die Temp", "CPU 0 Proximity Temp", \ + "MCP Proximity", "MCP Digital", \ + "Top Case", "Fin Stack Proximity Temp", } + #define ASMC_MM_TEMPS { "TN0P", "TN1P", NULL } #define ASMC_MM_TEMPNAMES { "northbridge1", "northbridge2" } #define ASMC_MM_TEMPDESCS { "Northbridge Point 1", \