adt7475.c (b70366e5d31788650b2a5cec5cd13ea80ac7e44a) adt7475.c (4e2496e419a159d907e744237384d3c1c103c76d)
1/*
2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
6 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
7 *
8 * Derived from the lm83 driver by Jean Delvare
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
1/*
2 * adt7475 - Thermal sensor driver for the ADT7475 chip and derivatives
3 * Copyright (C) 2007-2008, Advanced Micro Devices, Inc.
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
5 * Copyright (C) 2008 Hans de Goede <hdegoede@redhat.com>
6 * Copyright (C) 2009 Jean Delvare <jdelvare@suse.de>
7 *
8 * Derived from the lm83 driver by Jean Delvare
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/module.h>
16#include <linux/of_device.h>
16#include <linux/init.h>
17#include <linux/slab.h>
18#include <linux/i2c.h>
19#include <linux/hwmon.h>
20#include <linux/hwmon-sysfs.h>
21#include <linux/hwmon-vid.h>
22#include <linux/err.h>
23#include <linux/jiffies.h>

--- 132 unchanged lines hidden (view full) ---

156 { "adt7473", adt7473 },
157 { "adt7475", adt7475 },
158 { "adt7476", adt7476 },
159 { "adt7490", adt7490 },
160 { }
161};
162MODULE_DEVICE_TABLE(i2c, adt7475_id);
163
17#include <linux/init.h>
18#include <linux/slab.h>
19#include <linux/i2c.h>
20#include <linux/hwmon.h>
21#include <linux/hwmon-sysfs.h>
22#include <linux/hwmon-vid.h>
23#include <linux/err.h>
24#include <linux/jiffies.h>

--- 132 unchanged lines hidden (view full) ---

157 { "adt7473", adt7473 },
158 { "adt7475", adt7475 },
159 { "adt7476", adt7476 },
160 { "adt7490", adt7490 },
161 { }
162};
163MODULE_DEVICE_TABLE(i2c, adt7475_id);
164
165static const struct of_device_id adt7475_of_match[] = {
166 {
167 .compatible = "adi,adt7473",
168 .data = (void *)adt7473
169 },
170 {
171 .compatible = "adi,adt7475",
172 .data = (void *)adt7475
173 },
174 {
175 .compatible = "adi,adt7476",
176 .data = (void *)adt7476
177 },
178 {
179 .compatible = "adi,adt7490",
180 .data = (void *)adt7490
181 },
182 { },
183};
184MODULE_DEVICE_TABLE(of, adt7475_of_match);
185
164struct adt7475_data {
165 struct device *hwmon_dev;
166 struct mutex lock;
167
168 unsigned long measure_updated;
169 unsigned long limits_updated;
170 char valid;
171

--- 1073 unchanged lines hidden (view full) ---

1245 sysfs_remove_group(&client->dev.kobj, &in5_attr_group);
1246 if (data->has_vid)
1247 sysfs_remove_group(&client->dev.kobj, &vid_attr_group);
1248}
1249
1250static int adt7475_probe(struct i2c_client *client,
1251 const struct i2c_device_id *id)
1252{
186struct adt7475_data {
187 struct device *hwmon_dev;
188 struct mutex lock;
189
190 unsigned long measure_updated;
191 unsigned long limits_updated;
192 char valid;
193

--- 1073 unchanged lines hidden (view full) ---

1267 sysfs_remove_group(&client->dev.kobj, &in5_attr_group);
1268 if (data->has_vid)
1269 sysfs_remove_group(&client->dev.kobj, &vid_attr_group);
1270}
1271
1272static int adt7475_probe(struct i2c_client *client,
1273 const struct i2c_device_id *id)
1274{
1275 enum chips chip;
1253 static const char * const names[] = {
1254 [adt7473] = "ADT7473",
1255 [adt7475] = "ADT7475",
1256 [adt7476] = "ADT7476",
1257 [adt7490] = "ADT7490",
1258 };
1259
1260 struct adt7475_data *data;
1261 int i, ret = 0, revision;
1262 u8 config2, config3;
1263
1264 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
1265 if (data == NULL)
1266 return -ENOMEM;
1267
1268 mutex_init(&data->lock);
1269 i2c_set_clientdata(client, data);
1270
1276 static const char * const names[] = {
1277 [adt7473] = "ADT7473",
1278 [adt7475] = "ADT7475",
1279 [adt7476] = "ADT7476",
1280 [adt7490] = "ADT7490",
1281 };
1282
1283 struct adt7475_data *data;
1284 int i, ret = 0, revision;
1285 u8 config2, config3;
1286
1287 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
1288 if (data == NULL)
1289 return -ENOMEM;
1290
1291 mutex_init(&data->lock);
1292 i2c_set_clientdata(client, data);
1293
1294 if (client->dev.of_node)
1295 chip = (enum chips)of_device_get_match_data(&client->dev);
1296 else
1297 chip = id->driver_data;
1298
1271 /* Initialize device-specific values */
1299 /* Initialize device-specific values */
1272 switch (id->driver_data) {
1300 switch (chip) {
1273 case adt7476:
1274 data->has_voltage = 0x0e; /* in1 to in3 */
1275 revision = adt7475_read(REG_DEVID2) & 0x07;
1276 break;
1277 case adt7490:
1278 data->has_voltage = 0x3e; /* in1 to in5 */
1279 revision = adt7475_read(REG_DEVID2) & 0x03;
1280 if (revision == 0x03)

--- 142 unchanged lines hidden (view full) ---

1423
1424 return 0;
1425}
1426
1427static struct i2c_driver adt7475_driver = {
1428 .class = I2C_CLASS_HWMON,
1429 .driver = {
1430 .name = "adt7475",
1301 case adt7476:
1302 data->has_voltage = 0x0e; /* in1 to in3 */
1303 revision = adt7475_read(REG_DEVID2) & 0x07;
1304 break;
1305 case adt7490:
1306 data->has_voltage = 0x3e; /* in1 to in5 */
1307 revision = adt7475_read(REG_DEVID2) & 0x03;
1308 if (revision == 0x03)

--- 142 unchanged lines hidden (view full) ---

1451
1452 return 0;
1453}
1454
1455static struct i2c_driver adt7475_driver = {
1456 .class = I2C_CLASS_HWMON,
1457 .driver = {
1458 .name = "adt7475",
1459 .of_match_table = of_match_ptr(adt7475_of_match),
1431 },
1432 .probe = adt7475_probe,
1433 .remove = adt7475_remove,
1434 .id_table = adt7475_id,
1435 .detect = adt7475_detect,
1436 .address_list = normal_i2c,
1437};
1438

--- 193 unchanged lines hidden ---
1460 },
1461 .probe = adt7475_probe,
1462 .remove = adt7475_remove,
1463 .id_table = adt7475_id,
1464 .detect = adt7475_detect,
1465 .address_list = normal_i2c,
1466};
1467

--- 193 unchanged lines hidden ---