^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Honeywell HIH-6130/HIH-6131 humidity and temperature sensor driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 2012 Iain Paton <ipaton0@gmail.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * heavily based on the sht21 driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 2010 Urs Fleisch <urs.fleisch@sensirion.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Data sheets available (2012-06-22) at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * http://sensing.honeywell.com/index.php?ci_id=3106&la_id=1&defId=44872
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/i2c.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/hwmon.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/hwmon-sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/mutex.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/jiffies.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * struct hih6130 - HIH-6130 device specific data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * @client: pointer to I2C client device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * @lock: mutex to protect measurement values
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * @valid: only false before first measurement is taken
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * @last_update: time of last update (jiffies)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * @temperature: cached temperature measurement value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @humidity: cached humidity measurement value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @write_length: length for I2C measurement request
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct hih6130 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) struct i2c_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct mutex lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) bool valid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) unsigned long last_update;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int temperature;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int humidity;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) size_t write_length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * hih6130_temp_ticks_to_millicelsius() - convert raw temperature ticks to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * milli celsius
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @ticks: temperature ticks value received from sensor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static inline int hih6130_temp_ticks_to_millicelsius(int ticks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ticks = ticks >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * from data sheet section 5.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * Formula T = ( ticks / ( 2^14 - 2 ) ) * 165 -40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) return (DIV_ROUND_CLOSEST(ticks * 1650, 16382) - 400) * 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * hih6130_rh_ticks_to_per_cent_mille() - convert raw humidity ticks to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * one-thousandths of a percent relative humidity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * @ticks: humidity ticks value received from sensor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) static inline int hih6130_rh_ticks_to_per_cent_mille(int ticks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ticks &= ~0xC000; /* clear status bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * from data sheet section 4.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * Formula RH = ( ticks / ( 2^14 -2 ) ) * 100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) return DIV_ROUND_CLOSEST(ticks * 1000, 16382) * 100;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * hih6130_update_measurements() - get updated measurements from device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * @dev: device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) * Returns 0 on success, else negative errno.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static int hih6130_update_measurements(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct hih6130 *hih6130 = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct i2c_client *client = hih6130->client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) int t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned char tmp[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) struct i2c_msg msgs[1] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) .addr = client->addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) .flags = I2C_M_RD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) .len = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) .buf = tmp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) mutex_lock(&hih6130->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) * While the measurement can be completed in ~40ms the sensor takes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * much longer to react to a change in external conditions. How quickly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * it reacts depends on airflow and other factors outwith our control.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * The datasheet specifies maximum 'Response time' for humidity at 8s
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * and temperature at 30s under specified conditions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * We therefore choose to only read the sensor at most once per second.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * This trades off pointless activity polling the sensor much faster
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * than it can react against better response times in conditions more
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * favourable than specified in the datasheet.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (time_after(jiffies, hih6130->last_update + HZ) || !hih6130->valid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * Write to slave address to request a measurement.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) * According with the datasheet it should be with no data, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * for systems with I2C bus drivers that do not allow zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * length packets we write one dummy byte to allow sensor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) * measurements on them.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) tmp[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) ret = i2c_master_send(client, tmp, hih6130->write_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) /* measurement cycle time is ~36.65msec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) msleep(40);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ret = i2c_transfer(client->adapter, msgs, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) if ((tmp[0] & 0xC0) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) dev_err(&client->dev, "Error while reading measurement result\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) t = (tmp[0] << 8) + tmp[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) hih6130->humidity = hih6130_rh_ticks_to_per_cent_mille(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) t = (tmp[2] << 8) + tmp[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) hih6130->temperature = hih6130_temp_ticks_to_millicelsius(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) hih6130->last_update = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) hih6130->valid = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) mutex_unlock(&hih6130->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return ret >= 0 ? 0 : ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * hih6130_show_temperature() - show temperature measurement value in sysfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * @dev: device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * @attr: device attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * @buf: sysfs buffer (PAGE_SIZE) where measurement values are written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * Will be called on read access to temp1_input sysfs attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) * Returns number of bytes written into buffer, negative errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static ssize_t hih6130_temperature_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct hih6130 *hih6130 = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ret = hih6130_update_measurements(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return sprintf(buf, "%d\n", hih6130->temperature);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * hih6130_show_humidity() - show humidity measurement value in sysfs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * @dev: device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * @attr: device attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * @buf: sysfs buffer (PAGE_SIZE) where measurement values are written to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * Will be called on read access to humidity1_input sysfs attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * Returns number of bytes written into buffer, negative errno on error.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) static ssize_t hih6130_humidity_show(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct hih6130 *hih6130 = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ret = hih6130_update_measurements(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return sprintf(buf, "%d\n", hih6130->humidity);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* sysfs attributes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) static SENSOR_DEVICE_ATTR_RO(temp1_input, hih6130_temperature, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static SENSOR_DEVICE_ATTR_RO(humidity1_input, hih6130_humidity, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static struct attribute *hih6130_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) &sensor_dev_attr_temp1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) &sensor_dev_attr_humidity1_input.dev_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) ATTRIBUTE_GROUPS(hih6130);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) static int hih6130_probe(struct i2c_client *client)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct device *dev = &client->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct hih6130 *hih6130;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct device *hwmon_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) dev_err(&client->dev, "adapter does not support true I2C\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) hih6130 = devm_kzalloc(dev, sizeof(*hih6130), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) if (!hih6130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) hih6130->client = client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) mutex_init(&hih6130->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_QUICK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) hih6130->write_length = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) hih6130,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) hih6130_groups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) return PTR_ERR_OR_ZERO(hwmon_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) /* Device ID table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static const struct i2c_device_id hih6130_id[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) { "hih6130", 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) MODULE_DEVICE_TABLE(i2c, hih6130_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) static const struct of_device_id __maybe_unused hih6130_of_match[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) { .compatible = "honeywell,hih6130", },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) { }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) MODULE_DEVICE_TABLE(of, hih6130_of_match);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) static struct i2c_driver hih6130_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) .driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) .name = "hih6130",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) .of_match_table = of_match_ptr(hih6130_of_match),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) .probe_new = hih6130_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) .id_table = hih6130_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) module_i2c_driver(hih6130_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) MODULE_AUTHOR("Iain Paton <ipaton0@gmail.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) MODULE_DESCRIPTION("Honeywell HIH-6130 humidity and temperature sensor driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) MODULE_LICENSE("GPL");