* [PATCH] iio: chemical: atlas-sensor: add DO-SM module support
@ 2020-01-06 9:03 Matt Ranostay
2020-01-06 9:07 ` Matt Ranostay
2020-01-08 20:23 ` Rob Herring
0 siblings, 2 replies; 4+ messages in thread
From: Matt Ranostay @ 2020-01-06 9:03 UTC (permalink / raw)
To: linux-iio; +Cc: jic23, Matt Ranostay, devicetree
Atlas Scientific DO-SM OEM sensor reads disolved oxygen in
a solution. This is reported back as mg/L which maps directly
to ppm and so the IIO_CONCENTRATION channel type can be used.
Cc: devicetree@vger.kernel.org
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
.../bindings/iio/chemical/atlas,do-sm.txt | 21 ++++++
drivers/iio/chemical/atlas-sensor.c | 64 +++++++++++++++++--
2 files changed, 81 insertions(+), 4 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
new file mode 100644
index 000000000000..fc741ea794c4
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
@@ -0,0 +1,21 @@
+* Atlas Scientific DO-SM OEM sensor
+
+http://www.atlas-scientific.com/_files/_datasheets/_oem/DO_oem_datasheet.pdf
+
+Required properties:
+
+ - compatible: must be "atlas,do-sm"
+ - reg: the I2C address of the sensor
+ - interrupts: the sole interrupt generated by the device
+
+ Refer to interrupt-controller/interrupts.txt for generic interrupt client
+ node bindings.
+
+Example:
+
+atlas@64 {
+ compatible = "atlas,do-sm";
+ reg = <0x67>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <16 2>;
+};
diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
index 2f0a6fed2589..42ad1ed76144 100644
--- a/drivers/iio/chemical/atlas-sensor.c
+++ b/drivers/iio/chemical/atlas-sensor.c
@@ -48,6 +48,11 @@
#define ATLAS_REG_EC_CALIB_STATUS_LOW BIT(2)
#define ATLAS_REG_EC_CALIB_STATUS_HIGH BIT(3)
+#define ATLAS_REG_DO_CALIB_STATUS 0x09
+#define ATLAS_REG_DO_CALIB_STATUS_MASK 0x03
+#define ATLAS_REG_DO_CALIB_STATUS_PRESSURE BIT(0)
+#define ATLAS_REG_DO_CALIB_STATUS_DO BIT(1)
+
#define ATLAS_REG_PH_TEMP_DATA 0x0e
#define ATLAS_REG_PH_DATA 0x16
@@ -60,14 +65,19 @@
#define ATLAS_REG_ORP_CALIB_STATUS 0x0d
#define ATLAS_REG_ORP_DATA 0x0e
+#define ATLAS_REG_DO_TEMP_DATA 0x12
+#define ATLAS_REG_DO_DATA 0x22
+
#define ATLAS_PH_INT_TIME_IN_MS 450
#define ATLAS_EC_INT_TIME_IN_MS 650
#define ATLAS_ORP_INT_TIME_IN_MS 450
+#define ATLAS_DO_INT_TIME_IN_MS 450
enum {
ATLAS_PH_SM,
ATLAS_EC_SM,
ATLAS_ORP_SM,
+ ATLAS_DO_SM,
};
struct atlas_data {
@@ -121,7 +131,7 @@ static const struct iio_chan_spec atlas_ph_channels[] = {
},
};
-#define ATLAS_EC_CHANNEL(_idx, _addr) \
+#define ATLAS_CONCENTRATION_CHANNEL(_idx, _addr) \
{\
.type = IIO_CONCENTRATION, \
.indexed = 1, \
@@ -152,8 +162,8 @@ static const struct iio_chan_spec atlas_ec_channels[] = {
.endianness = IIO_BE,
},
},
- ATLAS_EC_CHANNEL(0, ATLAS_REG_TDS_DATA),
- ATLAS_EC_CHANNEL(1, ATLAS_REG_PSS_DATA),
+ ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_TDS_DATA),
+ ATLAS_CONCENTRATION_CHANNEL(1, ATLAS_REG_PSS_DATA),
IIO_CHAN_SOFT_TIMESTAMP(3),
{
.type = IIO_TEMP,
@@ -182,6 +192,19 @@ static const struct iio_chan_spec atlas_orp_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(1),
};
+static const struct iio_chan_spec atlas_do_channels[] = {
+ ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_DO_DATA),
+ IIO_CHAN_SOFT_TIMESTAMP(1),
+ {
+ .type = IIO_TEMP,
+ .address = ATLAS_REG_DO_TEMP_DATA,
+ .info_mask_separate =
+ BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+ .output = 1,
+ .scan_index = -1
+ },
+};
+
static int atlas_check_ph_calibration(struct atlas_data *data)
{
struct device *dev = &data->client->dev;
@@ -262,7 +285,31 @@ static int atlas_check_orp_calibration(struct atlas_data *data)
dev_warn(dev, "device has not been calibrated\n");
return 0;
-};
+}
+
+static int atlas_check_do_calibration(struct atlas_data *data)
+{
+ struct device *dev = &data->client->dev;
+ int ret;
+ unsigned int val;
+
+ ret = regmap_read(data->regmap, ATLAS_REG_DO_CALIB_STATUS, &val);
+ if (ret)
+ return ret;
+
+ if (!(val & ATLAS_REG_DO_CALIB_STATUS_MASK)) {
+ dev_warn(dev, "device has not been calibrated\n");
+ return 0;
+ }
+
+ if (!(val & ATLAS_REG_DO_CALIB_STATUS_PRESSURE))
+ dev_warn(dev, "device missing atmospheric pressure calibration\n");
+
+ if (!(val & ATLAS_REG_DO_CALIB_STATUS_DO))
+ dev_warn(dev, "device missing dissolved oxygen calibration\n");
+
+ return 0;
+}
struct atlas_device {
const struct iio_chan_spec *channels;
@@ -295,6 +342,13 @@ static struct atlas_device atlas_devices[] = {
.calibration = &atlas_check_orp_calibration,
.delay = ATLAS_ORP_INT_TIME_IN_MS,
},
+ [ATLAS_DO_SM] = {
+ .channels = atlas_do_channels,
+ .num_channels = 3,
+ .data_reg = ATLAS_REG_DO_DATA,
+ .calibration = &atlas_check_do_calibration,
+ .delay = ATLAS_DO_INT_TIME_IN_MS,
+ },
};
static int atlas_set_powermode(struct atlas_data *data, int on)
@@ -507,6 +561,7 @@ static const struct i2c_device_id atlas_id[] = {
{ "atlas-ph-sm", ATLAS_PH_SM},
{ "atlas-ec-sm", ATLAS_EC_SM},
{ "atlas-orp-sm", ATLAS_ORP_SM},
+ { "atlas-do-sm", ATLAS_DO_SM},
{}
};
MODULE_DEVICE_TABLE(i2c, atlas_id);
@@ -515,6 +570,7 @@ static const struct of_device_id atlas_dt_ids[] = {
{ .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, },
{ .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, },
{ }
};
MODULE_DEVICE_TABLE(of, atlas_dt_ids);
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: chemical: atlas-sensor: add DO-SM module support
2020-01-06 9:03 [PATCH] iio: chemical: atlas-sensor: add DO-SM module support Matt Ranostay
@ 2020-01-06 9:07 ` Matt Ranostay
2020-01-11 11:19 ` Jonathan Cameron
2020-01-08 20:23 ` Rob Herring
1 sibling, 1 reply; 4+ messages in thread
From: Matt Ranostay @ 2020-01-06 9:07 UTC (permalink / raw)
To: open list:IIO SUBSYSTEM AND DRIVERS; +Cc: Jonathan Cameron, devicetree
On Mon, Jan 6, 2020 at 5:04 PM Matt Ranostay <matt.ranostay@konsulko.com> wrote:
>
> Atlas Scientific DO-SM OEM sensor reads disolved oxygen in
> a solution. This is reported back as mg/L which maps directly
> to ppm and so the IIO_CONCENTRATION channel type can be used.
>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
> .../bindings/iio/chemical/atlas,do-sm.txt | 21 ++++++
> drivers/iio/chemical/atlas-sensor.c | 64 +++++++++++++++++--
> 2 files changed, 81 insertions(+), 4 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
>
> diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> new file mode 100644
> index 000000000000..fc741ea794c4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> @@ -0,0 +1,21 @@
> +* Atlas Scientific DO-SM OEM sensor
> +
> +http://www.atlas-scientific.com/_files/_datasheets/_oem/DO_oem_datasheet.pdf
> +
> +Required properties:
> +
> + - compatible: must be "atlas,do-sm"
> + - reg: the I2C address of the sensor
> + - interrupts: the sole interrupt generated by the device
> +
> + Refer to interrupt-controller/interrupts.txt for generic interrupt client
> + node bindings.
> +
> +Example:
> +
> +atlas@64 {
Noticed this should be 67.. But won't submit a v2 till some feedback.
- Matt
> + compatible = "atlas,do-sm";
> + reg = <0x67>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <16 2>;
> +};
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 2f0a6fed2589..42ad1ed76144 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -48,6 +48,11 @@
> #define ATLAS_REG_EC_CALIB_STATUS_LOW BIT(2)
> #define ATLAS_REG_EC_CALIB_STATUS_HIGH BIT(3)
>
> +#define ATLAS_REG_DO_CALIB_STATUS 0x09
> +#define ATLAS_REG_DO_CALIB_STATUS_MASK 0x03
> +#define ATLAS_REG_DO_CALIB_STATUS_PRESSURE BIT(0)
> +#define ATLAS_REG_DO_CALIB_STATUS_DO BIT(1)
> +
> #define ATLAS_REG_PH_TEMP_DATA 0x0e
> #define ATLAS_REG_PH_DATA 0x16
>
> @@ -60,14 +65,19 @@
> #define ATLAS_REG_ORP_CALIB_STATUS 0x0d
> #define ATLAS_REG_ORP_DATA 0x0e
>
> +#define ATLAS_REG_DO_TEMP_DATA 0x12
> +#define ATLAS_REG_DO_DATA 0x22
> +
> #define ATLAS_PH_INT_TIME_IN_MS 450
> #define ATLAS_EC_INT_TIME_IN_MS 650
> #define ATLAS_ORP_INT_TIME_IN_MS 450
> +#define ATLAS_DO_INT_TIME_IN_MS 450
>
> enum {
> ATLAS_PH_SM,
> ATLAS_EC_SM,
> ATLAS_ORP_SM,
> + ATLAS_DO_SM,
> };
>
> struct atlas_data {
> @@ -121,7 +131,7 @@ static const struct iio_chan_spec atlas_ph_channels[] = {
> },
> };
>
> -#define ATLAS_EC_CHANNEL(_idx, _addr) \
> +#define ATLAS_CONCENTRATION_CHANNEL(_idx, _addr) \
> {\
> .type = IIO_CONCENTRATION, \
> .indexed = 1, \
> @@ -152,8 +162,8 @@ static const struct iio_chan_spec atlas_ec_channels[] = {
> .endianness = IIO_BE,
> },
> },
> - ATLAS_EC_CHANNEL(0, ATLAS_REG_TDS_DATA),
> - ATLAS_EC_CHANNEL(1, ATLAS_REG_PSS_DATA),
> + ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_TDS_DATA),
> + ATLAS_CONCENTRATION_CHANNEL(1, ATLAS_REG_PSS_DATA),
> IIO_CHAN_SOFT_TIMESTAMP(3),
> {
> .type = IIO_TEMP,
> @@ -182,6 +192,19 @@ static const struct iio_chan_spec atlas_orp_channels[] = {
> IIO_CHAN_SOFT_TIMESTAMP(1),
> };
>
> +static const struct iio_chan_spec atlas_do_channels[] = {
> + ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_DO_DATA),
> + IIO_CHAN_SOFT_TIMESTAMP(1),
> + {
> + .type = IIO_TEMP,
> + .address = ATLAS_REG_DO_TEMP_DATA,
> + .info_mask_separate =
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + .output = 1,
> + .scan_index = -1
> + },
> +};
> +
> static int atlas_check_ph_calibration(struct atlas_data *data)
> {
> struct device *dev = &data->client->dev;
> @@ -262,7 +285,31 @@ static int atlas_check_orp_calibration(struct atlas_data *data)
> dev_warn(dev, "device has not been calibrated\n");
>
> return 0;
> -};
> +}
> +
> +static int atlas_check_do_calibration(struct atlas_data *data)
> +{
> + struct device *dev = &data->client->dev;
> + int ret;
> + unsigned int val;
> +
> + ret = regmap_read(data->regmap, ATLAS_REG_DO_CALIB_STATUS, &val);
> + if (ret)
> + return ret;
> +
> + if (!(val & ATLAS_REG_DO_CALIB_STATUS_MASK)) {
> + dev_warn(dev, "device has not been calibrated\n");
> + return 0;
> + }
> +
> + if (!(val & ATLAS_REG_DO_CALIB_STATUS_PRESSURE))
> + dev_warn(dev, "device missing atmospheric pressure calibration\n");
> +
> + if (!(val & ATLAS_REG_DO_CALIB_STATUS_DO))
> + dev_warn(dev, "device missing dissolved oxygen calibration\n");
> +
> + return 0;
> +}
>
> struct atlas_device {
> const struct iio_chan_spec *channels;
> @@ -295,6 +342,13 @@ static struct atlas_device atlas_devices[] = {
> .calibration = &atlas_check_orp_calibration,
> .delay = ATLAS_ORP_INT_TIME_IN_MS,
> },
> + [ATLAS_DO_SM] = {
> + .channels = atlas_do_channels,
> + .num_channels = 3,
> + .data_reg = ATLAS_REG_DO_DATA,
> + .calibration = &atlas_check_do_calibration,
> + .delay = ATLAS_DO_INT_TIME_IN_MS,
> + },
> };
>
> static int atlas_set_powermode(struct atlas_data *data, int on)
> @@ -507,6 +561,7 @@ static const struct i2c_device_id atlas_id[] = {
> { "atlas-ph-sm", ATLAS_PH_SM},
> { "atlas-ec-sm", ATLAS_EC_SM},
> { "atlas-orp-sm", ATLAS_ORP_SM},
> + { "atlas-do-sm", ATLAS_DO_SM},
> {}
> };
> MODULE_DEVICE_TABLE(i2c, atlas_id);
> @@ -515,6 +570,7 @@ static const struct of_device_id atlas_dt_ids[] = {
> { .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, },
> { .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, },
> { }
> };
> MODULE_DEVICE_TABLE(of, atlas_dt_ids);
> --
> 2.20.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: chemical: atlas-sensor: add DO-SM module support
2020-01-06 9:03 [PATCH] iio: chemical: atlas-sensor: add DO-SM module support Matt Ranostay
2020-01-06 9:07 ` Matt Ranostay
@ 2020-01-08 20:23 ` Rob Herring
1 sibling, 0 replies; 4+ messages in thread
From: Rob Herring @ 2020-01-08 20:23 UTC (permalink / raw)
To: Matt Ranostay; +Cc: linux-iio, jic23, devicetree
On Mon, Jan 06, 2020 at 01:03:35AM -0800, Matt Ranostay wrote:
> Atlas Scientific DO-SM OEM sensor reads disolved oxygen in
> a solution. This is reported back as mg/L which maps directly
> to ppm and so the IIO_CONCENTRATION channel type can be used.
>
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
> .../bindings/iio/chemical/atlas,do-sm.txt | 21 ++++++
Please split bindings to separate patch and make this a DT schema.
It seems like all these Atlas sensors are the same. Can you combine them
into one schema?
> drivers/iio/chemical/atlas-sensor.c | 64 +++++++++++++++++--
> 2 files changed, 81 insertions(+), 4 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
>
> diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> new file mode 100644
> index 000000000000..fc741ea794c4
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> @@ -0,0 +1,21 @@
> +* Atlas Scientific DO-SM OEM sensor
> +
> +http://www.atlas-scientific.com/_files/_datasheets/_oem/DO_oem_datasheet.pdf
> +
> +Required properties:
> +
> + - compatible: must be "atlas,do-sm"
> + - reg: the I2C address of the sensor
> + - interrupts: the sole interrupt generated by the device
> +
> + Refer to interrupt-controller/interrupts.txt for generic interrupt client
> + node bindings.
> +
> +Example:
> +
> +atlas@64 {
> + compatible = "atlas,do-sm";
> + reg = <0x67>;
> + interrupt-parent = <&gpio1>;
> + interrupts = <16 2>;
> +};
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: chemical: atlas-sensor: add DO-SM module support
2020-01-06 9:07 ` Matt Ranostay
@ 2020-01-11 11:19 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2020-01-11 11:19 UTC (permalink / raw)
To: Matt Ranostay; +Cc: open list:IIO SUBSYSTEM AND DRIVERS, devicetree
On Mon, 6 Jan 2020 17:07:58 +0800
Matt Ranostay <matt.ranostay@konsulko.com> wrote:
> On Mon, Jan 6, 2020 at 5:04 PM Matt Ranostay <matt.ranostay@konsulko.com> wrote:
> >
> > Atlas Scientific DO-SM OEM sensor reads disolved oxygen in
> > a solution. This is reported back as mg/L which maps directly
> > to ppm and so the IIO_CONCENTRATION channel type can be used.
> >
> > Cc: devicetree@vger.kernel.org
> > Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Seems straight forward to me.
My only thought is that we perhaps want to think about how we distinguish
between 'what' the concentration is of?
Doesn't need to be solved today though.
Jonathan
> > ---
> > .../bindings/iio/chemical/atlas,do-sm.txt | 21 ++++++
> > drivers/iio/chemical/atlas-sensor.c | 64 +++++++++++++++++--
> > 2 files changed, 81 insertions(+), 4 deletions(-)
> > create mode 100644 Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> >
> > diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> > new file mode 100644
> > index 000000000000..fc741ea794c4
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/chemical/atlas,do-sm.txt
> > @@ -0,0 +1,21 @@
> > +* Atlas Scientific DO-SM OEM sensor
> > +
> > +http://www.atlas-scientific.com/_files/_datasheets/_oem/DO_oem_datasheet.pdf
> > +
> > +Required properties:
> > +
> > + - compatible: must be "atlas,do-sm"
> > + - reg: the I2C address of the sensor
> > + - interrupts: the sole interrupt generated by the device
> > +
> > + Refer to interrupt-controller/interrupts.txt for generic interrupt client
> > + node bindings.
> > +
> > +Example:
> > +
> > +atlas@64 {
>
> Noticed this should be 67.. But won't submit a v2 till some feedback.
>
> - Matt
>
> > + compatible = "atlas,do-sm";
> > + reg = <0x67>;
> > + interrupt-parent = <&gpio1>;
> > + interrupts = <16 2>;
> > +};
> > diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> > index 2f0a6fed2589..42ad1ed76144 100644
> > --- a/drivers/iio/chemical/atlas-sensor.c
> > +++ b/drivers/iio/chemical/atlas-sensor.c
> > @@ -48,6 +48,11 @@
> > #define ATLAS_REG_EC_CALIB_STATUS_LOW BIT(2)
> > #define ATLAS_REG_EC_CALIB_STATUS_HIGH BIT(3)
> >
> > +#define ATLAS_REG_DO_CALIB_STATUS 0x09
> > +#define ATLAS_REG_DO_CALIB_STATUS_MASK 0x03
> > +#define ATLAS_REG_DO_CALIB_STATUS_PRESSURE BIT(0)
> > +#define ATLAS_REG_DO_CALIB_STATUS_DO BIT(1)
> > +
> > #define ATLAS_REG_PH_TEMP_DATA 0x0e
> > #define ATLAS_REG_PH_DATA 0x16
> >
> > @@ -60,14 +65,19 @@
> > #define ATLAS_REG_ORP_CALIB_STATUS 0x0d
> > #define ATLAS_REG_ORP_DATA 0x0e
> >
> > +#define ATLAS_REG_DO_TEMP_DATA 0x12
> > +#define ATLAS_REG_DO_DATA 0x22
> > +
> > #define ATLAS_PH_INT_TIME_IN_MS 450
> > #define ATLAS_EC_INT_TIME_IN_MS 650
> > #define ATLAS_ORP_INT_TIME_IN_MS 450
> > +#define ATLAS_DO_INT_TIME_IN_MS 450
> >
> > enum {
> > ATLAS_PH_SM,
> > ATLAS_EC_SM,
> > ATLAS_ORP_SM,
> > + ATLAS_DO_SM,
> > };
> >
> > struct atlas_data {
> > @@ -121,7 +131,7 @@ static const struct iio_chan_spec atlas_ph_channels[] = {
> > },
> > };
> >
> > -#define ATLAS_EC_CHANNEL(_idx, _addr) \
> > +#define ATLAS_CONCENTRATION_CHANNEL(_idx, _addr) \
> > {\
> > .type = IIO_CONCENTRATION, \
> > .indexed = 1, \
> > @@ -152,8 +162,8 @@ static const struct iio_chan_spec atlas_ec_channels[] = {
> > .endianness = IIO_BE,
> > },
> > },
> > - ATLAS_EC_CHANNEL(0, ATLAS_REG_TDS_DATA),
> > - ATLAS_EC_CHANNEL(1, ATLAS_REG_PSS_DATA),
> > + ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_TDS_DATA),
> > + ATLAS_CONCENTRATION_CHANNEL(1, ATLAS_REG_PSS_DATA),
> > IIO_CHAN_SOFT_TIMESTAMP(3),
> > {
> > .type = IIO_TEMP,
> > @@ -182,6 +192,19 @@ static const struct iio_chan_spec atlas_orp_channels[] = {
> > IIO_CHAN_SOFT_TIMESTAMP(1),
> > };
> >
> > +static const struct iio_chan_spec atlas_do_channels[] = {
> > + ATLAS_CONCENTRATION_CHANNEL(0, ATLAS_REG_DO_DATA),
> > + IIO_CHAN_SOFT_TIMESTAMP(1),
> > + {
> > + .type = IIO_TEMP,
> > + .address = ATLAS_REG_DO_TEMP_DATA,
> > + .info_mask_separate =
> > + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> > + .output = 1,
> > + .scan_index = -1
> > + },
> > +};
> > +
> > static int atlas_check_ph_calibration(struct atlas_data *data)
> > {
> > struct device *dev = &data->client->dev;
> > @@ -262,7 +285,31 @@ static int atlas_check_orp_calibration(struct atlas_data *data)
> > dev_warn(dev, "device has not been calibrated\n");
> >
> > return 0;
> > -};
> > +}
> > +
> > +static int atlas_check_do_calibration(struct atlas_data *data)
> > +{
> > + struct device *dev = &data->client->dev;
> > + int ret;
> > + unsigned int val;
> > +
> > + ret = regmap_read(data->regmap, ATLAS_REG_DO_CALIB_STATUS, &val);
> > + if (ret)
> > + return ret;
> > +
> > + if (!(val & ATLAS_REG_DO_CALIB_STATUS_MASK)) {
> > + dev_warn(dev, "device has not been calibrated\n");
> > + return 0;
> > + }
> > +
> > + if (!(val & ATLAS_REG_DO_CALIB_STATUS_PRESSURE))
> > + dev_warn(dev, "device missing atmospheric pressure calibration\n");
> > +
> > + if (!(val & ATLAS_REG_DO_CALIB_STATUS_DO))
> > + dev_warn(dev, "device missing dissolved oxygen calibration\n");
> > +
> > + return 0;
> > +}
> >
> > struct atlas_device {
> > const struct iio_chan_spec *channels;
> > @@ -295,6 +342,13 @@ static struct atlas_device atlas_devices[] = {
> > .calibration = &atlas_check_orp_calibration,
> > .delay = ATLAS_ORP_INT_TIME_IN_MS,
> > },
> > + [ATLAS_DO_SM] = {
> > + .channels = atlas_do_channels,
> > + .num_channels = 3,
> > + .data_reg = ATLAS_REG_DO_DATA,
> > + .calibration = &atlas_check_do_calibration,
> > + .delay = ATLAS_DO_INT_TIME_IN_MS,
> > + },
> > };
> >
> > static int atlas_set_powermode(struct atlas_data *data, int on)
> > @@ -507,6 +561,7 @@ static const struct i2c_device_id atlas_id[] = {
> > { "atlas-ph-sm", ATLAS_PH_SM},
> > { "atlas-ec-sm", ATLAS_EC_SM},
> > { "atlas-orp-sm", ATLAS_ORP_SM},
> > + { "atlas-do-sm", ATLAS_DO_SM},
> > {}
> > };
> > MODULE_DEVICE_TABLE(i2c, atlas_id);
> > @@ -515,6 +570,7 @@ static const struct of_device_id atlas_dt_ids[] = {
> > { .compatible = "atlas,ph-sm", .data = (void *)ATLAS_PH_SM, },
> > { .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, },
> > { }
> > };
> > MODULE_DEVICE_TABLE(of, atlas_dt_ids);
> > --
> > 2.20.1
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-11 11:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-06 9:03 [PATCH] iio: chemical: atlas-sensor: add DO-SM module support Matt Ranostay
2020-01-06 9:07 ` Matt Ranostay
2020-01-11 11:19 ` Jonathan Cameron
2020-01-08 20:23 ` Rob Herring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).