ar71xx: change board specific Kconfig option to 'default n'
[openwrt.git] / target / linux / ifxmips / patches-2.6.30 / 160-led.patch
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
5 @@ -227,6 +227,12 @@
6 This option enables support for BD2802GU RGB LED driver chips
7 accessed via the I2C bus.
8
9 +config LEDS_IFXMIPS
10 + tristate "LED Support for IFXMIPS LEDs"
11 + depends on LEDS_CLASS && IFXMIPS
12 + help
13 + This option enables support for the CM-X270 LEDs.
14 +
15 comment "LED Triggers"
16
17 config LEDS_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
22 @@ -27,6 +27,7 @@
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
27
28 # LED SPI Drivers
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
34 @@ -0,0 +1,196 @@
35 +/*
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.
40 + *
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.
45 + *
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.
49 + *
50 + * Copyright (C) 2006 infineon
51 + * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
52 + *
53 + */
54 +
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>
67 +
68 +#include <ifxmips.h>
69 +#include <ifxmips_gpio.h>
70 +#include <ifxmips_pmu.h>
71 +
72 +#define DRVNAME "ifxmips_led"
73 +
74 +/* might need to be changed depending on shift register used on the pcb */
75 +#if 1
76 +#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING
77 +#else
78 +#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING
79 +#endif
80 +
81 +#define IFXMIPS_LED_SPEED IFXMIPS_LED_8HZ
82 +
83 +#define IFXMIPS_LED_GPIO_PORT 0
84 +
85 +#define IFXMIPS_MAX_LED 24
86 +
87 +struct ifxmips_led {
88 + struct led_classdev cdev;
89 + u8 bit;
90 +};
91 +
92 +void ifxmips_led_set(unsigned int led)
93 +{
94 + led &= 0xffffff;
95 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) | led, IFXMIPS_LED_CPU0);
96 +}
97 +EXPORT_SYMBOL(ifxmips_led_set);
98 +
99 +void ifxmips_led_clear(unsigned int led)
100 +{
101 + led = ~(led & 0xffffff);
102 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) & led, IFXMIPS_LED_CPU0);
103 +}
104 +EXPORT_SYMBOL(ifxmips_led_clear);
105 +
106 +void ifxmips_led_blink_set(unsigned int led)
107 +{
108 + led &= 0xffffff;
109 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | led, IFXMIPS_LED_CON0);
110 +}
111 +EXPORT_SYMBOL(ifxmips_led_blink_set);
112 +
113 +void ifxmips_led_blink_clear(unsigned int led)
114 +{
115 + led = ~(led & 0xffffff);
116 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & led, IFXMIPS_LED_CON0);
117 +}
118 +EXPORT_SYMBOL(ifxmips_led_blink_clear);
119 +
120 +static void ifxmips_ledapi_set(struct led_classdev *led_cdev,
121 + enum led_brightness value)
122 +{
123 + struct ifxmips_led *led_dev =
124 + container_of(led_cdev, struct ifxmips_led, cdev);
125 +
126 + if (value)
127 + ifxmips_led_set(1 << led_dev->bit);
128 + else
129 + ifxmips_led_clear(1 << led_dev->bit);
130 +}
131 +
132 +void ifxmips_led_setup_gpio(void)
133 +{
134 + int i = 0;
135 +
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);
143 + }
144 +}
145 +
146 +static int ifxmips_led_probe(struct platform_device *dev)
147 +{
148 + int i = 0;
149 +
150 + ifxmips_led_setup_gpio();
151 +
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);
157 +
158 + /* setup the clock edge that the shift register is triggered on */
159 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & ~IFXMIPS_LED_EDGE_MASK,
160 + IFXMIPS_LED_CON0);
161 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_CLK_EDGE,
162 + IFXMIPS_LED_CON0);
163 +
164 + /* per default leds 15-0 are set */
165 + ifxmips_w32(IFXMIPS_LED_GROUP1 | IFXMIPS_LED_GROUP0, IFXMIPS_LED_CON1);
166 +
167 + /* leds are update periodically by the FPID */
168 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_UPD_MASK,
169 + IFXMIPS_LED_CON1);
170 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_UPD_SRC_FPI,
171 + IFXMIPS_LED_CON1);
172 +
173 + /* set led update speed */
174 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) & ~IFXMIPS_LED_MASK,
175 + IFXMIPS_LED_CON1);
176 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON1) | IFXMIPS_LED_SPEED,
177 + IFXMIPS_LED_CON1);
178 +
179 + /* adsl 0 and 1 leds are updated by the arc */
180 + ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | IFXMIPS_LED_ADSL_SRC,
181 + IFXMIPS_LED_CON0);
182 +
183 + /* per default, the leds are turned on */
184 + ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED);
185 +
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;
193 + tmp->bit = i;
194 + led_classdev_register(&dev->dev, &tmp->cdev);
195 + }
196 +
197 + return 0;
198 +}
199 +
200 +static int ifxmips_led_remove(struct platform_device *pdev)
201 +{
202 + return 0;
203 +}
204 +
205 +static struct platform_driver ifxmips_led_driver = {
206 + .probe = ifxmips_led_probe,
207 + .remove = ifxmips_led_remove,
208 + .driver = {
209 + .name = DRVNAME,
210 + .owner = THIS_MODULE,
211 + },
212 +};
213 +
214 +int __init ifxmips_led_init(void)
215 +{
216 + int ret = platform_driver_register(&ifxmips_led_driver);
217 + if (ret)
218 + printk(KERN_INFO
219 + "ifxmips_led: Error registering platfom driver!");
220 +
221 + return ret;
222 +}
223 +
224 +void __exit ifxmips_led_exit(void)
225 +{
226 + platform_driver_unregister(&ifxmips_led_driver);
227 +}
228 +
229 +module_init(ifxmips_led_init);
230 +module_exit(ifxmips_led_exit);
This page took 0.051661 seconds and 5 git commands to generate.