Browse Source

add LED support for AVR32 Grasshopper board

Mario Haustein 7 years ago
parent
commit
64f0969359

+ 118 - 0
target/avr32/grasshopper/patches/4.7.3/0002-grasshopper-led-pwm.patch

@@ -0,0 +1,118 @@
+diff -Naur linux-4.7.3/arch/avr32/boards/grasshopper/Kconfig linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/Kconfig
+--- linux-4.7.3/arch/avr32/boards/grasshopper/Kconfig	2016-09-21 17:42:47.405315973 +0200
++++ linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/Kconfig	2016-09-21 18:02:11.184236423 +0200
+@@ -2,4 +2,37 @@
+ 
+ if BOARD_GRASSHOPPER
+ 
++config BOARD_GRASSHOPPER_LEDS
++	bool "Enable LED1 through 8"
++	depends on NEW_LEDS
++	depends on LEDS_GPIO
++	default y
++	help
++	  Enabling this option will provide access to the LED trough
++	  Linux LED API.
++
++config BOARD_GRASSHOPPER_PWM0
++	bool "Enable PWM0"
++	depends on PWM_ATMEL
++	depends on BOARD_GRASSHOPPER_LEDS
++	default n
++	help
++	  Enabling PWM channel 0 will exclude LED6 from LED API.
++
++config BOARD_GRASSHOPPER_PWM1
++	bool "Enable PWM1"
++	depends on PWM_ATMEL
++	depends on BOARD_GRASSHOPPER_LEDS
++	default n
++	help
++	  Enabling PWM channel 1 will exclude LED7 from LED API.
++
++config BOARD_GRASSHOPPER_PWM3
++	bool "Enable PWM3"
++	depends on PWM_ATMEL
++	depends on BOARD_GRASSHOPPER_LEDS
++	default n
++	help
++	  Enabling PWM channel 3 will exclude the power LED from LED API.
++
+ endif	# BOARD_GRASSHOPPER
+diff -Naur linux-4.7.3/arch/avr32/boards/grasshopper/led.c linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/led.c
+--- linux-4.7.3/arch/avr32/boards/grasshopper/led.c	2016-09-21 17:42:47.405315973 +0200
++++ linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/led.c	2016-09-21 17:43:33.144940844 +0200
+@@ -19,7 +19,7 @@
+  
+  // LEDs
+ static struct gpio_led grasshopper_led[] = {
+-#ifndef CONFIG_BOARD_GRASSHOPPER_PWM0
++#ifndef CONFIG_BOARD_GRASSHOPPER_PWM3
+     {
+         .name = "pwrled:red",
+         .gpio = GPIO_PIN_PA(22),
+@@ -78,7 +78,7 @@
+ };
+ 
+ /* PWM */
+-#ifdef CONFIG_LEDS_ATMEL_PWM
++#ifdef CONFIG_PWM_ATMEL
+ static struct gpio_led pwm_led[] = {
+     /* here the "gpio" is actually a PWM channel */
+ #ifdef CONFIG_BOARD_GRASSHOPPER_PWM0
+@@ -93,12 +93,6 @@
+         .gpio = 1,
+     },
+ #endif
+-#ifdef CONFIG_BOARD_GRASSHOPPER_PWM2
+-    {
+-        .name = "pwm2",
+-        .gpio = 2,
+-    },
+-#endif
+ #ifdef CONFIG_BOARD_GRASSHOPPER_PWM3
+     {
+         .name = "pwm3",
+@@ -123,13 +117,15 @@
+ 
+ static int __init grasshopper_setup_leds(void)
+ {
++    unsigned int i;
++
+     printk("Grasshopper: Setting up %d LEDs\n", grasshopper_led_data.num_leds);
+-    //for (i=0; i<grasshopper_led_data.num_leds; i++)
+-    //    at32_select_gpio(grasshopper_led[i].gpio, AT32_GPIOF_OUTPUT);
++    for (i=0; i<grasshopper_led_data.num_leds; i++)
++        at32_select_gpio(grasshopper_led[i].gpio, AT32_GPIOF_OUTPUT);
+ 
+     platform_device_register(&grasshopper_led_dev);
+ 
+-#ifdef CONFIG_LEDS_ATMEL_PWM
++#ifdef CONFIG_PWM_ATMEL
+     at32_add_device_pwm(0
+ #ifdef CONFIG_BOARD_GRASSHOPPER_PWM0
+         | (1 << 0)
+@@ -137,9 +133,6 @@
+ #ifdef CONFIG_BOARD_GRASSHOPPER_PWM1
+         | (1 << 1)
+ #endif
+-#ifdef CONFIG_BOARD_GRASSHOPPER_PWM2
+-        | (1 << 2)
+-#endif
+ #ifdef CONFIG_BOARD_GRASSHOPPER_PWM3
+         | (1 << 3)
+ #endif
+diff -Naur linux-4.7.3/arch/avr32/boards/grasshopper/Makefile linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/Makefile
+--- linux-4.7.3/arch/avr32/boards/grasshopper/Makefile	2016-09-21 17:42:47.405315973 +0200
++++ linux-4.7.3.grasshopper/arch/avr32/boards/grasshopper/Makefile	2016-09-21 17:43:04.042543262 +0200
+@@ -1,5 +1,5 @@
+-obj-y	+= button.o
+-obj-y	+= flash.o
+-obj-y	+= led.o
+-obj-y	+= mac.o
+-obj-y	+= setup.o
++obj-y					+= button.o
++obj-y					+= flash.o
++obj-$(CONFIG_BOARD_GRASSHOPPER_LEDS)	+= led.o
++obj-y					+= mac.o
++obj-y					+= setup.o

+ 1 - 0
target/avr32/systems/grasshopper

@@ -12,6 +12,7 @@ config ADK_TARGET_SYSTEM_GRASSHOPPER
 	select ADK_TARGET_WITH_INPUT
 	select ADK_TARGET_WITH_MTD
 	select ADK_TARGET_WITH_RTC
+	select ADK_TARGET_WITH_LEDS
 	select ADK_TARGET_KERNEL_UIMAGE
 	select ADK_TARGET_KERNEL_WITH_COMPRESSION
 	select ADK_HOST_BUILD_U_BOOT

+ 16 - 0
target/linux/config/Config.in.leds

@@ -12,6 +12,12 @@ config ADK_KERNEL_LEDS_TRIGGERS
 	bool
 	select ADK_KERNEL_NEW_LEDS
 
+config ADK_KERNEL_LEDS_GPIO
+	bool
+	select ADK_KERNEL_NEW_LEDS
+	select ADK_KERNEL_LEDS_CLASS
+	select ADK_KERNEL_GPIOLIB
+
 config ADK_KERNEL_LEDS_CLASS
 	bool
 
@@ -39,6 +45,16 @@ config ADK_KERNEL_LEDS_ALIX2
 	default y if ADK_TARGET_MODEL_PCENGINES_ALIX2D
 	default n
 
+config ADK_KERNEL_BOARD_GRASSHOPPER_LEDS
+	bool "LED suppport for AVR32 Grasshopper boards"
+	select ADK_KERNEL_LEDS_CLASS
+	select ADK_KERNEL_LEDS_GPIO
+	select ADK_KERNEL_LEDS_TRIGGERS
+	select ADK_KERNEL_LEDS_TRIGGER_HEARTBEAT
+	depends on ADK_TARGET_SYSTEM_GRASSHOPPER
+	default y if ADK_TARGET_SYSTEM_GRASSHOPPER
+	default n
+
 config ADK_KERNEL_LEDS_TRIGGER_TIMER
 	tristate "LED Timer trigger"
 	select ADK_KERNEL_LEDS_TRIGGERS