Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 1 | /* |
| 2 | * LEDs driver for the "User LED" on Routerboard532 |
| 3 | * |
| 4 | * Copyright (C) 2009 Phil Sutter <n0-1@freewrt.org> |
| 5 | * |
| 6 | * Based on leds-cobalt-qube.c by Florian Fainelly and |
| 7 | * rb-diag.c (my own standalone driver for both LED and |
| 8 | * button of Routerboard532). |
| 9 | */ |
| 10 | |
| 11 | #include <linux/leds.h> |
| 12 | #include <linux/module.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | |
| 15 | #include <asm/mach-rc32434/gpio.h> |
| 16 | #include <asm/mach-rc32434/rb.h> |
| 17 | |
| 18 | static void rb532_led_set(struct led_classdev *cdev, |
Sachin Kamat | 7a0eff4 | 2012-11-27 20:38:09 -0800 | [diff] [blame] | 19 | enum led_brightness brightness) |
Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 20 | { |
| 21 | if (brightness) |
| 22 | set_latch_u5(LO_ULED, 0); |
| 23 | |
| 24 | else |
| 25 | set_latch_u5(0, LO_ULED); |
| 26 | } |
| 27 | |
| 28 | static enum led_brightness rb532_led_get(struct led_classdev *cdev) |
| 29 | { |
| 30 | return (get_latch_u5() & LO_ULED) ? LED_FULL : LED_OFF; |
| 31 | } |
| 32 | |
| 33 | static struct led_classdev rb532_uled = { |
| 34 | .name = "uled", |
| 35 | .brightness_set = rb532_led_set, |
| 36 | .brightness_get = rb532_led_get, |
| 37 | .default_trigger = "nand-disk", |
| 38 | }; |
| 39 | |
Bill Pemberton | 98ea1ea | 2012-11-19 13:23:02 -0500 | [diff] [blame] | 40 | static int rb532_led_probe(struct platform_device *pdev) |
Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 41 | { |
| 42 | return led_classdev_register(&pdev->dev, &rb532_uled); |
| 43 | } |
| 44 | |
Bill Pemberton | 678e8a6 | 2012-11-19 13:26:00 -0500 | [diff] [blame] | 45 | static int rb532_led_remove(struct platform_device *pdev) |
Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 46 | { |
| 47 | led_classdev_unregister(&rb532_uled); |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | static struct platform_driver rb532_led_driver = { |
| 52 | .probe = rb532_led_probe, |
Bill Pemberton | df07cf8 | 2012-11-19 13:20:20 -0500 | [diff] [blame] | 53 | .remove = rb532_led_remove, |
Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 54 | .driver = { |
| 55 | .name = "rb532-led", |
Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 56 | }, |
| 57 | }; |
| 58 | |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 59 | module_platform_driver(rb532_led_driver); |
Phil Sutter | ac67e23 | 2009-01-22 19:35:48 +0100 | [diff] [blame] | 60 | |
| 61 | MODULE_LICENSE("GPL"); |
| 62 | MODULE_DESCRIPTION("User LED support for Routerboard532"); |
| 63 | MODULE_AUTHOR("Phil Sutter <n0-1@freewrt.org>"); |
Axel Lin | 892a884 | 2012-01-10 15:09:24 -0800 | [diff] [blame] | 64 | MODULE_ALIAS("platform:rb532-led"); |