ARM: omap1: use real firmware node lookup for GPIOs on Nokia 770
Subsystems (6)
v5 cover ARM: omap1: use real firmware node lookup for GPIOs on Nokia 770
Mergin strategy: It would be awesome if patches 1-3 could make v7.1 through the driver core tree after which the final patch could go through ARM-SoC separately in v7.2.
This converts Nokia 770 to using real firmware node lookup for GPIOs by attaching the software nodes describing GPIO controllers to their target devices.
As determined by Aaro's testing, both omap16xx_gpio_init() and software_node_init() run in postcore_initcall() so we need to make software nodes available earlier hence the new patches in v4.
Please note that while the goal of this series is to allow Nokia 770 to use software nodes earlier, we're not modifying core kernel code just to accomodate an old ARM platform - more such conversions are coming up so the change will be useful to more consumers of the software node API.
---
Changes in v5:
- Put ksysfs_init() in a separate new header
- Remove software_node_exit() in a separate patch
- Link to v4: https://patch.msgid.link/20260330-nokia770-gpio-swnodes-v4-0-b68592e977d0@oss.qualcomm.com
Changes in v4:
- Add patches making software nodes available earlier
- Remove stray newline
- Link to v3: https://lore.kernel.org/all/[email protected]/
Changes in v3:
- fix references to the MPU node
Changes in v2:
- fix build with CONFIG_I2C_CBUS_GPIO
- only export the two symbols that are actually required by the nokia board file
---
Bartosz Golaszewski (4):
kernel: ksysfs: initialize kernel_kobj earlier software node: remove software_node_exit()
driver core: make software nodes available earlier
ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
MAINTAINERS | 1 + arch/arm/mach-omap1/board-nokia770.c | 30 +++++------------------------- arch/arm/mach-omap1/common.h | 3 +++ arch/arm/mach-omap1/gpio16xx.c | 28 +++++++++++++++++++++++++++- drivers/base/base.h | 1 + drivers/base/init.c | 1 + drivers/base/swnode.c | 13 ++----------- include/linux/ksysfs.h | 8 ++++++++ init/main.c | 2 ++ kernel/ksysfs.c | 9 ++++----- 10 files changed, 54 insertions(+), 42 deletions(-)
---
base-commit: bd0f139e5fc11182777b81cefc3893ea508544ec
change-id: 20260330-nokia770-gpio-swnodes-5da8ba35946e
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>
PATCH v5 1/4 kernel: ksysfs: initialize kernel_kobj earlier
Software nodes depend on kernel_kobj which is initialized pretty late into the boot process - as a core_initcall(). Ahead of moving the software node initialization to driver_init() we must first make kernel_kobj available before it.
Make ksysfs_init() visible in a new header - ksysfs.h - and call it in do_basic_setup() right before driver_init().
--- MAINTAINERS | 1 + include/linux/ksysfs.h | 8 ++++++++ init/main.c | 2 ++ kernel/ksysfs.c | 9 ++++----- 4 files changed, 15 insertions(+), 5 deletions(-)
MAINTAINERS +1 -0
@@ -7843,6 +7843,7 @@ F: include/linux/debugfs.h F: include/linux/device.h F: include/linux/fwnode.h F: include/linux/kobj* +F: include/linux/ksysfs.h F: include/linux/property.h F: include/linux/sysfs.h F: lib/kobj*
include/linux/ksysfs.h new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _KSYSFS_H_ +#define _KSYSFS_H_ + +void ksysfs_init (void ); + +#endif /* _KSYSFS_H_ */
init/main.c +2 -0
@@ -36,6 +36,7 @@#include <linux/kmod.h> #include <linux/kprobes.h> #include <linux/kmsan.h> +#include <linux/ksysfs.h> #include <linux/vmalloc.h> #include <linux/kernel_stat.h> #include <linux/start_kernel.h>
@@ -1482,6 +1483,7 @@ static void __init do_initcalls(void)static void __init do_basic_setup (void ) {cpuset_init_smp (); +ksysfs_init ();driver_init ();init_irq_proc ();do_ctors ();
kernel/ksysfs.c +4 -5
@@ -8,6 +8,7 @@#include <asm/byteorder.h> #include <linux/kobject.h> +#include <linux/ksysfs.h> #include <linux/string.h> #include <linux/sysfs.h> #include <linux/export.h>
@@ -213,7 +214,7 @@ static const struct attribute_group kernel_attr_group = { .attrs = kernel_attrs, }; -static int __init ksysfs_init (void ) +void __init ksysfs_init (void ) {int error;
@@ -234,14 +235,12 @@ static int __init ksysfs_init(void) goto group_exit; } -return 0 ; +return ; group_exit:sysfs_remove_group (kernel_kobj, &kernel_attr_group); kset_exit:kobject_put (kernel_kobj); exit: -return error; +pr_err ("failed to initialize the kernel kobject: %d\n" , error); } - -core_initcall (ksysfs_init);
Signature · 1 line
2.47.3
Danilo Krummrich
maintainerRe: [PATCH v5 1/4] kernel: ksysfs: initialize kernel_kobj earlier
MAINTAINERS F: include/linux/debugfs.h · line 7846
Quoted 9 lines · Bartosz Golaszewski
MAINTAINERS +1
-0@@ -7843,6 +7843,7 @@ F: include/linux/debugfs.h F: include/linux/device.h F: include/linux/fwnode.h F: include/linux/kobj* +F: include/linux/ksysfs.h
Currently, kernel/ksysfs.c is not listed in the driver core entry (it is not in any entry), but I guess that would make sense.
So, we should probably also add kernel/ksysfs.c. :) But this can be a separate patch independent of this series.
Bartosz Golaszewski
reviewerRe: [PATCH v5 1/4] kernel: ksysfs: initialize kernel_kobj earlier
Quoted 15 lines · Danilo Krummrich
MAINTAINERS F: include/linux/debugfs.h · line 7846
Quoted 9 lines · Bartosz Golaszewski
MAINTAINERS +1
-0@@ -7843,6 +7843,7 @@ F: include/linux/debugfs.h F: include/linux/device.h F: include/linux/fwnode.h F: include/linux/kobj* +F: include/linux/ksysfs.hCurrently,
kernel/ksysfs.cis not listed in the driver core entry (it is not in any entry), but I guess that would make sense.
Quoted 2 lines
So, we should probably also add
kernel/ksysfs.c. :) But this can be a separate patch independent of this series.
Ok, I take it no need to resend this?
Bart
PATCH v5 2/4 software node: remove software_node_exit()
In reply to Bartosz Golaszewskisoftware_node_exit() is an __exitcall() in a built-in compilation unit so effectively dead code. Remove it.
--- drivers/base/swnode.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/base/swnode.c +0 -7
@@ -1135,10 +1135,3 @@ static int __init software_node_init(void)return 0 ; }postcore_initcall (software_node_init); - -static void __exit software_node_exit(void) -{ -ida_destroy (&swnode_root_ids); -kset_unregister (swnode_kset); -} -__exitcall (software_node_exit);
Signature · 1 line
2.47.3
Re: [PATCH v5 2/4] software node: remove software_node_exit()
Quoted 2 lines · Bartosz Golaszewski
software_node_exit()is an__exitcall()in a built-in compilation unit so effectively dead code. Remove it.
a dead code
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 2/4] software node: remove software_node_exit()
Quoted 5 lines · Andy Shevchenko
Quoted 2 lines · Bartosz Golaszewski
software_node_exit()is an__exitcall()in a built-in compilation unit so effectively dead code. Remove it.a dead code
"
In technical writing, "dead code" is typically treated as an uncountable noun, meaning it does not need the article "a" when referring to it as a category or state.
"
Thanks.
Signature · 1 line
Dmitry
PATCH v5 3/4 driver core: make software nodes available earlier
In reply to Bartosz GolaszewskiSoftware nodes are currently initialized in a function registered as a postcore_initcall(). However, some devices may want to register software nodes earlier than that (or also in a postcore_initcall() where they're at the merci of the link order). Move the initialization to driver_init() making swnode available much earlier as well as making their initialization time deterministic.
--- drivers/base/base.h | 1 + drivers/base/init.c | 1 + drivers/base/swnode.c | 6 ++---- 3 files changed, 4 insertions(+), 4 deletions(-)
drivers/base/base.h +1 -0
@@ -312,6 +312,7 @@ static inline int devtmpfs_create_node(struct device *dev) { return 0; }static inline int devtmpfs_delete_node (struct device *dev) {return 0 ; }#endif +void software_node_init (void );void software_node_notify (struct device *dev);void software_node_notify_remove (struct device *dev);
drivers/base/init.c +1 -0
@@ -34,6 +34,7 @@ void __init driver_init(void)*/ faux_bus_init ();of_core_init (); +software_node_init ();platform_bus_init ();auxiliary_bus_init ();memory_dev_init ();
drivers/base/swnode.c +2 -4
@@ -1127,11 +1127,9 @@ void software_node_notify_remove(struct device *dev) } } -static int __init software_node_init (void ) +void __init software_node_init (void ) { swnode_kset =kset_create_and_add ("software_nodes" ,NULL , kernel_kobj);if (!swnode_kset) -return -ENOMEM ; -return 0 ; +pr_err ("failed to register software nodes\n" ); } -postcore_initcall (software_node_init);
Signature · 1 line
2.47.3
Re: [PATCH v5 3/4] driver core: make software nodes available earlier
Quoted 6 lines · Bartosz Golaszewski
Software nodes are currently initialized in a function registered as a
postcore_initcall(). However, some devices may want to register software nodes earlier than that (or also in apostcore_initcall()where they're at the merci of the link order). Move the initialization todriver_init()making swnode available much earlier as well as making their initialization time deterministic.
Okay, if people want this, why not.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v5 4/4 ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
In reply to Bartosz GolaszewskiCurrently the board file for Nokia 770 creates dummy software nodes not attached in any way to the actual GPIO controller devices and uses the fact that GPIOLIB matching swnode's name to the GPIO chip's label during software node lookup. This behavior is wrong and we want to remove it. To that end, we need to first convert all existing users to creating actual fwnode links.
Create real software nodes for GPIO controllers on OMAP16xx and reference them from the software nodes in the nokia board file.
--- arch/arm/mach-omap1/board-nokia770.c | 30 +++++------------------------- arch/arm/mach-omap1/common.h | 3 +++ arch/arm/mach-omap1/gpio16xx.c | 28 +++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 26 deletions(-)
arch/arm/mach-omap1/board-nokia770.c +5 -25
@@ -36,25 +36,6 @@#include "clock.h" #include "mmc.h" -static const struct software_node nokia770_mpuio_gpiochip_node = { - .name ="mpuio" , -}; - -static const struct software_node nokia770_gpiochip1_node = { - .name ="gpio-0-15" , -}; - -static const struct software_node nokia770_gpiochip2_node = { - .name ="gpio-16-31" , -}; - -static const struct software_node *nokia770_gpiochip_nodes[] = { - &nokia770_mpuio_gpiochip_node, - &nokia770_gpiochip1_node, - &nokia770_gpiochip2_node, -NULL -}; -#define ADS7846_PENDOWN_GPIO 15static const unsigned int nokia770_keymap[] = {
@@ -112,7 +93,7 @@ static const struct omap_lcd_config nokia770_lcd_config __initconst = { };static const struct property_entry nokia770_mipid_props[] = { -PROPERTY_ENTRY_GPIO ("reset-gpios" , &nokia770_gpiochip1_node, +PROPERTY_ENTRY_GPIO ("reset-gpios" , &omap16xx_gpio1_swnode,13 ,GPIO_ACTIVE_LOW ), { } };
@@ -138,7 +119,7 @@ static const struct property_entry nokia770_ads7846_props[] = {PROPERTY_ENTRY_U16 ("ti,x-plate-ohms" ,180 ),PROPERTY_ENTRY_U16 ("ti,debounce-tol" ,3 ),PROPERTY_ENTRY_U16 ("ti,debounce-rep" ,1 ), -PROPERTY_ENTRY_GPIO ("pendown-gpios" , &nokia770_gpiochip1_node, +PROPERTY_ENTRY_GPIO ("pendown-gpios" , &omap16xx_gpio1_swnode, ADS7846_PENDOWN_GPIO, GPIO_ACTIVE_LOW), { } };
@@ -225,9 +206,9 @@ static inline void nokia770_mmc_init(void)#if IS_ENABLED (CONFIG_I2C_CBUS_GPIO )static const struct software_node_ref_args nokia770_cbus_gpio_refs[] = { -SOFTWARE_NODE_REFERENCE (&nokia770_mpuio_gpiochip_node,9 ,0 ), -SOFTWARE_NODE_REFERENCE (&nokia770_mpuio_gpiochip_node,10 ,0 ), -SOFTWARE_NODE_REFERENCE (&nokia770_mpuio_gpiochip_node,11 ,0 ), +SOFTWARE_NODE_REFERENCE (&omap16xx_mpu_gpio_swnode,9 ,0 ), +SOFTWARE_NODE_REFERENCE (&omap16xx_mpu_gpio_swnode,10 ,0 ), +SOFTWARE_NODE_REFERENCE (&omap16xx_mpu_gpio_swnode,11 ,0 ), }; static const struct property_entry nokia770_cbus_props[] = {
@@ -318,7 +299,6 @@ static void __init omap_nokia770_init(void)/* Unmask SleepX signal */ omap_writew ((omap_readw (0xfffb5004 ) & ~2 ),0xfffb5004 ); -software_node_register_node_group (nokia770_gpiochip_nodes);platform_add_devices (nokia770_devices,ARRAY_SIZE (nokia770_devices));gpiod_add_lookup_table (&nokia770_irq_gpio_table);
arch/arm/mach-omap1/common.h +3 -0
@@ -35,6 +35,9 @@#include "soc.h" #include "i2c.h" +extern const struct software_node omap16xx_mpu_gpio_swnode; +extern const struct software_node omap16xx_gpio1_swnode; +#ifdef CONFIG_OMAP_SERIAL_WAKE int omap_serial_wakeup_init (void );#else
arch/arm/mach-omap1/gpio16xx.c +27 -1
@@ -9,6 +9,7 @@*/ #include <linux/platform_data/gpio-omap.h> +#include <linux/property.h> #include <linux/soc/ti/omap1-io.h> #include "hardware.h"
@@ -55,6 +56,8 @@ static struct omap_gpio_platform_data omap16xx_mpu_gpio_config = { .regs = &omap16xx_mpuio_regs, }; +const struct software_node omap16xx_mpu_gpio_swnode = { }; +static struct platform_device omap16xx_mpu_gpio = { .name ="omap_gpio" , .id =0 ,
@@ -99,6 +102,8 @@ static struct omap_gpio_platform_data omap16xx_gpio1_config = { .regs = &omap16xx_gpio_regs, }; +const struct software_node omap16xx_gpio1_swnode = { }; +static struct platform_device omap16xx_gpio1 = { .name ="omap_gpio" , .id =1 ,
@@ -122,6 +127,8 @@ static struct resource omap16xx_gpio2_resources[] = { }, }; +static const struct software_node omap16xx_gpio2_swnode = { }; +static struct omap_gpio_platform_data omap16xx_gpio2_config = { .bank_width =16 , .regs = &omap16xx_gpio_regs,
@@ -155,6 +162,8 @@ static struct omap_gpio_platform_data omap16xx_gpio3_config = { .regs = &omap16xx_gpio_regs, }; +static const struct software_node omap16xx_gpio3_swnode = { }; +static struct platform_device omap16xx_gpio3 = { .name ="omap_gpio" , .id =3 ,
@@ -183,6 +192,8 @@ static struct omap_gpio_platform_data omap16xx_gpio4_config = { .regs = &omap16xx_gpio_regs, }; +static const struct software_node omap16xx_gpio4_swnode = { }; +static struct platform_device omap16xx_gpio4 = { .name ="omap_gpio" , .id =4 ,
@@ -201,6 +212,14 @@ static struct platform_device *omap16xx_gpio_dev[] __initdata = { &omap16xx_gpio4, }; +static const struct software_node *omap16xx_gpio_swnodes[]__initconst = { + &omap16xx_mpu_gpio_swnode, + &omap16xx_gpio1_swnode, + &omap16xx_gpio2_swnode, + &omap16xx_gpio3_swnode, + &omap16xx_gpio4_swnode, +}; +/* * omap16xx_gpio_init needs to be done before * machine_init functions access gpio APIs.
@@ -208,7 +227,7 @@ static struct platform_device *omap16xx_gpio_dev[] __initdata = {*/ static int __init omap16xx_gpio_init (void ) { -int i; +int i, ret;void __iomem *base;struct resource *res;struct platform_device *pdev;
@@ -244,6 +263,13 @@ static int __init omap16xx_gpio_init(void)iounmap (base);platform_device_register (omap16xx_gpio_dev[i]); + + ret =device_add_software_node (&omap16xx_gpio_dev[i]->dev, + omap16xx_gpio_swnodes[i]); +if (ret) { +dev_err (&pdev->dev,"Failed to add software node.\n" ); +return ret; + } }return 0 ;
Signature · 1 line
2.47.3
Andy Shevchenko
reviewerRe: [PATCH v5 4/4] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
Quoted 9 lines · Bartosz Golaszewski
Currently the board file for Nokia 770 creates dummy software nodes not attached in any way to the actual GPIO controller devices and uses the fact that GPIOLIB matching swnode's name to the GPIO chip's label during software node lookup. This behavior is wrong and we want to remove it. To that end, we need to first convert all existing users to creating actual fwnode links.
Create real software nodes for GPIO controllers on OMAP16xx and reference them from the software nodes in the nokia board file.
...
Quoted 1 line
+static const struct
software_nodeomap16xx_gpio2_swnode= { };
No need to have {} for statically defined variables. OTOH, if you want to have same style over exported and static, perhaps it's okay.
Quoted 3 lines
arch/arm/mach-omap1/gpio16xx.c +2
-0+static const struct software_node omap16xx_gpio3_swnode = { }; +static const struct software_node omap16xx_gpio4_swnode = { };
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 4/4] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
In reply to Bartosz Golaszewskiarch/arm/mach-omap1/gpio16xx.c static int __init omap16xx_gpio_init(void) · line 272
Quoted 11 lines · Bartosz Golaszewski
arch/arm/mach-omap1/gpio16xx.c +7
-0@@ -244,6 +263,13 @@ static int __init omap16xx_gpio_init(void)iounmap (base);platform_device_register (omap16xx_gpio_dev[i]); + + ret =device_add_software_node (&omap16xx_gpio_dev[i]->dev, + omap16xx_gpio_swnodes[i]); +if (ret) { +dev_err (&pdev->dev,"Failed to add software node.\n" ); +return ret; + }
I think the best and safest way is to convert to using platform_driver_register_full() and set swnode in the relevant "info" instance.
Thanks.
Signature · 1 line
Dmitry
Bartosz Golaszewski
reviewerRe: [PATCH v5 4/4] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
Quoted 5 lines · Dmitry Torokhov
Quoted 3 lines · Bartosz Golaszewski
arch/arm/mach-omap1/gpio16xx.c +0
-0@@ -244,6 +263,13 @@ static int __init omap16xx_gpio_init(void)iounmap (base);
Quoted 12 lines
arch/arm/mach-omap1/gpio16xx.c static int __init omap16xx_gpio_init(void) · line 272
Quoted 8 lines
arch/arm/mach-omap1/gpio16xx.c +7
-0platform_device_register (omap16xx_gpio_dev[i]); + + ret =device_add_software_node (&omap16xx_gpio_dev[i]->dev, + omap16xx_gpio_swnodes[i]); +if (ret) { +dev_err (&pdev->dev,"Failed to add software node.\n" ); +return ret; + }I think the best and safest way is to convert to using
platform_driver_register_full()and set swnode in the relevant "info" instance.
For sure, that's the plan. I will respin this after v7.1-rc1 with that change.
Bart
Danilo Krummrich
maintainerQuoted 4 lines · Bartosz Golaszewski
Bartosz Golaszewski (4):
kernel: ksysfs: initializekernel_kobjearlier software node: removesoftware_node_exit()driver core: make software nodes available earlier
Looks good to me now; I will give it a few more days on the list and then pull it in for v7.1-rc1 if no one else raises concerns.
Quoted 1 line
ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
Danilo Krummrich
maintainerRe: (subset) [PATCH v5 0/4] ARM: omap1: use real firmware node lookup for GPIOs on Nokia 770
In reply to Bartosz GolaszewskiOn Thu Apr 2, 2026 at 4:15 PM CEST, Bartosz Golaszewski wrote:
Applied to driver-core-testing, thanks!
Quoted 4 lines
Bartosz Golaszewski (4):
kernel: ksysfs: initializekernel_kobjearlier software node: removesoftware_node_exit()driver core: make software nodes available earlier
[ Fix typo in the commit message: "s/merci/mercy/". - Danilo ]
Andy Shevchenko
reviewerRe: (subset) [PATCH v5 0/4] ARM: omap1: use real firmware node lookup for GPIOs on Nokia 770
Quoted 3 lines · Danilo Krummrich
On Thu Apr 2, 2026 at 4:15 PM CEST, Bartosz Golaszewski wrote:
[ Fix typo in the commit message: "s/merci/mercy/". - Danilo ]
Depends if Bart used French to sound that genuine.
Signature · 2 lines
With Best Regards, Andy Shevchenko