Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 29c4e69

Browse files
dtorarndb
authored andcommitted
ARM: spitz: Use software nodes to describe LED GPIOs
Convert Spitz to use software nodes for specifying GPIOs for the LEDs. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20240628180852.1738922-10-dmitry.torokhov@gmail.com Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 444b898 commit 29c4e69

File tree

1 file changed

+50
-21
lines changed

1 file changed

+50
-21
lines changed

arch/arm/mach-pxa/spitz.c

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -467,35 +467,64 @@ static inline void spitz_keys_init(void) {}
467467
* LEDs
468468
******************************************************************************/
469469
#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
470-
static struct gpio_led spitz_gpio_leds[] = {
471-
{
472-
.name = "spitz:amber:charge",
473-
.default_trigger = "sharpsl-charge",
474-
.gpio = SPITZ_GPIO_LED_ORANGE,
475-
},
476-
{
477-
.name = "spitz:green:hddactivity",
478-
.default_trigger = "disk-activity",
479-
.gpio = SPITZ_GPIO_LED_GREEN,
480-
},
470+
static const struct software_node spitz_gpio_leds_node = {
471+
.name = "spitz-leds",
481472
};
482473

483-
static struct gpio_led_platform_data spitz_gpio_leds_info = {
484-
.leds = spitz_gpio_leds,
485-
.num_leds = ARRAY_SIZE(spitz_gpio_leds),
474+
static const struct property_entry spitz_orange_led_props[] = {
475+
PROPERTY_ENTRY_STRING("linux,default-trigger", "sharpsl-charge"),
476+
PROPERTY_ENTRY_GPIO("gpios",
477+
&spitz_scoop_1_gpiochip_node, 6, GPIO_ACTIVE_HIGH),
478+
{ }
486479
};
487480

488-
static struct platform_device spitz_led_device = {
489-
.name = "leds-gpio",
490-
.id = -1,
491-
.dev = {
492-
.platform_data = &spitz_gpio_leds_info,
493-
},
481+
static const struct software_node spitz_orange_led_node = {
482+
.name = "spitz:amber:charge",
483+
.parent = &spitz_gpio_leds_node,
484+
.properties = spitz_orange_led_props,
485+
};
486+
487+
static const struct property_entry spitz_green_led_props[] = {
488+
PROPERTY_ENTRY_STRING("linux,default-trigger", "disk-activity"),
489+
PROPERTY_ENTRY_GPIO("gpios",
490+
&spitz_scoop_1_gpiochip_node, 0, GPIO_ACTIVE_HIGH),
491+
{ }
492+
};
493+
494+
static const struct software_node spitz_green_led_node = {
495+
.name = "spitz:green:hddactivity",
496+
.parent = &spitz_gpio_leds_node,
497+
.properties = spitz_green_led_props,
498+
};
499+
500+
static const struct software_node *spitz_gpio_leds_swnodes[] = {
501+
&spitz_gpio_leds_node,
502+
&spitz_orange_led_node,
503+
&spitz_green_led_node,
504+
NULL
494505
};
495506

496507
static void __init spitz_leds_init(void)
497508
{
498-
platform_device_register(&spitz_led_device);
509+
struct platform_device_info led_info = {
510+
.name = "leds-gpio",
511+
.id = PLATFORM_DEVID_NONE,
512+
};
513+
struct platform_device *led_dev;
514+
int err;
515+
516+
err = software_node_register_node_group(spitz_gpio_leds_swnodes);
517+
if (err) {
518+
pr_err("failed to register LED software nodes: %d\n", err);
519+
return;
520+
}
521+
522+
led_info.fwnode = software_node_fwnode(&spitz_gpio_leds_node);
523+
524+
led_dev = platform_device_register_full(&led_info);
525+
err = PTR_ERR_OR_ZERO(led_dev);
526+
if (err)
527+
pr_err("failed to create LED device: %d\n", err);
499528
}
500529
#else
501530
static inline void spitz_leds_init(void) {}

0 commit comments

Comments
 (0)