2 * STTS751 sensor driver
4 * Copyright (C) 2016-2017 Istituto Italiano di Tecnologia - RBCS - EDL
5 * Robotics, Brain and Cognitive Sciences department
6 * Electronic Design Laboratory
8 * Written by Andrea Merello <andrea.merello@gmail.com>
10 * Based on LM95241 driver and LM90 driver
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
23 #include <linux/bitops.h>
24 #include <linux/err.h>
25 #include <linux/hwmon.h>
26 #include <linux/hwmon-sysfs.h>
27 #include <linux/i2c.h>
28 #include <linux/init.h>
29 #include <linux/interrupt.h>
30 #include <linux/jiffies.h>
31 #include <linux/module.h>
32 #include <linux/mutex.h>
33 #include <linux/property.h>
34 #include <linux/slab.h>
35 #include <linux/sysfs.h>
36 #include <linux/util_macros.h>
38 #define DEVNAME "stts751"
40 static const unsigned short normal_i2c
[] = {
41 0x48, 0x49, 0x38, 0x39, /* STTS751-0 */
42 0x4A, 0x4B, 0x3A, 0x3B, /* STTS751-1 */
45 #define STTS751_REG_TEMP_H 0x00
46 #define STTS751_REG_STATUS 0x01
47 #define STTS751_STATUS_TRIPT BIT(0)
48 #define STTS751_STATUS_TRIPL BIT(5)
49 #define STTS751_STATUS_TRIPH BIT(6)
50 #define STTS751_REG_TEMP_L 0x02
51 #define STTS751_REG_CONF 0x03
52 #define STTS751_CONF_RES_MASK 0x0C
53 #define STTS751_CONF_RES_SHIFT 2
54 #define STTS751_CONF_EVENT_DIS BIT(7)
55 #define STTS751_CONF_STOP BIT(6)
56 #define STTS751_REG_RATE 0x04
57 #define STTS751_REG_HLIM_H 0x05
58 #define STTS751_REG_HLIM_L 0x06
59 #define STTS751_REG_LLIM_H 0x07
60 #define STTS751_REG_LLIM_L 0x08
61 #define STTS751_REG_TLIM 0x20
62 #define STTS751_REG_HYST 0x21
63 #define STTS751_REG_SMBUS_TO 0x22
65 #define STTS751_REG_PROD_ID 0xFD
66 #define STTS751_REG_MAN_ID 0xFE
67 #define STTS751_REG_REV_ID 0xFF
69 #define STTS751_0_PROD_ID 0x00
70 #define STTS751_1_PROD_ID 0x01
71 #define ST_MAN_ID 0x53
74 * Possible update intervals are (in mS):
75 * 16000, 8000, 4000, 2000, 1000, 500, 250, 125, 62.5, 31.25
76 * However we are not going to complicate things too much and we stick to the
79 static const int stts751_intervals
[] = {
80 16000, 8000, 4000, 2000, 1000, 500, 250, 125, 63, 31
83 static const struct i2c_device_id stts751_id
[] = {
88 static const struct of_device_id stts751_of_match
[] = {
89 { .compatible
= "stts751" },
92 MODULE_DEVICE_TABLE(of
, stts751_of_match
);
96 struct i2c_client
*client
;
97 struct mutex access_lock
;
100 int event_max
, event_min
;
105 unsigned long last_update
, last_alert_update
;
107 bool min_alert
, max_alert
, therm_trip
;
108 bool data_valid
, alert_valid
;
109 bool notify_max
, notify_min
;
113 * These functions converts temperature from HW format to integer format and
114 * vice-vers. They are (mostly) taken from lm90 driver. Unit is in mC.
116 static int stts751_to_deg(s16 hw_val
)
118 return hw_val
* 125 / 32;
121 static s32
stts751_to_hw(int val
)
123 return DIV_ROUND_CLOSEST(val
, 125) * 32;
126 static int stts751_adjust_resolution(struct stts751_priv
*priv
)
130 switch (priv
->interval
) {
145 if (priv
->res
== res
)
148 priv
->config
&= ~STTS751_CONF_RES_MASK
;
149 priv
->config
|= res
<< STTS751_CONF_RES_SHIFT
;
150 dev_dbg(&priv
->client
->dev
, "setting res %d. config %x",
154 return i2c_smbus_write_byte_data(priv
->client
,
155 STTS751_REG_CONF
, priv
->config
);
158 static int stts751_update_temp(struct stts751_priv
*priv
)
160 s32 integer1
, integer2
, frac
;
163 * There is a trick here, like in the lm90 driver. We have to read two
164 * registers to get the sensor temperature, but we have to beware a
165 * conversion could occur between the readings. We could use the
166 * one-shot conversion register, but we don't want to do this (disables
167 * hardware monitoring). So the solution used here is to read the high
168 * byte once, then the low byte, then the high byte again. If the new
169 * high byte matches the old one, then we have a valid reading. Else we
170 * have to read the low byte again, and now we believe we have a correct
173 integer1
= i2c_smbus_read_byte_data(priv
->client
, STTS751_REG_TEMP_H
);
175 dev_dbg(&priv
->client
->dev
,
176 "I2C read failed (temp H). ret: %x\n", integer1
);
180 frac
= i2c_smbus_read_byte_data(priv
->client
, STTS751_REG_TEMP_L
);
182 dev_dbg(&priv
->client
->dev
,
183 "I2C read failed (temp L). ret: %x\n", frac
);
187 integer2
= i2c_smbus_read_byte_data(priv
->client
, STTS751_REG_TEMP_H
);
189 dev_dbg(&priv
->client
->dev
,
190 "I2C 2nd read failed (temp H). ret: %x\n", integer2
);
194 if (integer1
!= integer2
) {
195 frac
= i2c_smbus_read_byte_data(priv
->client
,
198 dev_dbg(&priv
->client
->dev
,
199 "I2C 2nd read failed (temp L). ret: %x\n",
205 priv
->temp
= stts751_to_deg((integer1
<< 8) | frac
);
209 static int stts751_set_temp_reg16(struct stts751_priv
*priv
, int temp
,
215 hwval
= stts751_to_hw(temp
);
217 ret
= i2c_smbus_write_byte_data(priv
->client
, hreg
, hwval
>> 8);
221 return i2c_smbus_write_byte_data(priv
->client
, lreg
, hwval
& 0xff);
224 static int stts751_set_temp_reg8(struct stts751_priv
*priv
, int temp
, u8 reg
)
228 hwval
= stts751_to_hw(temp
);
229 return i2c_smbus_write_byte_data(priv
->client
, reg
, hwval
>> 8);
232 static int stts751_read_reg16(struct stts751_priv
*priv
, int *temp
,
237 integer
= i2c_smbus_read_byte_data(priv
->client
, hreg
);
241 frac
= i2c_smbus_read_byte_data(priv
->client
, lreg
);
245 *temp
= stts751_to_deg((integer
<< 8) | frac
);
250 static int stts751_read_reg8(struct stts751_priv
*priv
, int *temp
, u8 reg
)
254 integer
= i2c_smbus_read_byte_data(priv
->client
, reg
);
258 *temp
= stts751_to_deg(integer
<< 8);
264 * Update alert flags without waiting for cache to expire. We detects alerts
265 * immediately for the sake of the alert handler; we still need to deal with
266 * caching to workaround the fact that alarm flags int the status register,
267 * despite what the datasheet claims, gets always cleared on read.
269 static int stts751_update_alert(struct stts751_priv
*priv
)
273 int cache_time
= msecs_to_jiffies(stts751_intervals
[priv
->interval
]);
276 * Add another 10% because if we run faster than the HW conversion
277 * rate we will end up in reporting incorrectly alarms.
279 cache_time
+= cache_time
/ 10;
281 ret
= i2c_smbus_read_byte_data(priv
->client
, STTS751_REG_STATUS
);
285 dev_dbg(&priv
->client
->dev
, "status reg %x\n", ret
);
286 conv_done
= ret
& (STTS751_STATUS_TRIPH
| STTS751_STATUS_TRIPL
);
288 * Reset the cache if the cache time expired, or if we are sure
289 * we have valid data from a device conversion, or if we know
290 * our cache has been never written.
292 * Note that when the cache has been never written the point is
293 * to correctly initialize the timestamp, rather than clearing
296 * Note that updating the cache timestamp when we get an alarm flag
297 * is required, otherwise we could incorrectly report alarms to be zero.
299 if (time_after(jiffies
, priv
->last_alert_update
+ cache_time
) ||
300 conv_done
|| !priv
->alert_valid
) {
301 priv
->max_alert
= false;
302 priv
->min_alert
= false;
303 priv
->alert_valid
= true;
304 priv
->last_alert_update
= jiffies
;
305 dev_dbg(&priv
->client
->dev
, "invalidating alert cache\n");
308 priv
->max_alert
|= !!(ret
& STTS751_STATUS_TRIPH
);
309 priv
->min_alert
|= !!(ret
& STTS751_STATUS_TRIPL
);
310 priv
->therm_trip
= !!(ret
& STTS751_STATUS_TRIPT
);
312 dev_dbg(&priv
->client
->dev
, "max_alert: %d, min_alert: %d, therm_trip: %d\n",
313 priv
->max_alert
, priv
->min_alert
, priv
->therm_trip
);
318 static void stts751_alert(struct i2c_client
*client
,
319 enum i2c_alert_protocol type
, unsigned int data
)
322 struct stts751_priv
*priv
= i2c_get_clientdata(client
);
324 if (type
!= I2C_PROTOCOL_SMBUS_ALERT
)
327 dev_dbg(&client
->dev
, "alert!");
329 mutex_lock(&priv
->access_lock
);
330 ret
= stts751_update_alert(priv
);
332 /* default to worst case */
333 priv
->max_alert
= true;
334 priv
->min_alert
= true;
337 "Alert received, but can't communicate to the device. Triggering all alarms!");
340 if (priv
->max_alert
) {
341 if (priv
->notify_max
)
342 dev_notice(priv
->dev
, "got alert for HIGH temperature");
343 priv
->notify_max
= false;
345 /* unblock alert poll */
346 sysfs_notify(&priv
->dev
->kobj
, NULL
, "temp1_max_alarm");
349 if (priv
->min_alert
) {
350 if (priv
->notify_min
)
351 dev_notice(priv
->dev
, "got alert for LOW temperature");
352 priv
->notify_min
= false;
354 /* unblock alert poll */
355 sysfs_notify(&priv
->dev
->kobj
, NULL
, "temp1_min_alarm");
358 if (priv
->min_alert
|| priv
->max_alert
)
359 kobject_uevent(&priv
->dev
->kobj
, KOBJ_CHANGE
);
361 mutex_unlock(&priv
->access_lock
);
364 static int stts751_update(struct stts751_priv
*priv
)
367 int cache_time
= msecs_to_jiffies(stts751_intervals
[priv
->interval
]);
369 if (time_after(jiffies
, priv
->last_update
+ cache_time
) ||
371 ret
= stts751_update_temp(priv
);
375 ret
= stts751_update_alert(priv
);
378 priv
->data_valid
= true;
379 priv
->last_update
= jiffies
;
385 static ssize_t
show_max_alarm(struct device
*dev
, struct device_attribute
*attr
,
389 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
391 mutex_lock(&priv
->access_lock
);
392 ret
= stts751_update(priv
);
394 priv
->notify_max
= true;
395 mutex_unlock(&priv
->access_lock
);
399 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->max_alert
);
402 static ssize_t
show_min_alarm(struct device
*dev
, struct device_attribute
*attr
,
406 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
408 mutex_lock(&priv
->access_lock
);
409 ret
= stts751_update(priv
);
411 priv
->notify_min
= true;
412 mutex_unlock(&priv
->access_lock
);
416 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->min_alert
);
419 static ssize_t
show_input(struct device
*dev
, struct device_attribute
*attr
,
423 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
425 mutex_lock(&priv
->access_lock
);
426 ret
= stts751_update(priv
);
427 mutex_unlock(&priv
->access_lock
);
431 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->temp
);
434 static ssize_t
show_therm(struct device
*dev
, struct device_attribute
*attr
,
437 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
439 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->therm
);
442 static ssize_t
set_therm(struct device
*dev
, struct device_attribute
*attr
,
443 const char *buf
, size_t count
)
447 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
449 if (kstrtol(buf
, 10, &temp
) < 0)
452 /* HW works in range -64C to +127.937C */
453 temp
= clamp_val(temp
, -64000, 127937);
454 mutex_lock(&priv
->access_lock
);
455 ret
= stts751_set_temp_reg8(priv
, temp
, STTS751_REG_TLIM
);
459 dev_dbg(&priv
->client
->dev
, "setting therm %ld", temp
);
462 * hysteresis reg is relative to therm, so the HW does not need to be
463 * adjusted, we need to update our local copy only.
465 priv
->hyst
= temp
- (priv
->therm
- priv
->hyst
);
469 mutex_unlock(&priv
->access_lock
);
476 static ssize_t
show_hyst(struct device
*dev
, struct device_attribute
*attr
,
479 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
481 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->hyst
);
484 static ssize_t
set_hyst(struct device
*dev
, struct device_attribute
*attr
,
485 const char *buf
, size_t count
)
490 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
492 if (kstrtol(buf
, 10, &temp
) < 0)
495 mutex_lock(&priv
->access_lock
);
496 /* HW works in range -64C to +127.937C */
497 temp
= clamp_val(temp
, -64000, priv
->therm
);
499 dev_dbg(&priv
->client
->dev
, "setting hyst %ld", temp
);
500 temp
= priv
->therm
- temp
;
501 ret
= stts751_set_temp_reg8(priv
, temp
, STTS751_REG_HYST
);
502 mutex_unlock(&priv
->access_lock
);
509 static ssize_t
show_therm_trip(struct device
*dev
,
510 struct device_attribute
*attr
, char *buf
)
513 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
515 mutex_lock(&priv
->access_lock
);
516 ret
= stts751_update(priv
);
517 mutex_unlock(&priv
->access_lock
);
521 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->therm_trip
);
524 static ssize_t
show_max(struct device
*dev
, struct device_attribute
*attr
,
527 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
529 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->event_max
);
532 static ssize_t
set_max(struct device
*dev
, struct device_attribute
*attr
,
533 const char *buf
, size_t count
)
537 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
539 if (kstrtol(buf
, 10, &temp
) < 0)
542 mutex_lock(&priv
->access_lock
);
543 /* HW works in range -64C to +127.937C */
544 temp
= clamp_val(temp
, priv
->event_min
, 127937);
545 ret
= stts751_set_temp_reg16(priv
, temp
,
546 STTS751_REG_HLIM_H
, STTS751_REG_HLIM_L
);
550 dev_dbg(&priv
->client
->dev
, "setting event max %ld", temp
);
551 priv
->event_max
= temp
;
554 mutex_unlock(&priv
->access_lock
);
558 static ssize_t
show_min(struct device
*dev
, struct device_attribute
*attr
,
561 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
563 return snprintf(buf
, PAGE_SIZE
, "%d\n", priv
->event_min
);
566 static ssize_t
set_min(struct device
*dev
, struct device_attribute
*attr
,
567 const char *buf
, size_t count
)
571 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
573 if (kstrtol(buf
, 10, &temp
) < 0)
576 mutex_lock(&priv
->access_lock
);
577 /* HW works in range -64C to +127.937C */
578 temp
= clamp_val(temp
, -64000, priv
->event_max
);
579 ret
= stts751_set_temp_reg16(priv
, temp
,
580 STTS751_REG_LLIM_H
, STTS751_REG_LLIM_L
);
584 dev_dbg(&priv
->client
->dev
, "setting event min %ld", temp
);
585 priv
->event_min
= temp
;
588 mutex_unlock(&priv
->access_lock
);
592 static ssize_t
show_interval(struct device
*dev
, struct device_attribute
*attr
,
595 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
597 return snprintf(buf
, PAGE_SIZE
, "%d\n",
598 stts751_intervals
[priv
->interval
]);
601 static ssize_t
set_interval(struct device
*dev
, struct device_attribute
*attr
,
602 const char *buf
, size_t count
)
607 struct stts751_priv
*priv
= dev_get_drvdata(dev
);
609 if (kstrtoul(buf
, 10, &val
) < 0)
612 idx
= find_closest_descending(val
, stts751_intervals
,
613 ARRAY_SIZE(stts751_intervals
));
615 dev_dbg(&priv
->client
->dev
, "setting interval. req:%lu, idx: %d, val: %d",
616 val
, idx
, stts751_intervals
[idx
]);
618 mutex_lock(&priv
->access_lock
);
619 if (priv
->interval
== idx
)
623 * In early development stages I've become suspicious about the chip
624 * starting to misbehave if I ever set, even briefly, an invalid
625 * configuration. While I'm not sure this is really needed, be
626 * conservative and set rate/resolution in such an order that avoids
627 * passing through an invalid configuration.
630 /* speed up: lower the resolution, then modify convrate */
631 if (priv
->interval
< idx
) {
632 dev_dbg(&priv
->client
->dev
, "lower resolution, then modify convrate");
633 priv
->interval
= idx
;
634 ret
= stts751_adjust_resolution(priv
);
639 ret
= i2c_smbus_write_byte_data(priv
->client
, STTS751_REG_RATE
, idx
);
642 /* slow down: modify convrate, then raise resolution */
643 if (priv
->interval
!= idx
) {
644 dev_dbg(&priv
->client
->dev
, "modify convrate, then raise resolution");
645 priv
->interval
= idx
;
646 ret
= stts751_adjust_resolution(priv
);
652 mutex_unlock(&priv
->access_lock
);
657 static int stts751_detect(struct i2c_client
*new_client
,
658 struct i2c_board_info
*info
)
660 struct i2c_adapter
*adapter
= new_client
->adapter
;
664 if (!i2c_check_functionality(adapter
, I2C_FUNC_SMBUS_BYTE_DATA
))
667 tmp
= i2c_smbus_read_byte_data(new_client
, STTS751_REG_MAN_ID
);
668 if (tmp
!= ST_MAN_ID
)
671 /* lower temperaure registers always have bits 0-3 set to zero */
672 tmp
= i2c_smbus_read_byte_data(new_client
, STTS751_REG_TEMP_L
);
676 tmp
= i2c_smbus_read_byte_data(new_client
, STTS751_REG_HLIM_L
);
680 tmp
= i2c_smbus_read_byte_data(new_client
, STTS751_REG_LLIM_L
);
684 /* smbus timeout register always have bits 0-7 set to zero */
685 tmp
= i2c_smbus_read_byte_data(new_client
, STTS751_REG_SMBUS_TO
);
689 tmp
= i2c_smbus_read_byte_data(new_client
, STTS751_REG_PROD_ID
);
692 case STTS751_0_PROD_ID
:
695 case STTS751_1_PROD_ID
:
701 dev_dbg(&new_client
->dev
, "Chip %s detected", name
);
703 strlcpy(info
->type
, stts751_id
[0].name
, I2C_NAME_SIZE
);
707 static int stts751_read_chip_config(struct stts751_priv
*priv
)
712 ret
= i2c_smbus_read_byte_data(priv
->client
, STTS751_REG_CONF
);
716 priv
->res
= (ret
& STTS751_CONF_RES_MASK
) >> STTS751_CONF_RES_SHIFT
;
718 ret
= i2c_smbus_read_byte_data(priv
->client
, STTS751_REG_RATE
);
721 if (ret
>= ARRAY_SIZE(stts751_intervals
)) {
722 dev_err(priv
->dev
, "Unrecognized conversion rate 0x%x\n", ret
);
725 priv
->interval
= ret
;
727 ret
= stts751_read_reg16(priv
, &priv
->event_max
,
728 STTS751_REG_HLIM_H
, STTS751_REG_HLIM_L
);
732 ret
= stts751_read_reg16(priv
, &priv
->event_min
,
733 STTS751_REG_LLIM_H
, STTS751_REG_LLIM_L
);
737 ret
= stts751_read_reg8(priv
, &priv
->therm
, STTS751_REG_TLIM
);
741 ret
= stts751_read_reg8(priv
, &tmp
, STTS751_REG_HYST
);
744 priv
->hyst
= priv
->therm
- tmp
;
749 static SENSOR_DEVICE_ATTR(temp1_input
, 0444, show_input
, NULL
, 0);
750 static SENSOR_DEVICE_ATTR(temp1_min
, 0644, show_min
, set_min
, 0);
751 static SENSOR_DEVICE_ATTR(temp1_max
, 0644, show_max
, set_max
, 0);
752 static SENSOR_DEVICE_ATTR(temp1_min_alarm
, 0444, show_min_alarm
, NULL
, 0);
753 static SENSOR_DEVICE_ATTR(temp1_max_alarm
, 0444, show_max_alarm
, NULL
, 0);
754 static SENSOR_DEVICE_ATTR(temp1_crit
, 0644, show_therm
, set_therm
, 0);
755 static SENSOR_DEVICE_ATTR(temp1_crit_hyst
, 0644, show_hyst
, set_hyst
, 0);
756 static SENSOR_DEVICE_ATTR(temp1_crit_alarm
, 0444, show_therm_trip
, NULL
, 0);
757 static SENSOR_DEVICE_ATTR(update_interval
, 0644,
758 show_interval
, set_interval
, 0);
760 static struct attribute
*stts751_attrs
[] = {
761 &sensor_dev_attr_temp1_input
.dev_attr
.attr
,
762 &sensor_dev_attr_temp1_min
.dev_attr
.attr
,
763 &sensor_dev_attr_temp1_max
.dev_attr
.attr
,
764 &sensor_dev_attr_temp1_min_alarm
.dev_attr
.attr
,
765 &sensor_dev_attr_temp1_max_alarm
.dev_attr
.attr
,
766 &sensor_dev_attr_temp1_crit
.dev_attr
.attr
,
767 &sensor_dev_attr_temp1_crit_hyst
.dev_attr
.attr
,
768 &sensor_dev_attr_temp1_crit_alarm
.dev_attr
.attr
,
769 &sensor_dev_attr_update_interval
.dev_attr
.attr
,
772 ATTRIBUTE_GROUPS(stts751
);
774 static int stts751_probe(struct i2c_client
*client
,
775 const struct i2c_device_id
*id
)
777 struct stts751_priv
*priv
;
782 priv
= devm_kzalloc(&client
->dev
, sizeof(*priv
), GFP_KERNEL
);
786 priv
->client
= client
;
787 priv
->notify_max
= true;
788 priv
->notify_min
= true;
789 i2c_set_clientdata(client
, priv
);
790 mutex_init(&priv
->access_lock
);
792 if (device_property_present(&client
->dev
,
793 "smbus-timeout-disable")) {
794 smbus_nto
= device_property_read_bool(&client
->dev
,
795 "smbus-timeout-disable");
797 ret
= i2c_smbus_write_byte_data(client
, STTS751_REG_SMBUS_TO
,
798 smbus_nto
? 0 : 0x80);
803 rev_id
= i2c_smbus_read_byte_data(client
, STTS751_REG_REV_ID
);
807 dev_dbg(&client
->dev
, "Chip revision 0x%x is untested\n",
811 ret
= stts751_read_chip_config(priv
);
815 priv
->config
&= ~(STTS751_CONF_STOP
| STTS751_CONF_EVENT_DIS
);
816 ret
= i2c_smbus_write_byte_data(client
, STTS751_REG_CONF
, priv
->config
);
820 priv
->dev
= devm_hwmon_device_register_with_groups(&client
->dev
,
823 return PTR_ERR_OR_ZERO(priv
->dev
);
826 MODULE_DEVICE_TABLE(i2c
, stts751_id
);
828 static struct i2c_driver stts751_driver
= {
829 .class = I2C_CLASS_HWMON
,
832 .of_match_table
= of_match_ptr(stts751_of_match
),
834 .probe
= stts751_probe
,
835 .id_table
= stts751_id
,
836 .detect
= stts751_detect
,
837 .alert
= stts751_alert
,
838 .address_list
= normal_i2c
,
841 module_i2c_driver(stts751_driver
);
843 MODULE_AUTHOR("Andrea Merello <andrea.merello@gmail.com>");
844 MODULE_DESCRIPTION("STTS751 sensor driver");
845 MODULE_LICENSE("GPL");