[PATCH 1/2] sh: mach-x3proto: add software node for GPIO controller

Dmitry Torokhov <[email protected]> Sat, 04 Jul 2026 22:04:37 -0700
Newsgroups org.kernel.vger.linux-sh,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
We want to convert the legacy gpio-keys platform device on the SH-X3
Prototype board to use software nodes. To do this properly and allow
referencing the GPIO controller by address rather than relying on
name-based matching (which is being removed from the gpiolib core),
we need to associate the GPIO controller with a software node.

Introduce x3proto_gpiochip_node, register it, and associate it with
x3proto_gpio_chip.

Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <[email protected]>
---
 arch/sh/boards/mach-x3proto/gpio.c           | 15 ++++++++++++++-
 arch/sh/include/mach-x3proto/mach/hardware.h |  2 ++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/arch/sh/boards/mach-x3proto/gpio.c b/arch/sh/boards/mach-x3proto/gpio.c
index c13d51b29702..a09cafc782b4 100644
--- a/arch/sh/boards/mach-x3proto/gpio.c
+++ b/arch/sh/boards/mach-x3proto/gpio.c
@@ -18,6 +18,7 @@
 #include <linux/io.h>
 #include <mach/ilsel.h>
 #include <mach/hardware.h>
+#include <linux/property.h>
 
 #define KEYCTLR	0xb81c0000
 #define KEYOUTR	0xb81c0002
@@ -73,6 +74,10 @@ static void x3proto_gpio_irq_handler(struct irq_desc *desc)
 	chip->irq_unmask(data);
 }
 
+const struct software_node x3proto_gpiochip_node = {
+	.name = "x3proto-gpio",
+};
+
 struct gpio_chip x3proto_gpio_chip = {
 	.label			= "x3proto-gpio",
 	.direction_input	= x3proto_gpio_direction_input,
@@ -104,9 +109,15 @@ int __init x3proto_gpio_setup(void)
 	if (unlikely(ilsel < 0))
 		return ilsel;
 
+	ret = software_node_register(&x3proto_gpiochip_node);
+	if (ret)
+		goto err_gpio;
+
+	x3proto_gpio_chip.fwnode = software_node_fwnode(&x3proto_gpiochip_node);
+
 	ret = gpiochip_add_data(&x3proto_gpio_chip, NULL);
 	if (unlikely(ret))
-		goto err_gpio;
+		goto err_swnode;
 
 	x3proto_irq_domain = irq_domain_create_linear(NULL, NR_BASEBOARD_GPIOS,
 						   &x3proto_gpio_irq_ops, NULL);
@@ -127,6 +138,8 @@ int __init x3proto_gpio_setup(void)
 err_irq:
 	gpiochip_remove(&x3proto_gpio_chip);
 	ret = 0;
+err_swnode:
+	software_node_unregister(&x3proto_gpiochip_node);
 err_gpio:
 	synchronize_irq(ilsel);
 
diff --git a/arch/sh/include/mach-x3proto/mach/hardware.h b/arch/sh/include/mach-x3proto/mach/hardware.h
index 57ea4a5cca35..1ee5a404973c 100644
--- a/arch/sh/include/mach-x3proto/mach/hardware.h
+++ b/arch/sh/include/mach-x3proto/mach/hardware.h
@@ -3,10 +3,12 @@
 #define __MACH_X3PROTO_HARDWARE_H
 
 struct gpio_chip;
+struct software_node;
 
 /* arch/sh/boards/mach-x3proto/gpio.c */
 int x3proto_gpio_setup(void);
 extern struct gpio_chip x3proto_gpio_chip;
+extern const struct software_node x3proto_gpiochip_node;
 
 #define NR_BASEBOARD_GPIOS	16
 

-- 
2.55.0.rc0.799.gd6f94ed593-goog