[PATCH v3 06/10] ARM: s3c: crag6410: use software nodes/properties to set up GPIO keys
From: Dmitry Torokhov
Date: Sat Jul 11 2026 - 22:15:47 EST
Switch the gpio-keys device to use software nodes/properties to
describe the buttons and switches. This will allow dropping support
for platform data from the gpio-keys driver in the future.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
arch/arm/mach-s3c/mach-crag6410.c | 79 ++++++++++++++++++++++++++++-----------
1 file changed, 58 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-s3c/mach-crag6410.c b/arch/arm/mach-s3c/mach-crag6410.c
index c2df5dcb3368..757c0f383ff1 100644
--- a/arch/arm/mach-s3c/mach-crag6410.c
+++ b/arch/arm/mach-s3c/mach-crag6410.c
@@ -18,6 +18,7 @@
#include <linux/input/matrix_keypad.h>
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
+#include <linux/gpio/property.h>
#include <linux/leds.h>
#include <linux/delay.h>
#include <linux/mmc/host.h>
@@ -228,32 +229,68 @@ static void __init crag6410_setup_keypad(void)
pr_err("failed to instantiate keypad device\n");
}
-static struct gpio_keys_button crag6410_gpio_keys[] = {
- [0] = {
- .code = KEY_SUSPEND,
- .gpio = S3C64XX_GPL(10), /* EINT 18 */
- .type = EV_KEY,
- .wakeup = 1,
- .active_low = 1,
- },
- [1] = {
- .code = SW_FRONT_PROXIMITY,
- .gpio = S3C64XX_GPN(11), /* EINT 11 */
- .type = EV_SW,
- },
+static const struct software_node crag6410_gpio_keys_node = {
+ .name = "crag6410-gpio-keys",
};
-static struct gpio_keys_platform_data crag6410_gpio_keydata = {
- .buttons = crag6410_gpio_keys,
- .nbuttons = ARRAY_SIZE(crag6410_gpio_keys),
+static const struct property_entry crag6410_suspend_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", KEY_SUSPEND),
+ PROPERTY_ENTRY_GPIO("gpios",
+ SAMSUNG_GPIO_NODE('L'), 10, /* EINT 18 */
+ GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_BOOL("wakeup-source"),
+ { }
};
-static struct platform_device crag6410_gpio_keydev = {
- .name = "gpio-keys",
- .id = 0,
- .dev.platform_data = &crag6410_gpio_keydata,
+static const struct software_node crag6410_suspend_key_node = {
+ .parent = &crag6410_gpio_keys_node,
+ .properties = crag6410_suspend_key_props,
+};
+
+static const struct property_entry crag6410_prox_sw_props[] = {
+ PROPERTY_ENTRY_U32("linux,input-type", EV_SW),
+ PROPERTY_ENTRY_U32("linux,code", SW_FRONT_PROXIMITY),
+ PROPERTY_ENTRY_GPIO("gpios",
+ SAMSUNG_GPIO_NODE('N'), 11, /* EINT 11 */
+ GPIO_ACTIVE_HIGH),
+ { }
+};
+
+static const struct software_node crag6410_prox_sw_node = {
+ .parent = &crag6410_gpio_keys_node,
+ .properties = crag6410_prox_sw_props,
};
+static const struct software_node *crag6410_gpio_keys_swnodes[] = {
+ &crag6410_gpio_keys_node,
+ &crag6410_suspend_key_node,
+ &crag6410_prox_sw_node,
+ NULL
+};
+
+static void __init crag6410_setup_gpio_keys(void)
+{
+ struct platform_device_info keys_info = {
+ .name = "gpio-keys",
+ .id = 0,
+ };
+ struct platform_device *pd;
+ int err;
+
+ err = software_node_register_node_group(crag6410_gpio_keys_swnodes);
+ if (err) {
+ pr_err("failed to register gpio-keys software nodes: %d\n", err);
+ return;
+ }
+
+ keys_info.fwnode = software_node_fwnode(&crag6410_gpio_keys_node);
+
+ pd = platform_device_register_full(&keys_info);
+ err = PTR_ERR_OR_ZERO(pd);
+ if (err)
+ pr_err("failed to create gpio-keys device: %d\n", err);
+}
+
static struct resource crag6410_dm9k_resource[] = {
[0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5, 2),
[1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5 + (1 << 8), 2),
@@ -397,7 +434,6 @@ static struct platform_device *crag6410_devs0[] __initdata = {
&samsung_device_pwm,
&s3c64xx_device_iis0,
&s3c64xx_device_iis1,
- &crag6410_gpio_keydev,
};
static struct platform_device *crag6410_devs1[] __initdata = {
@@ -909,6 +945,7 @@ static void __init crag6410_machine_init(void)
gpiod_add_lookup_table(&crag_leds_table);
crag6410_setup_keypad();
+ crag6410_setup_gpio_keys();
platform_add_devices(crag6410_devs1, ARRAY_SIZE(crag6410_devs1));
gpio_led_register_device(-1, &gpio_leds_pdata);
--
2.55.0.795.g602f6c329a-goog