diff options
author | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2013-01-07 08:18:12 +0100 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2013-01-07 08:18:12 +0100 |
commit | 5028e99a19fa01c9d1ed426e168fa6fd15feefb3 (patch) | |
tree | 55620788329d0a1bea1cd4c6b41c3c3589ac4076 /drivers/hwmon/lm95245.c | |
parent | 6067366f519fd91088c28eeee6a3cd67458a58be (diff) |
hwmon: lm95245: implement remote over-temperature shutdown alarm limit
In addition to the critical temperature alarm limit this chip features
a second alarm limit called remote over-temperature shutdown ROS with
a separate pin configurable as trigger output. Implement this feature
and add platform data to allow configuring respective pin as output.
Diffstat (limited to 'drivers/hwmon/lm95245.c')
-rw-r--r-- | drivers/hwmon/lm95245.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/hwmon/lm95245.c b/drivers/hwmon/lm95245.c index 93862375407d..33c8e35a67be 100644 --- a/drivers/hwmon/lm95245.c +++ b/drivers/hwmon/lm95245.c @@ -34,6 +34,8 @@ #include <linux/mutex.h> #include <linux/sysfs.h> +#include <linux/lm95245.h> + #define DEVNAME "lm95245" static const unsigned short normal_i2c[] = { @@ -93,6 +95,7 @@ static const unsigned short normal_i2c[] = { #define RATE_CR1000 0x02 #define RATE_CR2500 0x03 +#define STATUS1_ROS 0x10 #define STATUS1_DIODE_FAULT 0x04 #define STATUS1_RTCRIT 0x02 #define STATUS1_LOC 0x01 @@ -107,6 +110,7 @@ static const u8 lm95245_reg_address[] = { LM95245_REG_R_REMOTE_TEMPL_S, LM95245_REG_R_REMOTE_TEMPH_U, LM95245_REG_R_REMOTE_TEMPL_U, + LM95245_REG_RW_REMOTE_OS_LIMIT, LM95245_REG_RW_LOCAL_OS_TCRIT_LIMIT, LM95245_REG_RW_REMOTE_TCRIT_LIMIT, LM95245_REG_RW_COMMON_HYSTERESIS, @@ -118,7 +122,8 @@ static const u8 lm95245_reg_address[] = { enum { INDEX_LOCAL_TEMP = 0, INDEX_REMOTE_TEMP = 2, - INDEX_LOCAL_OS_TCRIT_LIMIT = 6, + INDEX_REMOTE_OS_LIMIT = 6, + INDEX_LOCAL_OS_TCRIT_LIMIT, INDEX_REMOTE_TCRIT_LIMIT, INDEX_COMMON_HYSTERESIS, INDEX_STATUS1, @@ -402,10 +407,14 @@ static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, STATUS1_LOC); static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, INDEX_REMOTE_TEMP); +static SENSOR_DEVICE_ATTR(temp2_os, S_IWUSR | S_IRUGO, show_limit, + set_limit, INDEX_REMOTE_OS_LIMIT); static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_limit, set_limit, INDEX_REMOTE_TCRIT_LIMIT); static SENSOR_DEVICE_ATTR(temp2_crit_hyst, S_IWUSR | S_IRUGO, show_limit, set_crit_hyst, INDEX_COMMON_HYSTERESIS); +static SENSOR_DEVICE_ATTR(temp2_os_alarm, S_IRUGO, show_alarm, NULL, + STATUS1_ROS); static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, STATUS1_RTCRIT); static SENSOR_DEVICE_ATTR(temp2_type, S_IWUSR | S_IRUGO, show_type, @@ -422,8 +431,10 @@ static struct attribute *lm95245_attributes[] = { &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, &sensor_dev_attr_temp2_input.dev_attr.attr, + &sensor_dev_attr_temp2_os.dev_attr.attr, &sensor_dev_attr_temp2_crit.dev_attr.attr, &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, + &sensor_dev_attr_temp2_os_alarm.dev_attr.attr, &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, &sensor_dev_attr_temp2_type.dev_attr.attr, &sensor_dev_attr_temp2_fault.dev_attr.attr, @@ -472,6 +483,13 @@ static void lm95245_init_client(struct i2c_client *client) i2c_smbus_write_byte_data(client, LM95245_REG_RW_CONFIG1, data->config1); } + + /* Configure over-temperature shutdown (OS) output pin */ + if (client->dev.platform_data && ((struct lm95245_platform_data*)(client->dev.platform_data))->enable_os_pin) { + data->config2 |= CFG2_OS_A0; + i2c_smbus_write_byte_data(client, LM95245_REG_RW_CONFIG2, + data->config2); + } } static int lm95245_probe(struct i2c_client *new_client, |