mbox series

[0/2] iio: chemical: Add Senseair Sunrise CO2 sensor

Message ID 20210817154951.50208-1-jacopo@jmondi.org (mailing list archive)
Headers show
Series iio: chemical: Add Senseair Sunrise CO2 sensor | expand

Message

Jacopo Mondi Aug. 17, 2021, 3:49 p.m. UTC
Hello,
   this is a small driver for the Senseair Sunrise 006-0-0007 CO2
sensor.

The driver supports continuous reads of temperature and CO2 concentration
through two dedicated IIO channels.

While the driver is rather simple I'm not sure calibration is handled in
the correct way. In this version, at probe time, a check on the general
error register is made to verify if a calibration cycle is required.
The calibration takes a time in the order of a few seconds, and currently
can only happen at probe time.

Is there a mechanism available in the IIO framework to expose a trigger to have
userspace decide when the calibration has to happen ? In my understanding IIO
triggers are meant to trigger read events, using them for calibration purpose
seems not the right thing to do, or am I mistaken ?

Thanks
  j

Jacopo Mondi (2):
  dt-bindings: iio: chemical: Document senseair,sunrise CO2 sensor
  iio: chemical: Add Senseair Sunrise 006-0-007 driver

 .../iio/chemical/senseair,sunrise.yaml        |  51 +++
 .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
 MAINTAINERS                                   |   6 +
 drivers/iio/chemical/Kconfig                  |  10 +
 drivers/iio/chemical/Makefile                 |   1 +
 drivers/iio/chemical/sunrise.c                | 310 ++++++++++++++++++
 6 files changed, 380 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/chemical/senseair,sunrise.yaml
 create mode 100644 drivers/iio/chemical/sunrise.c

--
2.32.0

Comments

Matt Ranostay Aug. 17, 2021, 5:01 p.m. UTC | #1
On Tue, Aug 17, 2021 at 8:49 AM Jacopo Mondi <jacopo@jmondi.org> wrote:
>
> Hello,
>    this is a small driver for the Senseair Sunrise 006-0-0007 CO2
> sensor.
>
> The driver supports continuous reads of temperature and CO2 concentration
> through two dedicated IIO channels.
>
> While the driver is rather simple I'm not sure calibration is handled in
> the correct way. In this version, at probe time, a check on the general
> error register is made to verify if a calibration cycle is required.
> The calibration takes a time in the order of a few seconds, and currently
> can only happen at probe time.
>
> Is there a mechanism available in the IIO framework to expose a trigger to have
> userspace decide when the calibration has to happen ? In my understanding IIO
> triggers are meant to trigger read events, using them for calibration purpose
> seems not the right thing to do, or am I mistaken ?

For sure you shouldn't use the trigger framework for that.

You should use an attribute group, e.g.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iio/proximity/as3935.c?h=v5.14-rc6#n168

- Matt

>
> Thanks
>   j
>
> Jacopo Mondi (2):
>   dt-bindings: iio: chemical: Document senseair,sunrise CO2 sensor
>   iio: chemical: Add Senseair Sunrise 006-0-007 driver
>
>  .../iio/chemical/senseair,sunrise.yaml        |  51 +++
>  .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
>  MAINTAINERS                                   |   6 +
>  drivers/iio/chemical/Kconfig                  |  10 +
>  drivers/iio/chemical/Makefile                 |   1 +
>  drivers/iio/chemical/sunrise.c                | 310 ++++++++++++++++++
>  6 files changed, 380 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/chemical/senseair,sunrise.yaml
>  create mode 100644 drivers/iio/chemical/sunrise.c
>
> --
> 2.32.0
>
Jacopo Mondi Aug. 18, 2021, 8:03 a.m. UTC | #2
Hi Matt,

On Tue, Aug 17, 2021 at 10:01:40AM -0700, Matt Ranostay wrote:
> On Tue, Aug 17, 2021 at 8:49 AM Jacopo Mondi <jacopo@jmondi.org> wrote:
> >
> > Hello,
> >    this is a small driver for the Senseair Sunrise 006-0-0007 CO2
> > sensor.
> >
> > The driver supports continuous reads of temperature and CO2 concentration
> > through two dedicated IIO channels.
> >
> > While the driver is rather simple I'm not sure calibration is handled in
> > the correct way. In this version, at probe time, a check on the general
> > error register is made to verify if a calibration cycle is required.
> > The calibration takes a time in the order of a few seconds, and currently
> > can only happen at probe time.
> >
> > Is there a mechanism available in the IIO framework to expose a trigger to have
> > userspace decide when the calibration has to happen ? In my understanding IIO
> > triggers are meant to trigger read events, using them for calibration purpose
> > seems not the right thing to do, or am I mistaken ?
>
> For sure you shouldn't use the trigger framework for that.
>
> You should use an attribute group, e.g.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iio/proximity/as3935.c?h=v5.14-rc6#n168

Thanks for the pointer! I'll consider that for v2!

>
> - Matt
>
> >
> > Thanks
> >   j
> >
> > Jacopo Mondi (2):
> >   dt-bindings: iio: chemical: Document senseair,sunrise CO2 sensor
> >   iio: chemical: Add Senseair Sunrise 006-0-007 driver
> >
> >  .../iio/chemical/senseair,sunrise.yaml        |  51 +++
> >  .../devicetree/bindings/vendor-prefixes.yaml  |   2 +
> >  MAINTAINERS                                   |   6 +
> >  drivers/iio/chemical/Kconfig                  |  10 +
> >  drivers/iio/chemical/Makefile                 |   1 +
> >  drivers/iio/chemical/sunrise.c                | 310 ++++++++++++++++++
> >  6 files changed, 380 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/iio/chemical/senseair,sunrise.yaml
> >  create mode 100644 drivers/iio/chemical/sunrise.c
> >
> > --
> > 2.32.0
> >