aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorChris Verges <kg4ysn@gmail.com>2013-01-05 04:41:20 -0500
committerGuenter Roeck <linux@roeck-us.net>2013-02-06 12:57:58 -0500
commit2bf9233a108cea32edbb5a65afa8e609fa146577 (patch)
tree7c7f3550fd520786c63d63b1c65f5b5893cd95a0 /drivers/hwmon
parent8c14d126ae2efbcd094b24e5413b8cbe1d2c01e4 (diff)
hwmon: (lm73) Add support for max/min alarms
Add support for temp1_min_alarm and temp1_max_alarm Signed-off-by: Chris Verges <kg4ysn@gmail.com> [linux@roeck-us.net: cleanup; dropped platform data and interrupt support] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/lm73.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/hwmon/lm73.c b/drivers/hwmon/lm73.c
index 0b19f03950e0..9bde9644b102 100644
--- a/drivers/hwmon/lm73.c
+++ b/drivers/hwmon/lm73.c
@@ -8,6 +8,7 @@
8 * Guillaume Ligneul <guillaume.ligneul@gmail.com> 8 * Guillaume Ligneul <guillaume.ligneul@gmail.com>
9 * Adrien Demarez <adrien.demarez@bolloretelecom.eu> 9 * Adrien Demarez <adrien.demarez@bolloretelecom.eu>
10 * Jeremy Laine <jeremy.laine@bolloretelecom.eu> 10 * Jeremy Laine <jeremy.laine@bolloretelecom.eu>
11 * Chris Verges <kg4ysn@gmail.com>
11 * 12 *
12 * This software program is licensed subject to the GNU General Public License 13 * This software program is licensed subject to the GNU General Public License
13 * (GPL).Version 2,June 1991, available at 14 * (GPL).Version 2,June 1991, available at
@@ -43,6 +44,9 @@ static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c,
43#define LM73_CTRL_RES_MASK (BIT(5) | BIT(6)) 44#define LM73_CTRL_RES_MASK (BIT(5) | BIT(6))
44#define LM73_CTRL_TO_MASK BIT(7) 45#define LM73_CTRL_TO_MASK BIT(7)
45 46
47#define LM73_CTRL_HI_SHIFT 2
48#define LM73_CTRL_LO_SHIFT 1
49
46static const unsigned short lm73_convrates[] = { 50static const unsigned short lm73_convrates[] = {
47 14, /* 11-bits (0.25000 C/LSB): RES1 Bit = 0, RES0 Bit = 0 */ 51 14, /* 11-bits (0.25000 C/LSB): RES1 Bit = 0, RES0 Bit = 0 */
48 28, /* 12-bits (0.12500 C/LSB): RES1 Bit = 0, RES0 Bit = 1 */ 52 28, /* 12-bits (0.12500 C/LSB): RES1 Bit = 0, RES0 Bit = 1 */
@@ -140,6 +144,28 @@ static ssize_t show_convrate(struct device *dev, struct device_attribute *da,
140 return scnprintf(buf, PAGE_SIZE, "%hu\n", lm73_convrates[res]); 144 return scnprintf(buf, PAGE_SIZE, "%hu\n", lm73_convrates[res]);
141} 145}
142 146
147static ssize_t show_maxmin_alarm(struct device *dev,
148 struct device_attribute *da, char *buf)
149{
150 struct i2c_client *client = to_i2c_client(dev);
151 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
152 struct lm73_data *data = i2c_get_clientdata(client);
153 s32 ctrl;
154
155 mutex_lock(&data->lock);
156 ctrl = i2c_smbus_read_byte_data(client, LM73_REG_CTRL);
157 if (ctrl < 0)
158 goto abort;
159 data->ctrl = ctrl;
160 mutex_unlock(&data->lock);
161
162 return scnprintf(buf, PAGE_SIZE, "%d\n", (ctrl >> attr->index) & 1);
163
164abort:
165 mutex_unlock(&data->lock);
166 return ctrl;
167}
168
143/*-----------------------------------------------------------------------*/ 169/*-----------------------------------------------------------------------*/
144 170
145/* sysfs attributes for hwmon */ 171/* sysfs attributes for hwmon */
@@ -152,12 +178,18 @@ static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO,
152 show_temp, NULL, LM73_REG_INPUT); 178 show_temp, NULL, LM73_REG_INPUT);
153static SENSOR_DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO, 179static SENSOR_DEVICE_ATTR(update_interval, S_IWUSR | S_IRUGO,
154 show_convrate, set_convrate, 0); 180 show_convrate, set_convrate, 0);
181static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO,
182 show_maxmin_alarm, NULL, LM73_CTRL_HI_SHIFT);
183static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO,
184 show_maxmin_alarm, NULL, LM73_CTRL_LO_SHIFT);
155 185
156static struct attribute *lm73_attributes[] = { 186static struct attribute *lm73_attributes[] = {
157 &sensor_dev_attr_temp1_input.dev_attr.attr, 187 &sensor_dev_attr_temp1_input.dev_attr.attr,
158 &sensor_dev_attr_temp1_max.dev_attr.attr, 188 &sensor_dev_attr_temp1_max.dev_attr.attr,
159 &sensor_dev_attr_temp1_min.dev_attr.attr, 189 &sensor_dev_attr_temp1_min.dev_attr.attr,
160 &sensor_dev_attr_update_interval.dev_attr.attr, 190 &sensor_dev_attr_update_interval.dev_attr.attr,
191 &sensor_dev_attr_temp1_max_alarm.dev_attr.attr,
192 &sensor_dev_attr_temp1_min_alarm.dev_attr.attr,
161 NULL 193 NULL
162}; 194};
163 195