Commit 11efe71f6564e59ba9acfc636ac6f423e059dc69
Committed by
Nicolas Pitre
1 parent
b6a044ff57
Exists in
master
and in
7 other branches
leds: add LED driver for Network Space v2 LEDs
This patch add a LED class driver for the dual-GPIO LEDs found on the Network Space v2 board (and parents). This include Internet Space v2, Network Space (Max) v2 and d2 Network v2 boards. This dual-GPIO LED is wired to a CPLD and can blink in relation with the SATA activity. The driver expose this capability through a "sata" sysfs attribute. Signed-off-by: Simon Guinot <sguinot@lacie.com> Signed-off-by: Nicolas Pitre <nico@fluxnic.net>
Showing 4 changed files with 374 additions and 0 deletions Inline Diff
arch/arm/mach-kirkwood/include/mach/leds-ns2.h
File was created | 1 | /* | |
2 | * arch/arm/mach-kirkwood/include/mach/leds-ns2.h | ||
3 | * | ||
4 | * Platform data structure for Network Space v2 LED driver | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #ifndef __MACH_LEDS_NS2_H | ||
12 | #define __MACH_LEDS_NS2_H | ||
13 | |||
14 | struct ns2_led { | ||
15 | const char *name; | ||
16 | const char *default_trigger; | ||
17 | unsigned cmd; | ||
18 | unsigned slow; | ||
19 | }; | ||
20 | |||
21 | struct ns2_led_platform_data { | ||
22 | int num_leds; | ||
23 | struct ns2_led *leds; | ||
24 | }; | ||
25 | |||
26 | #endif /* __MACH_LEDS_NS2_H */ | ||
27 |
drivers/leds/Kconfig
1 | menuconfig NEW_LEDS | 1 | menuconfig NEW_LEDS |
2 | bool "LED Support" | 2 | bool "LED Support" |
3 | help | 3 | help |
4 | Say Y to enable Linux LED support. This allows control of supported | 4 | Say Y to enable Linux LED support. This allows control of supported |
5 | LEDs from both userspace and optionally, by kernel events (triggers). | 5 | LEDs from both userspace and optionally, by kernel events (triggers). |
6 | 6 | ||
7 | This is not related to standard keyboard LEDs which are controlled | 7 | This is not related to standard keyboard LEDs which are controlled |
8 | via the input system. | 8 | via the input system. |
9 | 9 | ||
10 | if NEW_LEDS | 10 | if NEW_LEDS |
11 | 11 | ||
12 | config LEDS_CLASS | 12 | config LEDS_CLASS |
13 | tristate "LED Class Support" | 13 | tristate "LED Class Support" |
14 | help | 14 | help |
15 | This option enables the led sysfs class in /sys/class/leds. You'll | 15 | This option enables the led sysfs class in /sys/class/leds. You'll |
16 | need this to do anything useful with LEDs. If unsure, say N. | 16 | need this to do anything useful with LEDs. If unsure, say N. |
17 | 17 | ||
18 | if LEDS_CLASS | 18 | if LEDS_CLASS |
19 | 19 | ||
20 | comment "LED drivers" | 20 | comment "LED drivers" |
21 | 21 | ||
22 | config LEDS_88PM860X | 22 | config LEDS_88PM860X |
23 | tristate "LED Support for Marvell 88PM860x PMIC" | 23 | tristate "LED Support for Marvell 88PM860x PMIC" |
24 | depends on MFD_88PM860X | 24 | depends on MFD_88PM860X |
25 | help | 25 | help |
26 | This option enables support for on-chip LED drivers found on Marvell | 26 | This option enables support for on-chip LED drivers found on Marvell |
27 | Semiconductor 88PM8606 PMIC. | 27 | Semiconductor 88PM8606 PMIC. |
28 | 28 | ||
29 | config LEDS_ATMEL_PWM | 29 | config LEDS_ATMEL_PWM |
30 | tristate "LED Support using Atmel PWM outputs" | 30 | tristate "LED Support using Atmel PWM outputs" |
31 | depends on ATMEL_PWM | 31 | depends on ATMEL_PWM |
32 | help | 32 | help |
33 | This option enables support for LEDs driven using outputs | 33 | This option enables support for LEDs driven using outputs |
34 | of the dedicated PWM controller found on newer Atmel SOCs. | 34 | of the dedicated PWM controller found on newer Atmel SOCs. |
35 | 35 | ||
36 | config LEDS_LOCOMO | 36 | config LEDS_LOCOMO |
37 | tristate "LED Support for Locomo device" | 37 | tristate "LED Support for Locomo device" |
38 | depends on SHARP_LOCOMO | 38 | depends on SHARP_LOCOMO |
39 | help | 39 | help |
40 | This option enables support for the LEDs on Sharp Locomo. | 40 | This option enables support for the LEDs on Sharp Locomo. |
41 | Zaurus models SL-5500 and SL-5600. | 41 | Zaurus models SL-5500 and SL-5600. |
42 | 42 | ||
43 | config LEDS_MIKROTIK_RB532 | 43 | config LEDS_MIKROTIK_RB532 |
44 | tristate "LED Support for Mikrotik Routerboard 532" | 44 | tristate "LED Support for Mikrotik Routerboard 532" |
45 | depends on MIKROTIK_RB532 | 45 | depends on MIKROTIK_RB532 |
46 | help | 46 | help |
47 | This option enables support for the so called "User LED" of | 47 | This option enables support for the so called "User LED" of |
48 | Mikrotik's Routerboard 532. | 48 | Mikrotik's Routerboard 532. |
49 | 49 | ||
50 | config LEDS_S3C24XX | 50 | config LEDS_S3C24XX |
51 | tristate "LED Support for Samsung S3C24XX GPIO LEDs" | 51 | tristate "LED Support for Samsung S3C24XX GPIO LEDs" |
52 | depends on ARCH_S3C2410 | 52 | depends on ARCH_S3C2410 |
53 | help | 53 | help |
54 | This option enables support for LEDs connected to GPIO lines | 54 | This option enables support for LEDs connected to GPIO lines |
55 | on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440. | 55 | on Samsung S3C24XX series CPUs, such as the S3C2410 and S3C2440. |
56 | 56 | ||
57 | config LEDS_AMS_DELTA | 57 | config LEDS_AMS_DELTA |
58 | tristate "LED Support for the Amstrad Delta (E3)" | 58 | tristate "LED Support for the Amstrad Delta (E3)" |
59 | depends on MACH_AMS_DELTA | 59 | depends on MACH_AMS_DELTA |
60 | help | 60 | help |
61 | This option enables support for the LEDs on Amstrad Delta (E3). | 61 | This option enables support for the LEDs on Amstrad Delta (E3). |
62 | 62 | ||
63 | config LEDS_NET48XX | 63 | config LEDS_NET48XX |
64 | tristate "LED Support for Soekris net48xx series Error LED" | 64 | tristate "LED Support for Soekris net48xx series Error LED" |
65 | depends on SCx200_GPIO | 65 | depends on SCx200_GPIO |
66 | help | 66 | help |
67 | This option enables support for the Soekris net4801 and net4826 error | 67 | This option enables support for the Soekris net4801 and net4826 error |
68 | LED. | 68 | LED. |
69 | 69 | ||
70 | config LEDS_NET5501 | 70 | config LEDS_NET5501 |
71 | tristate "LED Support for Soekris net5501 series Error LED" | 71 | tristate "LED Support for Soekris net5501 series Error LED" |
72 | depends on LEDS_TRIGGERS | 72 | depends on LEDS_TRIGGERS |
73 | depends on X86 && LEDS_GPIO_PLATFORM && GPIO_CS5535 | 73 | depends on X86 && LEDS_GPIO_PLATFORM && GPIO_CS5535 |
74 | select LEDS_TRIGGER_DEFAULT_ON | 74 | select LEDS_TRIGGER_DEFAULT_ON |
75 | default n | 75 | default n |
76 | help | 76 | help |
77 | Add support for the Soekris net5501 board (detection, error led | 77 | Add support for the Soekris net5501 board (detection, error led |
78 | and GPIO). | 78 | and GPIO). |
79 | 79 | ||
80 | config LEDS_FSG | 80 | config LEDS_FSG |
81 | tristate "LED Support for the Freecom FSG-3" | 81 | tristate "LED Support for the Freecom FSG-3" |
82 | depends on MACH_FSG | 82 | depends on MACH_FSG |
83 | help | 83 | help |
84 | This option enables support for the LEDs on the Freecom FSG-3. | 84 | This option enables support for the LEDs on the Freecom FSG-3. |
85 | 85 | ||
86 | config LEDS_WRAP | 86 | config LEDS_WRAP |
87 | tristate "LED Support for the WRAP series LEDs" | 87 | tristate "LED Support for the WRAP series LEDs" |
88 | depends on SCx200_GPIO | 88 | depends on SCx200_GPIO |
89 | help | 89 | help |
90 | This option enables support for the PCEngines WRAP programmable LEDs. | 90 | This option enables support for the PCEngines WRAP programmable LEDs. |
91 | 91 | ||
92 | config LEDS_ALIX2 | 92 | config LEDS_ALIX2 |
93 | tristate "LED Support for ALIX.2 and ALIX.3 series" | 93 | tristate "LED Support for ALIX.2 and ALIX.3 series" |
94 | depends on X86 && !GPIO_CS5535 && !CS5535_GPIO | 94 | depends on X86 && !GPIO_CS5535 && !CS5535_GPIO |
95 | help | 95 | help |
96 | This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs. | 96 | This option enables support for the PCEngines ALIX.2 and ALIX.3 LEDs. |
97 | You have to set leds-alix2.force=1 for boards with Award BIOS. | 97 | You have to set leds-alix2.force=1 for boards with Award BIOS. |
98 | 98 | ||
99 | config LEDS_H1940 | 99 | config LEDS_H1940 |
100 | tristate "LED Support for iPAQ H1940 device" | 100 | tristate "LED Support for iPAQ H1940 device" |
101 | depends on ARCH_H1940 | 101 | depends on ARCH_H1940 |
102 | help | 102 | help |
103 | This option enables support for the LEDs on the h1940. | 103 | This option enables support for the LEDs on the h1940. |
104 | 104 | ||
105 | config LEDS_COBALT_QUBE | 105 | config LEDS_COBALT_QUBE |
106 | tristate "LED Support for the Cobalt Qube series front LED" | 106 | tristate "LED Support for the Cobalt Qube series front LED" |
107 | depends on MIPS_COBALT | 107 | depends on MIPS_COBALT |
108 | help | 108 | help |
109 | This option enables support for the front LED on Cobalt Qube series | 109 | This option enables support for the front LED on Cobalt Qube series |
110 | 110 | ||
111 | config LEDS_COBALT_RAQ | 111 | config LEDS_COBALT_RAQ |
112 | bool "LED Support for the Cobalt Raq series" | 112 | bool "LED Support for the Cobalt Raq series" |
113 | depends on LEDS_CLASS=y && MIPS_COBALT | 113 | depends on LEDS_CLASS=y && MIPS_COBALT |
114 | select LEDS_TRIGGERS | 114 | select LEDS_TRIGGERS |
115 | help | 115 | help |
116 | This option enables support for the Cobalt Raq series LEDs. | 116 | This option enables support for the Cobalt Raq series LEDs. |
117 | 117 | ||
118 | config LEDS_SUNFIRE | 118 | config LEDS_SUNFIRE |
119 | tristate "LED support for SunFire servers." | 119 | tristate "LED support for SunFire servers." |
120 | depends on SPARC64 | 120 | depends on SPARC64 |
121 | select LEDS_TRIGGERS | 121 | select LEDS_TRIGGERS |
122 | help | 122 | help |
123 | This option enables support for the Left, Middle, and Right | 123 | This option enables support for the Left, Middle, and Right |
124 | LEDs on the I/O and CPU boards of SunFire UltraSPARC servers. | 124 | LEDs on the I/O and CPU boards of SunFire UltraSPARC servers. |
125 | 125 | ||
126 | config LEDS_HP6XX | 126 | config LEDS_HP6XX |
127 | tristate "LED Support for the HP Jornada 6xx" | 127 | tristate "LED Support for the HP Jornada 6xx" |
128 | depends on SH_HP6XX | 128 | depends on SH_HP6XX |
129 | help | 129 | help |
130 | This option enables LED support for the handheld | 130 | This option enables LED support for the handheld |
131 | HP Jornada 620/660/680/690. | 131 | HP Jornada 620/660/680/690. |
132 | 132 | ||
133 | config LEDS_PCA9532 | 133 | config LEDS_PCA9532 |
134 | tristate "LED driver for PCA9532 dimmer" | 134 | tristate "LED driver for PCA9532 dimmer" |
135 | depends on I2C && INPUT && EXPERIMENTAL | 135 | depends on I2C && INPUT && EXPERIMENTAL |
136 | help | 136 | help |
137 | This option enables support for NXP pca9532 | 137 | This option enables support for NXP pca9532 |
138 | LED controller. It is generally only useful | 138 | LED controller. It is generally only useful |
139 | as a platform driver | 139 | as a platform driver |
140 | 140 | ||
141 | config LEDS_GPIO | 141 | config LEDS_GPIO |
142 | tristate "LED Support for GPIO connected LEDs" | 142 | tristate "LED Support for GPIO connected LEDs" |
143 | depends on GENERIC_GPIO | 143 | depends on GENERIC_GPIO |
144 | help | 144 | help |
145 | This option enables support for the LEDs connected to GPIO | 145 | This option enables support for the LEDs connected to GPIO |
146 | outputs. To be useful the particular board must have LEDs | 146 | outputs. To be useful the particular board must have LEDs |
147 | and they must be connected to the GPIO lines. The LEDs must be | 147 | and they must be connected to the GPIO lines. The LEDs must be |
148 | defined as platform devices and/or OpenFirmware platform devices. | 148 | defined as platform devices and/or OpenFirmware platform devices. |
149 | The code to use these bindings can be selected below. | 149 | The code to use these bindings can be selected below. |
150 | 150 | ||
151 | config LEDS_GPIO_PLATFORM | 151 | config LEDS_GPIO_PLATFORM |
152 | bool "Platform device bindings for GPIO LEDs" | 152 | bool "Platform device bindings for GPIO LEDs" |
153 | depends on LEDS_GPIO | 153 | depends on LEDS_GPIO |
154 | default y | 154 | default y |
155 | help | 155 | help |
156 | Let the leds-gpio driver drive LEDs which have been defined as | 156 | Let the leds-gpio driver drive LEDs which have been defined as |
157 | platform devices. If you don't know what this means, say yes. | 157 | platform devices. If you don't know what this means, say yes. |
158 | 158 | ||
159 | config LEDS_GPIO_OF | 159 | config LEDS_GPIO_OF |
160 | bool "OpenFirmware platform device bindings for GPIO LEDs" | 160 | bool "OpenFirmware platform device bindings for GPIO LEDs" |
161 | depends on LEDS_GPIO && OF_DEVICE | 161 | depends on LEDS_GPIO && OF_DEVICE |
162 | default y | 162 | default y |
163 | help | 163 | help |
164 | Let the leds-gpio driver drive LEDs which have been defined as | 164 | Let the leds-gpio driver drive LEDs which have been defined as |
165 | of_platform devices. For instance, LEDs which are listed in a "dts" | 165 | of_platform devices. For instance, LEDs which are listed in a "dts" |
166 | file. | 166 | file. |
167 | 167 | ||
168 | config LEDS_LP3944 | 168 | config LEDS_LP3944 |
169 | tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip" | 169 | tristate "LED Support for N.S. LP3944 (Fun Light) I2C chip" |
170 | depends on I2C | 170 | depends on I2C |
171 | help | 171 | help |
172 | This option enables support for LEDs connected to the National | 172 | This option enables support for LEDs connected to the National |
173 | Semiconductor LP3944 Lighting Management Unit (LMU) also known as | 173 | Semiconductor LP3944 Lighting Management Unit (LMU) also known as |
174 | Fun Light Chip. | 174 | Fun Light Chip. |
175 | 175 | ||
176 | To compile this driver as a module, choose M here: the | 176 | To compile this driver as a module, choose M here: the |
177 | module will be called leds-lp3944. | 177 | module will be called leds-lp3944. |
178 | 178 | ||
179 | config LEDS_CLEVO_MAIL | 179 | config LEDS_CLEVO_MAIL |
180 | tristate "Mail LED on Clevo notebook" | 180 | tristate "Mail LED on Clevo notebook" |
181 | depends on X86 && SERIO_I8042 && DMI | 181 | depends on X86 && SERIO_I8042 && DMI |
182 | help | 182 | help |
183 | This driver makes the mail LED accessible from userspace | 183 | This driver makes the mail LED accessible from userspace |
184 | programs through the leds subsystem. This LED have three | 184 | programs through the leds subsystem. This LED have three |
185 | known mode: off, blink at 0.5Hz and blink at 1Hz. | 185 | known mode: off, blink at 0.5Hz and blink at 1Hz. |
186 | 186 | ||
187 | The driver supports two kinds of interface: using ledtrig-timer | 187 | The driver supports two kinds of interface: using ledtrig-timer |
188 | or through /sys/class/leds/clevo::mail/brightness. As this LED | 188 | or through /sys/class/leds/clevo::mail/brightness. As this LED |
189 | cannot change it's brightness it blinks instead. The brightness | 189 | cannot change it's brightness it blinks instead. The brightness |
190 | value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means | 190 | value 0 means off, 1..127 means blink at 0.5Hz and 128..255 means |
191 | blink at 1Hz. | 191 | blink at 1Hz. |
192 | 192 | ||
193 | This module can drive the mail LED for the following notebooks: | 193 | This module can drive the mail LED for the following notebooks: |
194 | 194 | ||
195 | Clevo D400P | 195 | Clevo D400P |
196 | Clevo D410J | 196 | Clevo D410J |
197 | Clevo D410V | 197 | Clevo D410V |
198 | Clevo D400V/D470V (not tested, but might work) | 198 | Clevo D400V/D470V (not tested, but might work) |
199 | Clevo M540N | 199 | Clevo M540N |
200 | Clevo M5x0N (not tested, but might work) | 200 | Clevo M5x0N (not tested, but might work) |
201 | Positivo Mobile (Clevo M5x0V) | 201 | Positivo Mobile (Clevo M5x0V) |
202 | 202 | ||
203 | If your model is not listed here you can try the "nodetect" | 203 | If your model is not listed here you can try the "nodetect" |
204 | module parameter. | 204 | module parameter. |
205 | 205 | ||
206 | To compile this driver as a module, choose M here: the | 206 | To compile this driver as a module, choose M here: the |
207 | module will be called leds-clevo-mail. | 207 | module will be called leds-clevo-mail. |
208 | 208 | ||
209 | config LEDS_PCA955X | 209 | config LEDS_PCA955X |
210 | tristate "LED Support for PCA955x I2C chips" | 210 | tristate "LED Support for PCA955x I2C chips" |
211 | depends on I2C | 211 | depends on I2C |
212 | help | 212 | help |
213 | This option enables support for LEDs connected to PCA955x | 213 | This option enables support for LEDs connected to PCA955x |
214 | LED driver chips accessed via the I2C bus. Supported | 214 | LED driver chips accessed via the I2C bus. Supported |
215 | devices include PCA9550, PCA9551, PCA9552, and PCA9553. | 215 | devices include PCA9550, PCA9551, PCA9552, and PCA9553. |
216 | 216 | ||
217 | config LEDS_WM831X_STATUS | 217 | config LEDS_WM831X_STATUS |
218 | tristate "LED support for status LEDs on WM831x PMICs" | 218 | tristate "LED support for status LEDs on WM831x PMICs" |
219 | depends on MFD_WM831X | 219 | depends on MFD_WM831X |
220 | help | 220 | help |
221 | This option enables support for the status LEDs of the WM831x | 221 | This option enables support for the status LEDs of the WM831x |
222 | series of PMICs. | 222 | series of PMICs. |
223 | 223 | ||
224 | config LEDS_WM8350 | 224 | config LEDS_WM8350 |
225 | tristate "LED Support for WM8350 AudioPlus PMIC" | 225 | tristate "LED Support for WM8350 AudioPlus PMIC" |
226 | depends on MFD_WM8350 | 226 | depends on MFD_WM8350 |
227 | help | 227 | help |
228 | This option enables support for LEDs driven by the Wolfson | 228 | This option enables support for LEDs driven by the Wolfson |
229 | Microelectronics WM8350 AudioPlus PMIC. | 229 | Microelectronics WM8350 AudioPlus PMIC. |
230 | 230 | ||
231 | config LEDS_DA903X | 231 | config LEDS_DA903X |
232 | tristate "LED Support for DA9030/DA9034 PMIC" | 232 | tristate "LED Support for DA9030/DA9034 PMIC" |
233 | depends on PMIC_DA903X | 233 | depends on PMIC_DA903X |
234 | help | 234 | help |
235 | This option enables support for on-chip LED drivers found | 235 | This option enables support for on-chip LED drivers found |
236 | on Dialog Semiconductor DA9030/DA9034 PMICs. | 236 | on Dialog Semiconductor DA9030/DA9034 PMICs. |
237 | 237 | ||
238 | config LEDS_DAC124S085 | 238 | config LEDS_DAC124S085 |
239 | tristate "LED Support for DAC124S085 SPI DAC" | 239 | tristate "LED Support for DAC124S085 SPI DAC" |
240 | depends on SPI | 240 | depends on SPI |
241 | help | 241 | help |
242 | This option enables support for DAC124S085 SPI DAC from NatSemi, | 242 | This option enables support for DAC124S085 SPI DAC from NatSemi, |
243 | which can be used to control up to four LEDs. | 243 | which can be used to control up to four LEDs. |
244 | 244 | ||
245 | config LEDS_PWM | 245 | config LEDS_PWM |
246 | tristate "PWM driven LED Support" | 246 | tristate "PWM driven LED Support" |
247 | depends on HAVE_PWM | 247 | depends on HAVE_PWM |
248 | help | 248 | help |
249 | This option enables support for pwm driven LEDs | 249 | This option enables support for pwm driven LEDs |
250 | 250 | ||
251 | config LEDS_REGULATOR | 251 | config LEDS_REGULATOR |
252 | tristate "REGULATOR driven LED support" | 252 | tristate "REGULATOR driven LED support" |
253 | depends on REGULATOR | 253 | depends on REGULATOR |
254 | help | 254 | help |
255 | This option enables support for regulator driven LEDs. | 255 | This option enables support for regulator driven LEDs. |
256 | 256 | ||
257 | config LEDS_BD2802 | 257 | config LEDS_BD2802 |
258 | tristate "LED driver for BD2802 RGB LED" | 258 | tristate "LED driver for BD2802 RGB LED" |
259 | depends on I2C | 259 | depends on I2C |
260 | help | 260 | help |
261 | This option enables support for BD2802GU RGB LED driver chips | 261 | This option enables support for BD2802GU RGB LED driver chips |
262 | accessed via the I2C bus. | 262 | accessed via the I2C bus. |
263 | 263 | ||
264 | config LEDS_INTEL_SS4200 | 264 | config LEDS_INTEL_SS4200 |
265 | tristate "LED driver for Intel NAS SS4200 series" | 265 | tristate "LED driver for Intel NAS SS4200 series" |
266 | depends on PCI && DMI | 266 | depends on PCI && DMI |
267 | help | 267 | help |
268 | This option enables support for the Intel SS4200 series of | 268 | This option enables support for the Intel SS4200 series of |
269 | Network Attached Storage servers. You may control the hard | 269 | Network Attached Storage servers. You may control the hard |
270 | drive or power LEDs on the front panel. Using this driver | 270 | drive or power LEDs on the front panel. Using this driver |
271 | can stop the front LED from blinking after startup. | 271 | can stop the front LED from blinking after startup. |
272 | 272 | ||
273 | config LEDS_LT3593 | 273 | config LEDS_LT3593 |
274 | tristate "LED driver for LT3593 controllers" | 274 | tristate "LED driver for LT3593 controllers" |
275 | depends on GENERIC_GPIO | 275 | depends on GENERIC_GPIO |
276 | help | 276 | help |
277 | This option enables support for LEDs driven by a Linear Technology | 277 | This option enables support for LEDs driven by a Linear Technology |
278 | LT3593 controller. This controller uses a special one-wire pulse | 278 | LT3593 controller. This controller uses a special one-wire pulse |
279 | coding protocol to set the brightness. | 279 | coding protocol to set the brightness. |
280 | 280 | ||
281 | config LEDS_ADP5520 | 281 | config LEDS_ADP5520 |
282 | tristate "LED Support for ADP5520/ADP5501 PMIC" | 282 | tristate "LED Support for ADP5520/ADP5501 PMIC" |
283 | depends on PMIC_ADP5520 | 283 | depends on PMIC_ADP5520 |
284 | help | 284 | help |
285 | This option enables support for on-chip LED drivers found | 285 | This option enables support for on-chip LED drivers found |
286 | on Analog Devices ADP5520/ADP5501 PMICs. | 286 | on Analog Devices ADP5520/ADP5501 PMICs. |
287 | 287 | ||
288 | To compile this driver as a module, choose M here: the module will | 288 | To compile this driver as a module, choose M here: the module will |
289 | be called leds-adp5520. | 289 | be called leds-adp5520. |
290 | 290 | ||
291 | config LEDS_DELL_NETBOOKS | 291 | config LEDS_DELL_NETBOOKS |
292 | tristate "External LED on Dell Business Netbooks" | 292 | tristate "External LED on Dell Business Netbooks" |
293 | depends on X86 && ACPI_WMI | 293 | depends on X86 && ACPI_WMI |
294 | help | 294 | help |
295 | This adds support for the Latitude 2100 and similar | 295 | This adds support for the Latitude 2100 and similar |
296 | notebooks that have an external LED. | 296 | notebooks that have an external LED. |
297 | 297 | ||
298 | config LEDS_MC13783 | 298 | config LEDS_MC13783 |
299 | tristate "LED Support for MC13783 PMIC" | 299 | tristate "LED Support for MC13783 PMIC" |
300 | depends on MFD_MC13783 | 300 | depends on MFD_MC13783 |
301 | help | 301 | help |
302 | This option enable support for on-chip LED drivers found | 302 | This option enable support for on-chip LED drivers found |
303 | on Freescale Semiconductor MC13783 PMIC. | 303 | on Freescale Semiconductor MC13783 PMIC. |
304 | 304 | ||
305 | config LEDS_NS2 | ||
306 | tristate "LED support for Network Space v2 GPIO LEDs" | ||
307 | depends on MACH_NETSPACE_V2 || MACH_INETSPACE_V2 || MACH_NETSPACE_MAX_V2 | ||
308 | default y | ||
309 | help | ||
310 | This option enable support for the dual-GPIO LED found on the | ||
311 | Network Space v2 board (and parents). This include Internet Space v2, | ||
312 | Network Space (Max) v2 and d2 Network v2 boards. | ||
313 | |||
305 | config LEDS_TRIGGERS | 314 | config LEDS_TRIGGERS |
306 | bool "LED Trigger support" | 315 | bool "LED Trigger support" |
307 | help | 316 | help |
308 | This option enables trigger support for the leds class. | 317 | This option enables trigger support for the leds class. |
309 | These triggers allow kernel events to drive the LEDs and can | 318 | These triggers allow kernel events to drive the LEDs and can |
310 | be configured via sysfs. If unsure, say Y. | 319 | be configured via sysfs. If unsure, say Y. |
311 | 320 | ||
312 | if LEDS_TRIGGERS | 321 | if LEDS_TRIGGERS |
313 | 322 | ||
314 | comment "LED Triggers" | 323 | comment "LED Triggers" |
315 | 324 | ||
316 | config LEDS_TRIGGER_TIMER | 325 | config LEDS_TRIGGER_TIMER |
317 | tristate "LED Timer Trigger" | 326 | tristate "LED Timer Trigger" |
318 | help | 327 | help |
319 | This allows LEDs to be controlled by a programmable timer | 328 | This allows LEDs to be controlled by a programmable timer |
320 | via sysfs. Some LED hardware can be programmed to start | 329 | via sysfs. Some LED hardware can be programmed to start |
321 | blinking the LED without any further software interaction. | 330 | blinking the LED without any further software interaction. |
322 | For more details read Documentation/leds-class.txt. | 331 | For more details read Documentation/leds-class.txt. |
323 | 332 | ||
324 | If unsure, say Y. | 333 | If unsure, say Y. |
325 | 334 | ||
326 | config LEDS_TRIGGER_IDE_DISK | 335 | config LEDS_TRIGGER_IDE_DISK |
327 | bool "LED IDE Disk Trigger" | 336 | bool "LED IDE Disk Trigger" |
328 | depends on IDE_GD_ATA | 337 | depends on IDE_GD_ATA |
329 | help | 338 | help |
330 | This allows LEDs to be controlled by IDE disk activity. | 339 | This allows LEDs to be controlled by IDE disk activity. |
331 | If unsure, say Y. | 340 | If unsure, say Y. |
332 | 341 | ||
333 | config LEDS_TRIGGER_HEARTBEAT | 342 | config LEDS_TRIGGER_HEARTBEAT |
334 | tristate "LED Heartbeat Trigger" | 343 | tristate "LED Heartbeat Trigger" |
335 | help | 344 | help |
336 | This allows LEDs to be controlled by a CPU load average. | 345 | This allows LEDs to be controlled by a CPU load average. |
337 | The flash frequency is a hyperbolic function of the 1-minute | 346 | The flash frequency is a hyperbolic function of the 1-minute |
338 | load average. | 347 | load average. |
339 | If unsure, say Y. | 348 | If unsure, say Y. |
340 | 349 | ||
341 | config LEDS_TRIGGER_BACKLIGHT | 350 | config LEDS_TRIGGER_BACKLIGHT |
342 | tristate "LED backlight Trigger" | 351 | tristate "LED backlight Trigger" |
343 | help | 352 | help |
344 | This allows LEDs to be controlled as a backlight device: they | 353 | This allows LEDs to be controlled as a backlight device: they |
345 | turn off and on when the display is blanked and unblanked. | 354 | turn off and on when the display is blanked and unblanked. |
346 | 355 | ||
347 | If unsure, say N. | 356 | If unsure, say N. |
348 | 357 | ||
349 | config LEDS_TRIGGER_GPIO | 358 | config LEDS_TRIGGER_GPIO |
350 | tristate "LED GPIO Trigger" | 359 | tristate "LED GPIO Trigger" |
351 | depends on GPIOLIB | 360 | depends on GPIOLIB |
352 | help | 361 | help |
353 | This allows LEDs to be controlled by gpio events. It's good | 362 | This allows LEDs to be controlled by gpio events. It's good |
354 | when using gpios as switches and triggering the needed LEDs | 363 | when using gpios as switches and triggering the needed LEDs |
355 | from there. One use case is n810's keypad LEDs that could | 364 | from there. One use case is n810's keypad LEDs that could |
356 | be triggered by this trigger when user slides up to show | 365 | be triggered by this trigger when user slides up to show |
357 | keypad. | 366 | keypad. |
358 | 367 | ||
359 | If unsure, say N. | 368 | If unsure, say N. |
360 | 369 | ||
361 | config LEDS_TRIGGER_DEFAULT_ON | 370 | config LEDS_TRIGGER_DEFAULT_ON |
362 | tristate "LED Default ON Trigger" | 371 | tristate "LED Default ON Trigger" |
363 | help | 372 | help |
364 | This allows LEDs to be initialised in the ON state. | 373 | This allows LEDs to be initialised in the ON state. |
365 | If unsure, say Y. | 374 | If unsure, say Y. |
366 | 375 | ||
367 | comment "iptables trigger is under Netfilter config (LED target)" | 376 | comment "iptables trigger is under Netfilter config (LED target)" |
368 | depends on LEDS_TRIGGERS | 377 | depends on LEDS_TRIGGERS |
369 | 378 | ||
370 | endif # LEDS_TRIGGERS | 379 | endif # LEDS_TRIGGERS |
371 | 380 | ||
372 | endif # LEDS_CLASS | 381 | endif # LEDS_CLASS |
373 | 382 | ||
374 | endif # NEW_LEDS | 383 | endif # NEW_LEDS |
375 | 384 |
drivers/leds/Makefile
1 | 1 | ||
2 | # LED Core | 2 | # LED Core |
3 | obj-$(CONFIG_NEW_LEDS) += led-core.o | 3 | obj-$(CONFIG_NEW_LEDS) += led-core.o |
4 | obj-$(CONFIG_LEDS_CLASS) += led-class.o | 4 | obj-$(CONFIG_LEDS_CLASS) += led-class.o |
5 | obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o | 5 | obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o |
6 | 6 | ||
7 | # LED Platform Drivers | 7 | # LED Platform Drivers |
8 | obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o | 8 | obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o |
9 | obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o | 9 | obj-$(CONFIG_LEDS_ATMEL_PWM) += leds-atmel-pwm.o |
10 | obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o | 10 | obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o |
11 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o | 11 | obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o |
12 | obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o | 12 | obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o |
13 | obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o | 13 | obj-$(CONFIG_LEDS_S3C24XX) += leds-s3c24xx.o |
14 | obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o | 14 | obj-$(CONFIG_LEDS_AMS_DELTA) += leds-ams-delta.o |
15 | obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o | 15 | obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o |
16 | obj-$(CONFIG_LEDS_NET5501) += leds-net5501.o | 16 | obj-$(CONFIG_LEDS_NET5501) += leds-net5501.o |
17 | obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o | 17 | obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o |
18 | obj-$(CONFIG_LEDS_ALIX2) += leds-alix2.o | 18 | obj-$(CONFIG_LEDS_ALIX2) += leds-alix2.o |
19 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o | 19 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o |
20 | obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o | 20 | obj-$(CONFIG_LEDS_COBALT_QUBE) += leds-cobalt-qube.o |
21 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o | 21 | obj-$(CONFIG_LEDS_COBALT_RAQ) += leds-cobalt-raq.o |
22 | obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o | 22 | obj-$(CONFIG_LEDS_SUNFIRE) += leds-sunfire.o |
23 | obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o | 23 | obj-$(CONFIG_LEDS_PCA9532) += leds-pca9532.o |
24 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o | 24 | obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o |
25 | obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o | 25 | obj-$(CONFIG_LEDS_LP3944) += leds-lp3944.o |
26 | obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o | 26 | obj-$(CONFIG_LEDS_CLEVO_MAIL) += leds-clevo-mail.o |
27 | obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o | 27 | obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o |
28 | obj-$(CONFIG_LEDS_FSG) += leds-fsg.o | 28 | obj-$(CONFIG_LEDS_FSG) += leds-fsg.o |
29 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o | 29 | obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o |
30 | obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o | 30 | obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o |
31 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o | 31 | obj-$(CONFIG_LEDS_WM831X_STATUS) += leds-wm831x-status.o |
32 | obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o | 32 | obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o |
33 | obj-$(CONFIG_LEDS_PWM) += leds-pwm.o | 33 | obj-$(CONFIG_LEDS_PWM) += leds-pwm.o |
34 | obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o | 34 | obj-$(CONFIG_LEDS_REGULATOR) += leds-regulator.o |
35 | obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o | 35 | obj-$(CONFIG_LEDS_INTEL_SS4200) += leds-ss4200.o |
36 | obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o | 36 | obj-$(CONFIG_LEDS_LT3593) += leds-lt3593.o |
37 | obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o | 37 | obj-$(CONFIG_LEDS_ADP5520) += leds-adp5520.o |
38 | obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o | 38 | obj-$(CONFIG_LEDS_DELL_NETBOOKS) += dell-led.o |
39 | obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o | 39 | obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o |
40 | obj-$(CONFIG_LEDS_NS2) += leds-ns2.o | ||
40 | 41 | ||
41 | # LED SPI Drivers | 42 | # LED SPI Drivers |
42 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o | 43 | obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o |
43 | 44 | ||
44 | # LED Triggers | 45 | # LED Triggers |
45 | obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o | 46 | obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o |
46 | obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o | 47 | obj-$(CONFIG_LEDS_TRIGGER_IDE_DISK) += ledtrig-ide-disk.o |
47 | obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o | 48 | obj-$(CONFIG_LEDS_TRIGGER_HEARTBEAT) += ledtrig-heartbeat.o |
48 | obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o | 49 | obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o |
49 | obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o | 50 | obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o |
50 | obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o | 51 | obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o |
51 | 52 |
drivers/leds/leds-ns2.c
File was created | 1 | /* | |
2 | * leds-ns2.c - Driver for the Network Space v2 (and parents) dual-GPIO LED | ||
3 | * | ||
4 | * Copyright (C) 2010 LaCie | ||
5 | * | ||
6 | * Author: Simon Guinot <sguinot@lacie.com> | ||
7 | * | ||
8 | * Based on leds-gpio.c by Raphael Assenat <raph@8d.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, write to the Free Software | ||
22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
23 | */ | ||
24 | |||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/init.h> | ||
27 | #include <linux/platform_device.h> | ||
28 | #include <linux/slab.h> | ||
29 | #include <linux/gpio.h> | ||
30 | #include <linux/leds.h> | ||
31 | #include <mach/leds-ns2.h> | ||
32 | |||
33 | /* | ||
34 | * The Network Space v2 dual-GPIO LED is wired to a CPLD and can blink in | ||
35 | * relation with the SATA activity. This capability is exposed through the | ||
36 | * "sata" sysfs attribute. | ||
37 | * | ||
38 | * The following array detail the different LED registers and the combination | ||
39 | * of their possible values: | ||
40 | * | ||
41 | * cmd_led | slow_led | /SATA active | LED state | ||
42 | * | | | | ||
43 | * 1 | 0 | x | off | ||
44 | * - | 1 | x | on | ||
45 | * 0 | 0 | 1 | on | ||
46 | * 0 | 0 | 0 | blink (rate 300ms) | ||
47 | */ | ||
48 | |||
49 | enum ns2_led_modes { | ||
50 | NS_V2_LED_OFF, | ||
51 | NS_V2_LED_ON, | ||
52 | NS_V2_LED_SATA, | ||
53 | }; | ||
54 | |||
55 | struct ns2_led_mode_value { | ||
56 | enum ns2_led_modes mode; | ||
57 | int cmd_level; | ||
58 | int slow_level; | ||
59 | }; | ||
60 | |||
61 | static struct ns2_led_mode_value ns2_led_modval[] = { | ||
62 | { NS_V2_LED_OFF , 1, 0 }, | ||
63 | { NS_V2_LED_ON , 0, 1 }, | ||
64 | { NS_V2_LED_ON , 1, 1 }, | ||
65 | { NS_V2_LED_SATA, 0, 0 }, | ||
66 | }; | ||
67 | |||
68 | struct ns2_led_data { | ||
69 | struct led_classdev cdev; | ||
70 | unsigned cmd; | ||
71 | unsigned slow; | ||
72 | unsigned char sata; /* True when SATA mode active. */ | ||
73 | rwlock_t rw_lock; /* Lock GPIOs. */ | ||
74 | }; | ||
75 | |||
76 | static int ns2_led_get_mode(struct ns2_led_data *led_dat, | ||
77 | enum ns2_led_modes *mode) | ||
78 | { | ||
79 | int i; | ||
80 | int ret = -EINVAL; | ||
81 | int cmd_level; | ||
82 | int slow_level; | ||
83 | |||
84 | read_lock(&led_dat->rw_lock); | ||
85 | |||
86 | cmd_level = gpio_get_value(led_dat->cmd); | ||
87 | slow_level = gpio_get_value(led_dat->slow); | ||
88 | |||
89 | for (i = 0; i < ARRAY_SIZE(ns2_led_modval); i++) { | ||
90 | if (cmd_level == ns2_led_modval[i].cmd_level && | ||
91 | slow_level == ns2_led_modval[i].slow_level) { | ||
92 | *mode = ns2_led_modval[i].mode; | ||
93 | ret = 0; | ||
94 | break; | ||
95 | } | ||
96 | } | ||
97 | |||
98 | read_unlock(&led_dat->rw_lock); | ||
99 | |||
100 | return ret; | ||
101 | } | ||
102 | |||
103 | static void ns2_led_set_mode(struct ns2_led_data *led_dat, | ||
104 | enum ns2_led_modes mode) | ||
105 | { | ||
106 | int i; | ||
107 | |||
108 | write_lock(&led_dat->rw_lock); | ||
109 | |||
110 | for (i = 0; i < ARRAY_SIZE(ns2_led_modval); i++) { | ||
111 | if (mode == ns2_led_modval[i].mode) { | ||
112 | gpio_set_value(led_dat->cmd, | ||
113 | ns2_led_modval[i].cmd_level); | ||
114 | gpio_set_value(led_dat->slow, | ||
115 | ns2_led_modval[i].slow_level); | ||
116 | } | ||
117 | } | ||
118 | |||
119 | write_unlock(&led_dat->rw_lock); | ||
120 | } | ||
121 | |||
122 | static void ns2_led_set(struct led_classdev *led_cdev, | ||
123 | enum led_brightness value) | ||
124 | { | ||
125 | struct ns2_led_data *led_dat = | ||
126 | container_of(led_cdev, struct ns2_led_data, cdev); | ||
127 | enum ns2_led_modes mode; | ||
128 | |||
129 | if (value == LED_OFF) | ||
130 | mode = NS_V2_LED_OFF; | ||
131 | else if (led_dat->sata) | ||
132 | mode = NS_V2_LED_SATA; | ||
133 | else | ||
134 | mode = NS_V2_LED_ON; | ||
135 | |||
136 | ns2_led_set_mode(led_dat, mode); | ||
137 | } | ||
138 | |||
139 | static ssize_t ns2_led_sata_store(struct device *dev, | ||
140 | struct device_attribute *attr, | ||
141 | const char *buff, size_t count) | ||
142 | { | ||
143 | int ret; | ||
144 | unsigned long enable; | ||
145 | enum ns2_led_modes mode; | ||
146 | struct ns2_led_data *led_dat = dev_get_drvdata(dev); | ||
147 | |||
148 | ret = strict_strtoul(buff, 10, &enable); | ||
149 | if (ret < 0) | ||
150 | return ret; | ||
151 | |||
152 | enable = !!enable; | ||
153 | |||
154 | if (led_dat->sata == enable) | ||
155 | return count; | ||
156 | |||
157 | ret = ns2_led_get_mode(led_dat, &mode); | ||
158 | if (ret < 0) | ||
159 | return ret; | ||
160 | |||
161 | if (enable && mode == NS_V2_LED_ON) | ||
162 | ns2_led_set_mode(led_dat, NS_V2_LED_SATA); | ||
163 | if (!enable && mode == NS_V2_LED_SATA) | ||
164 | ns2_led_set_mode(led_dat, NS_V2_LED_ON); | ||
165 | |||
166 | led_dat->sata = enable; | ||
167 | |||
168 | return count; | ||
169 | } | ||
170 | |||
171 | static ssize_t ns2_led_sata_show(struct device *dev, | ||
172 | struct device_attribute *attr, char *buf) | ||
173 | { | ||
174 | struct ns2_led_data *led_dat = dev_get_drvdata(dev); | ||
175 | |||
176 | return sprintf(buf, "%d\n", led_dat->sata); | ||
177 | } | ||
178 | |||
179 | static DEVICE_ATTR(sata, 0644, ns2_led_sata_show, ns2_led_sata_store); | ||
180 | |||
181 | static int __devinit | ||
182 | create_ns2_led(struct platform_device *pdev, struct ns2_led_data *led_dat, | ||
183 | const struct ns2_led *template) | ||
184 | { | ||
185 | int ret; | ||
186 | enum ns2_led_modes mode; | ||
187 | |||
188 | ret = gpio_request(template->cmd, template->name); | ||
189 | if (ret == 0) { | ||
190 | ret = gpio_direction_output(template->cmd, | ||
191 | gpio_get_value(template->cmd)); | ||
192 | if (ret) | ||
193 | gpio_free(template->cmd); | ||
194 | } | ||
195 | if (ret) { | ||
196 | dev_err(&pdev->dev, "%s: failed to setup command GPIO\n", | ||
197 | template->name); | ||
198 | } | ||
199 | |||
200 | ret = gpio_request(template->slow, template->name); | ||
201 | if (ret == 0) { | ||
202 | ret = gpio_direction_output(template->slow, | ||
203 | gpio_get_value(template->slow)); | ||
204 | if (ret) | ||
205 | gpio_free(template->slow); | ||
206 | } | ||
207 | if (ret) { | ||
208 | dev_err(&pdev->dev, "%s: failed to setup slow GPIO\n", | ||
209 | template->name); | ||
210 | goto err_free_cmd; | ||
211 | } | ||
212 | |||
213 | rwlock_init(&led_dat->rw_lock); | ||
214 | |||
215 | led_dat->cdev.name = template->name; | ||
216 | led_dat->cdev.default_trigger = template->default_trigger; | ||
217 | led_dat->cdev.blink_set = NULL; | ||
218 | led_dat->cdev.brightness_set = ns2_led_set; | ||
219 | led_dat->cdev.flags |= LED_CORE_SUSPENDRESUME; | ||
220 | led_dat->cmd = template->cmd; | ||
221 | led_dat->slow = template->slow; | ||
222 | |||
223 | ret = ns2_led_get_mode(led_dat, &mode); | ||
224 | if (ret < 0) | ||
225 | goto err_free_slow; | ||
226 | |||
227 | /* Set LED initial state. */ | ||
228 | led_dat->sata = (mode == NS_V2_LED_SATA) ? 1 : 0; | ||
229 | led_dat->cdev.brightness = | ||
230 | (mode == NS_V2_LED_OFF) ? LED_OFF : LED_FULL; | ||
231 | |||
232 | ret = led_classdev_register(&pdev->dev, &led_dat->cdev); | ||
233 | if (ret < 0) | ||
234 | goto err_free_slow; | ||
235 | |||
236 | dev_set_drvdata(led_dat->cdev.dev, led_dat); | ||
237 | ret = device_create_file(led_dat->cdev.dev, &dev_attr_sata); | ||
238 | if (ret < 0) | ||
239 | goto err_free_cdev; | ||
240 | |||
241 | return 0; | ||
242 | |||
243 | err_free_cdev: | ||
244 | led_classdev_unregister(&led_dat->cdev); | ||
245 | err_free_slow: | ||
246 | gpio_free(led_dat->slow); | ||
247 | err_free_cmd: | ||
248 | gpio_free(led_dat->cmd); | ||
249 | |||
250 | return ret; | ||
251 | } | ||
252 | |||
253 | static void __devexit delete_ns2_led(struct ns2_led_data *led_dat) | ||
254 | { | ||
255 | device_remove_file(led_dat->cdev.dev, &dev_attr_sata); | ||
256 | led_classdev_unregister(&led_dat->cdev); | ||
257 | gpio_free(led_dat->cmd); | ||
258 | gpio_free(led_dat->slow); | ||
259 | } | ||
260 | |||
261 | static int __devinit ns2_led_probe(struct platform_device *pdev) | ||
262 | { | ||
263 | struct ns2_led_platform_data *pdata = pdev->dev.platform_data; | ||
264 | struct ns2_led_data *leds_data; | ||
265 | int i; | ||
266 | int ret; | ||
267 | |||
268 | if (!pdata) | ||
269 | return -EINVAL; | ||
270 | |||
271 | leds_data = kzalloc(sizeof(struct ns2_led_data) * | ||
272 | pdata->num_leds, GFP_KERNEL); | ||
273 | if (!leds_data) | ||
274 | return -ENOMEM; | ||
275 | |||
276 | for (i = 0; i < pdata->num_leds; i++) { | ||
277 | ret = create_ns2_led(pdev, &leds_data[i], &pdata->leds[i]); | ||
278 | if (ret < 0) | ||
279 | goto err; | ||
280 | |||
281 | } | ||
282 | |||
283 | platform_set_drvdata(pdev, leds_data); | ||
284 | |||
285 | return 0; | ||
286 | |||
287 | err: | ||
288 | for (i = i - 1; i >= 0; i--) | ||
289 | delete_ns2_led(&leds_data[i]); | ||
290 | |||
291 | kfree(leds_data); | ||
292 | |||
293 | return ret; | ||
294 | } | ||
295 | |||
296 | static int __devexit ns2_led_remove(struct platform_device *pdev) | ||
297 | { | ||
298 | int i; | ||
299 | struct ns2_led_platform_data *pdata = pdev->dev.platform_data; | ||
300 | struct ns2_led_data *leds_data; | ||
301 | |||
302 | leds_data = platform_get_drvdata(pdev); | ||
303 | |||
304 | for (i = 0; i < pdata->num_leds; i++) | ||
305 | delete_ns2_led(&leds_data[i]); | ||
306 | |||
307 | kfree(leds_data); | ||
308 | platform_set_drvdata(pdev, NULL); | ||
309 | |||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | static struct platform_driver ns2_led_driver = { | ||
314 | .probe = ns2_led_probe, | ||
315 | .remove = __devexit_p(ns2_led_remove), | ||
316 | .driver = { | ||
317 | .name = "leds-ns2", | ||
318 | .owner = THIS_MODULE, | ||
319 | }, | ||
320 | }; | ||
321 | MODULE_ALIAS("platform:leds-ns2"); | ||
322 | |||
323 | static int __init ns2_led_init(void) | ||
324 | { | ||
325 | return platform_driver_register(&ns2_led_driver); | ||
326 | } | ||
327 | |||
328 | static void __exit ns2_led_exit(void) | ||
329 | { | ||
330 | platform_driver_unregister(&ns2_led_driver); | ||
331 | } | ||
332 | |||
333 | module_init(ns2_led_init); | ||
334 | module_exit(ns2_led_exit); | ||
335 | |||
336 | MODULE_AUTHOR("Simon Guinot <sguinot@lacie.com>"); | ||
337 | MODULE_DESCRIPTION("Network Space v2 LED driver"); | ||
338 | MODULE_LICENSE("GPL"); | ||
339 |