blob: 3c9a8a94753ff475757a799212c379f6cc074841 [file] [log] [blame]
Kalhan Trisaldac68312010-05-27 19:58:56 +02001/*
2 * emc1403.c - SMSC Thermal Driver
3 *
4 * Copyright (C) 2008 Intel Corp
5 *
6 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Kalhan Trisaldac68312010-05-27 19:58:56 +020021 */
22
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/slab.h>
26#include <linux/i2c.h>
27#include <linux/hwmon.h>
28#include <linux/hwmon-sysfs.h>
29#include <linux/err.h>
30#include <linux/sysfs.h>
31#include <linux/mutex.h>
Guenter Roeck4cab2592014-05-12 10:44:48 -070032#include <linux/regmap.h>
Kalhan Trisaldac68312010-05-27 19:58:56 +020033
34#define THERMAL_PID_REG 0xfd
35#define THERMAL_SMSC_ID_REG 0xfe
36#define THERMAL_REVISION_REG 0xff
37
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +020038enum emc1403_chip { emc1402, emc1403, emc1404 };
39
Kalhan Trisaldac68312010-05-27 19:58:56 +020040struct thermal_data {
Guenter Roeck4cab2592014-05-12 10:44:48 -070041 struct regmap *regmap;
Kalhan Trisaldac68312010-05-27 19:58:56 +020042 struct mutex mutex;
Guenter Roeck4cab2592014-05-12 10:44:48 -070043 const struct attribute_group *groups[4];
Kalhan Trisaldac68312010-05-27 19:58:56 +020044};
45
46static ssize_t show_temp(struct device *dev,
47 struct device_attribute *attr, char *buf)
48{
Kalhan Trisaldac68312010-05-27 19:58:56 +020049 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
Guenter Roeck454aee12013-09-29 11:49:53 -070050 struct thermal_data *data = dev_get_drvdata(dev);
Guenter Roeck4cab2592014-05-12 10:44:48 -070051 unsigned int val;
Guenter Roeck454aee12013-09-29 11:49:53 -070052 int retval;
Kalhan Trisaldac68312010-05-27 19:58:56 +020053
Guenter Roeck4cab2592014-05-12 10:44:48 -070054 retval = regmap_read(data->regmap, sda->index, &val);
Kalhan Trisaldac68312010-05-27 19:58:56 +020055 if (retval < 0)
56 return retval;
Guenter Roeck4cab2592014-05-12 10:44:48 -070057 return sprintf(buf, "%d000\n", val);
Kalhan Trisaldac68312010-05-27 19:58:56 +020058}
59
60static ssize_t show_bit(struct device *dev,
61 struct device_attribute *attr, char *buf)
62{
Kalhan Trisaldac68312010-05-27 19:58:56 +020063 struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr);
Guenter Roeck454aee12013-09-29 11:49:53 -070064 struct thermal_data *data = dev_get_drvdata(dev);
Guenter Roeck4cab2592014-05-12 10:44:48 -070065 unsigned int val;
Guenter Roeck454aee12013-09-29 11:49:53 -070066 int retval;
Kalhan Trisaldac68312010-05-27 19:58:56 +020067
Guenter Roeck4cab2592014-05-12 10:44:48 -070068 retval = regmap_read(data->regmap, sda->nr, &val);
Kalhan Trisaldac68312010-05-27 19:58:56 +020069 if (retval < 0)
70 return retval;
Guenter Roeck4cab2592014-05-12 10:44:48 -070071 return sprintf(buf, "%d\n", !!(val & sda->index));
Kalhan Trisaldac68312010-05-27 19:58:56 +020072}
73
74static ssize_t store_temp(struct device *dev,
75 struct device_attribute *attr, const char *buf, size_t count)
76{
77 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
Guenter Roeck454aee12013-09-29 11:49:53 -070078 struct thermal_data *data = dev_get_drvdata(dev);
Kalhan Trisaldac68312010-05-27 19:58:56 +020079 unsigned long val;
80 int retval;
81
Frans Meulenbroeks179c4fd2012-01-04 20:58:52 +010082 if (kstrtoul(buf, 10, &val))
Kalhan Trisaldac68312010-05-27 19:58:56 +020083 return -EINVAL;
Guenter Roeck4cab2592014-05-12 10:44:48 -070084 retval = regmap_write(data->regmap, sda->index,
85 DIV_ROUND_CLOSEST(val, 1000));
Kalhan Trisaldac68312010-05-27 19:58:56 +020086 if (retval < 0)
87 return retval;
88 return count;
89}
90
Alan Cox960f12f2010-08-14 21:08:49 +020091static ssize_t store_bit(struct device *dev,
92 struct device_attribute *attr, const char *buf, size_t count)
93{
Alan Cox960f12f2010-08-14 21:08:49 +020094 struct sensor_device_attribute_2 *sda = to_sensor_dev_attr_2(attr);
Guenter Roeck454aee12013-09-29 11:49:53 -070095 struct thermal_data *data = dev_get_drvdata(dev);
Alan Cox960f12f2010-08-14 21:08:49 +020096 unsigned long val;
97 int retval;
98
Frans Meulenbroeks179c4fd2012-01-04 20:58:52 +010099 if (kstrtoul(buf, 10, &val))
Alan Cox960f12f2010-08-14 21:08:49 +0200100 return -EINVAL;
101
Guenter Roeck4cab2592014-05-12 10:44:48 -0700102 retval = regmap_update_bits(data->regmap, sda->nr, sda->index,
103 val ? sda->index : 0);
Alan Cox960f12f2010-08-14 21:08:49 +0200104 if (retval < 0)
Guenter Roeck4cab2592014-05-12 10:44:48 -0700105 return retval;
106 return count;
Alan Cox960f12f2010-08-14 21:08:49 +0200107}
108
Kalhan Trisaldac68312010-05-27 19:58:56 +0200109static ssize_t show_hyst(struct device *dev,
110 struct device_attribute *attr, char *buf)
111{
Kalhan Trisaldac68312010-05-27 19:58:56 +0200112 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
Guenter Roeck454aee12013-09-29 11:49:53 -0700113 struct thermal_data *data = dev_get_drvdata(dev);
Guenter Roeck4cab2592014-05-12 10:44:48 -0700114 struct regmap *regmap = data->regmap;
115 unsigned int limit;
116 unsigned int hyst;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200117 int retval;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200118
Guenter Roeck4cab2592014-05-12 10:44:48 -0700119 retval = regmap_read(regmap, sda->index, &limit);
Kalhan Trisaldac68312010-05-27 19:58:56 +0200120 if (retval < 0)
121 return retval;
122
Guenter Roeck4cab2592014-05-12 10:44:48 -0700123 retval = regmap_read(regmap, 0x21, &hyst);
124 if (retval < 0)
125 return retval;
126
127 return sprintf(buf, "%d000\n", limit - hyst);
Kalhan Trisaldac68312010-05-27 19:58:56 +0200128}
129
130static ssize_t store_hyst(struct device *dev,
131 struct device_attribute *attr, const char *buf, size_t count)
132{
Kalhan Trisaldac68312010-05-27 19:58:56 +0200133 struct sensor_device_attribute *sda = to_sensor_dev_attr(attr);
Guenter Roeck454aee12013-09-29 11:49:53 -0700134 struct thermal_data *data = dev_get_drvdata(dev);
Guenter Roeck4cab2592014-05-12 10:44:48 -0700135 struct regmap *regmap = data->regmap;
136 unsigned int limit;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200137 int retval;
138 int hyst;
139 unsigned long val;
140
Frans Meulenbroeks179c4fd2012-01-04 20:58:52 +0100141 if (kstrtoul(buf, 10, &val))
Kalhan Trisaldac68312010-05-27 19:58:56 +0200142 return -EINVAL;
143
144 mutex_lock(&data->mutex);
Guenter Roeck4cab2592014-05-12 10:44:48 -0700145 retval = regmap_read(regmap, sda->index, &limit);
Kalhan Trisaldac68312010-05-27 19:58:56 +0200146 if (retval < 0)
147 goto fail;
148
Guenter Roeck4cab2592014-05-12 10:44:48 -0700149 hyst = limit * 1000 - val;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200150 hyst = DIV_ROUND_CLOSEST(hyst, 1000);
151 if (hyst < 0 || hyst > 255) {
152 retval = -ERANGE;
153 goto fail;
154 }
155
Guenter Roeck4cab2592014-05-12 10:44:48 -0700156 retval = regmap_write(regmap, 0x21, hyst);
157 if (retval == 0)
Kalhan Trisaldac68312010-05-27 19:58:56 +0200158 retval = count;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200159fail:
160 mutex_unlock(&data->mutex);
161 return retval;
162}
163
164/*
165 * Sensors. We pass the actual i2c register to the methods.
166 */
167
168static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR,
169 show_temp, store_temp, 0x06);
170static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR,
171 show_temp, store_temp, 0x05);
172static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
173 show_temp, store_temp, 0x20);
174static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0x00);
175static SENSOR_DEVICE_ATTR_2(temp1_min_alarm, S_IRUGO,
176 show_bit, NULL, 0x36, 0x01);
177static SENSOR_DEVICE_ATTR_2(temp1_max_alarm, S_IRUGO,
178 show_bit, NULL, 0x35, 0x01);
179static SENSOR_DEVICE_ATTR_2(temp1_crit_alarm, S_IRUGO,
180 show_bit, NULL, 0x37, 0x01);
181static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO | S_IWUSR,
182 show_hyst, store_hyst, 0x20);
183
184static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR,
185 show_temp, store_temp, 0x08);
186static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR,
187 show_temp, store_temp, 0x07);
188static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO | S_IWUSR,
189 show_temp, store_temp, 0x19);
190static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0x01);
191static SENSOR_DEVICE_ATTR_2(temp2_min_alarm, S_IRUGO,
192 show_bit, NULL, 0x36, 0x02);
193static SENSOR_DEVICE_ATTR_2(temp2_max_alarm, S_IRUGO,
194 show_bit, NULL, 0x35, 0x02);
195static SENSOR_DEVICE_ATTR_2(temp2_crit_alarm, S_IRUGO,
196 show_bit, NULL, 0x37, 0x02);
197static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IRUGO | S_IWUSR,
198 show_hyst, store_hyst, 0x19);
199
200static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR,
201 show_temp, store_temp, 0x16);
202static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR,
203 show_temp, store_temp, 0x15);
204static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO | S_IWUSR,
205 show_temp, store_temp, 0x1A);
206static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 0x23);
207static SENSOR_DEVICE_ATTR_2(temp3_min_alarm, S_IRUGO,
208 show_bit, NULL, 0x36, 0x04);
209static SENSOR_DEVICE_ATTR_2(temp3_max_alarm, S_IRUGO,
210 show_bit, NULL, 0x35, 0x04);
211static SENSOR_DEVICE_ATTR_2(temp3_crit_alarm, S_IRUGO,
212 show_bit, NULL, 0x37, 0x04);
213static SENSOR_DEVICE_ATTR(temp3_crit_hyst, S_IRUGO | S_IWUSR,
214 show_hyst, store_hyst, 0x1A);
215
Guenter Roeck0011ddf2013-09-29 13:20:53 -0700216static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR,
217 show_temp, store_temp, 0x2D);
218static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR,
219 show_temp, store_temp, 0x2C);
220static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO | S_IWUSR,
221 show_temp, store_temp, 0x30);
222static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 0x2A);
223static SENSOR_DEVICE_ATTR_2(temp4_min_alarm, S_IRUGO,
224 show_bit, NULL, 0x36, 0x08);
225static SENSOR_DEVICE_ATTR_2(temp4_max_alarm, S_IRUGO,
226 show_bit, NULL, 0x35, 0x08);
227static SENSOR_DEVICE_ATTR_2(temp4_crit_alarm, S_IRUGO,
228 show_bit, NULL, 0x37, 0x08);
229static SENSOR_DEVICE_ATTR(temp4_crit_hyst, S_IRUGO | S_IWUSR,
230 show_hyst, store_hyst, 0x30);
231
Alan Cox960f12f2010-08-14 21:08:49 +0200232static SENSOR_DEVICE_ATTR_2(power_state, S_IRUGO | S_IWUSR,
233 show_bit, store_bit, 0x03, 0x40);
234
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200235static struct attribute *emc1402_attrs[] = {
Kalhan Trisaldac68312010-05-27 19:58:56 +0200236 &sensor_dev_attr_temp1_min.dev_attr.attr,
237 &sensor_dev_attr_temp1_max.dev_attr.attr,
238 &sensor_dev_attr_temp1_crit.dev_attr.attr,
239 &sensor_dev_attr_temp1_input.dev_attr.attr,
Kalhan Trisaldac68312010-05-27 19:58:56 +0200240 &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr,
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200241
Kalhan Trisaldac68312010-05-27 19:58:56 +0200242 &sensor_dev_attr_temp2_min.dev_attr.attr,
243 &sensor_dev_attr_temp2_max.dev_attr.attr,
244 &sensor_dev_attr_temp2_crit.dev_attr.attr,
245 &sensor_dev_attr_temp2_input.dev_attr.attr,
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200246 &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr,
247
248 &sensor_dev_attr_power_state.dev_attr.attr,
249 NULL
250};
251
252static const struct attribute_group emc1402_group = {
253 .attrs = emc1402_attrs,
254};
255
256static struct attribute *emc1403_attrs[] = {
257 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
258 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
259 &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr,
260
Kalhan Trisaldac68312010-05-27 19:58:56 +0200261 &sensor_dev_attr_temp2_min_alarm.dev_attr.attr,
262 &sensor_dev_attr_temp2_max_alarm.dev_attr.attr,
263 &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr,
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200264
Kalhan Trisaldac68312010-05-27 19:58:56 +0200265 &sensor_dev_attr_temp3_min.dev_attr.attr,
266 &sensor_dev_attr_temp3_max.dev_attr.attr,
267 &sensor_dev_attr_temp3_crit.dev_attr.attr,
268 &sensor_dev_attr_temp3_input.dev_attr.attr,
269 &sensor_dev_attr_temp3_min_alarm.dev_attr.attr,
270 &sensor_dev_attr_temp3_max_alarm.dev_attr.attr,
271 &sensor_dev_attr_temp3_crit_alarm.dev_attr.attr,
272 &sensor_dev_attr_temp3_crit_hyst.dev_attr.attr,
Kalhan Trisaldac68312010-05-27 19:58:56 +0200273 NULL
274};
Guenter Roeck0011ddf2013-09-29 13:20:53 -0700275
276static const struct attribute_group emc1403_group = {
277 .attrs = emc1403_attrs,
278};
279
280static struct attribute *emc1404_attrs[] = {
281 &sensor_dev_attr_temp4_min.dev_attr.attr,
282 &sensor_dev_attr_temp4_max.dev_attr.attr,
283 &sensor_dev_attr_temp4_crit.dev_attr.attr,
284 &sensor_dev_attr_temp4_input.dev_attr.attr,
285 &sensor_dev_attr_temp4_min_alarm.dev_attr.attr,
286 &sensor_dev_attr_temp4_max_alarm.dev_attr.attr,
287 &sensor_dev_attr_temp4_crit_alarm.dev_attr.attr,
288 &sensor_dev_attr_temp4_crit_hyst.dev_attr.attr,
289 NULL
290};
291
292static const struct attribute_group emc1404_group = {
293 .attrs = emc1404_attrs,
294};
Kalhan Trisaldac68312010-05-27 19:58:56 +0200295
296static int emc1403_detect(struct i2c_client *client,
297 struct i2c_board_info *info)
298{
299 int id;
Jekyll Lai7a1b76f2011-01-12 21:55:12 +0100300 /* Check if thermal chip is SMSC and EMC1403 or EMC1423 */
Kalhan Trisaldac68312010-05-27 19:58:56 +0200301
302 id = i2c_smbus_read_byte_data(client, THERMAL_SMSC_ID_REG);
303 if (id != 0x5d)
304 return -ENODEV;
305
Jekyll Lai7a1b76f2011-01-12 21:55:12 +0100306 id = i2c_smbus_read_byte_data(client, THERMAL_PID_REG);
307 switch (id) {
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200308 case 0x20:
309 strlcpy(info->type, "emc1402", I2C_NAME_SIZE);
310 break;
Jekyll Lai7a1b76f2011-01-12 21:55:12 +0100311 case 0x21:
312 strlcpy(info->type, "emc1403", I2C_NAME_SIZE);
313 break;
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200314 case 0x22:
315 strlcpy(info->type, "emc1422", I2C_NAME_SIZE);
316 break;
Jekyll Lai7a1b76f2011-01-12 21:55:12 +0100317 case 0x23:
318 strlcpy(info->type, "emc1423", I2C_NAME_SIZE);
319 break;
Guenter Roeck0011ddf2013-09-29 13:20:53 -0700320 case 0x25:
321 strlcpy(info->type, "emc1404", I2C_NAME_SIZE);
322 break;
323 case 0x27:
324 strlcpy(info->type, "emc1424", I2C_NAME_SIZE);
325 break;
Jekyll Lai7a1b76f2011-01-12 21:55:12 +0100326 default:
Kalhan Trisaldac68312010-05-27 19:58:56 +0200327 return -ENODEV;
Jekyll Lai7a1b76f2011-01-12 21:55:12 +0100328 }
Kalhan Trisaldac68312010-05-27 19:58:56 +0200329
330 id = i2c_smbus_read_byte_data(client, THERMAL_REVISION_REG);
Josef Gajdusek3a18e132014-05-12 13:48:26 +0200331 if (id < 0x01 || id > 0x04)
Kalhan Trisaldac68312010-05-27 19:58:56 +0200332 return -ENODEV;
333
Kalhan Trisaldac68312010-05-27 19:58:56 +0200334 return 0;
335}
336
Guenter Roeck4cab2592014-05-12 10:44:48 -0700337static bool emc1403_regmap_is_volatile(struct device *dev, unsigned int reg)
338{
339 switch (reg) {
340 case 0x00: /* internal diode high byte */
341 case 0x01: /* external diode 1 high byte */
342 case 0x02: /* status */
343 case 0x10: /* external diode 1 low byte */
344 case 0x1b: /* external diode fault */
345 case 0x23: /* external diode 2 high byte */
346 case 0x24: /* external diode 2 low byte */
347 case 0x29: /* internal diode low byte */
348 case 0x2a: /* externl diode 3 high byte */
349 case 0x2b: /* external diode 3 low byte */
350 case 0x35: /* high limit status */
351 case 0x36: /* low limit status */
352 case 0x37: /* therm limit status */
353 return true;
354 default:
355 return false;
356 }
357}
358
359static struct regmap_config emc1403_regmap_config = {
360 .reg_bits = 8,
361 .val_bits = 8,
362 .cache_type = REGCACHE_RBTREE,
363 .volatile_reg = emc1403_regmap_is_volatile,
364};
365
Kalhan Trisaldac68312010-05-27 19:58:56 +0200366static int emc1403_probe(struct i2c_client *client,
367 const struct i2c_device_id *id)
368{
Kalhan Trisaldac68312010-05-27 19:58:56 +0200369 struct thermal_data *data;
Guenter Roeck454aee12013-09-29 11:49:53 -0700370 struct device *hwmon_dev;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200371
Guenter Roeck7b52eef2012-06-02 09:58:04 -0700372 data = devm_kzalloc(&client->dev, sizeof(struct thermal_data),
373 GFP_KERNEL);
374 if (data == NULL)
Kalhan Trisaldac68312010-05-27 19:58:56 +0200375 return -ENOMEM;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200376
Guenter Roeck4cab2592014-05-12 10:44:48 -0700377 data->regmap = devm_regmap_init_i2c(client, &emc1403_regmap_config);
378 if (IS_ERR(data->regmap))
379 return PTR_ERR(data->regmap);
380
Kalhan Trisaldac68312010-05-27 19:58:56 +0200381 mutex_init(&data->mutex);
Kalhan Trisaldac68312010-05-27 19:58:56 +0200382
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200383 switch (id->driver_data) {
384 case emc1404:
385 data->groups[2] = &emc1404_group;
386 case emc1403:
387 data->groups[1] = &emc1403_group;
388 case emc1402:
389 data->groups[0] = &emc1402_group;
390 }
Guenter Roeck0011ddf2013-09-29 13:20:53 -0700391
Jean Delvare8759f902014-05-12 11:44:51 +0200392 hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
393 client->name, data,
394 data->groups);
Guenter Roeck454aee12013-09-29 11:49:53 -0700395 if (IS_ERR(hwmon_dev))
396 return PTR_ERR(hwmon_dev);
397
Guenter Roeck0011ddf2013-09-29 13:20:53 -0700398 dev_info(&client->dev, "%s Thermal chip found\n", id->name);
Guenter Roeck7b52eef2012-06-02 09:58:04 -0700399 return 0;
Kalhan Trisaldac68312010-05-27 19:58:56 +0200400}
401
402static const unsigned short emc1403_address_list[] = {
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200403 0x18, 0x1c, 0x29, 0x4c, 0x4d, 0x5c, I2C_CLIENT_END
Kalhan Trisaldac68312010-05-27 19:58:56 +0200404};
405
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200406/* Last digit of chip name indicates number of channels */
Kalhan Trisaldac68312010-05-27 19:58:56 +0200407static const struct i2c_device_id emc1403_idtable[] = {
Josef Gajdusekbe7f5c42014-05-12 14:34:09 +0200408 { "emc1402", emc1402 },
409 { "emc1403", emc1403 },
410 { "emc1404", emc1404 },
411 { "emc1422", emc1402 },
412 { "emc1423", emc1403 },
413 { "emc1424", emc1404 },
Kalhan Trisaldac68312010-05-27 19:58:56 +0200414 { }
415};
416MODULE_DEVICE_TABLE(i2c, emc1403_idtable);
417
418static struct i2c_driver sensor_emc1403 = {
419 .class = I2C_CLASS_HWMON,
420 .driver = {
421 .name = "emc1403",
422 },
423 .detect = emc1403_detect,
424 .probe = emc1403_probe,
Kalhan Trisaldac68312010-05-27 19:58:56 +0200425 .id_table = emc1403_idtable,
426 .address_list = emc1403_address_list,
427};
428
Axel Linf0967ee2012-01-20 15:38:18 +0800429module_i2c_driver(sensor_emc1403);
Kalhan Trisaldac68312010-05-27 19:58:56 +0200430
431MODULE_AUTHOR("Kalhan Trisal <kalhan.trisal@intel.com");
432MODULE_DESCRIPTION("emc1403 Thermal Driver");
433MODULE_LICENSE("GPL v2");