[PATCH 1/2] MIPS/input: Move RB532 button to GPIO descriptors
Dmitry Torokhov
dmitry.torokhov at gmail.com
Sun Mar 29 15:38:53 PDT 2026
Hi Linus,
On Sat, Mar 28, 2026 at 04:55:47PM +0100, Linus Walleij wrote:
> Convert the Mikrotik RouterBoard RB532 to use GPIO descriptors
> by defining a software node for the GPIO chip, then register
> the button platform device with full info passing the GPIO
> as a device property.
>
> This can be used as a base to move more of the RB532 devices
> over to passing GPIOs using device properties.
>
> Use the GPIO_ACTIVE_LOW flag and drop the inversion in the
> rb532_button_pressed() function.
>
> Signed-off-by: Linus Walleij <linusw at kernel.org>
> ---
> arch/mips/rb532/devices.c | 47 +++++++++++++++++++++++++++++++++------
> drivers/input/misc/rb532_button.c | 35 ++++++++++++++++++++++++-----
> 2 files changed, 69 insertions(+), 13 deletions(-)
>
> diff --git a/arch/mips/rb532/devices.c b/arch/mips/rb532/devices.c
> index 4f027efbf27b..3f56d9feb73a 100644
> --- a/arch/mips/rb532/devices.c
> +++ b/arch/mips/rb532/devices.c
> @@ -16,8 +16,10 @@
> #include <linux/mtd/mtd.h>
> #include <linux/gpio.h>
> #include <linux/gpio/machine.h>
> +#include <linux/gpio/property.h>
> #include <linux/gpio_keys.h>
> #include <linux/input.h>
> +#include <linux/property.h>
> #include <linux/serial_8250.h>
>
> #include <asm/bootinfo.h>
> @@ -38,6 +40,10 @@ extern unsigned int idt_cpu_freq;
>
> static struct mpmc_device dev3;
>
> +static const struct software_node rb532_gpio0_node = {
> + .name = "gpio0",
> +};
You need to move this and registration into arch/mips/rb532/gpio.c,
export it and use it here: Bartosz is against using gpiohip label to
match with software node name and prefers identity matching.
...
> -static bool rb532_button_pressed(void)
> +static bool rb532_button_pressed(struct rb532_button *button)
> {
> int val;
>
> set_latch_u5(0, LO_FOFF);
> - gpio_direction_input(GPIO_BTN_S1);
> + gpiod_direction_input(button->gpio);
>
> - val = gpio_get_value(GPIO_BTN_S1);
> + val = gpiod_get_value(button->gpio);
>
> rb532_gpio_set_func(GPIO_BTN_S1);
> set_latch_u5(LO_FOFF, 0);
>
> - return !val;
> + return val;
> }
I suppose there is no reasonable way of making this work with
gpio-keys...
For input piece:
Acked-by: Dmitry Torokhov <dmitry.torokhov at gmail.com>
Thanks.
--
Dmitry
More information about the linux-mtd
mailing list