diff options
author | Guenter Roeck <linux@roeck-us.net> | 2013-09-29 16:20:53 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2013-10-18 12:12:04 -0400 |
commit | 0011ddfe6a03279fae60d237f2f4d0d7f7678928 (patch) | |
tree | 34c03087df0721b3e114b7f47031f1b71da2dc76 /drivers/hwmon | |
parent | 454aee17fd441b8ee8e956196dd3ddc9c8ee96d6 (diff) |
hwmon: (emc1403) Add support for EMC1404 and EMC1424
EMC1404 and EMC1424 are similar to EMC1403 and EMC1423,
but support an additional external temperature sensor.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/emc1403.c | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c index dc2a917a87bb..90ec1173b8a1 100644 --- a/drivers/hwmon/emc1403.c +++ b/drivers/hwmon/emc1403.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * | 21 | * |
22 | * TODO | 22 | * TODO |
23 | * - cache alarm and critical limit registers | 23 | * - cache alarm and critical limit registers |
24 | * - add emc1404 support | ||
25 | */ | 24 | */ |
26 | 25 | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
@@ -41,6 +40,7 @@ | |||
41 | 40 | ||
42 | struct thermal_data { | 41 | struct thermal_data { |
43 | struct i2c_client *client; | 42 | struct i2c_client *client; |
43 | const struct attribute_group *groups[3]; | ||
44 | struct mutex mutex; | 44 | struct mutex mutex; |
45 | /* | 45 | /* |
46 | * Cache the hyst value so we don't keep re-reading it. In theory | 46 | * Cache the hyst value so we don't keep re-reading it. In theory |
@@ -233,6 +233,22 @@ static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO, | |||
233 | static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO | S_IWUSR, | 233 | static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO | S_IWUSR, |
234 | show_hyst, store_hyst, 0x1A); | 234 | show_hyst, store_hyst, 0x1A); |
235 | 235 | ||
236 | static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR, | ||
237 | show_temp, store_temp, 0x2D); | ||
238 | static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR, | ||
239 | show_temp, store_temp, 0x2C); | ||
240 | static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO | S_IWUSR, | ||
241 | show_temp, store_temp, 0x30); | ||
242 | static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 0x2A); | ||
243 | static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO, | ||
244 | show_bit, NULL, 0x36, 0x08); | ||
245 | static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO, | ||
246 | show_bit, NULL, 0x35, 0x08); | ||
247 | static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO, | ||
248 | show_bit, NULL, 0x37, 0x08); | ||
249 | static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO | S_IWUSR, | ||
250 | show_hyst, store_hyst, 0x30); | ||
251 | |||
236 | static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR, | 252 | static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR, |
237 | show_bit, store_bit, 0x03, 0x40); | 253 | show_bit, store_bit, 0x03, 0x40); |
238 | 254 | ||
@@ -264,7 +280,26 @@ static struct attribute *emc1403_attrs[] = { | |||
264 | &sensor_dev_attr_power_state.dev_attr.attr, | 280 | &sensor_dev_attr_power_state.dev_attr.attr, |
265 | NULL | 281 | NULL |
266 | }; | 282 | }; |
267 | ATTRIBUTE_GROUPS(emc1403); | 283 | |
284 | static const struct attribute_group emc1403_group = { | ||
285 | .attrs = emc1403_attrs, | ||
286 | }; | ||
287 | |||
288 | static struct attribute *emc1404_attrs[] = { | ||
289 | &sensor_dev_attr_temp4_min.dev_attr.attr, | ||
290 | &sensor_dev_attr_temp4_max.dev_attr.attr, | ||
291 | &sensor_dev_attr_temp4_crit.dev_attr.attr, | ||
292 | &sensor_dev_attr_temp4_input.dev_attr.attr, | ||
293 | &sensor_dev_attr_temp4_min_alarm.dev_attr.attr, | ||
294 | &sensor_dev_attr_temp4_max_alarm.dev_attr.attr, | ||
295 | &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr, | ||
296 | &sensor_dev_attr_temp4_crit_hyst.dev_attr.attr, | ||
297 | NULL | ||
298 | }; | ||
299 | |||
300 | static const struct attribute_group emc1404_group = { | ||
301 | .attrs = emc1404_attrs, | ||
302 | }; | ||
268 | 303 | ||
269 | static int emc1403_detect(struct i2c_client *client, | 304 | static int emc1403_detect(struct i2c_client *client, |
270 | struct i2c_board_info *info) | 305 | struct i2c_board_info *info) |
@@ -284,10 +319,12 @@ static int emc1403_detect(struct i2c_client *client, | |||
284 | case 0x23: | 319 | case 0x23: |
285 | strlcpy(info->type, "emc1423", I2C_NAME_SIZE); | 320 | strlcpy(info->type, "emc1423", I2C_NAME_SIZE); |
286 | break; | 321 | break; |
287 | /* | 322 | case 0x25: |
288 | * Note: 0x25 is the 1404 which is very similar and this | 323 | strlcpy(info->type, "emc1404", I2C_NAME_SIZE); |
289 | * driver could be extended | 324 | break; |
290 | */ | 325 | case 0x27: |
326 | strlcpy(info->type, "emc1424", I2C_NAME_SIZE); | ||
327 | break; | ||
291 | default: | 328 | default: |
292 | return -ENODEV; | 329 | return -ENODEV; |
293 | } | 330 | } |
@@ -314,13 +351,17 @@ static int emc1403_probe(struct i2c_client *client, | |||
314 | mutex_init(&data->mutex); | 351 | mutex_init(&data->mutex); |
315 | data->hyst_valid = jiffies - 1; /* Expired */ | 352 | data->hyst_valid = jiffies - 1; /* Expired */ |
316 | 353 | ||
354 | data->groups[0] = &emc1403_group; | ||
355 | if (id->driver_data) | ||
356 | data->groups[1] = &emc1404_group; | ||
357 | |||
317 | hwmon_dev = hwmon_device_register_with_groups(&client->dev, | 358 | hwmon_dev = hwmon_device_register_with_groups(&client->dev, |
318 | client->name, data, | 359 | client->name, data, |
319 | emc1403_groups); | 360 | data->groups); |
320 | if (IS_ERR(hwmon_dev)) | 361 | if (IS_ERR(hwmon_dev)) |
321 | return PTR_ERR(hwmon_dev); | 362 | return PTR_ERR(hwmon_dev); |
322 | 363 | ||
323 | dev_info(&client->dev, "EMC1403 Thermal chip found\n"); | 364 | dev_info(&client->dev, "%s Thermal chip found\n", id->name); |
324 | return 0; | 365 | return 0; |
325 | } | 366 | } |
326 | 367 | ||
@@ -330,7 +371,9 @@ static const unsigned short emc1403_address_list[] = { | |||
330 | 371 | ||
331 | static const struct i2c_device_id emc1403_idtable[] = { | 372 | static const struct i2c_device_id emc1403_idtable[] = { |
332 | { "emc1403", 0 }, | 373 | { "emc1403", 0 }, |
374 | { "emc1404", 1 }, | ||
333 | { "emc1423", 0 }, | 375 | { "emc1423", 0 }, |
376 | { "emc1424", 1 }, | ||
334 | { } | 377 | { } |
335 | }; | 378 | }; |
336 | MODULE_DEVICE_TABLE(i2c, emc1403_idtable); | 379 | MODULE_DEVICE_TABLE(i2c, emc1403_idtable); |