* [lm-sensors] [PATCH] w83627ehf: Add alarms support
@ 2006-03-22 21:06 Jean Delvare
2006-03-22 22:12 ` Rudolf Marek
2006-03-23 6:13 ` Ymu
0 siblings, 2 replies; 3+ messages in thread
From: Jean Delvare @ 2006-03-22 21:06 UTC (permalink / raw)
To: lm-sensors
Hi all,
Here is a patch adding alarms support to the w83627ehf driver. It
applies on top of Yuan Mu's patch converting the driver to use arrays
of attributes [1] and Rudolf Marek's patch adding voltage inputs
support [2]. Owners of W83627EHF/EHG chips are invited to give it
testing and report how it works. Note that you'll need lm_sensors2 CVS
on the user-space side.
[1] http://khali.linux-fr.org/devel/i2c/linux-2.6/hwmon-w83627ehf-use-attr-arrays.patch
[2] http://khali.linux-fr.org/devel/i2c/linux-2.6/hwmon-w83627ehf-add-voltages.patch
Add alarms support for the W83627EHF/EHG hardware monitoring chip.
This is based on an earlier patch from Rudolf Marek.
Signed-off-by: Rudolf Marek <r.marek at sh.cvut.cz>
Signed-off-by: Jean Delvare <khali at linux-fr.org>
---
drivers/hwmon/w83627ehf.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
--- linux-2.6.16.orig/drivers/hwmon/w83627ehf.c 2006-03-22 09:24:57.000000000 +0100
+++ linux-2.6.16/drivers/hwmon/w83627ehf.c 2006-03-22 14:40:53.000000000 +0100
@@ -141,6 +141,10 @@
#define W83627EHF_REG_DIODE 0x59
#define W83627EHF_REG_SMI_OVT 0x4C
+#define W83627EHF_REG_ALARM1 0x459
+#define W83627EHF_REG_ALARM2 0x45A
+#define W83627EHF_REG_ALARM3 0x45B
+
/*
* Conversions
*/
@@ -218,6 +222,7 @@
s16 temp[2];
s16 temp_max[2];
s16 temp_max_hyst[2];
+ u32 alarms;
};
static inline int is_word_sized(u16 reg)
@@ -427,6 +432,13 @@
W83627EHF_REG_TEMP_HYST[i]);
}
+ data->alarms = w83627ehf_read_value(client,
+ W83627EHF_REG_ALARM1) |
+ (w83627ehf_read_value(client,
+ W83627EHF_REG_ALARM2) << 8) |
+ (w83627ehf_read_value(client,
+ W83627EHF_REG_ALARM3) << 16);
+
data->last_updated = jiffies;
data->valid = 1;
}
@@ -474,6 +486,14 @@
store_in_reg(MIN, min)
store_in_reg(MAX, max)
+static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct w83627ehf_data *data = w83627ehf_update_device(dev);
+ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+ int nr = sensor_attr->index;
+ return sprintf(buf, "%u\n", (data->alarms >> nr) & 0x01);
+}
+
static struct sensor_device_attribute sda_in_input[] = {
SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0),
SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1),
@@ -487,6 +507,19 @@
SENSOR_ATTR(in9_input, S_IRUGO, show_in, NULL, 9),
};
+static struct sensor_device_attribute sda_in_alarm[] = {
+ SENSOR_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0),
+ SENSOR_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1),
+ SENSOR_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2),
+ SENSOR_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3),
+ SENSOR_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 8),
+ SENSOR_ATTR(in5_alarm, S_IRUGO, show_alarm, NULL, 21),
+ SENSOR_ATTR(in6_alarm, S_IRUGO, show_alarm, NULL, 20),
+ SENSOR_ATTR(in7_alarm, S_IRUGO, show_alarm, NULL, 16),
+ SENSOR_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 17),
+ SENSOR_ATTR(in9_alarm, S_IRUGO, show_alarm, NULL, 19),
+};
+
static struct sensor_device_attribute sda_in_min[] = {
SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0),
SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1),
@@ -516,6 +549,7 @@
static void device_create_file_in(struct device *dev, int i)
{
device_create_file(dev, &sda_in_input[i].dev_attr);
+ device_create_file(dev, &sda_in_alarm[i].dev_attr);
device_create_file(dev, &sda_in_min[i].dev_attr);
device_create_file(dev, &sda_in_max[i].dev_attr);
}
@@ -618,6 +652,14 @@
SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4),
};
+static struct sensor_device_attribute sda_fan_alarm[] = {
+ SENSOR_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6),
+ SENSOR_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7),
+ SENSOR_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 10),
+ SENSOR_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 11),
+ SENSOR_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 23),
+};
+
static struct sensor_device_attribute sda_fan_min[] = {
SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min,
store_fan_min, 0),
@@ -642,6 +684,7 @@
static void device_create_file_fan(struct device *dev, int i)
{
device_create_file(dev, &sda_fan_input[i].dev_attr);
+ device_create_file(dev, &sda_fan_alarm[i].dev_attr);
device_create_file(dev, &sda_fan_div[i].dev_attr);
device_create_file(dev, &sda_fan_min[i].dev_attr);
}
@@ -729,6 +772,9 @@
store_temp_max_hyst, 0),
SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst,
store_temp_max_hyst, 1),
+ SENSOR_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4),
+ SENSOR_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5),
+ SENSOR_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13),
};
/*
--
Jean Delvare
^ permalink raw reply [flat|nested] 3+ messages in thread* [lm-sensors] [PATCH] w83627ehf: Add alarms support
2006-03-22 21:06 [lm-sensors] [PATCH] w83627ehf: Add alarms support Jean Delvare
@ 2006-03-22 22:12 ` Rudolf Marek
2006-03-23 6:13 ` Ymu
1 sibling, 0 replies; 3+ messages in thread
From: Rudolf Marek @ 2006-03-22 22:12 UTC (permalink / raw)
To: lm-sensors
Hi Jean,
> Here is a patch adding alarms support to the w83627ehf driver. It
> applies on top of Yuan Mu's patch converting the driver to use arrays
> of attributes [1] and Rudolf Marek's patch adding voltage inputs
> support [2]. Owners of W83627EHF/EHG chips are invited to give it
> testing and report how it works. Note that you'll need lm_sensors2 CVS
> on the user-space side.
I added to CVS sensors.conf.eg some voltage formulas too.
>
> [1] http://khali.linux-fr.org/devel/i2c/linux-2.6/hwmon-w83627ehf-use-attr-arrays.patch
> [2] http://khali.linux-fr.org/devel/i2c/linux-2.6/hwmon-w83627ehf-add-voltages.patch
Much more is needed:
Order:
1 hwmon-allow-sensor-attr-arrays.patch
2 hwmon-convert-semaphores-to-mutexes.patch
5 hwmon-w83627ehf-add-alarms.patch
4 hwmon-w83627ehf-add-voltages.patch
3 hwmon-w83627ehf-use-attr-arrays.patch
Some other drivers will fail to patch but it does not matter.
I did the testing except the fan4/fan5 which look OK anyway.
(I did not try the voltage alarms, I assume you did not changed the numbers)
There is only one problem:
> + SENSOR_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 10),
> + SENSOR_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 11),
10 and 11 needs to be swapped.
Thank you for the patch.
regards
Rudolf
^ permalink raw reply [flat|nested] 3+ messages in thread
* [lm-sensors] [PATCH] w83627ehf: Add alarms support
2006-03-22 21:06 [lm-sensors] [PATCH] w83627ehf: Add alarms support Jean Delvare
2006-03-22 22:12 ` Rudolf Marek
@ 2006-03-23 6:13 ` Ymu
1 sibling, 0 replies; 3+ messages in thread
From: Ymu @ 2006-03-23 6:13 UTC (permalink / raw)
To: lm-sensors
Hello all,
> Much more is needed:
>
> Order:
> 1 hwmon-allow-sensor-attr-arrays.patch
> 2 hwmon-convert-semaphores-to-mutexes.patch
> 5 hwmon-w83627ehf-add-alarms.patch
> 4 hwmon-w83627ehf-add-voltages.patch
> 3 hwmon-w83627ehf-use-attr-arrays.patch
>
> Some other drivers will fail to patch but it does not matter.
>
> I did the testing except the fan4/fan5 which look OK anyway.
I did not try fan5.
> (I did not try the voltage alarms, I assume you did not changed the
numbers)
>
> There is only one problem:
>
> > + SENSOR_ATTR(fan3_alarm, S_IRUGO, show_alarm, NULL, 10),
> > + SENSOR_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 11),
> 10 and 11 needs to be swapped.
Yes :)
I have tested the patches just now, it works well for me, and I like one
file per sensor too, all wonderful, thank you!
Best Regards
Yuan Mu
=============================================The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Winbond is strictly prohibited; and any information in this email irrelevant to the official business of Winbond shall be deemed as neither given nor endorsed by Winbond.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-03-23 6:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-22 21:06 [lm-sensors] [PATCH] w83627ehf: Add alarms support Jean Delvare
2006-03-22 22:12 ` Rudolf Marek
2006-03-23 6:13 ` Ymu
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.