2 * LED Driver for the Freecom FSG-3
4 * Copyright (c) 2008 Rod Whitby <rod@whitby.id.au>
6 * Author: Rod Whitby <rod@whitby.id.au>
8 * Based on leds-spitz.c
9 * Copyright 2005-2006 Openedhand Ltd.
10 * Author: Richard Purdie <rpurdie@openedhand.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
18 #include <linux/kernel.h>
19 #include <linux/platform_device.h>
20 #include <linux/leds.h>
21 #include <linux/module.h>
23 #include <mach/hardware.h>
25 #define FSG_LED_WLAN_BIT 0
26 #define FSG_LED_WAN_BIT 1
27 #define FSG_LED_SATA_BIT 2
28 #define FSG_LED_USB_BIT 4
29 #define FSG_LED_RING_BIT 5
30 #define FSG_LED_SYNC_BIT 7
32 static short __iomem
*latch_address
;
33 static unsigned short latch_value
;
36 static void fsg_led_wlan_set(struct led_classdev
*led_cdev
,
37 enum led_brightness value
)
40 latch_value
&= ~(1 << FSG_LED_WLAN_BIT
);
41 *latch_address
= latch_value
;
43 latch_value
|= (1 << FSG_LED_WLAN_BIT
);
44 *latch_address
= latch_value
;
48 static void fsg_led_wan_set(struct led_classdev
*led_cdev
,
49 enum led_brightness value
)
52 latch_value
&= ~(1 << FSG_LED_WAN_BIT
);
53 *latch_address
= latch_value
;
55 latch_value
|= (1 << FSG_LED_WAN_BIT
);
56 *latch_address
= latch_value
;
60 static void fsg_led_sata_set(struct led_classdev
*led_cdev
,
61 enum led_brightness value
)
64 latch_value
&= ~(1 << FSG_LED_SATA_BIT
);
65 *latch_address
= latch_value
;
67 latch_value
|= (1 << FSG_LED_SATA_BIT
);
68 *latch_address
= latch_value
;
72 static void fsg_led_usb_set(struct led_classdev
*led_cdev
,
73 enum led_brightness value
)
76 latch_value
&= ~(1 << FSG_LED_USB_BIT
);
77 *latch_address
= latch_value
;
79 latch_value
|= (1 << FSG_LED_USB_BIT
);
80 *latch_address
= latch_value
;
84 static void fsg_led_sync_set(struct led_classdev
*led_cdev
,
85 enum led_brightness value
)
88 latch_value
&= ~(1 << FSG_LED_SYNC_BIT
);
89 *latch_address
= latch_value
;
91 latch_value
|= (1 << FSG_LED_SYNC_BIT
);
92 *latch_address
= latch_value
;
96 static void fsg_led_ring_set(struct led_classdev
*led_cdev
,
97 enum led_brightness value
)
100 latch_value
&= ~(1 << FSG_LED_RING_BIT
);
101 *latch_address
= latch_value
;
103 latch_value
|= (1 << FSG_LED_RING_BIT
);
104 *latch_address
= latch_value
;
109 static struct led_classdev fsg_wlan_led
= {
110 .name
= "fsg:blue:wlan",
111 .brightness_set
= fsg_led_wlan_set
,
112 .flags
= LED_CORE_SUSPENDRESUME
,
115 static struct led_classdev fsg_wan_led
= {
116 .name
= "fsg:blue:wan",
117 .brightness_set
= fsg_led_wan_set
,
118 .flags
= LED_CORE_SUSPENDRESUME
,
121 static struct led_classdev fsg_sata_led
= {
122 .name
= "fsg:blue:sata",
123 .brightness_set
= fsg_led_sata_set
,
124 .flags
= LED_CORE_SUSPENDRESUME
,
127 static struct led_classdev fsg_usb_led
= {
128 .name
= "fsg:blue:usb",
129 .brightness_set
= fsg_led_usb_set
,
130 .flags
= LED_CORE_SUSPENDRESUME
,
133 static struct led_classdev fsg_sync_led
= {
134 .name
= "fsg:blue:sync",
135 .brightness_set
= fsg_led_sync_set
,
136 .flags
= LED_CORE_SUSPENDRESUME
,
139 static struct led_classdev fsg_ring_led
= {
140 .name
= "fsg:blue:ring",
141 .brightness_set
= fsg_led_ring_set
,
142 .flags
= LED_CORE_SUSPENDRESUME
,
146 static int fsg_led_probe(struct platform_device
*pdev
)
150 /* Map the LED chip select address space */
151 latch_address
= (unsigned short *) devm_ioremap(&pdev
->dev
,
152 IXP4XX_EXP_BUS_BASE(2), 512);
156 latch_value
= 0xffff;
157 *latch_address
= latch_value
;
159 ret
= led_classdev_register(&pdev
->dev
, &fsg_wlan_led
);
163 ret
= led_classdev_register(&pdev
->dev
, &fsg_wan_led
);
167 ret
= led_classdev_register(&pdev
->dev
, &fsg_sata_led
);
171 ret
= led_classdev_register(&pdev
->dev
, &fsg_usb_led
);
175 ret
= led_classdev_register(&pdev
->dev
, &fsg_sync_led
);
179 ret
= led_classdev_register(&pdev
->dev
, &fsg_ring_led
);
186 led_classdev_unregister(&fsg_sync_led
);
188 led_classdev_unregister(&fsg_usb_led
);
190 led_classdev_unregister(&fsg_sata_led
);
192 led_classdev_unregister(&fsg_wan_led
);
194 led_classdev_unregister(&fsg_wlan_led
);
200 static int fsg_led_remove(struct platform_device
*pdev
)
202 led_classdev_unregister(&fsg_wlan_led
);
203 led_classdev_unregister(&fsg_wan_led
);
204 led_classdev_unregister(&fsg_sata_led
);
205 led_classdev_unregister(&fsg_usb_led
);
206 led_classdev_unregister(&fsg_sync_led
);
207 led_classdev_unregister(&fsg_ring_led
);
213 static struct platform_driver fsg_led_driver
= {
214 .probe
= fsg_led_probe
,
215 .remove
= fsg_led_remove
,
221 module_platform_driver(fsg_led_driver
);
223 MODULE_AUTHOR("Rod Whitby <rod@whitby.id.au>");
224 MODULE_DESCRIPTION("Freecom FSG-3 LED driver");
225 MODULE_LICENSE("GPL");