* [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API
@ 2026-09-30 4:57 Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode Dmitry Torokhov
` (5 more replies)
0 siblings, 6 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 4:57 UTC (permalink / raw)
To: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
This series of patches converts rsk7203 to use static device properties
for its devices, including gpio-keys and gpio-leds, and removing
dependency on legacy gpio API (in favor of gpiod API).
To configure pin functions the board is switched to use gpio-hogs, as
doing full conversion to pinmux is too challenging without access to
hardware.
Changes in v3:
- Avoided using inline compound literals for property entries in
software node initializers to fix compilation errors with older GCC
compilers (GCC < 14).
- Collected Acked-by and Reviewed-by trailers from Bartosz Golaszewski
and Linus Walleij.
Changes in v2:
- Added a patch to isolate the function gpiochip from the parent fwnode
to prevent ambiguous property lookups.
- Added a patch attaching a software node to the main PFC gpiochip device.
- Adjusted the board setup to use the PFC software node for LEDs and
GPIO keys instead of creating a standalone node.
- Added support to sh-pfc for configuring the secondary "function"
gpiochip via a "functions" child software node.
- Converted board pin configuration from legacy gpio_request() to GPIO
hogs, using postcore_initcall to ensure nodes are available during
driver probe.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
Dmitry Torokhov (5):
pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode
sh: pfc: attach software node to the GPIO chip
sh: mach-rsk: rsk7203: use static device properties for LEDs and GPIO buttons
pinctrl: renesas: gpio: support software nodes for function GPIOs
sh: mach-rsk: rsk7203: convert pin configuration to using software nodes
arch/sh/boards/mach-rsk/devices-rsk7203.c | 314 ++++++++++++++++++++++--------
arch/sh/include/cpu-common/cpu/pfc.h | 3 +
arch/sh/kernel/cpu/pfc.c | 20 +-
drivers/pinctrl/renesas/gpio.c | 28 +++
4 files changed, 281 insertions(+), 84 deletions(-)
---
base-commit: 6474fa070f2b8013b4b87350b775b8c3be6e8aac
change-id: 20260310-rsk7203-properties-82bf2c12b985
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
@ 2026-09-30 4:58 ` Dmitry Torokhov
2026-09-30 7:05 ` Geert Uytterhoeven
2026-09-30 4:58 ` [PATCH v3 2/5] sh: pfc: attach software node to the GPIO chip Dmitry Torokhov
` (4 subsequent siblings)
5 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 4:58 UTC (permalink / raw)
To: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
The sh-pfc driver registers two separate gpiochip instances: one for
real GPIOs and another for function GPIOs. Since both share the same
parent platform device, gpiolib's fallback logic causes both chips to
share the same firmware node (fwnode).
This causes ambiguity when using software nodes to describe GPIOs, as
gpiolib may apply hogs meant for one chip to the other if they share the
same node.
Explicitly set gc->fwnode to ERR_PTR(-ENODEV) for the function GPIO
chip. This satisfies gpiolib's check for an existing fwnode and prevents
it from falling back to the parent device's node, while ensuring that no
actual properties or hogs are found on the function chip unless
explicitly assigned later.
Assisted-by: LLM
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/pinctrl/renesas/gpio.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/pinctrl/renesas/gpio.c b/drivers/pinctrl/renesas/gpio.c
index 2293af642849..4e59dadb7364 100644
--- a/drivers/pinctrl/renesas/gpio.c
+++ b/drivers/pinctrl/renesas/gpio.c
@@ -278,6 +278,12 @@ static int gpio_function_setup(struct sh_pfc_chip *chip)
gc->request = gpio_function_request;
+ /*
+ * Explicitly mask the parent's fwnode to prevent gpiolib from
+ * reusing it for function GPIOs.
+ */
+ gc->fwnode = ERR_PTR(-ENODEV);
+
gc->label = pfc->info->name;
gc->owner = THIS_MODULE;
gc->base = pfc->nr_gpio_pins;
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 2/5] sh: pfc: attach software node to the GPIO chip
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode Dmitry Torokhov
@ 2026-09-30 4:58 ` Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 3/5] sh: mach-rsk: rsk7203: use static device properties for LEDs and GPIO buttons Dmitry Torokhov
` (3 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 4:58 UTC (permalink / raw)
To: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
With commit e5d527be7e69 ("gpio: swnode: don't use the swnode's name as
the key for GPIO lookup") gpiolib requires that firmware nodes from the
GPIO references to match firmware node in gpiochip structure.
Define a software node for the pfc gpiochip so that it can be referenced
by boards using static device properties.
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
arch/sh/include/cpu-common/cpu/pfc.h | 3 +++
arch/sh/kernel/cpu/pfc.c | 20 ++++++++++++++------
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/arch/sh/include/cpu-common/cpu/pfc.h b/arch/sh/include/cpu-common/cpu/pfc.h
index 879d2c9da537..d57e38c05bdb 100644
--- a/arch/sh/include/cpu-common/cpu/pfc.h
+++ b/arch/sh/include/cpu-common/cpu/pfc.h
@@ -11,6 +11,9 @@
#include <linux/types.h>
struct resource;
+struct software_node;
+
+extern const struct software_node pfc_gpiochip_node;
int sh_pfc_register(const char *name,
struct resource *resource, u32 num_resources);
diff --git a/arch/sh/kernel/cpu/pfc.c b/arch/sh/kernel/cpu/pfc.c
index 062056ede88d..5a8d804d607b 100644
--- a/arch/sh/kernel/cpu/pfc.c
+++ b/arch/sh/kernel/cpu/pfc.c
@@ -5,21 +5,29 @@
* Copyright (C) 2012 Renesas Solutions Corp.
*/
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/platform_device.h>
+#include <linux/property.h>
#include <cpu/pfc.h>
-static struct platform_device sh_pfc_device = {
- .id = -1,
+const struct software_node pfc_gpiochip_node = {
+ .name = "sh-pfc",
};
int __init sh_pfc_register(const char *name,
struct resource *resource, u32 num_resources)
{
- sh_pfc_device.name = name;
- sh_pfc_device.num_resources = num_resources;
- sh_pfc_device.resource = resource;
+ struct platform_device_info pdev_info = {
+ .name = name,
+ .id = PLATFORM_DEVID_NONE,
+ .res = resource,
+ .num_res = num_resources,
+ .swnode = &pfc_gpiochip_node,
+ };
+ struct platform_device *pdev;
- return platform_device_register(&sh_pfc_device);
+ pdev = platform_device_register_full(&pdev_info);
+ return PTR_ERR_OR_ZERO(pdev);
}
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 3/5] sh: mach-rsk: rsk7203: use static device properties for LEDs and GPIO buttons
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 2/5] sh: pfc: attach software node to the GPIO chip Dmitry Torokhov
@ 2026-09-30 4:58 ` Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 4/5] pinctrl: renesas: gpio: support software nodes for function GPIOs Dmitry Torokhov
` (2 subsequent siblings)
5 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 4:58 UTC (permalink / raw)
To: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
Convert the board to use static device properties instead of platform
data to describe LEDs and GPIO-connected buttons on the board, so
that support for platform data can be removed from gpio-keys and other
drivers, unifying their behavior.
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
arch/sh/boards/mach-rsk/devices-rsk7203.c | 225 ++++++++++++++++++++----------
1 file changed, 152 insertions(+), 73 deletions(-)
diff --git a/arch/sh/boards/mach-rsk/devices-rsk7203.c b/arch/sh/boards/mach-rsk/devices-rsk7203.c
index e6b05d4588b7..8076c9d15f87 100644
--- a/arch/sh/boards/mach-rsk/devices-rsk7203.c
+++ b/arch/sh/boards/mach-rsk/devices-rsk7203.c
@@ -4,17 +4,19 @@
*
* Copyright (C) 2008 - 2010 Paul Mundt
*/
+#include <linux/err.h>
#include <linux/init.h>
#include <linux/types.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
#include <linux/smsc911x.h>
#include <linux/input.h>
+#include <linux/io.h>
#include <linux/gpio.h>
-#include <linux/gpio_keys.h>
-#include <linux/leds.h>
+#include <linux/gpio/machine.h>
+#include <linux/gpio/property.h>
#include <asm/machvec.h>
-#include <asm/io.h>
+#include <cpu/pfc.h>
#include <cpu/sh7203.h>
static struct smsc911x_platform_config smsc911x_config = {
@@ -37,92 +39,154 @@ static struct resource smsc911x_resources[] = {
},
};
-static struct platform_device smsc911x_device = {
- .name = "smsc911x",
- .id = -1,
- .num_resources = ARRAY_SIZE(smsc911x_resources),
- .resource = smsc911x_resources,
- .dev = {
- .platform_data = &smsc911x_config,
- },
+static const struct software_node rsk7203_gpio_leds_node = {
+ .name = "rsk7203-gpio-leds",
};
-static struct gpio_led rsk7203_gpio_leds[] = {
- {
- .name = "green",
- .gpio = GPIO_PE10,
- .active_low = 1,
- }, {
- .name = "orange",
- .default_trigger = "nand-disk",
- .gpio = GPIO_PE12,
- .active_low = 1,
- }, {
- .name = "red:timer",
- .default_trigger = "timer",
- .gpio = GPIO_PC14,
- .active_low = 1,
- }, {
- .name = "red:heartbeat",
- .default_trigger = "heartbeat",
- .gpio = GPIO_PE11,
- .active_low = 1,
- },
+static const struct property_entry rsk7203_green_led_props[] = {
+ PROPERTY_ENTRY_STRING("label", "green"),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PE10, GPIO_ACTIVE_LOW),
+ { }
};
-static struct gpio_led_platform_data rsk7203_gpio_leds_info = {
- .leds = rsk7203_gpio_leds,
- .num_leds = ARRAY_SIZE(rsk7203_gpio_leds),
+static const struct software_node rsk7203_green_led_node = {
+ .name = "green",
+ .parent = &rsk7203_gpio_leds_node,
+ .properties = rsk7203_green_led_props,
};
-static struct platform_device led_device = {
- .name = "leds-gpio",
- .id = -1,
- .dev = {
- .platform_data = &rsk7203_gpio_leds_info,
- },
+static const struct property_entry rsk7203_orange_led_props[] = {
+ PROPERTY_ENTRY_STRING("label", "orange"),
+ PROPERTY_ENTRY_STRING("linux,default-trigger", "nand-disk"),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PE12, GPIO_ACTIVE_LOW),
+ { }
};
-static struct gpio_keys_button rsk7203_gpio_keys_table[] = {
- {
- .code = BTN_0,
- .gpio = GPIO_PB0,
- .active_low = 1,
- .desc = "SW1",
- }, {
- .code = BTN_1,
- .gpio = GPIO_PB1,
- .active_low = 1,
- .desc = "SW2",
- }, {
- .code = BTN_2,
- .gpio = GPIO_PB2,
- .active_low = 1,
- .desc = "SW3",
- },
+static const struct software_node rsk7203_orange_led_node = {
+ .name = "orange",
+ .parent = &rsk7203_gpio_leds_node,
+ .properties = rsk7203_orange_led_props,
};
-static struct gpio_keys_platform_data rsk7203_gpio_keys_info = {
- .buttons = rsk7203_gpio_keys_table,
- .nbuttons = ARRAY_SIZE(rsk7203_gpio_keys_table),
- .poll_interval = 50, /* default to 50ms */
+static const struct property_entry rsk7203_red1_led_props[] = {
+ PROPERTY_ENTRY_STRING("label", "red:timer"),
+ PROPERTY_ENTRY_STRING("linux,default-trigger", "timer"),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PC14, GPIO_ACTIVE_LOW),
+ { }
};
-static struct platform_device keys_device = {
- .name = "gpio-keys-polled",
- .dev = {
- .platform_data = &rsk7203_gpio_keys_info,
- },
+static const struct software_node rsk7203_red1_led_node = {
+ .name = "red:timer",
+ .parent = &rsk7203_gpio_leds_node,
+ .properties = rsk7203_red1_led_props,
+};
+
+static const struct property_entry rsk7203_red2_led_props[] = {
+ PROPERTY_ENTRY_STRING("label", "red:heartbeat"),
+ PROPERTY_ENTRY_STRING("linux,default-trigger", "heartbeat"),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PE11, GPIO_ACTIVE_LOW),
+ { }
+};
+
+static const struct software_node rsk7203_red2_led_node = {
+ .name = "red:heartbeat",
+ .parent = &rsk7203_gpio_leds_node,
+ .properties = rsk7203_red2_led_props,
+};
+
+static const struct property_entry rsk7203_gpio_keys_props[] = {
+ PROPERTY_ENTRY_U32("poll-interval", 50),
+ { }
+};
+
+static const struct software_node rsk7203_gpio_keys_node = {
+ .name = "rsk7203-gpio-keys",
+ .properties = rsk7203_gpio_keys_props,
+};
+
+static const struct property_entry rsk7203_sw1_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", BTN_0),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PB0, GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_STRING("label", "SW1"),
+ { }
+};
+
+static const struct software_node rsk7203_sw1_key_node = {
+ .parent = &rsk7203_gpio_keys_node,
+ .properties = rsk7203_sw1_key_props,
};
-static struct platform_device *rsk7203_devices[] __initdata = {
- &smsc911x_device,
- &led_device,
- &keys_device,
+static const struct property_entry rsk7203_sw2_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", BTN_1),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PB1, GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_STRING("label", "SW2"),
+ { }
+};
+
+static const struct software_node rsk7203_sw2_key_node = {
+ .parent = &rsk7203_gpio_keys_node,
+ .properties = rsk7203_sw2_key_props,
+};
+
+static const struct property_entry rsk7203_sw3_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", BTN_2),
+ PROPERTY_ENTRY_GPIO("gpios", &pfc_gpiochip_node,
+ GPIO_PB2, GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_STRING("label", "SW3"),
+ { }
+};
+
+static const struct software_node rsk7203_sw3_key_node = {
+ .parent = &rsk7203_gpio_keys_node,
+ .properties = rsk7203_sw3_key_props,
+};
+
+static const struct software_node * const rsk7203_swnodes[] __initconst = {
+ &rsk7203_gpio_leds_node,
+ &rsk7203_green_led_node,
+ &rsk7203_orange_led_node,
+ &rsk7203_red1_led_node,
+ &rsk7203_red2_led_node,
+ &rsk7203_gpio_keys_node,
+ &rsk7203_sw1_key_node,
+ &rsk7203_sw2_key_node,
+ &rsk7203_sw3_key_node,
+ NULL
+};
+
+static const struct platform_device_info rsk7203_devices[] __initconst = {
+ {
+ .name = "smsc911x",
+ .id = PLATFORM_DEVID_NONE,
+ .res = smsc911x_resources,
+ .num_res = ARRAY_SIZE(smsc911x_resources),
+ .data = &smsc911x_config,
+ .size_data = sizeof(smsc911x_config),
+ },
+ {
+ .name = "leds-gpio",
+ .id = PLATFORM_DEVID_NONE,
+ .swnode = &rsk7203_gpio_leds_node,
+ },
+ {
+ .name = "gpio-keys-polled",
+ .id = PLATFORM_DEVID_NONE,
+ .swnode = &rsk7203_gpio_keys_node,
+ },
};
static int __init rsk7203_devices_setup(void)
{
+ struct platform_device *pd;
+ int error;
+ int i;
+
/* Select pins for SCIF0 */
gpio_request(GPIO_FN_TXD0, NULL);
gpio_request(GPIO_FN_RXD0, NULL);
@@ -131,7 +195,22 @@ static int __init rsk7203_devices_setup(void)
__raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
gpio_request(GPIO_FN_IRQ0_PB, NULL);
- return platform_add_devices(rsk7203_devices,
- ARRAY_SIZE(rsk7203_devices));
+ error = software_node_register_node_group(rsk7203_swnodes);
+ if (error) {
+ pr_err("failed to register software nodes: %d\n", error);
+ return error;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(rsk7203_devices); i++) {
+ pd = platform_device_register_full(&rsk7203_devices[i]);
+ error = PTR_ERR_OR_ZERO(pd);
+ if (error) {
+ pr_err("failed to create platform device %s: %d\n",
+ rsk7203_devices[i].name, error);
+ return error;
+ }
+ }
+
+ return 0;
}
device_initcall(rsk7203_devices_setup);
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 4/5] pinctrl: renesas: gpio: support software nodes for function GPIOs
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
` (2 preceding siblings ...)
2026-09-30 4:58 ` [PATCH v3 3/5] sh: mach-rsk: rsk7203: use static device properties for LEDs and GPIO buttons Dmitry Torokhov
@ 2026-09-30 4:58 ` Dmitry Torokhov
2026-09-30 7:06 ` Geert Uytterhoeven
2026-09-30 4:58 ` [PATCH v3 5/5] sh: mach-rsk: rsk7203: convert pin configuration to using software nodes Dmitry Torokhov
2026-09-30 7:23 ` [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Arnd Bergmann
5 siblings, 1 reply; 10+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 4:58 UTC (permalink / raw)
To: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
This patch extends the sh-pfc GPIO driver to support software-node-based
configuration for the secondary 'function' GPIO chip.
While the primary GPIO chip typically uses the firmware node attached to
the parent platform device, the secondary chip should target a specific
child node to avoid ambiguity when defining GPIO hogs or properties.
Update gpio_function_setup() to look for a child node named 'functions',
but only when the parent is a software node. This ensures the behavior
is restricted to legacy platforms being migrated to software nodes.
Assisted-by: LLM
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/pinctrl/renesas/gpio.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/renesas/gpio.c b/drivers/pinctrl/renesas/gpio.c
index 4e59dadb7364..b49a3e14da91 100644
--- a/drivers/pinctrl/renesas/gpio.c
+++ b/drivers/pinctrl/renesas/gpio.c
@@ -271,18 +271,40 @@ static int gpio_function_request(struct gpio_chip *gc, unsigned offset)
return ret;
}
+static void sh_pfc_fwnode_put(void *data)
+{
+ fwnode_handle_put(data);
+}
+
static int gpio_function_setup(struct sh_pfc_chip *chip)
{
struct sh_pfc *pfc = chip->pfc;
struct gpio_chip *gc = &chip->gpio_chip;
+ struct fwnode_handle *fwnode = dev_fwnode(pfc->dev);
gc->request = gpio_function_request;
+ if (is_software_node(fwnode)) {
+ fwnode = fwnode_get_named_child_node(fwnode, "functions");
+ if (fwnode) {
+ int ret;
+
+ ret = devm_add_action_or_reset(pfc->dev,
+ sh_pfc_fwnode_put,
+ fwnode);
+ if (ret)
+ return ret;
+
+ gc->fwnode = fwnode;
+ }
+ }
+
/*
- * Explicitly mask the parent's fwnode to prevent gpiolib from
- * reusing it for function GPIOs.
+ * If we did not find 'functions' node, explicitly mask the parent's
+ * fwnode to prevent gpiolib from reusing it for function GPIOs.
*/
- gc->fwnode = ERR_PTR(-ENODEV);
+ if (!gc->fwnode)
+ gc->fwnode = ERR_PTR(-ENODEV);
gc->label = pfc->info->name;
gc->owner = THIS_MODULE;
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3 5/5] sh: mach-rsk: rsk7203: convert pin configuration to using software nodes
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
` (3 preceding siblings ...)
2026-09-30 4:58 ` [PATCH v3 4/5] pinctrl: renesas: gpio: support software nodes for function GPIOs Dmitry Torokhov
@ 2026-09-30 4:58 ` Dmitry Torokhov
2026-09-30 7:23 ` [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Arnd Bergmann
5 siblings, 0 replies; 10+ messages in thread
From: Dmitry Torokhov @ 2026-09-30 4:58 UTC (permalink / raw)
To: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
Replace legacy gpio_request() calls used to configure function pins
(SCIF0 TXD/RXD and LAN9118 IRQ) with software nodes describing GPIO
hogs. These hogs are attached to the PFC gpiochip node, allowing the
GPIO subsystem to automatically configure these pins when the driver is
registered.
Assisted-by: LLM
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
arch/sh/boards/mach-rsk/devices-rsk7203.c | 103 ++++++++++++++++++++++++++----
1 file changed, 91 insertions(+), 12 deletions(-)
diff --git a/arch/sh/boards/mach-rsk/devices-rsk7203.c b/arch/sh/boards/mach-rsk/devices-rsk7203.c
index 8076c9d15f87..7a2e73bb9645 100644
--- a/arch/sh/boards/mach-rsk/devices-rsk7203.c
+++ b/arch/sh/boards/mach-rsk/devices-rsk7203.c
@@ -12,7 +12,6 @@
#include <linux/smsc911x.h>
#include <linux/input.h>
#include <linux/io.h>
-#include <linux/gpio.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/property.h>
#include <asm/machvec.h>
@@ -147,6 +146,62 @@ static const struct software_node rsk7203_sw3_key_node = {
.properties = rsk7203_sw3_key_props,
};
+/* The base of the function GPIOs in the flat enum */
+#define SH7203_FN_BASE GPIO_FN_PINT7_PB
+
+static const struct software_node rsk7203_pfc_functions_node = {
+ .name = "functions",
+ .parent = &pfc_gpiochip_node,
+};
+
+static const struct property_entry rsk7203_txd0_hog_props[] = {
+ PROPERTY_ENTRY_BOOL("gpio-hog"),
+ PROPERTY_ENTRY_U32_ARRAY("gpios", ((u32[]){
+ GPIO_FN_TXD0 - SH7203_FN_BASE, GPIO_ACTIVE_HIGH
+ })),
+ PROPERTY_ENTRY_BOOL("input"),
+ PROPERTY_ENTRY_STRING("line-name", "TXD0"),
+ { }
+};
+
+static const struct software_node rsk7203_txd0_hog_node = {
+ .name = "txd0-hog",
+ .parent = &rsk7203_pfc_functions_node,
+ .properties = rsk7203_txd0_hog_props,
+};
+
+static const struct property_entry rsk7203_rxd0_hog_props[] = {
+ PROPERTY_ENTRY_BOOL("gpio-hog"),
+ PROPERTY_ENTRY_U32_ARRAY("gpios", ((u32[]){
+ GPIO_FN_RXD0 - SH7203_FN_BASE, GPIO_ACTIVE_HIGH
+ })),
+ PROPERTY_ENTRY_BOOL("input"),
+ PROPERTY_ENTRY_STRING("line-name", "RXD0"),
+ { }
+};
+
+static const struct software_node rsk7203_rxd0_hog_node = {
+ .name = "rxd0-hog",
+ .parent = &rsk7203_pfc_functions_node,
+ .properties = rsk7203_rxd0_hog_props,
+};
+
+static const struct property_entry rsk7203_irq0_hog_props[] = {
+ PROPERTY_ENTRY_BOOL("gpio-hog"),
+ PROPERTY_ENTRY_U32_ARRAY("gpios", ((u32[]){
+ GPIO_FN_IRQ0_PB - SH7203_FN_BASE, GPIO_ACTIVE_HIGH
+ })),
+ PROPERTY_ENTRY_BOOL("input"),
+ PROPERTY_ENTRY_STRING("line-name", "IRQ0_PB"),
+ { }
+};
+
+static const struct software_node rsk7203_irq0_hog_node = {
+ .name = "irq0-hog",
+ .parent = &rsk7203_pfc_functions_node,
+ .properties = rsk7203_irq0_hog_props,
+};
+
static const struct software_node * const rsk7203_swnodes[] __initconst = {
&rsk7203_gpio_leds_node,
&rsk7203_green_led_node,
@@ -157,6 +212,10 @@ static const struct software_node * const rsk7203_swnodes[] __initconst = {
&rsk7203_sw1_key_node,
&rsk7203_sw2_key_node,
&rsk7203_sw3_key_node,
+ &rsk7203_pfc_functions_node,
+ &rsk7203_txd0_hog_node,
+ &rsk7203_rxd0_hog_node,
+ &rsk7203_irq0_hog_node,
NULL
};
@@ -181,26 +240,46 @@ static const struct platform_device_info rsk7203_devices[] __initconst = {
},
};
-static int __init rsk7203_devices_setup(void)
+/*
+ * The pfc-sh7203 device is registered at arch_initcall level, and the
+ * sh-pfc driver (registered at postcore_initcall level) probes as soon
+ * as the device is created.
+ *
+ * We need to register our software nodes at postcore_initcall level so
+ * they are already present in the system when the driver probes and
+ * tries to apply GPIO hogs.
+ */
+static int __init rsk7203_sw_nodes_setup(void)
{
- struct platform_device *pd;
int error;
- int i;
- /* Select pins for SCIF0 */
- gpio_request(GPIO_FN_TXD0, NULL);
- gpio_request(GPIO_FN_RXD0, NULL);
-
- /* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
- __raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
- gpio_request(GPIO_FN_IRQ0_PB, NULL);
+ error = software_node_register(&pfc_gpiochip_node);
+ if (error && error != -EEXIST) {
+ pr_err("RSK7203: failed to register PFC software node: %d\n",
+ error);
+ return error;
+ }
error = software_node_register_node_group(rsk7203_swnodes);
if (error) {
- pr_err("failed to register software nodes: %d\n", error);
+ pr_err("RSK7203: failed to register board software nodes: %d\n",
+ error);
return error;
}
+ return 0;
+}
+postcore_initcall(rsk7203_sw_nodes_setup);
+
+static int __init rsk7203_devices_setup(void)
+{
+ struct platform_device *pd;
+ int error;
+ int i;
+
+ /* Setup LAN9118: CS1 in 16-bit Big Endian Mode, IRQ0 at Port B */
+ __raw_writel(0x36db0400, 0xfffc0008); /* CS1BCR */
+
for (i = 0; i < ARRAY_SIZE(rsk7203_devices); i++) {
pd = platform_device_register_full(&rsk7203_devices[i]);
error = PTR_ERR_OR_ZERO(pd);
--
2.56.0.rc1.315.gc6ed9934b7-goog
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode
2026-09-30 4:58 ` [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode Dmitry Torokhov
@ 2026-09-30 7:05 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2026-09-30 7:05 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato,
Linus Walleij, Bartosz Golaszewski, Andy Shevchenko,
Arnd Bergmann, linux-sh, linux-kernel, linux-renesas-soc,
linux-gpio, Bartosz Golaszewski
On Wed, 30 Sept 2026 at 06:58, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> The sh-pfc driver registers two separate gpiochip instances: one for
> real GPIOs and another for function GPIOs. Since both share the same
> parent platform device, gpiolib's fallback logic causes both chips to
> share the same firmware node (fwnode).
>
> This causes ambiguity when using software nodes to describe GPIOs, as
> gpiolib may apply hogs meant for one chip to the other if they share the
> same node.
>
> Explicitly set gc->fwnode to ERR_PTR(-ENODEV) for the function GPIO
> chip. This satisfies gpiolib's check for an existing fwnode and prevents
> it from falling back to the parent device's node, while ensuring that no
> actual properties or hogs are found on the function chip unless
> explicitly assigned later.
>
> Assisted-by: LLM
> Acked-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> --- a/drivers/pinctrl/renesas/gpio.c
> +++ b/drivers/pinctrl/renesas/gpio.c
> @@ -278,6 +278,12 @@ static int gpio_function_setup(struct sh_pfc_chip *chip)
As this function is only used on SH:
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 4/5] pinctrl: renesas: gpio: support software nodes for function GPIOs
2026-09-30 4:58 ` [PATCH v3 4/5] pinctrl: renesas: gpio: support software nodes for function GPIOs Dmitry Torokhov
@ 2026-09-30 7:06 ` Geert Uytterhoeven
0 siblings, 0 replies; 10+ messages in thread
From: Geert Uytterhoeven @ 2026-09-30 7:06 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato,
Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, Arnd Bergmann, linux-sh, linux-kernel,
linux-renesas-soc, linux-gpio, Bartosz Golaszewski
On Wed, 30 Sept 2026 at 06:58, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> This patch extends the sh-pfc GPIO driver to support software-node-based
> configuration for the secondary 'function' GPIO chip.
>
> While the primary GPIO chip typically uses the firmware node attached to
> the parent platform device, the secondary chip should target a specific
> child node to avoid ambiguity when defining GPIO hogs or properties.
>
> Update gpio_function_setup() to look for a child node named 'functions',
> but only when the parent is a software node. This ensures the behavior
> is restricted to legacy platforms being migrated to software nodes.
>
> Assisted-by: LLM
> Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
> drivers/pinctrl/renesas/gpio.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pinctrl/renesas/gpio.c b/drivers/pinctrl/renesas/gpio.c
> index 4e59dadb7364..b49a3e14da91 100644
> --- a/drivers/pinctrl/renesas/gpio.c
> +++ b/drivers/pinctrl/renesas/gpio.c
> @@ -271,18 +271,40 @@ static int gpio_function_request(struct gpio_chip *gc, unsigned offset)
> return ret;
> }
>
> +static void sh_pfc_fwnode_put(void *data)
> +{
> + fwnode_handle_put(data);
> +}
> +
> static int gpio_function_setup(struct sh_pfc_chip *chip)
> {
As these function are only used on SH:
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
` (4 preceding siblings ...)
2026-09-30 4:58 ` [PATCH v3 5/5] sh: mach-rsk: rsk7203: convert pin configuration to using software nodes Dmitry Torokhov
@ 2026-09-30 7:23 ` Arnd Bergmann
2026-09-30 8:37 ` Andy Shevchenko
5 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2026-09-30 7:23 UTC (permalink / raw)
To: Dmitry Torokhov, Rich Felker, John Paul Adrian Glaubitz, Yoshinori Sato
Cc: Geert Uytterhoeven, Linus Walleij, Bartosz Golaszewski,
Andy Shevchenko, linux-sh, linux-kernel, Linux-Renesas,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski
On Wed, Sep 30, 2026, at 06:57, Dmitry Torokhov wrote:
> This series of patches converts rsk7203 to use static device properties
> for its devices, including gpio-keys and gpio-leds, and removing
> dependency on legacy gpio API (in favor of gpiod API).
The patches look good to me. I have build-tested this with the snippet
below and my series from
https://lore.kernel.org/all/20260907090956.2825703-2-arnd@kernel.org/
to check that no use of the legacy interfaces remain.
You can probably fold my one-liner into your last patch.
There is a trivial conflict between your series and my patch 2/2
"gpiolib: remove linux/gpio.h", but if yours gets merged, I can
resend mine without that line.
> To configure pin functions the board is switched to use gpio-hogs, as
> doing full conversion to pinmux is too challenging without access to
> hardware.
I would guess even with access to hardware testing is going to be
challenging, I noticed that the defconfig kernel does not fit on the
4MB flash any more (even without rootfs), and the USB support was
never added for rsk7203, only for 7264/7269.
Arnd
--- a/arch/sh/boards/mach-rsk/Kconfig
+++ b/arch/sh/boards/mach-rsk/Kconfig
@@ -12,7 +12,6 @@ config SH_RSK7201
config SH_RSK7203
bool "RSK7203"
select GPIOLIB
- select GPIOLIB_LEGACY
depends on CPU_SUBTYPE_SH7203
config SH_RSK7264
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API
2026-09-30 7:23 ` [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Arnd Bergmann
@ 2026-09-30 8:37 ` Andy Shevchenko
0 siblings, 0 replies; 10+ messages in thread
From: Andy Shevchenko @ 2026-09-30 8:37 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Dmitry Torokhov, Rich Felker, John Paul Adrian Glaubitz,
Yoshinori Sato, Geert Uytterhoeven, Linus Walleij,
Bartosz Golaszewski, linux-sh, linux-kernel, Linux-Renesas,
open list:GPIO SUBSYSTEM, Bartosz Golaszewski
On Wed, Sep 30, 2026 at 09:23:21AM +0200, Arnd Bergmann wrote:
> On Wed, Sep 30, 2026, at 06:57, Dmitry Torokhov wrote:
> > This series of patches converts rsk7203 to use static device properties
> > for its devices, including gpio-keys and gpio-leds, and removing
> > dependency on legacy gpio API (in favor of gpiod API).
>
> The patches look good to me. I have build-tested this with the snippet
> below and my series from
> https://lore.kernel.org/all/20260907090956.2825703-2-arnd@kernel.org/
> to check that no use of the legacy interfaces remain.
> You can probably fold my one-liner into your last patch.
>
> There is a trivial conflict between your series and my patch 2/2
> "gpiolib: remove linux/gpio.h", but if yours gets merged, I can
> resend mine without that line.
>
> > To configure pin functions the board is switched to use gpio-hogs, as
> > doing full conversion to pinmux is too challenging without access to
> > hardware.
>
> I would guess even with access to hardware testing is going to be
> challenging, I noticed that the defconfig kernel does not fit on the
> 4MB flash any more (even without rootfs), and the USB support was
> never added for rsk7203, only for 7264/7269.
...which induces a practical question, shouldn't we just drop the whole thing
for good?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-09-30 8:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-30 4:57 [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 1/5] pinctrl: renesas: gpio: isolate function gpiochip from parent fwnode Dmitry Torokhov
2026-09-30 7:05 ` Geert Uytterhoeven
2026-09-30 4:58 ` [PATCH v3 2/5] sh: pfc: attach software node to the GPIO chip Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 3/5] sh: mach-rsk: rsk7203: use static device properties for LEDs and GPIO buttons Dmitry Torokhov
2026-09-30 4:58 ` [PATCH v3 4/5] pinctrl: renesas: gpio: support software nodes for function GPIOs Dmitry Torokhov
2026-09-30 7:06 ` Geert Uytterhoeven
2026-09-30 4:58 ` [PATCH v3 5/5] sh: mach-rsk: rsk7203: convert pin configuration to using software nodes Dmitry Torokhov
2026-09-30 7:23 ` [PATCH v3 0/5] sh: mach-rsk: rsk7203: switch to using static device property, drop legacy gpio API Arnd Bergmann
2026-09-30 8:37 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®