1 Index: linux-2.6.30.8/drivers/leds/Kconfig
2 ===================================================================
3 --- linux-2.6.30.8.orig/drivers/leds/Kconfig 2009-10-19 21:31:31.000000000 +0200
4 +++ linux-2.6.30.8/drivers/leds/Kconfig 2009-10-19 21:31:32.000000000 +0200
6 This option enables support for BD2802GU RGB LED driver chips
7 accessed via the I2C bus.
10 + tristate "LED Support for IFXMIPS LEDs"
11 + depends on LEDS_CLASS && IFXMIPS
13 + This option enables support for the CM-X270 LEDs.
15 comment "LED Triggers"
18 Index: linux-2.6.30.8/drivers/leds/Makefile
19 ===================================================================
20 --- linux-2.6.30.8.orig/drivers/leds/Makefile 2009-10-19 21:31:31.000000000 +0200
21 +++ linux-2.6.30.8/drivers/leds/Makefile 2009-10-19 21:31:32.000000000 +0200
23 obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
24 obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o
25 obj-$(CONFIG_LEDS_PWM) += leds-pwm.o
26 +obj-$(CONFIG_LEDS_IFXMIPS) += leds-ifxmips.o
29 obj-$(CONFIG_LEDS_DAC124S085) += leds-dac124s085.o
30 Index: linux-2.6.30.8/drivers/leds/leds-ifxmips.c
31 ===================================================================
32 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
33 +++ linux-2.6.30.8/drivers/leds/leds-ifxmips.c 2009-10-19 21:39:59.000000000 +0200
36 + * This program is free software; you can redistribute it and/or modify
37 + * it under the terms of the GNU General Public License as published by
38 + * the Free Software Foundation; either version 2 of the License, or
39 + * (at your option) any later version.
41 + * This program is distributed in the hope that it will be useful,
42 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 + * GNU General Public License for more details.
46 + * You should have received a copy of the GNU General Public License
47 + * along with this program; if not, write to the Free Software
48 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
50 + * Copyright (C) 2006 infineon
51 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
55 +#include <linux/kernel.h>
56 +#include <linux/module.h>
57 +#include <linux/version.h>
58 +#include <linux/types.h>
59 +#include <linux/fs.h>
60 +#include <linux/init.h>
61 +#include <linux/platform_device.h>
62 +#include <linux/uaccess.h>
63 +#include <linux/unistd.h>
64 +#include <linux/errno.h>
65 +#include <linux/leds.h>
66 +#include <linux/delay.h>
69 +#include <ifxmips_gpio.h>
70 +#include <ifxmips_pmu.h>
72 +#define DRVNAME "ifxmips_led"
74 +/* might need to be changed depending on shift register used on the pcb */
76 +#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING
78 +#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING
81 +#define IFXMIPS_LED_SPEED IFXMIPS_LED_8HZ
83 +#define IFXMIPS_LED_GPIO_PORT 0
85 +#define IFXMIPS_MAX_LED 24
88 + struct led_classdev cdev;
92 +void ifxmips_led_set(unsigned int led)
95 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) | led, IFXMIPS_LED_CPU0);
97 +EXPORT_SYMBOL(ifxmips_led_set);
99 +void ifxmips_led_clear(unsigned int led)
101 + led = ~(led & 0xffffff);
102 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) & led, IFXMIPS_LED_CPU0);
104 +EXPORT_SYMBOL(ifxmips_led_clear);
106 +void ifxmips_led_blink_set(unsigned int led)
109 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | led, IFXMIPS_LED_CON0);
111 +EXPORT_SYMBOL(ifxmips_led_blink_set);
113 +void ifxmips_led_blink_clear(unsigned int led)
115 + led = ~(led & 0xffffff);
116 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & led, IFXMIPS_LED_CON0);
118 +EXPORT_SYMBOL(ifxmips_led_blink_clear);
120 +static void ifxmips_ledapi_set(struct led_classdev *led_cdev,
121 + enum led_brightness value)
123 + struct ifxmips_led *led_dev =
124 + container_of(led_cdev, struct ifxmips_led, cdev);
127 + ifxmips_led_set(1 << led_dev->bit);
129 + ifxmips_led_clear(1 << led_dev->bit);
132 +void ifxmips_led_setup_gpio(void)
136 + /* leds are controlled via a shift register
137 + we need to setup pins SH,D,ST (4,5,6) to make it work */
138 + for (i = 4; i < 7; i++) {
139 + ifxmips_port_set_altsel0(IFXMIPS_LED_GPIO_PORT, i);
140 + ifxmips_port_clear_altsel1(IFXMIPS_LED_GPIO_PORT, i);
141 + ifxmips_port_set_dir_out(IFXMIPS_LED_GPIO_PORT, i);
142 + ifxmips_port_set_open_drain(IFXMIPS_LED_GPIO_PORT, i);
146 +static int ifxmips_led_probe(struct platform_device *dev)
150 + ifxmips_led_setup_gpio();
152 + ifxmips_w32(0, IFXMIPS_LED_AR);
153 + ifxmips_w32(0, IFXMIPS_LED_CPU0);
154 + ifxmips_w32(0, IFXMIPS_LED_CPU1);
155 + ifxmips_w32(LED_CON0_SWU, IFXMIPS_LED_CON0);
156 + ifxmips_w32(0, IFXMIPS_LED_CON1);
158 + /* setup the clock edge that the shift register is triggered on */
159 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & ~IFXMIPS_LED_EDGE_MASK,
161 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_CLK_EDGE,
164 + /* per default leds 15-0 are set */
165 + ifxmips_w32(IFXMIPS_LED_GROUP1 | IFXMIPS_LED_GROUP0, IFXMIPS_LED_CON1);
167 + /* leds are update periodically by the FPID */
168 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_UPD_MASK,
170 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_UPD_SRC_FPI,
173 + /* set led update speed */
174 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_MASK,
176 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_SPEED,
179 + /* adsl 0 and 1 leds are updated by the arc */
180 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_ADSL_SRC,
183 + /* per default, the leds are turned on */
184 + ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED);
186 + for (i = 0; i < IFXMIPS_MAX_LED; i++) {
187 + struct ifxmips_led *tmp =
188 + kzalloc(sizeof(struct ifxmips_led), GFP_KERNEL);
189 + tmp->cdev.brightness_set = ifxmips_ledapi_set;
190 + tmp->cdev.name = kmalloc(sizeof("ifxmips:led:00"), GFP_KERNEL);
191 + sprintf((char *)tmp->cdev.name, "ifxmips:led:%02d", i);
192 + tmp->cdev.default_trigger = NULL;
194 + led_classdev_register(&dev->dev, &tmp->cdev);
200 +static int ifxmips_led_remove(struct platform_device *pdev)
205 +static struct platform_driver ifxmips_led_driver = {
206 + .probe = ifxmips_led_probe,
207 + .remove = ifxmips_led_remove,
210 + .owner = THIS_MODULE,
214 +int __init ifxmips_led_init(void)
216 + int ret = platform_driver_register(&ifxmips_led_driver);
219 + "ifxmips_led: Error registering platfom driver!");
224 +void __exit ifxmips_led_exit(void)
226 + platform_driver_unregister(&ifxmips_led_driver);
229 +module_init(ifxmips_led_init);
230 +module_exit(ifxmips_led_exit);