diff options
author | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2014-05-28 19:20:17 -0400 |
---|---|---|
committer | Nicolas Ferre <nicolas.ferre@atmel.com> | 2014-07-09 09:13:35 -0400 |
commit | 3088883b598be8adc47ba5330f3492331d7c6ec5 (patch) | |
tree | 89dd9e8b1dd47a351d6b13b6000432ede2b352c0 | |
parent | ec38846ad59d7b780540afcec101b24139933195 (diff) |
leds: atmel-pwm: remove obsolete driver
The leds-atmel-pwm driver is now obsolete. It is not used by any mainlined
boards and is replaced by the generic leds_pwm with the pwm-atmel driver using
the generic PWM framework.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Bryan Wu <cooloney@gmail.com>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
-rw-r--r-- | drivers/leds/Kconfig | 8 | ||||
-rw-r--r-- | drivers/leds/Makefile | 1 | ||||
-rw-r--r-- | drivers/leds/leds-atmel-pwm.c | 149 |
3 files changed, 0 insertions, 158 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index a1b044e7eaad..8736f69262f9 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
@@ -32,14 +32,6 @@ config LEDS_88PM860X | |||
32 | This option enables support for on-chip LED drivers found on Marvell | 32 | This option enables support for on-chip LED drivers found on Marvell |
33 | Semiconductor 88PM8606 PMIC. | 33 | Semiconductor 88PM8606 PMIC. |
34 | 34 | ||
35 | config LEDS_ATMEL_PWM | ||
36 | tristate "LED Support using Atmel PWM outputs" | ||
37 | depends on LEDS_CLASS | ||
38 | depends on ATMEL_PWM | ||
39 | help | ||
40 | This option enables support for LEDs driven using outputs | ||
41 | of the dedicated PWM controller found on newer Atmel SOCs. | ||
42 | |||
43 | config LEDS_LM3530 | 35 | config LEDS_LM3530 |
44 | tristate "LCD Backlight driver for LM3530" | 36 | tristate "LCD Backlight driver for LM3530" |
45 | depends on LEDS_CLASS | 37 | depends on LEDS_CLASS |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 79c5155199a7..3c036663f17b 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
@@ -6,7 +6,6 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o | |||
6 | 6 | ||
7 | # LED Platform Drivers | 7 | # LED Platform Drivers |
8 | obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o | 8 | obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o |
9 | obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o | ||
10 | obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o | 9 | obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o |
11 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o | 10 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o |
12 | obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o | 11 | obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o |
diff --git a/drivers/leds/leds-atmel-pwm.c b/drivers/leds/leds-atmel-pwm.c deleted file mode 100644 index 56cec8d6a2ac..000000000000 --- a/drivers/leds/leds-atmel-pwm.c +++ /dev/null | |||
@@ -1,149 +0,0 @@ | |||
1 | #include <linux/kernel.h> | ||
2 | #include <linux/platform_device.h> | ||
3 | #include <linux/leds.h> | ||
4 | #include <linux/io.h> | ||
5 | #include <linux/atmel_pwm.h> | ||
6 | #include <linux/slab.h> | ||
7 | #include <linux/module.h> | ||
8 | |||
9 | |||
10 | struct pwmled { | ||
11 | struct led_classdev cdev; | ||
12 | struct pwm_channel pwmc; | ||
13 | struct gpio_led *desc; | ||
14 | u32 mult; | ||
15 | u8 active_low; | ||
16 | }; | ||
17 | |||
18 | |||
19 | /* | ||
20 | * For simplicity, we use "brightness" as if it were a linear function | ||
21 | * of PWM duty cycle. However, a logarithmic function of duty cycle is | ||
22 | * probably a better match for perceived brightness: two is half as bright | ||
23 | * as four, four is half as bright as eight, etc | ||
24 | */ | ||
25 | static void pwmled_brightness(struct led_classdev *cdev, enum led_brightness b) | ||
26 | { | ||
27 | struct pwmled *led; | ||
28 | |||
29 | /* update the duty cycle for the *next* period */ | ||
30 | led = container_of(cdev, struct pwmled, cdev); | ||
31 | pwm_channel_writel(&led->pwmc, PWM_CUPD, led->mult * (unsigned) b); | ||
32 | } | ||
33 | |||
34 | /* | ||
35 | * NOTE: we reuse the platform_data structure of GPIO leds, | ||
36 | * but repurpose its "gpio" number as a PWM channel number. | ||
37 | */ | ||
38 | static int pwmled_probe(struct platform_device *pdev) | ||
39 | { | ||
40 | const struct gpio_led_platform_data *pdata; | ||
41 | struct pwmled *leds; | ||
42 | int i; | ||
43 | int status; | ||
44 | |||
45 | pdata = dev_get_platdata(&pdev->dev); | ||
46 | if (!pdata || pdata->num_leds < 1) | ||
47 | return -ENODEV; | ||
48 | |||
49 | leds = devm_kzalloc(&pdev->dev, pdata->num_leds * sizeof(*leds), | ||
50 | GFP_KERNEL); | ||
51 | if (!leds) | ||
52 | return -ENOMEM; | ||
53 | |||
54 | for (i = 0; i < pdata->num_leds; i++) { | ||
55 | struct pwmled *led = leds + i; | ||
56 | const struct gpio_led *dat = pdata->leds + i; | ||
57 | u32 tmp; | ||
58 | |||
59 | led->cdev.name = dat->name; | ||
60 | led->cdev.brightness = LED_OFF; | ||
61 | led->cdev.brightness_set = pwmled_brightness; | ||
62 | led->cdev.default_trigger = dat->default_trigger; | ||
63 | |||
64 | led->active_low = dat->active_low; | ||
65 | |||
66 | status = pwm_channel_alloc(dat->gpio, &led->pwmc); | ||
67 | if (status < 0) | ||
68 | goto err; | ||
69 | |||
70 | /* | ||
71 | * Prescale clock by 2^x, so PWM counts in low MHz. | ||
72 | * Start each cycle with the LED active, so increasing | ||
73 | * the duty cycle gives us more time on (== brighter). | ||
74 | */ | ||
75 | tmp = 5; | ||
76 | if (!led->active_low) | ||
77 | tmp |= PWM_CPR_CPOL; | ||
78 | pwm_channel_writel(&led->pwmc, PWM_CMR, tmp); | ||
79 | |||
80 | /* | ||
81 | * Pick a period so PWM cycles at 100+ Hz; and a multiplier | ||
82 | * for scaling duty cycle: brightness * mult. | ||
83 | */ | ||
84 | tmp = (led->pwmc.mck / (1 << 5)) / 100; | ||
85 | tmp /= 255; | ||
86 | led->mult = tmp; | ||
87 | pwm_channel_writel(&led->pwmc, PWM_CDTY, | ||
88 | led->cdev.brightness * 255); | ||
89 | pwm_channel_writel(&led->pwmc, PWM_CPRD, | ||
90 | LED_FULL * tmp); | ||
91 | |||
92 | pwm_channel_enable(&led->pwmc); | ||
93 | |||
94 | /* Hand it over to the LED framework */ | ||
95 | status = led_classdev_register(&pdev->dev, &led->cdev); | ||
96 | if (status < 0) { | ||
97 | pwm_channel_free(&led->pwmc); | ||
98 | goto err; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | platform_set_drvdata(pdev, leds); | ||
103 | return 0; | ||
104 | |||
105 | err: | ||
106 | if (i > 0) { | ||
107 | for (i = i - 1; i >= 0; i--) { | ||
108 | led_classdev_unregister(&leds[i].cdev); | ||
109 | pwm_channel_free(&leds[i].pwmc); | ||
110 | } | ||
111 | } | ||
112 | |||
113 | return status; | ||
114 | } | ||
115 | |||
116 | static int pwmled_remove(struct platform_device *pdev) | ||
117 | { | ||
118 | const struct gpio_led_platform_data *pdata; | ||
119 | struct pwmled *leds; | ||
120 | unsigned i; | ||
121 | |||
122 | pdata = dev_get_platdata(&pdev->dev); | ||
123 | leds = platform_get_drvdata(pdev); | ||
124 | |||
125 | for (i = 0; i < pdata->num_leds; i++) { | ||
126 | struct pwmled *led = leds + i; | ||
127 | |||
128 | led_classdev_unregister(&led->cdev); | ||
129 | pwm_channel_free(&led->pwmc); | ||
130 | } | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static struct platform_driver pwmled_driver = { | ||
136 | .driver = { | ||
137 | .name = "leds-atmel-pwm", | ||
138 | .owner = THIS_MODULE, | ||
139 | }, | ||
140 | /* REVISIT add suspend() and resume() methods */ | ||
141 | .probe = pwmled_probe, | ||
142 | .remove = pwmled_remove, | ||
143 | }; | ||
144 | |||
145 | module_platform_driver(pwmled_driver); | ||
146 | |||
147 | MODULE_DESCRIPTION("Driver for LEDs with PWM-controlled brightness"); | ||
148 | MODULE_LICENSE("GPL"); | ||
149 | MODULE_ALIAS("platform:leds-atmel-pwm"); | ||