* [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
@ 2026-02-11 13:13 Bartosz Golaszewski
2026-02-11 13:19 ` Bartosz Golaszewski
2026-02-11 16:31 ` Arnd Bergmann
0 siblings, 2 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-02-11 13:13 UTC (permalink / raw)
To: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
Dmitry Torokhov, Arnd Bergmann, Hans de Goede
Cc: linux-omap, linux-arm-kernel, linux-kernel, brgl,
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.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- fix build with CONFIG_I2C_CBUS_GPIO
- only export the two symbols that are actually required by the nokia
board file
This is a follow up to the following discussion[1]. I don't have the
hardware for testing so only build-tested it.
[1] https://lore.kernel.org/all/aYkdKfP5fg6iywgr@jekhomev/
arch/arm/mach-omap1/board-nokia770.c | 30 +++++-----------------------
arch/arm/mach-omap1/common.h | 3 +++
arch/arm/mach-omap1/gpio16xx.c | 29 ++++++++++++++++++++++++++-
3 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index a5bf5554800f..a840934d4d15 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -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 15
static 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);
diff --git a/arch/arm/mach-omap1/common.h b/arch/arm/mach-omap1/common.h
index 7a7c3d9eb84a..c0f6e231fdb4 100644
--- a/arch/arm/mach-omap1/common.h
+++ b/arch/arm/mach-omap1/common.h
@@ -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
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
index 55acec22fef4..177621cb4784 100644
--- a/arch/arm/mach-omap1/gpio16xx.c
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -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,14 @@ 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;
--
2.47.3
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-11 13:13 [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770 Bartosz Golaszewski
@ 2026-02-11 13:19 ` Bartosz Golaszewski
2026-02-11 16:31 ` Arnd Bergmann
1 sibling, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-02-11 13:19 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Aaro Koskinen, Janusz Krzysztofik, Tony Lindgren, Russell King,
Dmitry Torokhov, Arnd Bergmann, Hans de Goede, linux-omap,
linux-arm-kernel, linux-kernel
On Wed, Feb 11, 2026 at 2:14 PM Bartosz Golaszewski
<bartosz.golaszewski@oss.qualcomm.com> wrote:
>
> 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.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
> Changes in v2:
> - fix build with CONFIG_I2C_CBUS_GPIO
> - only export the two symbols that are actually required by the nokia
> board file
>
> @@ -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),
> };
>
I'm sorry, this is still wrong but it builds, so I didn't notice. It
should be `&omap16xx_mpu_gpio_swnode`.
Will send v3 tomorrow.
Bartosz
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-11 13:13 [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770 Bartosz Golaszewski
2026-02-11 13:19 ` Bartosz Golaszewski
@ 2026-02-11 16:31 ` Arnd Bergmann
2026-02-11 21:40 ` Dmitry Torokhov
2026-02-12 11:40 ` Bartosz Golaszewski
1 sibling, 2 replies; 8+ messages in thread
From: Arnd Bergmann @ 2026-02-11 16:31 UTC (permalink / raw)
To: Bartosz Golaszewski, Aaro Koskinen, Janusz Krzysztofik,
Tony Lindgren, Russell King, Dmitry Torokhov, Hans de Goede
Cc: Linux-OMAP, linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote:
> 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.
>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> ---
I don't see mistakes here, and I don't want to throw a wrench in
this patch, but I wonder if there is a way to take this one step further:
> @@ -244,6 +263,14 @@ 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 was planning to go through the remaining 'static struct platform_device'
definitions in arch/arm/ after the planned board file removal and
try to convert these to 'platform_device_info' or similar, using
platform_device_register_full(). Since that function already contains
code to dynamically allocate the software_node, I had hoped that
a lot of this would just go away.
However, I see that your patch creates pointers to those software_node
instances, so think that would become a bit harder, but I have not
actually tried it.
Do you know if there is a good way to do this without using static
platform devices?
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-11 16:31 ` Arnd Bergmann
@ 2026-02-11 21:40 ` Dmitry Torokhov
2026-02-12 1:12 ` Dmitry Torokhov
2026-02-12 11:40 ` Bartosz Golaszewski
1 sibling, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2026-02-11 21:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Bartosz Golaszewski, Aaro Koskinen, Janusz Krzysztofik,
Tony Lindgren, Russell King, Hans de Goede, Linux-OMAP,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Wed, Feb 11, 2026 at 05:31:52PM +0100, Arnd Bergmann wrote:
> On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote:
> > 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.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > ---
>
> I don't see mistakes here, and I don't want to throw a wrench in
> this patch, but I wonder if there is a way to take this one step further:
>
> > @@ -244,6 +263,14 @@ 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 was planning to go through the remaining 'static struct platform_device'
> definitions in arch/arm/ after the planned board file removal and
> try to convert these to 'platform_device_info' or similar, using
> platform_device_register_full(). Since that function already contains
> code to dynamically allocate the software_node, I had hoped that
> a lot of this would just go away.
>
> However, I see that your patch creates pointers to those software_node
> instances, so think that would become a bit harder, but I have not
> actually tried it.
>
> Do you know if there is a good way to do this without using static
> platform devices?
I wonder if something like below will help reducing boilerplate...
Thanks.
--
Dmitry
driver core: platform: allow attaching software nodes when creating devices
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Extend platform_device_info structure with ian optional pointer to a
software node to be used as a secondary firmware node for the device
being created. If software node has not been registered yet it will be
automatically registered.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/base/platform.c | 15 ++++++++++-----
include/linux/platform_device.h | 23 ++++++++++++-----------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 09450349cf32..2abacdf714d6 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -809,6 +809,9 @@ struct platform_device *platform_device_register_full(
int ret;
struct platform_device *pdev;
+ if (pdevinfo->swnode && pdevinfo->properties)
+ return ERR_PTR(-EINVAL);
+
pdev = platform_device_alloc(pdevinfo->name, pdevinfo->id);
if (!pdev)
return ERR_PTR(-ENOMEM);
@@ -824,17 +827,19 @@ struct platform_device *platform_device_register_full(
pdev->dev.coherent_dma_mask = pdevinfo->dma_mask;
}
- ret = platform_device_add_resources(pdev,
- pdevinfo->res, pdevinfo->num_res);
+ ret = platform_device_add_resources(pdev, pdevinfo->res, pdevinfo->num_res);
if (ret)
goto err;
- ret = platform_device_add_data(pdev,
- pdevinfo->data, pdevinfo->size_data);
+ ret = platform_device_add_data(pdev, pdevinfo->data, pdevinfo->size_data);
if (ret)
goto err;
- if (pdevinfo->properties) {
+ if (pdevinfo->swnode) {
+ ret = device_add_software_node(&pdev->dev, pdevinfo->swnode);
+ if (ret)
+ goto err;
+ } else if (pdevinfo->properties) {
ret = device_create_managed_software_node(&pdev->dev,
pdevinfo->properties, NULL);
if (ret)
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 074754c23d33..ef5b882d08e0 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -117,21 +117,22 @@ extern int platform_get_irq_byname_optional(struct platform_device *dev,
extern int platform_add_devices(struct platform_device **, int);
struct platform_device_info {
- struct device *parent;
- struct fwnode_handle *fwnode;
- bool of_node_reused;
+ struct device *parent;
+ struct fwnode_handle *fwnode;
+ bool of_node_reused;
- const char *name;
- int id;
+ const char *name;
+ int id;
- const struct resource *res;
- unsigned int num_res;
+ const struct resource *res;
+ unsigned int num_res;
- const void *data;
- size_t size_data;
- u64 dma_mask;
+ const void *data;
+ size_t size_data;
+ u64 dma_mask;
- const struct property_entry *properties;
+ const struct software_node *swnode;
+ const struct property_entry *properties;
};
extern struct platform_device *platform_device_register_full(
const struct platform_device_info *pdevinfo);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-11 21:40 ` Dmitry Torokhov
@ 2026-02-12 1:12 ` Dmitry Torokhov
2026-02-12 6:57 ` Arnd Bergmann
0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2026-02-12 1:12 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Bartosz Golaszewski, Aaro Koskinen, Janusz Krzysztofik,
Tony Lindgren, Russell King, Hans de Goede, Linux-OMAP,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Wed, Feb 11, 2026 at 01:40:44PM -0800, Dmitry Torokhov wrote:
> On Wed, Feb 11, 2026 at 05:31:52PM +0100, Arnd Bergmann wrote:
> > On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote:
> > > 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.
> > >
> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > > ---
> >
> > I don't see mistakes here, and I don't want to throw a wrench in
> > this patch, but I wonder if there is a way to take this one step further:
> >
> > > @@ -244,6 +263,14 @@ 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 was planning to go through the remaining 'static struct platform_device'
> > definitions in arch/arm/ after the planned board file removal and
> > try to convert these to 'platform_device_info' or similar, using
> > platform_device_register_full(). Since that function already contains
> > code to dynamically allocate the software_node, I had hoped that
> > a lot of this would just go away.
> >
> > However, I see that your patch creates pointers to those software_node
> > instances, so think that would become a bit harder, but I have not
> > actually tried it.
> >
> > Do you know if there is a good way to do this without using static
> > platform devices?
>
> I wonder if something like below will help reducing boilerplate...
And then we can change the gpio16xx like this (on top of Bartosz
changes):
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c
index 177621cb4784..a42f13890b94 100644
--- a/arch/arm/mach-omap1/gpio16xx.c
+++ b/arch/arm/mach-omap1/gpio16xx.c
@@ -26,7 +26,7 @@
#define SYSCONFIG_WORD 0x14
/* mpu gpio */
-static struct resource omap16xx_mpu_gpio_resources[] = {
+static const struct resource omap16xx_mpu_gpio_resources[] __initconst = {
{
.start = OMAP1_MPUIO_VBASE,
.end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
@@ -38,7 +38,7 @@ static struct resource omap16xx_mpu_gpio_resources[] = {
},
};
-static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
+static const struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
.revision = USHRT_MAX,
.direction = OMAP_MPUIO_IO_CNTL,
.datain = OMAP_MPUIO_INPUT_LATCH,
@@ -49,27 +49,27 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
.irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
};
-static struct omap_gpio_platform_data omap16xx_mpu_gpio_config = {
+static const struct omap_gpio_platform_data omap16xx_mpu_gpio_config __initconst = {
.is_mpuio = true,
.bank_width = 16,
.bank_stride = 1,
.regs = &omap16xx_mpuio_regs,
};
-const struct software_node omap16xx_mpu_gpio_swnode = { };
+static const struct software_node omap16xx_mpu_gpio_swnode;
-static struct platform_device omap16xx_mpu_gpio = {
- .name = "omap_gpio",
- .id = 0,
- .dev = {
- .platform_data = &omap16xx_mpu_gpio_config,
- },
- .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
- .resource = omap16xx_mpu_gpio_resources,
+static const struct platform_device_info omap16xx_mpu_gpio_info __initconst = {
+ .name = "omap_gpio",
+ .id = 0,
+ .data = &omap16xx_mpu_gpio_config,
+ .size_data = sizeof(omap16xx_mpu_gpio_config),
+ .res = omap16xx_mpu_gpio_resources,
+ .num_res = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
+ .swnode = &omap16xx_mpu_gpio_swnode,
};
/* gpio1 */
-static struct resource omap16xx_gpio1_resources[] = {
+static const struct resource omap16xx_gpio1_resources[] __initconst = {
{
.start = OMAP1610_GPIO1_BASE,
.end = OMAP1610_GPIO1_BASE + SZ_2K - 1,
@@ -81,7 +81,7 @@ static struct resource omap16xx_gpio1_resources[] = {
},
};
-static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
+static const struct omap_gpio_reg_offs omap16xx_gpio_regs = {
.revision = OMAP1610_GPIO_REVISION,
.direction = OMAP1610_GPIO_DIRECTION,
.set_dataout = OMAP1610_GPIO_SET_DATAOUT,
@@ -97,25 +97,25 @@ static struct omap_gpio_reg_offs omap16xx_gpio_regs = {
.edgectrl2 = OMAP1610_GPIO_EDGE_CTRL2,
};
-static struct omap_gpio_platform_data omap16xx_gpio1_config = {
+static const struct omap_gpio_platform_data omap16xx_gpio1_config __initconst = {
.bank_width = 16,
.regs = &omap16xx_gpio_regs,
};
-const struct software_node omap16xx_gpio1_swnode = { };
+static const struct software_node omap16xx_gpio1_swnode;
-static struct platform_device omap16xx_gpio1 = {
- .name = "omap_gpio",
- .id = 1,
- .dev = {
- .platform_data = &omap16xx_gpio1_config,
- },
- .num_resources = ARRAY_SIZE(omap16xx_gpio1_resources),
- .resource = omap16xx_gpio1_resources,
+static const struct platform_device_info omap16xx_gpio1_info __initconst = {
+ .name = "omap_gpio",
+ .id = 1,
+ .data = &omap16xx_gpio1_config,
+ .size_data = sizeof(omap16xx_gpio1_config),
+ .res = omap16xx_gpio1_resources,
+ .num_res = ARRAY_SIZE(omap16xx_gpio1_resources),
+ .swnode = &omap16xx_gpio1_swnode,
};
/* gpio2 */
-static struct resource omap16xx_gpio2_resources[] = {
+static const struct resource omap16xx_gpio2_resources[] __initconst = {
{
.start = OMAP1610_GPIO2_BASE,
.end = OMAP1610_GPIO2_BASE + SZ_2K - 1,
@@ -127,25 +127,25 @@ static struct resource omap16xx_gpio2_resources[] = {
},
};
-static const struct software_node omap16xx_gpio2_swnode = { };
+static const struct software_node omap16xx_gpio2_swnode;
-static struct omap_gpio_platform_data omap16xx_gpio2_config = {
+static const struct omap_gpio_platform_data omap16xx_gpio2_config __initconst = {
.bank_width = 16,
.regs = &omap16xx_gpio_regs,
};
-static struct platform_device omap16xx_gpio2 = {
- .name = "omap_gpio",
- .id = 2,
- .dev = {
- .platform_data = &omap16xx_gpio2_config,
- },
- .num_resources = ARRAY_SIZE(omap16xx_gpio2_resources),
- .resource = omap16xx_gpio2_resources,
+static const struct platform_device_info omap16xx_gpio2_info __initconst = {
+ .name = "omap_gpio",
+ .id = 2,
+ .data = &omap16xx_gpio2_config,
+ .size_data = sizeof(omap16xx_gpio2_config),
+ .res = omap16xx_gpio2_resources,
+ .num_res = ARRAY_SIZE(omap16xx_gpio2_resources),
+ .swnode = &omap16xx_gpio2_swnode,
};
/* gpio3 */
-static struct resource omap16xx_gpio3_resources[] = {
+static const struct resource omap16xx_gpio3_resources[] __initconst = {
{
.start = OMAP1610_GPIO3_BASE,
.end = OMAP1610_GPIO3_BASE + SZ_2K - 1,
@@ -157,25 +157,25 @@ static struct resource omap16xx_gpio3_resources[] = {
},
};
-static struct omap_gpio_platform_data omap16xx_gpio3_config = {
+static const struct omap_gpio_platform_data omap16xx_gpio3_config __initconst = {
.bank_width = 16,
.regs = &omap16xx_gpio_regs,
};
-static const struct software_node omap16xx_gpio3_swnode = { };
+static const struct software_node omap16xx_gpio3_swnode;
-static struct platform_device omap16xx_gpio3 = {
- .name = "omap_gpio",
- .id = 3,
- .dev = {
- .platform_data = &omap16xx_gpio3_config,
- },
- .num_resources = ARRAY_SIZE(omap16xx_gpio3_resources),
- .resource = omap16xx_gpio3_resources,
+static const struct platform_device_info omap16xx_gpio3_info __initconst = {
+ .name = "omap_gpio",
+ .id = 3,
+ .data = &omap16xx_gpio3_config,
+ .size_data = sizeof(omap16xx_gpio3_config),
+ .res = omap16xx_gpio3_resources,
+ .num_res = ARRAY_SIZE(omap16xx_gpio3_resources),
+ .swnode = &omap16xx_gpio3_swnode,
};
/* gpio4 */
-static struct resource omap16xx_gpio4_resources[] = {
+static const struct resource omap16xx_gpio4_resources[] __initconst = {
{
.start = OMAP1610_GPIO4_BASE,
.end = OMAP1610_GPIO4_BASE + SZ_2K - 1,
@@ -187,37 +187,29 @@ static struct resource omap16xx_gpio4_resources[] = {
},
};
-static struct omap_gpio_platform_data omap16xx_gpio4_config = {
+static const struct omap_gpio_platform_data omap16xx_gpio4_config __initconst = {
.bank_width = 16,
.regs = &omap16xx_gpio_regs,
};
-static const struct software_node omap16xx_gpio4_swnode = { };
-
-static struct platform_device omap16xx_gpio4 = {
- .name = "omap_gpio",
- .id = 4,
- .dev = {
- .platform_data = &omap16xx_gpio4_config,
- },
- .num_resources = ARRAY_SIZE(omap16xx_gpio4_resources),
- .resource = omap16xx_gpio4_resources,
-};
+static const struct software_node omap16xx_gpio4_swnode;
-static struct platform_device *omap16xx_gpio_dev[] __initdata = {
- &omap16xx_mpu_gpio,
- &omap16xx_gpio1,
- &omap16xx_gpio2,
- &omap16xx_gpio3,
- &omap16xx_gpio4,
+static const struct platform_device_info omap16xx_gpio4_info __initconst = {
+ .name = "omap_gpio",
+ .id = 4,
+ .data = &omap16xx_gpio4_config,
+ .size_data = sizeof(omap16xx_gpio4_config),
+ .res = omap16xx_gpio4_resources,
+ .num_res = ARRAY_SIZE(omap16xx_gpio4_resources),
+ .swnode = &omap16xx_gpio4_swnode,
};
-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,
+static const struct platform_device_info * const omap16xx_gpio_dev[] __initconst = {
+ &omap16xx_mpu_gpio_info,
+ &omap16xx_gpio1_info,
+ &omap16xx_gpio2_info,
+ &omap16xx_gpio3_info,
+ &omap16xx_gpio4_info,
};
/*
@@ -227,11 +219,7 @@ static const struct software_node *omap16xx_gpio_swnodes[] __initconst = {
*/
static int __init omap16xx_gpio_init(void)
{
- int i, ret;
- void __iomem *base;
- struct resource *res;
- struct platform_device *pdev;
- struct omap_gpio_platform_data *pdata;
+ int i;
if (!cpu_is_omap16xx())
return -EINVAL;
@@ -240,36 +228,41 @@ static int __init omap16xx_gpio_init(void)
* Enable system clock for GPIO module.
* The CAM_CLK_CTRL *is* really the right place.
*/
- omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04,
- ULPD_CAM_CLK_CTRL);
+ omap_writel(omap_readl(ULPD_CAM_CLK_CTRL) | 0x04, ULPD_CAM_CLK_CTRL);
for (i = 0; i < ARRAY_SIZE(omap16xx_gpio_dev); i++) {
- pdev = omap16xx_gpio_dev[i];
- pdata = pdev->dev.platform_data;
+ const struct platform_device_info *pdev_info = omap16xx_gpio_dev[i];
+ const struct resource *res = NULL;
+ struct platform_device *pdev;
+ void __iomem *base;
+ int j;
+
+ for (j = 0; j < pdev_info->num_res; j++) {
+ if (resource_type(&pdev_info->res[j]) == IORESOURCE_MEM) {
+ res = &pdev_info->res[j];
+ break;
+ }
+ }
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (unlikely(!res)) {
- dev_err(&pdev->dev, "Invalid mem resource.\n");
+ pr_err("gpio%d: Invalid mem resource.\n", i);
return -ENODEV;
}
base = ioremap(res->start, resource_size(res));
if (unlikely(!base)) {
- dev_err(&pdev->dev, "ioremap failed.\n");
+ pr_err("gpio%d: ioremap failed.\n", i);
return -ENOMEM;
}
__raw_writel(SYSCONFIG_WORD, base + OMAP1610_GPIO_SYSCONFIG);
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;
+ pdev = platform_device_register_full(pdev_info);
+ if (IS_ERR(pdev)) {
+ pr_err("gpio%d: Failed to register device: %ld\n",
+ i, PTR_ERR(pdev));
+ return PTR_ERR(pdev);
}
}
>
> Thanks.
>
--
Dmitry
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-12 1:12 ` Dmitry Torokhov
@ 2026-02-12 6:57 ` Arnd Bergmann
0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2026-02-12 6:57 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Bartosz Golaszewski, Aaro Koskinen, Janusz Krzysztofik,
Tony Lindgren, Russell King, Hans de Goede, Linux-OMAP,
linux-arm-kernel, linux-kernel, Bartosz Golaszewski
On Thu, Feb 12, 2026, at 02:12, Dmitry Torokhov wrote:
> On Wed, Feb 11, 2026 at 01:40:44PM -0800, Dmitry Torokhov wrote:
>> On Wed, Feb 11, 2026 at 05:31:52PM +0100, Arnd Bergmann wrote:
>> >
>> > Do you know if there is a good way to do this without using static
>> > platform devices?
>>
>> I wonder if something like below will help reducing boilerplate...
>
> And then we can change the gpio16xx like this (on top of Bartosz
> changes):
> @@ -49,27 +49,27 @@ static struct omap_gpio_reg_offs omap16xx_mpuio_regs = {
> .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
> };
>
> -static struct omap_gpio_platform_data omap16xx_mpu_gpio_config = {
> +static const struct omap_gpio_platform_data omap16xx_mpu_gpio_config
> __initconst = {
> .is_mpuio = true,
> .bank_width = 16,
> .bank_stride = 1,
> .regs = &omap16xx_mpuio_regs,
> };
>
> -const struct software_node omap16xx_mpu_gpio_swnode = { };
> +static const struct software_node omap16xx_mpu_gpio_swnode;
>
> -static struct platform_device omap16xx_mpu_gpio = {
> - .name = "omap_gpio",
> - .id = 0,
> - .dev = {
> - .platform_data = &omap16xx_mpu_gpio_config,
> - },
> - .num_resources = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
> - .resource = omap16xx_mpu_gpio_resources,
> +static const struct platform_device_info omap16xx_mpu_gpio_info __initconst = {
> + .name = "omap_gpio",
> + .id = 0,
> + .data = &omap16xx_mpu_gpio_config,
> + .size_data = sizeof(omap16xx_mpu_gpio_config),
> + .res = omap16xx_mpu_gpio_resources,
> + .num_res = ARRAY_SIZE(omap16xx_mpu_gpio_resources),
> + .swnode = &omap16xx_mpu_gpio_swnode,
> };
Yes, that looks really nice!
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-11 16:31 ` Arnd Bergmann
2026-02-11 21:40 ` Dmitry Torokhov
@ 2026-02-12 11:40 ` Bartosz Golaszewski
2026-02-12 11:45 ` Arnd Bergmann
1 sibling, 1 reply; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-02-12 11:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Bartosz Golaszewski, Aaro Koskinen, Janusz Krzysztofik,
Tony Lindgren, Russell King, Dmitry Torokhov, Hans de Goede,
Linux-OMAP, linux-arm-kernel, linux-kernel
On Wed, Feb 11, 2026 at 5:32 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote:
> > 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.
> >
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
> > ---
>
> I don't see mistakes here, and I don't want to throw a wrench in
> this patch, but I wonder if there is a way to take this one step further:
>
> > @@ -244,6 +263,14 @@ 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 was planning to go through the remaining 'static struct platform_device'
> definitions in arch/arm/ after the planned board file removal and
> try to convert these to 'platform_device_info' or similar, using
> platform_device_register_full(). Since that function already contains
> code to dynamically allocate the software_node, I had hoped that
> a lot of this would just go away.
>
> However, I see that your patch creates pointers to those software_node
> instances, so think that would become a bit harder, but I have not
> actually tried it.
>
> Do you know if there is a good way to do this without using static
> platform devices?
>
Add a pointer to const struct software_node to platform_device_info
and then use this if it's set and there's no fwnode? It's in line with
what MFD does with its cells.
In any case, I'd prefer to not overcomplicate this patch, let's do it
separately?
Bart
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770
2026-02-12 11:40 ` Bartosz Golaszewski
@ 2026-02-12 11:45 ` Arnd Bergmann
0 siblings, 0 replies; 8+ messages in thread
From: Arnd Bergmann @ 2026-02-12 11:45 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Bartosz Golaszewski, Aaro Koskinen, Janusz Krzysztofik,
Tony Lindgren, Russell King, Dmitry Torokhov, Hans de Goede,
Linux-OMAP, linux-arm-kernel, linux-kernel
On Thu, Feb 12, 2026, at 12:40, Bartosz Golaszewski wrote:
> On Wed, Feb 11, 2026 at 5:32 PM Arnd Bergmann <arnd@kernel.org> wrote:
>> On Wed, Feb 11, 2026, at 14:13, Bartosz Golaszewski wrote:
>
> Add a pointer to const struct software_node to platform_device_info
> and then use this if it's set and there's no fwnode? It's in line with
> what MFD does with its cells.
Right, that's what Dmitry also suggested, see his earlier patch/
> In any case, I'd prefer to not overcomplicate this patch, let's do it
> separately?
Sure, I mainly wanted to make sure we're not blocking future
changes here that I had already planned, and this sounds like
we can change that later without undoing all of your patch again.
Arnd
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-02-12 11:46 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11 13:13 [RFT PATCH v2] ARM: omap1: enable real software node lookup of GPIOs on Nokia 770 Bartosz Golaszewski
2026-02-11 13:19 ` Bartosz Golaszewski
2026-02-11 16:31 ` Arnd Bergmann
2026-02-11 21:40 ` Dmitry Torokhov
2026-02-12 1:12 ` Dmitry Torokhov
2026-02-12 6:57 ` Arnd Bergmann
2026-02-12 11:40 ` Bartosz Golaszewski
2026-02-12 11:45 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox