Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 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 | |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 12 | #include <linux/gpio.h> |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/init.h> |
Andrew Victor | a7307bf | 2008-09-21 21:31:16 +0100 | [diff] [blame] | 16 | #include <linux/platform_device.h> |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 17 | |
Jean-Christophe PLAGNIOL-VILLARD | 43d2f53 | 2012-10-30 05:14:17 +0800 | [diff] [blame] | 18 | #include "board.h" |
Linus Walleij | cf2e933 | 2014-03-27 14:18:51 +0100 | [diff] [blame] | 19 | #include "gpio.h" |
Andrew Victor | cc2832a | 2006-04-02 17:15:48 +0100 | [diff] [blame] | 20 | |
| 21 | |
Andrew Victor | a04ff1a | 2008-01-23 09:27:06 +0100 | [diff] [blame] | 22 | /* ------------------------------------------------------------------------- */ |
| 23 | |
| 24 | #if defined(CONFIG_NEW_LEDS) |
| 25 | |
Andrew Victor | a04ff1a | 2008-01-23 09:27:06 +0100 | [diff] [blame] | 26 | /* |
| 27 | * New cross-platform LED support. |
| 28 | */ |
| 29 | |
| 30 | static struct gpio_led_platform_data led_data; |
| 31 | |
Andrew Victor | 791ccf2 | 2008-09-24 22:03:52 +0100 | [diff] [blame] | 32 | static struct platform_device at91_gpio_leds_device = { |
Andrew Victor | a04ff1a | 2008-01-23 09:27:06 +0100 | [diff] [blame] | 33 | .name = "leds-gpio", |
| 34 | .id = -1, |
| 35 | .dev.platform_data = &led_data, |
| 36 | }; |
| 37 | |
| 38 | void __init at91_gpio_leds(struct gpio_led *leds, int nr) |
| 39 | { |
| 40 | int i; |
| 41 | |
| 42 | if (!nr) |
| 43 | return; |
| 44 | |
| 45 | for (i = 0; i < nr; i++) |
| 46 | at91_set_gpio_output(leds[i].gpio, leds[i].active_low); |
| 47 | |
| 48 | led_data.leds = leds; |
| 49 | led_data.num_leds = nr; |
Andrew Victor | 791ccf2 | 2008-09-24 22:03:52 +0100 | [diff] [blame] | 50 | platform_device_register(&at91_gpio_leds_device); |
Andrew Victor | a04ff1a | 2008-01-23 09:27:06 +0100 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | #else |
| 54 | void __init at91_gpio_leds(struct gpio_led *leds, int nr) {} |
| 55 | #endif |
| 56 | |