leds: leds-gpio for ngw100

Add GPIO leds to the NGW100 platform and its defconfig.
Access through /sys/class/leds/{a,b,sys}/* files; one
defaults to a heartbeat.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Richard Purdie <rpurdie@rpsys.net>

authored by David Brownell and committed by Richard Purdie f9f451d9 e3986f63

+46 -1
+31
arch/avr32/boards/atngw100/setup.c
··· 13 13 #include <linux/linkage.h> 14 14 #include <linux/platform_device.h> 15 15 #include <linux/types.h> 16 + #include <linux/leds.h> 16 17 #include <linux/spi/spi.h> 17 18 18 19 #include <asm/io.h> ··· 22 21 #include <asm/arch/at32ap7000.h> 23 22 #include <asm/arch/board.h> 24 23 #include <asm/arch/init.h> 24 + #include <asm/arch/portmux.h> 25 25 26 26 /* Initialized by bootloader-specific startup code. */ 27 27 struct tag *bootloader_tags __initdata; ··· 102 100 at32_setup_serial_console(0); 103 101 } 104 102 103 + static const struct gpio_led ngw_leds[] = { 104 + { .name = "sys", .gpio = GPIO_PIN_PA(16), .active_low = 1, 105 + .default_trigger = "heartbeat", 106 + }, 107 + { .name = "a", .gpio = GPIO_PIN_PA(19), .active_low = 1, }, 108 + { .name = "b", .gpio = GPIO_PIN_PE(19), .active_low = 1, }, 109 + }; 110 + 111 + static const struct gpio_led_platform_data ngw_led_data = { 112 + .num_leds = ARRAY_SIZE(ngw_leds), 113 + .leds = (void *) ngw_leds, 114 + }; 115 + 116 + static struct platform_device ngw_gpio_leds = { 117 + .name = "leds-gpio", 118 + .id = -1, 119 + .dev = { 120 + .platform_data = (void *) &ngw_led_data, 121 + } 122 + }; 123 + 105 124 static int __init atngw100_init(void) 106 125 { 126 + unsigned i; 127 + 107 128 /* 108 129 * ATNGW100 uses 16-bit SDRAM interface, so we don't need to 109 130 * reserve any pins for it. ··· 140 115 set_hw_addr(at32_add_device_eth(1, &eth_data[1])); 141 116 142 117 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info)); 118 + 119 + for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) { 120 + at32_select_gpio(ngw_leds[i].gpio, 121 + AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH); 122 + } 123 + platform_device_register(&ngw_gpio_leds); 143 124 144 125 return 0; 145 126 }
+15 -1
arch/avr32/configs/atngw100_defconfig
··· 712 712 # 713 713 # LED devices 714 714 # 715 - # CONFIG_NEW_LEDS is not set 715 + CONFIG_NEW_LEDS=y 716 + CONFIG_LEDS_CLASS=y 717 + 718 + # 719 + # LED drivers 720 + # 721 + CONFIG_LEDS_GPIO=y 722 + 723 + # 724 + # LED Triggers 725 + # 726 + CONFIG_LEDS_TRIGGERS=y 727 + CONFIG_LEDS_TRIGGER_TIMER=y 728 + CONFIG_LEDS_TRIGGER_HEARTBEAT=y 729 + 716 730 717 731 # 718 732 # LED drivers