aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/thmc50.c
diff options
context:
space:
mode:
authorKrzysztof Helt <krzysztof.h1@wp.pl>2007-08-22 14:05:22 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2007-10-09 22:56:29 -0400
commitdcf3b5fb7fb6e1b56bfaf705e665b04870213768 (patch)
tree3717c0f9b955dda6609784bad6ac587d5d333dca /drivers/hwmon/thmc50.c
parent6f9703d0be16f694ce24dde1ce1fc4a4e4e5ed55 (diff)
hwmon: (thmc50) add individual alarm & fault files
This patch adds individual alarm and fault files to the thmc50 driver. These sysfs entries are required for a new libsensors library. Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl> Acked-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/thmc50.c')
-rw-r--r--drivers/hwmon/thmc50.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/hwmon/thmc50.c b/drivers/hwmon/thmc50.c
index 9395b52d9b99..c920f394a5c2 100644
--- a/drivers/hwmon/thmc50.c
+++ b/drivers/hwmon/thmc50.c
@@ -46,6 +46,11 @@ I2C_CLIENT_MODULE_PARM(adm1022_temp3, "List of adapter,address pairs "
46#define THMC50_REG_COMPANY_ID 0x3E 46#define THMC50_REG_COMPANY_ID 0x3E
47#define THMC50_REG_DIE_CODE 0x3F 47#define THMC50_REG_DIE_CODE 0x3F
48#define THMC50_REG_ANALOG_OUT 0x19 48#define THMC50_REG_ANALOG_OUT 0x19
49/*
50 * We use mirror status register for reading alarms
51 * so ACPI can use the primary status register.
52 */
53#define THMC50_REG_INTR_MIRROR 0x4C
49 54
50const static u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 }; 55const static u8 THMC50_REG_TEMP[] = { 0x27, 0x26, 0x20 };
51const static u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C }; 56const static u8 THMC50_REG_TEMP_MIN[] = { 0x3A, 0x38, 0x2C };
@@ -69,6 +74,7 @@ struct thmc50_data {
69 s8 temp_max[3]; 74 s8 temp_max[3];
70 s8 temp_min[3]; 75 s8 temp_min[3];
71 u8 analog_out; 76 u8 analog_out;
77 u8 alarms;
72}; 78};
73 79
74static int thmc50_attach_adapter(struct i2c_adapter *adapter); 80static int thmc50_attach_adapter(struct i2c_adapter *adapter);
@@ -180,6 +186,15 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
180 return count; 186 return count;
181} 187}
182 188
189static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
190 char *buf)
191{
192 int index = to_sensor_dev_attr(attr)->index;
193 struct thmc50_data *data = thmc50_update_device(dev);
194
195 return sprintf(buf, "%u\n", (data->alarms >> index) & 1);
196}
197
183#define temp_reg(offset) \ 198#define temp_reg(offset) \
184static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \ 199static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp, \
185 NULL, offset - 1); \ 200 NULL, offset - 1); \
@@ -192,6 +207,12 @@ temp_reg(1);
192temp_reg(2); 207temp_reg(2);
193temp_reg(3); 208temp_reg(3);
194 209
210static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 0);
211static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
212static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 1);
213static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 7);
214static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_alarm, NULL, 2);
215
195static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_analog_out, 216static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_analog_out,
196 set_analog_out, 0); 217 set_analog_out, 0);
197static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0); 218static SENSOR_DEVICE_ATTR(pwm1_mode, S_IRUGO, show_pwm_mode, NULL, 0);
@@ -200,9 +221,12 @@ static struct attribute *thmc50_attributes[] = {
200 &sensor_dev_attr_temp1_max.dev_attr.attr, 221 &sensor_dev_attr_temp1_max.dev_attr.attr,
201 &sensor_dev_attr_temp1_min.dev_attr.attr, 222 &sensor_dev_attr_temp1_min.dev_attr.attr,
202 &sensor_dev_attr_temp1_input.dev_attr.attr, 223 &sensor_dev_attr_temp1_input.dev_attr.attr,
224 &sensor_dev_attr_temp1_alarm.dev_attr.attr,
203 &sensor_dev_attr_temp2_max.dev_attr.attr, 225 &sensor_dev_attr_temp2_max.dev_attr.attr,
204 &sensor_dev_attr_temp2_min.dev_attr.attr, 226 &sensor_dev_attr_temp2_min.dev_attr.attr,
205 &sensor_dev_attr_temp2_input.dev_attr.attr, 227 &sensor_dev_attr_temp2_input.dev_attr.attr,
228 &sensor_dev_attr_temp2_alarm.dev_attr.attr,
229 &sensor_dev_attr_temp2_fault.dev_attr.attr,
206 &sensor_dev_attr_pwm1.dev_attr.attr, 230 &sensor_dev_attr_pwm1.dev_attr.attr,
207 &sensor_dev_attr_pwm1_mode.dev_attr.attr, 231 &sensor_dev_attr_pwm1_mode.dev_attr.attr,
208 NULL 232 NULL
@@ -217,6 +241,8 @@ static struct attribute *adm1022_attributes[] = {
217 &sensor_dev_attr_temp3_max.dev_attr.attr, 241 &sensor_dev_attr_temp3_max.dev_attr.attr,
218 &sensor_dev_attr_temp3_min.dev_attr.attr, 242 &sensor_dev_attr_temp3_min.dev_attr.attr,
219 &sensor_dev_attr_temp3_input.dev_attr.attr, 243 &sensor_dev_attr_temp3_input.dev_attr.attr,
244 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
245 &sensor_dev_attr_temp3_fault.dev_attr.attr,
220 NULL 246 NULL
221}; 247};
222 248
@@ -414,6 +440,8 @@ static struct thmc50_data *thmc50_update_device(struct device *dev)
414 } 440 }
415 data->analog_out = 441 data->analog_out =
416 i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT); 442 i2c_smbus_read_byte_data(client, THMC50_REG_ANALOG_OUT);
443 data->alarms =
444 i2c_smbus_read_byte_data(client, THMC50_REG_INTR_MIRROR);
417 data->last_updated = jiffies; 445 data->last_updated = jiffies;
418 data->valid = 1; 446 data->valid = 1;
419 } 447 }