From 14992732d9e87f3d5f626d5cc11e338c20b0890e Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Fri, 8 Jan 1999 20:21:32 +0000 Subject: [PATCH] GL518SM fixes * Better VDD internal computation, as described in the data sheet; * Fixed the config file to reflect the above change; * The library read the wrong file to get its gl518sm alarm data. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@150 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + doc/progs | 5 +++++ etc/sensors.conf.eg | 3 --- kernel/chips/gl518sm.c | 22 ++++++++++++++-------- lib/chips.c | 2 +- src/gl518sm.c | 22 ++++++++++++++-------- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/CHANGES b/CHANGES index c37a3db0..cef8c503 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ ask CVS about it: 2.1.2 (199801??) Modules lm80.o, w83781d.o: fan-related Segmentation fault corrected + Module gl518sm.o: yet more bug fixes. It should at long last be usable now 2.1.1 (19990107) Module i2c-proc.o: Hack to make /proc/bus/ possible for kernels 2.0.35 diff --git a/doc/progs b/doc/progs index a85d1444..8b31e4f2 100644 --- a/doc/progs +++ b/doc/progs @@ -7,6 +7,11 @@ this package. file. It read /proc/bus/i2c (or the file specified on the command-line), and prints to stdout `bus' statements reflecting the currently detected adapters. +* prog/dump/isadump (written in C, not installed) + This program helps to dump the registers of LM78-like chips, or more + exactly, chips which use an I/O-port for its address and one as its + data register. Usual syntax: + ./isadump 0x295 0x296 * prog/eeprom/decode-dimms.pl (written in Perl 5, not installed) This program decodes the information generated by the `eeprom.o' module. It will only work for the installed eeprom module from the src/ directory, diff --git a/etc/sensors.conf.eg b/etc/sensors.conf.eg index 42ad32d0..5bf52c1a 100644 --- a/etc/sensors.conf.eg +++ b/etc/sensors.conf.eg @@ -201,9 +201,6 @@ chip "gl518sm-r00-*" "gl518sm-r80-*" # The below declaration is from the data sheet. We have no idea how these # chips are typically used. Please contact us if you own one. label vdd "+5V" - compute vdd @ * 2.5, @ / 2.5 - - chip "lm80-*" diff --git a/kernel/chips/gl518sm.c b/kernel/chips/gl518sm.c index 353b3228..93a41065 100644 --- a/kernel/chips/gl518sm.c +++ b/kernel/chips/gl518sm.c @@ -63,6 +63,9 @@ #define IN_TO_REG(val) ((((val)*10+8)/19) & 0xff) #define IN_FROM_REG(val) (((val)*19)/10) +#define VDD_TO_REG(val) ((((val)*10+11)/23) & 0xff) +#define VDD_FROM_REG(val) (((val)*23)/10) + #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) #define DIV_FROM_REG(val) (1 << (val)) @@ -84,7 +87,7 @@ #define GL518_INIT_VIN_1 300 #define GL518_INIT_VIN_2 300 #define GL518_INIT_VIN_3 300 -#define GL518_INIT_VDD 300 +#define GL518_INIT_VDD 500 #define GL518_INIT_PERCENTAGE 10 @@ -313,8 +316,8 @@ int gl518_attach_adapter(struct i2c_adapter *adapter) (IN_TO_REG(GL518_INIT_VIN_MAX_3) << 8) | IN_TO_REG(GL518_INIT_VIN_MIN_3)); gl518_write_value(new_client,GL518_REG_VDD_LIMIT, - (IN_TO_REG(GL518_INIT_VDD_MAX) << 8) | - IN_TO_REG(GL518_INIT_VDD_MIN)); + (VDD_TO_REG(GL518_INIT_VDD_MAX) << 8) | + VDD_TO_REG(GL518_INIT_VDD_MIN)); /* Clear status register (bit 5=1), start (bit6=1) */ gl518_write_value(new_client,GL518_REG_CONF,0x24); gl518_write_value(new_client,GL518_REG_CONF,0x44); @@ -504,12 +507,15 @@ void gl518_vin(struct i2c_client *client, int operation, int ctl_name, *nrels_mag = 2; else if (operation == SENSORS_PROC_REAL_READ) { gl518_update_client(client); - results[0] = IN_FROM_REG(data->voltage_min[nr]); - results[1] = IN_FROM_REG(data->voltage_max[nr]); + results[0] = nr?IN_FROM_REG(data->voltage_min[nr]): + VDD_FROM_REG(data->voltage_min[nr]); + results[1] = nr?IN_FROM_REG(data->voltage_max[nr]): + VDD_FROM_REG(data->voltage_max[nr]); if ((data->revision == 0x00) && (nr != 3)) results[2] = 0; else - results[2] = IN_FROM_REG(data->voltage[nr]); + results[2] = nr?IN_FROM_REG(data->voltage[nr]): + VDD_FROM_REG(data->voltage[nr]); *nrels_mag = 3; } else if (operation == SENSORS_PROC_REAL_WRITE) { regnr=nr==0?GL518_REG_VDD_LIMIT:nr==1?GL518_REG_VIN1_LIMIT:nr==2? @@ -517,11 +523,11 @@ void gl518_vin(struct i2c_client *client, int operation, int ctl_name, if (*nrels_mag == 1) old = gl518_read_value(client,regnr) & 0xff00; if (*nrels_mag >= 2) { - data->voltage_max[nr] = IN_TO_REG(results[1]); + data->voltage_max[nr] = nr?IN_TO_REG(results[1]):VDD_TO_REG(results[1]); old = data->voltage_max[nr] << 8; } if (*nrels_mag >= 1) { - data->voltage_min[nr] = IN_TO_REG(results[0]); + data->voltage_min[nr] = nr?IN_TO_REG(results[0]):VDD_TO_REG(results[0]); old |= data->voltage_min[nr]; gl518_write_value(client,regnr,old); } diff --git a/lib/chips.c b/lib/chips.c index 2eb9c877..80d373b5 100644 --- a/lib/chips.c +++ b/lib/chips.c @@ -434,7 +434,7 @@ static sensors_chip_feature gl518r80_features[] = GL518_SYSCTL_FAN_DIV, VALUE(2), 0 }, { SENSORS_GL518R80_ALARMS, "alarms", SENSORS_NO_MAPPING, SENSORS_NO_MAPPING, SENSORS_MODE_R, - GL518_SYSCTL_FAN_DIV, VALUE(3), 0 }, + GL518_SYSCTL_ALARMS, VALUE(1), 0 }, { SENSORS_GL518R80_BEEP_ENABLE, "beep_enable", SENSORS_GL518R80_ALARMS, SENSORS_NO_MAPPING, SENSORS_MODE_RW, GL518_SYSCTL_BEEP, VALUE(1), 0 }, diff --git a/src/gl518sm.c b/src/gl518sm.c index 353b3228..93a41065 100644 --- a/src/gl518sm.c +++ b/src/gl518sm.c @@ -63,6 +63,9 @@ #define IN_TO_REG(val) ((((val)*10+8)/19) & 0xff) #define IN_FROM_REG(val) (((val)*19)/10) +#define VDD_TO_REG(val) ((((val)*10+11)/23) & 0xff) +#define VDD_FROM_REG(val) (((val)*23)/10) + #define DIV_TO_REG(val) ((val)==8?3:(val)==4?2:(val)==1?0:1) #define DIV_FROM_REG(val) (1 << (val)) @@ -84,7 +87,7 @@ #define GL518_INIT_VIN_1 300 #define GL518_INIT_VIN_2 300 #define GL518_INIT_VIN_3 300 -#define GL518_INIT_VDD 300 +#define GL518_INIT_VDD 500 #define GL518_INIT_PERCENTAGE 10 @@ -313,8 +316,8 @@ int gl518_attach_adapter(struct i2c_adapter *adapter) (IN_TO_REG(GL518_INIT_VIN_MAX_3) << 8) | IN_TO_REG(GL518_INIT_VIN_MIN_3)); gl518_write_value(new_client,GL518_REG_VDD_LIMIT, - (IN_TO_REG(GL518_INIT_VDD_MAX) << 8) | - IN_TO_REG(GL518_INIT_VDD_MIN)); + (VDD_TO_REG(GL518_INIT_VDD_MAX) << 8) | + VDD_TO_REG(GL518_INIT_VDD_MIN)); /* Clear status register (bit 5=1), start (bit6=1) */ gl518_write_value(new_client,GL518_REG_CONF,0x24); gl518_write_value(new_client,GL518_REG_CONF,0x44); @@ -504,12 +507,15 @@ void gl518_vin(struct i2c_client *client, int operation, int ctl_name, *nrels_mag = 2; else if (operation == SENSORS_PROC_REAL_READ) { gl518_update_client(client); - results[0] = IN_FROM_REG(data->voltage_min[nr]); - results[1] = IN_FROM_REG(data->voltage_max[nr]); + results[0] = nr?IN_FROM_REG(data->voltage_min[nr]): + VDD_FROM_REG(data->voltage_min[nr]); + results[1] = nr?IN_FROM_REG(data->voltage_max[nr]): + VDD_FROM_REG(data->voltage_max[nr]); if ((data->revision == 0x00) && (nr != 3)) results[2] = 0; else - results[2] = IN_FROM_REG(data->voltage[nr]); + results[2] = nr?IN_FROM_REG(data->voltage[nr]): + VDD_FROM_REG(data->voltage[nr]); *nrels_mag = 3; } else if (operation == SENSORS_PROC_REAL_WRITE) { regnr=nr==0?GL518_REG_VDD_LIMIT:nr==1?GL518_REG_VIN1_LIMIT:nr==2? @@ -517,11 +523,11 @@ void gl518_vin(struct i2c_client *client, int operation, int ctl_name, if (*nrels_mag == 1) old = gl518_read_value(client,regnr) & 0xff00; if (*nrels_mag >= 2) { - data->voltage_max[nr] = IN_TO_REG(results[1]); + data->voltage_max[nr] = nr?IN_TO_REG(results[1]):VDD_TO_REG(results[1]); old = data->voltage_max[nr] << 8; } if (*nrels_mag >= 1) { - data->voltage_min[nr] = IN_TO_REG(results[0]); + data->voltage_min[nr] = nr?IN_TO_REG(results[0]):VDD_TO_REG(results[0]); old |= data->voltage_min[nr]; gl518_write_value(client,regnr,old); }