From 184cb1e3c747b9f3ff3feb58ebc14f7558e9d095 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 23 Feb 2006 23:11:17 +0000 Subject: [PATCH] Use real-time alarm registers instead of interrupt registers for W83782D, W83627HF, W83783S and W83791D. This is a backport from Linux 2.6. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@3260 7894878c-1315-0410-8ee3-d5d059ff63e0 --- kernel/chips/w83781d.c | 61 +++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/kernel/chips/w83781d.c b/kernel/chips/w83781d.c index 5235e98f..e931ad80 100644 --- a/kernel/chips/w83781d.c +++ b/kernel/chips/w83781d.c @@ -108,11 +108,21 @@ MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization"); #define W83781D_REG_BANK 0x4E #define W83781D_REG_CONFIG 0x40 + +/* Interrupt status (W83781D, AS99127F) */ #define W83781D_REG_ALARM1 0x41 #define W83781D_REG_ALARM2 0x42 -#define W83781D_REG_ALARM3 0x450 /* not on W83781D */ -#define W83781D_REG_IRQ 0x4C +/* Real-time status (W83782D, W83783S, W83627HF) */ +#define W83782D_REG_ALARM1 0x459 +#define W83782D_REG_ALARM2 0x45A +#define W83782D_REG_ALARM3 0x45B + +/* Real-time status (W83791D) */ +#define W83791D_REG_ALARM1 0xA9 +#define W83791D_REG_ALARM2 0xAA +#define W83791D_REG_ALARM3 0xAB + #define W83781D_REG_BEEP_CONFIG 0x4D #define W83781D_REG_BEEP_INTS1 0x56 #define W83781D_REG_BEEP_INTS2 0x57 @@ -1269,14 +1279,6 @@ static void w83781d_init_client(struct i2c_client *client) w83781d_write_value(client, W83781D_REG_TEMP3_CONFIG, 0x00); } - if (type != w83781d) { - /* enable comparator mode for temp2 and temp3 so - alarm indication will work correctly */ - i = w83781d_read_value(client, W83781D_REG_IRQ); - if (!(i & 0x40)) - w83781d_write_value(client, W83781D_REG_IRQ, - i | 0x40); - } } /* Start monitoring */ @@ -1386,15 +1388,36 @@ static void w83781d_update_client(struct i2c_client *client) data->fan_div[1] |= (i >> 4) & 0x04; data->fan_div[2] |= (i >> 5) & 0x04; } - data->alarms = - w83781d_read_value(client, - W83781D_REG_ALARM1) + - (w83781d_read_value(client, W83781D_REG_ALARM2) << 8); - if ((data->type == w83782d) || (data->type == w83627hf)) { - data->alarms |= - w83781d_read_value(client, - W83781D_REG_ALARM3) << 16; - } + + if ((data->type == w83782d) || (data->type == w83627hf)) { + data->alarms = w83781d_read_value(client, + W83782D_REG_ALARM1) + | (w83781d_read_value(client, + W83782D_REG_ALARM2) << 8) + | (w83781d_read_value(client, + W83782D_REG_ALARM3) << 16); + } else if (data->type == w83783s) { + /* Only two real-time status registers */ + data->alarms = w83781d_read_value(client, + W83782D_REG_ALARM1) + | (w83781d_read_value(client, + W83782D_REG_ALARM2) << 8); + } else if (data->type == w83791d) { + data->alarms = w83781d_read_value(client, + W83791D_REG_ALARM1) + | (w83781d_read_value(client, + W83791D_REG_ALARM2) << 8) + | (w83781d_read_value(client, + W83791D_REG_ALARM3) << 16); + } else { + /* No real-time status registers, fall back to + interrupt status registers */ + data->alarms = w83781d_read_value(client, + W83781D_REG_ALARM1) + | (w83781d_read_value(client, + W83781D_REG_ALARM2) << 8); + } + i = w83781d_read_value(client, W83781D_REG_BEEP_INTS2); data->beep_enable = i >> 7; data->beeps = ((i & 0x7f) << 8) +