summaryrefslogtreecommitdiff
path: root/target/avr32/grasshopper/patches/4.8.15/0002-grasshopper-led-pwm.patch
blob: 977c915235731b5511666af7d0a3dbd933a1a245 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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