From: Bartosz Golaszewski Date: Thu, 30 Apr 2026 11:23:13 +0000 (+0200) Subject: MIPS: RB532: attach the software node to its target GPIO controller X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5e8e224eb7ac003edcebfc7a00cefc38063bd18;p=thirdparty%2Fkernel%2Flinux.git MIPS: RB532: attach the software node to its target GPIO controller GPIOLIB wants to remove the software node's name matching against GPIO controller's label that is going on behind the scenes in software node lookup. To that end, we need to convert all existing users to using software nodes actually attached to the GPIO devices they represent. In order to use an attached software node with the GPIO controller on rb532: convert the GPIO module into a real platform device, provide platform device info for it in device.c and assign the software node using its swnode field. The software node will get inherited by the GPIO chip from the parent platform device in devm_gpiochip_add_data() as we don't set the fwnode using any other of the mechanisms. Signed-off-by: Bartosz Golaszewski Reviewed-by: Linus Walleij Signed-off-by: Thomas Bogendoerfer --- diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c index c3d8d96d0ef55..a6e3dc11298b7 100644 --- a/arch/mips/rb532/devices.c +++ b/arch/mips/rb532/devices.c @@ -240,6 +240,25 @@ static struct platform_device *rb532_devs[] = { &rb532_wdt }; +#define GPIOBASE 0x050000 + +static struct resource rb532_gpio_reg0_res[] = { + { + .name = "gpio_reg0", + .start = REGBASE + GPIOBASE, + .end = REGBASE + GPIOBASE + sizeof(struct rb532_gpio_reg) - 1, + .flags = IORESOURCE_MEM, + } +}; + +static struct platform_device_info rb532_gpio_devinfo = { + .name = "rb532-gpio", + .id = PLATFORM_DEVID_NONE, + .res = rb532_gpio_reg0_res, + .num_res = ARRAY_SIZE(rb532_gpio_reg0_res), + .swnode = &rb532_gpio0_node, +}; + static const struct property_entry rb532_button_properties[] = { PROPERTY_ENTRY_GPIO("button-gpios", &rb532_gpio0_node, GPIO_BTN_S1, GPIO_ACTIVE_LOW), @@ -309,17 +328,18 @@ static int __init plat_setup_devices(void) /* set the uart clock to the current cpu frequency */ rb532_uart_res[0].uartclk = idt_cpu_freq; + pd = platform_device_register_full(&rb532_gpio_devinfo); + ret = PTR_ERR_OR_ZERO(pd); + if (ret) { + pr_err("failed to create the GPIO device: %d\n", ret); + return ret; + } + gpiod_add_lookup_table(&cf_slot0_gpio_table); ret = platform_add_devices(rb532_devs, ARRAY_SIZE(rb532_devs)); if (ret) return ret; - /* - * Stack devices using full info and properties here, after we - * register the node for the GPIO chip. - */ - software_node_register(&rb532_gpio0_node); - pd = platform_device_register_full(&nand0_info); ret = PTR_ERR_OR_ZERO(pd); if (ret) { diff --git a/arch/mips/rb532/gpio.c b/arch/mips/rb532/gpio.c index 9aa5ef374465c..49e1a15a3827e 100644 --- a/arch/mips/rb532/gpio.c +++ b/arch/mips/rb532/gpio.c @@ -37,7 +37,6 @@ #include #include -#define GPIOBASE 0x050000 /* Offsets relative to GPIOBASE */ #define GPIOFUNC 0x00 #define GPIOCFG 0x04 @@ -52,15 +51,6 @@ struct rb532_gpio_chip { void __iomem *regbase; }; -static struct resource rb532_gpio_reg0_res[] = { - { - .name = "gpio_reg0", - .start = REGBASE + GPIOBASE, - .end = REGBASE + GPIOBASE + sizeof(struct rb532_gpio_reg) - 1, - .flags = IORESOURCE_MEM, - } -}; - /* rb532_set_bit - sanely set a bit * * bitval: new value for the bit @@ -199,21 +189,32 @@ void rb532_gpio_set_func(unsigned gpio) } EXPORT_SYMBOL(rb532_gpio_set_func); -static int __init rb532_gpio_init(void) +static int rb532_gpio_probe(struct platform_device *pdev) { - struct resource *r; + struct device *dev = &pdev->dev; + struct resource *res; - r = rb532_gpio_reg0_res; - rb532_gpio_chip->regbase = ioremap(r->start, resource_size(r)); + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; - if (!rb532_gpio_chip->regbase) { - printk(KERN_ERR "rb532: cannot remap GPIO register 0\n"); - return -ENXIO; - } + rb532_gpio_chip->regbase = devm_ioremap_resource(dev, res); + if (IS_ERR(rb532_gpio_chip->regbase)) + return PTR_ERR(rb532_gpio_chip->regbase); /* Register our GPIO chip */ - gpiochip_add_data(&rb532_gpio_chip->chip, rb532_gpio_chip); + return devm_gpiochip_add_data(dev, &rb532_gpio_chip->chip, rb532_gpio_chip); +} - return 0; +static struct platform_driver rb532_gpio_driver = { + .driver = { + .name = "rb532-gpio", + }, + .probe = rb532_gpio_probe, +}; + +static int __init rb532_gpio_init(void) +{ + return platform_driver_register(&rb532_gpio_driver); } arch_initcall(rb532_gpio_init);