layerscape: add i2c peripherials on LS1012A-RDB
authorPawel Dembicki <paweldembicki@gmail.com>
Tue, 27 Oct 2020 08:52:31 +0000 (09:52 +0100)
committerPetr Štetiar <ynezz@true.cz>
Mon, 23 Nov 2020 21:53:15 +0000 (22:53 +0100)
LS1012A-RDB equipped in some i2c devices:
  - 3x GPIO Expander: PCAL9555A (NXP)
  - Gyro: FXAS21002 (NXP)
  - Accelerometer: FXOS8700 (NXP)
  - Current & Power Monitor: INA220 (TI)

This patch enables i2c peripherials installed on LS1012A-RDB.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
target/linux/layerscape/armv8_64b/config-5.4
target/linux/layerscape/image/armv8_64b.mk
target/linux/layerscape/patches-5.4/900-layerscape_fix_support_of_LS1012A-RDB.patch [new file with mode: 0644]
target/linux/layerscape/patches-5.4/901-fix_irq_type_of_pca953x.patch [new file with mode: 0644]

index 6da7ff01a553fa208a42eba8cb1af37953ae840a..8c398f4a2b177d04ce462ea795a5676a49afe2c0 100644 (file)
@@ -419,9 +419,12 @@ CONFIG_GENERIC_TIME_VSYSCALL=y
 # CONFIG_GIANFAR is not set
 CONFIG_GLOB=y
 CONFIG_GPIOLIB=y
+CONFIG_GPIOLIB_IRQCHIP=y
 CONFIG_GPIO_GENERIC=y
 CONFIG_GPIO_GENERIC_PLATFORM=y
 CONFIG_GPIO_MPC8XXX=y
+CONFIG_GPIO_PCA953X=y
+CONFIG_GPIO_PCA953X_IRQ=y
 CONFIG_HANDLE_DOMAIN_IRQ=y
 CONFIG_HARDEN_BRANCH_PREDICTOR=y
 CONFIG_HARDIRQS_SW_RESEND=y
index bedf272f79ba8c5cea31ee895c17b36812aaa61f..264f7dfd84d1e97c2715a15588ff9413f09945cf 100644 (file)
@@ -63,6 +63,9 @@ define Device/fsl_ls1012a-rdb
   DEVICE_PACKAGES += \
     layerscape-ppfe \
     tfa-ls1012a-rdb \
+    kmod-hwmon-ina2xx \
+    kmod-iio-fxas21002c-i2c \
+    kmod-iio-fxos8700-i2c \
     kmod-ppfe
   IMAGE/firmware.bin := \
     ls-clean | \
diff --git a/target/linux/layerscape/patches-5.4/900-layerscape_fix_support_of_LS1012A-RDB.patch b/target/linux/layerscape/patches-5.4/900-layerscape_fix_support_of_LS1012A-RDB.patch
new file mode 100644 (file)
index 0000000..bcad654
--- /dev/null
@@ -0,0 +1,107 @@
+From 650480191492845c8eb7e0c2e5b1e37cabc59eff Mon Sep 17 00:00:00 2001
+From: Pawel Dembicki <paweldembicki@gmail.com>
+Date: Fri, 13 Nov 2020 07:17:39 +0100
+Subject: [PATCH 1/2] arm64: dts: fsl-ls1012a-rdb: add i2c devices
+
+LS1012A-RDB equipped in some i2c devices:
+  - 3x GPIO Expander: PCAL9555A (NXP)
+  - Gyro: FXAS21002 (NXP)
+  - Accelerometer: FXOS8700 (NXP)
+  - Current & Power Monitor: INA220 (TI)
+
+This patch add listed devices to dts.
+
+Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
+---
+ .../boot/dts/freescale/fsl-ls1012a-rdb.dts    | 66 +++++++++++++++++++
+ 1 file changed, 66 insertions(+)
+
+--- a/arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts
++++ b/arch/arm64/boot/dts/freescale/fsl-ls1012a-rdb.dts
+@@ -7,6 +7,7 @@
+  */
+ /dts-v1/;
++#include <dt-bindings/interrupt-controller/irq.h>
+ #include "fsl-ls1012a.dtsi"
+ / {
+@@ -16,6 +17,25 @@
+       aliases {
+               ethernet0 = &pfe_mac0;
+               ethernet1 = &pfe_mac1;
++              serial0 = &duart0;
++      };
++
++      dummy3v3: dummy_reg {
++              compatible = "regulator-fixed";
++              regulator-name = "dummy_regulator_3v3";
++
++              regulator-min-microvolt = <3300000>;
++              regulator-max-microvolt = <3300000>;
++              regulator-always-on;
++      };
++
++      dummy1v8: dummy_reg {
++              compatible = "regulator-fixed";
++              regulator-name = "dummy_regulator_1v8";
++
++              regulator-min-microvolt = <1800000>;
++              regulator-max-microvolt = <1800000>;
++              regulator-always-on;
+       };
+ };
+@@ -42,6 +62,52 @@
+ &i2c0 {
+       status = "okay";
++
++      accelerometer@1e {
++              compatible = "nxp,fxos8700";
++              reg = <0x1e>;
++              interrupt-parent = <&gpio26>;
++              interrupts = <13 IRQ_TYPE_EDGE_RISING>;
++              interrupt-names = "INT1";
++      };
++
++      gyroscope@20 {
++              compatible = "nxp,fxas21002c";
++              reg = <0x20>;
++              vdd-supply = <&dummy3v3>;
++              vddio-supply = <&dummy1v8>;
++      };
++
++      gpio@24 {
++              compatible = "nxp,pcal9555a";
++              reg = <0x24>;
++              gpio-controller;
++              #gpio-cells = <2>;
++      };
++
++      gpio25: gpio@25 {
++              compatible = "nxp,pcal9555a";
++              reg = <0x25>;
++              gpio-controller;
++              #gpio-cells = <2>;
++      };
++
++      gpio26: gpio@26 {
++              compatible = "nxp,pcal9555a";
++              reg = <0x26>;
++              interrupt-parent = <&gpio0>;
++              interrupts = <13 IRQ_TYPE_EDGE_FALLING>;
++              interrupt-controller;
++              #interrupt-cells = <2>;
++              gpio-controller;
++              #gpio-cells = <2>;
++      };
++
++      current-sensor@40 {
++              compatible = "ti,ina220";
++              reg = <0x40>;
++              shunt-resistor = <2000>;
++      };
+ };
+ &sata {
diff --git a/target/linux/layerscape/patches-5.4/901-fix_irq_type_of_pca953x.patch b/target/linux/layerscape/patches-5.4/901-fix_irq_type_of_pca953x.patch
new file mode 100644 (file)
index 0000000..a00a240
--- /dev/null
@@ -0,0 +1,28 @@
+From 12de4b5e7cbcd193d5abb753ca511fe8f2236846 Mon Sep 17 00:00:00 2001
+From: Pawel Dembicki <paweldembicki@gmail.com>
+Date: Fri, 13 Nov 2020 07:30:03 +0100
+Subject: [PATCH 1/1] gpio-pca953x: hack: Allow to use falling trigger
+
+Gpio-mpc8xxx driver of Layerscape gpio support only edge interrupts.
+Gpio-pca953x allow only low state trigger. This hack fix the problem.
+
+Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
+---
+
+--- a/drivers/gpio/gpio-pca953x.c
++++ b/drivers/gpio/gpio-pca953x.c
+@@ -879,10 +879,12 @@ static int pca953x_irq_setup(struct pca9
+       for (i = 0; i < NBANK(chip); i++)
+               chip->irq_stat[i] &= reg_direction[i];
+       mutex_init(&chip->irq_lock);
+-
++      /* gpio-mpc8xxx driver of Layerscape gpio support only edge interrupts.
++       * This hack fix the problem.
++       */
+       ret = devm_request_threaded_irq(&client->dev, client->irq,
+                                       NULL, pca953x_irq_handler,
+-                                      IRQF_TRIGGER_LOW | IRQF_ONESHOT |
++                                      IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+                                       IRQF_SHARED,
+                                       dev_name(&client->dev), chip);
+       if (ret) {