summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Duszynski <tduszyns@gmail.com>2018-12-14 13:28:01 -0500
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2018-12-16 09:05:57 -0500
commit17abc9ec68b73ddeb262a507a62421016b9c54d5 (patch)
tree765effd1562e97ea39fd1f2ed330849a756f4aa8
parentf1b753a0f866a834f5681506ac29b6ca0ee902b2 (diff)
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. Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio17
-rw-r--r--drivers/iio/industrialio-core.c5
-rw-r--r--include/uapi/linux/iio/types.h5
-rw-r--r--tools/iio/iio_event_monitor.c10
4 files changed, 36 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 8127a08e366d..67fd88bf7910 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -1684,4 +1684,19 @@ KernelVersion: 4.18
1684Contact: linux-iio@vger.kernel.org 1684Contact: linux-iio@vger.kernel.org
1685Description: 1685Description:
1686 Raw (unscaled) phase difference reading from channel Y 1686 Raw (unscaled) phase difference reading from channel Y
1687 that can be processed to radians. \ No newline at end of file 1687 that can be processed to radians.
1688
1689What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm1_input
1690What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm1_input
1691What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm2p5_input
1692What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm2p5_input
1693What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm4_input
1694What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm4_input
1695What: /sys/bus/iio/devices/iio:deviceX/in_massconcentration_pm10_input
1696What: /sys/bus/iio/devices/iio:deviceX/in_massconcentrationY_pm10_input
1697KernelVersion: 4.22
1698Contact: linux-iio@vger.kernel.org
1699Description:
1700 Mass concentration reading of particulate matter in ug / m3.
1701 pmX consists of particles with aerodynamic diameter less or
1702 equal to X micrometers.
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 4f5cd9f60870..4700fd5d8c90 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -87,6 +87,7 @@ static const char * const iio_chan_type_name_spec[] = {
87 [IIO_GRAVITY] = "gravity", 87 [IIO_GRAVITY] = "gravity",
88 [IIO_POSITIONRELATIVE] = "positionrelative", 88 [IIO_POSITIONRELATIVE] = "positionrelative",
89 [IIO_PHASE] = "phase", 89 [IIO_PHASE] = "phase",
90 [IIO_MASSCONCENTRATION] = "massconcentration",
90}; 91};
91 92
92static const char * const iio_modifier_names[] = { 93static const char * const iio_modifier_names[] = {
@@ -127,6 +128,10 @@ static const char * const iio_modifier_names[] = {
127 [IIO_MOD_Q] = "q", 128 [IIO_MOD_Q] = "q",
128 [IIO_MOD_CO2] = "co2", 129 [IIO_MOD_CO2] = "co2",
129 [IIO_MOD_VOC] = "voc", 130 [IIO_MOD_VOC] = "voc",
131 [IIO_MOD_PM1] = "pm1",
132 [IIO_MOD_PM2P5] = "pm2p5",
133 [IIO_MOD_PM4] = "pm4",
134 [IIO_MOD_PM10] = "pm10",
130}; 135};
131 136
132/* relies on pairs of these shared then separate */ 137/* relies on pairs of these shared then separate */
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index 92baabc103ac..c59adac24b1c 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -46,6 +46,7 @@ enum iio_chan_type {
46 IIO_GRAVITY, 46 IIO_GRAVITY,
47 IIO_POSITIONRELATIVE, 47 IIO_POSITIONRELATIVE,
48 IIO_PHASE, 48 IIO_PHASE,
49 IIO_MASSCONCENTRATION,
49}; 50};
50 51
51enum iio_modifier { 52enum iio_modifier {
@@ -87,6 +88,10 @@ enum iio_modifier {
87 IIO_MOD_VOC, 88 IIO_MOD_VOC,
88 IIO_MOD_LIGHT_UV, 89 IIO_MOD_LIGHT_UV,
89 IIO_MOD_LIGHT_DUV, 90 IIO_MOD_LIGHT_DUV,
91 IIO_MOD_PM1,
92 IIO_MOD_PM2P5,
93 IIO_MOD_PM4,
94 IIO_MOD_PM10,
90}; 95};
91 96
92enum iio_event_type { 97enum iio_event_type {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index ac2de6b7e89f..f6b8003fbe3c 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -60,6 +60,7 @@ static const char * const iio_chan_type_name_spec[] = {
60 [IIO_GRAVITY] = "gravity", 60 [IIO_GRAVITY] = "gravity",
61 [IIO_POSITIONRELATIVE] = "positionrelative", 61 [IIO_POSITIONRELATIVE] = "positionrelative",
62 [IIO_PHASE] = "phase", 62 [IIO_PHASE] = "phase",
63 [IIO_MASSCONCENTRATION] = "massconcentration",
63}; 64};
64 65
65static const char * const iio_ev_type_text[] = { 66static const char * const iio_ev_type_text[] = {
@@ -115,6 +116,10 @@ static const char * const iio_modifier_names[] = {
115 [IIO_MOD_Q] = "q", 116 [IIO_MOD_Q] = "q",
116 [IIO_MOD_CO2] = "co2", 117 [IIO_MOD_CO2] = "co2",
117 [IIO_MOD_VOC] = "voc", 118 [IIO_MOD_VOC] = "voc",
119 [IIO_MOD_PM1] = "pm1",
120 [IIO_MOD_PM2P5] = "pm2p5",
121 [IIO_MOD_PM4] = "pm4",
122 [IIO_MOD_PM10] = "pm10",
118}; 123};
119 124
120static bool event_is_known(struct iio_event_data *event) 125static bool event_is_known(struct iio_event_data *event)
@@ -156,6 +161,7 @@ static bool event_is_known(struct iio_event_data *event)
156 case IIO_GRAVITY: 161 case IIO_GRAVITY:
157 case IIO_POSITIONRELATIVE: 162 case IIO_POSITIONRELATIVE:
158 case IIO_PHASE: 163 case IIO_PHASE:
164 case IIO_MASSCONCENTRATION:
159 break; 165 break;
160 default: 166 default:
161 return false; 167 return false;
@@ -200,6 +206,10 @@ static bool event_is_known(struct iio_event_data *event)
200 case IIO_MOD_Q: 206 case IIO_MOD_Q:
201 case IIO_MOD_CO2: 207 case IIO_MOD_CO2:
202 case IIO_MOD_VOC: 208 case IIO_MOD_VOC:
209 case IIO_MOD_PM1:
210 case IIO_MOD_PM2P5:
211 case IIO_MOD_PM4:
212 case IIO_MOD_PM10:
203 break; 213 break;
204 default: 214 default:
205 return false; 215 return false;