add support for Sensirion SPS30 PM sensor
Tomasz Duszynski
maintainerv3 cover add support for Sensirion SPS30 PM sensor
This patch series adds support for Sensirion SPS30 particulate matter sensor. Along with a driver itself, new channel type and modifiers for distinguishing between coarse and fine particles measurements are introduced.
Sensor datasheet can be downloaded from
v3:
* convert be32 to cpu using predefined macro
* remove semicolon: reported by semicolon.cocci
* use capitalization consistently (particulate matter)
v2:
* add support for PM1 and PM4 measurements
* get rid of variable length arrays
* do proper cleanup via devm_add_action_or_reset()
* add extra level of precision (two decimal places) while displaying measurements
* improve comments a little bit
* slight refactoring and general improvements here and there
Tomasz Duszynski (3):
iio: add IIO_MASSCONCENTRATION channel type
iio: chemical: add support for Sensirion SPS30 sensor
iio: chemical: sps30: add device tree support
Documentation/ABI/testing/sysfs-bus-iio | 17 +- .../bindings/iio/chemical/sensirion,sps30.txt | 12 + drivers/iio/chemical/Kconfig | 11 + drivers/iio/chemical/Makefile | 1 + drivers/iio/chemical/sps30.c | 406 ++++++++++++++++++ drivers/iio/industrialio-core.c | 5 + include/uapi/linux/iio/types.h | 5 + tools/iio/iio_event_monitor.c | 10 + 8 files changed, 466 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt create mode 100644 drivers/iio/chemical/sps30.c
--
2.19.2
Tomasz Duszynski
maintainerPATCH v3 1/3 iio: add IIO_MASSCONCENTRATION channel type
Measuring particulate matter in ug / m3 (micro-grams per cubic meter) is de facto standard. Existing air quality sensors usually follow this convention and are capable of returning measurements using this unit.
IIO currently does not offer suitable channel type for this type of measurements hence this patch adds this.
In addition, extra modifiers are introduced used for distinguishing between fine pm1, pm2p5 and coarse pm4, pm10 particle measurements, i.e IIO_MOD_PM1, IIO_MOD_PM25 and IIO_MOD_PM4, IIO_MOD_PM10.
pmX consists of particles with aerodynamic diameter less or equal to X micrometers.
--- Documentation/ABI/testing/sysfs-bus-iio | 17 ++++++++++++++++- drivers/iio/industrialio-core.c | 5 +++++ include/uapi/linux/iio/types.h | 5 +++++ tools/iio/iio_event_monitor.c | 10 ++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-bus-iio +16 -1
@@ -1684,4 +1684,19 @@ KernelVersion: 4.18 Contact: [email protected] Description: Raw (unscaled) phase difference reading from channel Y - that can be processed to radians. + that can be processed to radians. + +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm1_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm1_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm2p5_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm2p5_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm4_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm4_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm10_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm10_input +KernelVersion: 4.21 +Contact: [email protected] +Description: + Mass concentration reading of particulate matter in ug / m3. + pmX consists of particles with aerodynamic diameter less or + equal to X micrometers.
drivers/iio/industrialio-core.c +5 -0
@@ -87,6 +87,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_GRAVITY] = "gravity", [IIO_POSITIONRELATIVE] = "positionrelative", [IIO_PHASE] = "phase", + [IIO_MASSCONCENTRATION] = "massconcentration", };static const char *const iio_modifier_names[] = {
@@ -127,6 +128,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_Q] = "q", [IIO_MOD_CO2] = "co2", [IIO_MOD_VOC] = "voc", + [IIO_MOD_PM1] = "pm1", + [IIO_MOD_PM2P5] = "pm2p5", + [IIO_MOD_PM4] = "pm4", + [IIO_MOD_PM10] = "pm10", };/* relies on pairs of these shared then separate */
include/uapi/linux/iio/types.h +5 -0
@@ -46,6 +46,7 @@ enum iio_chan_type {IIO_GRAVITY ,IIO_POSITIONRELATIVE ,IIO_PHASE , + IIO_MASSCONCENTRATION, }; enum iio_modifier {
@@ -87,6 +88,10 @@ enum iio_modifier {IIO_MOD_VOC ,IIO_MOD_LIGHT_UV ,IIO_MOD_LIGHT_DUV , +IIO_MOD_PM1 , +IIO_MOD_PM2P5 , +IIO_MOD_PM4 , + IIO_MOD_PM10, }; enum iio_event_type {
tools/iio/iio_event_monitor.c +10 -0
@@ -60,6 +60,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_GRAVITY] = "gravity", [IIO_POSITIONRELATIVE] = "positionrelative", [IIO_PHASE] = "phase", + [IIO_MASSCONCENTRATION] = "massconcentration", };static const char *const iio_ev_type_text[] = {
@@ -115,6 +116,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_Q] = "q", [IIO_MOD_CO2] = "co2", [IIO_MOD_VOC] = "voc", + [IIO_MOD_PM1] = "pm1", + [IIO_MOD_PM2P5] = "pm2p5", + [IIO_MOD_PM4] = "pm4", + [IIO_MOD_PM10] = "pm10", };static bool event_is_known (struct iio_event_data *event)
@@ -156,6 +161,7 @@ static bool event_is_known(struct iio_event_data *event)case IIO_GRAVITY :case IIO_POSITIONRELATIVE :case IIO_PHASE : +case IIO_MASSCONCENTRATION :break ;default :return false;
@@ -200,6 +206,10 @@ static bool event_is_known(struct iio_event_data *event)case IIO_MOD_Q :case IIO_MOD_CO2 :case IIO_MOD_VOC : +case IIO_MOD_PM1 : +case IIO_MOD_PM2P5 : +case IIO_MOD_PM4 : +case IIO_MOD_PM10 :break ;default :return false;
Signature · 1 line
2.19.2
Re: [PATCH v3 1/3] iio: add IIO_MASSCONCENTRATION channel type
Quoted 9 lines · Tomasz Duszynski
Measuring particulate matter in ug / m3 (micro-grams per cubic meter) is de facto standard. Existing air quality sensors usually follow this convention and are capable of returning measurements using this unit.
IIO currently does not offer suitable channel type for this type of measurements hence this patch adds this.
Quoted 7 lines
In addition, extra modifiers are introduced used for distinguishing between fine pm1, pm2p5 and coarse pm4, pm10 particle measurements, i.e
IIO_MOD_PM1,IIO_MOD_PM25andIIO_MOD_PM4,IIO_MOD_PM10.pmX consists of particles with aerodynamic diameter less or equal to X micrometers.
Quoted 125 lines
Signed-off-by Tomasz Duszynski <[email protected]>--- Documentation/ABI/testing/sysfs-bus-iio | 17 ++++++++++++++++- drivers/iio/industrialio-core.c | 5 +++++ include/uapi/linux/iio/types.h | 5 +++++ tools/iio/iio_event_monitor.c | 10 ++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-)Documentation/ABI/testing/sysfs-bus-iio +16
-1@@ -1684,4 +1684,19 @@ KernelVersion: 4.18 Contact: [email protected] Description: Raw (unscaled) phase difference reading from channel Y - that can be processed to radians. + that can be processed to radians. + +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm1_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm1_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm2p5_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm2p5_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm4_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm4_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm10_input +What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm10_input +KernelVersion: 4.21 +Contact: [email protected] +Description: + Mass concentration reading of particulate matter in ug / m3. + pmX consists of particles with aerodynamic diameter less or + equal to X micrometers.drivers/iio/industrialio-core.c +5
-0@@ -87,6 +87,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_GRAVITY] = "gravity", [IIO_POSITIONRELATIVE] = "positionrelative", [IIO_PHASE] = "phase", + [IIO_MASSCONCENTRATION] = "massconcentration", };static const char *const iio_modifier_names[] = {@@ -127,6 +128,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_Q] = "q", [IIO_MOD_CO2] = "co2", [IIO_MOD_VOC] = "voc", + [IIO_MOD_PM1] = "pm1", + [IIO_MOD_PM2P5] = "pm2p5", + [IIO_MOD_PM4] = "pm4", + [IIO_MOD_PM10] = "pm10", };/* relies on pairs of these shared then separate */ include/uapi/linux/iio/types.h +5
-0@@ -46,6 +46,7 @@ enum iio_chan_type {IIO_GRAVITY ,IIO_POSITIONRELATIVE ,IIO_PHASE , + IIO_MASSCONCENTRATION, }; enum iio_modifier {@@ -87,6 +88,10 @@ enum iio_modifier {IIO_MOD_VOC ,IIO_MOD_LIGHT_UV ,IIO_MOD_LIGHT_DUV , +IIO_MOD_PM1 , +IIO_MOD_PM2P5 , +IIO_MOD_PM4 , + IIO_MOD_PM10, }; enum iio_event_type {tools/iio/iio_event_monitor.c +10
-1@@ -60,6 +60,7 @@ static const char * const iio_chan_type_name_spec[] = { [IIO_GRAVITY] = "gravity", [IIO_POSITIONRELATIVE] = "positionrelative", [IIO_PHASE] = "phase", + [IIO_MASSCONCENTRATION] = "massconcentration", };static const char *const iio_ev_type_text[] = {@@ -115,6 +116,10 @@ static const char * const iio_modifier_names[] = { [IIO_MOD_Q] = "q", [IIO_MOD_CO2] = "co2", [IIO_MOD_VOC] = "voc", + [IIO_MOD_PM1] = "pm1", + [IIO_MOD_PM2P5] = "pm2p5", + [IIO_MOD_PM4] = "pm4", + [IIO_MOD_PM10] = "pm10", };static bool event_is_known (struct iio_event_data *event)@@ -156,6 +161,7 @@ static bool event_is_known(struct iio_event_data *event)case IIO_GRAVITY :case IIO_POSITIONRELATIVE :case IIO_PHASE : +case IIO_MASSCONCENTRATION :break ;default :return false;@@ -200,6 +206,10 @@ static bool event_is_known(struct iio_event_data *event)case IIO_MOD_Q :case IIO_MOD_CO2 :case IIO_MOD_VOC : +case IIO_MOD_PM1 : +case IIO_MOD_PM2P5 : +case IIO_MOD_PM4 : +case IIO_MOD_PM10 :break ;default :return false; --2.19.2
Tomasz Duszynski
maintainerPATCH v3 2/3 iio: chemical: add support for Sensirion SPS30 sensor
In reply to Tomasz DuszynskiAdd support for Sensirion SPS30 particulate matter sensor.
--- drivers/iio/chemical/Kconfig | 11 + drivers/iio/chemical/Makefile | 1 + drivers/iio/chemical/sps30.c | 406 ++++++++++++++++++++++++++++++++++ 3 files changed, 418 insertions(+) create mode 100644 drivers/iio/chemical/sps30.c
drivers/iio/chemical/Kconfig +11 -0
@@ -61,6 +61,17 @@ config IAQCORE iAQ-Core Continuous/Pulsed VOC (Volatile Organic Compounds) sensors +config SPS30 + tristate "SPS30 particulate matter sensor" + depends on I2C + select CRC8 + help + Say Y here to build support for the Sensirion SPS30 particulate + matter sensor. + + To compile this driver as a module, choose M here: the module will + be called sps30. + config VZ89X tristate "SGX Sensortech MiCS VZ89X VOC sensor" depends on I2C
drivers/iio/chemical/Makefile +1 -0
@@ -9,4 +9,5 @@ obj-$(CONFIG_BME680_I2C) += bme680_i2c.o obj-$(CONFIG_BME680_SPI) += bme680_spi.o obj-$(CONFIG_CCS811) += ccs811.o obj-$(CONFIG_IAQCORE) += ams-iaq-core.o +obj-$(CONFIG_SPS30) += sps30.o obj-$(CONFIG_VZ89X) += vz89x.o
drivers/iio/chemical/sps30.c new file +406 -0
406 lines not on this page · raw message
Signature · 1 line
2.19.2
Tomasz Duszynski
maintainerPATCH v3 3/3 iio: chemical: sps30: add device tree support
In reply to Tomasz DuszynskiAdd device tree support for Sensirion SPS30 particulate matter sensor.
--- .../bindings/iio/chemical/sensirion,sps30.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt
Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt new file +12 -0
@@ -0,0 +1,12 @@ +* Sensirion SPS30 particulate matter sensor + +Required properties: +- compatible: must be "sensirion,sps30" +- reg: the I2C address of the sensor + +Example: + +sps30@69 { + compatible = "sensirion,sps30"; + reg = <0x69>; +};
Signature · 1 line
2.19.2