aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91
diff options
context:
space:
mode:
authorBryan Wu <bryan.wu@canonical.com>2012-03-13 05:47:33 -0400
committerBryan Wu <bryan.wu@canonical.com>2012-07-31 09:23:32 -0400
commitd61015fad9703990e4b0c826ed943b13794f19c8 (patch)
treee2b69735592d36feb61b8543be92ccab8474c5b9 /arch/arm/mach-at91
parent8f88731d052d2b14f332249a9332690ac1b365ac (diff)
ARM: at91: convert old leds drivers to gpio_led and led_trigger drivers
Build with at91 defconfigs successfully Signed-off-by: Bryan Wu <bryan.wu@canonical.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r--arch/arm/mach-at91/board-csb337.c2
-rw-r--r--arch/arm/mach-at91/board-ecbat91.c18
-rw-r--r--arch/arm/mach-at91/board-eco920.c22
-rw-r--r--arch/arm/mach-at91/board-kafa.c17
-rw-r--r--arch/arm/mach-at91/board-kb9202.c23
-rw-r--r--arch/arm/mach-at91/board-rm9200dk.c3
-rw-r--r--arch/arm/mach-at91/board-rm9200ek.c3
-rw-r--r--arch/arm/mach-at91/board-rsi-ews.c3
-rw-r--r--arch/arm/mach-at91/board-sam9-l9260.c23
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c3
-rw-r--r--arch/arm/mach-at91/board-yl-9200.c3
-rw-r--r--arch/arm/mach-at91/include/mach/board.h1
-rw-r--r--arch/arm/mach-at91/leds.c105
13 files changed, 89 insertions, 137 deletions
diff --git a/arch/arm/mach-at91/board-csb337.c b/arch/arm/mach-at91/board-csb337.c
index cd813361cd26..4993f1bfa1a7 100644
--- a/arch/arm/mach-at91/board-csb337.c
+++ b/arch/arm/mach-at91/board-csb337.c
@@ -219,8 +219,6 @@ static struct gpio_led csb_leds[] = {
219 219
220static void __init csb337_board_init(void) 220static void __init csb337_board_init(void)
221{ 221{
222 /* Setup the LEDs */
223 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
224 /* Serial */ 222 /* Serial */
225 /* DBGU on ttyS0 */ 223 /* DBGU on ttyS0 */
226 at91_register_uart(0, 0, 0); 224 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-ecbat91.c b/arch/arm/mach-at91/board-ecbat91.c
index 89cc3726a9ce..f9a4ab93b152 100644
--- a/arch/arm/mach-at91/board-ecbat91.c
+++ b/arch/arm/mach-at91/board-ecbat91.c
@@ -137,11 +137,20 @@ static struct spi_board_info __initdata ecb_at91spi_devices[] = {
137 }, 137 },
138}; 138};
139 139
140/*
141 * LEDs
142 */
143static struct gpio_led ecb_leds[] = {
144 { /* D1 */
145 .name = "led1",
146 .gpio = AT91_PIN_PC7,
147 .active_low = 1,
148 .default_trigger = "heartbeat",
149 }
150};
151
140static void __init ecb_at91board_init(void) 152static void __init ecb_at91board_init(void)
141{ 153{
142 /* Setup the LEDs */
143 at91_init_leds(AT91_PIN_PC7, AT91_PIN_PC7);
144
145 /* Serial */ 154 /* Serial */
146 /* DBGU on ttyS0. (Rx & Tx only) */ 155 /* DBGU on ttyS0. (Rx & Tx only) */
147 at91_register_uart(0, 0, 0); 156 at91_register_uart(0, 0, 0);
@@ -164,6 +173,9 @@ static void __init ecb_at91board_init(void)
164 173
165 /* SPI */ 174 /* SPI */
166 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices)); 175 at91_add_device_spi(ecb_at91spi_devices, ARRAY_SIZE(ecb_at91spi_devices));
176
177 /* LEDs */
178 at91_gpio_leds(ecb_leds, ARRAY_SIZE(ecb_leds));
167} 179}
168 180
169MACHINE_START(ECBAT91, "emQbit's ECB_AT91") 181MACHINE_START(ECBAT91, "emQbit's ECB_AT91")
diff --git a/arch/arm/mach-at91/board-eco920.c b/arch/arm/mach-at91/board-eco920.c
index 558546cf63f4..76cc82632ab5 100644
--- a/arch/arm/mach-at91/board-eco920.c
+++ b/arch/arm/mach-at91/board-eco920.c
@@ -92,10 +92,26 @@ static struct spi_board_info eco920_spi_devices[] = {
92 }, 92 },
93}; 93};
94 94
95/*
96 * LEDs
97 */
98static struct gpio_led eco920_leds[] = {
99 { /* D1 */
100 .name = "led1",
101 .gpio = AT91_PIN_PB0,
102 .active_low = 1,
103 .default_trigger = "heartbeat",
104 },
105 { /* D2 */
106 .name = "led2",
107 .gpio = AT91_PIN_PB1,
108 .active_low = 1,
109 .default_trigger = "timer",
110 }
111};
112
95static void __init eco920_board_init(void) 113static void __init eco920_board_init(void)
96{ 114{
97 /* Setup the LEDs */
98 at91_init_leds(AT91_PIN_PB0, AT91_PIN_PB1);
99 /* DBGU on ttyS0. (Rx & Tx only */ 115 /* DBGU on ttyS0. (Rx & Tx only */
100 at91_register_uart(0, 0, 0); 116 at91_register_uart(0, 0, 0);
101 at91_add_device_serial(); 117 at91_add_device_serial();
@@ -126,6 +142,8 @@ static void __init eco920_board_init(void)
126 ); 142 );
127 143
128 at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices)); 144 at91_add_device_spi(eco920_spi_devices, ARRAY_SIZE(eco920_spi_devices));
145 /* LEDs */
146 at91_gpio_leds(eco920_leds, ARRAY_SIZE(eco920_leds));
129} 147}
130 148
131MACHINE_START(ECO920, "eco920") 149MACHINE_START(ECO920, "eco920")
diff --git a/arch/arm/mach-at91/board-kafa.c b/arch/arm/mach-at91/board-kafa.c
index f260657f32bc..8db11f41fe8c 100644
--- a/arch/arm/mach-at91/board-kafa.c
+++ b/arch/arm/mach-at91/board-kafa.c
@@ -65,11 +65,20 @@ static struct at91_udc_data __initdata kafa_udc_data = {
65 .pullup_pin = AT91_PIN_PB7, 65 .pullup_pin = AT91_PIN_PB7,
66}; 66};
67 67
68/*
69 * LEDs
70 */
71static struct gpio_led kafa_leds[] = {
72 { /* D1 */
73 .name = "led1",
74 .gpio = AT91_PIN_PB4,
75 .active_low = 1,
76 .default_trigger = "heartbeat",
77 },
78};
79
68static void __init kafa_board_init(void) 80static void __init kafa_board_init(void)
69{ 81{
70 /* Set up the LEDs */
71 at91_init_leds(AT91_PIN_PB4, AT91_PIN_PB4);
72
73 /* Serial */ 82 /* Serial */
74 /* DBGU on ttyS0. (Rx & Tx only) */ 83 /* DBGU on ttyS0. (Rx & Tx only) */
75 at91_register_uart(0, 0, 0); 84 at91_register_uart(0, 0, 0);
@@ -87,6 +96,8 @@ static void __init kafa_board_init(void)
87 at91_add_device_i2c(NULL, 0); 96 at91_add_device_i2c(NULL, 0);
88 /* SPI */ 97 /* SPI */
89 at91_add_device_spi(NULL, 0); 98 at91_add_device_spi(NULL, 0);
99 /* LEDs */
100 at91_gpio_leds(kafa_leds, ARRAY_SIZE(kafa_leds));
90} 101}
91 102
92MACHINE_START(KAFA, "Sperry-Sun KAFA") 103MACHINE_START(KAFA, "Sperry-Sun KAFA")
diff --git a/arch/arm/mach-at91/board-kb9202.c b/arch/arm/mach-at91/board-kb9202.c
index ba39db5482b9..4e362b8ec8cc 100644
--- a/arch/arm/mach-at91/board-kb9202.c
+++ b/arch/arm/mach-at91/board-kb9202.c
@@ -95,11 +95,26 @@ static struct atmel_nand_data __initdata kb9202_nand_data = {
95 .num_parts = ARRAY_SIZE(kb9202_nand_partition), 95 .num_parts = ARRAY_SIZE(kb9202_nand_partition),
96}; 96};
97 97
98/*
99 * LEDs
100 */
101static struct gpio_led kb9202_leds[] = {
102 { /* D1 */
103 .name = "led1",
104 .gpio = AT91_PIN_PC19,
105 .active_low = 1,
106 .default_trigger = "heartbeat",
107 },
108 { /* D2 */
109 .name = "led2",
110 .gpio = AT91_PIN_PC18,
111 .active_low = 1,
112 .default_trigger = "timer",
113 }
114};
115
98static void __init kb9202_board_init(void) 116static void __init kb9202_board_init(void)
99{ 117{
100 /* Set up the LEDs */
101 at91_init_leds(AT91_PIN_PC19, AT91_PIN_PC18);
102
103 /* Serial */ 118 /* Serial */
104 /* DBGU on ttyS0. (Rx & Tx only) */ 119 /* DBGU on ttyS0. (Rx & Tx only) */
105 at91_register_uart(0, 0, 0); 120 at91_register_uart(0, 0, 0);
@@ -127,6 +142,8 @@ static void __init kb9202_board_init(void)
127 at91_add_device_spi(NULL, 0); 142 at91_add_device_spi(NULL, 0);
128 /* NAND */ 143 /* NAND */
129 at91_add_device_nand(&kb9202_nand_data); 144 at91_add_device_nand(&kb9202_nand_data);
145 /* LEDs */
146 at91_gpio_leds(kb9202_leds, ARRAY_SIZE(kb9202_leds));
130} 147}
131 148
132MACHINE_START(KB9200, "KB920x") 149MACHINE_START(KB9200, "KB920x")
diff --git a/arch/arm/mach-at91/board-rm9200dk.c b/arch/arm/mach-at91/board-rm9200dk.c
index afd7a4713766..7417b7c835c8 100644
--- a/arch/arm/mach-at91/board-rm9200dk.c
+++ b/arch/arm/mach-at91/board-rm9200dk.c
@@ -176,9 +176,6 @@ static struct gpio_led dk_leds[] = {
176 176
177static void __init dk_board_init(void) 177static void __init dk_board_init(void)
178{ 178{
179 /* Setup the LEDs */
180 at91_init_leds(AT91_PIN_PB2, AT91_PIN_PB2);
181
182 /* Serial */ 179 /* Serial */
183 /* DBGU on ttyS0. (Rx & Tx only) */ 180 /* DBGU on ttyS0. (Rx & Tx only) */
184 at91_register_uart(0, 0, 0); 181 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-rm9200ek.c b/arch/arm/mach-at91/board-rm9200ek.c
index 2b15b8adec4c..18b2ec0cf24c 100644
--- a/arch/arm/mach-at91/board-rm9200ek.c
+++ b/arch/arm/mach-at91/board-rm9200ek.c
@@ -147,9 +147,6 @@ static struct gpio_led ek_leds[] = {
147 147
148static void __init ek_board_init(void) 148static void __init ek_board_init(void)
149{ 149{
150 /* Setup the LEDs */
151 at91_init_leds(AT91_PIN_PB1, AT91_PIN_PB2);
152
153 /* Serial */ 150 /* Serial */
154 /* DBGU on ttyS0. (Rx & Tx only) */ 151 /* DBGU on ttyS0. (Rx & Tx only) */
155 at91_register_uart(0, 0, 0); 152 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-rsi-ews.c b/arch/arm/mach-at91/board-rsi-ews.c
index 24ab9be7510f..32342b8304b4 100644
--- a/arch/arm/mach-at91/board-rsi-ews.c
+++ b/arch/arm/mach-at91/board-rsi-ews.c
@@ -184,9 +184,6 @@ static struct platform_device rsiews_nor_flash = {
184 */ 184 */
185static void __init rsi_ews_board_init(void) 185static void __init rsi_ews_board_init(void)
186{ 186{
187 /* Setup the LEDs */
188 at91_init_leds(AT91_PIN_PB6, AT91_PIN_PB9);
189
190 /* Serial */ 187 /* Serial */
191 /* DBGU on ttyS0. (Rx & Tx only) */ 188 /* DBGU on ttyS0. (Rx & Tx only) */
192 /* This one is for debugging */ 189 /* This one is for debugging */
diff --git a/arch/arm/mach-at91/board-sam9-l9260.c b/arch/arm/mach-at91/board-sam9-l9260.c
index cdd21f2595d2..ef982f8f71c0 100644
--- a/arch/arm/mach-at91/board-sam9-l9260.c
+++ b/arch/arm/mach-at91/board-sam9-l9260.c
@@ -165,11 +165,26 @@ static struct at91_mmc_data __initdata ek_mmc_data = {
165 .vcc_pin = -EINVAL, 165 .vcc_pin = -EINVAL,
166}; 166};
167 167
168/*
169 * LEDs
170 */
171static struct gpio_led ek_leds[] = {
172 { /* D1 */
173 .name = "led1",
174 .gpio = AT91_PIN_PA9,
175 .active_low = 1,
176 .default_trigger = "heartbeat",
177 },
178 { /* D2 */
179 .name = "led2",
180 .gpio = AT91_PIN_PA6,
181 .active_low = 1,
182 .default_trigger = "timer",
183 }
184};
185
168static void __init ek_board_init(void) 186static void __init ek_board_init(void)
169{ 187{
170 /* Setup the LEDs */
171 at91_init_leds(AT91_PIN_PA9, AT91_PIN_PA6);
172
173 /* Serial */ 188 /* Serial */
174 /* DBGU on ttyS0. (Rx & Tx only) */ 189 /* DBGU on ttyS0. (Rx & Tx only) */
175 at91_register_uart(0, 0, 0); 190 at91_register_uart(0, 0, 0);
@@ -196,6 +211,8 @@ static void __init ek_board_init(void)
196 at91_add_device_mmc(0, &ek_mmc_data); 211 at91_add_device_mmc(0, &ek_mmc_data);
197 /* I2C */ 212 /* I2C */
198 at91_add_device_i2c(NULL, 0); 213 at91_add_device_i2c(NULL, 0);
214 /* LEDs */
215 at91_gpio_leds(ek_leds, ARRAY_SIZE(ek_leds));
199} 216}
200 217
201MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260") 218MACHINE_START(SAM9_L9260, "Olimex SAM9-L9260")
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 2736453821b0..0b4501c7b727 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -568,9 +568,6 @@ static struct gpio_led ek_leds[] = {
568 568
569static void __init ek_board_init(void) 569static void __init ek_board_init(void)
570{ 570{
571 /* Setup the LEDs */
572 at91_init_leds(AT91_PIN_PA13, AT91_PIN_PA14);
573
574 /* Serial */ 571 /* Serial */
575 /* DBGU on ttyS0. (Rx & Tx only) */ 572 /* DBGU on ttyS0. (Rx & Tx only) */
576 at91_register_uart(0, 0, 0); 573 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/board-yl-9200.c b/arch/arm/mach-at91/board-yl-9200.c
index d56665ea4b55..cc05dd15bfcd 100644
--- a/arch/arm/mach-at91/board-yl-9200.c
+++ b/arch/arm/mach-at91/board-yl-9200.c
@@ -540,9 +540,6 @@ void __init yl9200_add_device_video(void) {}
540 540
541static void __init yl9200_board_init(void) 541static void __init yl9200_board_init(void)
542{ 542{
543 /* Setup the LEDs D2=PB17 (timer), D3=PB16 (cpu) */
544 at91_init_leds(AT91_PIN_PB16, AT91_PIN_PB17);
545
546 /* Serial */ 543 /* Serial */
547 /* DBGU on ttyS0. (Rx & Tx only) */ 544 /* DBGU on ttyS0. (Rx & Tx only) */
548 at91_register_uart(0, 0, 0); 545 at91_register_uart(0, 0, 0);
diff --git a/arch/arm/mach-at91/include/mach/board.h b/arch/arm/mach-at91/include/mach/board.h
index 369afc2ffc5b..c55a4364ffb4 100644
--- a/arch/arm/mach-at91/include/mach/board.h
+++ b/arch/arm/mach-at91/include/mach/board.h
@@ -187,7 +187,6 @@ struct at91_can_data {
187extern void __init at91_add_device_can(struct at91_can_data *data); 187extern void __init at91_add_device_can(struct at91_can_data *data);
188 188
189 /* LEDs */ 189 /* LEDs */
190extern void __init at91_init_leds(u8 cpu_led, u8 timer_led);
191extern void __init at91_gpio_leds(struct gpio_led *leds, int nr); 190extern void __init at91_gpio_leds(struct gpio_led *leds, int nr);
192extern void __init at91_pwm_leds(struct gpio_led *leds, int nr); 191extern void __init at91_pwm_leds(struct gpio_led *leds, int nr);
193 192
diff --git a/arch/arm/mach-at91/leds.c b/arch/arm/mach-at91/leds.c
index 8dfafe76ffe6..1b1e62b5f41b 100644
--- a/arch/arm/mach-at91/leds.c
+++ b/arch/arm/mach-at91/leds.c
@@ -90,108 +90,3 @@ void __init at91_pwm_leds(struct gpio_led *leds, int nr)
90#else 90#else
91void __init at91_pwm_leds(struct gpio_led *leds, int nr){} 91void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
92#endif 92#endif
93
94
95/* ------------------------------------------------------------------------- */
96
97#if defined(CONFIG_LEDS)
98
99#include <asm/leds.h>
100
101/*
102 * Old ARM-specific LED framework; not fully functional when generic time is
103 * in use.
104 */
105
106static u8 at91_leds_cpu;
107static u8 at91_leds_timer;
108
109static inline void at91_led_on(unsigned int led)
110{
111 at91_set_gpio_value(led, 0);
112}
113
114static inline void at91_led_off(unsigned int led)
115{
116 at91_set_gpio_value(led, 1);
117}
118
119static inline void at91_led_toggle(unsigned int led)
120{
121 unsigned long is_off = at91_get_gpio_value(led);
122 if (is_off)
123 at91_led_on(led);
124 else
125 at91_led_off(led);
126}
127
128
129/*
130 * Handle LED events.
131 */
132static void at91_leds_event(led_event_t evt)
133{
134 unsigned long flags;
135
136 local_irq_save(flags);
137
138 switch(evt) {
139 case led_start: /* System startup */
140 at91_led_on(at91_leds_cpu);
141 break;
142
143 case led_stop: /* System stop / suspend */
144 at91_led_off(at91_leds_cpu);
145 break;
146
147#ifdef CONFIG_LEDS_TIMER
148 case led_timer: /* Every 50 timer ticks */
149 at91_led_toggle(at91_leds_timer);
150 break;
151#endif
152
153#ifdef CONFIG_LEDS_CPU
154 case led_idle_start: /* Entering idle state */
155 at91_led_off(at91_leds_cpu);
156 break;
157
158 case led_idle_end: /* Exit idle state */
159 at91_led_on(at91_leds_cpu);
160 break;
161#endif
162
163 default:
164 break;
165 }
166
167 local_irq_restore(flags);
168}
169
170
171static int __init leds_init(void)
172{
173 if (!at91_leds_timer || !at91_leds_cpu)
174 return -ENODEV;
175
176 leds_event = at91_leds_event;
177
178 leds_event(led_start);
179 return 0;
180}
181
182__initcall(leds_init);
183
184
185void __init at91_init_leds(u8 cpu_led, u8 timer_led)
186{
187 /* Enable GPIO to access the LEDs */
188 at91_set_gpio_output(cpu_led, 1);
189 at91_set_gpio_output(timer_led, 1);
190
191 at91_leds_cpu = cpu_led;
192 at91_leds_timer = timer_led;
193}
194
195#else
196void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
197#endif