From 127249deb69e2d070772c74c2418b50b5acab4b3 Mon Sep 17 00:00:00 2001 From: "Mark D. Studebaker" Date: Sat, 21 Sep 2002 22:09:09 +0000 Subject: [PATCH] add multiple VRM support to lm87; patch from Dave Johnson git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1544 7894878c-1315-0410-8ee3-d5d059ff63e0 --- doc/vid | 4 ++-- kernel/chips/lm87.c | 39 ++++++++++++++++++++++++++++++--------- kernel/include/sensors.h | 3 ++- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/doc/vid b/doc/vid index b6b67b52..8b47f570 100644 --- a/doc/vid +++ b/doc/vid @@ -86,12 +86,12 @@ For those that do, the VRM support status is listed below. The following chip drivers support all the VRM versions via /etc/sensors.conf and the vrm entry in /proc: - adm1025, w83781d + adm1025, w83781d, lm87 The following chip drivers support only VRM 8.2 and cannot be changed: - adm1024, it87, lm87, mtp008 + adm1024, it87, mtp008 adm9240, gl520sm, lm78, maxilife If you have a board with one of these chips which needs advanced diff --git a/kernel/chips/lm87.c b/kernel/chips/lm87.c index e5184e79..4e6a3ea4 100644 --- a/kernel/chips/lm87.c +++ b/kernel/chips/lm87.c @@ -34,6 +34,7 @@ #include #include "version.h" #include "sensors.h" +#include "sensors_vid.h" #include /* Chip configuration settings. These should be set to reflect the @@ -204,9 +205,6 @@ extern inline u8 FAN_TO_REG(long rpm, int div) #define DIV_FROM_REG(val) (1 << (val)) #define DIV_TO_REG(val) ((val)==1?0:((val)==8?3:((val)==4?2:1))) -#define VID_FROM_REG(val) ((val)==0x1f?0:(val)>=0x10?510-(val)*10:\ - 205-(val)*5) - #define LM87_INIT_FAN_MIN 3000 #define LM87_INIT_EXT_TEMP_MAX 600 @@ -258,6 +256,7 @@ struct lm87_data { u16 alarms; /* Register encoding, combined */ u8 analog_out; /* Register value */ u8 vid; /* Register value combined */ + u8 vrm; /* VRM version * 10 */ }; #ifdef MODULE @@ -303,6 +302,8 @@ static void lm87_analog_out(struct i2c_client *client, int operation, long *results); static void lm87_vid(struct i2c_client *client, int operation, int ctl_name, int *nrels_mag, long *results); +static void lm87_vrm(struct i2c_client *client, int operation, + int ctl_name, int *nrels_mag, long *results); /* I choose here for semi-static LM87 allocation. Complete dynamic allocation could also be used; the code needed for this would probably @@ -382,6 +383,8 @@ static ctl_table LM87_dir_table_template[] = { &i2c_sysctl_real, NULL, &lm87_analog_out}, {LM87_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &i2c_proc_real, &i2c_sysctl_real, NULL, &lm87_vid}, + {LM87_SYSCTL_VRM, "vrm", NULL, 0, 0644, NULL, &i2c_proc_real, + &i2c_sysctl_real, NULL, &lm87_vrm}, {0} }; @@ -536,6 +539,7 @@ int lm87_write_value(struct i2c_client *client, u8 reg, u8 value) /* Called when we have found a new LM87. It should set limits, etc. */ void lm87_init_client(struct i2c_client *client) { + struct lm87_data *data = client->data; int vid; u8 v; @@ -597,11 +601,13 @@ void lm87_init_client(struct i2c_client *client) v = (lm87_read_value(client, LM87_REG_VID_FAN_DIV) & 0x0f) | ((lm87_read_value(client, LM87_REG_VID4) & 0x01) << 4 ); - vid = VID_FROM_REG(v); - v = vid * 95 * 192 / 27000; + data->vrm = DEFAULT_VRM; + vid = vid_from_reg(v, data->vrm); + + v = vid * 95 * 192 / 270000; lm87_write_value(client, LM87_REG_IN_MIN(1), v); lm87_write_value(client, LM87_REG_IN_MIN(5), v); - v = vid * 105 * 192 / 27000; + v = vid * 105 * 192 / 270000; lm87_write_value(client, LM87_REG_IN_MAX(1), v); lm87_write_value(client, LM87_REG_IN_MAX(5), v); @@ -1012,11 +1018,26 @@ void lm87_vid(struct i2c_client *client, int operation, int ctl_name, struct lm87_data *data = client->data; if (operation == SENSORS_PROC_REAL_INFO) - *nrels_mag = 2; + *nrels_mag = 3; else if (operation == SENSORS_PROC_REAL_READ) { lm87_update_client(client); - results[0] = VID_FROM_REG(data->vid); - *nrels_mag = 1; + results[0] = vid_from_reg(data->vid, data->vrm); + *nrels_mag = 1; + } +} + +void lm87_vrm(struct i2c_client *client, int operation, int ctl_name, + int *nrels_mag, long *results) +{ + struct lm87_data *data = client->data; + if (operation == SENSORS_PROC_REAL_INFO) + *nrels_mag = 1; + else if (operation == SENSORS_PROC_REAL_READ) { + results[0] = data->vrm; + *nrels_mag = 1; + } else if (operation == SENSORS_PROC_REAL_WRITE) { + if (*nrels_mag >= 1) + data->vrm = results[0]; } } diff --git a/kernel/include/sensors.h b/kernel/include/sensors.h index ca3ea700..ba2a0058 100644 --- a/kernel/include/sensors.h +++ b/kernel/include/sensors.h @@ -69,7 +69,7 @@ #define W83781D_SYSCTL_TEMP1 1200 /* Degrees Celcius * 10 */ #define W83781D_SYSCTL_TEMP2 1201 /* Degrees Celcius * 10 */ #define W83781D_SYSCTL_TEMP3 1202 /* Degrees Celcius * 10 */ -#define W83781D_SYSCTL_VID 1300 /* Volts * 100 */ +#define W83781D_SYSCTL_VID 1300 /* Volts * 1000 */ #define W83781D_SYSCTL_VRM 1301 #define W83781D_SYSCTL_PWM1 1401 #define W83781D_SYSCTL_PWM2 1402 @@ -414,6 +414,7 @@ #define LM87_SYSCTL_ALARMS 2001 /* bitvector */ #define LM87_SYSCTL_ANALOG_OUT 2002 #define LM87_SYSCTL_VID 2003 +#define LM87_SYSCTL_VRM 2004 #define LM87_ALARM_IN0 0x0001 #define LM87_ALARM_IN1 0x0002