mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-24 12:04:33 +00:00
(Kyösti) Modified gl518sm to use entries in /etc/sensors.conf.
Some small bugfixes, but temperature and fan alarms still don't work as documented. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@213 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
0ee18505f5
commit
90c8bc2ff6
2 files changed
+54
-33
No files matched your search
+22
-2
@@ -198,9 +198,29 @@ chip "lm78-*" "lm78-j-*" "lm79-*" "w83781d-*" "sis5595-*"
|
||||
|
||||
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.
|
||||
# Factors and labels taken from GL518SM datasheet, they give
|
||||
# reasonable values with my Eisca Fan78
|
||||
|
||||
label vdd "+5V"
|
||||
label vin1 "+3.3V"
|
||||
label vin2 "+12V"
|
||||
label vin3 "Vcore"
|
||||
|
||||
# vdd is internally attenuated to 4 volts
|
||||
# vin2 depends on external resistors.
|
||||
# vin1 and vin3 require no scaling
|
||||
|
||||
compute vdd (5/4)*@ , @/(5/4)
|
||||
compute vin2 (197/47)*@ , @/(197/47)
|
||||
|
||||
set vdd_min 4.8
|
||||
set vdd_max 5.2
|
||||
set vin1_min 3.20
|
||||
set vin1_max 3.40
|
||||
set vin2_min 11.0
|
||||
set vin2_max 13.0
|
||||
set vin3_min 2.10
|
||||
set vin3_max 2.30
|
||||
|
||||
chip "lm80-*"
|
||||
|
||||
|
||||
+32
-31
@@ -26,6 +26,9 @@
|
||||
#include "version.h"
|
||||
|
||||
|
||||
/* I wonder why my fan doesn't alarm */
|
||||
#define DEGUG_FAN 1
|
||||
|
||||
/* Many GL518 constants specified below */
|
||||
|
||||
/* The GL518 registers */
|
||||
@@ -51,21 +54,16 @@
|
||||
#define GL518_REG_VIN1 0x14
|
||||
#define GL518_REG_VDD 0x15
|
||||
|
||||
|
||||
/* Conversions. Rounding is only done on the TO_REG variants. */
|
||||
#define TEMP_TO_REG(val) (((((val)<0?(val)-5:(val)+5) / 10) + 119) & 0xff)
|
||||
#define TEMP_TO_REG(val) (((val) / 10 + 119) & 0xff)
|
||||
#define TEMP_FROM_REG(val) (((val) - 119) * 10)
|
||||
|
||||
#define FAN_TO_REG(val,div) (((val)==0?255:\
|
||||
(960000+((val)*(div)))/(2*(val)*(div))) & 0xff)
|
||||
#define FAN_TO_REG(val,div) \
|
||||
(((val)==0?255:(960000/(2*(val)*(div)))) & 0xff)
|
||||
#define FAN_FROM_REG(val,div) ((val)==0?0:(val)==255?0:960000/(2*(val)*(div)))
|
||||
|
||||
#define IN_TO_REG(val) ((((val)*10+8)/19) & 0xff)
|
||||
#define IN_TO_REG(val) ((((val)*10)/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,10 +82,10 @@
|
||||
#define GL518_INIT_FAN_MIN_2 3000
|
||||
|
||||
/* What are sane values for these?!? */
|
||||
#define GL518_INIT_VIN_1 300
|
||||
#define GL518_INIT_VIN_2 300
|
||||
#define GL518_INIT_VIN_3 300
|
||||
#define GL518_INIT_VDD 500
|
||||
#define GL518_INIT_VIN_1 330 /* 3.3 V */
|
||||
#define GL518_INIT_VIN_2 286 /* 12 V */
|
||||
#define GL518_INIT_VIN_3 260 /* Vcore */
|
||||
#define GL518_INIT_VDD 400 /* 5 V */
|
||||
|
||||
#define GL518_INIT_PERCENTAGE 10
|
||||
|
||||
@@ -316,8 +314,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,
|
||||
(VDD_TO_REG(GL518_INIT_VDD_MAX) << 8) |
|
||||
VDD_TO_REG(GL518_INIT_VDD_MIN));
|
||||
(IN_TO_REG(GL518_INIT_VDD_MAX) << 8) |
|
||||
IN_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);
|
||||
@@ -445,10 +443,16 @@ void gl518_update_client(struct i2c_client *client)
|
||||
data->voltage_max[3] = (val >> 8) & 0xff;
|
||||
|
||||
val = gl518_read_value(client,GL518_REG_FAN_COUNT);
|
||||
#if DEBUG_FAN
|
||||
printk("fan counts register: 0x%4x\n", val);
|
||||
#endif
|
||||
data->fan[0] = (val >> 8) & 0xff;
|
||||
data->fan[1] = val & 0xff;
|
||||
|
||||
val = gl518_read_value(client,GL518_REG_FAN_LIMIT);
|
||||
#if DEBUG_FAN
|
||||
printk("fan limits register: 0x%4x\n", val);
|
||||
#endif
|
||||
data->fan_min[0] = (val >> 8) & 0xff;
|
||||
data->fan_min[1] = val & 0xff;
|
||||
|
||||
@@ -460,8 +464,8 @@ void gl518_update_client(struct i2c_client *client)
|
||||
data->beeps = gl518_read_value(client,GL518_REG_ALARM);
|
||||
|
||||
val = gl518_read_value(client,GL518_REG_MISC);
|
||||
data->fan_div[0] = (val >> 4) & 0x03;
|
||||
data->fan_div[1] = (val >> 6) & 0x03;
|
||||
data->fan_div[0] = (val >> 6) & 0x03;
|
||||
data->fan_div[1] = (val >> 4) & 0x03;
|
||||
data->beep_enable = (gl518_read_value(client,GL518_REG_CONF) >> 2) & 1;
|
||||
|
||||
data->last_updated = jiffies;
|
||||
@@ -490,8 +494,8 @@ void gl518_temp(struct i2c_client *client, int operation, int ctl_name,
|
||||
gl518_write_value(client,GL518_REG_TEMP_OVER,data->temp_over);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->temp_over = TEMP_TO_REG(results[1]);
|
||||
gl518_write_value(client,GL518_REG_TEMP_HYST,data->temp_over);
|
||||
data->temp_hyst = TEMP_TO_REG(results[1]);
|
||||
gl518_write_value(client,GL518_REG_TEMP_HYST,data->temp_hyst);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -507,15 +511,12 @@ 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] = 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]);
|
||||
results[0] = IN_FROM_REG(data->voltage_min[nr]);
|
||||
results[1] = IN_FROM_REG(data->voltage_max[nr]);
|
||||
if ((data->revision == 0x00) && (nr != 3))
|
||||
results[2] = 0;
|
||||
else
|
||||
results[2] = nr?IN_FROM_REG(data->voltage[nr]):
|
||||
VDD_FROM_REG(data->voltage[nr]);
|
||||
results[2] = IN_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?
|
||||
@@ -523,11 +524,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] = nr?IN_TO_REG(results[1]):VDD_TO_REG(results[1]);
|
||||
data->voltage_max[nr] = IN_TO_REG(results[1]);
|
||||
old = data->voltage_max[nr] << 8;
|
||||
}
|
||||
if (*nrels_mag >= 1) {
|
||||
data->voltage_min[nr] = nr?IN_TO_REG(results[0]):VDD_TO_REG(results[0]);
|
||||
data->voltage_min[nr] = IN_TO_REG(results[0]);
|
||||
old |= data->voltage_min[nr];
|
||||
gl518_write_value(client,regnr,old);
|
||||
}
|
||||
@@ -547,7 +548,7 @@ void gl518_fan(struct i2c_client *client, int operation, int ctl_name,
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
gl518_update_client(client);
|
||||
results[0] = FAN_FROM_REG(data->fan_min[nr],
|
||||
DIV_FROM_REG(data->fan_div[nr]));
|
||||
DIV_FROM_REG(data->fan_div[nr]));
|
||||
results[1] = FAN_FROM_REG(data->fan[nr],DIV_FROM_REG(data->fan_div[nr]));
|
||||
*nrels_mag = 2;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
@@ -619,13 +620,13 @@ void gl518_fan_div(struct i2c_client *client, int operation, int ctl_name,
|
||||
old = gl518_read_value(client,GL518_REG_MISC);
|
||||
if (*nrels_mag >= 2) {
|
||||
data->fan_div[1] = DIV_TO_REG(results[1]);
|
||||
old = (old & 0x3f) | (data->fan_div[1] << 6);
|
||||
old = (old & 0xcf) | (data->fan_div[1] << 4);
|
||||
}
|
||||
if (*nrels_mag >= 1) {
|
||||
data->fan_div[0] = DIV_TO_REG(results[0]);
|
||||
old = (old & 0xcf) | (data->fan_div[0] << 4);
|
||||
gl518_write_value(client,GL518_REG_MISC,old);
|
||||
old = (old & 0x3f) | (data->fan_div[0] << 6);
|
||||
}
|
||||
gl518_write_value(client,GL518_REG_MISC,old);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user