diff mbox series

[v2,3/3] dt-bindings: iio: chemical: pms7003: add device tree support

Message ID 20190127181916.19948-4-tduszyns@gmail.com (mailing list archive)
State New, archived
Headers show
Series add support for PMS7003 PM sensor | expand

Commit Message

Tomasz Duszynski Jan. 27, 2019, 6:19 p.m. UTC
Add device tree support for Plantower PMS7003 particulate matter sensor.

Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
---
 .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt

Comments

Johan Hovold Jan. 28, 2019, 7:58 a.m. UTC | #1
On Sun, Jan 27, 2019 at 07:19:16PM +0100, Tomasz Duszynski wrote:
> Add device tree support for Plantower PMS7003 particulate matter sensor.
> 
> Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> ---
>  .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> 
> diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> new file mode 100644
> index 000000000000..e4c7f2fb1e30
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> @@ -0,0 +1,19 @@
> +* Plantower PMS7003 particulate matter sensor
> +
> +Required properties:
> +- compatible: must be "plantower,pms7003"
> +
> +Optional properties:
> +- vcc-supply: phandle to the regulator that provides power to the sensor

Shouldn't this one be a required property?

> +- set-gpios: phandle to the GPIO connected to the SET line
> +- reset-gpios: phandle to the GPIO connected to the RESET line
> +
> +Refer to serial/slave-device.txt for generic serial attached device bindings.
> +
> +Example:
> +
> +&uart0 {
> +	pms7003 {

The node name should be generic and reflect the functionality rather
than model. Perhaps "pms" will do here.

> +		compatible = "plantower,pms7003";
> +	};
> +};

Johan
Tomasz Duszynski Jan. 28, 2019, 6:43 p.m. UTC | #2
On Mon, Jan 28, 2019 at 08:58:19AM +0100, Johan Hovold wrote:
> On Sun, Jan 27, 2019 at 07:19:16PM +0100, Tomasz Duszynski wrote:
> > Add device tree support for Plantower PMS7003 particulate matter sensor.
> >
> > Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> > ---
> >  .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> >
> > diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > new file mode 100644
> > index 000000000000..e4c7f2fb1e30
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > @@ -0,0 +1,19 @@
> > +* Plantower PMS7003 particulate matter sensor
> > +
> > +Required properties:
> > +- compatible: must be "plantower,pms7003"
> > +
> > +Optional properties:
> > +- vcc-supply: phandle to the regulator that provides power to the sensor
>
> Shouldn't this one be a required property?
>

Driver does not use regulator framework hence to me this property fits
here better.

> > +- set-gpios: phandle to the GPIO connected to the SET line
> > +- reset-gpios: phandle to the GPIO connected to the RESET line
> > +
> > +Refer to serial/slave-device.txt for generic serial attached device bindings.
> > +
> > +Example:
> > +
> > +&uart0 {
> > +	pms7003 {
>
> The node name should be generic and reflect the functionality rather
> than model. Perhaps "pms" will do here.
>

Agree, ideally we should have a generic dt name for this kind of sensors
(something like air-pollution-sensor perhaps?). But unfortunately there isn't
anything available now so I guess compatible part name should be okay
(besides this is the type of naming commonly used in other iio bindings).

> > +		compatible = "plantower,pms7003";
> > +	};
> > +};
>
> Johan
Johan Hovold Jan. 30, 2019, 9:12 a.m. UTC | #3
On Mon, Jan 28, 2019 at 07:43:33PM +0100, Tomasz Duszynski wrote:
> On Mon, Jan 28, 2019 at 08:58:19AM +0100, Johan Hovold wrote:
> > On Sun, Jan 27, 2019 at 07:19:16PM +0100, Tomasz Duszynski wrote:
> > > Add device tree support for Plantower PMS7003 particulate matter sensor.
> > >
> > > Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> > > ---
> > >  .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
> > >  1 file changed, 19 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > >
> > > diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > new file mode 100644
> > > index 000000000000..e4c7f2fb1e30
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > @@ -0,0 +1,19 @@
> > > +* Plantower PMS7003 particulate matter sensor
> > > +
> > > +Required properties:
> > > +- compatible: must be "plantower,pms7003"
> > > +
> > > +Optional properties:
> > > +- vcc-supply: phandle to the regulator that provides power to the sensor
> >
> > Shouldn't this one be a required property?
> >
> 
> Driver does not use regulator framework hence to me this property fits
> here better.

The device tree describes hardware, not any particular driver.

That said, there is a bit of an on-going debate on whether mandatory
supplies (from a hardware perspective) should always be represented in
device tree or not.

	https://lore.kernel.org/lkml/20181123133126.GF2089@sirena.org.uk/T/#u
        https://lore.kernel.org/lkml/20180409102244.GB11532@sirena.org.uk/T/#u
	https://lore.kernel.org/lkml/20180425171123.xhyoay3nu463btoq@rob-hp-laptop/T/#u

> > > +- set-gpios: phandle to the GPIO connected to the SET line
> > > +- reset-gpios: phandle to the GPIO connected to the RESET line
> > > +
> > > +Refer to serial/slave-device.txt for generic serial attached device bindings.
> > > +
> > > +Example:
> > > +
> > > +&uart0 {
> > > +	pms7003 {
> >
> > The node name should be generic and reflect the functionality rather
> > than model. Perhaps "pms" will do here.
> 
> Agree, ideally we should have a generic dt name for this kind of sensors
> (something like air-pollution-sensor perhaps?). But unfortunately there isn't
> anything available now so I guess compatible part name should be okay
> (besides this is the type of naming commonly used in other iio bindings).

What's wrong with particulate matter sensor ("pms")?

Seems like a better fix than any particular model name to me at least.

> > > +		compatible = "plantower,pms7003";
> > > +	};
> > > +};

Johan
Tomasz Duszynski Jan. 31, 2019, 8:40 p.m. UTC | #4
On Wed, Jan 30, 2019 at 10:12:54AM +0100, Johan Hovold wrote:
> On Mon, Jan 28, 2019 at 07:43:33PM +0100, Tomasz Duszynski wrote:
> > On Mon, Jan 28, 2019 at 08:58:19AM +0100, Johan Hovold wrote:
> > > On Sun, Jan 27, 2019 at 07:19:16PM +0100, Tomasz Duszynski wrote:
> > > > Add device tree support for Plantower PMS7003 particulate matter sensor.
> > > >
> > > > Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> > > > ---
> > > >  .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
> > > >  1 file changed, 19 insertions(+)
> > > >  create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > >
> > > > diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > new file mode 100644
> > > > index 000000000000..e4c7f2fb1e30
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > @@ -0,0 +1,19 @@
> > > > +* Plantower PMS7003 particulate matter sensor
> > > > +
> > > > +Required properties:
> > > > +- compatible: must be "plantower,pms7003"
> > > > +
> > > > +Optional properties:
> > > > +- vcc-supply: phandle to the regulator that provides power to the sensor
> > >
> > > Shouldn't this one be a required property?
> > >
> >
> > Driver does not use regulator framework hence to me this property fits
> > here better.
>
> The device tree describes hardware, not any particular driver.
>
> That said, there is a bit of an on-going debate on whether mandatory
> supplies (from a hardware perspective) should always be represented in
> device tree or not.
>
> 	https://lore.kernel.org/lkml/20181123133126.GF2089@sirena.org.uk/T/#u
>         https://lore.kernel.org/lkml/20180409102244.GB11532@sirena.org.uk/T/#u
> 	https://lore.kernel.org/lkml/20180425171123.xhyoay3nu463btoq@rob-hp-laptop/T/#u
>

Even after going through this threads I am still unconvinced that
vcc-supply should be a requirement. Making this a mandatory property
would automatically imply using *_regulator_get() in a driver code
(on condition one is adding regulator support). In case there
isn't any physically connected we end up with a dummy one and a warning.

Is it how this should work?

> > > > +- set-gpios: phandle to the GPIO connected to the SET line
> > > > +- reset-gpios: phandle to the GPIO connected to the RESET line
> > > > +
> > > > +Refer to serial/slave-device.txt for generic serial attached device bindings.
> > > > +
> > > > +Example:
> > > > +
> > > > +&uart0 {
> > > > +	pms7003 {
> > >
> > > The node name should be generic and reflect the functionality rather
> > > than model. Perhaps "pms" will do here.
> >
> > Agree, ideally we should have a generic dt name for this kind of sensors
> > (something like air-pollution-sensor perhaps?). But unfortunately there isn't
> > anything available now so I guess compatible part name should be okay
> > (besides this is the type of naming commonly used in other iio bindings).
>
> What's wrong with particulate matter sensor ("pms")?
>
> Seems like a better fix than any particular model name to me at least.
>

Personally I would vote for a more descriptive node name, for example:
particulate-matter-sensor or air-pollution-sensor or other name
which clearly shows what device we are dealing with.

> > > > +		compatible = "plantower,pms7003";
> > > > +	};
> > > > +};
>
> Johan
Johan Hovold Feb. 1, 2019, 9:12 a.m. UTC | #5
On Thu, Jan 31, 2019 at 09:40:04PM +0100, Tomasz Duszynski wrote:
> On Wed, Jan 30, 2019 at 10:12:54AM +0100, Johan Hovold wrote:
> > On Mon, Jan 28, 2019 at 07:43:33PM +0100, Tomasz Duszynski wrote:
> > > On Mon, Jan 28, 2019 at 08:58:19AM +0100, Johan Hovold wrote:
> > > > On Sun, Jan 27, 2019 at 07:19:16PM +0100, Tomasz Duszynski wrote:
> > > > > Add device tree support for Plantower PMS7003 particulate matter sensor.
> > > > >
> > > > > Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> > > > > ---
> > > > >  .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
> > > > >  1 file changed, 19 insertions(+)
> > > > >  create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > >
> > > > > diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > > new file mode 100644
> > > > > index 000000000000..e4c7f2fb1e30
> > > > > --- /dev/null
> > > > > +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > > @@ -0,0 +1,19 @@
> > > > > +* Plantower PMS7003 particulate matter sensor
> > > > > +
> > > > > +Required properties:
> > > > > +- compatible: must be "plantower,pms7003"
> > > > > +
> > > > > +Optional properties:
> > > > > +- vcc-supply: phandle to the regulator that provides power to the sensor
> > > >
> > > > Shouldn't this one be a required property?
> > > >
> > >
> > > Driver does not use regulator framework hence to me this property fits
> > > here better.
> >
> > The device tree describes hardware, not any particular driver.
> >
> > That said, there is a bit of an on-going debate on whether mandatory
> > supplies (from a hardware perspective) should always be represented in
> > device tree or not.
> >
> > 	https://lore.kernel.org/lkml/20181123133126.GF2089@sirena.org.uk/T/#u
> >         https://lore.kernel.org/lkml/20180409102244.GB11532@sirena.org.uk/T/#u
> > 	https://lore.kernel.org/lkml/20180425171123.xhyoay3nu463btoq@rob-hp-laptop/T/#u
> >
> 
> Even after going through this threads I am still unconvinced that
> vcc-supply should be a requirement. Making this a mandatory property
> would automatically imply using *_regulator_get() in a driver code
> (on condition one is adding regulator support). In case there
> isn't any physically connected we end up with a dummy one and a warning.

How would the device work at all without a physical vcc supply?

> Is it how this should work?

As Mark mentioned in the threads above, you could add a fixed,
always-on regulator for cases where the device is always powered.

Boards failing to describe this supply would still work on Linux, but
would end up with a dummy regulator and a warning.

> > > > > +- set-gpios: phandle to the GPIO connected to the SET line
> > > > > +- reset-gpios: phandle to the GPIO connected to the RESET line
> > > > > +
> > > > > +Refer to serial/slave-device.txt for generic serial attached device bindings.
> > > > > +
> > > > > +Example:
> > > > > +
> > > > > +&uart0 {
> > > > > +	pms7003 {
> > > >
> > > > The node name should be generic and reflect the functionality rather
> > > > than model. Perhaps "pms" will do here.
> > >
> > > Agree, ideally we should have a generic dt name for this kind of sensors
> > > (something like air-pollution-sensor perhaps?). But unfortunately there isn't
> > > anything available now so I guess compatible part name should be okay
> > > (besides this is the type of naming commonly used in other iio bindings).
> >
> > What's wrong with particulate matter sensor ("pms")?
> >
> > Seems like a better fix than any particular model name to me at least.
> >
> 
> Personally I would vote for a more descriptive node name, for example:
> particulate-matter-sensor or air-pollution-sensor or other name
> which clearly shows what device we are dealing with.

Spelling it out seems preferable, yes. You know the domain better than
I do; I only suggest you come up with a generic node name.

Johan
Tomasz Duszynski Feb. 1, 2019, 5:10 p.m. UTC | #6
On Fri, Feb 01, 2019 at 10:12:31AM +0100, Johan Hovold wrote:
> On Thu, Jan 31, 2019 at 09:40:04PM +0100, Tomasz Duszynski wrote:
> > On Wed, Jan 30, 2019 at 10:12:54AM +0100, Johan Hovold wrote:
> > > On Mon, Jan 28, 2019 at 07:43:33PM +0100, Tomasz Duszynski wrote:
> > > > On Mon, Jan 28, 2019 at 08:58:19AM +0100, Johan Hovold wrote:
> > > > > On Sun, Jan 27, 2019 at 07:19:16PM +0100, Tomasz Duszynski wrote:
> > > > > > Add device tree support for Plantower PMS7003 particulate matter sensor.
> > > > > >
> > > > > > Signed-off-by: Tomasz Duszynski <tduszyns@gmail.com>
> > > > > > ---
> > > > > >  .../iio/chemical/plantower,pms7003.txt        | 19 +++++++++++++++++++
> > > > > >  1 file changed, 19 insertions(+)
> > > > > >  create mode 100644 Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > > >
> > > > > > diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > > > new file mode 100644
> > > > > > index 000000000000..e4c7f2fb1e30
> > > > > > --- /dev/null
> > > > > > +++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
> > > > > > @@ -0,0 +1,19 @@
> > > > > > +* Plantower PMS7003 particulate matter sensor
> > > > > > +
> > > > > > +Required properties:
> > > > > > +- compatible: must be "plantower,pms7003"
> > > > > > +
> > > > > > +Optional properties:
> > > > > > +- vcc-supply: phandle to the regulator that provides power to the sensor
> > > > >
> > > > > Shouldn't this one be a required property?
> > > > >
> > > >
> > > > Driver does not use regulator framework hence to me this property fits
> > > > here better.
> > >
> > > The device tree describes hardware, not any particular driver.
> > >
> > > That said, there is a bit of an on-going debate on whether mandatory
> > > supplies (from a hardware perspective) should always be represented in
> > > device tree or not.
> > >
> > > 	https://lore.kernel.org/lkml/20181123133126.GF2089@sirena.org.uk/T/#u
> > >         https://lore.kernel.org/lkml/20180409102244.GB11532@sirena.org.uk/T/#u
> > > 	https://lore.kernel.org/lkml/20180425171123.xhyoay3nu463btoq@rob-hp-laptop/T/#u
> > >
> >
> > Even after going through this threads I am still unconvinced that
> > vcc-supply should be a requirement. Making this a mandatory property
> > would automatically imply using *_regulator_get() in a driver code
> > (on condition one is adding regulator support). In case there
> > isn't any physically connected we end up with a dummy one and a warning.
>
> How would the device work at all without a physical vcc supply?
>

I meant the discrete IC regulator.

> > Is it how this should work?
>
> As Mark mentioned in the threads above, you could add a fixed,
> always-on regulator for cases where the device is always powered.
>
> Boards failing to describe this supply would still work on Linux, but
> would end up with a dummy regulator and a warning.
>

Fair enough.

> > > > > > +- set-gpios: phandle to the GPIO connected to the SET line
> > > > > > +- reset-gpios: phandle to the GPIO connected to the RESET line
> > > > > > +
> > > > > > +Refer to serial/slave-device.txt for generic serial attached device bindings.
> > > > > > +
> > > > > > +Example:
> > > > > > +
> > > > > > +&uart0 {
> > > > > > +	pms7003 {
> > > > >
> > > > > The node name should be generic and reflect the functionality rather
> > > > > than model. Perhaps "pms" will do here.
> > > >
> > > > Agree, ideally we should have a generic dt name for this kind of sensors
> > > > (something like air-pollution-sensor perhaps?). But unfortunately there isn't
> > > > anything available now so I guess compatible part name should be okay
> > > > (besides this is the type of naming commonly used in other iio bindings).
> > >
> > > What's wrong with particulate matter sensor ("pms")?
> > >
> > > Seems like a better fix than any particular model name to me at least.
> > >
> >
> > Personally I would vote for a more descriptive node name, for example:
> > particulate-matter-sensor or air-pollution-sensor or other name
> > which clearly shows what device we are dealing with.
>
> Spelling it out seems preferable, yes. You know the domain better than
> I do; I only suggest you come up with a generic node name.
>
> Johan
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
new file mode 100644
index 000000000000..e4c7f2fb1e30
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/chemical/plantower,pms7003.txt
@@ -0,0 +1,19 @@ 
+* Plantower PMS7003 particulate matter sensor
+
+Required properties:
+- compatible: must be "plantower,pms7003"
+
+Optional properties:
+- vcc-supply: phandle to the regulator that provides power to the sensor
+- set-gpios: phandle to the GPIO connected to the SET line
+- reset-gpios: phandle to the GPIO connected to the RESET line
+
+Refer to serial/slave-device.txt for generic serial attached device bindings.
+
+Example:
+
+&uart0 {
+	pms7003 {
+		compatible = "plantower,pms7003";
+	};
+};