Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Add ms8607 meas-spec driver support

Support for MS8607 temperature, pressure & humidity sensor.
This part is using functions from MS5637 for temperature and pressure
and HTU21 for humidity

Signed-off-by: Ludovic Tancerel <ludovic.tancerel@maplehightech.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Ludovic Tancerel and committed by
Jonathan Cameron
1b75ce65 64a70c65

+40 -4
+1
Documentation/ABI/testing/sysfs-bus-iio-meas-spec
··· 5 5 Reading returns either '1' or '0'. '1' means that the 6 6 battery level supplied to sensor is below 2.25V. 7 7 This ABI is available for tsys02d, htu21, ms8607 8 + This ABI is available for htu21, ms8607
+2
drivers/iio/humidity/Kconfig
··· 29 29 help 30 30 If you say yes here you get support for the Measurement Specialties 31 31 HTU21 humidity and temperature sensor. 32 + This driver is also used for MS8607 temperature, pressure & humidity 33 + sensor 32 34 33 35 This driver can also be built as a module. If so, the module will 34 36 be called htu21.
+30 -3
drivers/iio/humidity/htu21.c
··· 1 1 /* 2 2 * htu21.c - Support for Measurement-Specialties 3 3 * htu21 temperature & humidity sensor 4 + * and humidity part of MS8607 sensor 4 5 * 5 6 * Copyright (c) 2014 Measurement-Specialties 6 7 * ··· 11 10 * 12 11 * Datasheet: 13 12 * http://www.meas-spec.com/downloads/HTU21D.pdf 13 + * Datasheet: 14 + * http://www.meas-spec.com/downloads/MS8607-02BA01.pdf 14 15 */ 15 16 16 17 #include <linux/init.h> ··· 26 23 #include "../common/ms_sensors/ms_sensors_i2c.h" 27 24 28 25 #define HTU21_RESET 0xFE 26 + 27 + enum { 28 + HTU21, 29 + MS8607 30 + }; 29 31 30 32 static const int htu21_samp_freq[4] = { 20, 40, 70, 120 }; 31 33 /* String copy of the above const for readability purpose */ ··· 107 99 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_PROCESSED), 108 100 .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), 109 101 }, 102 + { 103 + .type = IIO_HUMIDITYRELATIVE, 104 + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_PROCESSED), 105 + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), 106 + } 107 + }; 108 + 109 + /* 110 + * Meas Spec recommendation is to not read temperature 111 + * on this driver part for MS8607 112 + */ 113 + static const struct iio_chan_spec ms8607_channels[] = { 110 114 { 111 115 .type = IIO_HUMIDITYRELATIVE, 112 116 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_PROCESSED), ··· 208 188 indio_dev->name = id->name; 209 189 indio_dev->dev.parent = &client->dev; 210 190 indio_dev->modes = INDIO_DIRECT_MODE; 211 - indio_dev->channels = htu21_channels; 212 - indio_dev->num_channels = ARRAY_SIZE(htu21_channels); 191 + 192 + if (id->driver_data == MS8607) { 193 + indio_dev->channels = ms8607_channels; 194 + indio_dev->num_channels = ARRAY_SIZE(ms8607_channels); 195 + } else { 196 + indio_dev->channels = htu21_channels; 197 + indio_dev->num_channels = ARRAY_SIZE(htu21_channels); 198 + } 213 199 214 200 i2c_set_clientdata(client, indio_dev); 215 201 ··· 232 206 } 233 207 234 208 static const struct i2c_device_id htu21_id[] = { 235 - {"htu21", 0}, 209 + {"htu21", HTU21}, 210 + {"ms8607-humidity", MS8607}, 236 211 {} 237 212 }; 238 213
+2
drivers/iio/pressure/Kconfig
··· 86 86 help 87 87 If you say yes here you get support for the Measurement Specialties 88 88 MS5637 pressure and temperature sensor. 89 + This driver is also used for MS8607 temperature, pressure & humidity 90 + sensor 89 91 90 92 This driver can also be built as a module. If so, the module will 91 93 be called ms5637.
+5 -1
drivers/iio/pressure/ms5637.c
··· 1 1 /* 2 - * ms5637.c - Support for Measurement-Specialties ms5637 2 + * ms5637.c - Support for Measurement-Specialties ms5637 and ms8607 3 3 * pressure & temperature sensor 4 4 * 5 5 * Copyright (c) 2015 Measurement-Specialties ··· 10 10 * 11 11 * Datasheet: 12 12 * http://www.meas-spec.com/downloads/MS5637-02BA03.pdf 13 + * Datasheet: 14 + * http://www.meas-spec.com/downloads/MS8607-02BA01.pdf 13 15 */ 16 + 14 17 #include <linux/init.h> 15 18 #include <linux/device.h> 16 19 #include <linux/kernel.h> ··· 170 167 171 168 static const struct i2c_device_id ms5637_id[] = { 172 169 {"ms5637", 0}, 170 + {"ms8607-temppressure", 1}, 173 171 {} 174 172 }; 175 173