treewide: add support for various sensors on the LG Nexus 5 (hammerhead)
v3 cover treewide: add support for various sensors on the LG Nexus 5 (hammerhead)
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 v2:
- Updated dt property names for tsl2772: amstaos,proximity-diodes and led-max-microamp based on feedback from Jonathan Cameron and Rob Herring.
- Removed regulator_enabled flags.
- Refactored tsl2772 regulator code.
- Split out device tree bindings into separate patches.
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 (9):
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 proximity led settings from
device tree
dt-bindings: iio: tsl2772: add new bindings
iio: tsl2772: add support for regulator framework
dt-bindings: iio: tsl2772: add bindings for regulator framework
iio: tsl2772: add support for avago,apds9930
dt-bindings: iio: tsl2772: add 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 | 42 ++++ .../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 | 62 ++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 + drivers/iio/light/tsl2772.c | 194 +++++++++++++++++- 8 files changed, 403 insertions(+), 13 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt
Signature · 1 line
2.17.1
PATCH v3 1/9 iio: imu: mpu6050: add support for regulator framework
This patch adds support for the regulator framework to the mpu6050 driver.
---
Changes since v2:
- Dropped regulator_enabled value since it is not needed.
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 | 62 +++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 + 3 files changed, 65 insertions(+)
Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt +1 -0
@@ -20,6 +20,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
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +62 -0
93 lines not on this page · raw message
drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +2 -0
@@ -129,6 +129,7 @@ struct inv_mpu6050_hw {* @chip_period: chip internal period estimation (~1kHz). * @it_timestamp: timestamp from previous interrupt. * @data_timestamp: timestamp for next data sample. +* @vddio_supply voltage regulator for the chip. */ struct inv_mpu6050_state {struct mutex lock;
@@ -149,6 +150,7 @@ struct inv_mpu6050_state {s64 chip_period;s64 it_timestamp;s64 data_timestamp; +struct regulator *vddio_supply; };/*register and associated bit definition*/
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 1/9] iio: imu: mpu6050: add support for regulator framework
Quoted 6 lines · On Thu, 2 Aug 2018 20:18:52 -0400 Brian Masney <[email protected]> wrote:
This patch adds support for the regulator framework to the mpu6050 driver.
Signed-off-by Brian Masney <[email protected]>Signed-off-by Jonathan Marek <[email protected]>Acked-by Rob Herring <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 163 lines
---
Changes since v2:
- Droppedregulator_enabledvalue since it is not needed.Changes since v1:
- Usedevm_regulator_get()instead ofdevm_regulator_get_optional()
- Usedevm_add_action()for cleaning up the regulator.
- Correct ordering of resume code.
- Addregulator_enabledflag 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 | 62 +++++++++++++++++++ drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h | 2 + 3 files changed, 65 insertions(+)Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt +1
-0@@ -20,6 +20,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. Seedrivers/iio/imu/inv_mpu6050/inv_mpu_core.c +62
-0@@ -23,6 +23,7 @@#include <linux/iio/iio.h> #include <linux/acpi.h> #include <linux/platform_device.h> +#include <linux/regulator/consumer.h> #include "inv_mpu_iio.h" /* @@ -926,6 +927,39 @@ static int inv_check_and_setup_chip(struct inv_mpu6050_state *st)return result; } +static int inv_mpu_core_enable_regulator (struct inv_mpu6050_state *st) +{ +int result; + + result =regulator_enable (st->vddio_supply); +if (result) { +dev_err (regmap_get_device (st->map), +"Failed to enable regulator: %d\n" , result); + }else { +/* Give the device a little bit of time to start up. */ +usleep_range (35000 ,70000 ); + } + +return result; +} + +static int inv_mpu_core_disable_regulator (struct inv_mpu6050_state *st) +{ +int result; + + result =regulator_disable (st->vddio_supply); +if (result) +dev_err (regmap_get_device (st->map), +"Failed to disable regulator: %d\n" , result); + +return result; +} + +static void inv_mpu_core_disable_regulator_action (void *_data) +{ +inv_mpu_core_disable_regulator (_data); +} +int inv_mpu_core_probe (struct regmap *regmap,int irq,const char *name,int (*inv_mpu_bus_setup)(struct iio_dev *),int chip_type) {@@ -992,6 +1026,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)); + +return PTR_ERR (st->vddio_supply); + } + + result =inv_mpu_core_enable_regulator (st); +if (result) +return result; + + 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); +return result; + } +/* power is turned on inside check chip type*/ result =inv_check_and_setup_chip (st);if (result)@@ -1051,7 +1107,12 @@ static int inv_mpu_resume(struct device *dev)int result;mutex_lock (&st->lock); + result =inv_mpu_core_enable_regulator (st); +if (result) + goto out_unlock; + result =inv_mpu6050_set_power_itg (st, true); +out_unlock:mutex_unlock (&st->lock);return result;@@ -1064,6 +1125,7 @@ static int inv_mpu_suspend(struct device *dev)mutex_lock (&st->lock); result =inv_mpu6050_set_power_itg (st, false); +inv_mpu_core_disable_regulator (st);mutex_unlock (&st->lock);return result;drivers/iio/imu/inv_mpu6050/inv_mpu_iio.h +2
-0@@ -129,6 +129,7 @@ struct inv_mpu6050_hw {* @chip_period: chip internal period estimation (~1kHz). * @it_timestamp: timestamp from previous interrupt. * @data_timestamp: timestamp for next data sample. +* @vddio_supply voltage regulator for the chip. */ struct inv_mpu6050_state {struct mutex lock;@@ -149,6 +150,7 @@ struct inv_mpu6050_state {s64 chip_period;s64 it_timestamp;s64 data_timestamp; +struct regulator *vddio_supply; };/*register and associated bit definition*/
PATCH v3 2/9 ARM: dts: qcom: msm8974-hammerhead: add device tree bindings for mpu6515
In reply to Brian MasneyThis 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
---
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(+)
arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts +56 -0
@@ -241,6 +241,24 @@ bias-pull-up; }; }; + + i2c12_pins: i2c12 { + mux { + pins = "gpio87", "gpio88"; + function = "blsp_i2c12"; + drive-strength = <2>; + bias-disable; + }; + }; + + mpu6515_pin: mpu6515 { + irq { + pins = "gpio73"; + function = "gpio"; + bias-disable; + input-enable; + }; + }; }; sdhci@f9824900 {
@@ -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 = <&msmgpio 73 IRQ_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 {
arch/arm/boot/dts/qcom-msm8974.dtsi +11 -0
@@ -737,6 +737,17 @@ dma-names = "tx", "rx"; }; + blsp_i2c12: i2c@f9968000 { + status = "disabled"; + compatible = "qcom,i2c-qup-v2.1.1"; + reg = <0xf9968000 0x1000>; + interrupts = <0 106 IRQ_TYPE_NONE>; + clocks = <&gcc GCC_BLSP2_QUP6_I2C_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; + clock-names = "core", "iface"; + #address-cells = <1>; + #size-cells = <0>; + }; + spmi_bus: spmi@fc4cf000 { compatible = "qcom,spmi-pmic-arb"; reg-names = "core", "intr", "cnfg";
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 2/9] ARM: dts: qcom: msm8974-hammerhead: add device tree bindings for mpu6515
Quoted 8 lines · On Thu, 2 Aug 2018 20:18:53 -0400 Brian Masney <[email protected]> wrote:
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.
Quoted 8 lines
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_ratioSigned-off-by Brian Masney <[email protected]>Signed-off-by Jonathan Marek <[email protected]>
I've queued up the regulator patch for IIO but it won't make the coming merge window. There is no dependence between this and that patch, but I would assume the hardware won't work until both are present.
Jonathan
Quoted 104 lines
---
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(+)arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts +56
-0@@ -241,6 +241,24 @@ bias-pull-up; }; }; + + i2c12_pins: i2c12 { + mux { + pins = "gpio87", "gpio88"; + function = "blsp_i2c12"; + drive-strength = <2>; + bias-disable; + }; + }; + + mpu6515_pin: mpu6515 { + irq { + pins = "gpio73"; + function = "gpio"; + bias-disable; + input-enable; + }; + }; }; sdhci@f9824900 {@@ -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 = <&msmgpio 73 IRQ_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 {arch/arm/boot/dts/qcom-msm8974.dtsi +11
-0@@ -737,6 +737,17 @@ dma-names = "tx", "rx"; }; + blsp_i2c12: i2c@f9968000 { + status = "disabled"; + compatible = "qcom,i2c-qup-v2.1.1"; + reg = <0xf9968000 0x1000>; + interrupts = <0 106 IRQ_TYPE_NONE>; + clocks = <&gcc GCC_BLSP2_QUP6_I2C_APPS_CLK>, <&gcc GCC_BLSP2_AHB_CLK>; + clock-names = "core", "iface"; + #address-cells = <1>; + #size-cells = <0>; + }; + spmi_bus: spmi@fc4cf000 { compatible = "qcom,spmi-pmic-arb"; reg-names = "core", "intr", "cnfg";
PATCH v3 3/9 iio: tsl2772: add support for reading proximity led settings from device tree
In reply to Brian MasneyThis patch adds support for optionally reading the proximity led diode and current 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.
--- drivers/iio/light/tsl2772.c | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
drivers/iio/light/tsl2772.c +81 -0
@@ -107,6 +107,8 @@#define TSL2772_ALS_GAIN_TRIM_MIN 250#define TSL2772_ALS_GAIN_TRIM_MAX 4000 +#define TSL2772_MAX_PROX_LEDS 2 +/* Device family members */ enum { tsl2571,
@@ -141,6 +143,14 @@ struct tsl2772_chip_info {const struct iio_info *info; }; +static const int tsl2772_led_currents[][2 ] = { + {100000 , TSL2772_100_mA }, + {50000 , TSL2772_50_mA }, + {25000 , TSL2772_25_mA }, + {13000 , TSL2772_13_mA }, + {0 ,0 } +}; +struct tsl2772_chip {kernel_ulong_t id;struct mutex prox_mutex;
@@ -515,6 +525,75 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)return ret; } +static int tsl2772_read_prox_led_current (struct tsl2772_chip *chip) +{ +struct device_node *of_node = chip->client->dev.of_node; +int ret, tmp, i; + + ret =of_property_read_u32 (of_node,"led-max-microamp" , &tmp); +if (ret <0 ) +return ret; + +for (i =0 ; tsl2772_led_currents[i][0 ] !=0 ; i++) { +if (tmp == tsl2772_led_currents[i][0 ]) { + chip->settings.prox_power = tsl2772_led_currents[i][1 ]; +return 0 ; + } + } + +dev_err (&chip->client->dev,"Invalid value %d for led-max-microamp\n" , + tmp); + +return -EINVAL ; + +} + +static int tsl2772_read_prox_diodes (struct tsl2772_chip *chip) +{ +struct device_node *of_node = chip->client->dev.of_node; +int i, ret, num_leds, prox_diode_mask; +u32 leds[TSL2772_MAX_PROX_LEDS ]; + + ret =of_property_count_u32_elems (of_node,"amstaos,proximity-diodes" ); +if (ret <0 ) +return ret; + + num_leds = ret; +if (num_leds >TSL2772_MAX_PROX_LEDS ) + num_leds =TSL2772_MAX_PROX_LEDS ; + + ret =of_property_read_u32_array (of_node,"amstaos,proximity-diodes" , + leds, num_leds); +if (ret <0 ) { +dev_err (&chip->client->dev, +"Invalid value for amstaos,proximity-diodes: %d.\n" , + ret); +return ret; + } + + prox_diode_mask =0 ; +for (i =0 ; i < num_leds; i++) { +if (leds[i] ==0 ) + prox_diode_mask |=TSL2772_DIODE0 ; +else if (leds[i] ==1 ) + prox_diode_mask |=TSL2772_DIODE1 ; +else { +dev_err (&chip->client->dev, +"Invalid value %d in amstaos,proximity-diodes.\n" , + leds[i]); +return -EINVAL ; + } + } + +return 0 ; +} + +static void tsl2772_parse_dt (struct tsl2772_chip *chip) +{ +tsl2772_read_prox_led_current (chip); +tsl2772_read_prox_diodes (chip); +} +/** * tsl2772_defaults() - Populates the device nominal operating parameters * with those provided by a 'platform' data struct or
@@ -541,6 +620,8 @@ static void tsl2772_defaults(struct tsl2772_chip *chip)memcpy (chip->tsl2772_device_lux, tsl2772_default_lux_table_group[chip->id],TSL2772_DEFAULT_TABLE_BYTES ); + +tsl2772_parse_dt (chip); }/**
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 3/9] iio: tsl2772: add support for reading proximity led settings from device tree
Quoted 6 lines · On Thu, 2 Aug 2018 20:18:54 -0400 Brian Masney <[email protected]> wrote:
This patch adds support for optionally reading the proximity led diode and current 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 <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with them.
thanks,
Jonathan
Quoted 117 lines
--- drivers/iio/light/tsl2772.c | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)drivers/iio/light/tsl2772.c +81
-0@@ -107,6 +107,8 @@#define TSL2772_ALS_GAIN_TRIM_MIN 250#define TSL2772_ALS_GAIN_TRIM_MAX 4000 +#define TSL2772_MAX_PROX_LEDS 2 +/* Device family members */ enum { tsl2571,@@ -141,6 +143,14 @@ struct tsl2772_chip_info {const struct iio_info *info; }; +static const int tsl2772_led_currents[][2 ] = { + {100000 , TSL2772_100_mA }, + {50000 , TSL2772_50_mA }, + {25000 , TSL2772_25_mA }, + {13000 , TSL2772_13_mA }, + {0 ,0 } +}; +struct tsl2772_chip {kernel_ulong_t id;struct mutex prox_mutex;@@ -515,6 +525,75 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)return ret; } +static int tsl2772_read_prox_led_current (struct tsl2772_chip *chip) +{ +struct device_node *of_node = chip->client->dev.of_node; +int ret, tmp, i; + + ret =of_property_read_u32 (of_node,"led-max-microamp" , &tmp); +if (ret <0 ) +return ret; + +for (i =0 ; tsl2772_led_currents[i][0 ] !=0 ; i++) { +if (tmp == tsl2772_led_currents[i][0 ]) { + chip->settings.prox_power = tsl2772_led_currents[i][1 ]; +return 0 ; + } + } + +dev_err (&chip->client->dev,"Invalid value %d for led-max-microamp\n" , + tmp); + +return -EINVAL ; + +} + +static int tsl2772_read_prox_diodes (struct tsl2772_chip *chip) +{ +struct device_node *of_node = chip->client->dev.of_node; +int i, ret, num_leds, prox_diode_mask; +u32 leds[TSL2772_MAX_PROX_LEDS ]; + + ret =of_property_count_u32_elems (of_node,"amstaos,proximity-diodes" ); +if (ret <0 ) +return ret; + + num_leds = ret; +if (num_leds >TSL2772_MAX_PROX_LEDS ) + num_leds =TSL2772_MAX_PROX_LEDS ; + + ret =of_property_read_u32_array (of_node,"amstaos,proximity-diodes" , + leds, num_leds); +if (ret <0 ) { +dev_err (&chip->client->dev, +"Invalid value for amstaos,proximity-diodes: %d.\n" , + ret); +return ret; + } + + prox_diode_mask =0 ; +for (i =0 ; i < num_leds; i++) { +if (leds[i] ==0 ) + prox_diode_mask |=TSL2772_DIODE0 ; +else if (leds[i] ==1 ) + prox_diode_mask |=TSL2772_DIODE1 ; +else { +dev_err (&chip->client->dev, +"Invalid value %d in amstaos,proximity-diodes.\n" , + leds[i]); +return -EINVAL ; + } + } + +return 0 ; +} + +static void tsl2772_parse_dt (struct tsl2772_chip *chip) +{ +tsl2772_read_prox_led_current (chip); +tsl2772_read_prox_diodes (chip); +} +/** * tsl2772_defaults() - Populates the device nominal operating parameters * with those provided by a 'platform' data struct or @@ -541,6 +620,8 @@ static void tsl2772_defaults(struct tsl2772_chip *chip)memcpy (chip->tsl2772_device_lux, tsl2772_default_lux_table_group[chip->id],TSL2772_DEFAULT_TABLE_BYTES ); + +tsl2772_parse_dt (chip); }/**
PATCH v3 4/9 dt-bindings: iio: tsl2772: add new bindings
In reply to Brian MasneyThis patch adds the new properties amstaos,proximity-diodes and led-max-microamp to the tsl2772 driver. This patch also removes the driver from the trivial-devices.txt.
---
I got a Reviewed-by: Rob Herring <[email protected]> on my last series but didn't include it due to the new file tsl2772.txt in this patch. Device tree bindings need to be complete.
.../devicetree/bindings/iio/light/tsl2772.txt | 37 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.txt | 10 ----- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt
Documentation/devicetree/bindings/iio/light/tsl2772.txt new file +37 -0
@@ -0,0 +1,37 @@ +* 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,proximity-diodes - proximity diodes to enable. <0>, <1>, or <0 1> + are the only valid values. + - led-max-microamp - current for the proximity LED. Must be 100000, 50000, + 25000, or 13000. + - interrupts: the sole interrupt generated by the device + + Refer to interrupt-controller/interrupts.txt for generic interrupt client + node bindings. + +Example: + +tsl2772@39 { + compatible = "amstaos,tsl2772"; + reg = <0x39>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + amstaos,proximity-diodes = <0>; + led-max-microamp = <100000>; +};
Documentation/devicetree/bindings/trivial-devices.txt +0 -10
@@ -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
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 4/9] dt-bindings: iio: tsl2772: add new bindings
Quoted 6 lines · On Thu, 2 Aug 2018 20:18:55 -0400 Brian Masney <[email protected]> wrote:
This patch adds the new properties amstaos,proximity-diodes and led-max-microamp to the tsl2772 driver. This patch also removes the driver from the trivial-devices.txt.
Signed-off-by Brian Masney <[email protected]>---
This and the implementation look fine to me, but I'll leave them for now to give Rob time to take a look if he wants to.
Thanks,
Jonathan
Quoted 73 lines
I got a Reviewed-by: Rob Herring <[email protected]> on my last series but didn't include it due to the new file tsl2772.txt in this patch. Device tree bindings need to be complete.
.../devicetree/bindings/iio/light/tsl2772.txt | 37 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.txt | 10 ----- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txtDocumentation/devicetree/bindings/iio/light/tsl2772.txt new file +37
-0@@ -0,0 +1,37 @@ +* 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,proximity-diodes - proximity diodes to enable. <0>, <1>, or <0 1> + are the only valid values. + - led-max-microamp - current for the proximity LED. Must be 100000, 50000, + 25000, or 13000. + - interrupts: the sole interrupt generated by the device + + Refer to interrupt-controller/interrupts.txt for generic interrupt client + node bindings. + +Example: + +tsl2772@39 { + compatible = "amstaos,tsl2772"; + reg = <0x39>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + amstaos,proximity-diodes = <0>; + led-max-microamp = <100000>; +};Documentation/devicetree/bindings/trivial-devices.txt +0
-10@@ -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
Re: [PATCH v3 4/9] dt-bindings: iio: tsl2772: add new bindings
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 2 Aug 2018 20:18:55 -0400 Brian Masney <[email protected]> wrote:
This patch adds the new properties amstaos,proximity-diodes and led-max-microamp to the tsl2772 driver. This patch also removes the driver from the trivial-devices.txt.
Quoted 17 lines
Quoted 2 lines
Signed-off-by Brian Masney <[email protected]>---
This and the implementation look fine to me, but I'll leave them for now to give Rob time to take a look if he wants to.
Thanks,
Jonathan
Quoted 8 lines
I got a Reviewed-by: Rob Herring <[email protected]> on my last series but didn't include it due to the new file tsl2772.txt in this patch. Device tree bindings need to be complete.
.../devicetree/bindings/iio/light/tsl2772.txt | 37 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.txt | 10 ----- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt
Jonathan Cameron
maintainerRe: [PATCH v3 4/9] dt-bindings: iio: tsl2772: add new bindings
Quoted 21 lines · On Tue, 7 Aug 2018 10:54:26 -0600 Rob Herring <[email protected]> wrote:
Quoted 20 lines · Jonathan Cameron
Quoted 6 lines · On Thu, 2 Aug 2018 20:18:55 -0400 Brian Masney <[email protected]> wrote:
This patch adds the new properties amstaos,proximity-diodes and led-max-microamp to the tsl2772 driver. This patch also removes the driver from the trivial-devices.txt.
Signed-off-by Brian Masney <[email protected]>---
This and the implementation look fine to me, but I'll leave them for now to give Rob time to take a look if he wants to.
Thanks,
Jonathan
Quoted 4 lines
I got a Reviewed-by: Rob Herring <[email protected]> on my last series but didn't include it due to the new file tsl2772.txt in this patch. Device tree bindings need to be complete.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
.../devicetree/bindings/iio/light/tsl2772.txt | 37 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.txt | 10 ----- 2 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txtReviewed-by Rob Herring <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to ignore it.
I'll apply the other dt bits to this as fixups.
Jonathan
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 5/9 iio: tsl2772: add support for regulator framework
In reply to Brian MasneyThis 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.
--- drivers/iio/light/tsl2772.c | 95 ++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-)
drivers/iio/light/tsl2772.c +94 -1
@@ -20,6 +20,7 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/platform_data/tsl2772.h> +#include <linux/regulator/consumer.h> /* Cal defs */ #define PROX_STAT_CAL 0
@@ -109,6 +110,9 @@#define TSL2772_MAX_PROX_LEDS 2 +#define TSL2772_BOOT_MIN_SLEEP_TIME 10000 +#define TSL2772_BOOT_MAX_SLEEP_TIME 28000 +/* Device family members */ enum { tsl2571,
@@ -156,6 +160,8 @@ struct tsl2772_chip {struct mutex prox_mutex;struct mutex als_mutex;struct i2c_client *client; +struct regulator *vdd_supply; +struct regulator *vddio_supply;u16 prox_data;struct tsl2772_als_info als_cur_info;struct tsl2772_settings settings;
@@ -676,6 +682,52 @@ static int tsl2772_als_calibrate(struct iio_dev *indio_dev)return ret; } +static void tsl2772_disable_regulators_action (void *_data) +{ +struct tsl2772_chip *chip = _data; + +regulator_disable (chip->vdd_supply); +regulator_disable (chip->vddio_supply); +} + +static int tsl2772_enable_regulator (struct tsl2772_chip *chip, +struct regulator *regulator) +{ +int ret; + + ret =regulator_enable (regulator); +if (ret <0 ) { +dev_err (&chip->client->dev,"Failed to enable regulator: %d\n" , + ret); +return ret; + } + +return 0 ; +} + +static struct regulator *tsl2772_get_regulator (struct tsl2772_chip *chip, +char *name) +{ +struct regulator *regulator; +int ret; + + regulator =devm_regulator_get (&chip->client->dev, name); +if (IS_ERR (regulator)) { +if (PTR_ERR (regulator) != -EPROBE_DEFER ) +dev_err (&chip->client->dev, +"Failed to get %s regulator %d\n" , + name, (int )PTR_ERR (regulator)); + +return regulator; + } + + ret =tsl2772_enable_regulator (chip, regulator); +if (ret <0 ) +return ERR_PTR (ret); + +return regulator; +} +static int tsl2772_chip_on (struct iio_dev *indio_dev) {struct tsl2772_chip *chip =iio_priv (indio_dev);
@@ -1733,6 +1785,27 @@ static int tsl2772_probe(struct i2c_client *clientp, chip->client = clientp;i2c_set_clientdata (clientp, indio_dev); + chip->vddio_supply =tsl2772_get_regulator (chip,"vddio" ); +if (IS_ERR (chip->vddio_supply)) +return PTR_ERR (chip->vddio_supply); + + chip->vdd_supply =tsl2772_get_regulator (chip,"vdd" ); +if (IS_ERR (chip->vdd_supply)) { +regulator_disable (chip->vddio_supply); +return PTR_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); +return ret; + } + +usleep_range (TSL2772_BOOT_MIN_SLEEP_TIME ,TSL2772_BOOT_MAX_SLEEP_TIME ); + ret =i2c_smbus_read_byte_data (chip->client,TSL2772_CMD_REG |TSL2772_CHIPID );if (ret <0 )
@@ -1806,13 +1879,33 @@ static int tsl2772_probe(struct i2c_client *clientp,static int tsl2772_suspend (struct device *dev) {struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct tsl2772_chip *chip =iio_priv (indio_dev); +int ret; -return tsl2772_chip_off (indio_dev); + ret =tsl2772_chip_off (indio_dev); +regulator_disable (chip->vdd_supply); +regulator_disable (chip->vddio_supply); + +return ret; }static int tsl2772_resume (struct device *dev) {struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct tsl2772_chip *chip =iio_priv (indio_dev); +int ret; + + ret =tsl2772_enable_regulator (chip, chip->vddio_supply); +if (ret <0 ) +return ret; + + ret =tsl2772_enable_regulator (chip, chip->vdd_supply); +if (ret <0 ) { +regulator_disable (chip->vddio_supply); +return ret; + } + +usleep_range (TSL2772_BOOT_MIN_SLEEP_TIME ,TSL2772_BOOT_MAX_SLEEP_TIME );return tsl2772_chip_on (indio_dev); }
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 5/9] iio: tsl2772: add support for regulator framework
Quoted 6 lines · On Thu, 2 Aug 2018 20:18:56 -0400 Brian Masney <[email protected]> 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 <[email protected]>
This looks fine, but will wait for the precursors.
Jonathan
Quoted 151 lines
--- drivers/iio/light/tsl2772.c | 95 ++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-)drivers/iio/light/tsl2772.c +94
-1@@ -20,6 +20,7 @@#include <linux/iio/iio.h> #include <linux/iio/sysfs.h> #include <linux/platform_data/tsl2772.h> +#include <linux/regulator/consumer.h> /* Cal defs */ #define PROX_STAT_CAL 0@@ -109,6 +110,9 @@#define TSL2772_MAX_PROX_LEDS 2 +#define TSL2772_BOOT_MIN_SLEEP_TIME 10000 +#define TSL2772_BOOT_MAX_SLEEP_TIME 28000 +/* Device family members */ enum { tsl2571,@@ -156,6 +160,8 @@ struct tsl2772_chip {struct mutex prox_mutex;struct mutex als_mutex;struct i2c_client *client; +struct regulator *vdd_supply; +struct regulator *vddio_supply;u16 prox_data;struct tsl2772_als_info als_cur_info;struct tsl2772_settings settings;@@ -676,6 +682,52 @@ static int tsl2772_als_calibrate(struct iio_dev *indio_dev)return ret; } +static void tsl2772_disable_regulators_action (void *_data) +{ +struct tsl2772_chip *chip = _data; + +regulator_disable (chip->vdd_supply); +regulator_disable (chip->vddio_supply); +} + +static int tsl2772_enable_regulator (struct tsl2772_chip *chip, +struct regulator *regulator) +{ +int ret; + + ret =regulator_enable (regulator); +if (ret <0 ) { +dev_err (&chip->client->dev,"Failed to enable regulator: %d\n" , + ret); +return ret; + } + +return 0 ; +} + +static struct regulator *tsl2772_get_regulator (struct tsl2772_chip *chip, +char *name) +{ +struct regulator *regulator; +int ret; + + regulator =devm_regulator_get (&chip->client->dev, name); +if (IS_ERR (regulator)) { +if (PTR_ERR (regulator) != -EPROBE_DEFER ) +dev_err (&chip->client->dev, +"Failed to get %s regulator %d\n" , + name, (int )PTR_ERR (regulator)); + +return regulator; + } + + ret =tsl2772_enable_regulator (chip, regulator); +if (ret <0 ) +return ERR_PTR (ret); + +return regulator; +} +static int tsl2772_chip_on (struct iio_dev *indio_dev) {struct tsl2772_chip *chip =iio_priv (indio_dev);@@ -1733,6 +1785,27 @@ static int tsl2772_probe(struct i2c_client *clientp, chip->client = clientp;i2c_set_clientdata (clientp, indio_dev); + chip->vddio_supply =tsl2772_get_regulator (chip,"vddio" ); +if (IS_ERR (chip->vddio_supply)) +return PTR_ERR (chip->vddio_supply); + + chip->vdd_supply =tsl2772_get_regulator (chip,"vdd" ); +if (IS_ERR (chip->vdd_supply)) { +regulator_disable (chip->vddio_supply); +return PTR_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); +return ret; + } + +usleep_range (TSL2772_BOOT_MIN_SLEEP_TIME ,TSL2772_BOOT_MAX_SLEEP_TIME ); + ret =i2c_smbus_read_byte_data (chip->client,TSL2772_CMD_REG |TSL2772_CHIPID );if (ret <0 )@@ -1806,13 +1879,33 @@ static int tsl2772_probe(struct i2c_client *clientp,static int tsl2772_suspend (struct device *dev) {struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct tsl2772_chip *chip =iio_priv (indio_dev); +int ret; -return tsl2772_chip_off (indio_dev); + ret =tsl2772_chip_off (indio_dev); +regulator_disable (chip->vdd_supply); +regulator_disable (chip->vddio_supply); + +return ret; }static int tsl2772_resume (struct device *dev) {struct iio_dev *indio_dev =dev_get_drvdata (dev); +struct tsl2772_chip *chip =iio_priv (indio_dev); +int ret; + + ret =tsl2772_enable_regulator (chip, chip->vddio_supply); +if (ret <0 ) +return ret; + + ret =tsl2772_enable_regulator (chip, chip->vdd_supply); +if (ret <0 ) { +regulator_disable (chip->vddio_supply); +return ret; + } + +usleep_range (TSL2772_BOOT_MIN_SLEEP_TIME ,TSL2772_BOOT_MAX_SLEEP_TIME );return tsl2772_chip_on (indio_dev); }
PATCH v3 6/9 dt-bindings: iio: tsl2772: add bindings for regulator framework
In reply to Brian MasneyThis patch adds device tree bindings to the tsl2772 driver for the regulator framework.
--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/iio/light/tsl2772.txt +4 -0
@@ -21,6 +21,8 @@ Optional properties: are the only valid values. - led-max-microamp - current for the proximity LED. Must be 100000, 50000, 25000, or 13000. + - vdd-supply: phandle to the regulator that provides power to the sensor. + - vddio-supply: phandle to the regulator that provides power to the bus. - interrupts: the sole interrupt generated by the device Refer to interrupt-controller/interrupts.txt for generic interrupt client
@@ -32,6 +34,8 @@ tsl2772@39 { compatible = "amstaos,tsl2772"; reg = <0x39>; interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; amstaos,proximity-diodes = <0>; led-max-microamp = <100000>; };
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 6/9] dt-bindings: iio: tsl2772: add bindings for regulator framework
Quoted 4 lines · On Thu, 2 Aug 2018 20:18:57 -0400 Brian Masney <[email protected]> wrote:
This patch adds device tree bindings to the tsl2772 driver for the regulator framework.
Signed-off-by Brian Masney <[email protected]>
I suspect Rob will tell you this should really have been in the same
patch as the earlier bindings. There is no need for us to wait
for the driver support as the binding describes what is there, not what we do with it.
Otherwise it's fine and if nothing else comes up I can merge them ;)
Jonathan
Quoted 26 lines
--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/iio/light/tsl2772.txt +4
-0@@ -21,6 +21,8 @@ Optional properties: are the only valid values. - led-max-microamp - current for the proximity LED. Must be 100000, 50000, 25000, or 13000. + - vdd-supply: phandle to the regulator that provides power to the sensor. + - vddio-supply: phandle to the regulator that provides power to the bus. - interrupts: the sole interrupt generated by the device Refer to interrupt-controller/interrupts.txt for generic interrupt client@@ -32,6 +34,8 @@ tsl2772@39 { compatible = "amstaos,tsl2772"; reg = <0x39>; interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; amstaos,proximity-diodes = <0>; led-max-microamp = <100000>; };
Rob Herring
maintainerRe: [PATCH v3 6/9] dt-bindings: iio: tsl2772: add bindings for regulator framework
Quoted 11 lines · Jonathan Cameron
Quoted 4 lines · On Thu, 2 Aug 2018 20:18:57 -0400 Brian Masney <[email protected]> wrote:
This patch adds device tree bindings to the tsl2772 driver for the regulator framework.
Signed-off-by Brian Masney <[email protected]>I suspect Rob will tell you this should really have been in the same
patch as the earlier bindings. There is no need for us to wait
for the driver support as the binding describes what is there, not what we do with it.
Yep.
Quoted 32 lines
Otherwise it's fine and if nothing else comes up I can merge them ;)
Jonathan
Quoted 26 lines
--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/iio/light/tsl2772.txt +4
-0@@ -21,6 +21,8 @@ Optional properties: are the only valid values. - led-max-microamp - current for the proximity LED. Must be 100000, 50000, 25000, or 13000. + - vdd-supply: phandle to the regulator that provides power to the sensor. + - vddio-supply: phandle to the regulator that provides power to the bus. - interrupts: the sole interrupt generated by the device Refer to interrupt-controller/interrupts.txt for generic interrupt client@@ -32,6 +34,8 @@ tsl2772@39 { compatible = "amstaos,tsl2772"; reg = <0x39>; interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; amstaos,proximity-diodes = <0>; led-max-microamp = <100000>; };
Jonathan Cameron
maintainerRe: [PATCH v3 6/9] dt-bindings: iio: tsl2772: add bindings for regulator framework
Quoted 7 lines · On Tue, 7 Aug 2018 11:20:28 -0600 Rob Herring <[email protected]> wrote:
Quoted 6 lines · Jonathan Cameron
Quoted 3 lines · On Thu, 2 Aug 2018 20:18:57 -0400 Brian Masney <[email protected]> wrote:
This patch adds device tree bindings to the tsl2772 driver for the regulator framework.
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
Signed-off-by Brian Masney <[email protected]>I suspect Rob will tell you this should really have been in the same
patch as the earlier bindings. There is no need for us to wait
for the driver support as the binding describes what is there, not what we do with it.Yep.
Quoted 2 lines
Otherwise it's fine and if nothing else comes up I can merge them ;)
I merged them.
Jonathan
Quoted 30 lines
Quoted 30 lines
Jonathan
Quoted 26 lines
--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 4 ++++ 1 file changed, 4 insertions(+)Documentation/devicetree/bindings/iio/light/tsl2772.txt +4
-0@@ -21,6 +21,8 @@ Optional properties: are the only valid values. - led-max-microamp - current for the proximity LED. Must be 100000, 50000, 25000, or 13000. + - vdd-supply: phandle to the regulator that provides power to the sensor. + - vddio-supply: phandle to the regulator that provides power to the bus. - interrupts: the sole interrupt generated by the device Refer to interrupt-controller/interrupts.txt for generic interrupt client@@ -32,6 +34,8 @@ tsl2772@39 { compatible = "amstaos,tsl2772"; reg = <0x39>; interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; amstaos,proximity-diodes = <0>; led-max-microamp = <100000>; };
PATCH v3 7/9 iio: tsl2772: add support for avago,apds9930
In reply to Brian MasneyThe Avago APDS9930 has the same register set as the TAOS/AMS TSL2772 so this patch adds the correct bindings and the appropriate LUX table values derived from 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
--- drivers/iio/light/tsl2772.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/iio/light/tsl2772.c +16 -2
@@ -124,7 +124,8 @@ enum { tsl2672, tmd2672, tsl2772, - tmd2772 + tmd2772, + apds9930, }; enum {
@@ -213,6 +214,12 @@ static const struct tsl2772_lux tmd2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { { 0, 0 }, }; +static const struct tsl2772_lux apds9930_lux_table[TSL2772_DEF_LUX_TABLE_SZ ] = { + {52000 ,96824 }, + {38792 ,67132 }, + {0 ,0 }, +}; +static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { [tsl2571] = tsl2x71_lux_table, [tsl2671] = tsl2x71_lux_table,
@@ -224,6 +231,7 @@ static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { [tmd2672] = tmd2x72_lux_table, [tsl2772] = tsl2x72_lux_table, [tmd2772] = tmd2x72_lux_table, + [apds9930] = apds9930_lux_table, };static const struct tsl2772_settings tsl2772_default_settings = {
@@ -274,6 +282,7 @@ static const int tsl2772_int_time_avail[][6] = { [tmd2672] = { 0, 2730, 0, 2730, 0, 699000 }, [tsl2772] = { 0, 2730, 0, 2730, 0, 699000 }, [tmd2772] = { 0, 2730, 0, 2730, 0, 699000 }, + [apds9930] = { 0, 2730, 0, 2730, 0, 699000 }, };static int tsl2772_int_calibscale_avail[] = {1 ,8 ,16 ,120 };
@@ -299,7 +308,8 @@ static const u8 device_channel_config[] = { [tsl2672] = PRX2, [tmd2672] = PRX2, [tsl2772] = ALSPRX2, - [tmd2772] = ALSPRX2 + [tmd2772] = ALSPRX2, + [apds9930] = ALSPRX2, };static int tsl2772_read_status (struct tsl2772_chip *chip)
@@ -513,6 +523,7 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)case tmd2672:case tsl2772:case tmd2772: +case apds9930:if (!(ret &TSL2772_STA_PRX_VALID )) { ret = -EINVAL ; goto prox_poll_err;
@@ -1393,6 +1404,7 @@ static int tsl2772_device_id_verif(int id, int target)case tmd2672:case tsl2772:case tmd2772: +case apds9930:return (id &0xf0 ) ==SWORDFISH_ID ; }
@@ -1932,6 +1944,7 @@ static const struct i2c_device_id tsl2772_idtable[] = { { "tmd2672", tmd2672 }, { "tsl2772", tsl2772 }, { "tmd2772", tmd2772 }, + { "apds9930", apds9930}, {} };
@@ -1948,6 +1961,7 @@ static const struct of_device_id tsl2772_of_match[] = { { .compatible = "amstaos,tmd2672" }, { .compatible = "amstaos,tsl2772" }, { .compatible = "amstaos,tmd2772" }, + { .compatible = "avago,apds9930" }, {} };MODULE_DEVICE_TABLE (of, tsl2772_of_match);
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 7/9] iio: tsl2772: add support for avago,apds9930
Quoted 5 lines · On Thu, 2 Aug 2018 20:18:58 -0400 Brian Masney <[email protected]> wrote:
The Avago APDS9930 has the same register set as the TAOS/AMS TSL2772 so this patch adds the correct bindings and the appropriate LUX table values derived from the values in the datasheet. Driver was tested on a LG Nexus 5 (hammerhead) phone.
Quoted 7 lines
avago,apds9930 datasheet:
https://www.mouser.com/datasheet/2/678/avago_AV02-3190EN_DS_APDS-9930_2014-03-25[1]-1217273.pdftsl2772 datasheet:
https://ams.com/eng/content/download/291503/1066377/file/TSL2772_DS000181_2-00.pdfSigned-off-by Brian Masney <[email protected]>
Glad you noticed they were the same. will apply once precursors are in.
Thanks,
Jonathan
Quoted 89 lines
--- drivers/iio/light/tsl2772.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/iio/light/tsl2772.c +16
-2@@ -124,7 +124,8 @@ enum { tsl2672, tmd2672, tsl2772, - tmd2772 + tmd2772, + apds9930, }; enum {@@ -213,6 +214,12 @@ static const struct tsl2772_lux tmd2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { { 0, 0 }, }; +static const struct tsl2772_lux apds9930_lux_table[TSL2772_DEF_LUX_TABLE_SZ ] = { + {52000 ,96824 }, + {38792 ,67132 }, + {0 ,0 }, +}; +static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { [tsl2571] = tsl2x71_lux_table, [tsl2671] = tsl2x71_lux_table,@@ -224,6 +231,7 @@ static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { [tmd2672] = tmd2x72_lux_table, [tsl2772] = tsl2x72_lux_table, [tmd2772] = tmd2x72_lux_table, + [apds9930] = apds9930_lux_table, };static const struct tsl2772_settings tsl2772_default_settings = {@@ -274,6 +282,7 @@ static const int tsl2772_int_time_avail[][6] = { [tmd2672] = { 0, 2730, 0, 2730, 0, 699000 }, [tsl2772] = { 0, 2730, 0, 2730, 0, 699000 }, [tmd2772] = { 0, 2730, 0, 2730, 0, 699000 }, + [apds9930] = { 0, 2730, 0, 2730, 0, 699000 }, };static int tsl2772_int_calibscale_avail[] = {1 ,8 ,16 ,120 };@@ -299,7 +308,8 @@ static const u8 device_channel_config[] = { [tsl2672] = PRX2, [tmd2672] = PRX2, [tsl2772] = ALSPRX2, - [tmd2772] = ALSPRX2 + [tmd2772] = ALSPRX2, + [apds9930] = ALSPRX2, };static int tsl2772_read_status (struct tsl2772_chip *chip)@@ -513,6 +523,7 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)case tmd2672:case tsl2772:case tmd2772: +case apds9930:if (!(ret &TSL2772_STA_PRX_VALID )) { ret = -EINVAL ; goto prox_poll_err;@@ -1393,6 +1404,7 @@ static int tsl2772_device_id_verif(int id, int target)case tmd2672:case tsl2772:case tmd2772: +case apds9930:return (id &0xf0 ) ==SWORDFISH_ID ; }@@ -1932,6 +1944,7 @@ static const struct i2c_device_id tsl2772_idtable[] = { { "tmd2672", tmd2672 }, { "tsl2772", tsl2772 }, { "tmd2772", tmd2772 }, + { "apds9930", apds9930}, {} };@@ -1948,6 +1961,7 @@ static const struct of_device_id tsl2772_of_match[] = { { .compatible = "amstaos,tmd2672" }, { .compatible = "amstaos,tsl2772" }, { .compatible = "amstaos,tmd2772" }, + { .compatible = "avago,apds9930" }, {} };MODULE_DEVICE_TABLE (of, tsl2772_of_match);
Re: [PATCH v3 7/9] iio: tsl2772: add support for avago,apds9930
Quoted 8 lines · On Fri, 3 Aug 2018 22:53:36 +0100 Jonathan Cameron <[email protected]> wrote:
Quoted 5 lines · On Thu, 2 Aug 2018 20:18:58 -0400 Brian Masney <[email protected]> wrote:
The Avago APDS9930 has the same register set as the TAOS/AMS TSL2772 so this patch adds the correct bindings and the appropriate LUX table values derived from the values in the datasheet. Driver was tested on a LG Nexus 5 (hammerhead) phone.
Quoted 9 lines
Quoted 7 lines
avago,apds9930 datasheet:
https://www.mouser.com/datasheet/2/678/avago_AV02-3190EN_DS_APDS-9930_2014-03-25[1]-1217273.pdftsl2772 datasheet:
https://ams.com/eng/content/download/291503/1066377/file/TSL2772_DS000181_2-00.pdfSigned-off-by Brian Masney <[email protected]>Glad you noticed they were the same. will apply once precursors are in.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 98 lines
Thanks,
Jonathan
Quoted 82 lines
--- drivers/iio/light/tsl2772.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/iio/light/tsl2772.c +15
-2@@ -124,7 +124,8 @@ enum { tsl2672, tmd2672, tsl2772, - tmd2772 + tmd2772, + apds9930, }; enum {@@ -213,6 +214,12 @@ static const struct tsl2772_lux tmd2x72_lux_table[TSL2772_DEF_LUX_TABLE_SZ] = { { 0, 0 }, }; +static const struct tsl2772_lux apds9930_lux_table[TSL2772_DEF_LUX_TABLE_SZ ] = { + {52000 ,96824 }, + {38792 ,67132 }, + {0 ,0 }, +}; +static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { [tsl2571] = tsl2x71_lux_table, [tsl2671] = tsl2x71_lux_table,@@ -224,6 +231,7 @@ static const struct tsl2772_lux *tsl2772_default_lux_table_group[] = { [tmd2672] = tmd2x72_lux_table, [tsl2772] = tsl2x72_lux_table, [tmd2772] = tmd2x72_lux_table, + [apds9930] = apds9930_lux_table, };static const struct tsl2772_settings tsl2772_default_settings = {@@ -274,6 +282,7 @@ static const int tsl2772_int_time_avail[][6] = { [tmd2672] = { 0, 2730, 0, 2730, 0, 699000 }, [tsl2772] = { 0, 2730, 0, 2730, 0, 699000 }, [tmd2772] = { 0, 2730, 0, 2730, 0, 699000 }, + [apds9930] = { 0, 2730, 0, 2730, 0, 699000 }, };static int tsl2772_int_calibscale_avail[] = {1 ,8 ,16 ,120 };@@ -299,7 +308,8 @@ static const u8 device_channel_config[] = { [tsl2672] = PRX2, [tmd2672] = PRX2, [tsl2772] = ALSPRX2, - [tmd2772] = ALSPRX2 + [tmd2772] = ALSPRX2, + [apds9930] = ALSPRX2, };static int tsl2772_read_status (struct tsl2772_chip *chip)@@ -513,6 +523,7 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)case tmd2672:case tsl2772:case tmd2772: +case apds9930:if (!(ret &TSL2772_STA_PRX_VALID )) { ret = -EINVAL ; goto prox_poll_err;@@ -1393,6 +1404,7 @@ static int tsl2772_device_id_verif(int id, int target)case tmd2672:case tsl2772:case tmd2772: +case apds9930:return (id &0xf0 ) ==SWORDFISH_ID ; }@@ -1932,6 +1944,7 @@ static const struct i2c_device_id tsl2772_idtable[] = { { "tmd2672", tmd2672 }, { "tsl2772", tsl2772 }, { "tmd2772", tmd2772 }, + { "apds9930", apds9930}, {} };drivers/iio/light/tsl2772.c static const struct of_device_id tsl2772_of_match[] = { · line 1967
Quoted 7 lines
drivers/iio/light/tsl2772.c +1
-0@@ -1948,6 +1961,7 @@ static const struct of_device_id tsl2772_of_match[] = { { .compatible = "amstaos,tmd2672" }, { .compatible = "amstaos,tsl2772" }, { .compatible = "amstaos,tmd2772" }, + { .compatible = "avago,apds9930" }, {} };MODULE_DEVICE_TABLE (of, tsl2772_of_match);--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v3 8/9 dt-bindings: iio: tsl2772: add binding for avago,apds9930
In reply to Brian MasneyThis patch adds avago,apds9930 to the tsl2772 bindings.
--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/iio/light/tsl2772.txt +1 -0
@@ -13,6 +13,7 @@ Required properties: "amstaos,tmd2672" "amstaos,tsl2772" "amstaos,tmd2772" + "avago,apds9930" - reg: the I2C address of the device Optional properties:
Signature · 1 line
2.17.1
Jonathan Cameron
maintainerRe: [PATCH v3 8/9] dt-bindings: iio: tsl2772: add binding for avago,apds9930
Quoted 3 lines · On Thu, 2 Aug 2018 20:18:59 -0400 Brian Masney <[email protected]> wrote:
This patch adds avago,apds9930 to the tsl2772 bindings.
Signed-off-by Brian Masney <[email protected]>
As before I'll pick up with the rest.
Thanks,
Jonathan
Quoted 16 lines
--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 1 + 1 file changed, 1 insertion(+)Documentation/devicetree/bindings/iio/light/tsl2772.txt +1
-0@@ -13,6 +13,7 @@ Required properties: "amstaos,tmd2672" "amstaos,tsl2772" "amstaos,tmd2772" + "avago,apds9930" - reg: the I2C address of the device Optional properties:
Re: [PATCH v3 8/9] dt-bindings: iio: tsl2772: add binding for avago,apds9930
In reply to Brian MasneyQuoted 6 lines · Brian Masney
This patch adds avago,apds9930 to the tsl2772 bindings.
Signed-off-by Brian Masney <[email protected]>--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 1 + 1 file changed, 1 insertion(+)
Re: [PATCH v3 8/9] dt-bindings: iio: tsl2772: add binding for avago,apds9930
Quoted 9 lines · On Tue, 7 Aug 2018 11:21:01 -0600 Rob Herring <[email protected]> wrote:
Quoted 6 lines · Brian Masney
This patch adds avago,apds9930 to the tsl2772 bindings.
Signed-off-by Brian Masney <[email protected]>--- Documentation/devicetree/bindings/iio/light/tsl2772.txt | 1 + 1 file changed, 1 insertion(+)Reviewed-by Rob Herring <[email protected]>
Applied. Thanks
PATCH v3 9/9 ARM: dts: qcom: msm8974-hammerhead: add device tree bindings for ALS / proximity
In reply to Brian MasneyThis patch adds device tree bindings for the tsl2772 ALS / proximity sensor for the LG Nexus 5 (hammerhead) phone.
--- .../qcom-msm8974-lge-nexus5-hammerhead.dts | 27 +++++++++++++++++++ arch/arm/boot/dts/qcom-msm8974.dtsi | 11 ++++++++ 2 files changed, 38 insertions(+)
arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts +27 -0
@@ -242,6 +242,15 @@ }; }; + i2c3_pins: i2c3 { + mux { + pins = "gpio10", "gpio11"; + function = "blsp_i2c3"; + drive-strength = <2>; + bias-disable; + }; + }; + i2c12_pins: i2c12 { mux { pins = "gpio87", "gpio88";
@@ -333,6 +342,24 @@ }; }; }; + + i2c@f9925000 { + status = "ok"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c3_pins>; + clock-frequency = <100000>; + qcom,src-freq = <50000000>; + + avago_apds993@39 { + compatible = "avago,apds9930"; + reg = <0x39>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; + led-max-microamp = <100000>; + amstaos,proximity-diodes = <0>; + }; + }; }; &spmi_bus {
arch/arm/boot/dts/qcom-msm8974.dtsi +11 -0
@@ -713,6 +713,17 @@ #size-cells = <0>; }; + blsp_i2c3: i2c@f9925000 { + status = "disabled"; + compatible = "qcom,i2c-qup-v2.1.1"; + reg = <0xf9925000 0x1000>; + interrupts = <0 97 IRQ_TYPE_NONE>; + clocks = <&gcc GCC_BLSP1_QUP3_I2C_APPS_CLK>, <&gcc GCC_BLSP1_AHB_CLK>; + clock-names = "core", "iface"; + #address-cells = <1>; + #size-cells = <0>; + }; + blsp_i2c8: i2c@f9964000 { status = "disabled"; compatible = "qcom,i2c-qup-v2.1.1";
Signature · 1 line
2.17.1
Re: [PATCH v3 9/9] ARM: dts: qcom: msm8974-hammerhead: add device tree bindings for ALS / proximity
Quoted 5 lines · On Thu, 2 Aug 2018 20:19:00 -0400 Brian Masney <[email protected]> wrote:
This patch adds device tree bindings for the tsl2772 ALS / proximity sensor for the LG Nexus 5 (hammerhead) phone.
Signed-off-by Brian Masney <[email protected]>Signed-off-by Jonathan Marek <[email protected]>
The precursors are working their way through the iio tree, but it will be the next merge window before they go upstream.
Thanks,
Jonathan
Quoted 72 lines
--- .../qcom-msm8974-lge-nexus5-hammerhead.dts | 27 +++++++++++++++++++ arch/arm/boot/dts/qcom-msm8974.dtsi | 11 ++++++++ 2 files changed, 38 insertions(+)arch/arm/boot/dts/qcom-msm8974-lge-nexus5-hammerhead.dts +27
-0@@ -242,6 +242,15 @@ }; }; + i2c3_pins: i2c3 { + mux { + pins = "gpio10", "gpio11"; + function = "blsp_i2c3"; + drive-strength = <2>; + bias-disable; + }; + }; + i2c12_pins: i2c12 { mux { pins = "gpio87", "gpio88";@@ -333,6 +342,24 @@ }; }; }; + + i2c@f9925000 { + status = "ok"; + pinctrl-names = "default"; + pinctrl-0 = <&i2c3_pins>; + clock-frequency = <100000>; + qcom,src-freq = <50000000>; + + avago_apds993@39 { + compatible = "avago,apds9930"; + reg = <0x39>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; + led-max-microamp = <100000>; + amstaos,proximity-diodes = <0>; + }; + }; }; &spmi_bus {arch/arm/boot/dts/qcom-msm8974.dtsi +11
-0@@ -713,6 +713,17 @@ #size-cells = <0>; }; + blsp_i2c3: i2c@f9925000 { + status = "disabled"; + compatible = "qcom,i2c-qup-v2.1.1"; + reg = <0xf9925000 0x1000>; + interrupts = <0 97 IRQ_TYPE_NONE>; + clocks = <&gcc GCC_BLSP1_QUP3_I2C_APPS_CLK>, <&gcc GCC_BLSP1_AHB_CLK>; + clock-names = "core", "iface"; + #address-cells = <1>; + #size-cells = <0>; + }; + blsp_i2c8: i2c@f9964000 { status = "disabled"; compatible = "qcom,i2c-qup-v2.1.1";