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 --- a/drivers/leds/Kconfig
22 +++ b/drivers/leds/Kconfig
24 This option enables support for the LEDs on Sharp Zaurus
25 SL-Cxx00 series (C1000, C3000, C3100).
28 + tristate "LED Support for the Freecom FSG-3"
29 + depends on LEDS_CLASS && MACH_FSG
31 + This option enables support for the LEDs on the Freecom FSG-3.
34 tristate "LED Support for the Sharp SL-6000 series"
35 depends on LEDS_CLASS && PXA_SHARPSL
36 --- a/drivers/leds/Makefile
37 +++ b/drivers/leds/Makefile
39 obj-$(CONFIG_LEDS_CM_X270) += leds-cm-x270.o
40 obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o
41 obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
42 +obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
45 obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
47 +++ b/drivers/leds/leds-fsg.c
50 + * LED Driver for the Freecom FSG-3
52 + * Copyright (c) 2008 Rod Whitby <rod@whitby.id.au>
54 + * Author: Rod Whitby <rod@whitby.id.au>
56 + * Based on leds-spitz.c
57 + * Copyright 2005-2006 Openedhand Ltd.
58 + * Author: Richard Purdie <rpurdie@openedhand.com>
60 + * This program is free software; you can redistribute it and/or modify
61 + * it under the terms of the GNU General Public License version 2 as
62 + * published by the Free Software Foundation.
66 +#include <linux/kernel.h>
67 +#include <linux/init.h>
68 +#include <linux/platform_device.h>
69 +#include <linux/leds.h>
70 +#include <asm/arch/hardware.h>
73 +static short __iomem *latch_address;
74 +static unsigned short latch_value;
77 +static void fsg_led_wlan_set(struct led_classdev *led_cdev,
78 + enum led_brightness value)
81 + latch_value &= ~(1 << FSG_LED_WLAN_BIT);
82 + *latch_address = latch_value;
84 + latch_value |= (1 << FSG_LED_WLAN_BIT);
85 + *latch_address = latch_value;
89 +static void fsg_led_wan_set(struct led_classdev *led_cdev,
90 + enum led_brightness value)
93 + latch_value &= ~(1 << FSG_LED_WAN_BIT);
94 + *latch_address = latch_value;
96 + latch_value |= (1 << FSG_LED_WAN_BIT);
97 + *latch_address = latch_value;
101 +static void fsg_led_sata_set(struct led_classdev *led_cdev,
102 + enum led_brightness value)
105 + latch_value &= ~(1 << FSG_LED_SATA_BIT);
106 + *latch_address = latch_value;
108 + latch_value |= (1 << FSG_LED_SATA_BIT);
109 + *latch_address = latch_value;
113 +static void fsg_led_usb_set(struct led_classdev *led_cdev,
114 + enum led_brightness value)
117 + latch_value &= ~(1 << FSG_LED_USB_BIT);
118 + *latch_address = latch_value;
120 + latch_value |= (1 << FSG_LED_USB_BIT);
121 + *latch_address = latch_value;
125 +static void fsg_led_sync_set(struct led_classdev *led_cdev,
126 + enum led_brightness value)
129 + latch_value &= ~(1 << FSG_LED_SYNC_BIT);
130 + *latch_address = latch_value;
132 + latch_value |= (1 << FSG_LED_SYNC_BIT);
133 + *latch_address = latch_value;
137 +static void fsg_led_ring_set(struct led_classdev *led_cdev,
138 + enum led_brightness value)
141 + latch_value &= ~(1 << FSG_LED_RING_BIT);
142 + *latch_address = latch_value;
144 + latch_value |= (1 << FSG_LED_RING_BIT);
145 + *latch_address = latch_value;
151 +static struct led_classdev fsg_wlan_led = {
152 + .name = "fsg:blue:wlan",
153 + .brightness_set = fsg_led_wlan_set,
156 +static struct led_classdev fsg_wan_led = {
157 + .name = "fsg:blue:wan",
158 + .brightness_set = fsg_led_wan_set,
161 +static struct led_classdev fsg_sata_led = {
162 + .name = "fsg:blue:sata",
163 + .brightness_set = fsg_led_sata_set,
166 +static struct led_classdev fsg_usb_led = {
167 + .name = "fsg:blue:usb",
168 + .brightness_set = fsg_led_usb_set,
171 +static struct led_classdev fsg_sync_led = {
172 + .name = "fsg:blue:sync",
173 + .brightness_set = fsg_led_sync_set,
176 +static struct led_classdev fsg_ring_led = {
177 + .name = "fsg:blue:ring",
178 + .brightness_set = fsg_led_ring_set,
184 +static int fsg_led_suspend(struct platform_device *dev, pm_message_t state)
186 + led_classdev_suspend(&fsg_wlan_led);
187 + led_classdev_suspend(&fsg_wan_led);
188 + led_classdev_suspend(&fsg_sata_led);
189 + led_classdev_suspend(&fsg_usb_led);
190 + led_classdev_suspend(&fsg_sync_led);
191 + led_classdev_suspend(&fsg_ring_led);
195 +static int fsg_led_resume(struct platform_device *dev)
197 + led_classdev_resume(&fsg_wlan_led);
198 + led_classdev_resume(&fsg_wan_led);
199 + led_classdev_resume(&fsg_sata_led);
200 + led_classdev_resume(&fsg_usb_led);
201 + led_classdev_resume(&fsg_sync_led);
202 + led_classdev_resume(&fsg_ring_led);
208 +static int fsg_led_probe(struct platform_device *pdev)
212 + ret = led_classdev_register(&pdev->dev, &fsg_wlan_led);
216 + ret = led_classdev_register(&pdev->dev, &fsg_wan_led);
220 + ret = led_classdev_register(&pdev->dev, &fsg_sata_led);
224 + ret = led_classdev_register(&pdev->dev, &fsg_usb_led);
228 + ret = led_classdev_register(&pdev->dev, &fsg_sync_led);
232 + ret = led_classdev_register(&pdev->dev, &fsg_ring_led);
236 + /* Map the LED chip select address space */
237 + latch_address = (unsigned short *) ioremap(IXP4XX_EXP_BUS_BASE(2), 512);
238 + if (!latch_address) {
243 + latch_value = 0xffff;
244 + *latch_address = latch_value;
249 + led_classdev_unregister(&fsg_ring_led);
251 + led_classdev_unregister(&fsg_sync_led);
253 + led_classdev_unregister(&fsg_usb_led);
255 + led_classdev_unregister(&fsg_sata_led);
257 + led_classdev_unregister(&fsg_wan_led);
259 + led_classdev_unregister(&fsg_wlan_led);
265 +static int fsg_led_remove(struct platform_device *pdev)
267 + iounmap(latch_address);
269 + led_classdev_unregister(&fsg_wlan_led);
270 + led_classdev_unregister(&fsg_wan_led);
271 + led_classdev_unregister(&fsg_sata_led);
272 + led_classdev_unregister(&fsg_usb_led);
273 + led_classdev_unregister(&fsg_sync_led);
274 + led_classdev_unregister(&fsg_ring_led);
280 +static struct platform_driver fsg_led_driver = {
281 + .probe = fsg_led_probe,
282 + .remove = fsg_led_remove,
284 + .suspend = fsg_led_suspend,
285 + .resume = fsg_led_resume,
293 +static int __init fsg_led_init(void)
295 + return platform_driver_register(&fsg_led_driver);
298 +static void __exit fsg_led_exit(void)
300 + platform_driver_unregister(&fsg_led_driver);
304 +module_init(fsg_led_init);
305 +module_exit(fsg_led_exit);
307 +MODULE_AUTHOR("Rod Whitby <rod@whitby.id.au>");
308 +MODULE_DESCRIPTION("Freecom FSG-3 LED driver");
309 +MODULE_LICENSE("GPL");