aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Coulson <rob.coulson@gmail.com>2013-05-16 18:10:41 -0400
committerGuenter Roeck <linux@roeck-us.net>2013-06-27 13:29:02 -0400
commit79c1cc1c90c0ccaddd20965ea19205c54addd5f7 (patch)
tree0a1de32d3c503e2eaf56130a315b9753530f3b68
parent3a8fe3315571e896489d2e271ffe7f935bfc5ce8 (diff)
hwmon: (ds1621) Add ds1631 chip support to ds1621 driver and documentation
Add definitions, information, and code for ds1631 chip support to the ds1621 driver. Signed-off-by: Robert Coulson <rob.coulson@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r--Documentation/hwmon/ds162127
-rw-r--r--drivers/hwmon/Kconfig1
-rw-r--r--drivers/hwmon/ds1621.c27
3 files changed, 45 insertions, 10 deletions
diff --git a/Documentation/hwmon/ds1621 b/Documentation/hwmon/ds1621
index b61e77c6b1cb..1ebaa2485770 100644
--- a/Documentation/hwmon/ds1621
+++ b/Documentation/hwmon/ds1621
@@ -14,6 +14,11 @@ Supported chips:
14 Addresses scanned: I2C 0x48 - 0x4f 14 Addresses scanned: I2C 0x48 - 0x4f
15 Datasheet: Publicly available from www.datasheetarchive.com 15 Datasheet: Publicly available from www.datasheetarchive.com
16 16
17 * Maxim Integrated DS1631
18 Prefix: 'ds1631'
19 Addresses scanned: I2C 0x48 - 0x4f
20 Datasheet: Publicly available from www.maximintegrated.com
21
17 * Maxim Integrated DS1721 22 * Maxim Integrated DS1721
18 Prefix: 'ds1721' 23 Prefix: 'ds1721'
19 Addresses scanned: I2C 0x48 - 0x4f 24 Addresses scanned: I2C 0x48 - 0x4f
@@ -69,7 +74,15 @@ Temperature conversion of the DS1621 takes up to 1000ms; internal access to
69non-volatile registers may last for 10ms or below. 74non-volatile registers may last for 10ms or below.
70 75
71The DS1625 is pin compatible and functionally equivalent with the DS1621, 76The DS1625 is pin compatible and functionally equivalent with the DS1621,
72but the DS1621 is meant to replace it. 77but the DS1621 is meant to replace it. The DS1631 and DS1721 are also
78pin compatible with the DS1621, but provide multi-resolution support.
79
80Since there is no version register, there is no unique identification
81for these devices. In addition, the DS1631 and DS1721 will emulate a
82DS1621 device, if not explicitly instantiated (why? because the detect
83function compares the temperature register values bits and checks for a
849-bit resolution). Therefore, for correct device identification and
85functionality, explicit device instantiation is required.
73 86
74The DS1721 is pin compatible with the DS1621, has an accuracy of +/- 1.0 87The DS1721 is pin compatible with the DS1621, has an accuracy of +/- 1.0
75degree Celsius over a -10 to +85 degree range, a minimum/maximum alarm 88degree Celsius over a -10 to +85 degree range, a minimum/maximum alarm
@@ -78,9 +91,17 @@ time of 750ms.
78 91
79In addition, the DS1721 supports four resolution settings from 9 to 12 bits 92In addition, the DS1721 supports four resolution settings from 9 to 12 bits
80(defined in degrees C per LSB: 0.5, 0.25, 0.125, and 0.0625, respectifully), 93(defined in degrees C per LSB: 0.5, 0.25, 0.125, and 0.0625, respectifully),
81that are set at device power on to the highest resolution: 12-bits (0.0625 degree C). 94that are set at device power on to the highest resolution: 12-bits.
95
96One additional note about the ds1721 is that although the data sheet says
97the temperature flags (THF and TLF) are used internally, these flags do
98get set and cleared as the actual temperature crosses the min or max settings.
99
100The DS1631 is also pin compatible with the DS1621 and feature compatible with
101the DS1721, however the DS1631 accuracy is +/- 0.5 degree Celsius over the
102same range.
82 103
83Changing the DS1721 resolution mode affects the conversion time and can be 104Changing the DS1631/1721 resolution mode affects the conversion time and can be
84done from userspace, via the device 'update_interval' sysfs attribute. This 105done from userspace, via the device 'update_interval' sysfs attribute. This
85attribute will normalize range of input values to the device maximum resolution 106attribute will normalize range of input values to the device maximum resolution
86values defined in the datasheet as such: 107values defined in the datasheet as such:
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 0114ed4b3c07..4f713705d373 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -355,6 +355,7 @@ config SENSORS_DS1621
355 Integrated DS1621 sensor chips and compatible models including: 355 Integrated DS1621 sensor chips and compatible models including:
356 356
357 - Dallas Semiconductor DS1625 357 - Dallas Semiconductor DS1625
358 - Maxim Integrated DS1631
358 - Maxim Integrated DS1721 359 - Maxim Integrated DS1721
359 360
360 This driver can also be built as a module. If so, the module 361 This driver can also be built as a module. If so, the module
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index b5d80fb851d0..98adf77fdc84 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -10,8 +10,8 @@
10 * resolution, a thermal alarm output (Tout), and user-defined minimum 10 * resolution, a thermal alarm output (Tout), and user-defined minimum
11 * and maximum temperature thresholds (TH and TL). 11 * and maximum temperature thresholds (TH and TL).
12 * 12 *
13 * The DS1625 and DS1721 are pin compatible with the DS1621 and similar 13 * The DS1625, DS1631, and DS1721 are pin compatible with the DS1621 and
14 * in operation, with slight variations as noted in the device 14 * similar in operation, with slight variations as noted in the device
15 * datasheets (please refer to www.maximintegrated.com for specific 15 * datasheets (please refer to www.maximintegrated.com for specific
16 * device information). 16 * device information).
17 * 17 *
@@ -51,7 +51,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
51 0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 51 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
52 52
53/* Supported devices */ 53/* Supported devices */
54enum chips { ds1621, ds1625, ds1721 }; 54enum chips { ds1621, ds1625, ds1631, ds1721 };
55 55
56/* Insmod parameters */ 56/* Insmod parameters */
57static int polarity = -1; 57static int polarity = -1;
@@ -69,6 +69,10 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
69 * 7 6 5 4 3 2 1 0 69 * 7 6 5 4 3 2 1 0
70 * |Done|THF |TLF |NVB | 1 | 0 |POL |1SHOT| 70 * |Done|THF |TLF |NVB | 1 | 0 |POL |1SHOT|
71 * 71 *
72 * - DS1631:
73 * 7 6 5 4 3 2 1 0
74 * |Done|THF |TLF |NVB | R1 | R0 |POL |1SHOT|
75 *
72 * - DS1721: 76 * - DS1721:
73 * 7 6 5 4 3 2 1 0 77 * 7 6 5 4 3 2 1 0
74 * |Done| X | X | U | R1 | R0 |POL |1SHOT| 78 * |Done| X | X | U | R1 | R0 |POL |1SHOT|
@@ -139,8 +143,8 @@ static inline int DS1621_TEMP_FROM_REG(u16 reg)
139/* 143/*
140 * TEMP: 0.001C/bit (-55C to +125C) 144 * TEMP: 0.001C/bit (-55C to +125C)
141 * REG: 145 * REG:
142 * - 1621, 1625: x = 0.5C 146 * - 1621, 1625: 0.5C/bit
143 * - 1721: x = 0.0625C 147 * - 1631, 1721: 0.0625C/bit
144 * Assume highest resolution and let the bits fall where they may.. 148 * Assume highest resolution and let the bits fall where they may..
145 */ 149 */
146static inline u16 DS1621_TEMP_TO_REG(long temp) 150static inline u16 DS1621_TEMP_TO_REG(long temp)
@@ -174,6 +178,7 @@ static void ds1621_init_client(struct i2c_client *client)
174 data->update_interval = DS1625_CONVERSION_MAX; 178 data->update_interval = DS1625_CONVERSION_MAX;
175 sreg = DS1621_COM_START; 179 sreg = DS1621_COM_START;
176 break; 180 break;
181 case ds1631:
177 case ds1721: 182 case ds1721:
178 resol = (new_conf & DS1621_REG_CONFIG_RESOL) >> 183 resol = (new_conf & DS1621_REG_CONFIG_RESOL) >>
179 DS1621_REG_CONFIG_RESOL_SHIFT; 184 DS1621_REG_CONFIG_RESOL_SHIFT;
@@ -342,7 +347,7 @@ static umode_t ds1621_attribute_visible(struct kobject *kobj,
342 struct ds1621_data *data = i2c_get_clientdata(client); 347 struct ds1621_data *data = i2c_get_clientdata(client);
343 348
344 if (attr == &dev_attr_update_interval.attr) 349 if (attr == &dev_attr_update_interval.attr)
345 if (data->kind != ds1721) 350 if (data->kind == ds1621 || data->kind == ds1625)
346 /* shhh, we're hiding update_interval */ 351 /* shhh, we're hiding update_interval */
347 return 0; 352 return 0;
348 return attr->mode; 353 return attr->mode;
@@ -376,7 +381,14 @@ static int ds1621_detect(struct i2c_client *client,
376 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); 381 conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
377 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) 382 if (conf < 0 || conf & DS1621_REG_CONFIG_NVB)
378 return -ENODEV; 383 return -ENODEV;
379 /* The 7 lowest bits of a temperature should always be 0. */ 384 /*
385 * The ds1621 & ds1625 use 9-bit resolution, so the 7 lowest bits
386 * of the temperature should always be 0 (NOTE: The other chips
387 * have multi-resolution support, so if they have 9-bit resolution
388 * configured and the min/max temperature values set accordingly,
389 * then if not explicitly instantiated, they *will* appear as and
390 * emulate a ds1621 device).
391 */
380 for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { 392 for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) {
381 temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]); 393 temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]);
382 if (temp < 0 || (temp & 0x7f00)) 394 if (temp < 0 || (temp & 0x7f00))
@@ -438,6 +450,7 @@ static int ds1621_remove(struct i2c_client *client)
438static const struct i2c_device_id ds1621_id[] = { 450static const struct i2c_device_id ds1621_id[] = {
439 { "ds1621", ds1621 }, 451 { "ds1621", ds1621 },
440 { "ds1625", ds1625 }, 452 { "ds1625", ds1625 },
453 { "ds1631", ds1631 },
441 { "ds1721", ds1721 }, 454 { "ds1721", ds1721 },
442 { } 455 { }
443}; 456};