Message ID | 20200425072520.27776-3-matt.ranostay@konsulko.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iio: chemical: atlas-sensor: add RTD-SM module support | expand |
On Sat, 25 Apr 2020 10:25:20 +0300 Matt Ranostay <matt.ranostay@konsulko.com> wrote: > Atlas Scientific RTD-SM OEM sensor reads temperaturee using temperature > resistance temperature detector technology. > > Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com> Other than the above looks good to me and as you've addressed Peter's comment I'll assume he is fine with it and apply to the togreg branch of iio.git Still time for people to comment though as I'll push that as testing for the autobuilders to play with it. Thanks, Jonathan > --- > drivers/iio/chemical/atlas-sensor.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c > index 82d470561ad3..4688cbe83d86 100644 > --- a/drivers/iio/chemical/atlas-sensor.c > +++ b/drivers/iio/chemical/atlas-sensor.c > @@ -53,6 +53,8 @@ > #define ATLAS_REG_DO_CALIB_STATUS_PRESSURE BIT(0) > #define ATLAS_REG_DO_CALIB_STATUS_DO BIT(1) > > +#define ATLAS_REG_RTD_DATA 0x0e > + > #define ATLAS_REG_PH_TEMP_DATA 0x0e > #define ATLAS_REG_PH_DATA 0x16 > > @@ -72,12 +74,14 @@ > #define ATLAS_EC_INT_TIME_IN_MS 650 > #define ATLAS_ORP_INT_TIME_IN_MS 450 > #define ATLAS_DO_INT_TIME_IN_MS 450 > +#define ATLAS_RTD_INT_TIME_IN_MS 450 > > enum { > ATLAS_PH_SM, > ATLAS_EC_SM, > ATLAS_ORP_SM, > ATLAS_DO_SM, > + ATLAS_RTD_SM, > }; > > struct atlas_data { > @@ -206,6 +210,22 @@ static const struct iio_chan_spec atlas_do_channels[] = { > }, > }; > > +static const struct iio_chan_spec atlas_rtd_channels[] = { > + { > + .type = IIO_TEMP, > + .address = ATLAS_REG_RTD_DATA, > + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), > + .scan_index = 0, > + .scan_type = { > + .sign = 's', > + .realbits = 32, > + .storagebits = 32, > + .endianness = IIO_BE, > + }, > + }, > + IIO_CHAN_SOFT_TIMESTAMP(1), > +}; > + > static int atlas_check_ph_calibration(struct atlas_data *data) > { > struct device *dev = &data->client->dev; > @@ -350,6 +370,12 @@ static struct atlas_device atlas_devices[] = { > .calibration = &atlas_check_do_calibration, > .delay = ATLAS_DO_INT_TIME_IN_MS, > }, > + [ATLAS_RTD_SM] = { > + .channels = atlas_rtd_channels, > + .num_channels = 2, > + .data_reg = ATLAS_REG_RTD_DATA, > + .delay = ATLAS_RTD_INT_TIME_IN_MS, > + }, > }; > > static int atlas_set_powermode(struct atlas_data *data, int on) > @@ -478,6 +504,7 @@ static int atlas_read_raw(struct iio_dev *indio_dev, > struct atlas_data *data = iio_priv(indio_dev); > > switch (mask) { > + case IIO_CHAN_INFO_PROCESSED: > case IIO_CHAN_INFO_RAW: { > int ret; > __be32 reg; > @@ -566,6 +593,7 @@ static const struct i2c_device_id atlas_id[] = { > { "atlas-ec-sm", ATLAS_EC_SM}, > { "atlas-orp-sm", ATLAS_ORP_SM}, > { "atlas-do-sm", ATLAS_DO_SM}, > + { "atlas-rtd-sm", ATLAS_RTD_SM}, > {} > }; > MODULE_DEVICE_TABLE(i2c, atlas_id); > @@ -575,6 +603,7 @@ static const struct of_device_id atlas_dt_ids[] = { > { .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, }, > { .compatible = "atlas,orp-sm", .data = (void *)ATLAS_ORP_SM, }, > { .compatible = "atlas,do-sm", .data = (void *)ATLAS_DO_SM, }, > + { .compatible = "atlas,rtd-sm", .data = (void *)ATLAS_RTD_SM, }, > { } > }; > MODULE_DEVICE_TABLE(of, atlas_dt_ids);
diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c index 82d470561ad3..4688cbe83d86 100644 --- a/drivers/iio/chemical/atlas-sensor.c +++ b/drivers/iio/chemical/atlas-sensor.c @@ -53,6 +53,8 @@ #define ATLAS_REG_DO_CALIB_STATUS_PRESSURE BIT(0) #define ATLAS_REG_DO_CALIB_STATUS_DO BIT(1) +#define ATLAS_REG_RTD_DATA 0x0e + #define ATLAS_REG_PH_TEMP_DATA 0x0e #define ATLAS_REG_PH_DATA 0x16 @@ -72,12 +74,14 @@ #define ATLAS_EC_INT_TIME_IN_MS 650 #define ATLAS_ORP_INT_TIME_IN_MS 450 #define ATLAS_DO_INT_TIME_IN_MS 450 +#define ATLAS_RTD_INT_TIME_IN_MS 450 enum { ATLAS_PH_SM, ATLAS_EC_SM, ATLAS_ORP_SM, ATLAS_DO_SM, + ATLAS_RTD_SM, }; struct atlas_data { @@ -206,6 +210,22 @@ static const struct iio_chan_spec atlas_do_channels[] = { }, }; +static const struct iio_chan_spec atlas_rtd_channels[] = { + { + .type = IIO_TEMP, + .address = ATLAS_REG_RTD_DATA, + .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), + .scan_index = 0, + .scan_type = { + .sign = 's', + .realbits = 32, + .storagebits = 32, + .endianness = IIO_BE, + }, + }, + IIO_CHAN_SOFT_TIMESTAMP(1), +}; + static int atlas_check_ph_calibration(struct atlas_data *data) { struct device *dev = &data->client->dev; @@ -350,6 +370,12 @@ static struct atlas_device atlas_devices[] = { .calibration = &atlas_check_do_calibration, .delay = ATLAS_DO_INT_TIME_IN_MS, }, + [ATLAS_RTD_SM] = { + .channels = atlas_rtd_channels, + .num_channels = 2, + .data_reg = ATLAS_REG_RTD_DATA, + .delay = ATLAS_RTD_INT_TIME_IN_MS, + }, }; static int atlas_set_powermode(struct atlas_data *data, int on) @@ -478,6 +504,7 @@ static int atlas_read_raw(struct iio_dev *indio_dev, struct atlas_data *data = iio_priv(indio_dev); switch (mask) { + case IIO_CHAN_INFO_PROCESSED: case IIO_CHAN_INFO_RAW: { int ret; __be32 reg; @@ -566,6 +593,7 @@ static const struct i2c_device_id atlas_id[] = { { "atlas-ec-sm", ATLAS_EC_SM}, { "atlas-orp-sm", ATLAS_ORP_SM}, { "atlas-do-sm", ATLAS_DO_SM}, + { "atlas-rtd-sm", ATLAS_RTD_SM}, {} }; MODULE_DEVICE_TABLE(i2c, atlas_id); @@ -575,6 +603,7 @@ static const struct of_device_id atlas_dt_ids[] = { { .compatible = "atlas,ec-sm", .data = (void *)ATLAS_EC_SM, }, { .compatible = "atlas,orp-sm", .data = (void *)ATLAS_ORP_SM, }, { .compatible = "atlas,do-sm", .data = (void *)ATLAS_DO_SM, }, + { .compatible = "atlas,rtd-sm", .data = (void *)ATLAS_RTD_SM, }, { } }; MODULE_DEVICE_TABLE(of, atlas_dt_ids);
Atlas Scientific RTD-SM OEM sensor reads temperaturee using resistance temperature detector technology. Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com> --- drivers/iio/chemical/atlas-sensor.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)