aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c11
-rw-r--r--drivers/leds/Kconfig6
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/leds-ams-delta.c162
4 files changed, 180 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 6178f046f128..73df32aac4c4 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -84,6 +84,15 @@ static struct omap_board_config_kernel ams_delta_config[] = {
84 { OMAP_TAG_UART, &ams_delta_uart_config }, 84 { OMAP_TAG_UART, &ams_delta_uart_config },
85}; 85};
86 86
87static struct platform_device ams_delta_led_device = {
88 .name = "ams-delta-led",
89 .id = -1
90};
91
92static struct platform_device *ams_delta_devices[] __initdata = {
93 &ams_delta_led_device,
94};
95
87static void __init ams_delta_init(void) 96static void __init ams_delta_init(void)
88{ 97{
89 iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc)); 98 iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc));
@@ -94,6 +103,8 @@ static void __init ams_delta_init(void)
94 103
95 /* Clear latch2 (NAND, LCD, modem enable) */ 104 /* Clear latch2 (NAND, LCD, modem enable) */
96 ams_delta_latch2_write(~0, 0); 105 ams_delta_latch2_write(~0, 0);
106
107 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
97} 108}
98 109
99static void __init ams_delta_map_io(void) 110static void __init ams_delta_map_io(void)
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 626506234b76..f573d5af0b1f 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -63,6 +63,12 @@ config LEDS_S3C24XX
63 This option enables support for LEDs connected to GPIO lines 63 This option enables support for LEDs connected to GPIO lines
64 on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440. 64 on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440.
65 65
66config LEDS_AMS_DELTA
67 tristate "LED Support for the Amstrad Delta (E3)"
68 depends LEDS_CLASS && MACH_AMS_DELTA
69 help
70 This option enables support for the LEDs on Amstrad Delta (E3).
71
66comment "LED Triggers" 72comment "LED Triggers"
67 73
68config LEDS_TRIGGERS 74config LEDS_TRIGGERS
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 40f042633bf5..dcea1001faa4 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_LEDS_SPITZ) += leds-spitz.o
11obj-$(CONFIG_LEDS_IXP4XX) += leds-ixp4xx-gpio.o 11obj-$(CONFIG_LEDS_IXP4XX) += leds-ixp4xx-gpio.o
12obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o 12obj-$(CONFIG_LEDS_TOSA) += leds-tosa.o
13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o 13obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o
14obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o
14 15
15# LED Triggers 16# LED Triggers
16obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 17obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/leds-ams-delta.c b/drivers/leds/leds-ams-delta.c
new file mode 100644
index 000000000000..e9f06116c4d7
--- /dev/null
+++ b/drivers/leds/leds-ams-delta.c
@@ -0,0 +1,162 @@
1/*
2 * LEDs driver for Amstrad Delta (E3)
3 *
4 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/config.h>
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/leds.h>
16#include <asm/arch/board-ams-delta.h>
17
18/*
19 * Our context
20 */
21struct ams_delta_led {
22 struct led_classdev cdev;
23 u8 bitmask;
24};
25
26static void ams_delta_led_set(struct led_classdev *led_cdev,
27 enum led_brightness value)
28{
29 struct ams_delta_led *led_dev =
30 container_of(led_cdev, struct ams_delta_led, cdev);
31
32 if (value)
33 ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
34 else
35 ams_delta_latch1_write(led_dev->bitmask, 0);
36}
37
38static struct ams_delta_led ams_delta_leds[] = {
39 {
40 .cdev = {
41 .name = "ams-delta:camera",
42 .brightness_set = ams_delta_led_set,
43 },
44 .bitmask = AMS_DELTA_LATCH1_LED_CAMERA,
45 },
46 {
47 .cdev = {
48 .name = "ams-delta:advert",
49 .brightness_set = ams_delta_led_set,
50 },
51 .bitmask = AMS_DELTA_LATCH1_LED_ADVERT,
52 },
53 {
54 .cdev = {
55 .name = "ams-delta:email",
56 .brightness_set = ams_delta_led_set,
57 },
58 .bitmask = AMS_DELTA_LATCH1_LED_EMAIL,
59 },
60 {
61 .cdev = {
62 .name = "ams-delta:handsfree",
63 .brightness_set = ams_delta_led_set,
64 },
65 .bitmask = AMS_DELTA_LATCH1_LED_HANDSFREE,
66 },
67 {
68 .cdev = {
69 .name = "ams-delta:voicemail",
70 .brightness_set = ams_delta_led_set,
71 },
72 .bitmask = AMS_DELTA_LATCH1_LED_VOICEMAIL,
73 },
74 {
75 .cdev = {
76 .name = "ams-delta:voice",
77 .brightness_set = ams_delta_led_set,
78 },
79 .bitmask = AMS_DELTA_LATCH1_LED_VOICE,
80 },
81};
82
83#ifdef CONFIG_PM
84static int ams_delta_led_suspend(struct platform_device *dev,
85 pm_message_t state)
86{
87 int i;
88
89 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
90 led_classdev_suspend(&ams_delta_leds[i].cdev);
91
92 return 0;
93}
94
95static int ams_delta_led_resume(struct platform_device *dev)
96{
97 int i;
98
99 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
100 led_classdev_resume(&ams_delta_leds[i].cdev);
101
102 return 0;
103}
104#else
105#define ams_delta_led_suspend NULL
106#define ams_delta_led_resume NULL
107#endif
108
109static int ams_delta_led_probe(struct platform_device *pdev)
110{
111 int i;
112 int ret;
113
114 for (i = ret = 0; ret >= 0 && i < ARRAY_SIZE(ams_delta_leds); i++) {
115 ret = led_classdev_register(&pdev->dev,
116 &ams_delta_leds[i].cdev);
117 }
118
119 if (ret < 0 && i > 1) {
120 for (i = i - 2; i >= 0; i--)
121 led_classdev_unregister(&ams_delta_leds[i].cdev);
122 }
123
124 return ret;
125}
126
127static int ams_delta_led_remove(struct platform_device *pdev)
128{
129 int i;
130
131 for (i = ARRAY_SIZE(ams_delta_leds) - 1; i >= 0; i--)
132 led_classdev_unregister(&ams_delta_leds[i].cdev);
133
134 return 0;
135}
136
137static struct platform_driver ams_delta_led_driver = {
138 .probe = ams_delta_led_probe,
139 .remove = ams_delta_led_remove,
140 .suspend = ams_delta_led_suspend,
141 .resume = ams_delta_led_resume,
142 .driver = {
143 .name = "ams-delta-led",
144 },
145};
146
147static int __init ams_delta_led_init(void)
148{
149 return platform_driver_register(&ams_delta_led_driver);
150}
151
152static void __exit ams_delta_led_exit(void)
153{
154 return platform_driver_unregister(&ams_delta_led_driver);
155}
156
157module_init(ams_delta_led_init);
158module_exit(ams_delta_led_exit);
159
160MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
161MODULE_DESCRIPTION("Amstrad Delta LED driver");
162MODULE_LICENSE("GPL");