mbox series

[v4,0/3] Add support for Sensirion SDP500

Message ID 20240725-mainline_sdp500-v4-0-ea2f5b189958@gmail.com
Headers show
Series Add support for Sensirion SDP500 | expand

Message

Petar Stoykov via B4 Relay July 25, 2024, 3:37 p.m. UTC
This patch series introduces support for Sensirion SDP500 in the IIO
subsystem. The series is split into three patches:

1. The first patch adds the device tree bindings.
2. The second patch implements the device driver.
3. The third patch updates the MAINTAINERS file.

The driver is relatively simple. It provides a way to read the measured
differential pressure directly in Pa, as the device has a fixed scale
factor of 1/60. When an applications wants to read the pressure value,
3 bytes are read from the device, 2 are data and 1 is CRC8. If the crc
check passes, the raw value is made available.

The initialization of the device just starts the measurement process.

We have been using this device and driver in a product development for
almost a year now. There the pressure is read every 25ms and is used in a
control loop. We have not even seen crc errors. We are using the
"linux-imx" repository and not the mainline one but I see no risky kernel
functions in use so it should be fine here too.

All feedback is appreciated! Thank you for taking the time to review this.

Changelog
v1->v2:
	driver code:
* Removed the use of wrapper functions for logging
* Using built-in crc function instead of a custom one
* Removed the use of a wrapper function for i2c send and receive data
* Use get_unaligned_be16 instead of custom calculation
* Removed error log if devm_iio_device_alloc fails
* indio_dev->name set directly to "sdp500"
* Updated error logging to use "dev_err_probe" in probe function
* Added a sensor readout in the probe function (first one is always bad)
* Used devm_iio_device_register instead of iio_device_register
* Removed trailing comma in "sdp500_id" data
* Deleted sdp500_remove after using devm_iio_device_register in probe
	dt-bindings:
* Fixed dt-bindings example wording
* Added vdd-supply in dt-bindings example

v2->v3:
	driver code:
* Added link to datasheet at the start of the driver code
* Removed some unnecessary defines
* Removed an unused argument of sdp500_start_measurement function
* Renamed variable that holds the received CRC to "received_crc"
* Switched to returning RAW and SCALE values instead of PROCESSED
* Change logging to use data->dev instead of indio_dev->dev.parent
* Removed unnecessary debug log of the read value from the sensor
* Added vdd regulator handling
* Added "sensirion,sdp510" as compatible
* Removed the aligning of '=' in the sdp500_driver struct
	dt-bindings:
* Added "sensirion,sdp510" as possible compatible value in dt-bindings example

Link to v3: https://lore.kernel.org/r/20240702-mainline_sdp500-v3-0-0902047b3eee@gmail.com
v3->v4:
	driver code:
* include linux/mod_devicetable.h
* limit all lines to 80 characters
* fix C++ style comment
	dt-bindings and MAINTAINERS:
* fix filename

Signed-off-by: Petar Stoykov <pd.pstoykov@gmail.com>

---
Petar Stoykov (3):
      dt-bindings: iio: pressure: Add Sensirion SDP500
      iio: pressure: Add driver for Sensirion SDP500
      MAINTAINERS: Add Sensirion SDP500

 .../bindings/iio/pressure/sensirion,sdp500.yaml    |  46 ++++++
 MAINTAINERS                                        |   6 +
 drivers/iio/pressure/Kconfig                       |   9 ++
 drivers/iio/pressure/Makefile                      |   1 +
 drivers/iio/pressure/sdp500.c                      | 157 +++++++++++++++++++++
 5 files changed, 219 insertions(+)
---
base-commit: ab27740f76654ed58dd32ac0ba0031c18a6dea3b
change-id: 20240702-mainline_sdp500-0d9f8c499228

Best regards,

Comments

Krzysztof Kozlowski July 28, 2024, 9:12 a.m. UTC | #1
On 25/07/2024 17:37, Petar Stoykov via B4 Relay wrote:
> From: Petar Stoykov <pd.pstoykov@gmail.com>
> 
> Sensirion SDP500 is a digital differential pressure sensor. The sensor is
> accessed over I2C.
> 
> Signed-off-by: Petar Stoykov <pd.pstoykov@gmail.com>
> ---

> +
> +static const struct i2c_device_id sdp500_id[] = {
> +	{ "sdp500" },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(i2c, sdp500_id);
> +
> +static const struct of_device_id sdp500_of_match[] = {
> +	{ .compatible = "sensirion,sdp500" },
> +	{ .compatible = "sensirion,sdp510" },

Drop, why do you need it? I asked about this last time. Also, your OF
table is not in sync with I2C table, so this should raise questions.

Best regards,
Krzysztof
Jonathan Cameron July 28, 2024, 3:29 p.m. UTC | #2
On Sun, 28 Jul 2024 11:12:45 +0200
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> wrote:

> On 25/07/2024 17:37, Petar Stoykov via B4 Relay wrote:
> > From: Petar Stoykov <pd.pstoykov@gmail.com>
> > 
> > Sensirion SDP500 is a digital differential pressure sensor. The sensor is
> > accessed over I2C.
> > 
> > Signed-off-by: Petar Stoykov <pd.pstoykov@gmail.com>
> > ---  
> 
> > +
> > +static const struct i2c_device_id sdp500_id[] = {
> > +	{ "sdp500" },
> > +	{ }
> > +};
> > +MODULE_DEVICE_TABLE(i2c, sdp500_id);
> > +
> > +static const struct of_device_id sdp500_of_match[] = {
> > +	{ .compatible = "sensirion,sdp500" },
> > +	{ .compatible = "sensirion,sdp510" },  
> 
> Drop, why do you need it? I asked about this last time. Also, your OF
> table is not in sync with I2C table, so this should raise questions.
> 

Agreed. I dropped the sdp510 entry whilst applying.
Petar, if that is wrong for some reason we are missing, then shout.
This won't go upstream for a little while yet so we can always put
it back again :)

Jonathan

> Best regards,
> Krzysztof
>
Jonathan Cameron July 28, 2024, 3:30 p.m. UTC | #3
On Thu, 25 Jul 2024 17:37:26 +0200
Petar Stoykov via B4 Relay <devnull+pd.pstoykov.gmail.com@kernel.org> wrote:

> This patch series introduces support for Sensirion SDP500 in the IIO
> subsystem. The series is split into three patches:
> 
> 1. The first patch adds the device tree bindings.
> 2. The second patch implements the device driver.
> 3. The third patch updates the MAINTAINERS file.

Series applied.  Tweaks to patch 2 in reply to that patch.

Thanks

Jonathan