[PATCH 7/7] ARM: orion5x: ts409: convert gpio-keys to use software nodes
Dmitry Torokhov
dmitry.torokhov at gmail.com
Sun Jul 5 18:29:24 PDT 2026
Convert the QNAP TS-409 board setup from legacy gpio_keys_platform_data
to software nodes. The gpio-keys platform device is registered with
static software node properties and button configurations.
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Dmitry Torokhov <dmitry.torokhov at gmail.com>
---
arch/arm/mach-orion5x/ts409-setup.c | 69 ++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 24 deletions(-)
diff --git a/arch/arm/mach-orion5x/ts409-setup.c b/arch/arm/mach-orion5x/ts409-setup.c
index 725688aa5cba..6758aebd327b 100644
--- a/arch/arm/mach-orion5x/ts409-setup.c
+++ b/arch/arm/mach-orion5x/ts409-setup.c
@@ -17,10 +17,12 @@
#include <linux/mtd/physmap.h>
#include <linux/mv643xx_eth.h>
#include <linux/leds.h>
-#include <linux/gpio_keys.h>
+#include <linux/gpio/property.h>
+#include <linux/property.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/serial_reg.h>
+#include <plat/orion-gpio.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/pci.h>
@@ -214,32 +216,47 @@ static struct platform_device ts409_leds = {
#define QNAP_TS409_GPIO_KEY_RESET 14
#define QNAP_TS409_GPIO_KEY_MEDIA 15
-static struct gpio_keys_button qnap_ts409_buttons[] = {
- {
- .code = KEY_RESTART,
- .gpio = QNAP_TS409_GPIO_KEY_RESET,
- .desc = "Reset Button",
- .active_low = 1,
- }, {
- .code = KEY_COPY,
- .gpio = QNAP_TS409_GPIO_KEY_MEDIA,
- .desc = "USB Copy Button",
- .active_low = 1,
- },
+static const struct software_node qnap_ts409_gpio_keys_node = {
+ .name = "qnap-ts409-gpio-keys",
};
-static struct gpio_keys_platform_data qnap_ts409_button_data = {
- .buttons = qnap_ts409_buttons,
- .nbuttons = ARRAY_SIZE(qnap_ts409_buttons),
+static const struct property_entry qnap_ts409_reset_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", KEY_RESTART),
+ PROPERTY_ENTRY_GPIO("gpios", &orion_gpio_swnodes[0],
+ QNAP_TS409_GPIO_KEY_RESET, GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_STRING("label", "Reset Button"),
+ { }
};
-static struct platform_device qnap_ts409_button_device = {
- .name = "gpio-keys",
- .id = -1,
- .num_resources = 0,
- .dev = {
- .platform_data = &qnap_ts409_button_data,
- },
+static const struct software_node qnap_ts409_reset_key_node = {
+ .parent = &qnap_ts409_gpio_keys_node,
+ .properties = qnap_ts409_reset_key_props,
+};
+
+static const struct property_entry qnap_ts409_copy_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", KEY_COPY),
+ PROPERTY_ENTRY_GPIO("gpios", &orion_gpio_swnodes[0],
+ QNAP_TS409_GPIO_KEY_MEDIA, GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_STRING("label", "USB Copy Button"),
+ { }
+};
+
+static const struct software_node qnap_ts409_copy_key_node = {
+ .parent = &qnap_ts409_gpio_keys_node,
+ .properties = qnap_ts409_copy_key_props,
+};
+
+static const struct software_node * const qnap_ts409_gpio_keys_swnodes[] __initconst = {
+ &qnap_ts409_gpio_keys_node,
+ &qnap_ts409_reset_key_node,
+ &qnap_ts409_copy_key_node,
+ NULL
+};
+
+static const struct platform_device_info qnap_ts409_button_info __initconst = {
+ .name = "gpio-keys",
+ .id = PLATFORM_DEVID_NONE,
+ .swnode = &qnap_ts409_gpio_keys_node,
};
/*****************************************************************************
@@ -271,6 +288,8 @@ static unsigned int ts409_mpp_modes[] __initdata = {
static void __init qnap_ts409_init(void)
{
+ int err;
+
/*
* Setup basic Orion functions. Need to be called early.
*/
@@ -296,7 +315,9 @@ static void __init qnap_ts409_init(void)
orion5x_uart0_init();
orion5x_uart1_init();
- platform_device_register(&qnap_ts409_button_device);
+ err = software_node_register_node_group(qnap_ts409_gpio_keys_swnodes);
+ if (!err)
+ platform_device_register_full(&qnap_ts409_button_info);
/* Get RTC IRQ and register the chip */
if (gpio_request(TS409_RTC_GPIO, "rtc") == 0) {
--
2.55.0.rc0.799.gd6f94ed593-goog
More information about the linux-arm-kernel
mailing list