[openwrt/openwrt] layerscape: add i2c peripherials on LS1012A-RDB

LEDE Commits lede-commits at lists.infradead.org
Mon Nov 23 16:53:45 EST 2020


ynezz pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/4dc27a026b7e308477adecbdf8e6da58e1d57716

commit 4dc27a026b7e308477adecbdf8e6da58e1d57716
Author: Pawel Dembicki <paweldembicki at gmail.com>
AuthorDate: Tue Oct 27 09:52:31 2020 +0100

    layerscape: add i2c peripherials on LS1012A-RDB
    
    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 at gmail.com>
---
 target/linux/layerscape/armv8_64b/config-5.4       |   3 +
 target/linux/layerscape/image/armv8_64b.mk         |   3 +
 ...900-layerscape_fix_support_of_LS1012A-RDB.patch | 107 +++++++++++++++++++++
 .../patches-5.4/901-fix_irq_type_of_pca953x.patch  |  28 ++++++
 4 files changed, 141 insertions(+)

diff --git a/target/linux/layerscape/armv8_64b/config-5.4 b/target/linux/layerscape/armv8_64b/config-5.4
index 6da7ff01a5..8c398f4a2b 100644
--- a/target/linux/layerscape/armv8_64b/config-5.4
+++ b/target/linux/layerscape/armv8_64b/config-5.4
@@ -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
diff --git a/target/linux/layerscape/image/armv8_64b.mk b/target/linux/layerscape/image/armv8_64b.mk
index bedf272f79..264f7dfd84 100644
--- a/target/linux/layerscape/image/armv8_64b.mk
+++ b/target/linux/layerscape/image/armv8_64b.mk
@@ -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
index 0000000000..bcad654e5c
--- /dev/null
+++ b/target/linux/layerscape/patches-5.4/900-layerscape_fix_support_of_LS1012A-RDB.patch
@@ -0,0 +1,107 @@
+From 650480191492845c8eb7e0c2e5b1e37cabc59eff Mon Sep 17 00:00:00 2001
+From: Pawel Dembicki <paweldembicki at 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 at 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 at 1e {
++		compatible = "nxp,fxos8700";
++		reg = <0x1e>;
++		interrupt-parent = <&gpio26>;
++		interrupts = <13 IRQ_TYPE_EDGE_RISING>;
++		interrupt-names = "INT1";
++	};
++
++	gyroscope at 20 {
++		compatible = "nxp,fxas21002c";
++		reg = <0x20>;
++		vdd-supply = <&dummy3v3>;
++		vddio-supply = <&dummy1v8>;
++	};
++
++	gpio at 24 {
++		compatible = "nxp,pcal9555a";
++		reg = <0x24>;
++		gpio-controller;
++		#gpio-cells = <2>;
++	};
++
++	gpio25: gpio at 25 {
++		compatible = "nxp,pcal9555a";
++		reg = <0x25>;
++		gpio-controller;
++		#gpio-cells = <2>;
++	};
++
++	gpio26: gpio at 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 at 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
index 0000000000..a00a240135
--- /dev/null
+++ b/target/linux/layerscape/patches-5.4/901-fix_irq_type_of_pca953x.patch
@@ -0,0 +1,28 @@
+From 12de4b5e7cbcd193d5abb753ca511fe8f2236846 Mon Sep 17 00:00:00 2001
+From: Pawel Dembicki <paweldembicki at 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 at 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) {



More information about the lede-commits mailing list