diff --git a/kernel/chips/Module.mk b/kernel/chips/Module.mk index fdd61fb9..9707a867 100644 --- a/kernel/chips/Module.mk +++ b/kernel/chips/Module.mk @@ -35,6 +35,7 @@ KERNELCHIPSTARGETS += $(MODULE_DIR)/vt8231.o KERNELCHIPSTARGETS += $(MODULE_DIR)/w83627hf.o KERNELCHIPSTARGETS += $(MODULE_DIR)/lm83.o KERNELCHIPSTARGETS += $(MODULE_DIR)/saa1064.o +KERNELCHIPSTARGETS += $(MODULE_DIR)/lm90.o # These targets ARE included in 'mkpatch', except for LTC1710, which we diff --git a/lib/chips.c b/lib/chips.c index b2a7954d..e910d190 100644 --- a/lib/chips.c +++ b/lib/chips.c @@ -698,6 +698,42 @@ static sensors_chip_feature lm83_features[] = }; +static sensors_chip_feature lm90_features[] = + { + { SENSORS_LM90_LOCAL_TEMP, "temp1", + SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, LM90_SYSCTL_LOCAL_TEMP, VALUE(3), 0 }, + { SENSORS_LM90_LOCAL_HIGH, "temp1_high", + SENSORS_LM90_LOCAL_TEMP, SENSORS_LM90_LOCAL_TEMP, + SENSORS_MODE_RW, LM90_SYSCTL_LOCAL_TEMP, VALUE(1), 0 }, + { SENSORS_LM90_LOCAL_LOW, "temp1_low", + SENSORS_LM90_LOCAL_TEMP, SENSORS_LM90_LOCAL_TEMP, + SENSORS_MODE_RW, LM90_SYSCTL_LOCAL_TEMP, VALUE(2), 0 }, + { SENSORS_LM90_REMOTE_TEMP, "temp2", + SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, LM90_SYSCTL_REMOTE_TEMP, VALUE(3), 1 }, + { SENSORS_LM90_REMOTE_HIGH, "temp2_high", + SENSORS_LM90_REMOTE_TEMP, SENSORS_LM90_REMOTE_TEMP, + SENSORS_MODE_RW, LM90_SYSCTL_REMOTE_TEMP, VALUE(1), 1 }, + { SENSORS_LM90_REMOTE_LOW, "temp2_low", + SENSORS_LM90_REMOTE_TEMP, SENSORS_LM90_REMOTE_TEMP, + SENSORS_MODE_RW, LM90_SYSCTL_REMOTE_TEMP, VALUE(2), 1 }, + { SENSORS_LM90_LOCAL_TCRIT, "tcrit1", + SENSORS_LM90_LOCAL_TEMP, SENSORS_LM90_LOCAL_TEMP, + SENSORS_MODE_RW, LM90_SYSCTL_LOCAL_TCRIT, VALUE(1), 0 }, + { SENSORS_LM90_REMOTE_TCRIT, "tcrit2", + SENSORS_LM90_REMOTE_TEMP, SENSORS_LM90_REMOTE_TEMP, + SENSORS_MODE_RW, LM90_SYSCTL_REMOTE_TCRIT, VALUE(1), 0 }, + { SENSORS_LM90_TCRIT_HYST, "hyst", + SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_RW, LM90_SYSCTL_HYST, VALUE(1), 0 }, + { SENSORS_LM90_ALARMS, "alarms", + SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, + SENSORS_MODE_R, LM90_SYSCTL_ALARMS, VALUE(1), 0 }, + { 0 } + }; + + static sensors_chip_feature w83781d_features[] = { { SENSORS_W83781D_IN0, "in0", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, @@ -4450,5 +4486,6 @@ sensors_chip_features sensors_chip_features_list[] = { SENSORS_ADM1027_PREFIX, adm1027_features }, { SENSORS_ADT7463_PREFIX, adm1027_features }, { SENSORS_LM83_PREFIX, lm83_features }, + { SENSORS_LM90_PREFIX, lm90_features }, { 0 } }; diff --git a/lib/chips.h b/lib/chips.h index 185cad63..be06493f 100644 --- a/lib/chips.h +++ b/lib/chips.h @@ -443,6 +443,21 @@ #define SENSORS_LM85_ZONE3_RANGE 100 /* RW -- zone3_range */ #define SENSORS_LM85_ZONE3_SMOOTH 101 /* RW -- zone3_smooth */ +/* LM90 chips */ + +#define SENSORS_LM90_PREFIX "lm90" + +#define SENSORS_LM90_LOCAL_TEMP 51 /* R */ +#define SENSORS_LM90_LOCAL_HIGH 52 /* RW */ +#define SENSORS_LM90_LOCAL_LOW 53 /* RW */ +#define SENSORS_LM90_LOCAL_TCRIT 54 /* RW */ +#define SENSORS_LM90_REMOTE_TEMP 57 /* R */ +#define SENSORS_LM90_REMOTE_HIGH 58 /* RW */ +#define SENSORS_LM90_REMOTE_LOW 59 /* RW */ +#define SENSORS_LM90_REMOTE_TCRIT 60 /* RW */ +#define SENSORS_LM90_TCRIT_HYST 79 /* RW */ +#define SENSORS_LM90_ALARMS 81 /* R */ + /* Winbond W83781D chips */ #define SENSORS_W83781D_PREFIX "w83781d" diff --git a/prog/sensors/chips.c b/prog/sensors/chips.c index 3b2bda34..175e6de6 100644 --- a/prog/sensors/chips.c +++ b/prog/sensors/chips.c @@ -54,6 +54,7 @@ inline float deg_ctof( float cel ) #define MINMAX 1 #define MAXONLY 2 #define CRIT 3 +#define SINGLE 4 /* minmax = 0 for limit/hysteresis, 1 for max/min, 2 for max only; curprec and limitprec are # of digits after decimal point for the current temp and the limits */ @@ -73,7 +74,7 @@ void print_temp_info(float n_cur, float n_over, float n_hyst, /* use %* to pass size and precision as arguments */ if(minmax == MINMAX) - printf( "%+6.*f%s (min = %+*.*f%s, max = %+*.*f%s)", + printf( "%+6.*f%s (low = %+*.*f%s, high = %+*.*f%s) ", curprec, n_cur, degv, limitprec + 4, limitprec, n_hyst, degv, limitprec + 4, limitprec, n_over, degv); @@ -86,11 +87,16 @@ void print_temp_info(float n_cur, float n_over, float n_hyst, curprec, n_cur, degv, limitprec + 4, limitprec, n_over, degv, limitprec + 4, limitprec, n_hyst, degv); - else /* HYST */ + else if(minmax == HYST) printf( "%+6.*f%s (limit = %+*.*f%s, hysteresis = %+*.*f%s)", curprec, n_cur, degv, limitprec + 4, limitprec, n_over, degv, limitprec + 4, limitprec, n_hyst, degv); + else if(minmax == SINGLE) + printf( "%+6.*f%s", + curprec, n_cur, degv); + else + printf( "unknown temperature mode!"); } void print_label(const char *label, int space) @@ -4378,6 +4384,74 @@ void print_lm83(const sensors_chip_name *name) free_the_label(&label); } +void print_lm90(const sensors_chip_name *name) +{ + char *label; + double cur, high, low, crit; + int valid, alarms; + + if (!sensors_get_feature(*name, SENSORS_LM90_ALARMS, &cur)) + alarms = cur + 0.5; + else { + printf("ERROR: Can't get alarm data!\n"); + alarms = 0; + } + + if (sensors_get_feature(*name, SENSORS_LM90_LOCAL_TCRIT, &crit)) { + printf("ERROR: Can't get local tcrit data!\n"); + crit = 127; + } + + if (!sensors_get_label_and_valid(*name, SENSORS_LM90_LOCAL_TEMP, + &label, &valid) + && !sensors_get_feature(*name, SENSORS_LM90_LOCAL_TEMP, &cur) + && !sensors_get_feature(*name, SENSORS_LM90_LOCAL_HIGH, &high) + && !sensors_get_feature(*name, SENSORS_LM90_LOCAL_LOW, &low)) { + if (valid) { + print_label(label, 10); + print_temp_info(cur, high, low, MINMAX, 0, 0); + printf(" %s\n", alarms&LM90_ALARM_LOCAL_CRIT?"CRITICAL": + alarms&(LM90_ALARM_LOCAL_HIGH|LM90_ALARM_LOCAL_LOW)?"ALARM": + ""); + } + } else + printf("ERROR: Can't get local temperature data!\n"); + free_the_label(&label); + + if (sensors_get_feature(*name, SENSORS_LM90_REMOTE_TCRIT, &crit)) { + printf("ERROR: Can't get remote tcrit data!\n"); + crit = 127; + } + + if (!sensors_get_label_and_valid(*name, SENSORS_LM90_REMOTE_TEMP, + &label, &valid) + && !sensors_get_feature(*name, SENSORS_LM90_REMOTE_TEMP, &cur) + && !sensors_get_feature(*name, SENSORS_LM90_REMOTE_HIGH, &high) + && !sensors_get_feature(*name, SENSORS_LM90_REMOTE_LOW, &low)) { + if (valid) { + print_label(label, 10); + print_temp_info(cur, high, low, MINMAX, 1, 1); + printf(" %s\n", alarms&LM90_ALARM_REMOTE_OPEN?"DISCONNECT": + alarms&LM90_ALARM_REMOTE_CRIT?"CRITICAL": + alarms&(LM90_ALARM_REMOTE_HIGH|LM90_ALARM_REMOTE_LOW)?"ALARM": + ""); + } + } else + printf("ERROR: Can't get remote temperature data!\n"); + free_the_label(&label); + + if (!sensors_get_label_and_valid(*name, SENSORS_LM90_TCRIT_HYST, + &label, &valid) + && !sensors_get_feature(*name, SENSORS_LM90_TCRIT_HYST, &cur)) { + if (valid) { + print_label(label, 10); + print_temp_info(cur, 0, 0, SINGLE, 0, 0); + } + } else + printf("ERROR: Can't get hysteresis data!\n"); + free_the_label(&label); +} + void print_unknown_chip(const sensors_chip_name *name) { int a,b,valid; diff --git a/prog/sensors/chips.h b/prog/sensors/chips.h index 1c0a5d5c..949d2a77 100644 --- a/prog/sensors/chips.h +++ b/prog/sensors/chips.h @@ -53,5 +53,6 @@ extern void print_lm92(const sensors_chip_name *name); extern void print_vt8231(const sensors_chip_name *name); extern void print_bmc(const sensors_chip_name *name); extern void print_lm83(const sensors_chip_name *name); +extern void print_lm90(const sensors_chip_name *name); #endif /* def PROG_SENSORS_CHIPS_H */