diff options
Diffstat (limited to 'arch/arm/mach-pxa/idp.c')
-rw-r--r-- | arch/arm/mach-pxa/idp.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/idp.c b/arch/arm/mach-pxa/idp.c index 6ff466bd43e8..ae1e9977603e 100644 --- a/arch/arm/mach-pxa/idp.c +++ b/arch/arm/mach-pxa/idp.c | |||
@@ -191,6 +191,87 @@ static void __init idp_map_io(void) | |||
191 | iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc)); | 191 | iotable_init(idp_io_desc, ARRAY_SIZE(idp_io_desc)); |
192 | } | 192 | } |
193 | 193 | ||
194 | /* LEDs */ | ||
195 | #if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) | ||
196 | struct idp_led { | ||
197 | struct led_classdev cdev; | ||
198 | u8 mask; | ||
199 | }; | ||
200 | |||
201 | /* | ||
202 | * The triggers lines up below will only be used if the | ||
203 | * LED triggers are compiled in. | ||
204 | */ | ||
205 | static const struct { | ||
206 | const char *name; | ||
207 | const char *trigger; | ||
208 | } idp_leds[] = { | ||
209 | { "idp:green", "heartbeat", }, | ||
210 | { "idp:red", "cpu0", }, | ||
211 | }; | ||
212 | |||
213 | static void idp_led_set(struct led_classdev *cdev, | ||
214 | enum led_brightness b) | ||
215 | { | ||
216 | struct idp_led *led = container_of(cdev, | ||
217 | struct idp_led, cdev); | ||
218 | u32 reg = IDP_CPLD_LED_CONTROL; | ||
219 | |||
220 | if (b != LED_OFF) | ||
221 | reg &= ~led->mask; | ||
222 | else | ||
223 | reg |= led->mask; | ||
224 | |||
225 | IDP_CPLD_LED_CONTROL = reg; | ||
226 | } | ||
227 | |||
228 | static enum led_brightness idp_led_get(struct led_classdev *cdev) | ||
229 | { | ||
230 | struct idp_led *led = container_of(cdev, | ||
231 | struct idp_led, cdev); | ||
232 | |||
233 | return (IDP_CPLD_LED_CONTROL & led->mask) ? LED_OFF : LED_FULL; | ||
234 | } | ||
235 | |||
236 | static int __init idp_leds_init(void) | ||
237 | { | ||
238 | int i; | ||
239 | |||
240 | if (!machine_is_pxa_idp()) | ||
241 | return -ENODEV; | ||
242 | |||
243 | for (i = 0; i < ARRAY_SIZE(idp_leds); i++) { | ||
244 | struct idp_led *led; | ||
245 | |||
246 | led = kzalloc(sizeof(*led), GFP_KERNEL); | ||
247 | if (!led) | ||
248 | break; | ||
249 | |||
250 | led->cdev.name = idp_leds[i].name; | ||
251 | led->cdev.brightness_set = idp_led_set; | ||
252 | led->cdev.brightness_get = idp_led_get; | ||
253 | led->cdev.default_trigger = idp_leds[i].trigger; | ||
254 | |||
255 | if (i == 0) | ||
256 | led->mask = IDP_HB_LED; | ||
257 | else | ||
258 | led->mask = IDP_BUSY_LED; | ||
259 | |||
260 | if (led_classdev_register(NULL, &led->cdev) < 0) { | ||
261 | kfree(led); | ||
262 | break; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | return 0; | ||
267 | } | ||
268 | |||
269 | /* | ||
270 | * Since we may have triggers on any subsystem, defer registration | ||
271 | * until after subsystem_init. | ||
272 | */ | ||
273 | fs_initcall(idp_leds_init); | ||
274 | #endif | ||
194 | 275 | ||
195 | MACHINE_START(PXA_IDP, "Vibren PXA255 IDP") | 276 | MACHINE_START(PXA_IDP, "Vibren PXA255 IDP") |
196 | /* Maintainer: Vibren Technologies */ | 277 | /* Maintainer: Vibren Technologies */ |