aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Gajdusek <atx@atx.name>2014-05-12 08:34:09 -0400
committerGuenter Roeck <linux@roeck-us.net>2014-05-21 19:02:23 -0400
commitbe7f5c4d48e05cb6753d17eb09bea3c38db2ec6f (patch)
tree026da64841bfc309520de0b097f8248f64dfc0a5
parent962a75a2d5c15ac98cc58139c0067708190c4d15 (diff)
hwmon: (emc1403) Add support for emc14x2
Add support for emc1402/emc1412/emc1422 temperature monitoring chips. This line of sensors only has 2 temperature channels (internal and external) in comparison to the emc14x3 (3 channels) and emc14x4 (4 channels). Signed-off-by: Josef Gajdusek <atx@atx.name> [Guenter Roeck: ordered i2c address list, updated description/headline] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--drivers/hwmon/emc1403.c58
1 files changed, 43 insertions, 15 deletions
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 01723f04fe45..0bb0bab60163 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -38,9 +38,11 @@
38#define THERMAL_SMSC_ID_REG 0xfe 38#define THERMAL_SMSC_ID_REG 0xfe
39#define THERMAL_REVISION_REG 0xff 39#define THERMAL_REVISION_REG 0xff
40 40
41enum emc1403_chip { emc1402, emc1403, emc1404 };
42
41struct thermal_data { 43struct thermal_data {
42 struct i2c_client *client; 44 struct i2c_client *client;
43 const struct attribute_group *groups[3]; 45 const struct attribute_group *groups[4];
44 struct mutex mutex; 46 struct mutex mutex;
45 /* 47 /*
46 * Cache the hyst value so we don't keep re-reading it. In theory 48 * Cache the hyst value so we don't keep re-reading it. In theory
@@ -252,23 +254,36 @@ static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO | S_IWUSR,
252static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR, 254static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR,
253 show_bit, store_bit, 0x03, 0x40); 255 show_bit, store_bit, 0x03, 0x40);
254 256
255static struct attribute *emc1403_attrs[] = { 257static struct attribute *emc1402_attrs[] = {
256 &sensor_dev_attr_temp1_min.dev_attr.attr, 258 &sensor_dev_attr_temp1_min.dev_attr.attr,
257 &sensor_dev_attr_temp1_max.dev_attr.attr, 259 &sensor_dev_attr_temp1_max.dev_attr.attr,
258 &sensor_dev_attr_temp1_crit.dev_attr.attr, 260 &sensor_dev_attr_temp1_crit.dev_attr.attr,
259 &sensor_dev_attr_temp1_input.dev_attr.attr, 261 &sensor_dev_attr_temp1_input.dev_attr.attr,
260 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
261 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
262 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
263 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, 262 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
263
264 &sensor_dev_attr_temp2_min.dev_attr.attr, 264 &sensor_dev_attr_temp2_min.dev_attr.attr,
265 &sensor_dev_attr_temp2_max.dev_attr.attr, 265 &sensor_dev_attr_temp2_max.dev_attr.attr,
266 &sensor_dev_attr_temp2_crit.dev_attr.attr, 266 &sensor_dev_attr_temp2_crit.dev_attr.attr,
267 &sensor_dev_attr_temp2_input.dev_attr.attr, 267 &sensor_dev_attr_temp2_input.dev_attr.attr,
268 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr,
269
270 &sensor_dev_attr_power_state.dev_attr.attr,
271 NULL
272};
273
274static const struct attribute_group emc1402_group = {
275 .attrs = emc1402_attrs,
276};
277
278static struct attribute *emc1403_attrs[] = {
279 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
280 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
281 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
282
268 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, 283 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
269 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, 284 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
270 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, 285 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
271 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, 286
272 &sensor_dev_attr_temp3_min.dev_attr.attr, 287 &sensor_dev_attr_temp3_min.dev_attr.attr,
273 &sensor_dev_attr_temp3_max.dev_attr.attr, 288 &sensor_dev_attr_temp3_max.dev_attr.attr,
274 &sensor_dev_attr_temp3_crit.dev_attr.attr, 289 &sensor_dev_attr_temp3_crit.dev_attr.attr,
@@ -277,7 +292,6 @@ static struct attribute *emc1403_attrs[] = {
277 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr, 292 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
278 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr, 293 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
279 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr, 294 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr,
280 &sensor_dev_attr_power_state.dev_attr.attr,
281 NULL 295 NULL
282}; 296};
283 297
@@ -313,9 +327,15 @@ static int emc1403_detect(struct i2c_client *client,
313 327
314 id = i2c_smbus_read_byte_data(client, THERMAL_PID_REG); 328 id = i2c_smbus_read_byte_data(client, THERMAL_PID_REG);
315 switch (id) { 329 switch (id) {
330 case 0x20:
331 strlcpy(info->type, "emc1402", I2C_NAME_SIZE);
332 break;
316 case 0x21: 333 case 0x21:
317 strlcpy(info->type, "emc1403", I2C_NAME_SIZE); 334 strlcpy(info->type, "emc1403", I2C_NAME_SIZE);
318 break; 335 break;
336 case 0x22:
337 strlcpy(info->type, "emc1422", I2C_NAME_SIZE);
338 break;
319 case 0x23: 339 case 0x23:
320 strlcpy(info->type, "emc1423", I2C_NAME_SIZE); 340 strlcpy(info->type, "emc1423", I2C_NAME_SIZE);
321 break; 341 break;
@@ -351,9 +371,14 @@ static int emc1403_probe(struct i2c_client *client,
351 mutex_init(&data->mutex); 371 mutex_init(&data->mutex);
352 data->hyst_valid = jiffies - 1; /* Expired */ 372 data->hyst_valid = jiffies - 1; /* Expired */
353 373
354 data->groups[0] = &emc1403_group; 374 switch (id->driver_data) {
355 if (id->driver_data) 375 case emc1404:
356 data->groups[1] = &emc1404_group; 376 data->groups[2] = &emc1404_group;
377 case emc1403:
378 data->groups[1] = &emc1403_group;
379 case emc1402:
380 data->groups[0] = &emc1402_group;
381 }
357 382
358 hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev, 383 hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
359 client->name, data, 384 client->name, data,
@@ -366,14 +391,17 @@ static int emc1403_probe(struct i2c_client *client,
366} 391}
367 392
368static const unsigned short emc1403_address_list[] = { 393static const unsigned short emc1403_address_list[] = {
369 0x18, 0x29, 0x4c, 0x4d, I2C_CLIENT_END 394 0x18, 0x1c, 0x29, 0x4c, 0x4d, 0x5c, I2C_CLIENT_END
370}; 395};
371 396
397/* Last digit of chip name indicates number of channels */
372static const struct i2c_device_id emc1403_idtable[] = { 398static const struct i2c_device_id emc1403_idtable[] = {
373 { "emc1403", 0 }, 399 { "emc1402", emc1402 },
374 { "emc1404", 1 }, 400 { "emc1403", emc1403 },
375 { "emc1423", 0 }, 401 { "emc1404", emc1404 },
376 { "emc1424", 1 }, 402 { "emc1422", emc1402 },
403 { "emc1423", emc1403 },
404 { "emc1424", emc1404 },
377 { } 405 { }
378}; 406};
379MODULE_DEVICE_TABLE(i2c, emc1403_idtable); 407MODULE_DEVICE_TABLE(i2c, emc1403_idtable);