linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support
@ 2020-08-17  0:50 Matt Ranostay
  2020-08-17  0:50 ` [PATCH v2 1/2] dt-bindings: iio: chemical: add Atlas EZO Humidity module documentation Matt Ranostay
  2020-08-17  0:50 ` [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
  0 siblings, 2 replies; 6+ messages in thread
From: Matt Ranostay @ 2020-08-17  0:50 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Matt Ranostay

Changes from v1:
* fix channel type to correct IIO_HUMIDITYRELATIVE
* fix scaling value to take in accountt the floating point is removed

Matt Ranostay (2):
  dt-bindings: iio: chemical: add Atlas EZO Humidity module
    documentation
  iio: chemical: atlas-ezo-sensor: add humidity sensor support

 .../bindings/iio/chemical/atlas,sensor.yaml   |  2 +
 drivers/iio/chemical/atlas-ezo-sensor.c       | 37 ++++++++++++++++++-
 2 files changed, 38 insertions(+), 1 deletion(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] dt-bindings: iio: chemical: add Atlas EZO Humidity module documentation
  2020-08-17  0:50 [PATCH v2 0/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
@ 2020-08-17  0:50 ` Matt Ranostay
  2020-08-25  2:26   ` Rob Herring
  2020-08-17  0:50 ` [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
  1 sibling, 1 reply; 6+ messages in thread
From: Matt Ranostay @ 2020-08-17  0:50 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Matt Ranostay, devicetree

Cc: devicetree@vger.kernel.org
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
 .../devicetree/bindings/iio/chemical/atlas,sensor.yaml          | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml b/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml
index 46496dc250f2..f1130d613735 100644
--- a/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml
+++ b/Documentation/devicetree/bindings/iio/chemical/atlas,sensor.yaml
@@ -20,6 +20,7 @@ description: |
     http://www.atlas-scientific.com/_files/_datasheets/_oem/RTD_oem_datasheet.pdf
     http://www.atlas-scientific.com/_files/_datasheets/_probe/EZO_CO2_Datasheet.pdf
     https://www.atlas-scientific.com/files/EZO_O2_datasheet.pdf
+    https://www.atlas-scientific.com/files/EZO_HUM_Datasheet.pdf
 
 properties:
   compatible:
@@ -31,6 +32,7 @@ properties:
       - atlas,rtd-sm
       - atlas,co2-ezo
       - atlas,o2-ezo
+      - atlas,hum-ezo
 
   reg:
      maxItems: 1
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support
  2020-08-17  0:50 [PATCH v2 0/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
  2020-08-17  0:50 ` [PATCH v2 1/2] dt-bindings: iio: chemical: add Atlas EZO Humidity module documentation Matt Ranostay
@ 2020-08-17  0:50 ` Matt Ranostay
  2020-08-22 11:01   ` Jonathan Cameron
  1 sibling, 1 reply; 6+ messages in thread
From: Matt Ranostay @ 2020-08-17  0:50 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, Matt Ranostay

Add support for atlas,hum-ezo / humidity sensor which with scaling
provides respective data in millipercent

Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/chemical/atlas-ezo-sensor.c | 37 ++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c
index 60a0c752fbc5..b1bacfe3c3ce 100644
--- a/drivers/iio/chemical/atlas-ezo-sensor.c
+++ b/drivers/iio/chemical/atlas-ezo-sensor.c
@@ -17,10 +17,12 @@
 
 #define ATLAS_EZO_DRV_NAME		"atlas-ezo-sensor"
 #define ATLAS_INT_TIME_IN_MS		950
+#define ATLAS_INT_HUM_TIME_IN_MS	350
 
 enum {
 	ATLAS_CO2_EZO,
 	ATLAS_O2_EZO,
+	ATLAS_HUM_EZO,
 };
 
 struct atlas_ezo_device {
@@ -63,6 +65,21 @@ static const struct iio_chan_spec atlas_o2_ezo_channels[] = {
 	ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_O2),
 };
 
+static const struct iio_chan_spec atlas_hum_ezo_channels[] = {
+	{
+		.type = IIO_HUMIDITYRELATIVE,
+		.info_mask_separate =
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+		.scan_index = 0,
+		.scan_type =  {
+			.sign = 'u',
+			.realbits = 32,
+			.storagebits = 32,
+			.endianness = IIO_CPU,
+		},
+	},
+};
+
 static struct atlas_ezo_device atlas_ezo_devices[] = {
 	[ATLAS_CO2_EZO] = {
 		.channels = atlas_co2_ezo_channels,
@@ -73,7 +90,12 @@ static struct atlas_ezo_device atlas_ezo_devices[] = {
 		.channels = atlas_o2_ezo_channels,
 		.num_channels = 1,
 		.delay = ATLAS_INT_TIME_IN_MS,
-	}
+	},
+	[ATLAS_HUM_EZO] = {
+		.channels = atlas_hum_ezo_channels,
+		.num_channels = 1,
+		.delay = ATLAS_INT_HUM_TIME_IN_MS,
+	},
 };
 
 static void atlas_ezo_sanitize(char *buf)
@@ -131,6 +153,17 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
 		return ret ? ret : IIO_VAL_INT;
 	}
 	case IIO_CHAN_INFO_SCALE:
+		switch (chan->type) {
+		case IIO_HUMIDITYRELATIVE:
+			*val = 10;
+			return IIO_VAL_INT;
+		case IIO_CONCENTRATION:
+			break;
+		default:
+			return -EINVAL;
+		}
+
+		/* IIO_CONCENTRATION modifiers */
 		switch (chan->channel2) {
 		case IIO_MOD_CO2:
 			*val = 0;
@@ -153,6 +186,7 @@ static const struct iio_info atlas_info = {
 static const struct i2c_device_id atlas_ezo_id[] = {
 	{ "atlas-co2-ezo", ATLAS_CO2_EZO },
 	{ "atlas-o2-ezo", ATLAS_O2_EZO },
+	{ "atlas-hum-ezo", ATLAS_HUM_EZO },
 	{}
 };
 MODULE_DEVICE_TABLE(i2c, atlas_ezo_id);
@@ -160,6 +194,7 @@ MODULE_DEVICE_TABLE(i2c, atlas_ezo_id);
 static const struct of_device_id atlas_ezo_dt_ids[] = {
 	{ .compatible = "atlas,co2-ezo", .data = (void *)ATLAS_CO2_EZO, },
 	{ .compatible = "atlas,o2-ezo", .data = (void *)ATLAS_O2_EZO, },
+	{ .compatible = "atlas,hum-ezo", .data = (void *)ATLAS_HUM_EZO, },
 	{}
 };
 MODULE_DEVICE_TABLE(of, atlas_ezo_dt_ids);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support
  2020-08-17  0:50 ` [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
@ 2020-08-22 11:01   ` Jonathan Cameron
  2020-08-22 22:47     ` Matt Ranostay
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2020-08-22 11:01 UTC (permalink / raw)
  To: Matt Ranostay; +Cc: linux-iio

On Mon, 17 Aug 2020 03:50:52 +0300
Matt Ranostay <matt.ranostay@konsulko.com> wrote:

> Add support for atlas,hum-ezo / humidity sensor which with scaling
> provides respective data in millipercent
> 
> Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
One comment inline.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/chemical/atlas-ezo-sensor.c | 37 ++++++++++++++++++++++++-
>  1 file changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c
> index 60a0c752fbc5..b1bacfe3c3ce 100644
> --- a/drivers/iio/chemical/atlas-ezo-sensor.c
> +++ b/drivers/iio/chemical/atlas-ezo-sensor.c
> @@ -17,10 +17,12 @@
>  
>  #define ATLAS_EZO_DRV_NAME		"atlas-ezo-sensor"
>  #define ATLAS_INT_TIME_IN_MS		950
> +#define ATLAS_INT_HUM_TIME_IN_MS	350
>  
>  enum {
>  	ATLAS_CO2_EZO,
>  	ATLAS_O2_EZO,
> +	ATLAS_HUM_EZO,
>  };
>  
>  struct atlas_ezo_device {
> @@ -63,6 +65,21 @@ static const struct iio_chan_spec atlas_o2_ezo_channels[] = {
>  	ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_O2),
>  };
>  
> +static const struct iio_chan_spec atlas_hum_ezo_channels[] = {
> +	{
> +		.type = IIO_HUMIDITYRELATIVE,
> +		.info_mask_separate =
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +		.scan_index = 0,
> +		.scan_type =  {
> +			.sign = 'u',
> +			.realbits = 32,
> +			.storagebits = 32,
> +			.endianness = IIO_CPU,
> +		},
> +	},
> +};
> +
>  static struct atlas_ezo_device atlas_ezo_devices[] = {
>  	[ATLAS_CO2_EZO] = {
>  		.channels = atlas_co2_ezo_channels,
> @@ -73,7 +90,12 @@ static struct atlas_ezo_device atlas_ezo_devices[] = {
>  		.channels = atlas_o2_ezo_channels,
>  		.num_channels = 1,
>  		.delay = ATLAS_INT_TIME_IN_MS,
> -	}
> +	},
> +	[ATLAS_HUM_EZO] = {
> +		.channels = atlas_hum_ezo_channels,
> +		.num_channels = 1,
> +		.delay = ATLAS_INT_HUM_TIME_IN_MS,
> +	},
>  };
>  
>  static void atlas_ezo_sanitize(char *buf)
> @@ -131,6 +153,17 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
>  		return ret ? ret : IIO_VAL_INT;
>  	}
>  	case IIO_CHAN_INFO_SCALE:
> +		switch (chan->type) {
> +		case IIO_HUMIDITYRELATIVE:
> +			*val = 10;
> +			return IIO_VAL_INT;
> +		case IIO_CONCENTRATION:
> +			break;
> +		default:
> +			return -EINVAL;
> +		}

This structure strikes me as something that might get rather ugly if it
gets much more complex.

I'll take this one, but keep in mind for any future additions to the driver!

Jonathan

> +
> +		/* IIO_CONCENTRATION modifiers */
>  		switch (chan->channel2) {
>  		case IIO_MOD_CO2:
>  			*val = 0;
> @@ -153,6 +186,7 @@ static const struct iio_info atlas_info = {
>  static const struct i2c_device_id atlas_ezo_id[] = {
>  	{ "atlas-co2-ezo", ATLAS_CO2_EZO },
>  	{ "atlas-o2-ezo", ATLAS_O2_EZO },
> +	{ "atlas-hum-ezo", ATLAS_HUM_EZO },
>  	{}
>  };
>  MODULE_DEVICE_TABLE(i2c, atlas_ezo_id);
> @@ -160,6 +194,7 @@ MODULE_DEVICE_TABLE(i2c, atlas_ezo_id);
>  static const struct of_device_id atlas_ezo_dt_ids[] = {
>  	{ .compatible = "atlas,co2-ezo", .data = (void *)ATLAS_CO2_EZO, },
>  	{ .compatible = "atlas,o2-ezo", .data = (void *)ATLAS_O2_EZO, },
> +	{ .compatible = "atlas,hum-ezo", .data = (void *)ATLAS_HUM_EZO, },
>  	{}
>  };
>  MODULE_DEVICE_TABLE(of, atlas_ezo_dt_ids);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support
  2020-08-22 11:01   ` Jonathan Cameron
@ 2020-08-22 22:47     ` Matt Ranostay
  0 siblings, 0 replies; 6+ messages in thread
From: Matt Ranostay @ 2020-08-22 22:47 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: open list:IIO SUBSYSTEM AND DRIVERS

On Sat, Aug 22, 2020 at 4:01 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Mon, 17 Aug 2020 03:50:52 +0300
> Matt Ranostay <matt.ranostay@konsulko.com> wrote:
>
> > Add support for atlas,hum-ezo / humidity sensor which with scaling
> > provides respective data in millipercent
> >
> > Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
> One comment inline.
>
> Applied to the togreg branch of iio.git and pushed out as testing for
> the autobuilders to play with it.
>
> Thanks,
>
> Jonathan
>
> > ---
> >  drivers/iio/chemical/atlas-ezo-sensor.c | 37 ++++++++++++++++++++++++-
> >  1 file changed, 36 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/chemical/atlas-ezo-sensor.c b/drivers/iio/chemical/atlas-ezo-sensor.c
> > index 60a0c752fbc5..b1bacfe3c3ce 100644
> > --- a/drivers/iio/chemical/atlas-ezo-sensor.c
> > +++ b/drivers/iio/chemical/atlas-ezo-sensor.c
> > @@ -17,10 +17,12 @@
> >
> >  #define ATLAS_EZO_DRV_NAME           "atlas-ezo-sensor"
> >  #define ATLAS_INT_TIME_IN_MS         950
> > +#define ATLAS_INT_HUM_TIME_IN_MS     350
> >
> >  enum {
> >       ATLAS_CO2_EZO,
> >       ATLAS_O2_EZO,
> > +     ATLAS_HUM_EZO,
> >  };
> >
> >  struct atlas_ezo_device {
> > @@ -63,6 +65,21 @@ static const struct iio_chan_spec atlas_o2_ezo_channels[] = {
> >       ATLAS_CONCENTRATION_CHANNEL(IIO_MOD_O2),
> >  };
> >
> > +static const struct iio_chan_spec atlas_hum_ezo_channels[] = {
> > +     {
> > +             .type = IIO_HUMIDITYRELATIVE,
> > +             .info_mask_separate =
> > +                     BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> > +             .scan_index = 0,
> > +             .scan_type =  {
> > +                     .sign = 'u',
> > +                     .realbits = 32,
> > +                     .storagebits = 32,
> > +                     .endianness = IIO_CPU,
> > +             },
> > +     },
> > +};
> > +
> >  static struct atlas_ezo_device atlas_ezo_devices[] = {
> >       [ATLAS_CO2_EZO] = {
> >               .channels = atlas_co2_ezo_channels,
> > @@ -73,7 +90,12 @@ static struct atlas_ezo_device atlas_ezo_devices[] = {
> >               .channels = atlas_o2_ezo_channels,
> >               .num_channels = 1,
> >               .delay = ATLAS_INT_TIME_IN_MS,
> > -     }
> > +     },
> > +     [ATLAS_HUM_EZO] = {
> > +             .channels = atlas_hum_ezo_channels,
> > +             .num_channels = 1,
> > +             .delay = ATLAS_INT_HUM_TIME_IN_MS,
> > +     },
> >  };
> >
> >  static void atlas_ezo_sanitize(char *buf)
> > @@ -131,6 +153,17 @@ static int atlas_ezo_read_raw(struct iio_dev *indio_dev,
> >               return ret ? ret : IIO_VAL_INT;
> >       }
> >       case IIO_CHAN_INFO_SCALE:
> > +             switch (chan->type) {
> > +             case IIO_HUMIDITYRELATIVE:
> > +                     *val = 10;
> > +                     return IIO_VAL_INT;
> > +             case IIO_CONCENTRATION:
> > +                     break;
> > +             default:
> > +                     return -EINVAL;
> > +             }
>
> This structure strikes me as something that might get rather ugly if it
> gets much more complex.
>
> I'll take this one, but keep in mind for any future additions to the driver!

Yeah I agree, and future additions will probably need a much less
hacky switch {} assortment.


- Matt

>
> Jonathan
>
> > +
> > +             /* IIO_CONCENTRATION modifiers */
> >               switch (chan->channel2) {
> >               case IIO_MOD_CO2:
> >                       *val = 0;
> > @@ -153,6 +186,7 @@ static const struct iio_info atlas_info = {
> >  static const struct i2c_device_id atlas_ezo_id[] = {
> >       { "atlas-co2-ezo", ATLAS_CO2_EZO },
> >       { "atlas-o2-ezo", ATLAS_O2_EZO },
> > +     { "atlas-hum-ezo", ATLAS_HUM_EZO },
> >       {}
> >  };
> >  MODULE_DEVICE_TABLE(i2c, atlas_ezo_id);
> > @@ -160,6 +194,7 @@ MODULE_DEVICE_TABLE(i2c, atlas_ezo_id);
> >  static const struct of_device_id atlas_ezo_dt_ids[] = {
> >       { .compatible = "atlas,co2-ezo", .data = (void *)ATLAS_CO2_EZO, },
> >       { .compatible = "atlas,o2-ezo", .data = (void *)ATLAS_O2_EZO, },
> > +     { .compatible = "atlas,hum-ezo", .data = (void *)ATLAS_HUM_EZO, },
> >       {}
> >  };
> >  MODULE_DEVICE_TABLE(of, atlas_ezo_dt_ids);
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] dt-bindings: iio: chemical: add Atlas EZO Humidity module documentation
  2020-08-17  0:50 ` [PATCH v2 1/2] dt-bindings: iio: chemical: add Atlas EZO Humidity module documentation Matt Ranostay
@ 2020-08-25  2:26   ` Rob Herring
  0 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2020-08-25  2:26 UTC (permalink / raw)
  To: Matt Ranostay; +Cc: linux-iio, devicetree, jic23

On Mon, 17 Aug 2020 03:50:51 +0300, Matt Ranostay wrote:
> Cc: devicetree@vger.kernel.org
> Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
> ---
>  .../devicetree/bindings/iio/chemical/atlas,sensor.yaml          | 2 ++
>  1 file changed, 2 insertions(+)
> 

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-25  2:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17  0:50 [PATCH v2 0/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
2020-08-17  0:50 ` [PATCH v2 1/2] dt-bindings: iio: chemical: add Atlas EZO Humidity module documentation Matt Ranostay
2020-08-25  2:26   ` Rob Herring
2020-08-17  0:50 ` [PATCH v2 2/2] iio: chemical: atlas-ezo-sensor: add humidity sensor support Matt Ranostay
2020-08-22 11:01   ` Jonathan Cameron
2020-08-22 22:47     ` Matt Ranostay

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).