From e3faedf71d881780c2b8f6548aaacfad7f0a8372 Mon Sep 17 00:00:00 2001 From: Kefeng Wang Date: Tue, 23 Apr 2019 15:50:03 +0800 Subject: [PATCH 01/28] iio: adc: at91: Use dev_get_drvdata() Using dev_get_drvdata directly. Cc: Ludovic Desroches Cc: Jonathan Cameron Cc: linux-iio@vger.kernel.org Signed-off-by: Kefeng Wang Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 12 ++++-------- drivers/iio/adc/at91_adc.c | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index d5ea84cf6460..a3a4ca946308 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1586,8 +1586,7 @@ static void at91_adc_hw_init(struct at91_adc_state *st) static ssize_t at91_adc_get_fifo_state(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); return scnprintf(buf, PAGE_SIZE, "%d\n", !!st->dma_st.dma_chan); @@ -1596,8 +1595,7 @@ static ssize_t at91_adc_get_fifo_state(struct device *dev, static ssize_t at91_adc_get_watermark(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); return scnprintf(buf, PAGE_SIZE, "%d\n", st->dma_st.watermark); @@ -1849,8 +1847,7 @@ static int at91_adc_remove(struct platform_device *pdev) static __maybe_unused int at91_adc_suspend(struct device *dev) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); /* @@ -1870,8 +1867,7 @@ static __maybe_unused int at91_adc_suspend(struct device *dev) static __maybe_unused int at91_adc_resume(struct device *dev) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); int ret; diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 596841a3c4db..1aa8af3491fd 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -1360,7 +1360,7 @@ static int at91_adc_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int at91_adc_suspend(struct device *dev) { - struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *idev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(idev); pinctrl_pm_select_sleep_state(dev); @@ -1371,7 +1371,7 @@ static int at91_adc_suspend(struct device *dev) static int at91_adc_resume(struct device *dev) { - struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *idev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(idev); clk_prepare_enable(st->clk); From 34c2a55b0df4448110f353f21a8a02fe3e0bddfe Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:42:18 +0200 Subject: [PATCH 02/28] iio: temperature: maxim_thermocouple: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/temperature/maxim_thermocouple.ko | grep alias alias: spi:max31855 alias: spi:max6675 After this patch: modinfo drivers/iio/temperature/maxim_thermocouple.ko | grep alias alias: spi:max31855 alias: spi:max6675 alias: of:N*T*Cmaxim,max31855C* alias: of:N*T*Cmaxim,max31855 alias: of:N*T*Cmaxim,max6675C* alias: of:N*T*Cmaxim,max6675 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Acked-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/maxim_thermocouple.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index c31b9633f32d..c613a64c017f 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -262,9 +264,17 @@ static const struct spi_device_id maxim_thermocouple_id[] = { }; MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id); +static const struct of_device_id maxim_thermocouple_of_match[] = { + { .compatible = "maxim,max6675" }, + { .compatible = "maxim,max31855" }, + { }, +}; +MODULE_DEVICE_TABLE(of, maxim_thermocouple_of_match); + static struct spi_driver maxim_thermocouple_driver = { .driver = { .name = MAXIM_THERMOCOUPLE_DRV_NAME, + .of_match_table = maxim_thermocouple_of_match, }, .probe = maxim_thermocouple_probe, .remove = maxim_thermocouple_remove, From 17b16c3cbe92dee378004699e12aa6aa3df389e7 Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:40:59 +0200 Subject: [PATCH 03/28] iio: accel: kxsd9: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/accel/kxsd9-spi.ko | grep alias alias: spi:kxsd9 After this patch: modinfo drivers/iio/accel/kxsd9-spi.ko | grep alias alias: spi:kxsd9 alias: of:N*T*Ckionix,kxsd9C* alias: of:N*T*Ckionix,kxsd9 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxsd9-spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c index b7d0078fd00e..3027917410f2 100644 --- a/drivers/iio/accel/kxsd9-spi.c +++ b/drivers/iio/accel/kxsd9-spi.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include #include #include @@ -40,10 +42,17 @@ static const struct spi_device_id kxsd9_spi_id[] = { }; MODULE_DEVICE_TABLE(spi, kxsd9_spi_id); +static const struct of_device_id kxsd9_of_match[] = { + { .compatible = "kionix,kxsd9" }, + { }, +}; +MODULE_DEVICE_TABLE(of, kxsd9_of_match); + static struct spi_driver kxsd9_spi_driver = { .driver = { .name = "kxsd9", .pm = &kxsd9_dev_pm_ops, + .of_match_table = kxsd9_of_match, }, .probe = kxsd9_spi_probe, .remove = kxsd9_spi_remove, From 311def4cd2c6e8bbb4777919a3a5cf71592221db Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:41:37 +0200 Subject: [PATCH 04/28] iio: adxl372: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/accel/adxl372_spi.ko | grep alias After this patch: modinfo drivers/iio/accel/adxl372_spi.ko | grep alias alias: spi:adxl372 alias: of:N*T*Cadi,adxl372C* alias: of:N*T*Cadi,adxl372 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl372_spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/accel/adxl372_spi.c b/drivers/iio/accel/adxl372_spi.c index e14e655ef165..3ef7e3a4804e 100644 --- a/drivers/iio/accel/adxl372_spi.c +++ b/drivers/iio/accel/adxl372_spi.c @@ -7,6 +7,8 @@ #include #include +#include +#include #include #include "adxl372.h" @@ -37,9 +39,16 @@ static const struct spi_device_id adxl372_spi_id[] = { }; MODULE_DEVICE_TABLE(spi, adxl372_spi_id); +static const struct of_device_id adxl372_of_match[] = { + { .compatible = "adi,adxl372" }, + { }, +}; +MODULE_DEVICE_TABLE(of, adxl372_of_match); + static struct spi_driver adxl372_spi_driver = { .driver = { .name = "adxl372_spi", + .of_match_table = adxl372_of_match, }, .probe = adxl372_spi_probe, .id_table = adxl372_spi_id, From ed61b30858141b6462f2a96c73c267845a478c0c Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:41:58 +0200 Subject: [PATCH 05/28] iio: dac: ad5758: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/dac/ad5758.ko | grep alias alias: spi:ad5758 After this patch: modinfo drivers/iio/dac/ad5758.ko | grep alias alias: spi:ad5758 alias: of:N*T*Cadi,ad5758C* alias: of:N*T*Cadi,ad5758 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5758.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c index a513c70faefa..7d116487475f 100644 --- a/drivers/iio/dac/ad5758.c +++ b/drivers/iio/dac/ad5758.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -885,9 +887,16 @@ static const struct spi_device_id ad5758_id[] = { }; MODULE_DEVICE_TABLE(spi, ad5758_id); +static const struct of_device_id ad5758_of_match[] = { + { .compatible = "adi,ad5758" }, + { }, +}; +MODULE_DEVICE_TABLE(of, ad5758_of_match); + static struct spi_driver ad5758_driver = { .driver = { .name = KBUILD_MODNAME, + .of_match_table = ad5758_of_match, }, .probe = ad5758_probe, .id_table = ad5758_id, From 40e64432ce98f4ee5671d39fbf909ef3f3592366 Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Thu, 25 Apr 2019 19:03:14 -0400 Subject: [PATCH 06/28] dt-bindings: iio: tsl2583: convert bindings to YAML format Convert the tsl2583 device tree bindings to the new YAML format. Signed-off-by: Brian Masney Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/light/tsl2583.txt | 25 ---------- .../bindings/iio/light/tsl2583.yaml | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/tsl2583.txt create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2583.yaml diff --git a/Documentation/devicetree/bindings/iio/light/tsl2583.txt b/Documentation/devicetree/bindings/iio/light/tsl2583.txt deleted file mode 100644 index 059dffa1829a..000000000000 --- a/Documentation/devicetree/bindings/iio/light/tsl2583.txt +++ /dev/null @@ -1,25 +0,0 @@ -* TAOS TSL 2580/2581/2583 ALS sensor - -Required properties: - - - compatible: Should be one of - "amstaos,tsl2580" - "amstaos,tsl2581" - "amstaos,tsl2583" - - reg: the I2C address of the device - -Optional properties: - - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - - - vcc-supply: phandle to the regulator that provides power to the sensor. - -Example: - -tsl2581@29 { - compatible = "amstaos,tsl2581"; - reg = <0x29>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/tsl2583.yaml b/Documentation/devicetree/bindings/iio/light/tsl2583.yaml new file mode 100644 index 000000000000..e86ef64ecf03 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/tsl2583.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/tsl2583.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS/TAOS Ambient Light Sensor (ALS) + +maintainers: + - Brian Masney + +description: | + Ambient light sensing with an i2c interface. + +properties: + compatible: + enum: + - amstaos,tsl2580 + - amstaos,tsl2581 + - amstaos,tsl2583 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vcc-supply: + description: Regulator that provides power to the sensor + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@29 { + compatible = "amstaos,tsl2581"; + reg = <0x29>; + }; + }; +... From 17b62779cbe40773e10a83af000e51c29b764575 Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Thu, 25 Apr 2019 19:03:13 -0400 Subject: [PATCH 07/28] dt-bindings: iio: tsl2772: convert bindings to YAML format Convert the tsl2772 device tree bindings to the new YAML format. Signed-off-by: Brian Masney Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/light/tsl2772.txt | 42 ---------- .../bindings/iio/light/tsl2772.yaml | 83 +++++++++++++++++++ 2 files changed, 83 insertions(+), 42 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.yaml diff --git a/Documentation/devicetree/bindings/iio/light/tsl2772.txt b/Documentation/devicetree/bindings/iio/light/tsl2772.txt deleted file mode 100644 index 1c5e6f17a1df..000000000000 --- a/Documentation/devicetree/bindings/iio/light/tsl2772.txt +++ /dev/null @@ -1,42 +0,0 @@ -* 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" - "avago,apds9930" - - 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. - - 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 - node bindings. - -Example: - -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>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/tsl2772.yaml b/Documentation/devicetree/bindings/iio/light/tsl2772.yaml new file mode 100644 index 000000000000..ed2c3d5eadf5 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/tsl2772.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/tsl2772.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS/TAOS Ambient Light Sensor (ALS) and Proximity Detector + +maintainers: + - Brian Masney + +description: | + Ambient light sensing and proximity detection with an i2c interface. + https://ams.com/documents/20143/36005/TSL2772_DS000181_2-00.pdf + +properties: + compatible: + enum: + - amstaos,tsl2571 + - amstaos,tsl2671 + - amstaos,tmd2671 + - amstaos,tsl2771 + - amstaos,tmd2771 + - amstaos,tsl2572 + - amstaos,tsl2672 + - amstaos,tmd2672 + - amstaos,tsl2772 + - amstaos,tmd2772 + - avago,apds9930 + + reg: + maxItems: 1 + + amstaos,proximity-diodes: + description: Proximity diodes to enable + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 1 + maxItems: 2 + items: + minimum: 0 + maximum: 1 + + interrupts: + maxItems: 1 + + led-max-microamp: + description: Current for the proximity LED + enum: + - 13000 + - 25000 + - 50000 + - 100000 + + vdd-supply: + description: Regulator that provides power to the sensor + + vddio-supply: + description: Regulator that provides power to the bus + +required: + - compatible + - reg + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensor@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>; + }; + }; +... From 3e53ef91f826957dec013c47707ffc1bb42b42d7 Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Wed, 24 Apr 2019 14:51:25 +0200 Subject: [PATCH 08/28] iio: adc: stm32-dfsdm: manage the get_irq error case During probe, check the "get_irq" error value. Signed-off-by: Fabien Dessenne Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 19adc2b23472..588907cc3b6b 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1456,6 +1456,12 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) * So IRQ associated to filter instance 0 is dedicated to the Filter 0. */ irq = platform_get_irq(pdev, 0); + if (irq < 0) { + if (irq != -EPROBE_DEFER) + dev_err(dev, "Failed to get IRQ: %d\n", irq); + return irq; + } + ret = devm_request_irq(dev, irq, stm32_dfsdm_irq, 0, pdev->name, adc); if (ret < 0) { From d2fc0156963cae8f1eec8e2dd645fbbf1e1c1c8e Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Wed, 24 Apr 2019 14:51:26 +0200 Subject: [PATCH 09/28] iio: adc: stm32-dfsdm: missing error case during probe During probe, check the devm_ioremap_resource() error value. Also return the devm_clk_get() error value instead of -EINVAL. Signed-off-by: Fabien Dessenne Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index 0a4d3746d21c..26e2011c5868 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -233,6 +233,8 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev, } priv->dfsdm.phys_base = res->start; priv->dfsdm.base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(priv->dfsdm.base)) + return PTR_ERR(priv->dfsdm.base); /* * "dfsdm" clock is mandatory for DFSDM peripheral clocking. @@ -242,8 +244,10 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev, */ priv->clk = devm_clk_get(&pdev->dev, "dfsdm"); if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "No stm32_dfsdm_clk clock found\n"); - return -EINVAL; + ret = PTR_ERR(priv->clk); + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "Failed to get clock (%d)\n", ret); + return ret; } priv->aclk = devm_clk_get(&pdev->dev, "audio"); From 8b7a6a35746292e140304107e60f9a980416abf7 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Fri, 26 Apr 2019 13:39:16 +0200 Subject: [PATCH 10/28] iio: cros_ec: add 'id' sysfs entry This new sysfs entry is used to interpret ring buffer information, mainly by Android sensor HAL. It expand to all sensors, the documentation about 'id' we can found in Documentation/ABI/testing/sysfs-bus-iio-cros-ec. Also fix typo in docs, I replace 'Septembre' by 'September'. Signed-off-by: Gwendal Grignou Signed-off-by: Fabien Lahoudere Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio-cros-ec | 10 +++++----- .../common/cros_ec_sensors/cros_ec_sensors_core.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-cros-ec b/Documentation/ABI/testing/sysfs-bus-iio-cros-ec index 0e95c2ca105c..6158f831c761 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-cros-ec +++ b/Documentation/ABI/testing/sysfs-bus-iio-cros-ec @@ -18,11 +18,11 @@ Description: values are 'base' and 'lid'. What: /sys/bus/iio/devices/iio:deviceX/id -Date: Septembre 2017 +Date: September 2017 KernelVersion: 4.14 Contact: linux-iio@vger.kernel.org Description: - This attribute is exposed by the CrOS EC legacy accelerometer - driver and represents the sensor ID as exposed by the EC. This - ID is used by the Android sensor service hardware abstraction - layer (sensor HAL) through the Android container on ChromeOS. + This attribute is exposed by the CrOS EC sensors driver and + represents the sensor ID as exposed by the EC. This ID is used + by the Android sensor service hardware abstraction layer (sensor + HAL) through the Android container on ChromeOS. diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index 719a0df5aeeb..130362ca421b 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -125,6 +125,15 @@ static ssize_t cros_ec_sensors_calibrate(struct iio_dev *indio_dev, return ret ? ret : len; } +static ssize_t cros_ec_sensors_id(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, char *buf) +{ + struct cros_ec_sensors_core_state *st = iio_priv(indio_dev); + + return snprintf(buf, PAGE_SIZE, "%d\n", st->param.info.sensor_num); +} + static ssize_t cros_ec_sensors_loc(struct iio_dev *indio_dev, uintptr_t private, const struct iio_chan_spec *chan, char *buf) @@ -140,6 +149,11 @@ const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = { .shared = IIO_SHARED_BY_ALL, .write = cros_ec_sensors_calibrate }, + { + .name = "id", + .shared = IIO_SHARED_BY_ALL, + .read = cros_ec_sensors_id + }, { .name = "location", .shared = IIO_SHARED_BY_ALL, From e99c25f4320d1a8329c12c66680a974725ff16a0 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Sat, 27 Apr 2019 00:40:06 +0800 Subject: [PATCH 11/28] iio: dac: ad5758: remove set but not used variable 'dc_dc_mode' Fixes gcc '-Wunused-but-set-variable' warning: drivers/iio/dac/ad5758.c: In function ad5758_write_powerdown: drivers/iio/dac/ad5758.c:585:15: warning: variable dc_dc_mode set but not used [-Wunused-but-set-variable] It is not used any more since commit edde945257e2 ("iio: dac: ad5758: Modifications for new revision") Signed-off-by: YueHaibing Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5758.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c index 7d116487475f..475646c82b40 100644 --- a/drivers/iio/dac/ad5758.c +++ b/drivers/iio/dac/ad5758.c @@ -584,7 +584,7 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev, { struct ad5758_state *st = iio_priv(indio_dev); bool pwr_down; - unsigned int dc_dc_mode, dac_config_mode, val; + unsigned int dac_config_mode, val; unsigned long int dac_config_msk; int ret; @@ -593,13 +593,10 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev, return ret; mutex_lock(&st->lock); - if (pwr_down) { - dc_dc_mode = AD5758_DCDC_MODE_POWER_OFF; + if (pwr_down) val = 0; - } else { - dc_dc_mode = st->dc_dc_mode; + else val = 1; - } dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) | AD5758_DAC_CONFIG_INT_EN_MODE(val); From 7fc1148cfde1c0d53930c7a5ac62b5bffe7b0e0b Mon Sep 17 00:00:00 2001 From: Zhiyong Tao Date: Wed, 24 Apr 2019 09:11:11 +0800 Subject: [PATCH 12/28] dt-bindings: adc: mt8183: add binding document The commit adds mt8183 compatible node in binding document. Signed-off-by: Zhiyong Tao Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt index 0df9befdaecc..936a0b4666da 100644 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt @@ -15,6 +15,7 @@ Required properties: - "mediatek,mt2712-auxadc": For MT2712 family of SoCs - "mediatek,mt7622-auxadc": For MT7622 family of SoCs - "mediatek,mt8173-auxadc": For MT8173 family of SoCs + - "mediatek,mt8183-auxadc", "mediatek,mt8173-auxadc": For MT8183 family of SoCs - reg: Address range of the AUXADC unit. - clocks: Should contain a clock specifier for each entry in clock-names - clock-names: Should contain "main". From cf54f4dd07a652d9a0630ec4e82c5ff082d2a14e Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Sat, 27 Apr 2019 14:23:59 -0400 Subject: [PATCH 13/28] dt-bindings: iio: isl29018: convert bindings to YAML format Convert the isl29018 device tree bindings to the new YAML format. Signed-off-by: Brian Masney Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/light/isl29018.txt | 27 --------- .../bindings/iio/light/isl29018.yaml | 56 +++++++++++++++++++ 2 files changed, 56 insertions(+), 27 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/isl29018.txt create mode 100644 Documentation/devicetree/bindings/iio/light/isl29018.yaml diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.txt b/Documentation/devicetree/bindings/iio/light/isl29018.txt deleted file mode 100644 index b9bbde3e13ed..000000000000 --- a/Documentation/devicetree/bindings/iio/light/isl29018.txt +++ /dev/null @@ -1,27 +0,0 @@ -* ISL 29018/29023/29035 I2C ALS, Proximity, and Infrared sensor - -Required properties: - - - compatible: Should be one of - "isil,isl29018" - "isil,isl29023" - "isil,isl29035" - - reg: the I2C address of the device - -Optional properties: - - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - - - vcc-supply: phandle to the regulator that provides power to the sensor. - -Example: - -isl29018@44 { - compatible = "isil,isl29018"; - reg = <0x44>; - interrupt-parent = <&gpio>; - interrupts = ; -}; diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.yaml b/Documentation/devicetree/bindings/iio/light/isl29018.yaml new file mode 100644 index 000000000000..cbb00be8f359 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/isl29018.yaml @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/isl29018.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: | + Intersil 29018/29023/29035 Ambient Light, Infrared Light, and Proximity Sensor + +maintainers: + - Brian Masney + +description: | + Ambient and infrared light sensing with proximity detection over an i2c + interface. + + https://www.renesas.com/us/en/www/doc/datasheet/isl29018.pdf + https://www.renesas.com/us/en/www/doc/datasheet/isl29023.pdf + https://www.renesas.com/us/en/www/doc/datasheet/isl29035.pdf + +properties: + compatible: + enum: + - isil,isl29018 + - isil,isl29023 + - isil,isl29035 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vcc-supply: + description: Regulator that provides power to the sensor + +required: + - compatible + - reg + +examples: + - | + #include + + i2c { + + #address-cells = <1>; + #size-cells = <0>; + + sensor@44 { + compatible = "isil,isl29018"; + reg = <0x44>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_LEVEL_HIGH>; + }; + }; +... From 5c25531d4b43c377544d2553f3a8e51d84037ca6 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 29 Apr 2019 17:24:09 +0200 Subject: [PATCH 14/28] iio: adc: rcar-gyroadc: Remove devm_iio_device_alloc() error printing devm_iio_device_alloc() can only fail due to a memory or IDA allocation failure. Hence there is no need to print a message, as the memory allocation or IIO core code already takes care of that. Signed-off-by: Geert Uytterhoeven Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rcar-gyroadc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index 2c0d0316d149..2d685730f867 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -485,10 +485,8 @@ static int rcar_gyroadc_probe(struct platform_device *pdev) int ret; indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); - if (!indio_dev) { - dev_err(dev, "Failed to allocate IIO device.\n"); + if (!indio_dev) return -ENOMEM; - } priv = iio_priv(indio_dev); priv->dev = dev; From a8b7ca187fd21e9bd53c57eb8c97124ef01fea04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Seckler?= Date: Mon, 29 Apr 2019 14:59:40 -0300 Subject: [PATCH 15/28] staging: iio: adt7316: match parenthesis alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch solves the following checkpatch.pl message: CHECK: Alignment should match open parenthesis. This makes the file more compliant with the preferred coding style for the Linux kernel. Signed-off-by: João Seckler Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index b6a65ee8d558..37ce563cb0e1 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2154,7 +2154,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, chip->dac_bits = 8; chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", - GPIOD_OUT_LOW); + GPIOD_OUT_LOW); if (IS_ERR(chip->ldac_pin)) { ret = PTR_ERR(chip->ldac_pin); dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); From c57c54bc9758ac0a7cacfece8eb2aba5b2732228 Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Wed, 1 May 2019 12:45:41 +0530 Subject: [PATCH 16/28] staging: iio: adc: Add paragraph to describe Kconfig symbol This patch updates Kconfig with paragraph that describe config symbol fully.Issue addressed by checkpatch. Signed-off-by: Vatsala Narang Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 23d9a655a520..31cd9a12f40f 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -12,6 +12,9 @@ config AD7816 Say yes here to build support for Analog Devices AD7816/7/8 temperature sensors and ADC. + To compile this driver as a module, choose M here: the + module will be called ad7816. + config AD7192 tristate "Analog Devices AD7190 AD7192 AD7193 AD7195 ADC driver" depends on SPI From b1f4c9a3c78c70b05b2d844cc72c17d3620ba543 Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Fri, 3 May 2019 15:57:23 +0200 Subject: [PATCH 17/28] iio: stmpe-adc: Remove unnecessary assignment Remove unnecessary assignment. This could potentially cause an issue, if the wait function runs into a timeout. Furthermore is this assignment also not there in stmpe_read_temp() Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 7921f827c6ec..c01806906416 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -78,8 +78,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); - *val = info->value; - ret = wait_for_completion_interruptible_timeout (&info->completion, STMPE_ADC_TIMEOUT); From 2abd293703ebafe8ae64876936ad345c6716cd9a Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:11 +0200 Subject: [PATCH 18/28] iio: stmpe-adc: Add compatible name Add the compatible name to the driver so it gets loaded when the proper node in DT is detected. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index c01806906416..da6cab88af53 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -351,9 +351,14 @@ static struct platform_driver stmpe_adc_driver = { .pm = &stmpe_adc_pm_ops, }, }; - module_platform_driver(stmpe_adc_driver); +static const struct of_device_id stmpe_adc_ids[] = { + { .compatible = "st,stmpe-adc", }, + { }, +}; +MODULE_DEVICE_TABLE(of, stmpe_adc_ids); + MODULE_AUTHOR("Stefan Agner "); MODULE_DESCRIPTION("STMPEXXX ADC driver"); MODULE_LICENSE("GPL v2"); From 263d21cd5e85eb4d96fd560eee814d98c5b89546 Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:12 +0200 Subject: [PATCH 19/28] iio: stmpe-adc: Reinit completion struct on begin conversion In some cases, the wait_completion got interrupted. This caused the error-handling to mutex_unlock the function. The before turned on interrupt then got called anyway. In the ISR then completion() was called causing wrong adc-values returned in a following adc-readout. Reinitialise completion struct to make sure the counter is zero when beginning a new adc-conversion. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index da6cab88af53..5940bb8085b2 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, mutex_lock(&info->lock); + reinit_completion(&info->completion); + info->channel = (u8)chan->channel; if (info->channel > STMPE_ADC_LAST_NR) { @@ -103,6 +105,8 @@ static int stmpe_read_temp(struct stmpe_adc *info, mutex_lock(&info->lock); + reinit_completion(&info->completion); + info->channel = (u8)chan->channel; if (info->channel != STMPE_TEMP_CHANNEL) { From 4bd44bb2b470459d795c4bac328ed8edb7ebd132 Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:13 +0200 Subject: [PATCH 20/28] iio: stmpe-adc: Enable all stmpe-adc interrupts just once This commit will enable the interrupts of all channels handled by this driver only once in the probe function. This will improve performance because one byte less has to be written over i2c on each read out of the adc. On the fastest ADC mode this will improve read out speed by 15%. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 5940bb8085b2..229b0b9ac130 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -74,9 +74,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info, return -EINVAL; } - stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, - STMPE_ADC_CH(info->channel)); - stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); @@ -333,6 +330,9 @@ static int stmpe_adc_probe(struct platform_device *pdev) if (ret) return ret; + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, + ~(norequest_mask & 0xFF)); + return devm_iio_device_register(&pdev->dev, indio_dev); } From e813dde6f83343012239a44e433eacc22de1079c Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:14 +0200 Subject: [PATCH 21/28] iio: stmpe-adc: Use wait_for_completion_timeout Use wait_for_completion_timeout instead of wait_for_completion_interuptible_timeout. The interruptible variant gets constantly interrupted if a user program is compiled with the -pg option. The killable variant was not used due to the fact that a second program, reading on this device, that gets killed is then also killing that wait. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 229b0b9ac130..40a4648f0bc5 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -77,15 +77,11 @@ static int stmpe_read_voltage(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); - ret = wait_for_completion_interruptible_timeout - (&info->completion, STMPE_ADC_TIMEOUT); + ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { mutex_unlock(&info->lock); - if (ret == 0) - return -ETIMEDOUT; - else - return ret; + return -ETIMEDOUT; } *val = info->value; @@ -114,15 +110,11 @@ static int stmpe_read_temp(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_TEMP_CTRL, STMPE_START_ONE_TEMP_CONV); - ret = wait_for_completion_interruptible_timeout - (&info->completion, STMPE_ADC_TIMEOUT); + ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { mutex_unlock(&info->lock); - if (ret == 0) - return -ETIMEDOUT; - else - return ret; + return -ETIMEDOUT; } /* From ed1f310ee23d277d5386f532165911df69afe62f Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:15 +0200 Subject: [PATCH 22/28] iio: stmpe-adc: Reset possible interrupts Clear any interrupt that still is on the device on every channel this driver is activated for in probe and specific channels in the timeout handler. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 40a4648f0bc5..bd72727fc417 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -80,6 +80,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_STA, + STMPE_ADC_CH(info->channel)); mutex_unlock(&info->lock); return -ETIMEDOUT; } @@ -325,6 +327,9 @@ static int stmpe_adc_probe(struct platform_device *pdev) stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, ~(norequest_mask & 0xFF)); + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_STA, + ~(norequest_mask & 0xFF)); + return devm_iio_device_register(&pdev->dev, indio_dev); } From a2d2010d95cd7ffe3773aba6eaee35d54e332c25 Mon Sep 17 00:00:00 2001 From: Ruslan Babayev Date: Sun, 5 May 2019 12:24:36 -0700 Subject: [PATCH 23/28] iio: dac: ds4422/ds4424 drop of_node check The driver doesn't actually rely on any DT properties. Removing this check makes it usable on ACPI based platforms. Signed-off-by: Ruslan Babayev Cc: xe-linux-external@cisco.com Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ds4424.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 883a47562055..2b3ba1a66fe8 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -236,12 +236,6 @@ static int ds4424_probe(struct i2c_client *client, indio_dev->dev.of_node = client->dev.of_node; indio_dev->dev.parent = &client->dev; - if (!client->dev.of_node) { - dev_err(&client->dev, - "Not found DT.\n"); - return -ENODEV; - } - data->vcc_reg = devm_regulator_get(&client->dev, "vcc"); if (IS_ERR(data->vcc_reg)) { dev_err(&client->dev, From 0d698a538f8d4827c3209c44db57ca5a5945550e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 17 May 2019 16:37:11 +0300 Subject: [PATCH 24/28] iio: ad9523-1: Improve reported VCO frequency accuracy To improve the accuracy of the reported VCO frequency perform all multiplications before divisions. This reduces rounding errors and makes sure the reported rates are accurate down to the last digit. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 9b9eee27176c..ceb1daceeb46 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -862,9 +862,11 @@ static int ad9523_setup(struct iio_dev *indio_dev) if (ret < 0) return ret; - st->vco_freq = (pdata->vcxo_freq * (pdata->pll2_freq_doubler_en ? 2 : 1) - / pdata->pll2_r2_div) * AD9523_PLL2_FB_NDIV(pdata-> - pll2_ndiv_a_cnt, pdata->pll2_ndiv_b_cnt); + st->vco_freq = div_u64((unsigned long long)pdata->vcxo_freq * + (pdata->pll2_freq_doubler_en ? 2 : 1) * + AD9523_PLL2_FB_NDIV(pdata->pll2_ndiv_a_cnt, + pdata->pll2_ndiv_b_cnt), + pdata->pll2_r2_div); ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_CTRL, AD9523_PLL2_VCO_CALIBRATE); From 5887c8364766842f9c5e07e4b0bf38013f48ba09 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Sun, 12 May 2019 04:32:41 -0400 Subject: [PATCH 25/28] iio: adc: sun4i-gpadc-iio convert to SPDX license tags Updates license to use SPDX-License-Identifier. Signed-off-by: Yangtao Li Acked-by: Maxime Ripard Signed-off-by: Jonathan Cameron --- drivers/iio/adc/sun4i-gpadc-iio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 04d7147e0110..f13c6248a662 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* ADC driver for sunxi platforms' (A10, A13 and A31) GPADC * * Copyright (c) 2016 Quentin Schulz * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License version 2 as published by the - * Free Software Foundation. - * * The Allwinner SoCs all have an ADC that can also act as a touchscreen * controller and a thermal sensor. * The thermal sensor works only when the ADC acts as a touchscreen controller From e359a29225dde53fade5fa4bc3d957599fb5f9a5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 May 2019 18:44:41 +0300 Subject: [PATCH 26/28] dt-bindings: iio: accel: adxl345: switch to YAML bindings The ADX345 supports both I2C & SPI bindings. This change switches from old text bindings, to YAML bindings, and also tries to make use of the recent multiple-examples support. Signed-off-by: Alexandru Ardelean Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/accel/adi,adxl345.yaml | 72 +++++++++++++++++++ .../devicetree/bindings/iio/accel/adxl345.txt | 39 ---------- MAINTAINERS | 1 + 3 files changed, 73 insertions(+), 39 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml delete mode 100644 Documentation/devicetree/bindings/iio/accel/adxl345.txt diff --git a/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml b/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml new file mode 100644 index 000000000000..7ba167e2e1ea --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accelerometers/adi,adxl345.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers + +maintainers: + - Michael Hennerich + +description: | + Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers that supports + both I2C & SPI interfaces. + http://www.analog.com/en/products/mems/accelerometers/adxl345.html + http://www.analog.com/en/products/sensors-mems/accelerometers/adxl375.html + +properties: + compatible: + enum: + - adi,adxl345 + - adi,adxl375 + + reg: + maxItems: 1 + + spi-cpha: true + + spi-cpol: true + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include + #include + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + /* Example for a I2C device node */ + accelerometer@2a { + compatible = "adi,adxl345"; + reg = <0x53>; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; + }; + - | + #include + #include + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + /* Example for a SPI device node */ + accelerometer@0 { + compatible = "adi,adxl345"; + reg = <0>; + spi-max-frequency = <5000000>; + spi-cpol; + spi-cpha; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; + }; diff --git a/Documentation/devicetree/bindings/iio/accel/adxl345.txt b/Documentation/devicetree/bindings/iio/accel/adxl345.txt deleted file mode 100644 index f9525f6e3d43..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/adxl345.txt +++ /dev/null @@ -1,39 +0,0 @@ -Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers - -http://www.analog.com/en/products/mems/accelerometers/adxl345.html -http://www.analog.com/en/products/sensors-mems/accelerometers/adxl375.html - -Required properties: - - compatible : should be one of - "adi,adxl345" - "adi,adxl375" - - reg : the I2C address or SPI chip select number of the sensor - -Required properties for SPI bus usage: - - spi-max-frequency : set maximum clock frequency, must be 5000000 - - spi-cpol and spi-cpha : must be defined for adxl345 to enable SPI mode 3 - -Optional properties: - - interrupts: interrupt mapping for IRQ as documented in - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - -Example for a I2C device node: - - accelerometer@2a { - compatible = "adi,adxl345"; - reg = <0x53>; - interrupt-parent = <&gpio1>; - interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; - }; - -Example for a SPI device node: - - accelerometer@0 { - compatible = "adi,adxl345"; - reg = <0>; - spi-max-frequency = <5000000>; - spi-cpol; - spi-cpha; - interrupt-parent = <&gpio1>; - interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; - }; diff --git a/MAINTAINERS b/MAINTAINERS index 43a9cebb2c19..54c8e14fae98 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -551,6 +551,7 @@ W: http://wiki.analog.com/ADXL345 W: http://ez.analog.com/community/linux-device-drivers S: Supported F: drivers/input/misc/adxl34x.c +F: Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml ADXL372 THREE-AXIS DIGITAL ACCELEROMETER DRIVER M: Stefan Popa From 73e1ccdab3c34b8f9be6e55600d40a1478049121 Mon Sep 17 00:00:00 2001 From: Chun-Hung Wu Date: Thu, 16 May 2019 16:10:44 +0800 Subject: [PATCH 27/28] dt-bindings: iio: adc: mediatek: Add document for mt6765 Add compatible node for mt6765 auxadc Signed-off-by: Chun-Hung Wu Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt index 936a0b4666da..78c06e05c8e5 100644 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt @@ -13,6 +13,7 @@ Required properties: - compatible: Should be one of: - "mediatek,mt2701-auxadc": For MT2701 family of SoCs - "mediatek,mt2712-auxadc": For MT2712 family of SoCs + - "mediatek,mt6765-auxadc": For MT6765 family of SoCs - "mediatek,mt7622-auxadc": For MT7622 family of SoCs - "mediatek,mt8173-auxadc": For MT8173 family of SoCs - "mediatek,mt8183-auxadc", "mediatek,mt8173-auxadc": For MT8183 family of SoCs From 6d97024dce236619b0bb85bdb5028019ed7fda56 Mon Sep 17 00:00:00 2001 From: Chun-Hung Wu Date: Thu, 16 May 2019 16:10:45 +0800 Subject: [PATCH 28/28] iio: adc: mediatek: mt6577-auxadc, add mt6765 support 1. Add calibrated sample data support 2. Use of_match_table to decide each platform's feature set Signed-off-by: Chun-Hung Wu Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mt6577_auxadc.c | 54 +++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index 95d76abb64ec..e1bdcc0a72a9 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -42,10 +42,26 @@ #define MT6577_AUXADC_POWER_READY_MS 1 #define MT6577_AUXADC_SAMPLE_READY_US 25 +struct mtk_auxadc_compatible { + bool sample_data_cali; + bool check_global_idle; +}; + struct mt6577_auxadc_device { void __iomem *reg_base; struct clk *adc_clk; struct mutex lock; + const struct mtk_auxadc_compatible *dev_comp; +}; + +static const struct mtk_auxadc_compatible mt8173_compat = { + .sample_data_cali = false, + .check_global_idle = true, +}; + +static const struct mtk_auxadc_compatible mt6765_compat = { + .sample_data_cali = true, + .check_global_idle = false, }; #define MT6577_AUXADC_CHANNEL(idx) { \ @@ -74,6 +90,11 @@ static const struct iio_chan_spec mt6577_auxadc_iio_channels[] = { MT6577_AUXADC_CHANNEL(15), }; +static int mt_auxadc_get_cali_data(int rawdata, bool enable_cali) +{ + return rawdata; +} + static inline void mt6577_auxadc_mod_reg(void __iomem *reg, u32 or_mask, u32 and_mask) { @@ -120,15 +141,17 @@ static int mt6577_auxadc_read(struct iio_dev *indio_dev, /* we must delay here for hardware sample channel data */ udelay(MT6577_AUXADC_SAMPLE_READY_US); - /* check MTK_AUXADC_CON2 if auxadc is idle */ - ret = readl_poll_timeout(adc_dev->reg_base + MT6577_AUXADC_CON2, val, - ((val & MT6577_AUXADC_STA) == 0), - MT6577_AUXADC_SLEEP_US, - MT6577_AUXADC_TIMEOUT_US); - if (ret < 0) { - dev_err(indio_dev->dev.parent, - "wait for auxadc idle time out\n"); - goto err_timeout; + if (adc_dev->dev_comp->check_global_idle) { + /* check MTK_AUXADC_CON2 if auxadc is idle */ + ret = readl_poll_timeout(adc_dev->reg_base + MT6577_AUXADC_CON2, + val, ((val & MT6577_AUXADC_STA) == 0), + MT6577_AUXADC_SLEEP_US, + MT6577_AUXADC_TIMEOUT_US); + if (ret < 0) { + dev_err(indio_dev->dev.parent, + "wait for auxadc idle time out\n"); + goto err_timeout; + } } /* read channel and make sure ready bit == 1 */ @@ -163,6 +186,8 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, int *val2, long info) { + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); + switch (info) { case IIO_CHAN_INFO_PROCESSED: *val = mt6577_auxadc_read(indio_dev, chan); @@ -172,6 +197,8 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, chan->channel); return *val; } + if (adc_dev->dev_comp->sample_data_cali) + *val = mt_auxadc_get_cali_data(*val, true); return IIO_VAL_INT; default: @@ -304,10 +331,11 @@ static SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops, mt6577_auxadc_resume); static const struct of_device_id mt6577_auxadc_of_match[] = { - { .compatible = "mediatek,mt2701-auxadc", }, - { .compatible = "mediatek,mt2712-auxadc", }, - { .compatible = "mediatek,mt7622-auxadc", }, - { .compatible = "mediatek,mt8173-auxadc", }, + { .compatible = "mediatek,mt2701-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt2712-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt7622-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt8173-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt6765-auxadc", .data = &mt6765_compat}, { } }; MODULE_DEVICE_TABLE(of, mt6577_auxadc_of_match);