diff mbox series

[09/17] MIPS: loongson32: Convert GPIO platform device to DT

Message ID 20230729134318.1694467-10-keguang.zhang@gmail.com (mailing list archive)
State New
Headers show
Series MIPS: loongson32: Convert all platform devices to DT | expand

Commit Message

Keguang Zhang July 29, 2023, 1:43 p.m. UTC
Add GPIO device nodes for Loongson-1 boards,
and drop the legacy platform devices and data accordingly.

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
 arch/mips/boot/dts/loongson/loongson1.dtsi  | 16 ++++++++++
 arch/mips/boot/dts/loongson/loongson1b.dtsi | 10 ++++++
 arch/mips/boot/dts/loongson/loongson1c.dtsi | 35 +++++++++++++++++++++
 arch/mips/loongson32/common/platform.c      | 31 ------------------
 arch/mips/loongson32/ls1b/board.c           |  2 --
 5 files changed, 61 insertions(+), 33 deletions(-)
diff mbox series

Patch

diff --git a/arch/mips/boot/dts/loongson/loongson1.dtsi b/arch/mips/boot/dts/loongson/loongson1.dtsi
index 48bb786bbf10..abe8170fa1b1 100644
--- a/arch/mips/boot/dts/loongson/loongson1.dtsi
+++ b/arch/mips/boot/dts/loongson/loongson1.dtsi
@@ -72,6 +72,22 @@  intc3: interrupt-controller@1fd01088 {
 			interrupts = <5>;
 		};
 
+		gpio0: gpio@1fd010c0 {
+			compatible = "loongson,ls1x-gpio";
+			reg = <0x1fd010c0 0x4>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio1: gpio@1fd010c4 {
+			compatible = "loongson,ls1x-gpio";
+			reg = <0x1fd010c4 0x4>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
 		gmac0: ethernet@1fe10000 {
 			compatible = "snps,dwmac-3.70a";
 			reg = <0x1fe10000 0x10000>;
diff --git a/arch/mips/boot/dts/loongson/loongson1b.dtsi b/arch/mips/boot/dts/loongson/loongson1b.dtsi
index 42b96c557660..7010d3f3511b 100644
--- a/arch/mips/boot/dts/loongson/loongson1b.dtsi
+++ b/arch/mips/boot/dts/loongson/loongson1b.dtsi
@@ -10,6 +10,8 @@  / {
 	aliases {
 		ethernet0 = &gmac0;
 		ethernet1 = &gmac1;
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
 	};
 
 	cpus {
@@ -110,6 +112,14 @@  phy1: ethernet-phy@0 {
 	};
 };
 
+&gpio0 {
+	ngpios = <31>;
+};
+
+&gpio1 {
+	ngpios = <30>;
+};
+
 &gmac0 {
 	interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
 
diff --git a/arch/mips/boot/dts/loongson/loongson1c.dtsi b/arch/mips/boot/dts/loongson/loongson1c.dtsi
index 5b3e0f9280f6..a5bc2c5093ca 100644
--- a/arch/mips/boot/dts/loongson/loongson1c.dtsi
+++ b/arch/mips/boot/dts/loongson/loongson1c.dtsi
@@ -7,6 +7,13 @@ 
 #include "loongson1.dtsi"
 
 / {
+	aliases {
+		gpio0 = &gpio0;
+		gpio1 = &gpio1;
+		gpio2 = &gpio2;
+		gpio3 = &gpio3;
+	};
+
 	cpus {
 		#address-cells = <1>;
 		#size-cells = <0>;
@@ -39,6 +46,34 @@  intc4: interrupt-controller@1fd010a0 {
 		interrupt-parent = <&cpu_intc>;
 		interrupts = <6>;
 	};
+
+	gpio2: gpio@1fd010c8 {
+		compatible = "loongson,ls1x-gpio";
+		reg = <0x1fd010c8 0x4>;
+
+		gpio-controller;
+		#gpio-cells = <2>;
+
+		ngpios = <32>;
+	};
+
+	gpio3: gpio@1fd010cc {
+		compatible = "loongson,ls1x-gpio";
+		reg = <0x1fd010cc 0x4>;
+
+		gpio-controller;
+		#gpio-cells = <2>;
+
+		ngpios = <32>;
+	};
+};
+
+&gpio0 {
+	ngpios = <32>;
+};
+
+&gpio1 {
+	ngpios = <32>;
 };
 
 &gmac0 {
diff --git a/arch/mips/loongson32/common/platform.c b/arch/mips/loongson32/common/platform.c
index 817518531b9b..37302bcfb9ab 100644
--- a/arch/mips/loongson32/common/platform.c
+++ b/arch/mips/loongson32/common/platform.c
@@ -16,37 +16,6 @@ 
 #include <nand.h>
 #include <irq.h>
 
-/* GPIO */
-static struct resource ls1x_gpio0_resources[] = {
-	[0] = {
-		.start	= LS1X_GPIO0_BASE,
-		.end	= LS1X_GPIO0_BASE + SZ_4 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-};
-
-struct platform_device ls1x_gpio0_pdev = {
-	.name		= "ls1x-gpio",
-	.id		= 0,
-	.num_resources	= ARRAY_SIZE(ls1x_gpio0_resources),
-	.resource	= ls1x_gpio0_resources,
-};
-
-static struct resource ls1x_gpio1_resources[] = {
-	[0] = {
-		.start	= LS1X_GPIO1_BASE,
-		.end	= LS1X_GPIO1_BASE + SZ_4 - 1,
-		.flags	= IORESOURCE_MEM,
-	},
-};
-
-struct platform_device ls1x_gpio1_pdev = {
-	.name		= "ls1x-gpio",
-	.id		= 1,
-	.num_resources	= ARRAY_SIZE(ls1x_gpio1_resources),
-	.resource	= ls1x_gpio1_resources,
-};
-
 /* USB EHCI */
 static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
 
diff --git a/arch/mips/loongson32/ls1b/board.c b/arch/mips/loongson32/ls1b/board.c
index f23e4e5c96ee..baadc524cc88 100644
--- a/arch/mips/loongson32/ls1b/board.c
+++ b/arch/mips/loongson32/ls1b/board.c
@@ -35,8 +35,6 @@  static const struct gpio_led_platform_data ls1x_led_pdata __initconst = {
 
 static struct platform_device *ls1b_platform_devices[] __initdata = {
 	&ls1x_ehci_pdev,
-	&ls1x_gpio0_pdev,
-	&ls1x_gpio1_pdev,
 	&ls1x_rtc_pdev,
 	&ls1x_wdt_pdev,
 };