提交 79c1cc1c 编写于 作者: R Robert Coulson 提交者: Guenter Roeck

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: NRobert Coulson <rob.coulson@gmail.com>
Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
上级 3a8fe331
...@@ -14,6 +14,11 @@ Supported chips: ...@@ -14,6 +14,11 @@ Supported chips:
Addresses scanned: I2C 0x48 - 0x4f Addresses scanned: I2C 0x48 - 0x4f
Datasheet: Publicly available from www.datasheetarchive.com Datasheet: Publicly available from www.datasheetarchive.com
* Maxim Integrated DS1631
Prefix: 'ds1631'
Addresses scanned: I2C 0x48 - 0x4f
Datasheet: Publicly available from www.maximintegrated.com
* Maxim Integrated DS1721 * Maxim Integrated DS1721
Prefix: 'ds1721' Prefix: 'ds1721'
Addresses scanned: I2C 0x48 - 0x4f Addresses scanned: I2C 0x48 - 0x4f
...@@ -69,7 +74,15 @@ Temperature conversion of the DS1621 takes up to 1000ms; internal access to ...@@ -69,7 +74,15 @@ Temperature conversion of the DS1621 takes up to 1000ms; internal access to
non-volatile registers may last for 10ms or below. non-volatile registers may last for 10ms or below.
The DS1625 is pin compatible and functionally equivalent with the DS1621, The DS1625 is pin compatible and functionally equivalent with the DS1621,
but the DS1621 is meant to replace it. but the DS1621 is meant to replace it. The DS1631 and DS1721 are also
pin compatible with the DS1621, but provide multi-resolution support.
Since there is no version register, there is no unique identification
for these devices. In addition, the DS1631 and DS1721 will emulate a
DS1621 device, if not explicitly instantiated (why? because the detect
function compares the temperature register values bits and checks for a
9-bit resolution). Therefore, for correct device identification and
functionality, explicit device instantiation is required.
The DS1721 is pin compatible with the DS1621, has an accuracy of +/- 1.0 The DS1721 is pin compatible with the DS1621, has an accuracy of +/- 1.0
degree Celsius over a -10 to +85 degree range, a minimum/maximum alarm degree Celsius over a -10 to +85 degree range, a minimum/maximum alarm
...@@ -78,9 +91,17 @@ time of 750ms. ...@@ -78,9 +91,17 @@ time of 750ms.
In addition, the DS1721 supports four resolution settings from 9 to 12 bits In addition, the DS1721 supports four resolution settings from 9 to 12 bits
(defined in degrees C per LSB: 0.5, 0.25, 0.125, and 0.0625, respectifully), (defined in degrees C per LSB: 0.5, 0.25, 0.125, and 0.0625, respectifully),
that are set at device power on to the highest resolution: 12-bits (0.0625 degree C). that are set at device power on to the highest resolution: 12-bits.
One additional note about the ds1721 is that although the data sheet says
the temperature flags (THF and TLF) are used internally, these flags do
get set and cleared as the actual temperature crosses the min or max settings.
The DS1631 is also pin compatible with the DS1621 and feature compatible with
the DS1721, however the DS1631 accuracy is +/- 0.5 degree Celsius over the
same range.
Changing the DS1721 resolution mode affects the conversion time and can be Changing the DS1631/1721 resolution mode affects the conversion time and can be
done from userspace, via the device 'update_interval' sysfs attribute. This done from userspace, via the device 'update_interval' sysfs attribute. This
attribute will normalize range of input values to the device maximum resolution attribute will normalize range of input values to the device maximum resolution
values defined in the datasheet as such: values defined in the datasheet as such:
......
...@@ -355,6 +355,7 @@ config SENSORS_DS1621 ...@@ -355,6 +355,7 @@ config SENSORS_DS1621
Integrated DS1621 sensor chips and compatible models including: Integrated DS1621 sensor chips and compatible models including:
- Dallas Semiconductor DS1625 - Dallas Semiconductor DS1625
- Maxim Integrated DS1631
- Maxim Integrated DS1721 - Maxim Integrated DS1721
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
* resolution, a thermal alarm output (Tout), and user-defined minimum * resolution, a thermal alarm output (Tout), and user-defined minimum
* and maximum temperature thresholds (TH and TL). * and maximum temperature thresholds (TH and TL).
* *
* The DS1625 and DS1721 are pin compatible with the DS1621 and similar * The DS1625, DS1631, and DS1721 are pin compatible with the DS1621 and
* in operation, with slight variations as noted in the device * similar in operation, with slight variations as noted in the device
* datasheets (please refer to www.maximintegrated.com for specific * datasheets (please refer to www.maximintegrated.com for specific
* device information). * device information).
* *
...@@ -51,7 +51,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c, ...@@ -51,7 +51,7 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
0x4d, 0x4e, 0x4f, I2C_CLIENT_END }; 0x4d, 0x4e, 0x4f, I2C_CLIENT_END };
/* Supported devices */ /* Supported devices */
enum chips { ds1621, ds1625, ds1721 }; enum chips { ds1621, ds1625, ds1631, ds1721 };
/* Insmod parameters */ /* Insmod parameters */
static int polarity = -1; static int polarity = -1;
...@@ -69,6 +69,10 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low") ...@@ -69,6 +69,10 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
* 7 6 5 4 3 2 1 0 * 7 6 5 4 3 2 1 0
* |Done|THF |TLF |NVB | 1 | 0 |POL |1SHOT| * |Done|THF |TLF |NVB | 1 | 0 |POL |1SHOT|
* *
* - DS1631:
* 7 6 5 4 3 2 1 0
* |Done|THF |TLF |NVB | R1 | R0 |POL |1SHOT|
*
* - DS1721: * - DS1721:
* 7 6 5 4 3 2 1 0 * 7 6 5 4 3 2 1 0
* |Done| X | X | U | R1 | R0 |POL |1SHOT| * |Done| X | X | U | R1 | R0 |POL |1SHOT|
...@@ -139,8 +143,8 @@ static inline int DS1621_TEMP_FROM_REG(u16 reg) ...@@ -139,8 +143,8 @@ static inline int DS1621_TEMP_FROM_REG(u16 reg)
/* /*
* TEMP: 0.001C/bit (-55C to +125C) * TEMP: 0.001C/bit (-55C to +125C)
* REG: * REG:
* - 1621, 1625: x = 0.5C * - 1621, 1625: 0.5C/bit
* - 1721: x = 0.0625C * - 1631, 1721: 0.0625C/bit
* Assume highest resolution and let the bits fall where they may.. * Assume highest resolution and let the bits fall where they may..
*/ */
static inline u16 DS1621_TEMP_TO_REG(long temp) static inline u16 DS1621_TEMP_TO_REG(long temp)
...@@ -174,6 +178,7 @@ static void ds1621_init_client(struct i2c_client *client) ...@@ -174,6 +178,7 @@ static void ds1621_init_client(struct i2c_client *client)
data->update_interval = DS1625_CONVERSION_MAX; data->update_interval = DS1625_CONVERSION_MAX;
sreg = DS1621_COM_START; sreg = DS1621_COM_START;
break; break;
case ds1631:
case ds1721: case ds1721:
resol = (new_conf & DS1621_REG_CONFIG_RESOL) >> resol = (new_conf & DS1621_REG_CONFIG_RESOL) >>
DS1621_REG_CONFIG_RESOL_SHIFT; DS1621_REG_CONFIG_RESOL_SHIFT;
...@@ -342,7 +347,7 @@ static umode_t ds1621_attribute_visible(struct kobject *kobj, ...@@ -342,7 +347,7 @@ static umode_t ds1621_attribute_visible(struct kobject *kobj,
struct ds1621_data *data = i2c_get_clientdata(client); struct ds1621_data *data = i2c_get_clientdata(client);
if (attr == &dev_attr_update_interval.attr) if (attr == &dev_attr_update_interval.attr)
if (data->kind != ds1721) if (data->kind == ds1621 || data->kind == ds1625)
/* shhh, we're hiding update_interval */ /* shhh, we're hiding update_interval */
return 0; return 0;
return attr->mode; return attr->mode;
...@@ -376,7 +381,14 @@ static int ds1621_detect(struct i2c_client *client, ...@@ -376,7 +381,14 @@ static int ds1621_detect(struct i2c_client *client,
conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF); conf = i2c_smbus_read_byte_data(client, DS1621_REG_CONF);
if (conf < 0 || conf & DS1621_REG_CONFIG_NVB) if (conf < 0 || conf & DS1621_REG_CONFIG_NVB)
return -ENODEV; return -ENODEV;
/* The 7 lowest bits of a temperature should always be 0. */ /*
* The ds1621 & ds1625 use 9-bit resolution, so the 7 lowest bits
* of the temperature should always be 0 (NOTE: The other chips
* have multi-resolution support, so if they have 9-bit resolution
* configured and the min/max temperature values set accordingly,
* then if not explicitly instantiated, they *will* appear as and
* emulate a ds1621 device).
*/
for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) { for (i = 0; i < ARRAY_SIZE(DS1621_REG_TEMP); i++) {
temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]); temp = i2c_smbus_read_word_data(client, DS1621_REG_TEMP[i]);
if (temp < 0 || (temp & 0x7f00)) if (temp < 0 || (temp & 0x7f00))
...@@ -438,6 +450,7 @@ static int ds1621_remove(struct i2c_client *client) ...@@ -438,6 +450,7 @@ static int ds1621_remove(struct i2c_client *client)
static const struct i2c_device_id ds1621_id[] = { static const struct i2c_device_id ds1621_id[] = {
{ "ds1621", ds1621 }, { "ds1621", ds1621 },
{ "ds1625", ds1625 }, { "ds1625", ds1625 },
{ "ds1631", ds1631 },
{ "ds1721", ds1721 }, { "ds1721", ds1721 },
{ } { }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册