: iio: chemical: bme680: 2nd round of cleanup
Subsystems (2)
v3 cover : iio: chemical: bme680: 2nd round of cleanup
Changes in v3:
Removed applied patches 1,2,3,5,6,7,8
[PATCH v3 1/7]:
- v2 4/13
- Set mode of sensor with enum variable and remove macros
[PATCH v3 5/7]:
- v2 11/13
- removed regulators from being required, adjusted commit message
[PATCH v3 7/7]:
- v2 13/13
- removed unecessary usage of runtime PM functions
---
v2: https://lore.kernel.org/linux-iio/[email protected]/
Changes in v2:
Generally, the patches were rearranged according to comments from Andy in previous version in order to be more consistent. The refactoring of the ambient temperature was dropped for now because it was a bit more complicated than I thought and this series is already heavy enough.
[PATCH v2 01/13]:
- New patch
[PATCH v2 02/13]:
- v1 1/13
- used "optimized" in commit message to not prompt for a fix.
- added documentation of where this sleep comes from
[PATCH v2 03/13]:
- v1 2/13
- Fix indentation of array and removed extra whitespace.
[PATCH v2 04/13]:
- v1 5/13
- removed extra check inside the set_mode() function.
[PATCH v2 06/13]:
- v1 1/13
- removed indentation fixes which are fixed later since code is changed in those lines in later commits.
[PATCH v2 09/13]:
- v1 12/13
- removed unnecessary debug messages
- Used struture instead of buffer to push data to userspace
[PATCH v2 10/13]:
- v1 13/13
- used better naming
- made channel index to -1
[PATCH v2 11/13]:
- v1 06/13
- removed device from trivial-devices
[PATCH v2 12/13]:
- v1 07/13
- use devm_regulator_bulk_get_enable()
[PATCH v2 13/13]:
- v1 08/13
- removed internal usage of dev structure
- added missing header in both bme680_core.c and bme680.h
- used devm_pm_runtime_enable
---
v1: https://lore.kernel.org/linux-iio/[email protected]
This patch series is continuing the work that started on [1] by improving some small issues of the driver in the commits 1,2,3.
Commits 4,5 are refactorizing existing code.
Commits 6,7,8 are adding DT, regulator and PM support.
Commit 9 is refactorizing one macro to attribute.
Commit 10,11,12 are refactorizing the read/compensate functions to become generic and add triggered buffer support.
Finally, commit 13 adds support for an *output* channel of type IIO_CURRENT in order to preheat the plate that is used to measure the quality of the air.
This and the previous series [1] started with the idea to add support for the new bme688 device but due to the structure of the driver I decided that it is better to restructure and improve some things before adding extra funcitonalities.
[1]: https://lore.kernel.org/linux-iio/[email protected]
Vasileios Amoiridis (7):
iio: chemical: bme680: refactorize set_mode() mode
iio: chemical: bme680: Add SCALE and RAW channels
iio: chemical: bme680: Add triggered buffer support
iio: chemical: bme680: Add support for preheat current
dt-bindings: iio: bosch,bme680: Add supply properties
iio: chemical: bme680: add regulators
iio: chemical: bme680: add power management
.../bindings/iio/chemical/bosch,bme680.yaml | 62 +++ .../devicetree/bindings/trivial-devices.yaml | 2 - drivers/iio/chemical/Kconfig | 2 + drivers/iio/chemical/bme680.h | 8 +- drivers/iio/chemical/bme680_core.c | 375 ++++++++++++++++-- drivers/iio/chemical/bme680_i2c.c | 1 + drivers/iio/chemical/bme680_spi.c | 1 + 7 files changed, 423 insertions(+), 28 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/chemical/bosch,bme680.yaml
base-commit: c218214db564ca7d6885fa5859541a86197856c0
Signature · 1 line
2.43.0
PATCH v3 1/7 iio: chemical: bme680: refactorize set_mode() mode
Refactorize the set_mode() function to use an external enum that describes the possible modes of the BME680 device instead of using true/false variables for selecting SLEEPING/FORCED mode.
--- drivers/iio/chemical/bme680.h | 2 -- drivers/iio/chemical/bme680_core.c | 31 ++++++++++++++---------------- 2 files changed, 14 insertions(+), 19 deletions(-)
drivers/iio/chemical/bme680.h +0 -2
@@ -27,8 +27,6 @@#define BME680_OSRS_TEMP_MASK GENMASK(7, 5)#define BME680_OSRS_PRESS_MASK GENMASK(4, 2)#define BME680_MODE_MASK GENMASK(1, 0) -#define BME680_MODE_FORCED 1 -#define BME680_MODE_SLEEP 0#define BME680_REG_CONFIG 0x75#define BME680_FILTER_MASK GENMASK(4, 2)
drivers/iio/chemical/bme680_core.c +14 -17
@@ -95,6 +95,12 @@ struct bme680_calib {s8 range_sw_err; }; +/* values of CTRL_MEAS register */ +enum bme680_op_mode { +BME680_MODE_SLEEP =0 , +BME680_MODE_FORCED =1 , +}; +struct bme680_data {struct regmap *regmap;struct bme680_calib bme680;
@@ -502,23 +508,16 @@ static u8 bme680_calc_heater_dur(u16 dur)return durval; } -static int bme680_set_mode (struct bme680_data *data,bool mode) +static int bme680_set_mode (struct bme680_data *data,enum bme680_op_mode mode) {struct device *dev =regmap_get_device (data->regmap);int ret; -if (mode) { - ret =regmap_write_bits (data->regmap,BME680_REG_CTRL_MEAS , -BME680_MODE_MASK ,BME680_MODE_FORCED ); -if (ret <0 ) -dev_err (dev,"failed to set forced mode\n" ); - - }else { - ret =regmap_write_bits (data->regmap,BME680_REG_CTRL_MEAS , -BME680_MODE_MASK ,BME680_MODE_SLEEP ); -if (ret <0 ) -dev_err (dev,"failed to set sleep mode\n" ); - + ret =regmap_write_bits (data->regmap,BME680_REG_CTRL_MEAS , +BME680_MODE_MASK , mode); +if (ret <0 ) { +dev_err (dev,"failed to set ctrl_meas register\n" ); +return ret; }return ret;
@@ -613,8 +612,7 @@ static int bme680_gas_config(struct bme680_data *data)int ret;u8 heatr_res, heatr_dur; -/* Go to sleep */ - ret =bme680_set_mode (data, false); + ret =bme680_set_mode (data,BME680_MODE_SLEEP );if (ret <0 )return ret;
@@ -745,8 +743,7 @@ static int bme680_read_raw(struct iio_dev *indio_dev,guard (mutex)(&data->lock); -/* set forced mode to trigger measurement */ - ret =bme680_set_mode (data, true); + ret =bme680_set_mode (data,BME680_MODE_FORCED );if (ret <0 )return ret;
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v3 1/7] iio: chemical: bme680: refactorize set_mode() mode
Quoted 5 lines · On Sat, 2 Nov 2024 14:13:05 +0100 Vasileios Amoiridis…
Refactorize the
set_mode()function to use an external enum that describes the possible modes of the BME680 device instead of using true/false variables for selecting SLEEPING/FORCED mode.Signed-off-by Vasileios Amoiridis <[email protected]>
Applied and pushed out as testing to see if 0-day can find anything we missed.
Thanks,
J
PATCH v3 2/7 iio: chemical: bme680: Add SCALE and RAW channels
In reply to Vasileios AmoiridisAdd SCALE,RAW channels to the device. Even though PROCESSED should be kept for backwards compatibility add comment to avoid using it if the value is not actually reported in IIO values.
--- drivers/iio/chemical/bme680_core.c | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/iio/chemical/bme680_core.c +51 -0
@@ -144,17 +144,26 @@ EXPORT_SYMBOL_NS(bme680_regmap_config, IIO_BME680);static const struct iio_chan_spec bme680_channels[] = { { .type =IIO_TEMP , +/* PROCESSED maintained for ABI backwards compatibility */ .info_mask_separate =BIT (IIO_CHAN_INFO_PROCESSED ) | +BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ) |BIT (IIO_CHAN_INFO_OVERSAMPLING_RATIO ), }, { .type =IIO_PRESSURE , +/* PROCESSED maintained for ABI backwards compatibility */ .info_mask_separate =BIT (IIO_CHAN_INFO_PROCESSED ) | +BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ) |BIT (IIO_CHAN_INFO_OVERSAMPLING_RATIO ), }, { .type =IIO_HUMIDITYRELATIVE , +/* PROCESSED maintained for ABI backwards compatibility */ .info_mask_separate =BIT (IIO_CHAN_INFO_PROCESSED ) | +BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_SCALE ) |BIT (IIO_CHAN_INFO_OVERSAMPLING_RATIO ), }, {
@@ -787,6 +796,48 @@ static int bme680_read_raw(struct iio_dev *indio_dev,default :return -EINVAL ; } +case IIO_CHAN_INFO_RAW : +switch (chan->type) { +case IIO_TEMP : + ret =bme680_read_temp (data, (s16 *)&chan_val); +if (ret) +return ret; + + *val = chan_val; +return IIO_VAL_INT ; +case IIO_PRESSURE : + ret =bme680_read_press (data, &chan_val); +if (ret) +return ret; + + *val = chan_val; +return IIO_VAL_INT ; +case IIO_HUMIDITYRELATIVE : + ret =bme680_read_humid (data, &chan_val); +if (ret) +return ret; + + *val = chan_val; +return IIO_VAL_INT ; +default : +return -EINVAL ; + } +case IIO_CHAN_INFO_SCALE : +switch (chan->type) { +case IIO_TEMP : + *val =10 ; +return IIO_VAL_INT ; +case IIO_PRESSURE : + *val =1 ; + *val2 =1000 ; +return IIO_VAL_FRACTIONAL ; +case IIO_HUMIDITYRELATIVE : + *val =1 ; + *val2 =1000 ; +return IIO_VAL_FRACTIONAL ; +default : +return -EINVAL ; + }case IIO_CHAN_INFO_OVERSAMPLING_RATIO :switch (chan->type) {case IIO_TEMP :
Signature · 1 line
2.43.0
Re: [PATCH v3 2/7] iio: chemical: bme680: Add SCALE and RAW channels
Quoted 5 lines · On Sat, 2 Nov 2024 14:13:06 +0100 Vasileios Amoiridis…
Add SCALE,RAW channels to the device. Even though PROCESSED should be kept for backwards compatibility add comment to avoid using it if the value is not actually reported in IIO values.
Signed-off-by Vasileios Amoiridis <[email protected]>
Applied.
PATCH v3 3/7 iio: chemical: bme680: Add triggered buffer support
In reply to Vasileios AmoiridisAdd triggered buffer and soft timestamp support. The available scan mask enables all the channels of the sensor in order to follow the operation of the sensor. The sensor basically starts to capture from all channels as long as it enters into FORCED mode.
The bulk read, reads a total of 15 registers from the sensor, 0x1D..0x2B. Even though some of those registers are not reported in the register map of the device, this is how the BME680 Sensor API [1] proposes to do it. This allows to have one bulk read instead of multiple ones.
--- drivers/iio/chemical/Kconfig | 2 + drivers/iio/chemical/bme680.h | 3 + drivers/iio/chemical/bme680_core.c | 137 ++++++++++++++++++++++++++++- 3 files changed, 141 insertions(+), 1 deletion(-)
drivers/iio/chemical/Kconfig +2 -0
@@ -50,6 +50,8 @@ config BME680 select REGMAP select BME680_I2C if I2C select BME680_SPI if SPI + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER help Say yes here to build support for Bosch Sensortec BME680 sensor with temperature, pressure, humidity and gas sensing capability.
drivers/iio/chemical/bme680.h +3 -0
@@ -66,6 +66,9 @@/* Datasheet Section 1.1, Table 1 */ #define BME680_STARTUP_TIME_US 2000 +#define BME680_NUM_CHANNELS 4 +#define BME680_NUM_BULK_READ_REGS 15 +/* Calibration Parameters */ #define BME680_T2_LSB_REG 0x8A#define BME680_H2_MSB_REG 0xE1
drivers/iio/chemical/bme680_core.c +136 -1
199 lines not on this page · raw message
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v3 3/7] iio: chemical: bme680: Add triggered buffer support
Quoted 5 lines · On Sat, 2 Nov 2024 14:13:07 +0100 Vasileios Amoiridis…
Add triggered buffer and soft timestamp support. The available scan mask enables all the channels of the sensor in order to follow the operation of the sensor. The sensor basically starts to capture from all channels as long as it enters into FORCED mode.
Quoted 7 lines
The bulk read, reads a total of 15 registers from the sensor, 0x1D..0x2B. Even though some of those registers are not reported in the register map of the device, this is how the BME680 Sensor API [1] proposes to do it. This allows to have one bulk read instead of multiple ones.
Applied with a couple of (to me) superfluous comments dropped.
Quoted 13 lines
drivers/iio/chemical/bme680_core.c +13
-0+static irqreturn_t bme680_trigger_handler (int irq,void *p) +{ +struct iio_poll_func *pf = p; +struct iio_dev *indio_dev = pf->indio_dev; +struct bme680_data *data =iio_priv (indio_dev); +struct device *dev =regmap_get_device (data->regmap); +u32 adc_temp, adc_press, adc_humid; +u16 adc_gas_res, gas_regs_val; +u8 gas_range; +s32 t_fine; +int ret; + +guard (mutex)(&data->lock);
drivers/iio/chemical/bme680_core.c static const struct iio_info bme680_info = { · line 994
Quoted 10 lines
drivers/iio/chemical/bme680_core.c +10
-0+ + ret =bme680_set_mode (data,BME680_MODE_FORCED ); +if (ret <0 ) + goto out; + + ret =bme680_wait_for_eoc (data); +if (ret) + goto out; + +/* Burst read data regs */
This one dropped as kind of obvious from the code.
Quoted 37 lines
drivers/iio/chemical/bme680_core.c +37
-0+ ret =regmap_bulk_read (data->regmap,BME680_REG_MEAS_STAT_0 , + data->buf,sizeof (data->buf)); +if (ret) { +dev_err (dev,"failed to burst read sensor data\n" ); + goto out; + } +if (data->buf[0 ] &BME680_GAS_MEAS_BIT ) { +dev_err (dev,"gas measurement incomplete\n" ); + goto out; + } + +/* Temperature calculations */ + adc_temp =FIELD_GET (BME680_MEAS_TRIM_MASK ,get_unaligned_be24 (&data->buf[5 ])); +if (adc_temp ==BME680_MEAS_SKIPPED ) { +dev_err (dev,"reading temperature skipped\n" ); + goto out; + } + data->scan.chan[0 ] =bme680_compensate_temp (data, adc_temp); + t_fine =bme680_calc_t_fine (data, adc_temp); + +/* Pressure calculations */ + adc_press =FIELD_GET (BME680_MEAS_TRIM_MASK ,get_unaligned_be24 (&data->buf[2 ])); +if (adc_press ==BME680_MEAS_SKIPPED ) { +dev_err (dev,"reading pressure skipped\n" ); + goto out; + } + data->scan.chan[1 ] =bme680_compensate_press (data, adc_press, t_fine); + +/* Humidity calculations */ + adc_humid =get_unaligned_be16 (&data->buf[8 ]); +if (adc_humid ==BME680_MEAS_SKIPPED ) { +dev_err (dev,"reading humidity skipped\n" ); + goto out; + } + data->scan.chan[2 ] =bme680_compensate_humid (data, adc_humid, t_fine); + +/* Gas calculations */
drivers/iio/chemical/bme680_core.c static const struct iio_info bme680_info = { · line 1041
Quoted 10 lines
drivers/iio/chemical/bme680_core.c +10
-0+ gas_regs_val =get_unaligned_be16 (&data->buf[13 ]); + adc_gas_res =FIELD_GET (BME680_ADC_GAS_RES , gas_regs_val); +if ((gas_regs_val &BME680_GAS_STAB_BIT ) ==0 ) { +dev_err (dev,"heater failed to reach the target temperature\n" ); + goto out; + } + gas_range =FIELD_GET (BME680_GAS_RANGE_MASK , gas_regs_val); + data->scan.chan[3 ] =bme680_compensate_gas (data, adc_gas_res, gas_range); + +/* Push to buffer */
This one is extremely obvious so dropped.
Quoted 7 lines
drivers/iio/chemical/bme680_core.c +7
-0+iio_push_to_buffers_with_timestamp (indio_dev, &data->scan, +iio_get_time_ns (indio_dev)); +out: +iio_trigger_notify_done (indio_dev->trig); +return IRQ_HANDLED ; +} +
PATCH v3 4/7 iio: chemical: bme680: Add support for preheat current
In reply to Vasileios AmoiridisAdd functionality to inject a specified amount of current to the heating plate before the start of the gas measurement to allow the sensor to reach faster to the requested temperature.
--- drivers/iio/chemical/bme680.h | 1 + drivers/iio/chemical/bme680_core.c | 41 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)
drivers/iio/chemical/bme680.h +1 -0
@@ -42,6 +42,7 @@#define BME680_RHRANGE_MASK GENMASK(5, 4)#define BME680_REG_RES_HEAT_VAL 0x00#define BME680_RSERROR_MASK GENMASK(7, 4) +#define BME680_REG_IDAC_HEAT_0 0x50#define BME680_REG_RES_HEAT_0 0x5A#define BME680_REG_GAS_WAIT_0 0x64#define BME680_ADC_GAS_RES GENMASK(15, 6)
drivers/iio/chemical/bme680_core.c +41 -0
83 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v3 4/7] iio: chemical: bme680: Add support for preheat current
Quoted 5 lines · On Sat, 2 Nov 2024 14:13:08 +0100 Vasileios Amoiridis…
Add functionality to inject a specified amount of current to the heating plate before the start of the gas measurement to allow the sensor to reach faster to the requested temperature.
Signed-off-by Vasileios Amoiridis <[email protected]>
Applied.
Thanks,
Jonathan
PATCH v3 5/7 dt-bindings: iio: bosch,bme680: Add supply properties
In reply to Vasileios AmoiridisExtend dt-binding for BME680 gas sensor device. The device incorporates as well temperature, pressure and relative humidity sensors.
--- .../bindings/iio/chemical/bosch,bme680.yaml | 62 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 2 - 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/chemical/bosch,bme680.yaml
Documentation/devicetree/bindings/iio/chemical/bosch,bme680.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/chemical/bosch,bme680.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BME680 Gas sensor + +maintainers: + - Vasileios Amoiridis <[email protected]> + +description: > + BME680 is a gas sensor which combines relative humidity, barometric pressure, + ambient temperature and gas (VOC - Volatile Organic Compounds) measurements. + + https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme680-ds001.pdf + +properties: + compatible: + const: bosch,bme680 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + +required: + - compatible + - reg + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + bme680@77 { + compatible = "bosch,bme680"; + reg = <0x77>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + }; + }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + bme680@0 { + compatible = "bosch,bme680"; + reg = <0>; + spi-max-frequency = <500000>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + }; + };
Documentation/devicetree/bindings/trivial-devices.yaml +0 -2
@@ -55,8 +55,6 @@ properties: - atmel,atsha204a # BPA-RS600: Power Supply - blutek,bpa-rs600 - # Bosch Sensortec pressure, temperature, humididty and VOC sensor - - bosch,bme680 # CM32181: Ambient Light Sensor - capella,cm32181 # CM3232: Ambient Light Sensor
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v3 5/7] dt-bindings: iio: bosch,bme680: Add supply properties
Quoted 2 lines · On Sat, 2 Nov 2024 14:13:09 +0100 Vasileios Amoiridis…
Extend dt-binding for BME680 gas sensor device. The device incorporates as well temperature, pressure and relative humidity sensors.
This description should make it clear it is moving from trivial-devices.yaml
dt-bindings: iio: bosch,bme680: Move from trivial-bindings and add missing supplies.
Then say a little more on why you are moving it.
Quoted 2 lines
Signed-off-by Vasileios Amoiridis <[email protected]>
There was an open question on the previous version about setting the supplies as required (which I see you've removed). My understanding previously was that it is fine to make that change in a binding if it reflects supplies that are required to be enabled for the device to function at all. If there were previously missing that's a binding bug we should fix.
I'd like a clarification from the DT binding maintainers on that. Obviously doesn't work for other users of dt bindings but in Linux this would be fine as they were already on for any board that worked and the regulator framework will through us a fake regulator for cases like this.
https://lore.kernel.org/all/[email protected]/
Jonathan
https://lore.kernel.org/all/[email protected]/
Quoted 87 lines
--- .../bindings/iio/chemical/bosch,bme680.yaml | 62 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 2 - 2 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/chemical/bosch,bme680.yamlDocumentation/devicetree/bindings/iio/chemical/bosch,bme680.yaml new file +62
-0@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/chemical/bosch,bme680.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BME680 Gas sensor + +maintainers: + - Vasileios Amoiridis <[email protected]> + +description: > + BME680 is a gas sensor which combines relative humidity, barometric pressure, + ambient temperature and gas (VOC - Volatile Organic Compounds) measurements. + + https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bme680-ds001.pdf + +properties: + compatible: + const: bosch,bme680 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + +required: + - compatible + - reg + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + bme680@77 { + compatible = "bosch,bme680"; + reg = <0x77>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + }; + }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + bme680@0 { + compatible = "bosch,bme680"; + reg = <0>; + spi-max-frequency = <500000>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + }; + };Documentation/devicetree/bindings/trivial-devices.yaml +0
-2@@ -55,8 +55,6 @@ properties: - atmel,atsha204a # BPA-RS600: Power Supply - blutek,bpa-rs600 - # Bosch Sensortec pressure, temperature, humididty and VOC sensor - - bosch,bme680 # CM32181: Ambient Light Sensor - capella,cm32181 # CM3232: Ambient Light Sensor
Re: [PATCH v3 5/7] dt-bindings: iio: bosch,bme680: Add supply properties
Quoted 27 lines · Jonathan Cameron
Quoted 2 lines · On Sat, 2 Nov 2024 14:13:09 +0100 Vasileios Amoiridis…
Extend dt-binding for BME680 gas sensor device. The device incorporates as well temperature, pressure and relative humidity sensors.
This description should make it clear it is moving from
trivial-devices.yamldt-bindings: iio: bosch,bme680: Move from trivial-bindings and add missing supplies.
Then say a little more on why you are moving it.
Quoted 2 lines
Signed-off-by Vasileios Amoiridis <[email protected]>There was an open question on the previous version about setting the supplies as required (which I see you've removed). My understanding previously was that it is fine to make that change in a binding if it reflects supplies that are required to be enabled for the device to function at all. If there were previously missing that's a binding bug we should fix.
I'd like a clarification from the DT binding maintainers on that. Obviously doesn't work for other users of dt bindings but in Linux this would be fine as they were already on for any board that worked and the regulator framework will through us a fake regulator for cases like this.
Quoted 3 lines
https://lore.kernel.org/all/[email protected]/
Jonathan
That was Rob's objection so I will leave it to him, but putting my two cents in for Linux it is not an ABI break because missing regulator supplies are substituted with dummy ones. Unless something changed...
Best regards,
Krzysztof
Rob Herring
maintainerRe: [PATCH v3 5/7] dt-bindings: iio: bosch,bme680: Add supply properties
Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Jonathan Cameron
Quoted 2 lines · On Sat, 2 Nov 2024 14:13:09 +0100 Vasileios Amoiridis…
Extend dt-binding for BME680 gas sensor device. The device incorporates as well temperature, pressure and relative humidity sensors.
This description should make it clear it is moving from
trivial-devices.yamldt-bindings: iio: bosch,bme680: Move from trivial-bindings and add missing supplies.
Then say a little more on why you are moving it.
Quoted 2 lines
Signed-off-by Vasileios Amoiridis <[email protected]>There was an open question on the previous version about setting the supplies as required (which I see you've removed). My understanding previously was that it is fine to make that change in a binding if it reflects supplies that are required to be enabled for the device to function at all. If there were previously missing that's a binding bug we should fix.
I'd like a clarification from the DT binding maintainers on that. Obviously doesn't work for other users of dt bindings but in Linux this would be fine as they were already on for any board that worked and the regulator framework will through us a fake regulator for cases like this.
Quoted 7 lines
Quoted 3 lines
https://lore.kernel.org/all/[email protected]/
Jonathan
That was Rob's objection so I will leave it to him, but putting my two cents in for Linux it is not an ABI break because missing regulator supplies are substituted with dummy ones. Unless something changed...
Shrug. I don't think we're entirely consistent on this. If we're saying supplies are always required, then every device in trivial-devices.yaml is wrong. Since Linux handles them missing, you can also argue that supplies are never required.
I'd prefer not to special case regulators as an exception I have to remember. I have some rudimentary ABI checking I'm working on that checks for things like new required properties. Though it wouldn't catch this particular change given it moves the schema.
Rob
Re: [PATCH v3 5/7] dt-bindings: iio: bosch,bme680: Add supply properties
Quoted 42 lines · Rob Herring
Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Jonathan Cameron
Quoted 2 lines · On Sat, 2 Nov 2024 14:13:09 +0100 Vasileios Amoiridis…
Extend dt-binding for BME680 gas sensor device. The device incorporates as well temperature, pressure and relative humidity sensors.
This description should make it clear it is moving from
trivial-devices.yamldt-bindings: iio: bosch,bme680: Move from trivial-bindings and add missing supplies.
Then say a little more on why you are moving it.
Quoted 2 lines
Signed-off-by Vasileios Amoiridis <[email protected]>There was an open question on the previous version about setting the supplies as required (which I see you've removed). My understanding previously was that it is fine to make that change in a binding if it reflects supplies that are required to be enabled for the device to function at all. If there were previously missing that's a binding bug we should fix.
I'd like a clarification from the DT binding maintainers on that. Obviously doesn't work for other users of dt bindings but in Linux this would be fine as they were already on for any board that worked and the regulator framework will through us a fake regulator for cases like this.
Quoted 7 lines
Quoted 3 lines
https://lore.kernel.org/all/[email protected]/
Jonathan
That was Rob's objection so I will leave it to him, but putting my two cents in for Linux it is not an ABI break because missing regulator supplies are substituted with dummy ones. Unless something changed...
Shrug. I don't think we're entirely consistent on this. If we're saying supplies are always required, then every device in
trivial-devices.yamlis wrong. Since Linux handles them missing, you can also argue that supplies are never required.
Quoted 6 lines
I'd prefer not to special case regulators as an exception I have to remember. I have some rudimentary ABI checking I'm working on that checks for things like new required properties. Though it wouldn't catch this particular change given it moves the schema.
Rob
Hi Jonathan,
According to Rob's answer, do you think that we can move on with the last 3 patches as they are or do you want some changes?
Cheers,
Vasilis
Rob Herring
maintainerRe: [PATCH v3 5/7] dt-bindings: iio: bosch,bme680: Add supply properties
Quoted 48 lines · Vasileios Amoiridis
Quoted 47 lines · Rob Herring
Quoted 28 lines · Krzysztof Kozlowski
Quoted 27 lines · Jonathan Cameron
Quoted 2 lines · On Sat, 2 Nov 2024 14:13:09 +0100 Vasileios Amoiridis…
Extend dt-binding for BME680 gas sensor device. The device incorporates as well temperature, pressure and relative humidity sensors.
This description should make it clear it is moving from
trivial-devices.yamldt-bindings: iio: bosch,bme680: Move from trivial-bindings and add missing supplies.
Then say a little more on why you are moving it.
Quoted 2 lines
Signed-off-by Vasileios Amoiridis <[email protected]>There was an open question on the previous version about setting the supplies as required (which I see you've removed). My understanding previously was that it is fine to make that change in a binding if it reflects supplies that are required to be enabled for the device to function at all. If there were previously missing that's a binding bug we should fix.
I'd like a clarification from the DT binding maintainers on that. Obviously doesn't work for other users of dt bindings but in Linux this would be fine as they were already on for any board that worked and the regulator framework will through us a fake regulator for cases like this.
Quoted 7 lines
Quoted 3 lines
https://lore.kernel.org/all/[email protected]/
Jonathan
That was Rob's objection so I will leave it to him, but putting my two cents in for Linux it is not an ABI break because missing regulator supplies are substituted with dummy ones. Unless something changed...
Shrug. I don't think we're entirely consistent on this. If we're saying supplies are always required, then every device in
trivial-devices.yamlis wrong. Since Linux handles them missing, you can also argue that supplies are never required.I'd prefer not to special case regulators as an exception I have to remember. I have some rudimentary ABI checking I'm working on that checks for things like new required properties. Though it wouldn't catch this particular change given it moves the schema.
Quoted 6 lines
Quoted 1 line
Rob
Hi Jonathan,
According to Rob's answer, do you think that we can move on with the last 3 patches as they are or do you want some changes?
Please update the commit message as Jonathan requested and resend (though you might as well wait til the end of the merge window now).
Rob
PATCH v3 6/7 iio: chemical: bme680: add regulators
In reply to Vasileios AmoiridisAdd support for the regulators described in the dt-binding.
--- drivers/iio/chemical/bme680_core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/iio/chemical/bme680_core.c +13 -0
@@ -15,6 +15,7 @@#include <linux/log2.h> #include <linux/module.h> #include <linux/regmap.h> +#include <linux/regulator/consumer.h> #include <linux/iio/buffer.h> #include <linux/iio/iio.h>
@@ -111,6 +112,10 @@ enum bme680_scan { BME680_GAS, }; +static const char *const bme680_supply_names[] = {"vdd" ,"vddio" }; + +#define BME680_NUM_SUPPLIES ARRAY_SIZE(bme680_supply_names) +struct bme680_data {struct regmap *regmap;struct bme680_calib bme680;
@@ -1116,6 +1121,14 @@ int bme680_core_probe(struct device *dev, struct regmap *regmap, data->heater_dur =150 ;/* milliseconds */ data->preheat_curr_mA =0 ; + ret =devm_regulator_bulk_get_enable (dev,BME680_NUM_SUPPLIES , + bme680_supply_names); +if (ret) +return dev_err_probe (dev, ret, +"failed to get and enable supplies.\n" ); + +fsleep (BME680_STARTUP_TIME_US ); + ret =regmap_write (regmap,BME680_REG_SOFT_RESET ,BME680_CMD_SOFTRESET );if (ret <0 )return dev_err_probe (dev, ret,"Failed to reset chip\n" );
Signature · 1 line
2.43.0
PATCH v3 7/7 iio: chemical: bme680: add power management
In reply to Vasileios AmoiridisAdd runtime power management to the device.
--- drivers/iio/chemical/bme680.h | 2 + drivers/iio/chemical/bme680_core.c | 104 +++++++++++++++++++++++++++-- drivers/iio/chemical/bme680_i2c.c | 1 + drivers/iio/chemical/bme680_spi.c | 1 + 4 files changed, 101 insertions(+), 7 deletions(-)
drivers/iio/chemical/bme680.h +2 -0
@@ -2,6 +2,7 @@#ifndef BME680_H_ #define BME680_H_ +#include <linux/pm.h> #include <linux/regmap.h> #define BME680_REG_CHIP_ID 0xD0
@@ -80,6 +81,7 @@#define BME680_CALIB_RANGE_3_LEN 5extern const struct regmap_config bme680_regmap_config; +extern const struct dev_pm_ops bme680_dev_pm_ops;int bme680_core_probe (struct device *dev,struct regmap *regmap,const char *name);
drivers/iio/chemical/bme680_core.c +97 -7
153 lines not on this page · raw message
drivers/iio/chemical/bme680_i2c.c +1 -0
@@ -51,6 +51,7 @@ static struct i2c_driver bme680_i2c_driver = { .driver = { .name = "bme680_i2c", .of_match_table = bme680_of_i2c_match, + .pm = pm_ptr(&bme680_dev_pm_ops), }, .probe = bme680_i2c_probe, .id_table = bme680_i2c_id,
drivers/iio/chemical/bme680_spi.c +1 -0
@@ -154,6 +154,7 @@ static struct spi_driver bme680_spi_driver = { .driver = { .name = "bme680_spi", .of_match_table = bme680_of_spi_match, + .pm = pm_ptr(&bme680_dev_pm_ops), }, .probe = bme680_spi_probe, .id_table = bme680_spi_id,
Signature · 1 line
2.43.0
Jonathan Cameron
maintainerRe: [PATCH v3 7/7] iio: chemical: bme680: add power management
Quoted 3 lines · On Sat, 2 Nov 2024 14:13:11 +0100 Vasileios Amoiridis…
Add runtime power management to the device.
Signed-off-by Vasileios Amoiridis <[email protected]>
This and previous patch look fine to me. Just need to clean up that dt-binding patch and hopefully get a clear direction on whether to require the supplies or not.
Thanks,
Jonathan
Re: [PATCH v3 7/7] iio: chemical: bme680: add power management
Quoted 5 lines · Jonathan Cameron
Quoted 2 lines · On Sat, 2 Nov 2024 14:13:11 +0100 Vasileios Amoiridis…
Add runtime power management to the device.
Quoted 8 lines
Quoted 1 line
Signed-off-by Vasileios Amoiridis <[email protected]>This and previous patch look fine to me. Just need to clean up that dt-binding patch and hopefully get a clear direction on whether to require the supplies or not.
Thanks,
Jonathan
Hi Jonathan,
Thank you very much for the review once again!
I will wait as well to see how that evolves and I will send a new version, thank you!
Cheers,
Vasilis