Commit | Line | Data |
---|---|---|
cc2832a1 AV |
1 | /* |
2 | * LED driver for Atmel AT91-based boards. | |
3 | * | |
4 | * Copyright (C) SAN People (Pty) Ltd | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version | |
9 | * 2 of the License, or (at your option) any later version. | |
10 | */ | |
11 | ||
2f8163ba | 12 | #include <linux/gpio.h> |
cc2832a1 AV |
13 | #include <linux/kernel.h> |
14 | #include <linux/module.h> | |
15 | #include <linux/init.h> | |
a7307bf2 | 16 | #include <linux/platform_device.h> |
cc2832a1 | 17 | |
43d2f532 | 18 | #include "board.h" |
cc2832a1 AV |
19 | |
20 | ||
a04ff1af AV |
21 | /* ------------------------------------------------------------------------- */ |
22 | ||
23 | #if defined(CONFIG_NEW_LEDS) | |
24 | ||
a04ff1af AV |
25 | /* |
26 | * New cross-platform LED support. | |
27 | */ | |
28 | ||
29 | static struct gpio_led_platform_data led_data; | |
30 | ||
791ccf2e | 31 | static struct platform_device at91_gpio_leds_device = { |
a04ff1af AV |
32 | .name = "leds-gpio", |
33 | .id = -1, | |
34 | .dev.platform_data = &led_data, | |
35 | }; | |
36 | ||
37 | void __init at91_gpio_leds(struct gpio_led *leds, int nr) | |
38 | { | |
39 | int i; | |
40 | ||
41 | if (!nr) | |
42 | return; | |
43 | ||
44 | for (i = 0; i < nr; i++) | |
45 | at91_set_gpio_output(leds[i].gpio, leds[i].active_low); | |
46 | ||
47 | led_data.leds = leds; | |
48 | led_data.num_leds = nr; | |
791ccf2e | 49 | platform_device_register(&at91_gpio_leds_device); |
a04ff1af AV |
50 | } |
51 | ||
52 | #else | |
53 | void __init at91_gpio_leds(struct gpio_led *leds, int nr) {} | |
54 | #endif | |
55 | ||
56 | ||
a7307bf2 AV |
57 | /* ------------------------------------------------------------------------- */ |
58 | ||
59 | #if defined (CONFIG_LEDS_ATMEL_PWM) | |
60 | ||
61 | /* | |
62 | * PWM Leds | |
63 | */ | |
64 | ||
65 | static struct gpio_led_platform_data pwm_led_data; | |
66 | ||
791ccf2e | 67 | static struct platform_device at91_pwm_leds_device = { |
a7307bf2 AV |
68 | .name = "leds-atmel-pwm", |
69 | .id = -1, | |
70 | .dev.platform_data = &pwm_led_data, | |
71 | }; | |
72 | ||
73 | void __init at91_pwm_leds(struct gpio_led *leds, int nr) | |
74 | { | |
75 | int i; | |
76 | u32 pwm_mask = 0; | |
77 | ||
78 | if (!nr) | |
79 | return; | |
80 | ||
81 | for (i = 0; i < nr; i++) | |
82 | pwm_mask |= (1 << leds[i].gpio); | |
83 | ||
84 | pwm_led_data.leds = leds; | |
85 | pwm_led_data.num_leds = nr; | |
86 | ||
87 | at91_add_device_pwm(pwm_mask); | |
791ccf2e | 88 | platform_device_register(&at91_pwm_leds_device); |
a7307bf2 AV |
89 | } |
90 | #else | |
91 | void __init at91_pwm_leds(struct gpio_led *leds, int nr){} | |
92 | #endif |