1 From a66e34fefb3f8142d7f16808563eb610225f6e77 Mon Sep 17 00:00:00 2001
2 From: Rod Whitby <rod@whitby.id.au>
3 Date: Tue, 29 Jan 2008 23:17:42 +1030
4 Subject: [PATCH] leds: Add new driver for the LEDs on the Freecom FSG-3
6 The LEDs on the Freecom FSG-3 are connected to an external
7 memory-mapped latch on the ixp4xx expansion bus, and therefore cannot
8 be supported by any of the existing LEDs drivers.
10 Signed-off-by: Rod Whitby <rod@whitby.id.au>
13 KernelVersion: v2.6.25-rc6-117-g457fb60
15 drivers/leds/Kconfig | 6 +
16 drivers/leds/Makefile | 1 +
17 drivers/leds/leds-fsg.c | 261 +++++++++++++++++++++++++++++++++++++++++++++++
18 3 files changed, 268 insertions(+), 0 deletions(-)
19 create mode 100644 drivers/leds/leds-fsg.c
21 diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
22 index 859814f..aefbe04 100644
23 --- a/drivers/leds/Kconfig
24 +++ b/drivers/leds/Kconfig
25 @@ -46,6 +46,12 @@ config LEDS_SPITZ
26 This option enables support for the LEDs on Sharp Zaurus
27 SL-Cxx00 series (C1000, C3000, C3100).
30 + tristate "LED Support for the Freecom FSG-3"
31 + depends on LEDS_CLASS && MACH_FSG
33 + This option enables support for the LEDs on the Freecom FSG-3.
36 tristate "LED Support for the Sharp SL-6000 series"
37 depends on LEDS_CLASS && PXA_SHARPSL
38 diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
39 index 84ced3b..b17bd91 100644
40 --- a/drivers/leds/Makefile
41 +++ b/drivers/leds/Makefile
42 @@ -21,6 +21,7 @@ obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
43 obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o
44 obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
45 obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
46 +obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
49 obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
50 diff --git a/drivers/leds/leds-fsg.c b/drivers/leds/leds-fsg.c
52 index 0000000..a7421b8
54 +++ b/drivers/leds/leds-fsg.c
57 + * LED Driver for the Freecom FSG-3
59 + * Copyright (c) 2008 Rod Whitby <rod@whitby.id.au>
61 + * Author: Rod Whitby <rod@whitby.id.au>
63 + * Based on leds-spitz.c
64 + * Copyright 2005-2006 Openedhand Ltd.
65 + * Author: Richard Purdie <rpurdie@openedhand.com>
67 + * This program is free software; you can redistribute it and/or modify
68 + * it under the terms of the GNU General Public License version 2 as
69 + * published by the Free Software Foundation.
73 +#include <linux/kernel.h>
74 +#include <linux/init.h>
75 +#include <linux/platform_device.h>
76 +#include <linux/leds.h>
77 +#include <asm/arch/hardware.h>
80 +static short __iomem *latch_address;
81 +static unsigned short latch_value;
84 +static void fsg_led_wlan_set(struct led_classdev *led_cdev,
85 + enum led_brightness value)
88 + latch_value &= ~(1 << FSG_LED_WLAN_BIT);
89 + *latch_address = latch_value;
91 + latch_value |= (1 << FSG_LED_WLAN_BIT);
92 + *latch_address = latch_value;
96 +static void fsg_led_wan_set(struct led_classdev *led_cdev,
97 + enum led_brightness value)
100 + latch_value &= ~(1 << FSG_LED_WAN_BIT);
101 + *latch_address = latch_value;
103 + latch_value |= (1 << FSG_LED_WAN_BIT);
104 + *latch_address = latch_value;
108 +static void fsg_led_sata_set(struct led_classdev *led_cdev,
109 + enum led_brightness value)
112 + latch_value &= ~(1 << FSG_LED_SATA_BIT);
113 + *latch_address = latch_value;
115 + latch_value |= (1 << FSG_LED_SATA_BIT);
116 + *latch_address = latch_value;
120 +static void fsg_led_usb_set(struct led_classdev *led_cdev,
121 + enum led_brightness value)
124 + latch_value &= ~(1 << FSG_LED_USB_BIT);
125 + *latch_address = latch_value;
127 + latch_value |= (1 << FSG_LED_USB_BIT);
128 + *latch_address = latch_value;
132 +static void fsg_led_sync_set(struct led_classdev *led_cdev,
133 + enum led_brightness value)
136 + latch_value &= ~(1 << FSG_LED_SYNC_BIT);
137 + *latch_address = latch_value;
139 + latch_value |= (1 << FSG_LED_SYNC_BIT);
140 + *latch_address = latch_value;
144 +static void fsg_led_ring_set(struct led_classdev *led_cdev,
145 + enum led_brightness value)
148 + latch_value &= ~(1 << FSG_LED_RING_BIT);
149 + *latch_address = latch_value;
151 + latch_value |= (1 << FSG_LED_RING_BIT);
152 + *latch_address = latch_value;
158 +static struct led_classdev fsg_wlan_led = {
159 + .name = "fsg:blue:wlan",
160 + .brightness_set = fsg_led_wlan_set,
163 +static struct led_classdev fsg_wan_led = {
164 + .name = "fsg:blue:wan",
165 + .brightness_set = fsg_led_wan_set,
168 +static struct led_classdev fsg_sata_led = {
169 + .name = "fsg:blue:sata",
170 + .brightness_set = fsg_led_sata_set,
173 +static struct led_classdev fsg_usb_led = {
174 + .name = "fsg:blue:usb",
175 + .brightness_set = fsg_led_usb_set,
178 +static struct led_classdev fsg_sync_led = {
179 + .name = "fsg:blue:sync",
180 + .brightness_set = fsg_led_sync_set,
183 +static struct led_classdev fsg_ring_led = {
184 + .name = "fsg:blue:ring",
185 + .brightness_set = fsg_led_ring_set,
191 +static int fsg_led_suspend(struct platform_device *dev, pm_message_t state)
193 + led_classdev_suspend(&fsg_wlan_led);
194 + led_classdev_suspend(&fsg_wan_led);
195 + led_classdev_suspend(&fsg_sata_led);
196 + led_classdev_suspend(&fsg_usb_led);
197 + led_classdev_suspend(&fsg_sync_led);
198 + led_classdev_suspend(&fsg_ring_led);
202 +static int fsg_led_resume(struct platform_device *dev)
204 + led_classdev_resume(&fsg_wlan_led);
205 + led_classdev_resume(&fsg_wan_led);
206 + led_classdev_resume(&fsg_sata_led);
207 + led_classdev_resume(&fsg_usb_led);
208 + led_classdev_resume(&fsg_sync_led);
209 + led_classdev_resume(&fsg_ring_led);
215 +static int fsg_led_probe(struct platform_device *pdev)
219 + ret = led_classdev_register(&pdev->dev, &fsg_wlan_led);
223 + ret = led_classdev_register(&pdev->dev, &fsg_wan_led);
227 + ret = led_classdev_register(&pdev->dev, &fsg_sata_led);
231 + ret = led_classdev_register(&pdev->dev, &fsg_usb_led);
235 + ret = led_classdev_register(&pdev->dev, &fsg_sync_led);
239 + ret = led_classdev_register(&pdev->dev, &fsg_ring_led);
243 + /* Map the LED chip select address space */
244 + latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
245 + if (!latch_address) {
250 + latch_value = 0xffff;
251 + *latch_address = latch_value;
256 + led_classdev_unregister(&fsg_ring_led);
258 + led_classdev_unregister(&fsg_sync_led);
260 + led_classdev_unregister(&fsg_usb_led);
262 + led_classdev_unregister(&fsg_sata_led);
264 + led_classdev_unregister(&fsg_wan_led);
266 + led_classdev_unregister(&fsg_wlan_led);
272 +static int fsg_led_remove(struct platform_device *pdev)
274 + iounmap(latch_address);
276 + led_classdev_unregister(&fsg_wlan_led);
277 + led_classdev_unregister(&fsg_wan_led);
278 + led_classdev_unregister(&fsg_sata_led);
279 + led_classdev_unregister(&fsg_usb_led);
280 + led_classdev_unregister(&fsg_sync_led);
281 + led_classdev_unregister(&fsg_ring_led);
287 +static struct platform_driver fsg_led_driver = {
288 + .probe = fsg_led_probe,
289 + .remove = fsg_led_remove,
291 + .suspend = fsg_led_suspend,
292 + .resume = fsg_led_resume,
300 +static int __init fsg_led_init(void)
302 + return platform_driver_register(&fsg_led_driver);
305 +static void __exit fsg_led_exit(void)
307 + platform_driver_unregister(&fsg_led_driver);
311 +module_init(fsg_led_init);
312 +module_exit(fsg_led_exit);
314 +MODULE_AUTHOR("Rod Whitby <rod@whitby.id.au>");
315 +MODULE_DESCRIPTION("Freecom FSG-3 LED driver");
316 +MODULE_LICENSE("GPL");