blob: 3e22978b5547a0eb80638a9f495f970e5da4d10e [file] [log] [blame]
Andrew Victorcc2832a2006-04-02 17:15:48 +01001/*
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
Russell King2f8163b2011-07-26 10:53:52 +010012#include <linux/gpio.h>
Andrew Victorcc2832a2006-04-02 17:15:48 +010013#include <linux/kernel.h>
14#include <linux/module.h>
15#include <linux/init.h>
Andrew Victora7307bf2008-09-21 21:31:16 +010016#include <linux/platform_device.h>
Andrew Victorcc2832a2006-04-02 17:15:48 +010017
Jean-Christophe PLAGNIOL-VILLARD43d2f532012-10-30 05:14:17 +080018#include "board.h"
Andrew Victorcc2832a2006-04-02 17:15:48 +010019
20
Andrew Victora04ff1a2008-01-23 09:27:06 +010021/* ------------------------------------------------------------------------- */
22
23#if defined(CONFIG_NEW_LEDS)
24
Andrew Victora04ff1a2008-01-23 09:27:06 +010025/*
26 * New cross-platform LED support.
27 */
28
29static struct gpio_led_platform_data led_data;
30
Andrew Victor791ccf22008-09-24 22:03:52 +010031static struct platform_device at91_gpio_leds_device = {
Andrew Victora04ff1a2008-01-23 09:27:06 +010032 .name = "leds-gpio",
33 .id = -1,
34 .dev.platform_data = &led_data,
35};
36
37void __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;
Andrew Victor791ccf22008-09-24 22:03:52 +010049 platform_device_register(&at91_gpio_leds_device);
Andrew Victora04ff1a2008-01-23 09:27:06 +010050}
51
52#else
53void __init at91_gpio_leds(struct gpio_led *leds, int nr) {}
54#endif
55
56
57/* ------------------------------------------------------------------------- */
58
Andrew Victora7307bf2008-09-21 21:31:16 +010059#if defined (CONFIG_LEDS_ATMEL_PWM)
60
61/*
62 * PWM Leds
63 */
64
65static struct gpio_led_platform_data pwm_led_data;
66
Andrew Victor791ccf22008-09-24 22:03:52 +010067static struct platform_device at91_pwm_leds_device = {
Andrew Victora7307bf2008-09-21 21:31:16 +010068 .name = "leds-atmel-pwm",
69 .id = -1,
70 .dev.platform_data = &pwm_led_data,
71};
72
73void __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);
Andrew Victor791ccf22008-09-24 22:03:52 +010088 platform_device_register(&at91_pwm_leds_device);
Andrew Victora7307bf2008-09-21 21:31:16 +010089}
90#else
91void __init at91_pwm_leds(struct gpio_led *leds, int nr){}
92#endif