diff options
| -rw-r--r-- | drivers/leds/Kconfig | 12 | ||||
| -rw-r--r-- | drivers/leds/Makefile | 2 | ||||
| -rw-r--r-- | drivers/leds/leds-cobalt.c | 43 | ||||
| -rw-r--r-- | drivers/leds/leds-h1940.c | 163 |
4 files changed, 220 insertions, 0 deletions
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 7399ba791116..80acd08f0e97 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig | |||
| @@ -82,6 +82,18 @@ config LEDS_WRAP | |||
| 82 | help | 82 | help |
| 83 | This option enables support for the PCEngines WRAP programmable LEDs. | 83 | This option enables support for the PCEngines WRAP programmable LEDs. |
| 84 | 84 | ||
| 85 | config LEDS_H1940 | ||
| 86 | tristate "LED Support for iPAQ H1940 device" | ||
| 87 | depends LEDS_CLASS && ARCH_H1940 | ||
| 88 | help | ||
| 89 | This option enables support for the LEDs on the h1940. | ||
| 90 | |||
| 91 | config LEDS_COBALT | ||
| 92 | tristate "LED Support for Cobalt Server front LED" | ||
| 93 | depends on LEDS_CLASS && MIPS_COBALT | ||
| 94 | help | ||
| 95 | This option enables support for the front LED on Cobalt Server | ||
| 96 | |||
| 85 | comment "LED Triggers" | 97 | comment "LED Triggers" |
| 86 | 98 | ||
| 87 | config LEDS_TRIGGERS | 99 | config LEDS_TRIGGERS |
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 500de3dc962a..aa2c18efa5b2 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile | |||
| @@ -14,6 +14,8 @@ 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_WRAP) += leds-wrap.o | 16 | obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o |
| 17 | obj-$(CONFIG_LEDS_H1940) += leds-h1940.o | ||
| 18 | obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o | ||
| 17 | 19 | ||
| 18 | # LED Triggers | 20 | # LED Triggers |
| 19 | obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o | 21 | obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o |
diff --git a/drivers/leds/leds-cobalt.c b/drivers/leds/leds-cobalt.c new file mode 100644 index 000000000000..d16439ce5da7 --- /dev/null +++ b/drivers/leds/leds-cobalt.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Copyright 2006 - Florian Fainelli <florian@openwrt.org> | ||
| 3 | * | ||
| 4 | * Control the Cobalt Qube/RaQ front LED | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <linux/module.h> | ||
| 8 | #include <linux/types.h> | ||
| 9 | #include <linux/kernel.h> | ||
| 10 | #include <linux/device.h> | ||
| 11 | #include <linux/leds.h> | ||
| 12 | #include <asm/mach-cobalt/cobalt.h> | ||
| 13 | |||
| 14 | static void cobalt_led_set(struct led_classdev *led_cdev, enum led_brightness brightness) | ||
| 15 | { | ||
| 16 | if (brightness) | ||
| 17 | COBALT_LED_PORT = COBALT_LED_BAR_LEFT | COBALT_LED_BAR_RIGHT; | ||
| 18 | else | ||
| 19 | COBALT_LED_PORT = 0; | ||
| 20 | } | ||
| 21 | |||
| 22 | static struct led_classdev cobalt_led = { | ||
| 23 | .name = "cobalt-front-led", | ||
| 24 | .brightness_set = cobalt_led_set, | ||
| 25 | .default_trigger = "ide-disk", | ||
| 26 | }; | ||
| 27 | |||
| 28 | static int __init cobalt_led_init(void) | ||
| 29 | { | ||
| 30 | return led_classdev_register(NULL, &cobalt_led); | ||
| 31 | } | ||
| 32 | |||
| 33 | static void __exit cobalt_led_exit(void) | ||
| 34 | { | ||
| 35 | led_classdev_unregister(&cobalt_led); | ||
| 36 | } | ||
| 37 | |||
| 38 | module_init(cobalt_led_init); | ||
| 39 | module_exit(cobalt_led_exit); | ||
| 40 | |||
| 41 | MODULE_LICENSE("GPL"); | ||
| 42 | MODULE_DESCRIPTION("Front LED support for Cobalt Server"); | ||
| 43 | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); | ||
diff --git a/drivers/leds/leds-h1940.c b/drivers/leds/leds-h1940.c new file mode 100644 index 000000000000..1d49d2ade557 --- /dev/null +++ b/drivers/leds/leds-h1940.c | |||
| @@ -0,0 +1,163 @@ | |||
| 1 | /* | ||
| 2 | * drivers/leds/h1940-leds.c | ||
| 3 | * Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org> | ||
| 4 | * | ||
| 5 | * This file is subject to the terms and conditions of the GNU General Public | ||
| 6 | * License. See the file COPYING in the main directory of this archive for | ||
| 7 | * more details. | ||
| 8 | * | ||
| 9 | * H1940 leds driver | ||
| 10 | * | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/module.h> | ||
| 14 | #include <linux/platform_device.h> | ||
| 15 | #include <linux/delay.h> | ||
| 16 | #include <linux/string.h> | ||
| 17 | #include <linux/ctype.h> | ||
| 18 | #include <linux/leds.h> | ||
| 19 | #include <asm/arch/regs-gpio.h> | ||
| 20 | #include <asm/hardware.h> | ||
| 21 | #include <asm/arch/h1940-latch.h> | ||
| 22 | |||
| 23 | /* | ||
| 24 | * Green led. | ||
| 25 | */ | ||
| 26 | void h1940_greenled_set(struct led_classdev *led_dev, enum led_brightness value) | ||
| 27 | { | ||
| 28 | switch (value) { | ||
| 29 | case LED_HALF: | ||
| 30 | h1940_latch_control(0,H1940_LATCH_LED_FLASH); | ||
| 31 | s3c2410_gpio_setpin(S3C2410_GPA7,1); | ||
| 32 | break; | ||
| 33 | case LED_FULL: | ||
| 34 | h1940_latch_control(0,H1940_LATCH_LED_GREEN); | ||
| 35 | s3c2410_gpio_setpin(S3C2410_GPA7,1); | ||
| 36 | break; | ||
| 37 | default: | ||
| 38 | case LED_OFF: | ||
| 39 | h1940_latch_control(H1940_LATCH_LED_FLASH,0); | ||
| 40 | h1940_latch_control(H1940_LATCH_LED_GREEN,0); | ||
| 41 | s3c2410_gpio_setpin(S3C2410_GPA7,0); | ||
| 42 | break; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | static struct led_classdev h1940_greenled = { | ||
| 47 | .name = "h1940:green", | ||
| 48 | .brightness_set = h1940_greenled_set, | ||
| 49 | .default_trigger = "h1940-charger", | ||
| 50 | }; | ||
| 51 | |||
| 52 | /* | ||
| 53 | * Red led. | ||
| 54 | */ | ||
| 55 | void h1940_redled_set(struct led_classdev *led_dev, enum led_brightness value) | ||
| 56 | { | ||
| 57 | switch (value) { | ||
| 58 | case LED_HALF: | ||
| 59 | h1940_latch_control(0,H1940_LATCH_LED_FLASH); | ||
| 60 | s3c2410_gpio_setpin(S3C2410_GPA1,1); | ||
| 61 | break; | ||
| 62 | case LED_FULL: | ||
| 63 | h1940_latch_control(0,H1940_LATCH_LED_RED); | ||
| 64 | s3c2410_gpio_setpin(S3C2410_GPA1,1); | ||
| 65 | break; | ||
| 66 | default: | ||
| 67 | case LED_OFF: | ||
| 68 | h1940_latch_control(H1940_LATCH_LED_FLASH,0); | ||
| 69 | h1940_latch_control(H1940_LATCH_LED_RED,0); | ||
| 70 | s3c2410_gpio_setpin(S3C2410_GPA1,0); | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | static struct led_classdev h1940_redled = { | ||
| 76 | .name = "h1940:red", | ||
| 77 | .brightness_set = h1940_redled_set, | ||
| 78 | .default_trigger = "h1940-charger", | ||
| 79 | }; | ||
| 80 | |||
| 81 | /* | ||
| 82 | * Blue led. | ||
| 83 | * (it can only be blue flashing led) | ||
| 84 | */ | ||
| 85 | void h1940_blueled_set(struct led_classdev *led_dev, enum led_brightness value) | ||
| 86 | { | ||
| 87 | if (value) { | ||
| 88 | /* flashing Blue */ | ||
| 89 | h1940_latch_control(0,H1940_LATCH_LED_FLASH); | ||
| 90 | s3c2410_gpio_setpin(S3C2410_GPA3,1); | ||
| 91 | } else { | ||
| 92 | h1940_latch_control(H1940_LATCH_LED_FLASH,0); | ||
| 93 | s3c2410_gpio_setpin(S3C2410_GPA3,0); | ||
| 94 | } | ||
| 95 | |||
| 96 | } | ||
| 97 | |||
| 98 | static struct led_classdev h1940_blueled = { | ||
| 99 | .name = "h1940:blue", | ||
| 100 | .brightness_set = h1940_blueled_set, | ||
| 101 | .default_trigger = "h1940-bluetooth", | ||
| 102 | }; | ||
| 103 | |||
| 104 | static int __init h1940leds_probe(struct platform_device *pdev) | ||
| 105 | { | ||
| 106 | int ret; | ||
| 107 | |||
| 108 | ret = led_classdev_register(&pdev->dev, &h1940_greenled); | ||
| 109 | if (ret) | ||
| 110 | goto err_green; | ||
| 111 | |||
| 112 | ret = led_classdev_register(&pdev->dev, &h1940_redled); | ||
| 113 | if (ret) | ||
| 114 | goto err_red; | ||
| 115 | |||
| 116 | ret = led_classdev_register(&pdev->dev, &h1940_blueled); | ||
| 117 | if (ret) | ||
| 118 | goto err_blue; | ||
| 119 | |||
| 120 | return 0; | ||
| 121 | |||
| 122 | err_blue: | ||
| 123 | led_classdev_unregister(&h1940_redled); | ||
| 124 | err_red: | ||
| 125 | led_classdev_unregister(&h1940_greenled); | ||
| 126 | err_green: | ||
| 127 | return ret; | ||
| 128 | } | ||
| 129 | |||
| 130 | static int h1940leds_remove(struct platform_device *pdev) | ||
| 131 | { | ||
| 132 | led_classdev_unregister(&h1940_greenled); | ||
| 133 | led_classdev_unregister(&h1940_redled); | ||
| 134 | led_classdev_unregister(&h1940_blueled); | ||
| 135 | return 0; | ||
| 136 | } | ||
| 137 | |||
| 138 | |||
| 139 | static struct platform_driver h1940leds_driver = { | ||
| 140 | .driver = { | ||
| 141 | .name = "h1940-leds", | ||
| 142 | }, | ||
| 143 | .probe = h1940leds_probe, | ||
| 144 | .remove = h1940leds_remove, | ||
| 145 | }; | ||
| 146 | |||
| 147 | |||
| 148 | static int __init h1940leds_init(void) | ||
| 149 | { | ||
| 150 | return platform_driver_register(&h1940leds_driver); | ||
| 151 | } | ||
| 152 | |||
| 153 | static void __exit h1940leds_exit(void) | ||
| 154 | { | ||
| 155 | platform_driver_unregister(&h1940leds_driver); | ||
| 156 | } | ||
| 157 | |||
| 158 | module_init(h1940leds_init); | ||
| 159 | module_exit(h1940leds_exit); | ||
| 160 | |||
| 161 | MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); | ||
| 162 | MODULE_DESCRIPTION("LED driver for the iPAQ H1940"); | ||
| 163 | MODULE_LICENSE("GPL"); | ||
