changes to mprls0025pa
Petre Rodan
maintainerv3 cover changes to mprls0025pa
A number of fixes to the mprls0025pa driver:
- an off-by-one initially caused by a typo in the bindings file
- two error fields are never checked during sensor interaction
- unsafe initialization if the driver is instantiated via sysfs and the bindings are missing
Quality of life changes:
- a refactor that adds a pressure-triplet property which initializes
pmin-pascal and pmax-pascal just like in the hsc030pa driver. The user only needs to extract a short string from the chip name instead of looking up the chip in the datasheet, understand the nomenclature, extract the measurement range and then convert all units to pascals.
New feature:
- SPI compatibility for Honeywell MPR sensors that require it.
Both binding and driver are backwards compatible.
Tested in I2C and SPI modes with two different sensors. The refactor requires property function present in the togreg branch.
Petre Rodan (10):
dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml improvements
dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add
pressure-triplet
dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add spi bus
iio: pressure: mprls0025pa fix off-by-one enum
iio: pressure: mprls0025pa improve driver error resilience
iio: pressure: mprls0025pa remove defaults
iio: pressure: mprls0025pa whitespace cleanup
iio: pressure: mprls0025pa refactor
iio: pressure: mprls0025pa add triplet property
iio: pressure: mprls0025pa add SPI driver
.../iio/pressure/honeywell,mprls0025pa.yaml | 98 ++++-- MAINTAINERS | 3 +- drivers/iio/pressure/Kconfig | 14 +- drivers/iio/pressure/Makefile | 2 + drivers/iio/pressure/mprls0025pa.c | 313 +++++++++--------- drivers/iio/pressure/mprls0025pa.h | 102 ++++++ drivers/iio/pressure/mprls0025pa_i2c.c | 98 ++++++ drivers/iio/pressure/mprls0025pa_spi.c | 89 +++++ 8 files changed, 542 insertions(+), 177 deletions(-) create mode 100644 drivers/iio/pressure/mprls0025pa.h create mode 100644 drivers/iio/pressure/mprls0025pa_i2c.c create mode 100644 drivers/iio/pressure/mprls0025pa_spi.c
--
2.41.0
Petre Rodan
maintainerPATCH v3 1/10 dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml improvements
Define enum inside the honeywell,transfer-function property block.
Set the correct irq edge in the example block.
Based on the datasheet, in table 13 on page 11:
"End-of-conversion indicator: This pin is set high when a measurement and calculation have been completed and the data is ready to be clocked out"
Add description on End-of-conversion interrupt.
---
v2 -> v3 no changes
.../bindings/iio/pressure/honeywell,mprls0025pa.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml +6 -1
@@ -42,6 +42,10 @@ properties: maxItems: 1 interrupts: + description: + Optional interrupt for indicating End-of-conversion. + If not present, the driver loops for a while until the received status + byte indicates correct measurement. maxItems: 1 reset-gpios:
@@ -65,6 +69,7 @@ properties: 1 - A, 10% to 90% of 2^24 (1677722 .. 15099494) 2 - B, 2.5% to 22.5% of 2^24 (419430 .. 3774874) 3 - C, 20% to 80% of 2^24 (3355443 .. 13421773) + enum: [1, 2, 3] $ref: /schemas/types.yaml#/definitions/uint32 vdd-supply:
@@ -93,7 +98,7 @@ examples: reg = <0x18>; reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; interrupt-parent = <&gpio3>; - interrupts = <21 IRQ_TYPE_EDGE_FALLING>; + interrupts = <21 IRQ_TYPE_EDGE_RISING>; honeywell,pmin-pascal = <0>; honeywell,pmax-pascal = <172369>; honeywell,transfer-function = <1>;
--
2.41.0
Petre Rodan
maintainerPATCH v3 2/10 dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add pressure-triplet
In reply to Petre RodanChange order of properties in order for the end user to hopefully ignore pmin-pascal and pmax-pascal which are superseded by pressure-triplet.
Add pressure-triplet property which automatically initializes pmin-pascal and pmax-pascal inside the driver.
Rework honeywell,pmXX-pascal requirements based on feedback from Jonathan and Conor.
---
v2 -> v3 remove redundant pmin, pmax description line
.../iio/pressure/honeywell,mprls0025pa.yaml | 64 +++++++++++++------ 1 file changed, 46 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml +46 -18
@@ -19,14 +19,17 @@ description: | calls them "mpr series". All of them have the identical programming model and differ in the pressure range, unit and transfer function. - To support different models one need to specify the pressure range as well as - the transfer function. Pressure range needs to be converted from its unit to - pascal. + To support different models one need to specify its pressure triplet as well + as the transfer function. + + For custom silicon chips not covered by the Honeywell MPR series datasheet, + the pressure values can be specified manually via honeywell,pmin-pascal and + honeywell,pmax-pascal. + The minimal range value stands for the minimum pressure and the maximum value + also for the maximum pressure with linear relation inside the range. The transfer function defines the ranges of numerical values delivered by the - sensor. The minimal range value stands for the minimum pressure and the - maximum value also for the maximum pressure with linear relation inside the - range. + sensor. Specifications about the devices can be found at: https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/
@@ -54,14 +57,6 @@ properties: If not present the device is not reset during the probe. maxItems: 1 - honeywell,pmin-pascal: - description: - Minimum pressure value the sensor can measure in pascal. - - honeywell,pmax-pascal: - description: - Maximum pressure value the sensor can measure in pascal. - honeywell,transfer-function: description: | Transfer function which defines the range of valid values delivered by the
@@ -72,17 +67,50 @@ properties: enum: [1, 2, 3] $ref: /schemas/types.yaml#/definitions/uint32 + honeywell,pressure-triplet: + description: | + Case-sensitive five character string that defines pressure range, unit + and type as part of the device nomenclature. In the unlikely case of a + custom chip, unset and provide pmin-pascal and pmax-pascal instead. + enum: [0001BA, 01.6BA, 02.5BA, 0060MG, 0100MG, 0160MG, 0250MG, 0400MG, + 0600MG, 0001BG, 01.6BG, 02.5BG, 0100KA, 0160KA, 0250KA, 0006KG, + 0010KG, 0016KG, 0025KG, 0040KG, 0060KG, 0100KG, 0160KG, 0250KG, + 0015PA, 0025PA, 0030PA, 0001PG, 0005PG, 0015PG, 0030PG, 0300YG] + $ref: /schemas/types.yaml#/definitions/string + + honeywell,pmin-pascal: + description: + Minimum pressure value the sensor can measure in pascal. + + honeywell,pmax-pascal: + description: + Maximum pressure value the sensor can measure in pascal. + vdd-supply: description: provide VDD power to the sensor. required: - compatible - reg - - honeywell,pmin-pascal - - honeywell,pmax-pascal - honeywell,transfer-function - vdd-supply +oneOf: + - required: + - honeywell,pressure-triplet + - required: + - honeywell,pmin-pascal + - honeywell,pmax-pascal + +allOf: + - if: + required: + - honeywell,pressure-triplet + then: + properties: + honeywell,pmin-pascal: false + honeywell,pmax-pascal: false + additionalProperties: false examples:
@@ -99,8 +127,8 @@ examples: reset-gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; interrupt-parent = <&gpio3>; interrupts = <21 IRQ_TYPE_EDGE_RISING>; - honeywell,pmin-pascal = <0>; - honeywell,pmax-pascal = <172369>; + + honeywell,pressure-triplet = "0025PA"; honeywell,transfer-function = <1>; vdd-supply = <&vcc_3v3>; };
--
2.41.0
Re: [PATCH v3 02/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add pressure-triplet
Quoted 6 lines · Petre Rodan
Change order of properties in order for the end user to hopefully ignore pmin-pascal and pmax-pascal which are superseded by pressure-triplet.
Add pressure-triplet property which automatically initializes pmin-pascal and pmax-pascal inside the driver.
Quoted 7 lines
Rework honeywell,pmXX-pascal requirements based on feedback from Jonathan and Conor.
Co-developed-by Andreas Klinger <[email protected]>Signed-off-by Andreas Klinger <[email protected]>Signed-off-by Petre Rodan <[email protected]>---
Best regards,
Krzysztof
Petre Rodan
maintainerPATCH v3 3/10 dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add spi bus
In reply to Petre RodanAdd spi based example.
Add spi-max-frequency property required by chip specifications.
Add additional maintainer.
---
v2 -> v3 add $ref: /schemas/spi/spi-peripheral-props.yaml
.../iio/pressure/honeywell,mprls0025pa.yaml | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml +25 -2
@@ -8,12 +8,12 @@ title: Honeywell mprls0025pa pressure sensor maintainers: - Andreas Klinger <[email protected]> + - Petre Rodan <[email protected]> description: | Honeywell pressure sensor of model mprls0025pa. - This sensor has an I2C and SPI interface. Only the I2C interface is - implemented. + This sensor has an I2C and SPI interface. There are many models with different pressure ranges available. The vendor calls them "mpr series". All of them have the identical programming model and
@@ -86,6 +86,9 @@ properties: description: Maximum pressure value the sensor can measure in pascal. + spi-max-frequency: + maximum: 800000 + vdd-supply: description: provide VDD power to the sensor.
@@ -103,6 +106,7 @@ oneOf: - honeywell,pmax-pascal allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml - if: required: - honeywell,pressure-triplet
@@ -133,3 +137,22 @@ examples: vdd-supply = <&vcc_3v3>; }; }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + pressure@0 { + compatible = "honeywell,mprls0025pa"; + reg = <0>; + spi-max-frequency = <800000>; + reset-gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>; + interrupt-parent = <&gpio0>; + interrupts = <30 IRQ_TYPE_EDGE_RISING>; + + honeywell,pressure-triplet = "0015PA"; + honeywell,transfer-function = <1>; + vdd-supply = <&vcc_3v3>; + }; + }; +...
--
2.41.0
Re: [PATCH v3 03/10] dt-bindings: iio: pressure: honeywell,mprls0025pa.yaml add spi bus
Quoted 5 lines · Petre Rodan
Add spi based example.
Add spi-max-frequency property required by chip specifications.
Add additional maintainer.
Best regards,
Krzysztof
Petre Rodan
maintainerPATCH v3 4/10 iio: pressure: mprls0025pa fix off-by-one enum
In reply to Petre RodanFix off-by-one error in transfer-function property.
The honeywell,transfer-function property takes values between 1-3 so make sure the proper enum gets used.
---
v2 -> v3 no changes
drivers/iio/pressure/mprls0025pa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/pressure/mprls0025pa.c +3 -1
@@ -323,6 +323,7 @@ static int mpr_probe(struct i2c_client *client)struct iio_dev *indio_dev;struct device *dev = &client->dev;s64 scale, offset; +u32 func;if (!i2c_check_functionality (client->adapter,I2C_FUNC_SMBUS_READ_BYTE )) return dev_err_probe(dev, -EOPNOTSUPP,
@@ -362,10 +363,11 @@ static int mpr_probe(struct i2c_client *client)return dev_err_probe (dev, ret,"honeywell,pmax-pascal could not be read\n" ); ret =device_property_read_u32 (dev, -"honeywell,transfer-function" , &data->function); +"honeywell,transfer-function" , &func);if (ret)return dev_err_probe (dev, ret,"honeywell,transfer-function could not be read\n" ); + data->function = func -1 ;if (data->function >MPR_FUNCTION_C ) return dev_err_probe(dev, -EINVAL, "honeywell,transfer-function %d invalid\n",
--
2.41.0
Petre Rodan
maintainerPATCH v3 5/10 iio: pressure: mprls0025pa improve driver error resilience
In reply to Petre RodanImprove driver error resilience by ignoring the measurement if any of the 3 error flags gets set while interacting with the sensor. Based on the datasheet, in table 14 on page 14, the status byte contains:
bit 5 busy flag - 1 if device is busy
bit 2 memory integrity/error flag - 1 if integrity test failed bit 0 math saturation - 1 if internal math saturation has occurred
---
v2 -> v3 no changes
drivers/iio/pressure/mprls0025pa.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/iio/pressure/mprls0025pa.c +4 -2
@@ -39,6 +39,8 @@#define MPR_I2C_MEMORY BIT(2)/* integrity test passed */ #define MPR_I2C_MATH BIT(0)/* internal math saturation */ +#define MPR_I2C_ERR_FLAG (MPR_I2C_BUSY | MPR_I2C_MEMORY | MPR_I2C_MATH) +/* * support _RAW sysfs interface: *
@@ -213,7 +215,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press) status);return status; } -if (!(status &MPR_I2C_BUSY )) +if (!(status &MPR_I2C_ERR_FLAG ))break ; }if (i == nloops) {
@@ -233,7 +235,7 @@ static int mpr_read_pressure(struct mpr_data *data, s32 *press)return -EIO ; } -if (buf[0 ] &MPR_I2C_BUSY ) { +if (buf[0 ] &MPR_I2C_ERR_FLAG ) {/* * it should never be the case that status still indicates * business
--
2.41.0
Petre Rodan
maintainerPATCH v3 6/10 iio: pressure: mprls0025pa remove defaults
In reply to Petre RodanThis driver supports 32*3 combinations of fixed ranges and transfer functions, plus custom ranges.
So statistically a user has more than 99% chance that the provided default configuration will generate invalid pressure readings if the bindings are not initialized and the driver is instantiated via sysfs.
The current patch removes this loophole making sure the driver loads only if the firmware properties are present.
---
v2 -> v3 drop the use of dev_fwnode() entirely
drivers/iio/pressure/mprls0025pa.c | 48 +++++++++++++----------------- 1 file changed, 20 insertions(+), 28 deletions(-)
drivers/iio/pressure/mprls0025pa.c +20 -28
@@ -353,34 +353,26 @@ static int mpr_probe(struct i2c_client *client)return dev_err_probe (dev, ret,"can't get and enable vdd supply\n" ); -if (dev_fwnode (dev)) { - ret =device_property_read_u32 (dev,"honeywell,pmin-pascal" , - &data->pmin); -if (ret) -return dev_err_probe (dev, ret, -"honeywell,pmin-pascal could not be read\n" ); - ret =device_property_read_u32 (dev,"honeywell,pmax-pascal" , - &data->pmax); -if (ret) -return dev_err_probe (dev, ret, -"honeywell,pmax-pascal could not be read\n" ); - ret =device_property_read_u32 (dev, -"honeywell,transfer-function" , &func); -if (ret) -return dev_err_probe (dev, ret, -"honeywell,transfer-function could not be read\n" ); - data->function = func -1 ; -if (data->function >MPR_FUNCTION_C ) -return dev_err_probe (dev, -EINVAL , -"honeywell,transfer-function %d invalid\n" , - data->function); - }else { -/* when loaded as i2c device we need to use default values */ -dev_notice (dev,"firmware node not found; using defaults\n" ); - data->pmin =0 ; - data->pmax =172369 ;/* 25 psi */ - data->function =MPR_FUNCTION_A ; - } + ret =device_property_read_u32 (dev,"honeywell,pmin-pascal" , + &data->pmin); +if (ret) +return dev_err_probe (dev, ret, +"honeywell,pmin-pascal could not be read\n" ); + ret =device_property_read_u32 (dev,"honeywell,pmax-pascal" , + &data->pmax); +if (ret) +return dev_err_probe (dev, ret, +"honeywell,pmax-pascal could not be read\n" ); + ret =device_property_read_u32 (dev, +"honeywell,transfer-function" , &func); +if (ret) +return dev_err_probe (dev, ret, +"honeywell,transfer-function could not be read\n" ); + data->function = func -1 ; +if (data->function >MPR_FUNCTION_C ) +return dev_err_probe (dev, -EINVAL , +"honeywell,transfer-function %d invalid\n" , + data->function); data->outmin = mpr_func_spec[data->function].output_min; data->outmax = mpr_func_spec[data->function].output_max;
--
2.41.0
Petre Rodan
maintainerPATCH v3 7/10 iio: pressure: mprls0025pa whitespace cleanup
In reply to Petre RodanFix indentation and whitespace in code that will not get refactored.
Make URL inside comment copy-paste friendly.
---
v2 -> v3 even more whitespace
drivers/iio/pressure/mprls0025pa.c | 35 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-)
drivers/iio/pressure/mprls0025pa.c +17 -18
@@ -5,10 +5,7 @@* Copyright (c) Andreas Klinger <[email protected]> * * Data sheet: -* https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/ -* products/sensors/pressure-sensors/board-mount-pressure-sensors/ -* micropressure-mpr-series/documents/ -* sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf +* https://prod-edam.honeywell.com/content/dam/honeywell-edam/sps/siot/en-us/products/sensors/pressure-sensors/board-mount-pressure-sensors/micropressure-mpr-series/documents/sps-siot-mpr-series-datasheet-32332628-ciid-172626.pdf * * 7-bit I2C default slave address: 0x18 */
@@ -84,9 +81,9 @@ struct mpr_func_spec { };static const struct mpr_func_spec mpr_func_spec[] = { - [MPR_FUNCTION_A ] = {.output_min =1677722 , .output_max =15099494 }, - [MPR_FUNCTION_B ] = {.output_min =419430 , .output_max =3774874 }, - [MPR_FUNCTION_C ] = {.output_min =3355443 , .output_max =13421773 }, + [MPR_FUNCTION_A ] = { .output_min =1677722 , .output_max =15099494 }, + [MPR_FUNCTION_B ] = { .output_min =419430 , .output_max =3774874 }, + [MPR_FUNCTION_C ] = { .output_min =3355443 , .output_max =13421773 }, };struct mpr_chan {
@@ -273,7 +270,7 @@ static irqreturn_t mpr_trigger_handler(int irq, void *p) goto err;iio_push_to_buffers_with_timestamp (indio_dev, &data->chan, -iio_get_time_ns (indio_dev)); +iio_get_time_ns (indio_dev)); err:mutex_unlock (&data->lock);
@@ -351,7 +348,7 @@ static int mpr_probe(struct i2c_client *client) ret =devm_regulator_get_enable (dev,"vdd" );if (ret)return dev_err_probe (dev, ret, -"can't get and enable vdd supply\n" ); +"can't get and enable vdd supply\n" ); ret =device_property_read_u32 (dev,"honeywell,pmin-pascal" , &data->pmin);
@@ -379,42 +376,44 @@ static int mpr_probe(struct i2c_client *client)/* use 64 bit calculation for preserving a reasonable precision */ scale =div_s64 (((s64)(data->pmax - data->pmin)) *NANO , - data->outmax - data->outmin); + data->outmax - data->outmin); data->scale =div_s64_rem (scale,NANO , &data->scale2);/* * multiply with NANO before dividing by scale and later divide by NANO * again. */ offset = ((-1LL ) * (s64 )data->outmin) *NANO - -div_s64 (div_s64 ((s64 )data->pmin *NANO , scale),NANO ); +div_s64 (div_s64 ((s64 )data->pmin *NANO , scale),NANO ); data->offset =div_s64_rem (offset,NANO , &data->offset2);if (data->irq >0 ) { ret =devm_request_irq (dev, data->irq, mpr_eoc_handler, -IRQF_TRIGGER_RISING , client->name, data); +IRQF_TRIGGER_RISING , + client->name, + data);if (ret)return dev_err_probe (dev, ret, -"request irq %d failed\n" , data->irq); +"request irq %d failed\n" , data->irq); } data->gpiod_reset =devm_gpiod_get_optional (dev,"reset" , -GPIOD_OUT_HIGH ); +GPIOD_OUT_HIGH );if (IS_ERR (data->gpiod_reset))return dev_err_probe (dev,PTR_ERR (data->gpiod_reset), -"request reset-gpio failed\n" ); +"request reset-gpio failed\n" );mpr_reset (data); ret =devm_iio_triggered_buffer_setup (dev, indio_dev,NULL , - mpr_trigger_handler,NULL ); + mpr_trigger_handler,NULL );if (ret)return dev_err_probe (dev, ret, -"iio triggered buffer setup failed\n" ); +"iio triggered buffer setup failed\n" ); ret =devm_iio_device_register (dev, indio_dev);if (ret)return dev_err_probe (dev, ret, -"unable to register iio device\n" ); +"unable to register iio device\n" );return 0 ; }
--
2.41.0
Re: [PATCH v3 07/10] iio: pressure: mprls0025pa whitespace cleanup
Quoted 3 lines · Petre Rodan
Fix indentation and whitespace in code that will not get refactored.
Make URL inside comment copy-paste friendly.
...
drivers/iio/pressure/mprls0025pa.c static int mpr_probe(struct i2c_client *client) · line 393
Quoted 5 lines
drivers/iio/pressure/mprls0025pa.c +3
-1ret =devm_request_irq (dev, data->irq, mpr_eoc_handler, -IRQF_TRIGGER_RISING , client->name, data); +IRQF_TRIGGER_RISING , + client->name, + data);
The last two are perfectly located on a single line and be even coupled semantically together.
No need to resend the patch just because of this, Jonathan can amend, I think, when applying.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Petre Rodan
maintainerPATCH v3 8/10 iio: pressure: mprls0025pa refactor
In reply to Petre RodanRefactor driver by splitting the code into core and i2c.
Seemingly redundant read/write function parameters are required for compatibility with the SPI driver.
---
v2 -> v3 move '#include <linux/iio/iio.h>' to mprls0025pa.h
fix checkpatch.pl warnings related to mprls0025pa.h
MAINTAINERS | 3 +- drivers/iio/pressure/Kconfig | 6 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mprls0025pa.c | 185 +++++++------------------ drivers/iio/pressure/mprls0025pa.h | 102 ++++++++++++++ drivers/iio/pressure/mprls0025pa_i2c.c | 98 +++++++++++++ 6 files changed, 262 insertions(+), 133 deletions(-) create mode 100644 drivers/iio/pressure/mprls0025pa.h create mode 100644 drivers/iio/pressure/mprls0025pa_i2c.c
MAINTAINERS +2 -1
@@ -9686,10 +9686,11 @@ F: drivers/iio/pressure/hsc030pa* HONEYWELL MPRLS0025PA PRESSURE SENSOR SERIES IIO DRIVER M: Andreas Klinger <[email protected]> +M: Petre Rodan <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/iio/pressure/honeywell,mprls0025pa.yaml -F: drivers/iio/pressure/mprls0025pa.c +F: drivers/iio/pressure/mprls0025pa* HOST AP DRIVER L: [email protected]
drivers/iio/pressure/Kconfig +6 -0
@@ -182,6 +182,7 @@ config MPL3115 config MPRLS0025PA tristate "Honeywell MPRLS0025PA (MicroPressure sensors series)" depends on I2C + select MPRLS0025PA_I2C if I2C select IIO_BUFFER select IIO_TRIGGERED_BUFFER help
@@ -192,6 +193,11 @@ config MPRLS0025PA To compile this driver as a module, choose M here: the module will be called mprls0025pa. +config MPRLS0025PA_I2C + tristate + depends on MPRLS0025PA + depends on I2C + config MS5611 tristate "Measurement Specialties MS5611 pressure sensor driver" select IIO_BUFFER
drivers/iio/pressure/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_MPL115_I2C) += mpl115_i2c.o obj-$(CONFIG_MPL115_SPI) += mpl115_spi.o obj-$(CONFIG_MPL3115) += mpl3115.o obj-$(CONFIG_MPRLS0025PA) += mprls0025pa.o +obj-$(CONFIG_MPRLS0025PA_I2C) += mprls0025pa_i2c.o obj-$(CONFIG_MS5611) += ms5611_core.o obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o
drivers/iio/pressure/mprls0025pa.c +53 -132
305 lines not on this page · raw message
drivers/iio/pressure/mprls0025pa.h new file +102 -0
102 lines not on this page · raw message
drivers/iio/pressure/mprls0025pa_i2c.c new file +98 -0
98 lines not on this page · raw message
--
2.41.0
Petre Rodan
maintainerPATCH v3 9/10 iio: pressure: mprls0025pa add triplet property
In reply to Petre RodanAdd honeywell,pressure-triplet property that automatically initializes pmin-pascal, pmax-pascal so that the user is not required to look-up the chip in the datasheet and convert various units to pascals himself.
---
v2 -> v3 no changes
drivers/iio/pressure/mprls0025pa.c | 105 ++++++++++++++++++++++++++--- 1 file changed, 97 insertions(+), 8 deletions(-)
drivers/iio/pressure/mprls0025pa.c +97 -8
@@ -80,6 +80,78 @@ static const struct mpr_func_spec mpr_func_spec[] = { [MPR_FUNCTION_C] = { .output_min = 3355443, .output_max = 13421773 }, }; +enum mpr_variants { +MPR0001BA =0x00 ,MPR01_6BA =0x01 ,MPR02_5BA =0x02 ,MPR0060MG =0x03 , +MPR0100MG =0x04 ,MPR0160MG =0x05 ,MPR0250MG =0x06 ,MPR0400MG =0x07 , +MPR0600MG =0x08 ,MPR0001BG =0x09 ,MPR01_6BG =0x0a ,MPR02_5BG =0x0b , +MPR0100KA =0x0c ,MPR0160KA =0x0d ,MPR0250KA =0x0e ,MPR0006KG =0x0f , +MPR0010KG =0x10 ,MPR0016KG =0x11 ,MPR0025KG =0x12 ,MPR0040KG =0x13 , +MPR0060KG =0x14 ,MPR0100KG =0x15 ,MPR0160KG =0x16 ,MPR0250KG =0x17 , +MPR0015PA =0x18 ,MPR0025PA =0x19 ,MPR0030PA =0x1a ,MPR0001PG =0x1b , +MPR0005PG =0x1c ,MPR0015PG =0x1d ,MPR0030PG =0x1e ,MPR0300YG =0x1f , +MPR_VARIANTS_MAX +}; + +static const char *const mpr_triplet_variants[MPR_VARIANTS_MAX ] = { + [MPR0001BA ] ="0001BA" , [MPR01_6BA ] ="01.6BA" , [MPR02_5BA ] ="02.5BA" , + [MPR0060MG ] ="0060MG" , [MPR0100MG ] ="0100MG" , [MPR0160MG ] ="0160MG" , + [MPR0250MG ] ="0250MG" , [MPR0400MG ] ="0400MG" , [MPR0600MG ] ="0600MG" , + [MPR0001BG ] ="0001BG" , [MPR01_6BG ] ="01.6BG" , [MPR02_5BG ] ="02.5BG" , + [MPR0100KA ] ="0100KA" , [MPR0160KA ] ="0160KA" , [MPR0250KA ] ="0250KA" , + [MPR0006KG ] ="0006KG" , [MPR0010KG ] ="0010KG" , [MPR0016KG ] ="0016KG" , + [MPR0025KG ] ="0025KG" , [MPR0040KG ] ="0040KG" , [MPR0060KG ] ="0060KG" , + [MPR0100KG ] ="0100KG" , [MPR0160KG ] ="0160KG" , [MPR0250KG ] ="0250KG" , + [MPR0015PA ] ="0015PA" , [MPR0025PA ] ="0025PA" , [MPR0030PA ] ="0030PA" , + [MPR0001PG ] ="0001PG" , [MPR0005PG ] ="0005PG" , [MPR0015PG ] ="0015PG" , + [MPR0030PG ] ="0030PG" , [MPR0300YG ] ="0300YG" +}; + +/** +* struct mpr_range_config - list of pressure ranges based on nomenclature +* @pmin: lowest pressure that can be measured +* @pmax: highest pressure that can be measured +*/ +struct mpr_range_config { +const s32 pmin; +const s32 pmax; +}; + +/* All min max limits have been converted to pascals */ +static const struct mpr_range_config mpr_range_config[MPR_VARIANTS_MAX ] = { + [MPR0001BA ] = { .pmin =0 , .pmax =100000 }, + [MPR01_6BA ] = { .pmin =0 , .pmax =160000 }, + [MPR02_5BA ] = { .pmin =0 , .pmax =250000 }, + [MPR0060MG ] = { .pmin =0 , .pmax =6000 }, + [MPR0100MG ] = { .pmin =0 , .pmax =10000 }, + [MPR0160MG ] = { .pmin =0 , .pmax =16000 }, + [MPR0250MG ] = { .pmin =0 , .pmax =25000 }, + [MPR0400MG ] = { .pmin =0 , .pmax =40000 }, + [MPR0600MG ] = { .pmin =0 , .pmax =60000 }, + [MPR0001BG ] = { .pmin =0 , .pmax =100000 }, + [MPR01_6BG ] = { .pmin =0 , .pmax =160000 }, + [MPR02_5BG ] = { .pmin =0 , .pmax =250000 }, + [MPR0100KA ] = { .pmin =0 , .pmax =100000 }, + [MPR0160KA ] = { .pmin =0 , .pmax =160000 }, + [MPR0250KA ] = { .pmin =0 , .pmax =250000 }, + [MPR0006KG ] = { .pmin =0 , .pmax =6000 }, + [MPR0010KG ] = { .pmin =0 , .pmax =10000 }, + [MPR0016KG ] = { .pmin =0 , .pmax =16000 }, + [MPR0025KG ] = { .pmin =0 , .pmax =25000 }, + [MPR0040KG ] = { .pmin =0 , .pmax =40000 }, + [MPR0060KG ] = { .pmin =0 , .pmax =60000 }, + [MPR0100KG ] = { .pmin =0 , .pmax =100000 }, + [MPR0160KG ] = { .pmin =0 , .pmax =160000 }, + [MPR0250KG ] = { .pmin =0 , .pmax =250000 }, + [MPR0015PA ] = { .pmin =0 , .pmax =103421 }, + [MPR0025PA ] = { .pmin =0 , .pmax =172369 }, + [MPR0030PA ] = { .pmin =0 , .pmax =206843 }, + [MPR0001PG ] = { .pmin =0 , .pmax =6895 }, + [MPR0005PG ] = { .pmin =0 , .pmax =34474 }, + [MPR0015PG ] = { .pmin =0 , .pmax =103421 }, + [MPR0030PG ] = { .pmin =0 , .pmax =206843 }, + [MPR0300YG ] = { .pmin =0 , .pmax =39997 } +}; +static const struct iio_chan_spec mpr_channels[] = { { .type =IIO_PRESSURE ,
@@ -257,6 +329,7 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq)int ret;struct mpr_data *data;struct iio_dev *indio_dev; +const char *triplet;s64 scale, offset;u32 func;
@@ -298,16 +371,32 @@ int mpr_common_probe(struct device *dev, const struct mpr_ops *ops, int irq)"honeywell,transfer-function %d invalid\n" , data->function); - ret =device_property_read_u32 (dev,"honeywell,pmin-pascal" , - &data->pmin); -if (ret) -return dev_err_probe (dev, ret, + ret =device_property_read_string (dev,"honeywell,pressure-triplet" , + &triplet); +if (ret) { + ret =device_property_read_u32 (dev,"honeywell,pmin-pascal" , + &data->pmin); +if (ret) +return dev_err_probe (dev, ret,"honeywell,pmin-pascal could not be read\n" ); - ret =device_property_read_u32 (dev,"honeywell,pmax-pascal" , - &data->pmax); -if (ret) -return dev_err_probe (dev, ret, + + ret =device_property_read_u32 (dev,"honeywell,pmax-pascal" , + &data->pmax); +if (ret) +return dev_err_probe (dev, ret,"honeywell,pmax-pascal could not be read\n" ); + }else { + ret =device_property_match_property_string (dev, +"honeywell,pressure-triplet" , + mpr_triplet_variants, +MPR_VARIANTS_MAX ); +if (ret <0 ) +return dev_err_probe (dev, -EINVAL , +"honeywell,pressure-triplet is invalid\n" ); + + data->pmin = mpr_range_config[ret].pmin; + data->pmax = mpr_range_config[ret].pmax; + }if (data->pmin >= data->pmax) return dev_err_probe(dev, -EINVAL,
--
2.41.0
Petre Rodan
maintainerPATCH v3 10/10 iio: pressure: mprls0025pa add SPI driver
In reply to Petre RodanAdd SPI component of the driver.
Tested with mprls0015pa0000sa in spi mode on BeagleBone Black on slightly patched 6.7.0-rc6 mainline.
Tested with mprls0025pa in i2c mode on BeagleBone Black with togreg branch ongit://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
(tag: iio-for-6.8a)
---
v2 -> v3 removed iio.h include line
drivers/iio/pressure/Kconfig | 8 ++- drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/mprls0025pa_spi.c | 89 ++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 drivers/iio/pressure/mprls0025pa_spi.c
drivers/iio/pressure/Kconfig +7 -1
@@ -181,8 +181,9 @@ config MPL3115 config MPRLS0025PA tristate "Honeywell MPRLS0025PA (MicroPressure sensors series)" - depends on I2C + depends on (I2C || SPI_MASTER) select MPRLS0025PA_I2C if I2C + select MPRLS0025PA_SPI if SPI_MASTER select IIO_BUFFER select IIO_TRIGGERED_BUFFER help
@@ -198,6 +199,11 @@ config MPRLS0025PA_I2C depends on MPRLS0025PA depends on I2C +config MPRLS0025PA_SPI + tristate + depends on MPRLS0025PA + depends on SPI_MASTER + config MS5611 tristate "Measurement Specialties MS5611 pressure sensor driver" select IIO_BUFFER
drivers/iio/pressure/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_MPL115_SPI) += mpl115_spi.o obj-$(CONFIG_MPL3115) += mpl3115.o obj-$(CONFIG_MPRLS0025PA) += mprls0025pa.o obj-$(CONFIG_MPRLS0025PA_I2C) += mprls0025pa_i2c.o +obj-$(CONFIG_MPRLS0025PA_SPI) += mprls0025pa_spi.o obj-$(CONFIG_MS5611) += ms5611_core.o obj-$(CONFIG_MS5611_I2C) += ms5611_i2c.o obj-$(CONFIG_MS5611_SPI) += ms5611_spi.o
drivers/iio/pressure/mprls0025pa_spi.c new file +89 -0
89 lines not on this page · raw message
--
2.41.0
Re: [PATCH v3 10/10] iio: pressure: mprls0025pa add SPI driver
Quoted 9 lines · Petre Rodan
Add SPI component of the driver.
Tested with mprls0015pa0000sa in spi mode on BeagleBone Black on slightly patched 6.7.0-rc6 mainline.
Tested with mprls0025pa in i2c mode on BeagleBone Black with togreg branch on
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
(tag: iio-for-6.8a)
I believe these paragraphs can be moved to the patch submission comments from the commit message...
Quoted 4 lines
Tested-by Andreas Klinger <[email protected]>Signed-off-by Petre Rodan <[email protected]>---
v2 -> v3 removediio.hinclude line
...somewhere here.
...
drivers/iio/pressure/mprls0025pa_spi.c line 14
Quoted 4 lines
drivers/iio/pressure/mprls0025pa_spi.c new file +4
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/spi/spi.h> +#include <linux/stddef.h>
Basically here we need additionally these ones:
device.herrno.htypes.h
(I haven't checked i2c counterpart for the similarities).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Petre Rodan
maintainerRe: [PATCH v3 10/10] iio: pressure: mprls0025pa add SPI driver
hello Andy,
Quoted 30 lines · Andy Shevchenko
Quoted 9 lines · Petre Rodan
Add SPI component of the driver.
Tested with mprls0015pa0000sa in spi mode on BeagleBone Black on slightly patched 6.7.0-rc6 mainline.
Tested with mprls0025pa in i2c mode on BeagleBone Black with togreg branch on
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
(tag: iio-for-6.8a)I believe these paragraphs can be moved to the patch submission comments from the commit message...
Quoted 4 lines
Tested-by Andreas Klinger <[email protected]>Signed-off-by Petre Rodan <[email protected]>---
v2 -> v3 removediio.hinclude line...somewhere here.
...
drivers/iio/pressure/mprls0025pa_spi.c line 14
Quoted 4 lines
drivers/iio/pressure/mprls0025pa_spi.c new file +4
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/spi/spi.h> +#include <linux/stddef.h> Basically here we need additionally these ones:
Quoted 3 lines
device.herrno.htypes.h
ok, I'll add errno.h. the other two are in the shared .h file.
cheers,
peter
Quoted 7 lines
(I haven't checked i2c counterpart for the similarities).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Signature · 1 line
petre rodan
Re: [PATCH v3 10/10] iio: pressure: mprls0025pa add SPI driver
Quoted 11 lines · Petre Rodan
Quoted 10 lines · Andy Shevchenko
drivers/iio/pressure/mprls0025pa_spi.c line 14
Quoted 6 lines · Petre Rodan
Add SPI component of the driver.
drivers/iio/pressure/mprls0025pa_spi.c new file +4
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/spi/spi.h> +#include <linux/stddef.h> Basically here we need additionally these ones:
Quoted 5 lines
Quoted 3 lines
device.herrno.htypes.hok, I'll add
errno.h. the other two are in the shared .h file.
Yes, but it's better to follow IWYI principle. Generally speaking there is no guarantee that above will be _always_ the case.
Anyway, I leave this to Jonathan.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Jonathan Cameron
maintainerRe: [PATCH v3 10/10] iio: pressure: mprls0025pa add SPI driver
Quoted 16 lines · On Sat, 6 Jan 2024 18:07:55 +0200 Andy Shevchenko…
Quoted 15 lines · Petre Rodan
Quoted 13 lines · Andy Shevchenko
drivers/iio/pressure/mprls0025pa_spi.c line 14
Quoted 6 lines · Petre Rodan
Add SPI component of the driver.
drivers/iio/pressure/mprls0025pa_spi.c new file +4
-0+#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/spi/spi.h> +#include <linux/stddef.h> Basically here we need additionally these ones:
device.herrno.htypes.h
Quoted 7 lines
Quoted 1 line
ok, I'll add
errno.h. the other two are in the shared .h file.Yes, but it's better to follow IWYI principle. Generally speaking there is no guarantee that above will be _always_ the case.
Anyway, I leave this to Jonathan.
When it's a local include to the driver like this I don't mind as much if the includes aren't there in the c file, but do generally 'slightly prefer' them to be so. As such I've added them here and in the i2c file (I also renamed that patch as 'refactor' isn't exactly descriptive in the patch title!) I suspect none of us feel that strongly about this so rather than slowing things down I took a fairly random decision that let me apply the series today.
Anyhow, along with dropping the text on what this was tested on in the final patch - series applied to the togreg branch of iio.git.
However, I'll be rebasing that tree on rc1 once available hence for now this will only be pushed out as testing for 0-day to get a head start on poking it.
Thanks,
Jonathan