[OpenWrt-Devel] [PATCH v2] ath79: use gpio_hog instead of gpio-export

Adrian Schmutzler freifunk at adrianschmutzler.de
Tue Nov 5 10:12:02 EST 2019


From: Birger Koblitz <mail at birger-koblitz.de>

The gpio-export functionality is a hack for missing kernel
functionality, which was rejected in upstream kernel long time ago,
for details see this email
http://lists.infradead.org/pipermail/openwrt-devel/2019-February/015772.html,
discussion in PR#1366 or
https://github.com/openwrt/openwrt/pull/1814#issuecomment-462942022.

This patch converts all DTS files with settings that normally do
not need user interaction, e.g. power for external USB ports, to
gpio_hog. The only remaining gpio-export will be in
qca9558_openmesh_om5p-ac-v2.dts

Signed-off-by: Birger Koblitz <mail at birger-koblitz.de>
[rebased, renamed nodes, do not change openmesh, removed redundant
status=okay, updated commit message]
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>

---

This is a resubmission of the patch initially created by Birger
Koblitz. It should be limited to conversion that do not require
the user setting the value.
---
 .../dts/ar7161_buffalo_wzr-hp-ag300h.dts      | 19 ++++++------
 .../ath79/dts/ar7241_tplink_tl-mr3x20.dtsi    | 15 +++++-----
 .../ath79/dts/ar7241_tplink_tl-wr842n-v1.dts  | 19 +++++-------
 .../ath79/dts/ar7242_buffalo_wzr-bhr.dtsi     | 20 ++++++-------
 .../dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts  | 20 ++++++-------
 .../ath79/dts/ar9341_tplink_tl-wr842n-v2.dts  | 19 ++++++------
 .../ath79/dts/qca9558_devolo_dvl1750e.dts     | 15 +++++-----
 .../ath79/dts/qca9558_tplink_archer-c7.dtsi   | 30 +++++++++----------
 .../dts/qca9558_tplink_tl-wdr4900-v2.dts      | 28 +++++++++--------
 .../ath79/dts/qca9558_tplink_tl-wr1043nd.dtsi | 20 +++++--------
 .../ath79/dts/qca9561_tplink_archer-c5x.dtsi  | 30 +++++++++----------
 .../ath79/dts/qca9563_dlink_dir-859-a1.dts    | 20 +++++--------
 .../ath79/dts/qca9563_tplink_archer-c7-v4.dts | 30 +++++++++----------
 .../dts/qca9563_tplink_archer-x7-v5.dtsi      | 17 +++++------
 .../dts/qca9563_tplink_tl-wr1043nd-v4.dts     | 16 +++++-----
 15 files changed, 145 insertions(+), 173 deletions(-)

diff --git a/target/linux/ath79/dts/ar7161_buffalo_wzr-hp-ag300h.dts b/target/linux/ath79/dts/ar7161_buffalo_wzr-hp-ag300h.dts
index f51bc0f771..23f1845876 100644
--- a/target/linux/ath79/dts/ar7161_buffalo_wzr-hp-ag300h.dts
+++ b/target/linux/ath79/dts/ar7161_buffalo_wzr-hp-ag300h.dts
@@ -120,16 +120,6 @@
 		};
 	};
 
-	gpio-export {
-		compatible = "gpio-export";
-
-		gpio_usb_power {
-			gpio-export,name = "buffalo:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
-		};
-	};
-
 	flash {
 		compatible = "mtd-concat";
 
@@ -172,6 +162,15 @@
 	};
 };
 
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "buffalo:power:usb";
+		gpios = <2 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
+};
+
 &usb_phy {
 	status = "okay";
 };
diff --git a/target/linux/ath79/dts/ar7241_tplink_tl-mr3x20.dtsi b/target/linux/ath79/dts/ar7241_tplink_tl-mr3x20.dtsi
index 04403637b6..333ee17ceb 100644
--- a/target/linux/ath79/dts/ar7241_tplink_tl-mr3x20.dtsi
+++ b/target/linux/ath79/dts/ar7241_tplink_tl-mr3x20.dtsi
@@ -3,15 +3,14 @@
 #include "ar7241_tplink.dtsi"
 
 / {
-	gpio-export {
-		compatible = "gpio-export";
-		#size-cells = <0>;
+};
 
-		gpio_usb_power {
-			gpio-export,name = "tp-link:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
-		};
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb";
+		gpios = <6 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
diff --git a/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts b/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts
index 162b5f2838..ee468df244 100644
--- a/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts
+++ b/target/linux/ath79/dts/ar7241_tplink_tl-wr842n-v1.dts
@@ -66,15 +66,16 @@
 			linux,default-trigger = "phy0tpt";
 		};
 	};
+};
 
-	gpio-export {
-		compatible = "gpio-export";
+&gpio {
+	status = "okay";
 
-		gpio_usb_power {
-			gpio-export,name = "tp-link:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 6 GPIO_ACTIVE_HIGH>;
-		};
+	usb_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb";
+		gpios = <6 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
@@ -155,10 +156,6 @@
 	mtd-mac-address-increment = <1>;
 };
 
-&gpio {
-	status = "okay";
-};
-
 &uart {
 	status = "okay";
 };
diff --git a/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi b/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi
index 3b5a4dd13d..d7632faf5c 100644
--- a/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi
+++ b/target/linux/ath79/dts/ar7242_buffalo_wzr-bhr.dtsi
@@ -57,17 +57,6 @@
 		};
 	};
 
-	gpio-export {
-		compatible = "gpio-export";
-		#size-cells = <0>;
-
-		gpio_usb_power {
-			gpio-export,name = "buffalo:usb-power";
-			gpio-export,output = <1>;
-			gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
-		};
-	};
-
 	virtual_flash {
 		compatible = "mtd-concat";
 		devices = <&flash0 &flash1>;
@@ -109,6 +98,15 @@
 	};
 };
 
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "buffalo:usb-power";
+		gpios = <16 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
+};
+
 &spi {
 	status = "okay";
 	cs-gpios = <0>, <0>;
diff --git a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts
index 8ac4df2194..2b30b7830b 100644
--- a/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts
+++ b/target/linux/ath79/dts/ar7242_buffalo_wzr-hp-g302h-a1a0.dts
@@ -109,17 +109,6 @@
 		};
 	};
 
-	gpio-export {
-		compatible = "gpio-export";
-		#size-cells = <0>;
-
-		gpio_usb_power {
-			gpio-export,name = "buffalo:usb-power";
-			gpio-export,output = <1>;
-			gpios = <&gpio 13 GPIO_ACTIVE_HIGH>;
-		};
-	};
-
 	virtual_flash {
 		compatible = "mtd-concat";
 		devices = <&flash0 &flash1>;
@@ -161,6 +150,15 @@
 	};
 };
 
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "buffalo:usb-power";
+		gpios = <13 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
+};
+
 &spi {
 	status = "okay";
 	cs-gpios = <0>, <0>;
diff --git a/target/linux/ath79/dts/ar9341_tplink_tl-wr842n-v2.dts b/target/linux/ath79/dts/ar9341_tplink_tl-wr842n-v2.dts
index 86a316b518..1df0e27cb2 100644
--- a/target/linux/ath79/dts/ar9341_tplink_tl-wr842n-v2.dts
+++ b/target/linux/ath79/dts/ar9341_tplink_tl-wr842n-v2.dts
@@ -6,16 +6,6 @@
 / {
 	model = "TP-Link TL-WR842N/ND v2";
 	compatible = "tplink,tl-wr842n-v2", "qca,ar9341";
-
-	gpio-export {
-		compatible = "gpio-export";
-
-		gpio_usb_power {
-			gpio-export,name = "tp-link:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
-		};
-	};
 };
 
 &keys {
@@ -36,6 +26,15 @@
 	};
 };
 
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb";
+		gpios = <4 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
+};
+
 &spi {
 	num-cs = <1>;
 
diff --git a/target/linux/ath79/dts/qca9558_devolo_dvl1750e.dts b/target/linux/ath79/dts/qca9558_devolo_dvl1750e.dts
index 3d25004c40..e790cf0df4 100644
--- a/target/linux/ath79/dts/qca9558_devolo_dvl1750e.dts
+++ b/target/linux/ath79/dts/qca9558_devolo_dvl1750e.dts
@@ -53,15 +53,14 @@
 		compatible = "gpio-beeper";
 		gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
 	};
+};
 
-	gpio_export {
-		compatible = "gpio-export";
-
-		gpio_usb_power {
-			gpio-export,name = "devolo:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
-		};
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "devolo:power:usb";
+		gpios = <11 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
diff --git a/target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi b/target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi
index c77613dad6..fb38f35dc1 100644
--- a/target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi
+++ b/target/linux/ath79/dts/qca9558_tplink_archer-c7.dtsi
@@ -64,22 +64,6 @@
 			debounce-interval = <60>;
 		};
 	};
-
-	gpio-export {
-		compatible = "gpio-export";
-
-		gpio_usb1_power {
-			gpio-export,name = "tp-link:power:usb1";
-			gpio-export,output = <1>;
-			gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
-		};
-
-		gpio_usb2_power {
-			gpio-export,name = "tp-link:power:usb2";
-			gpio-export,output = <1>;
-			gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
-		};
-	};
 };
 
 &pcie1 {
@@ -92,6 +76,20 @@
 
 &gpio {
 	status = "okay";
+
+	usb1_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb1";
+		gpios = <21 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
+
+	usb2_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb2";
+		gpios = <22 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
 };
 
 &usb_phy0 {
diff --git a/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts b/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts
index 77166b8bfe..470b742578 100644
--- a/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts
+++ b/target/linux/ath79/dts/qca9558_tplink_tl-wdr4900-v2.dts
@@ -57,7 +57,7 @@
 		};
 	};
 
-	 ath9k-leds {
+	ath9k-leds {
 		compatible = "gpio-leds";
 
 		wlan5g {
@@ -77,21 +77,23 @@
 			debounce-interval = <60>;
 		};
 	};
+};
 
-	gpio-export {
-		compatible = "gpio-export";
+&gpio {
+	status = "okay";
 
-		gpio_usb1_power {
-			gpio-export,name = "tp-link:power:usb1";
-			gpio-export,output = <1>;
-			gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
-		};
+	usb1_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb1";
+		gpios = <21 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
 
-		gpio_usb2_power {
-			gpio-export,name = "tp-link:power:usb2";
-			gpio-export,output = <1>;
-			gpios = <&gpio 22 GPIO_ACTIVE_HIGH>;
-		};
+	usb2_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb2";
+		gpios = <22 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
diff --git a/target/linux/ath79/dts/qca9558_tplink_tl-wr1043nd.dtsi b/target/linux/ath79/dts/qca9558_tplink_tl-wr1043nd.dtsi
index 1092250f02..f6d34ab3ff 100644
--- a/target/linux/ath79/dts/qca9558_tplink_tl-wr1043nd.dtsi
+++ b/target/linux/ath79/dts/qca9558_tplink_tl-wr1043nd.dtsi
@@ -64,16 +64,16 @@
 			debounce-interval = <60>;
 		};
 	};
+};
 
-	gpio-export {
-		compatible = "gpio-export";
-		#size-cells = <0>;
+&gpio {
+	status = "okay";
 
-		gpio_usb_power {
-			gpio-export,name = "tp-link:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 21 GPIO_ACTIVE_HIGH>;
-		};
+	usb_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb";
+		gpios = <21 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
@@ -81,10 +81,6 @@
 	status = "okay";
 };
 
-&gpio {
-	status = "okay";
-};
-
 &usb_phy0 {
 	status = "okay";
 };
diff --git a/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi b/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi
index ddf92108b5..53329f2268 100644
--- a/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi
+++ b/target/linux/ath79/dts/qca9561_tplink_archer-c5x.dtsi
@@ -103,22 +103,6 @@
 			gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
 		};
 	};
-
-	gpio-export {
-		compatible = "gpio-export";
-
-		gpio_shift_register_oe {
-			gpio-export,name = "tp-link:oe:sr";
-			gpio-export,output = <0>;
-			gpios = <&gpio 16 GPIO_ACTIVE_HIGH>;
-		};
-
-		gpio_shift_register_reset {
-			gpio-export,name = "tp-link:reset:sr";
-			gpio-export,output = <1>;
-			gpios = <&gpio 19 GPIO_ACTIVE_HIGH>;
-		};
-	};
 };
 
 &uart {
@@ -127,6 +111,20 @@
 
 &gpio {
 	status = "okay";
+
+	shift_register_oe {
+		gpio-hog;
+		line-name = "tp-link:oe:sr";
+		gpios = <16 GPIO_ACTIVE_HIGH>;
+		output-low;
+	};
+
+	shift_register_reset {
+		gpio-hog;
+		line-name = "tp-link:reset:sr";
+		gpios = <19 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
 };
 
 &pcie {
diff --git a/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts b/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts
index a17d9f263a..63baa376c6 100644
--- a/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts
+++ b/target/linux/ath79/dts/qca9563_dlink_dir-859-a1.dts
@@ -61,16 +61,16 @@
 			debounce-interval = <60>;
 		};
 	};
+};
 
-	gpio-export {
-		compatible = "gpio-export";
-		#size-cells = <0>;
+&gpio {
+	status = "okay";
 
-		gpio_switch_reset {
-			gpio-export,name = "dir-859-a1:reset:switch";
-			gpio-export,output = <1>;
-			gpios = <&gpio 11 GPIO_ACTIVE_HIGH>;
-		};
+	switch_reset {
+		gpio-hog;
+		line-name = "dir-859-a1:reset:switch";
+		gpios = <11 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
@@ -78,10 +78,6 @@
 	status = "okay";
 };
 
-&gpio {
-	status = "okay";
-};
-
 &pcie {
 	status = "okay";
 };
diff --git a/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts b/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts
index 470a8e6bf9..66083aa7f9 100644
--- a/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts
+++ b/target/linux/ath79/dts/qca9563_tplink_archer-c7-v4.dts
@@ -42,22 +42,6 @@
 		};
 	};
 
-	gpio-export {
-		compatible = "gpio-export";
-
-		gpio_shift_register_oe {
-			gpio-export,name = "tp-link:oe:sr";
-			gpio-export,output = <0>;
-			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;	// 74HC595 /OE (Output Enable)
-		};
-
-		gpio_shift_register_reset {
-			gpio-export,name = "tp-link:reset:sr";
-			gpio-export,output = <1>;
-			gpios = <&gpio 21 GPIO_ACTIVE_LOW>;	// 74HC595 /SRCLR (Serial Clear)
-		};
-	};
-
 	leds {
 		compatible = "gpio-leds";
 
@@ -158,6 +142,20 @@
 
 &gpio {
 	status = "okay";
+
+	shift_register_oe { // 74HC595 /OE
+		gpio-hog;
+		line-name = "tp-link:oe:sr";
+		gpios = <1 GPIO_ACTIVE_LOW>;
+		output-low;
+	};
+
+	shift_register_reset { // 74HC595 /SRCLR
+		gpio-hog;
+		line-name = "tp-link:reset:sr";
+		gpios = <21 GPIO_ACTIVE_LOW>;
+		output-high;
+	};
 };
 
 &usb_phy0 {
diff --git a/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi b/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi
index 2e66e0f03e..64115c4248 100644
--- a/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi
+++ b/target/linux/ath79/dts/qca9563_tplink_archer-x7-v5.dtsi
@@ -93,16 +93,6 @@
 			debounce-interval = <60>;
 		};
 	};
-
-	gpio-export {
-		compatible = "gpio-export";
-
-		gpio_usb_power {
-			gpio-export,name = "tp-link:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 19 GPIO_ACTIVE_HIGH>;
-		};
-	};
 };
 
 &pcie {
@@ -115,6 +105,13 @@
 
 &gpio {
 	status = "okay";
+
+	usb_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb";
+		gpios = <19 GPIO_ACTIVE_HIGH>;
+		output-high;
+	};
 };
 
 &usb_phy0 {
diff --git a/target/linux/ath79/dts/qca9563_tplink_tl-wr1043nd-v4.dts b/target/linux/ath79/dts/qca9563_tplink_tl-wr1043nd-v4.dts
index 07a7409886..45ee0c21c7 100644
--- a/target/linux/ath79/dts/qca9563_tplink_tl-wr1043nd-v4.dts
+++ b/target/linux/ath79/dts/qca9563_tplink_tl-wr1043nd-v4.dts
@@ -6,16 +6,14 @@
 / {
 	compatible = "tplink,tl-wr1043nd-v4", "qca,qca9563";
 	model = "TP-Link TL-WR1043ND v4";
+};
 
-	gpio-export {
-		compatible = "gpio-export";
-		#size-cells = <0>;
-
-		gpio_usb_power {
-			gpio-export,name = "tp-link:power:usb";
-			gpio-export,output = <1>;
-			gpios = <&gpio 8 GPIO_ACTIVE_HIGH>;
-		};
+&gpio {
+	usb_power {
+		gpio-hog;
+		line-name = "tp-link:power:usb";
+		gpios = <8 GPIO_ACTIVE_HIGH>;
+		output-high;
 	};
 };
 
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list