iio: humidity: sht31: add Sensirion SHT31 support
Subsystems (4)
cover iio: humidity: sht31: add Sensirion SHT31 support
Add support for the humidity and temperature functionally for the SHT31 chipset. In addition add support for using using software triggers.
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support
.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/humidity/sht31.c
Signature · 1 line
2.7.4
PATCH 1/2 devicetree: add Sensirion AG vendor id
In reply to a message not in the archive--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -225,6 +225,7 @@ sbs Smart Battery System schindler Schindler seagate Seagate Technology PLC semtech Semtech Corporation +sensirion Sensirion AG Switzerland sgx SGX Sensortech sharp Sharp Corporation si-en Si-En Technology Ltd.
Signature · 1 line
2.7.4
PATCH 2/2 iio: humidity: sht31: add Sensirion SHT31 support
In reply to Matt RanostayAdd support for the Sensirion SHT31 humidity + temperature sensor.
--- .../devicetree/bindings/i2c/trivial-devices.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 4 files changed, 429 insertions(+) create mode 100644 drivers/iio/humidity/sht31.c
Documentation/devicetree/bindings/i2c/trivial-devices.txt +1 -0
@@ -78,6 +78,7 @@ ricoh,rs5c372b I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC ricoh,rv5c386 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC ricoh,rv5c387a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC samsung,24ad0xd1 S524AD0XF1 (128K/256K-bit Serial EEPROM for Low Power) +sensirion,sht31 Sensirion SHT31 humidity + temperature sensor sgx,vz89x SGX Sensortech VZ89X Sensors sii,s35390a 2-wire CMOS real-time clock skyworks,sky81452 Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supply
drivers/iio/humidity/Kconfig +11 -0
@@ -45,6 +45,17 @@ config HTU21 This driver can also be built as a module. If so, the module will be called htu21. +config SHT31 + tristate "Sensirion SHT31 humidity and temperature sensor" + depends on I2C + select CRC8 + help + If you say yes here you support for the Sensirion SHT31 humidity and + temperature sensor. + + This driver can also be built as a module. If so, the module will be + called sht31. + config SI7005 tristate "SI7005 relative humidity and temperature sensor" depends on I2C
drivers/iio/humidity/Makefile +1 -0
@@ -6,5 +6,6 @@ obj-$(CONFIG_AM2315) += am2315.o obj-$(CONFIG_DHT11) += dht11.o obj-$(CONFIG_HDC100X) += hdc100x.o obj-$(CONFIG_HTU21) += htu21.o +obj-$(CONFIG_SHT31) += sht31.o obj-$(CONFIG_SI7005) += si7005.o obj-$(CONFIG_SI7020) += si7020.o
drivers/iio/humidity/sht31.c new file +416 -0
416 lines not on this page · raw message
Signature · 1 line
2.7.4
Quoted 285 lines · Matt Ranostay
Add support for the Sensirion SHT31 humidity + temperature sensor.
Signed-off-by Matt Ranostay <[email protected]>--- .../devicetree/bindings/i2c/trivial-devices.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 4 files changed, 429 insertions(+) create mode 100644 drivers/iio/humidity/sht31.cDocumentation/devicetree/bindings/i2c/trivial-devices.txt +1
-0@@ -78,6 +78,7 @@ ricoh,rs5c372b I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC ricoh,rv5c386 I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC ricoh,rv5c387a I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC samsung,24ad0xd1 S524AD0XF1 (128K/256K-bit Serial EEPROM for Low Power) +sensirion,sht31 Sensirion SHT31 humidity + temperature sensor sgx,vz89x SGX Sensortech VZ89X Sensors sii,s35390a 2-wire CMOS real-time clock skyworks,sky81452 Skyworks SKY81452: Six-Channel White LED Driver with Touch Panel Bias Supplydrivers/iio/humidity/Kconfig +11
-0@@ -45,6 +45,17 @@ config HTU21 This driver can also be built as a module. If so, the module will be called htu21. +config SHT31 + tristate "Sensirion SHT31 humidity and temperature sensor" + depends on I2C + select CRC8 + help + If you say yes here you support for the Sensirion SHT31 humidity and + temperature sensor. + + This driver can also be built as a module. If so, the module will be + called sht31. + config SI7005 tristate "SI7005 relative humidity and temperature sensor" depends on I2Cdrivers/iio/humidity/Makefile +1
-0@@ -6,5 +6,6 @@ obj-$(CONFIG_AM2315) += am2315.o obj-$(CONFIG_DHT11) += dht11.o obj-$(CONFIG_HDC100X) += hdc100x.o obj-$(CONFIG_HTU21) += htu21.o +obj-$(CONFIG_SHT31) += sht31.o obj-$(CONFIG_SI7005) += si7005.o obj-$(CONFIG_SI7020) += si7020.odrivers/iio/humidity/sht31.c new file +223
-0@@ -0,0 +1,416 @@ +/* +* sht31.c - Support for the Sensirion SHT31 temperature + humidity sensor +* +* Copyright (C) 2016 Matt Ranostay <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +*/ + +#include <linux/crc8.h> +#include <linux/module.h> +#include <linux/mutex.h> +#include <linux/init.h> +#include <linux/i2c.h> +#include <linux/iio/iio.h> +#include <linux/iio/sysfs.h> +#include <linux/iio/buffer.h> +#include <linux/iio/trigger.h> +#include <linux/iio/triggered_buffer.h> +#include <linux/iio/trigger_consumer.h> + +#define SHT31_DRV_NAME "sht31" + +#define SHT31_HEATER_CMD_MSB 0x30 +#define SHT31_HEATER_CMD_ENABLE 0x6d +#define SHT31_HEATER_CMD_DISABLE 0x66 + +#define SHT31_MEASUREMENT_CMD_MSB (0x2C << 8) + +#define SHT31_STATUS_CMD 0xF32D +#define SHT31_STATUS_CMD_CHKSUM BIT(0) + +struct sht31_data { +struct iio_dev *indio_dev; +struct i2c_client *client; +struct mutex lock; + +/* config */ +int heater_status; +int it_time; + +u8 crc_table[CRC8_TABLE_SIZE ]; +u16 buffer[8 ];/* 4 byte data + 2 byte pad + 8 byte */ +}; + +static const struct iio_chan_spec sht31_channels[] = { + { + .type =IIO_TEMP , + .address =0 , + .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ) | +BIT (IIO_CHAN_INFO_OFFSET ), + .info_mask_shared_by_all =BIT (IIO_CHAN_INFO_INT_TIME ), + .scan_index =0 , + .scan_type = { + .sign ='u' , + .realbits =16 , + .storagebits =16 , + }, + }, + { + .type =IIO_HUMIDITYRELATIVE , + .address =1 , + .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ), + .info_mask_shared_by_all =BIT (IIO_CHAN_INFO_INT_TIME ), + .scan_index =1 , + .scan_type = { + .sign ='u' , + .realbits =16 , + .storagebits =16 , + }, + }, +IIO_CHAN_SOFT_TIMESTAMP (2 ), + { + .type =IIO_CURRENT , + .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ), + .extend_name ="heater" , + .scan_index =-1 , + .output =1 , + }, +}; + +static IIO_CONST_ATTR(integration_time_available, + "0.0025 0.0045 0.0125"); + +static IIO_CONST_ATTR(out_current_heater_raw_available, + "0 1"); + +/* integration time + LSB of I2C command */ +static const int sht31_integration_time[][2 ] = { + {2500 ,0x10 }, + {4500 ,0x0d }, + {12500 ,0x06 } +}; + +static const unsigned long sht31_scan_masks[] = {0x3 ,0 }; + +static struct attribute *sht31_attributes[] = { + &iio_const_attr_integration_time_available.dev_attr.attr, + &iio_const_attr_out_current_heater_raw_available.dev_attr.attr, +NULL +}; + +static struct attribute_group sht31_attribute_group = { + .attrs = sht31_attributes, +}; + +static int sht31_crc8_check (struct sht31_data *data,u8 *vals) +{ +int ret =crc8 (data->crc_table, vals,2 ,0xff ); + +if (ret != vals[2 ]) +return -EINVAL ; + +return 0 ; +} + +static int sht31_get_measurement (struct sht31_data *data,u16 *buf) +{ +struct i2c_client *client = data->client; +struct i2c_msg msg[2 ]; +u16 reg =cpu_to_be16 (SHT31_MEASUREMENT_CMD_MSB | + sht31_integration_time[data->it_time][1 ]); +u8 vals[6 ]; +int ret, i; + + msg[0 ].addr = client->addr; + msg[0 ].flags = client->flags; + msg[0 ].len =2 ; + msg[0 ].buf = (char *) ® + + msg[1 ].addr = client->addr; + msg[1 ].flags = client->flags |I2C_M_RD ; + msg[1 ].len =sizeof (vals); + msg[1 ].buf = (char *) &vals; + + ret =i2c_transfer (client->adapter, msg,2 ); +if (ret !=2 ) +return -EIO ; + +for (i =0 ; i <2 ; i++) { + ret =sht31_crc8_check (data, (u8 *) &vals[3 * i]); +if (ret) +return -EINVAL ; + *buf++ =be16_to_cpu (*((u16 *) &vals[3 * i])); + } + +return 0 ; +} + +static irqreturn_t sht31_trigger_handler (int irq,void *private) +{ +struct iio_poll_func *pf = private; +struct iio_dev *indio_dev = pf->indio_dev; +struct sht31_data *data =iio_priv (indio_dev); +int ret; + + ret =sht31_get_measurement (data, data->buffer); +if (!ret) +iio_push_to_buffers_with_timestamp (indio_dev, data->buffer, +iio_get_time_ns ()); +iio_trigger_notify_done (indio_dev->trig); + +return IRQ_HANDLED ; +} + +static int sht31_read_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan, +int *val,int *val2,long mask) +{ +struct sht31_data *data =iio_priv (indio_dev); +int ret = -EINVAL ; +u16 buf[2 ]; + +switch (mask) { +case IIO_CHAN_INFO_INT_TIME : +mutex_lock (&data->lock); + *val =0 ; + *val2 = sht31_integration_time[data->it_time][0 ]; + ret =IIO_VAL_INT_PLUS_MICRO ; +mutex_unlock (&data->lock); +break ; +case IIO_CHAN_INFO_RAW : +switch (chan->type) { +case IIO_HUMIDITYRELATIVE : +case IIO_TEMP : +if (iio_device_claim_direct_mode (indio_dev)) +return -EBUSY ; + + ret =sht31_get_measurement (data, (u16 *) &buf); +if (!ret) { + *val = buf[chan->address]; + ret =IIO_VAL_INT ; + } +iio_device_release_direct_mode (indio_dev); +break ; +case IIO_CURRENT : +mutex_lock (&data->lock); + *val = data->heater_status; + ret =IIO_VAL_INT ; +mutex_unlock (&data->lock); +break ; +default : +return -EINVAL ; + } +break ; +case IIO_CHAN_INFO_SCALE : +switch (chan->type) { +case IIO_HUMIDITYRELATIVE : + *val =100 ; + *val2 =65535 ; +break ; +case IIO_TEMP : + *val =175000 ;
drivers/iio/humidity/sht31.c line 233
Quoted 10 lines
drivers/iio/humidity/sht31.c new file +10
-0+ *val2 =65535 ; +break ; +default : +return -EINVAL ; + } + ret =IIO_VAL_FRACTIONAL ; +break ; +case IIO_CHAN_INFO_OFFSET : + *val =18349 ;/* 18349.8 */ + *val2 =800000 ;
*doh* doublechecking my maths for the calculation I think it should be the following after all 16851.857142
Quoted 186 lines
drivers/iio/humidity/sht31.c new file +183
-1+ ret =IIO_VAL_INT_PLUS_MICRO ; +break ; + } + +return ret; +} + +static int sht31_set_it_time (struct sht31_data *data,int val2) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (sht31_integration_time); i++) { +if (sht31_integration_time[i][0 ] == val2) { + data->it_time = i; +return 0 ; + } + } + +return -EINVAL ; +} + +static int sht31_validate_checksum (struct sht31_data *data) +{ +struct i2c_client *client = data->client; +struct i2c_msg msg[2 ]; +u16 reg =cpu_to_be16 (SHT31_STATUS_CMD ); +u8 vals[3 ]; +int ret; + + msg[0 ].addr = client->addr; + msg[0 ].flags = client->flags; + msg[0 ].len =2 ; + msg[0 ].buf = (char *) ® + + msg[1 ].addr = client->addr; + msg[1 ].flags = client->flags |I2C_M_RD ; + msg[1 ].len =sizeof (vals); + msg[1 ].buf = (char *) &vals; + + ret =i2c_transfer (client->adapter, msg,2 ); +if (ret !=2 ) +return -EIO ; + + ret =sht31_crc8_check (data, (u8 *) &vals); +if (ret) +return ret; + +return (vals[1 ] &SHT31_STATUS_CMD_CHKSUM ) ? -EINVAL :0 ; +} + +static int sht31_set_heater_status (struct sht31_data *data,int val) +{ +int ret; + + ret =i2c_smbus_write_byte_data (data->client,SHT31_HEATER_CMD_MSB , + val ?SHT31_HEATER_CMD_ENABLE :SHT31_HEATER_CMD_DISABLE ); +if (ret <0 ) +return ret; + + ret =sht31_validate_checksum (data); +if (!ret) + data->heater_status = !!val; + +return ret; +} + +static int sht31_write_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan, +int val,int val2,long mask) +{ +struct sht31_data *data =iio_priv (indio_dev); +int ret = -EINVAL ; + +switch (mask) { +case IIO_CHAN_INFO_INT_TIME : +if (val !=0 ) +return -EINVAL ; + +mutex_lock (&data->lock); + ret =sht31_set_it_time (data, val2); +mutex_unlock (&data->lock); +break ; +case IIO_CHAN_INFO_RAW : +if (chan->type !=IIO_CURRENT || val2 !=0 ) +return -EINVAL ; + +mutex_lock (&data->lock); + ret =sht31_set_heater_status (data, val); +mutex_unlock (&data->lock); +break ; + } + +return ret; +} + +static const struct iio_info sht31_info = { + .driver_module =THIS_MODULE , + .read_raw = sht31_read_raw, + .write_raw = sht31_write_raw, + .attrs = &sht31_attribute_group, +}; + +static int sht31_probe (struct i2c_client *client, +const struct i2c_device_id *id) +{ +struct sht31_data *data; +struct iio_dev *indio_dev; +int ret; + + indio_dev =devm_iio_device_alloc (&client->dev,sizeof (*data)); +if (!indio_dev) +return -ENOMEM ; + data =iio_priv (indio_dev); + + indio_dev->info = &sht31_info; + indio_dev->name =SHT31_DRV_NAME ; + indio_dev->channels = sht31_channels; + indio_dev->num_channels =ARRAY_SIZE (sht31_channels); + indio_dev->available_scan_masks = sht31_scan_masks; + indio_dev->modes =INDIO_DIRECT_MODE ; + indio_dev->dev.parent = &client->dev; + +i2c_set_clientdata (client, indio_dev); + + data->client = client; + data->indio_dev = indio_dev; +mutex_init (&data->lock); + +/* CRC polynomial x8 + x5 + x4 + 1 */ +crc8_populate_msb (data->crc_table,0x31 ); + + ret =iio_triggered_buffer_setup (indio_dev,NULL , + sht31_trigger_handler,NULL ); +if (ret) +return ret; + + ret =iio_device_register (indio_dev); +if (ret) + goto error_unreg_buffer; + +return 0 ; + +error_unreg_buffer: +iio_triggered_buffer_cleanup (indio_dev); + +return ret; +} + +static int sht31_remove (struct i2c_client *client) +{ +struct iio_dev *indio_dev =i2c_get_clientdata (client); + +iio_device_unregister (indio_dev); +iio_triggered_buffer_cleanup (indio_dev); + +return 0 ; +} + +static const struct of_device_id sht31_dt_ids[] = { + { .compatible ="sensirion,sht31" }, + { } +}; +MODULE_DEVICE_TABLE (of, sht31_dt_ids); + +static const struct i2c_device_id sht31_id[] = { + {"sht31" ,0 }, + { } +}; +MODULE_DEVICE_TABLE (i2c, sht31_id); + +static struct i2c_driver sht31_driver = { + .driver = { + .name =SHT31_DRV_NAME , + }, + .probe = sht31_probe, + .remove = sht31_remove, + .id_table = sht31_id, +}; +module_i2c_driver (sht31_driver); + +MODULE_AUTHOR ("Matt Ranostay <[email protected]>" ); +MODULE_DESCRIPTION ("Sensirion SHT31 humidity and temperature sensor driver" ); +MODULE_LICENSE ("GPL" ); --2.7.4
Quoted 2 lines · Matt Ranostay
Add support for the humidity and temperature functionally for the SHT31 chipset. In addition add support for using using software triggers.
Now that I'm hwmon-aware ;) I see this same driver under review in hwmon. Can support exist in 2 places?
alisons
Quoted 20 lines
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/humidity/sht31.cSignature · 6 lines
2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Didn't notice that will till now, and looking at the timestamp I see why :). However this is more for the sw triggered buffer support which hwmon lacks... there is a few examples of this already in the tree.
Maybe Jonathan and Peter will have some input on this.
Quoted 29 lines · Alison Schofield
Quoted 2 lines · Matt Ranostay
Add support for the humidity and temperature functionally for the SHT31 chipset. In addition add support for using using software triggers.
Now that I'm hwmon-aware ;) I see this same driver under review in hwmon. Can support exist in 2 places?
alisons
Quoted 20 lines
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/humidity/sht31.c--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Matt Ranostay
Didn't notice that will till now, and looking at the timestamp I see why :). However this is more for the sw triggered buffer support which hwmon lacks... there is a few examples of this already in the tree.
Maybe Jonathan and Peter will have some input on this.
Thanks for highlighting this Alison. Not the first time we have had simultaneous driver postings under review for both IIO and HWMON unfortunately.
The hwmon guys are fairly flexible iff there is a good reason to want stuff that is in IIO. The original hwmon humidity driver was actually my fault as it slipped in when hwmon was effectively not maintained (Andrew Morton was babysitting). People on their side have always been a bit split on humidity drivers and whether they are within their scope.
Anyhow, best bet is to email their list (perhaps reply to the driver thread) to make sure everyone knows this is going on (cc linux-iio as well). Then we can work out how to move forward.
Two drivers, one in each place is a non starter for new parts. We have ended up with a few instances, but it's mostly been a case of a driver with much wider scope ending up covering parts that were already in hwmon. Also a very small number of devices have moved across from hwmon to IIO.
In this particular case the sensor is reasonably fast so there is at least some argument for IIO support. Note I tend to stay out of these and let the driver author work on convincing Guenter / Jean (they are very reasonable and responsive!) Only thing I'll say is that I'm more than happy to have this in IIO if the hwmon guys don't mind.
Jonathan
Quoted 31 lines · Alison Schofield
Quoted 30 lines · Matt Ranostay
Quoted 2 lines
Add support for the humidity and temperature functionally for the SHT31 chipset. In addition add support for using using software triggers.
Now that I'm hwmon-aware ;) I see this same driver under review in hwmon. Can support exist in 2 places?
alisons
Quoted 21 lines
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/humidity/sht31.c--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Guenter et al,
So seems I wrote an iio driver for the SHT31 chipset about the same David Frey had his merged into hwmon tree. So was wondering per Jonathan's comments what your input on this would be.
Quoted 1 line
From what I can see the additional functionality of the hrtimer
trigger + rather fast update/integration time that a case could be made because of the triggered buffer.
Now there is some functionality missing from my iio driver than exists in the hwmon.. like the thermal and humidity trip points (but that can be handled in a userspace HAL anyway), and the non-clock skewing read/write functionality (this can be easily added).
Thanks,
Matt
Quoted 73 lines · On Tue, Jun 14, 2016 at 12:44 AM, <[email protected]> wrote:
Quoted 8 lines · Matt Ranostay
Didn't notice that will till now, and looking at the timestamp I see why :).
However this is more for the sw triggered buffer support which hwmon lacks... there is a few examples of this already in the tree.Maybe Jonathan and Peter will have some input on this.
Thanks for highlighting this Alison. Not the first time we have had simultaneous driver postings under review for both IIO and HWMON unfortunately.
The hwmon guys are fairly flexible iff there is a good reason to want stuff that is in IIO. The original hwmon humidity driver was actually my fault as it slipped in when hwmon was effectively not maintained (Andrew Morton was
babysitting). People on their side have always been a bit split on humidity drivers and whether they are within their scope.Anyhow, best bet is to email their list (perhaps reply to the driver thread) to make sure everyone knows this is going on (cc linux-iio as well). Then we can work out how to move forward.
Two drivers, one in each place is a non starter for new parts. We have ended up with a few instances, but it's mostly been a case of a driver with much wider scope ending up covering parts that were already in hwmon. Also a very small number of devices have moved across from hwmon to IIO.
In this particular case the sensor is reasonably fast so there is at least some argument for IIO support. Note I tend to stay out of these and let the driver author work on convincing Guenter / Jean (they are very reasonable and responsive!) Only thing I'll say is that I'm more than happy to have this in IIO if the hwmon guys don't mind.
Jonathan
Quoted 36 lines
Quoted 34 lines · Alison Schofield
Quoted 3 lines · Matt Ranostay
Add support for the humidity and temperature functionally for the SHT31 chipset. In addition add support for using using software triggers.
Now that I'm hwmon-aware ;) I see this same driver under review in hwmon.
Can support exist in 2 places?alisons
Quoted 21 lines
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/humidity/sht31.c--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Rob Herring
Acked-byRe: [PATCH 1/2] devicetree: add Sensirion AG vendor id
In reply to a message not in the archiveQuoted 6 lines · Matt Ranostay
Cc Rob Herring <[email protected]>Signed-off-by Matt Ranostay <[email protected]>--- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+)
Guenter Roeck
maintainerQuoted 6 lines · Matt Ranostay
Hello Guenter et al,
So seems I wrote an iio driver for the SHT31 chipset about the same David Frey had his merged into hwmon tree. So was wondering per Jonathan's comments what your input on this would be.
Quoted 9 lines
Quoted 1 line
Quoted 1 line
From what I can see the additional functionality of the hrtimer
trigger + rather fast update/integration time that a case could be made because of the triggered buffer.
Now there is some functionality missing from my iio driver than exists in the hwmon.. like the thermal and humidity trip points (but that can be handled in a userspace HAL anyway), and the non-clock skewing read/write functionality (this can be easily added).
I am quite sure that we had this discussion about this very driver before. One of the key reasons for going with hwmon was limit register support.
Guess you claim that is no longer relevant since it can be handled in user space ? If so, I would disagree; it seems to be difficult to generate an alert signal from user space.
I don't mind if you folks want drivers for chips like like this (ie chips supporting limits, or in other words typical hardware monitoring chips) in iio, but I would kindly ask to enhance the iio subsystem to support limits.
It might be worth mentioning that at least for my part am not split on humidity sensors. They are supported in high end servers and thus used for hardware monitoring.
Thanks,
Guenter
Quoted 85 lines
Thanks,
Matt
Quoted 29 lines · On Tue, Jun 14, 2016 at 12:44 AM, <[email protected]> wrote:
Quoted 8 lines · Matt Ranostay
Didn't notice that will till now, and looking at the timestamp I see why :).
However this is more for the sw triggered buffer support which hwmon lacks... there is a few examples of this already in the tree.Maybe Jonathan and Peter will have some input on this.
Thanks for highlighting this Alison. Not the first time we have had simultaneous driver postings under review for both IIO and HWMON unfortunately.
The hwmon guys are fairly flexible iff there is a good reason to want stuff that is in IIO. The original hwmon humidity driver was actually my fault as it slipped in when hwmon was effectively not maintained (Andrew Morton was
babysitting). People on their side have always been a bit split on humidity drivers and whether they are within their scope.Anyhow, best bet is to email their list (perhaps reply to the driver thread) to make sure everyone knows this is going on (cc linux-iio as well). Then we can work out how to move forward.
Two drivers, one in each place is a non starter for new parts. We have ended up with a few instances, but it's mostly been a case of a driver with much wider scope ending up covering parts that were already in hwmon. Also a very small number of devices have moved across from hwmon to IIO.
Quoted 44 lines
In this particular case the sensor is reasonably fast so there is at least some argument for IIO support. Note I tend to stay out of these and let the driver author work on convincing Guenter / Jean (they are very reasonable and responsive!) Only thing I'll say is that I'm more than happy to have this in IIO if the hwmon guys don't mind.
Jonathan
Quoted 36 lines
Quoted 34 lines · Alison Schofield
Quoted 3 lines · Matt Ranostay
Add support for the humidity and temperature functionally for the SHT31 chipset. In addition add support for using using software triggers.
Now that I'm hwmon-aware ;) I see this same driver under review in hwmon.
Can support exist in 2 places?alisons
Quoted 21 lines
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+)create mode 100644
drivers/iio/humidity/sht31.c--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 23 lines · Guenter Roeck
Quoted 11 lines · Matt Ranostay
Hello Guenter et al,
So seems I wrote an iio driver for the SHT31 chipset about the same David Frey had his merged into hwmon tree. So was wondering per Jonathan's comments what your input on this would be.
Quoted 1 line
From what I can see the additional functionality of the hrtimer
trigger + rather fast update/integration time that a case could be made because of the triggered buffer.
Now there is some functionality missing from my iio driver than
exists
Quoted 1 line
in the hwmon.. like the thermal and humidity trip points (but that
can
Quoted 3 lines
be handled in a userspace HAL anyway), and the non-clock skewing read/write functionality (this can be easily added).
I am quite sure that we had this discussion about this very driver before.
One of the key reasons for going with hwmon was limit register support.
Quoted 5 lines
Guess you claim that is no longer relevant since it can be handled in user space ?
If so, I would disagree; it seems to be difficult to generate an alert signal
from user space.
Agreed
Quoted 6 lines
I don't mind if you folks want drivers for chips like like this (ie chips supporting
limits, or in other words typical hardware monitoring chips) in iio, but I would
kindly ask to enhance the iio subsystem to support limits.
It has done since day one via event chardev. Limitations are :
* One per channel per type per direction. (Didn't seem necessary at the time) This obviously matters for hwmon chips.
* No in kernel interface yet so not pushed on to iio-hwmon bridge.
* Intended for interrupt type limits which do not always correspond to how all devices do it... there are ways around it but only indirectly.
All fixable and not actually directly relevant for this part (possibly the inkern
interface is...)
Quoted 5 lines
It might be worth mentioning that at least for my part am not split on humidity
sensors. They are supported in high end servers and thus used for hardware monitoring.
Cool. Didn't know that.
Jonathan
Quoted 111 lines
Thanks,
GuenterQuoted 7 lines
Thanks,
Matt
On Tue, Jun 14, 2016 at 12:44 AM, <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines · Matt Ranostay
Quoted 2 lines
Didn't notice that will till now, and looking at the timestamp I
see why
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
:).
However this is more for the sw triggered buffer support whichhwmon
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
lacks... there is a few examples of this already in the tree.
Maybe Jonathan and Peter will have some input on this.
Thanks for highlighting this Alison. Not the first time we have had simultaneous driver postings under review for both IIO and HWMON unfortunately.
The hwmon guys are fairly flexible iff there is a good reason to
want stuff
Quoted 1 line
Quoted 1 line
that is in IIO. The original hwmon humidity driver was actually my
fault
Quoted 1 line
Quoted 1 line
as it slipped in when hwmon was effectively not maintained (Andrew
Morton
Quoted 2 lines
Quoted 2 lines
was
babysitting). People on their side have always been a bit split onhumidity
Quoted 3 lines
Quoted 3 lines
drivers and whether they are within their scope.
Anyhow, best bet is to email their list (perhaps reply to the driver
thread)
Quoted 4 lines
Quoted 4 lines
to make sure everyone knows this is going on (cc linux-iio as well). Then we can work out how to move forward.
Two drivers, one in each place is a non starter for new parts. We
have
Quoted 1 line
Quoted 1 line
ended up with a few instances, but it's mostly been a case of a
driver
Quoted 1 line
Quoted 1 line
with much wider scope ending up covering parts that were already in
hwmon.
Quoted 1 line
Quoted 1 line
Also a very small number of devices have moved across from hwmon to
IIO.
Quoted 3 lines
Quoted 3 lines
In this particular case the sensor is reasonably fast so there is at least some argument for IIO support. Note I tend to stay out of
these
Quoted 2 lines
Quoted 2 lines
and let the driver author work on convincing Guenter / Jean (they are very reasonable and responsive!) Only thing I'll say is
that
Quoted 1 line
Quoted 1 line
I'm more than happy to have this in IIO if the hwmon guys don't
mind.
Quoted 4 lines
Quoted 4 lines
Jonathan
Quoted 1 line
On Mon, Jun 13, 2016 at 3:25 PM, Alison Schofield
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines · wrote:
Quoted 2 lines · Matt Ranostay
Add support for the humidity and temperature functionally for the
SHT31
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
chipset. In addition add support for using using software
triggers.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Now that I'm hwmon-aware ;) I see this same driver under review
in
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
hwmon.
Can support exist in 2 places?alisons
Quoted 14 lines
Matt Ranostay (2):
devicetree: add Sensirion AG vendor id
iio: humidity: sht31: add Sensirion SHT31 support.../devicetree/bindings/i2c/trivial-devices.txt | 1 + .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/iio/humidity/Kconfig | 11 + drivers/iio/humidity/Makefile | 1 + drivers/iio/humidity/sht31.c | 416 +++++++++++++++++++++ 5 files changed, 430 insertions(+)create mode 100644
drivers/iio/humidity/sht31.cQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
--
2.7.4--
To unsubscribe from this list: send the line "unsubscribelinux-iio" in
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Quoted 2 lines
--
To unsubscribe from this list: send the line "unsubscribelinux-hwmon" in
Quoted 3 lines
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Guenter Roeck
maintainerQuoted 46 lines · Jonathan Cameron
Quoted 23 lines · Guenter Roeck
Quoted 11 lines · Matt Ranostay
Hello Guenter et al,
So seems I wrote an iio driver for the SHT31 chipset about the same David Frey had his merged into hwmon tree. So was wondering per Jonathan's comments what your input on this would be.
Quoted 1 line
From what I can see the additional functionality of the hrtimer
trigger + rather fast update/integration time that a case could be made because of the triggered buffer.
Now there is some functionality missing from my iio driver than
exists
Quoted 1 line
in the hwmon.. like the thermal and humidity trip points (but that
can
Quoted 3 lines
be handled in a userspace HAL anyway), and the non-clock skewing read/write functionality (this can be easily added).
I am quite sure that we had this discussion about this very driver before.
One of the key reasons for going with hwmon was limit register support.Quoted 5 lines
Guess you claim that is no longer relevant since it can be handled in user space ?
If so, I would disagree; it seems to be difficult to generate an alert signal
from user space.Agreed
Quoted 6 lines
I don't mind if you folks want drivers for chips like like this (ie chips supporting
limits, or in other words typical hardware monitoring chips) in iio, but I would
kindly ask to enhance the iio subsystem to support limits.It has done since day one via event chardev. Limitations are :
* One per channel per type per direction. (Didn't seem necessary at the time) This obviously matters for hwmon chips.
* No in kernel interface yet so not pushed on to iio-hwmon bridge.
* Intended for interrupt type limits which do not always correspond to how all devices do it... there are ways around it but only indirectly.
Quoted 2 lines
All fixable and not actually directly relevant for this part (possibly the inkern
interface is...)
Sure, all is fixable. Not that it will help here.
If you plan to accept this driver, please let me and David know, and I'll drop the hwmon driver. It means we'll both have wasted our time, but it does not make sense to keep two drivers for this chip around.
On another side note, I don't really believe that it makes much sense to add all this functionality to iio to start with. I'd rather fix the hwmon registration API and create a hwmon->iio bridge.
Guenter
Quoted 51 lines · Guenter Roeck
Quoted 3 lines · Jonathan Cameron
On 15 June 2016 05:18:05 BST, Guenter Roeck <[email protected]>
Quoted 4 lines · wrote:
Quoted 4 lines · Matt Ranostay
Quoted 3 lines
Hello Guenter et al,
So seems I wrote an iio driver for the SHT31 chipset about the
same
Quoted 10 lines
Quoted 10 lines
Quoted 8 lines
David Frey had his merged into hwmon tree. So was wondering per Jonathan's comments what your input on this would be.
Quoted 1 line
From what I can see the additional functionality of the hrtimer
trigger + rather fast update/integration time that a case could be made because of the triggered buffer.
Now there is some functionality missing from my iio driver than
exists
Quoted 1 line
in the hwmon.. like the thermal and humidity trip points (but that
Quoted 8 lines
Quoted 8 lines
can
Quoted 3 lines
be handled in a userspace HAL anyway), and the non-clock skewing read/write functionality (this can be easily added).
I am quite sure that we had this discussion about this very driver before.
One of the key reasons for going with hwmon was limit registersupport.
Quoted 2 lines
Quoted 2 lines
Guess you claim that is no longer relevant since it can be handled
in
Quoted 2 lines
Quoted 2 lines
user space ?
If so, I would disagree; it seems to be difficult to generate analert
Quoted 4 lines
Quoted 2 lines
signal
from user space.Agreed
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
I don't mind if you folks want drivers for chips like like this (ie chips supporting
limits, or in other words typical hardware monitoring chips) in iio, but I would
kindly ask to enhance the iio subsystem to support limits.It has done since day one via event chardev. Limitations are :
* One per channel per type per direction. (Didn't seem necessary atthe time)
Quoted 3 lines
This obviously matters for hwmon chips.
* No in kernel interface yet so not pushed on to iio-hwmon bridge.
* Intended for interrupt type limits which do not always correspond
Quoted 8 lines
to how all
Quoted 3 lines
devices do it... there are ways around it but only indirectly.
All fixable and not actually directly relevant for this part
(possibly the inkern
Quoted 1 line
interface is...)
Sure, all is fixable. Not that it will help here.
Quite.
Quoted 6 lines
If you plan to accept this driver, please let me and David know, and I'll drop
the hwmon driver. It means we'll both have wasted our time, but it does not make
sense to keep two drivers for this chip around.
I don't plan to accept it. The argument in favour has not been strong enough for likely uses if this part. Humidity doesn't typically change that fast. Would need a really strong usecase argument to persuade me... (if anyone has one, now is the time to raise it!)
If the drivers had turned up in the other order I would been fine with it in IIO. Sadly it happens sometimes and this time Matt loses! Sorry Matt.
However, whilst it is a bit tedious for everyone, I think we do keep needing to debate the suitable home for border line drivers. I don't think there really are any clear rules we can formulate unfortunately.
Quoted 6 lines
On another side note, I don't really believe that it makes much senses to add all
this functionality to iio to start with. I'd rather fix the hwmon registration
API and create ahwmon->iiobridge.
A worthy aim but I think you would either end up with some nasty name of attr based hackery or a substantial part of the IIO stuff reimplemented. I wish I had more time to drive the plan to fully separate the front end and back end of IIO to provide that sort of 'minimal' hardware description interface. Annoyingly we aren't actually that far away from it.
I am also unclear that there is that much point in doing hwmon to IIO bridge in kernel space. Any general ADC driver that would have uses outside hwmon that demand streaming data and similar wouldn't work over such an interface anyway. Anything else is polled via sysfs in both cases, a bit of name look up code and both can be supported by one library.
So for devices where the main usecase is probably relatively slow polled reading, I personally don't feel it really matters whether then end up in IIO of hwmon. Just comes down to how they work with legacy interfaces (which is pretty much all the iio-hwmon bridge is for).
Right now the unclear corners are 'unusual temperature sensors' e.g. thermophiles, near infrared or high end theromcouple devices where typically high speed drives them to IIO. (they change fast because they are moving around quickly).
Humidity partly because a lot of the users are not coming from hardware monitoring but rather environmental side of things.
General purpose ADCs - more historical I think where hwmon was kind of the only option... + obviously there are specific hardware monitoring focused parts where hwmon makes sense as it has the interfaces tailored to these applications.
Anyhow, that's my 2 pence ;) I suspect we'll keep muddling through but I absolutely agree that we should avoid two drivers for the same part.
Maybe I should add a note in the relevant Kconfig files to say if you are putting something here you'd better have a good reason. Not sure anyone would notice though...
Jonathan
Quoted 6 lines
Guenter
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html