From: Brian Masney <hidden> Date: 2018-07-17 08:42:06
This patch set adds support for the gyroscope / accelerometer
(mpu6515), magnetometer (ak8963), temperature / pressure (bmp280), and
proximity / ALS (tsl2772) sensors to the LG Nexus 5 (hammerhead) phone.
Changes since v1:
- Correct mpu6050 patch based on feedback from Jonathan Cameron. See
that patch for more details.
- Add support for proximity / ALS driver (tsl2772).
Brian Masney (7):
iio: imu: mpu6050: add support for regulator framework
ARM: dts: qcom: msm8974-hammerhead: add device tree bindings for
mpu6515
iio: tsl2772: add support for reading power settings from device tree
dt-bindings: trivial: remove tsl2772
iio: tsl2772: add support for regulator framework
iio: tsl2772: add device tree binding for avago,apds9930
ARM: dts: qcom: msm8974-hammerhead: add device tree bindings for ALS /
proximity
.../bindings/iio/imu/inv_mpu6050.txt | 1 +
.../devicetree/bindings/iio/light/tsl2772.txt | 44 +++++++
.../devicetree/bindings/trivial-devices.txt | 10 --
.../qcom-msm8974-lge-nexus5-hammerhead.dts | 83 +++++++++++++
arch/arm/boot/dts/qcom-msm8974.dtsi | 22 ++++
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 73 +++++++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 +
drivers/iio/light/tsl2772.c | 116 +++++++++++++++++-
include/dt-bindings/iio/amstaos,tsl2772.h | 24 ++++
9 files changed, 363 insertions(+), 13 deletions(-)
create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt
create mode 100644 include/dt-bindings/iio/amstaos,tsl2772.h
--
2.17.1
From: Brian Masney <hidden> Date: 2018-07-17 08:42:08
This patch adds support for the regulator framework to the mpu6050
driver.
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
---
Changes since v1:
- Use devm_regulator_get() instead of devm_regulator_get_optional()
- Use devm_add_action() for cleaning up the regulator.
- Correct ordering of resume code.
- Add regulator_enabled flag to ensure regulator is not disabled twice,
specifically the case where the device is suspended and then the
driver is removed.
Original extra changelog from v1:
This is a variation of Jonathan Marek's patch from postmarketOS
https://gitlab.com/postmarketOS/linux-postmarketos/commit/b8ad1ec1859c8bbcbce94944b3f4dd68f8f9fc37
with the following changes:
- Stripped out 6515 variant code.
- Add the regulator to the mpu core instead of only the i2c variant.
- Add error handling.
- Release the regulator on suspend, device remove, etc.
- Device tree documentation.
.../bindings/iio/imu/inv_mpu6050.txt | 1 +
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 73 +++++++++++++++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 +
3 files changed, 77 insertions(+)
@@ -21,6 +21,7 @@ Required properties: bindings. Optional properties:+ - vddio-supply: regulator phandle for VDDIO supply - mount-matrix: an optional 3x3 mounting rotation matrix - i2c-gate node. These devices also support an auxiliary i2c bus. This is simple enough to be described using the i2c-gate binding. See
@@ -926,6 +927,46 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)returnresult;}+staticintinv_mpu_core_enable_regulator(structinv_mpu6050_state*st)+{+intresult;++result=regulator_enable(st->vddio_supply);+if(result){+dev_err(regmap_get_device(st->map),+"Failed to enable regulator: %d\n",result);+}else{+st->regulator_enabled=true;++/* Give the device a little bit of time to start up. */+usleep_range(35000,70000);+}++returnresult;+}++staticintinv_mpu_core_disable_regulator(structinv_mpu6050_state*st)+{+intresult;++if(!st->regulator_enabled)+return0;++result=regulator_disable(st->vddio_supply);+if(result)+dev_err(regmap_get_device(st->map),+"Failed to disable regulator: %d\n",result);++st->regulator_enabled=false;++returnresult;+}++staticvoidinv_mpu_core_disable_regulator_action(void*_data)+{+inv_mpu_core_disable_regulator(_data);+}+intinv_mpu_core_probe(structregmap*regmap,intirq,constchar*name,int(*inv_mpu_bus_setup)(structiio_dev*),intchip_type){
@@ -990,6 +1031,28 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,return-EINVAL;}+st->vddio_supply=devm_regulator_get(dev,"vddio");+if(IS_ERR(st->vddio_supply)){+if(PTR_ERR(st->vddio_supply)!=-EPROBE_DEFER)+dev_err(dev,"Failed to get vddio regulator %d\n",+(int)PTR_ERR(st->vddio_supply));++returnPTR_ERR(st->vddio_supply);+}++result=inv_mpu_core_enable_regulator(st);+if(result)+returnresult;++result=devm_add_action(dev,inv_mpu_core_disable_regulator_action,+st);+if(result){+inv_mpu_core_disable_regulator_action(st);+dev_err(dev,"Failed to setup regulator cleanup action %d\n",+result);+returnresult;+}+/* power is turned on inside check chip type*/result=inv_check_and_setup_chip(st);if(result)
@@ -1049,7 +1112,12 @@ static int inv_mpu_resume(struct device *dev)intresult;mutex_lock(&st->lock);+result=inv_mpu_core_enable_regulator(st);+if(result)+gotoout_unlock;+result=inv_mpu6050_set_power_itg(st,true);+out_unlock:mutex_unlock(&st->lock);returnresult;
@@ -1062,6 +1130,11 @@ static int inv_mpu_suspend(struct device *dev)mutex_lock(&st->lock);result=inv_mpu6050_set_power_itg(st,false);+if(result)+gotoout_unlock;++result=inv_mpu_core_disable_regulator(st);+out_unlock:mutex_unlock(&st->lock);returnresult;
From: Brian Masney <hidden> Date: 2018-07-17 08:42:09
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
---
The next patch in the series removes the tsl2772 driver from the
trivial-devices.txt file. I separated it out so that change can go
through device tree.
.../devicetree/bindings/iio/light/tsl2772.txt | 39 +++++++++++++++++++
drivers/iio/light/tsl2772.c | 16 ++++++++
include/dt-bindings/iio/amstaos,tsl2772.h | 24 ++++++++++++
3 files changed, 79 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt
create mode 100644 include/dt-bindings/iio/amstaos,tsl2772.h
@@ -0,0 +1,39 @@+* AMS/TAOS ALS and proximity sensor++Required properties:++ - compatible: Should be one of+ "amstaos,tsl2571"+ "amstaos,tsl2671"+ "amstaos,tmd2671"+ "amstaos,tsl2771"+ "amstaos,tmd2771"+ "amstaos,tsl2572"+ "amstaos,tsl2672"+ "amstaos,tmd2672"+ "amstaos,tsl2772"+ "amstaos,tmd2772"+ - reg: the I2C address of the device++Optional properties:++ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or+ TSL2772_DIODE_BOTH.+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,+ or TSL2772_13_mA.+ - interrupt-parent: should be the phandle for the interrupt controller+ - interrupts: the sole interrupt generated by the device++ Refer to interrupt-controller/interrupts.txt for generic interrupt client+ node bindings.++Example:++#include <dt-bindings/iio/amstaos,tsl2772.h>++tsl2772@39 {+ compatible = "amstaos,tsl2772";+ reg = <0x39>;+ interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>;+ amstaos,prox_diode = <TSL2772_DIODE0>;+};
From: Brian Masney <hidden> Date: 2018-07-17 08:42:13
The Avago APDS9930 has the same register set as the TAOS/AMS TSL2772 so
this patch adds the correct device tree bindings and the appropriate
LUX table values based on the values in the datasheet. Driver was tested
on a LG Nexus 5 (hammerhead) phone.
avago,apds9930 datasheet:
https://www.mouser.com/datasheet/2/678/avago_AV02-3190EN_DS_APDS-9930_2014-03-25[1]-1217273.pdf
tsl2772 datasheet:
https://ams.com/eng/content/download/291503/1066377/file/TSL2772_DS000181_2-00.pdf
Signed-off-by: Brian Masney <redacted>
---
.../devicetree/bindings/iio/light/tsl2772.txt | 1 +
drivers/iio/light/tsl2772.c | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
@@ -501,6 +511,7 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)casetmd2672:casetsl2772:casetmd2772:+caseapds9930:if(!(ret&TSL2772_STA_PRX_VALID)){ret=-EINVAL;gotoprox_poll_err;
@@ -1325,6 +1336,7 @@ static int tsl2772_device_id_verif(int id, int target)casetmd2672:casetsl2772:casetmd2772:+caseapds9930:return(id&0xf0)==SWORDFISH_ID;}
From: Brian Masney <hidden> Date: 2018-07-17 08:42:19
This patch adds device tree bindings for the tsl2772 ALS / proximity
sensor for the LG Nexus 5 (hammerhead) phone.
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
---
.../qcom-msm8974-lge-nexus5-hammerhead.dts | 27 +++++++++++++++++++
arch/arm/boot/dts/qcom-msm8974.dtsi | 11 ++++++++
2 files changed, 38 insertions(+)
From: Brian Masney <hidden> Date: 2018-07-17 08:42:26
This patch adds support for the regulator framework to the tsl2772
driver. Driver was tested using a LG Nexus 5 (hammerhead) phone with
the two regulators and on a Raspberry Pi 2 without any regulators
controlling the power to the sensor.
Signed-off-by: Brian Masney <redacted>
---
.../devicetree/bindings/iio/light/tsl2772.txt | 4 +
drivers/iio/light/tsl2772.c | 82 ++++++++++++++++++-
2 files changed, 85 insertions(+), 1 deletion(-)
@@ -21,6 +21,8 @@ Optional properties: TSL2772_DIODE_BOTH. - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA, or TSL2772_13_mA.+ - vdd-supply: phandle to the regulator that provides power to the sensor.+ - vddio-supply: phandle to the regulator that provides power to the bus. - interrupt-parent: should be the phandle for the interrupt controller - interrupts: the sole interrupt generated by the device
@@ -609,6 +613,46 @@ static int tsl2772_als_calibrate(struct iio_dev *indio_dev)returnret;}+staticinttsl2772_enable_regulators(structtsl2772_chip*chip)+{+intret;++ret=regulator_enable(chip->vddio_supply);+if(ret<0){+dev_err(&chip->client->dev,"Failed to enable regulator: %d\n",+ret);+returnret;+}++ret=regulator_enable(chip->vdd_supply);+if(ret<0){+regulator_disable(chip->vddio_supply);+dev_err(&chip->client->dev,"Failed to enable regulator: %d\n",+ret);+returnret;+}++chip->regulators_enabled=true;++return0;+}++staticvoidtsl2772_disable_regulators(structtsl2772_chip*chip)+{+if(!chip->regulators_enabled)+return;++regulator_disable(chip->vdd_supply);+regulator_disable(chip->vddio_supply);++chip->regulators_enabled=false;+}++staticvoidtsl2772_disable_regulators_action(void*_data)+{+tsl2772_disable_regulators(_data);+}+staticinttsl2772_chip_on(structiio_dev*indio_dev){structtsl2772_chip*chip=iio_priv(indio_dev);
@@ -666,6 +710,10 @@ static int tsl2772_chip_on(struct iio_dev *indio_dev)chip->als_gain_time_scale=als_time_us*tsl2772_als_gain[chip->settings.als_gain];+ret=tsl2772_enable_regulators(chip);+if(ret<0)+returnret;+/**TSL2772Specificpower-on/adcenablesequence*Poweronthedevice1st.
@@ -724,10 +772,13 @@ static int tsl2772_chip_on(struct iio_dev *indio_dev)staticinttsl2772_chip_off(structiio_dev*indio_dev){structtsl2772_chip*chip=iio_priv(indio_dev);+intret;/* turn device off */chip->tsl2772_chip_status=TSL2772_CHIP_SUSPENDED;-returntsl2772_write_control_reg(chip,0x00);+ret=tsl2772_write_control_reg(chip,0x00);+tsl2772_disable_regulators(chip);+returnret;}/**
@@ -1666,6 +1717,35 @@ static int tsl2772_probe(struct i2c_client *clientp,chip->client=clientp;i2c_set_clientdata(clientp,indio_dev);+chip->vddio_supply=devm_regulator_get(&clientp->dev,"vddio");+if(IS_ERR(chip->vddio_supply)){+if(PTR_ERR(chip->vddio_supply)!=-EPROBE_DEFER)+dev_err(&clientp->dev,+"Failed to get vddio regulator %d\n",+(int)PTR_ERR(chip->vddio_supply));++returnPTR_ERR(chip->vddio_supply);+}++chip->vdd_supply=devm_regulator_get(&clientp->dev,"vdd");+if(IS_ERR(chip->vdd_supply)){+if(PTR_ERR(chip->vdd_supply)!=-EPROBE_DEFER)+dev_err(&clientp->dev,+"Failed to get vdd regulator %d\n",+(int)PTR_ERR(chip->vdd_supply));++returnPTR_ERR(chip->vdd_supply);+}++ret=devm_add_action(&clientp->dev,tsl2772_disable_regulators_action,+chip);+if(ret<0){+tsl2772_disable_regulators_action(chip);+dev_err(&clientp->dev,"Failed to setup regulator cleanup action %d\n",+ret);+returnret;+}+ret=i2c_smbus_read_byte_data(chip->client,TSL2772_CMD_REG|TSL2772_CHIPID);if(ret<0)
From: Brian Masney <hidden> Date: 2018-07-17 08:42:37
Remove the tsl2772 driver from trivial-devices.txt. A separate
patch added the binding information to the file
Documentation/devicetree/bindings/iio/light/tsl2772.txt.
Signed-off-by: Brian Masney <redacted>
---
Documentation/devicetree/bindings/trivial-devices.txt | 10 ----------
1 file changed, 10 deletions(-)
@@ -21,16 +21,6 @@ adi,adt7490 +/-1C TDM Extended Temp Range I.C adi,adxl345 Three-Axis Digital Accelerometer adi,adxl346 Three-Axis Digital Accelerometer (backward-compatibility value "adi,adxl345" must be listed too) ams,iaq-core AMS iAQ-Core VOC Sensor-amstaos,tsl2571 AMS/TAOS ALS and proximity sensor-amstaos,tsl2671 AMS/TAOS ALS and proximity sensor-amstaos,tmd2671 AMS/TAOS ALS and proximity sensor-amstaos,tsl2771 AMS/TAOS ALS and proximity sensor-amstaos,tmd2771 AMS/TAOS ALS and proximity sensor-amstaos,tsl2572 AMS/TAOS ALS and proximity sensor-amstaos,tsl2672 AMS/TAOS ALS and proximity sensor-amstaos,tmd2672 AMS/TAOS ALS and proximity sensor-amstaos,tsl2772 AMS/TAOS ALS and proximity sensor-amstaos,tmd2772 AMS/TAOS ALS and proximity sensor at,24c08 i2c serial eeprom (24cxx) atmel,at97sc3204t i2c trusted platform module (TPM) capella,cm32181 CM32181: Ambient Light Sensor
From: Brian Masney <hidden> Date: 2018-07-17 08:42:52
This patch adds device tree bindings for the mpu6515 to the LG Nexus 5
(hammerhead) phone. Confirmed that the gyroscope / accelerometer
(mpu6515), magnetometer (ak8963), and temperature / pressure (bmp280)
sensors are available on the phone.
Interrupts are not working properly on the ak8963 magnetometer so they
are currently not configured.
The bmp280 retuns temperature/pressure measurement skipped errors but
will reliably work if I run:
echo 1 > in_pressure_oversampling_ratio
echo 1 > in_temp_oversampling_ratio
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
---
I'll send follow up patch(es) once I investigate why the skipped errors
are occurring with the bmp280 with the default oversampling ratios.
.../qcom-msm8974-lge-nexus5-hammerhead.dts | 56 +++++++++++++++++++
arch/arm/boot/dts/qcom-msm8974.dtsi | 11 ++++
2 files changed, 67 insertions(+)
@@ -277,6 +295,44 @@linux,code=<KEY_VOLUMEDOWN>;};};++i2c@f9968000{+status="ok";+pinctrl-names="default";+pinctrl-0=<&i2c12_pins>;+clock-frequency=<100000>;+qcom,src-freq=<50000000>;++mpu6515@68{+compatible="invensense,mpu6515";+reg=<0x68>;+interrupts-extended=<&msmgpio73IRQ_TYPE_EDGE_FALLING>;+vddio-supply=<&pm8941_lvs1>;++pinctrl-names="default";+pinctrl-0=<&mpu6515_pin>;++i2c-gate{+#address-cells=<1>;+#size-cells=<0>;+ak8963@f{+compatible="asahi-kasei,ak8963";+reg=<0x0f>;+// Currently only works in polling mode.+// gpios = <&msmgpio 61 0>;+vid-supply=<&pm8941_lvs1>;+vdd-supply=<&pm8941_l17>;+};++bmp280@76{+compatible="bosch,bmp280";+reg=<0x76>;+vdda-supply=<&pm8941_lvs1>;+vddd-supply=<&pm8941_l17>;+};+};+};+};};&spmi_bus{
From: Rob Herring <robh@kernel.org> Date: 2018-07-20 17:02:46
On Tue, Jul 17, 2018 at 04:41:52AM -0400, Brian Masney wrote:
This patch adds support for the regulator framework to the mpu6050
driver.
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
---
Changes since v1:
- Use devm_regulator_get() instead of devm_regulator_get_optional()
- Use devm_add_action() for cleaning up the regulator.
- Correct ordering of resume code.
- Add regulator_enabled flag to ensure regulator is not disabled twice,
specifically the case where the device is suspended and then the
driver is removed.
Original extra changelog from v1:
This is a variation of Jonathan Marek's patch from postmarketOS
https://gitlab.com/postmarketOS/linux-postmarketos/commit/b8ad1ec1859c8bbcbce94944b3f4dd68f8f9fc37
with the following changes:
- Stripped out 6515 variant code.
- Add the regulator to the mpu core instead of only the i2c variant.
- Add error handling.
- Release the regulator on suspend, device remove, etc.
- Device tree documentation.
.../bindings/iio/imu/inv_mpu6050.txt | 1 +
From: Rob Herring <robh@kernel.org> Date: 2018-07-20 17:36:43
On Tue, Jul 17, 2018 at 04:41:54AM -0400, Brian Masney wrote:
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
---
The next patch in the series removes the tsl2772 driver from the
trivial-devices.txt file. I separated it out so that change can go
through device tree.
.../devicetree/bindings/iio/light/tsl2772.txt | 39 +++++++++++++++++++
@@ -0,0 +1,39 @@+* AMS/TAOS ALS and proximity sensor++Required properties:++ - compatible: Should be one of+ "amstaos,tsl2571"+ "amstaos,tsl2671"+ "amstaos,tmd2671"+ "amstaos,tsl2771"+ "amstaos,tmd2771"+ "amstaos,tsl2572"+ "amstaos,tsl2672"+ "amstaos,tmd2672"+ "amstaos,tsl2772"+ "amstaos,tmd2772"+ - reg: the I2C address of the device++Optional properties:++ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or+ TSL2772_DIODE_BOTH.
s/_/-/
+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,
+ or TSL2772_13_mA.
I wonder if this should be common. Perhaps we should use the existing
'led-max-microamp' as this is setting the current for an IR LED.
And while called 'power' this setting is current.
+ - interrupt-parent: should be the phandle for the interrupt controller
Don't need to document this. It's implied by interrupts (and could be in
a parent node).
+ - interrupts: the sole interrupt generated by the device
+
+ Refer to interrupt-controller/interrupts.txt for generic interrupt client
+ node bindings.
+
+Example:
+
+#include <dt-bindings/iio/amstaos,tsl2772.h>
+
+tsl2772@39 {
+ compatible = "amstaos,tsl2772";
+ reg = <0x39>;
+ interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>;
+ amstaos,prox_diode = <TSL2772_DIODE0>;
+};
From: Rob Herring <robh@kernel.org> Date: 2018-07-20 17:38:31
On Tue, Jul 17, 2018 at 04:41:56AM -0400, Brian Masney wrote:
This patch adds support for the regulator framework to the tsl2772
driver. Driver was tested using a LG Nexus 5 (hammerhead) phone with
the two regulators and on a Raspberry Pi 2 without any regulators
controlling the power to the sensor.
Signed-off-by: Brian Masney <redacted>
---
.../devicetree/bindings/iio/light/tsl2772.txt | 4 +
This belongs with the binding patch. Bindings should be complete, not
extended as a driver changes.
From: Jonathan Cameron <jic23@kernel.org> Date: 2018-07-21 17:31:17
On Tue, 17 Jul 2018 04:41:52 -0400
Brian Masney [off-list ref] wrote:
This patch adds support for the regulator framework to the mpu6050
driver.
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
I'm not 100% sure what the purpose of the regulator_enabled
tracking is. Perhaps you could point out the path where that is
needed?
Also, a missing bit of documentation needs adding.
Jonathan
quoted hunk
---
Changes since v1:
- Use devm_regulator_get() instead of devm_regulator_get_optional()
- Use devm_add_action() for cleaning up the regulator.
- Correct ordering of resume code.
- Add regulator_enabled flag to ensure regulator is not disabled twice,
specifically the case where the device is suspended and then the
driver is removed.
Original extra changelog from v1:
This is a variation of Jonathan Marek's patch from postmarketOS
https://gitlab.com/postmarketOS/linux-postmarketos/commit/b8ad1ec1859c8bbcbce94944b3f4dd68f8f9fc37
with the following changes:
- Stripped out 6515 variant code.
- Add the regulator to the mpu core instead of only the i2c variant.
- Add error handling.
- Release the regulator on suspend, device remove, etc.
- Device tree documentation.
.../bindings/iio/imu/inv_mpu6050.txt | 1 +
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 73 +++++++++++++++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 +
3 files changed, 77 insertions(+)
@@ -21,6 +21,7 @@ Required properties: bindings. Optional properties:+ - vddio-supply: regulator phandle for VDDIO supply - mount-matrix: an optional 3x3 mounting rotation matrix - i2c-gate node. These devices also support an auxiliary i2c bus. This is simple enough to be described using the i2c-gate binding. See
@@ -926,6 +927,46 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)returnresult;}+staticintinv_mpu_core_enable_regulator(structinv_mpu6050_state*st)+{+intresult;++result=regulator_enable(st->vddio_supply);+if(result){+dev_err(regmap_get_device(st->map),+"Failed to enable regulator: %d\n",result);+}else{+st->regulator_enabled=true;++/* Give the device a little bit of time to start up. */+usleep_range(35000,70000);+}++returnresult;+}++staticintinv_mpu_core_disable_regulator(structinv_mpu6050_state*st)+{+intresult;++if(!st->regulator_enabled)+return0;++result=regulator_disable(st->vddio_supply);+if(result)+dev_err(regmap_get_device(st->map),+"Failed to disable regulator: %d\n",result);++st->regulator_enabled=false;++returnresult;+}++staticvoidinv_mpu_core_disable_regulator_action(void*_data)+{+inv_mpu_core_disable_regulator(_data);+}+intinv_mpu_core_probe(structregmap*regmap,intirq,constchar*name,int(*inv_mpu_bus_setup)(structiio_dev*),intchip_type){
@@ -990,6 +1031,28 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,return-EINVAL;}+st->vddio_supply=devm_regulator_get(dev,"vddio");+if(IS_ERR(st->vddio_supply)){+if(PTR_ERR(st->vddio_supply)!=-EPROBE_DEFER)+dev_err(dev,"Failed to get vddio regulator %d\n",+(int)PTR_ERR(st->vddio_supply));++returnPTR_ERR(st->vddio_supply);+}++result=inv_mpu_core_enable_regulator(st);+if(result)+returnresult;++result=devm_add_action(dev,inv_mpu_core_disable_regulator_action,+st);+if(result){+inv_mpu_core_disable_regulator_action(st);+dev_err(dev,"Failed to setup regulator cleanup action %d\n",+result);+returnresult;+}+/* power is turned on inside check chip type*/result=inv_check_and_setup_chip(st);if(result)
@@ -1049,7 +1112,12 @@ static int inv_mpu_resume(struct device *dev)intresult;mutex_lock(&st->lock);+result=inv_mpu_core_enable_regulator(st);+if(result)+gotoout_unlock;+result=inv_mpu6050_set_power_itg(st,true);+out_unlock:mutex_unlock(&st->lock);returnresult;
@@ -1062,6 +1130,11 @@ static int inv_mpu_suspend(struct device *dev)mutex_lock(&st->lock);result=inv_mpu6050_set_power_itg(st,false);+if(result)+gotoout_unlock;++result=inv_mpu_core_disable_regulator(st);+out_unlock:mutex_unlock(&st->lock);returnresult;
From: Jonathan Cameron <jic23@kernel.org> Date: 2018-07-21 17:36:08
On Tue, 17 Jul 2018 04:41:54 -0400
Brian Masney [off-list ref] wrote:
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
I think we can make this binding more 'generic' as right now
the amstaos bindings aren't even general enough to apply
to future amstaos devices that need a similar binding.
I'm always anti defines rather than real values in DT (where
possible) and I think there is no reason not to use real values
here.
Jonathan
quoted hunk
---
The next patch in the series removes the tsl2772 driver from the
trivial-devices.txt file. I separated it out so that change can go
through device tree.
.../devicetree/bindings/iio/light/tsl2772.txt | 39 +++++++++++++++++++
drivers/iio/light/tsl2772.c | 16 ++++++++
include/dt-bindings/iio/amstaos,tsl2772.h | 24 ++++++++++++
3 files changed, 79 insertions(+)
create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt
create mode 100644 include/dt-bindings/iio/amstaos,tsl2772.h
@@ -0,0 +1,39 @@+* AMS/TAOS ALS and proximity sensor++Required properties:++ - compatible: Should be one of+ "amstaos,tsl2571"+ "amstaos,tsl2671"+ "amstaos,tmd2671"+ "amstaos,tsl2771"+ "amstaos,tmd2771"+ "amstaos,tsl2572"+ "amstaos,tsl2672"+ "amstaos,tmd2672"+ "amstaos,tsl2772"+ "amstaos,tmd2772"+ - reg: the I2C address of the device++Optional properties:++ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or+ TSL2772_DIODE_BOTH.+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,+ or TSL2772_13_mA.+ - interrupt-parent: should be the phandle for the interrupt controller+ - interrupts: the sole interrupt generated by the device++ Refer to interrupt-controller/interrupts.txt for generic interrupt client+ node bindings.++Example:++#include <dt-bindings/iio/amstaos,tsl2772.h>++tsl2772@39 {+ compatible = "amstaos,tsl2772";+ reg = <0x39>;+ interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>;+ amstaos,prox_diode = <TSL2772_DIODE0>;+};
@@ -0,0 +1,24 @@+/* SPDX-License-Identifier: GPL-2.0+ */+/*+*Devicedriverformonitoringambientlightintensity(lux)+*andproximity(prox)withintheTAOSTSL2772familyofdevices.+*+*Copyright(c)2012TAOSCorporation.+*Copyright(c)2017-2018BrianMasney<masneyb@onstation.org>+*/++#ifndef _DT_BINDINGS_AMSTAOS_TSL2772_H+#define _DT_BINDINGS_AMSTAOS_TSL2772_H++/* Proximity diode to use */+#define TSL2772_DIODE0 0x01+#define TSL2772_DIODE1 0x02+#define TSL2772_DIODE_BOTH 0x03
Can we have two separate parameters to enable them?
+
+/* LED Power */
+#define TSL2772_100_mA 0x00
+#define TSL2772_50_mA 0x01
+#define TSL2772_25_mA 0x02
+#define TSL2772_13_mA 0x03
I'd like to see real numbers rather than defines. List the valid
values in the binding then match them to register addresses in the
driver.
A different instance of this binding for a different taos device
might have different values that are valid.
From: Jonathan Cameron <jic23@kernel.org> Date: 2018-07-21 17:37:25
On Fri, 20 Jul 2018 11:36:35 -0600
Rob Herring [off-list ref] wrote:
On Tue, Jul 17, 2018 at 04:41:54AM -0400, Brian Masney wrote:
quoted
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
---
The next patch in the series removes the tsl2772 driver from the
trivial-devices.txt file. I separated it out so that change can go
through device tree.
.../devicetree/bindings/iio/light/tsl2772.txt | 39 +++++++++++++++++++
@@ -0,0 +1,39 @@+* AMS/TAOS ALS and proximity sensor++Required properties:++ - compatible: Should be one of+ "amstaos,tsl2571"+ "amstaos,tsl2671"+ "amstaos,tmd2671"+ "amstaos,tsl2771"+ "amstaos,tmd2771"+ "amstaos,tsl2572"+ "amstaos,tsl2672"+ "amstaos,tmd2672"+ "amstaos,tsl2772"+ "amstaos,tmd2772"+ - reg: the I2C address of the device++Optional properties:++ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or+ TSL2772_DIODE_BOTH.
s/_/-/
quoted
+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,
+ or TSL2772_13_mA.
I wonder if this should be common. Perhaps we should use the existing
'led-max-microamp' as this is setting the current for an IR LED.
Seems reasonable, then perhaps have two controls to turn on the diodes
above.
And while called 'power' this setting is current.
Also can we have real values? I really don't like defines if they
aren't absolutely necessary - particularly when there is a nice real
unit to be used.
quoted
+ - interrupt-parent: should be the phandle for the interrupt controller
Don't need to document this. It's implied by interrupts (and could be in
a parent node).
quoted
+ - interrupts: the sole interrupt generated by the device
+
+ Refer to interrupt-controller/interrupts.txt for generic interrupt client
+ node bindings.
+
+Example:
+
+#include <dt-bindings/iio/amstaos,tsl2772.h>
+
+tsl2772@39 {
+ compatible = "amstaos,tsl2772";
+ reg = <0x39>;
+ interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>;
+ amstaos,prox_diode = <TSL2772_DIODE0>;
+};
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Jonathan Cameron <jic23@kernel.org> Date: 2018-07-21 17:45:55
On Tue, 17 Jul 2018 04:41:56 -0400
Brian Masney [off-list ref] wrote:
This patch adds support for the regulator framework to the tsl2772
driver. Driver was tested using a LG Nexus 5 (hammerhead) phone with
the two regulators and on a Raspberry Pi 2 without any regulators
controlling the power to the sensor.
Signed-off-by: Brian Masney <redacted>
There is an ordering issue in probe and hence the tear down. Fixing
it is unfortunately going to make the rest of the handling more complex...
Jonathan
@@ -21,6 +21,8 @@ Optional properties: TSL2772_DIODE_BOTH. - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA, or TSL2772_13_mA.+ - vdd-supply: phandle to the regulator that provides power to the sensor.+ - vddio-supply: phandle to the regulator that provides power to the bus. - interrupt-parent: should be the phandle for the interrupt controller - interrupts: the sole interrupt generated by the device
@@ -666,6 +710,10 @@ static int tsl2772_chip_on(struct iio_dev *indio_dev) chip->als_gain_time_scale = als_time_us * tsl2772_als_gain[chip->settings.als_gain];+ ret = tsl2772_enable_regulators(chip);+ if (ret < 0)+ return ret;+ /* * TSL2772 Specific power-on / adc enable sequence * Power on the device 1st.
@@ -724,10 +772,13 @@ static int tsl2772_chip_on(struct iio_dev *indio_dev) static int tsl2772_chip_off(struct iio_dev *indio_dev) { struct tsl2772_chip *chip = iio_priv(indio_dev);+ int ret; /* turn device off */ chip->tsl2772_chip_status = TSL2772_CHIP_SUSPENDED;- return tsl2772_write_control_reg(chip, 0x00);+ ret = tsl2772_write_control_reg(chip, 0x00);+ tsl2772_disable_regulators(chip);
Blank line here would be nice.
quoted hunk
+ return ret;
}
/**
@@ -1666,6 +1717,35 @@ static int tsl2772_probe(struct i2c_client *clientp, chip->client = clientp; i2c_set_clientdata(clientp, indio_dev);+ chip->vddio_supply = devm_regulator_get(&clientp->dev, "vddio");+ if (IS_ERR(chip->vddio_supply)) {+ if (PTR_ERR(chip->vddio_supply) != -EPROBE_DEFER)+ dev_err(&clientp->dev,+ "Failed to get vddio regulator %d\n",+ (int)PTR_ERR(chip->vddio_supply));++ return PTR_ERR(chip->vddio_supply);+ }++ chip->vdd_supply = devm_regulator_get(&clientp->dev, "vdd");+ if (IS_ERR(chip->vdd_supply)) {+ if (PTR_ERR(chip->vdd_supply) != -EPROBE_DEFER)+ dev_err(&clientp->dev,+ "Failed to get vdd regulator %d\n",+ (int)PTR_ERR(chip->vdd_supply));++ return PTR_ERR(chip->vdd_supply);+ }++ ret = devm_add_action(&clientp->dev, tsl2772_disable_regulators_action,+ chip);
Can't do them together. you need to think about where you might
get a failure. What if it is after the first enable but before the
second? In that case you've just left a regulator on as we haven't done this
setup yet.
+ if (ret < 0) {
+ tsl2772_disable_regulators_action(chip);
+ dev_err(&clientp->dev, "Failed to setup regulator cleanup action %d\n",
+ ret);
+ return ret;
+ }
+
ret = i2c_smbus_read_byte_data(chip->client,
TSL2772_CMD_REG | TSL2772_CHIPID);
if (ret < 0)
From: Brian Masney <hidden> Date: 2018-07-22 12:32:11
On Sat, Jul 21, 2018 at 06:31:07PM +0100, Jonathan Cameron wrote:
On Tue, 17 Jul 2018 04:41:52 -0400
Brian Masney [off-list ref] wrote:
quoted
This patch adds support for the regulator framework to the mpu6050
driver.
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
I'm not 100% sure what the purpose of the regulator_enabled
tracking is. Perhaps you could point out the path where that is
needed?
I was thinking about the use case where the device is compiled into the
kernel as a module, the device is suspended, and then someone rmmods
the module. If that is not a use case that I need to worry about, then
the flag can go away and it will simplify the code.
Brian
Also, a missing bit of documentation needs adding.
Jonathan
quoted
---
Changes since v1:
- Use devm_regulator_get() instead of devm_regulator_get_optional()
- Use devm_add_action() for cleaning up the regulator.
- Correct ordering of resume code.
- Add regulator_enabled flag to ensure regulator is not disabled twice,
specifically the case where the device is suspended and then the
driver is removed.
Original extra changelog from v1:
This is a variation of Jonathan Marek's patch from postmarketOS
https://gitlab.com/postmarketOS/linux-postmarketos/commit/b8ad1ec1859c8bbcbce94944b3f4dd68f8f9fc37
with the following changes:
- Stripped out 6515 variant code.
- Add the regulator to the mpu core instead of only the i2c variant.
- Add error handling.
- Release the regulator on suspend, device remove, etc.
- Device tree documentation.
.../bindings/iio/imu/inv_mpu6050.txt | 1 +
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 73 +++++++++++++++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 +
3 files changed, 77 insertions(+)
@@ -21,6 +21,7 @@ Required properties: bindings. Optional properties:+ - vddio-supply: regulator phandle for VDDIO supply - mount-matrix: an optional 3x3 mounting rotation matrix - i2c-gate node. These devices also support an auxiliary i2c bus. This is simple enough to be described using the i2c-gate binding. See
@@ -926,6 +927,46 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)returnresult;}+staticintinv_mpu_core_enable_regulator(structinv_mpu6050_state*st)+{+intresult;++result=regulator_enable(st->vddio_supply);+if(result){+dev_err(regmap_get_device(st->map),+"Failed to enable regulator: %d\n",result);+}else{+st->regulator_enabled=true;++/* Give the device a little bit of time to start up. */+usleep_range(35000,70000);+}++returnresult;+}++staticintinv_mpu_core_disable_regulator(structinv_mpu6050_state*st)+{+intresult;++if(!st->regulator_enabled)+return0;++result=regulator_disable(st->vddio_supply);+if(result)+dev_err(regmap_get_device(st->map),+"Failed to disable regulator: %d\n",result);++st->regulator_enabled=false;++returnresult;+}++staticvoidinv_mpu_core_disable_regulator_action(void*_data)+{+inv_mpu_core_disable_regulator(_data);+}+intinv_mpu_core_probe(structregmap*regmap,intirq,constchar*name,int(*inv_mpu_bus_setup)(structiio_dev*),intchip_type){
@@ -990,6 +1031,28 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,return-EINVAL;}+st->vddio_supply=devm_regulator_get(dev,"vddio");+if(IS_ERR(st->vddio_supply)){+if(PTR_ERR(st->vddio_supply)!=-EPROBE_DEFER)+dev_err(dev,"Failed to get vddio regulator %d\n",+(int)PTR_ERR(st->vddio_supply));++returnPTR_ERR(st->vddio_supply);+}++result=inv_mpu_core_enable_regulator(st);+if(result)+returnresult;++result=devm_add_action(dev,inv_mpu_core_disable_regulator_action,+st);+if(result){+inv_mpu_core_disable_regulator_action(st);+dev_err(dev,"Failed to setup regulator cleanup action %d\n",+result);+returnresult;+}+/* power is turned on inside check chip type*/result=inv_check_and_setup_chip(st);if(result)
@@ -1049,7 +1112,12 @@ static int inv_mpu_resume(struct device *dev)intresult;mutex_lock(&st->lock);+result=inv_mpu_core_enable_regulator(st);+if(result)+gotoout_unlock;+result=inv_mpu6050_set_power_itg(st,true);+out_unlock:mutex_unlock(&st->lock);returnresult;
@@ -1062,6 +1130,11 @@ static int inv_mpu_suspend(struct device *dev)mutex_lock(&st->lock);result=inv_mpu6050_set_power_itg(st,false);+if(result)+gotoout_unlock;++result=inv_mpu_core_disable_regulator(st);+out_unlock:mutex_unlock(&st->lock);returnresult;
From: Brian Masney <hidden> Date: 2018-07-22 12:37:24
On Sat, Jul 21, 2018 at 06:37:16PM +0100, Jonathan Cameron wrote:
On Fri, 20 Jul 2018 11:36:35 -0600
Rob Herring [off-list ref] wrote:
quoted
On Tue, Jul 17, 2018 at 04:41:54AM -0400, Brian Masney wrote:
quoted
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
---
The next patch in the series removes the tsl2772 driver from the
trivial-devices.txt file. I separated it out so that change can go
through device tree.
.../devicetree/bindings/iio/light/tsl2772.txt | 39 +++++++++++++++++++
@@ -0,0 +1,39 @@+* AMS/TAOS ALS and proximity sensor++Required properties:++ - compatible: Should be one of+ "amstaos,tsl2571"+ "amstaos,tsl2671"+ "amstaos,tmd2671"+ "amstaos,tsl2771"+ "amstaos,tmd2771"+ "amstaos,tsl2572"+ "amstaos,tsl2672"+ "amstaos,tmd2672"+ "amstaos,tsl2772"+ "amstaos,tmd2772"+ - reg: the I2C address of the device++Optional properties:++ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or+ TSL2772_DIODE_BOTH.
s/_/-/
quoted
+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,
+ or TSL2772_13_mA.
I wonder if this should be common. Perhaps we should use the existing
'led-max-microamp' as this is setting the current for an IR LED.
Seems reasonable, then perhaps have two controls to turn on the diodes
above.
quoted
And while called 'power' this setting is current.
Also can we have real values? I really don't like defines if they
aren't absolutely necessary - particularly when there is a nice real
unit to be used.
How about these options then?
amstaos,proximity-diode-0-enabled;
amstaos,proximity-diode-1-enabled;
led-max-microamp = <100000>;
Brian
From: Jonathan Cameron <jic23@kernel.org> Date: 2018-07-22 17:18:05
On Sun, 22 Jul 2018 12:37:20 +0000
Brian Masney [off-list ref] wrote:
On Sat, Jul 21, 2018 at 06:37:16PM +0100, Jonathan Cameron wrote:
quoted
On Fri, 20 Jul 2018 11:36:35 -0600
Rob Herring [off-list ref] wrote:
quoted
On Tue, Jul 17, 2018 at 04:41:54AM -0400, Brian Masney wrote:
quoted
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
---
The next patch in the series removes the tsl2772 driver from the
trivial-devices.txt file. I separated it out so that change can go
through device tree.
.../devicetree/bindings/iio/light/tsl2772.txt | 39 +++++++++++++++++++
@@ -0,0 +1,39 @@+* AMS/TAOS ALS and proximity sensor++Required properties:++ - compatible: Should be one of+ "amstaos,tsl2571"+ "amstaos,tsl2671"+ "amstaos,tmd2671"+ "amstaos,tsl2771"+ "amstaos,tmd2771"+ "amstaos,tsl2572"+ "amstaos,tsl2672"+ "amstaos,tmd2672"+ "amstaos,tsl2772"+ "amstaos,tmd2772"+ - reg: the I2C address of the device++Optional properties:++ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or+ TSL2772_DIODE_BOTH.
s/_/-/
quoted
+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,
+ or TSL2772_13_mA.
I wonder if this should be common. Perhaps we should use the existing
'led-max-microamp' as this is setting the current for an IR LED.
Seems reasonable, then perhaps have two controls to turn on the diodes
above.
quoted
And while called 'power' this setting is current.
Also can we have real values? I really don't like defines if they
aren't absolutely necessary - particularly when there is a nice real
unit to be used.
How about these options then?
amstaos,proximity-diode-0-enabled;
amstaos,proximity-diode-1-enabled;
led-max-microamp = <100000>;
From: Jonathan Cameron <jic23@kernel.org> Date: 2018-07-22 17:20:54
On Sun, 22 Jul 2018 12:31:45 +0000
Brian Masney [off-list ref] wrote:
On Sat, Jul 21, 2018 at 06:31:07PM +0100, Jonathan Cameron wrote:
quoted
On Tue, 17 Jul 2018 04:41:52 -0400
Brian Masney [off-list ref] wrote:
quoted
This patch adds support for the regulator framework to the mpu6050
driver.
Signed-off-by: Brian Masney <redacted>
Signed-off-by: Jonathan Marek <redacted>
I'm not 100% sure what the purpose of the regulator_enabled
tracking is. Perhaps you could point out the path where that is
needed?
I was thinking about the use case where the device is compiled into the
kernel as a module, the device is suspended, and then someone rmmods
the module. If that is not a use case that I need to worry about, then
the flag can go away and it will simplify the code.
I'm not sure it's a situation that can actually happen.
Before a rmmod is acted upon I think it will always be un-suspended.
This is necessary to avoid all sorts of nasty corner cases.
It's been debate in the past on whether it is necessary to come
out of runtime suspend under these sorts of circumstances but
I don't think anyone has ever tried to make suspend and remove
play nicely.
Jonathan
Brian
quoted
Also, a missing bit of documentation needs adding.
Jonathan
quoted
---
Changes since v1:
- Use devm_regulator_get() instead of devm_regulator_get_optional()
- Use devm_add_action() for cleaning up the regulator.
- Correct ordering of resume code.
- Add regulator_enabled flag to ensure regulator is not disabled twice,
specifically the case where the device is suspended and then the
driver is removed.
Original extra changelog from v1:
This is a variation of Jonathan Marek's patch from postmarketOS
https://gitlab.com/postmarketOS/linux-postmarketos/commit/b8ad1ec1859c8bbcbce94944b3f4dd68f8f9fc37
with the following changes:
- Stripped out 6515 variant code.
- Add the regulator to the mpu core instead of only the i2c variant.
- Add error handling.
- Release the regulator on suspend, device remove, etc.
- Device tree documentation.
.../bindings/iio/imu/inv_mpu6050.txt | 1 +
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 73 +++++++++++++++++++
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 3 +
3 files changed, 77 insertions(+)
@@ -21,6 +21,7 @@ Required properties: bindings. Optional properties:+ - vddio-supply: regulator phandle for VDDIO supply - mount-matrix: an optional 3x3 mounting rotation matrix - i2c-gate node. These devices also support an auxiliary i2c bus. This is simple enough to be described using the i2c-gate binding. See
@@ -926,6 +927,46 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)returnresult;}+staticintinv_mpu_core_enable_regulator(structinv_mpu6050_state*st)+{+intresult;++result=regulator_enable(st->vddio_supply);+if(result){+dev_err(regmap_get_device(st->map),+"Failed to enable regulator: %d\n",result);+}else{+st->regulator_enabled=true;++/* Give the device a little bit of time to start up. */+usleep_range(35000,70000);+}++returnresult;+}++staticintinv_mpu_core_disable_regulator(structinv_mpu6050_state*st)+{+intresult;++if(!st->regulator_enabled)+return0;++result=regulator_disable(st->vddio_supply);+if(result)+dev_err(regmap_get_device(st->map),+"Failed to disable regulator: %d\n",result);++st->regulator_enabled=false;++returnresult;+}++staticvoidinv_mpu_core_disable_regulator_action(void*_data)+{+inv_mpu_core_disable_regulator(_data);+}+intinv_mpu_core_probe(structregmap*regmap,intirq,constchar*name,int(*inv_mpu_bus_setup)(structiio_dev*),intchip_type){
@@ -990,6 +1031,28 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,return-EINVAL;}+st->vddio_supply=devm_regulator_get(dev,"vddio");+if(IS_ERR(st->vddio_supply)){+if(PTR_ERR(st->vddio_supply)!=-EPROBE_DEFER)+dev_err(dev,"Failed to get vddio regulator %d\n",+(int)PTR_ERR(st->vddio_supply));++returnPTR_ERR(st->vddio_supply);+}++result=inv_mpu_core_enable_regulator(st);+if(result)+returnresult;++result=devm_add_action(dev,inv_mpu_core_disable_regulator_action,+st);+if(result){+inv_mpu_core_disable_regulator_action(st);+dev_err(dev,"Failed to setup regulator cleanup action %d\n",+result);+returnresult;+}+/* power is turned on inside check chip type*/result=inv_check_and_setup_chip(st);if(result)
@@ -1049,7 +1112,12 @@ static int inv_mpu_resume(struct device *dev)intresult;mutex_lock(&st->lock);+result=inv_mpu_core_enable_regulator(st);+if(result)+gotoout_unlock;+result=inv_mpu6050_set_power_itg(st,true);+out_unlock:mutex_unlock(&st->lock);returnresult;
@@ -1062,6 +1130,11 @@ static int inv_mpu_suspend(struct device *dev)mutex_lock(&st->lock);result=inv_mpu6050_set_power_itg(st,false);+if(result)+gotoout_unlock;++result=inv_mpu_core_disable_regulator(st);+out_unlock:mutex_unlock(&st->lock);returnresult;
From: Rob Herring <robh@kernel.org> Date: 2018-07-23 13:29:06
On Sun, Jul 22, 2018 at 11:17 AM Jonathan Cameron [off-list ref] wrote:
On Sun, 22 Jul 2018 12:37:20 +0000
Brian Masney [off-list ref] wrote:
quoted
On Sat, Jul 21, 2018 at 06:37:16PM +0100, Jonathan Cameron wrote:
quoted
On Fri, 20 Jul 2018 11:36:35 -0600
Rob Herring [off-list ref] wrote:
quoted
On Tue, Jul 17, 2018 at 04:41:54AM -0400, Brian Masney wrote:
quoted
This patch adds support for optionally reading the prox_diode and
prox_power settings from device tree. This was tested using a LG
Nexus 5 (hammerhead) which requires a different diode than the driver
default for the IR LED.
Signed-off-by: Brian Masney <redacted>
quoted
quoted
quoted
quoted
+ - amstaos,prox_diode - must be TSL2772_DIODE0, TSL2772_DIODE1, or
+ TSL2772_DIODE_BOTH.
s/_/-/
quoted
+ - amstaos,prox_power - must be TSL2772_100_mA, TSL2772_50_mA, TSL2772_25_mA,
+ or TSL2772_13_mA.
I wonder if this should be common. Perhaps we should use the existing
'led-max-microamp' as this is setting the current for an IR LED.
Seems reasonable, then perhaps have two controls to turn on the diodes
above.
quoted
And while called 'power' this setting is current.
Also can we have real values? I really don't like defines if they
aren't absolutely necessary - particularly when there is a nice real
unit to be used.
How about these options then?
amstaos,proximity-diode-0-enabled;
amstaos,proximity-diode-1-enabled;
led-max-microamp = <100000>;
Works for me. Rob?
I think we're bikeshedding, but I'd prefer a single property though
perhaps as a list (0, 1, or <0 1>) or mask. A list would be similar to
the "led-sources" property format.
Rob
From: Rob Herring <robh@kernel.org> Date: 2018-07-25 16:01:45
On Tue, Jul 17, 2018 at 04:41:55AM -0400, Brian Masney wrote:
Remove the tsl2772 driver from trivial-devices.txt. A separate
patch added the binding information to the file
Documentation/devicetree/bindings/iio/light/tsl2772.txt.
Signed-off-by: Brian Masney <redacted>
---
Documentation/devicetree/bindings/trivial-devices.txt | 10 ----------
1 file changed, 10 deletions(-)