* [lm-sensors] [PATCH 0/4] hwmon: (w83791d) refresh fandiv patch
@ 2008-08-05 22:29 Marc Hulsman
2008-08-06 6:51 ` Hans de Goede
2008-09-30 13:48 ` Jean Delvare
0 siblings, 2 replies; 3+ messages in thread
From: Marc Hulsman @ 2008-08-05 22:29 UTC (permalink / raw)
To: lm-sensors
[-- Attachment #1: Type: text/plain, Size: 4126 bytes --]
The following series of patches apply to the new-style version of the w83791d
driver, with the earlier submitted fandiv patch applied. Hereby for
convenience a refreshed version of that patch which applies cleanly to the
current driver.
Marc
---
Update w83791d with fan bits in vbat mon register (7.48 of the
datasheet). This change allows all fans to have a divisor of 128,
and fixes a problem with incorrectly reported fan speeds.
Signed-off-by: Marc Hulsman <m.hulsman@tudelft.nl>
Acked-by: Jean Delvare <khali@linux-fr.org>
---
Documentation/hwmon/w83791d | 6 +++---
drivers/hwmon/w83791d.c | 24 ++++++++++++++++++++----
2 files changed, 23 insertions(+), 7 deletions(-)
---
diff -uprN linux-2.6.26-rc1-git6/drivers/hwmon/w83791d.c
linux-2.6.26-rc1-git6-modified2/drivers/hwmon/w83791d.c
--- linux-2.6.26-rc1-git6/drivers/hwmon/w83791d.c 2008-05-03
20:59:44.000000000 +0200
+++ linux-2.6.26-rc1-git6-modified2/drivers/hwmon/w83791d.c 2008-05-16
22:13:15.000000000 +0200
@@ -233,11 +233,9 @@ static u8 fan_to_reg(long rpm, int div)
static u8 div_to_reg(int nr, long val)
{
int i;
- int max;
- /* first three fan's divisor max out at 8, rest max out at 128 */
- max = (nr < 3) ? 8 : 128;
- val = SENSORS_LIMIT(val, 1, max) >> 1;
+ /* fan divisors max out at 128 */
+ val = SENSORS_LIMIT(val, 1, 128) >> 1;
for (i = 0; i < 7; i++) {
if (val == 0)
break;
@@ -519,6 +517,7 @@ static ssize_t store_fan_div(struct devi
unsigned long min;
u8 tmp_fan_div;
u8 fan_div_reg;
+ u8 vbat_reg;
int indx = 0;
u8 keep_mask = 0;
u8 new_shift = 0;
@@ -570,6 +569,16 @@ static ssize_t store_fan_div(struct devi
w83791d_write(client, W83791D_REG_FAN_DIV[indx],
fan_div_reg | tmp_fan_div);
+ /* Bit 2 of fans 0-2 is stored in the vbat register (bits 5-7) */
+ if (nr < 3) {
+ keep_mask = ~(1 << (nr + 5));
+ vbat_reg = w83791d_read(client, W83791D_REG_VBAT)
+ & keep_mask;
+ tmp_fan_div = (data->fan_div[nr] << (3 + nr)) & ~keep_mask;
+ w83791d_write(client, W83791D_REG_VBAT,
+ vbat_reg | tmp_fan_div);
+ }
+
/* Restore fan_min */
data->fan_min[nr] = fan_to_reg(min, DIV_FROM_REG(data->fan_div[nr]));
w83791d_write(client, W83791D_REG_FAN_MIN[nr], data->fan_min[nr]);
@@ -1245,6 +1254,7 @@ static struct w83791d_data *w83791d_upda
struct w83791d_data *data = i2c_get_clientdata(client);
int i, j;
u8 reg_array_tmp[3];
+ u8 vbat_reg;
mutex_lock(&data->update_lock);
@@ -1282,6 +1292,12 @@ static struct w83791d_data *w83791d_upda
data->fan_div[3] = reg_array_tmp[2] & 0x07;
data->fan_div[4] = (reg_array_tmp[2] >> 4) & 0x07;
+ /* The fan divisor for fans 0-2 get bit 2 from
+ bits 5-7 respectively of vbat register */
+ vbat_reg = w83791d_read(client, W83791D_REG_VBAT);
+ for (i = 0; i < 3; i++)
+ data->fan_div[i] |= (vbat_reg >> (3 + i)) & 0x04;
+
/* Update the first temperature sensor */
for (i = 0; i < 3; i++) {
data->temp1[i] = w83791d_read(client,
diff -uprN linux-2.6.26-rc1-git6/Documentation/hwmon/w83791d
linux-2.6.26-rc1-git6-modified2/Documentation/hwmon/w83791d
--- linux-2.6.26-rc1-git6/Documentation/hwmon/w83791d 2008-05-03
20:59:44.000000000 +0200
+++ linux-2.6.26-rc1-git6-modified2/Documentation/hwmon/w83791d 2008-05-16
22:10:16.000000000 +0200
@@ -22,6 +22,7 @@ Credits:
Additional contributors:
Sven Anders <anders@anduras.de>
+ Marc Hulsman <m.hulsman@tudelft.nl>
Module Parameters
-----------------
@@ -67,9 +68,8 @@ on until the temperature falls below the
Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
triggered if the rotation speed has dropped below a programmable limit. Fan
-readings can be divided by a programmable divider (1, 2, 4, 8 for fan 1/2/3
-and 1, 2, 4, 8, 16, 32, 64 or 128 for fan 4/5) to give the readings more
-range or accuracy.
+readings can be divided by a programmable divider (1, 2, 4, 8, 16,
+32, 64 or 128 for all fans) to give the readings more range or accuracy.
Voltage sensors (also known as IN sensors) report their values in millivolts.
An alarm is triggered if the voltage has crossed a programmable minimum
[-- Attachment #2: w83791d_fandiv.patch --]
[-- Type: text/x-diff, Size: 3868 bytes --]
Update w83791d with fan bits in vbat mon register (7.48 of the
datasheet). This change allows all fans to have a divisor of 128,
and fixes a problem with incorrectly reported fan speeds.
Signed-off-by: Marc Hulsman <m.hulsman@tudelft.nl>
Acked-by: Jean Delvare <khali@linux-fr.org>
---
Documentation/hwmon/w83791d | 6 +++---
drivers/hwmon/w83791d.c | 24 ++++++++++++++++++++----
2 files changed, 23 insertions(+), 7 deletions(-)
---
diff -uprN linux-2.6.26-rc1-git6/drivers/hwmon/w83791d.c linux-2.6.26-rc1-git6-modified2/drivers/hwmon/w83791d.c
--- linux-2.6.26-rc1-git6/drivers/hwmon/w83791d.c 2008-05-03 20:59:44.000000000 +0200
+++ linux-2.6.26-rc1-git6-modified2/drivers/hwmon/w83791d.c 2008-05-16 22:13:15.000000000 +0200
@@ -233,11 +233,9 @@ static u8 fan_to_reg(long rpm, int div)
static u8 div_to_reg(int nr, long val)
{
int i;
- int max;
- /* first three fan's divisor max out at 8, rest max out at 128 */
- max = (nr < 3) ? 8 : 128;
- val = SENSORS_LIMIT(val, 1, max) >> 1;
+ /* fan divisors max out at 128 */
+ val = SENSORS_LIMIT(val, 1, 128) >> 1;
for (i = 0; i < 7; i++) {
if (val == 0)
break;
@@ -519,6 +517,7 @@ static ssize_t store_fan_div(struct devi
unsigned long min;
u8 tmp_fan_div;
u8 fan_div_reg;
+ u8 vbat_reg;
int indx = 0;
u8 keep_mask = 0;
u8 new_shift = 0;
@@ -570,6 +569,16 @@ static ssize_t store_fan_div(struct devi
w83791d_write(client, W83791D_REG_FAN_DIV[indx],
fan_div_reg | tmp_fan_div);
+ /* Bit 2 of fans 0-2 is stored in the vbat register (bits 5-7) */
+ if (nr < 3) {
+ keep_mask = ~(1 << (nr + 5));
+ vbat_reg = w83791d_read(client, W83791D_REG_VBAT)
+ & keep_mask;
+ tmp_fan_div = (data->fan_div[nr] << (3 + nr)) & ~keep_mask;
+ w83791d_write(client, W83791D_REG_VBAT,
+ vbat_reg | tmp_fan_div);
+ }
+
/* Restore fan_min */
data->fan_min[nr] = fan_to_reg(min, DIV_FROM_REG(data->fan_div[nr]));
w83791d_write(client, W83791D_REG_FAN_MIN[nr], data->fan_min[nr]);
@@ -1245,6 +1254,7 @@ static struct w83791d_data *w83791d_upda
struct w83791d_data *data = i2c_get_clientdata(client);
int i, j;
u8 reg_array_tmp[3];
+ u8 vbat_reg;
mutex_lock(&data->update_lock);
@@ -1282,6 +1292,12 @@ static struct w83791d_data *w83791d_upda
data->fan_div[3] = reg_array_tmp[2] & 0x07;
data->fan_div[4] = (reg_array_tmp[2] >> 4) & 0x07;
+ /* The fan divisor for fans 0-2 get bit 2 from
+ bits 5-7 respectively of vbat register */
+ vbat_reg = w83791d_read(client, W83791D_REG_VBAT);
+ for (i = 0; i < 3; i++)
+ data->fan_div[i] |= (vbat_reg >> (3 + i)) & 0x04;
+
/* Update the first temperature sensor */
for (i = 0; i < 3; i++) {
data->temp1[i] = w83791d_read(client,
diff -uprN linux-2.6.26-rc1-git6/Documentation/hwmon/w83791d linux-2.6.26-rc1-git6-modified2/Documentation/hwmon/w83791d
--- linux-2.6.26-rc1-git6/Documentation/hwmon/w83791d 2008-05-03 20:59:44.000000000 +0200
+++ linux-2.6.26-rc1-git6-modified2/Documentation/hwmon/w83791d 2008-05-16 22:10:16.000000000 +0200
@@ -22,6 +22,7 @@ Credits:
Additional contributors:
Sven Anders <anders@anduras.de>
+ Marc Hulsman <m.hulsman@tudelft.nl>
Module Parameters
-----------------
@@ -67,9 +68,8 @@ on until the temperature falls below the
Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
triggered if the rotation speed has dropped below a programmable limit. Fan
-readings can be divided by a programmable divider (1, 2, 4, 8 for fan 1/2/3
-and 1, 2, 4, 8, 16, 32, 64 or 128 for fan 4/5) to give the readings more
-range or accuracy.
+readings can be divided by a programmable divider (1, 2, 4, 8, 16,
+32, 64 or 128 for all fans) to give the readings more range or accuracy.
Voltage sensors (also known as IN sensors) report their values in millivolts.
An alarm is triggered if the voltage has crossed a programmable minimum
[-- Attachment #3: Type: text/plain, Size: 153 bytes --]
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] [PATCH 0/4] hwmon: (w83791d) refresh fandiv patch
2008-08-05 22:29 [lm-sensors] [PATCH 0/4] hwmon: (w83791d) refresh fandiv patch Marc Hulsman
@ 2008-08-06 6:51 ` Hans de Goede
2008-09-30 13:48 ` Jean Delvare
1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2008-08-06 6:51 UTC (permalink / raw)
To: lm-sensors
Marc Hulsman wrote:
> The following series of patches apply to the new-style version of the w83791d
> driver, with the earlier submitted fandiv patch applied. Hereby for
> convenience a refreshed version of that patch which applies cleanly to the
> current driver.
>
> Marc
>
Marc,
Unfortunately Mark Hofmann has stepped down as hwmon maintainer due to lack of
time, I see that these patches have been Acked-by Jean. Can you please send
them directly to Andrew Morton (with a CC to the lm-sensors list) for 2.6.27
inclusion? Sending patches to Andrew now is the path for hwmon-patches to get
them included in Linus tree.
Regards,
Hans
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [lm-sensors] [PATCH 0/4] hwmon: (w83791d) refresh fandiv patch
2008-08-05 22:29 [lm-sensors] [PATCH 0/4] hwmon: (w83791d) refresh fandiv patch Marc Hulsman
2008-08-06 6:51 ` Hans de Goede
@ 2008-09-30 13:48 ` Jean Delvare
1 sibling, 0 replies; 3+ messages in thread
From: Jean Delvare @ 2008-09-30 13:48 UTC (permalink / raw)
To: lm-sensors
Hi Hans, Marc,
On Wed, 06 Aug 2008 08:51:06 +0200, Hans de Goede wrote:
> Marc Hulsman wrote:
> > The following series of patches apply to the new-style version of the w83791d
> > driver, with the earlier submitted fandiv patch applied. Hereby for
> > convenience a refreshed version of that patch which applies cleanly to the
> > current driver.
>
> Unfortunately Mark Hofmann has stepped down as hwmon maintainer due to lack of
> time, I see that these patches have been Acked-by Jean. Can you please send
> them directly to Andrew Morton (with a CC to the lm-sensors list) for 2.6.27
> inclusion? Sending patches to Andrew now is the path for hwmon-patches to get
> them included in Linus tree.
I'm looking at these patches now, and will add them to my hwmon tree if
I see no problem with them. This will then go in kernel 2.6.28 - it's
too late for 2.6.27, sorry.
--
Jean Delvare
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-30 13:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-05 22:29 [lm-sensors] [PATCH 0/4] hwmon: (w83791d) refresh fandiv patch Marc Hulsman
2008-08-06 6:51 ` Hans de Goede
2008-09-30 13:48 ` Jean Delvare
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.