Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ARM: spitz: Use software nodes/properties for the GPIO-driven buttons

Convert the Spitz to use software nodes and static properties to
describe GPIOs for the GPIO-driven buttons.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20240805014710.1961677-4-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+68 -31
+68 -31
arch/arm/mach-pxa/spitz.c
··· 419 419 * GPIO keys 420 420 ******************************************************************************/ 421 421 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) 422 - static struct gpio_keys_button spitz_gpio_keys[] = { 423 - { 424 - .type = EV_PWR, 425 - .code = KEY_SUSPEND, 426 - .gpio = SPITZ_GPIO_ON_KEY, 427 - .desc = "On Off", 428 - .wakeup = 1, 429 - }, 430 - /* Two buttons detecting the lid state */ 431 - { 432 - .type = EV_SW, 433 - .code = 0, 434 - .gpio = SPITZ_GPIO_SWA, 435 - .desc = "Display Down", 436 - }, 437 - { 438 - .type = EV_SW, 439 - .code = 1, 440 - .gpio = SPITZ_GPIO_SWB, 441 - .desc = "Lid Closed", 442 - }, 422 + static const struct software_node spitz_gpio_keys_node = { 423 + .name = "spitz-gpio-keys", 443 424 }; 444 425 445 - static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = { 446 - .buttons = spitz_gpio_keys, 447 - .nbuttons = ARRAY_SIZE(spitz_gpio_keys), 426 + static const struct property_entry spitz_suspend_key_props[] = { 427 + PROPERTY_ENTRY_U32("linux,input-type", EV_PWR), 428 + PROPERTY_ENTRY_U32("linux,code", KEY_SUSPEND), 429 + PROPERTY_ENTRY_GPIO("gpios", &pxa2xx_gpiochip_node, 430 + SPITZ_GPIO_ON_KEY, GPIO_ACTIVE_HIGH), 431 + PROPERTY_ENTRY_STRING("label", "On Off"), 432 + PROPERTY_ENTRY_BOOL("wakeup-source"), 433 + { } 448 434 }; 449 435 450 - static struct platform_device spitz_gpio_keys_device = { 451 - .name = "gpio-keys", 452 - .id = -1, 453 - .dev = { 454 - .platform_data = &spitz_gpio_keys_platform_data, 455 - }, 436 + static const struct software_node spitz_suspend_key_node = { 437 + .parent = &spitz_gpio_keys_node, 438 + .properties = spitz_suspend_key_props, 439 + }; 440 + 441 + static const struct property_entry spitz_sw1_props[] = { 442 + PROPERTY_ENTRY_U32("linux,input-type", EV_SW), 443 + PROPERTY_ENTRY_U32("linux,code", 0), 444 + PROPERTY_ENTRY_GPIO("gpios", &pxa2xx_gpiochip_node, 445 + SPITZ_GPIO_SWA, GPIO_ACTIVE_HIGH), 446 + PROPERTY_ENTRY_STRING("label", "Display Down"), 447 + { } 448 + }; 449 + 450 + static const struct software_node spitz_sw1_node = { 451 + .parent = &spitz_gpio_keys_node, 452 + .properties = spitz_sw1_props, 453 + }; 454 + 455 + static const struct property_entry spitz_sw2_props[] = { 456 + PROPERTY_ENTRY_U32("linux,input-type", EV_SW), 457 + PROPERTY_ENTRY_U32("linux,code", 1), 458 + PROPERTY_ENTRY_GPIO("gpios", &pxa2xx_gpiochip_node, 459 + SPITZ_GPIO_SWB, GPIO_ACTIVE_HIGH), 460 + PROPERTY_ENTRY_STRING("label", "Lid Closed"), 461 + { } 462 + }; 463 + 464 + static const struct software_node spitz_sw2_node = { 465 + .parent = &spitz_gpio_keys_node, 466 + .properties = spitz_sw2_props, 467 + }; 468 + 469 + static const struct software_node *spitz_gpio_keys_swnodes[] = { 470 + &spitz_gpio_keys_node, 471 + &spitz_suspend_key_node, 472 + &spitz_sw1_node, 473 + &spitz_sw2_node, 474 + NULL 456 475 }; 457 476 458 477 static void __init spitz_keys_init(void) 459 478 { 460 - platform_device_register(&spitz_gpio_keys_device); 479 + struct platform_device_info keys_info = { 480 + .name = "gpio-keys", 481 + .id = PLATFORM_DEVID_NONE, 482 + }; 483 + struct platform_device *pd; 484 + int err; 485 + 486 + err = software_node_register_node_group(spitz_gpio_keys_swnodes); 487 + if (err) { 488 + pr_err("failed to register gpio-keys software nodes: %d\n", err); 489 + return; 490 + } 491 + 492 + keys_info.fwnode = software_node_fwnode(&spitz_gpio_keys_node); 493 + 494 + pd = platform_device_register_full(&keys_info); 495 + err = PTR_ERR_OR_ZERO(pd); 496 + if (err) 497 + pr_err("failed to create gpio-keys device: %d\n", err); 461 498 } 462 499 #else 463 500 static inline void spitz_keys_init(void) {}