Commit 8ee8ef2996df477aa1623bd213b1548ab1b9c07c
1 parent
95f4965cf8
ARM: mach-clps711x: retire custom LED code of P720T machine
Add tigger based LED driver into board file of P720T. Remove old LED driver file. Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
Showing 4 changed files with 61 additions and 66 deletions Side-by-side Diff
arch/arm/mach-clps711x/Makefile
arch/arm/mach-clps711x/common.c
arch/arm/mach-clps711x/p720t-leds.c
1 | -/* | |
2 | - * linux/arch/arm/mach-clps711x/leds.c | |
3 | - * | |
4 | - * Integrator LED control routines | |
5 | - * | |
6 | - * Copyright (C) 2000 Deep Blue Solutions Ltd | |
7 | - * | |
8 | - * This program is free software; you can redistribute it and/or modify | |
9 | - * it under the terms of the GNU General Public License as published by | |
10 | - * the Free Software Foundation; either version 2 of the License, or | |
11 | - * (at your option) any later version. | |
12 | - * | |
13 | - * This program is distributed in the hope that it will be useful, | |
14 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | - * GNU General Public License for more details. | |
17 | - * | |
18 | - * You should have received a copy of the GNU General Public License | |
19 | - * along with this program; if not, write to the Free Software | |
20 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | - */ | |
22 | -#include <linux/kernel.h> | |
23 | -#include <linux/init.h> | |
24 | -#include <linux/io.h> | |
25 | - | |
26 | -#include <mach/hardware.h> | |
27 | -#include <asm/leds.h> | |
28 | -#include <asm/mach-types.h> | |
29 | - | |
30 | -static void p720t_leds_event(led_event_t ledevt) | |
31 | -{ | |
32 | - unsigned long flags; | |
33 | - u32 pddr; | |
34 | - | |
35 | - local_irq_save(flags); | |
36 | - switch(ledevt) { | |
37 | - case led_idle_start: | |
38 | - break; | |
39 | - | |
40 | - case led_idle_end: | |
41 | - break; | |
42 | - | |
43 | - case led_timer: | |
44 | - pddr = clps_readb(PDDR); | |
45 | - clps_writeb(pddr ^ 1, PDDR); | |
46 | - break; | |
47 | - | |
48 | - default: | |
49 | - break; | |
50 | - } | |
51 | - | |
52 | - local_irq_restore(flags); | |
53 | -} | |
54 | - | |
55 | -static int __init leds_init(void) | |
56 | -{ | |
57 | - if (machine_is_p720t()) | |
58 | - leds_event = p720t_leds_event; | |
59 | - | |
60 | - return 0; | |
61 | -} | |
62 | - | |
63 | -arch_initcall(leds_init); |
arch/arm/mach-clps711x/p720t.c
... | ... | @@ -23,6 +23,8 @@ |
23 | 23 | #include <linux/string.h> |
24 | 24 | #include <linux/mm.h> |
25 | 25 | #include <linux/io.h> |
26 | +#include <linux/slab.h> | |
27 | +#include <linux/leds.h> | |
26 | 28 | |
27 | 29 | #include <mach/hardware.h> |
28 | 30 | #include <asm/pgtable.h> |
... | ... | @@ -34,6 +36,8 @@ |
34 | 36 | #include <asm/mach/map.h> |
35 | 37 | #include <mach/syspld.h> |
36 | 38 | |
39 | +#include <asm/hardware/clps7111.h> | |
40 | + | |
37 | 41 | #include "common.h" |
38 | 42 | |
39 | 43 | /* |
... | ... | @@ -120,4 +124,62 @@ |
120 | 124 | } |
121 | 125 | |
122 | 126 | __initcall(p720t_hw_init); |
127 | + | |
128 | +/* | |
129 | + * LED controled by CPLD | |
130 | + */ | |
131 | +#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) | |
132 | +static void p720t_led_set(struct led_classdev *cdev, | |
133 | + enum led_brightness b) | |
134 | +{ | |
135 | + u8 reg = clps_readb(PDDR); | |
136 | + | |
137 | + if (b != LED_OFF) | |
138 | + reg |= 0x1; | |
139 | + else | |
140 | + reg &= ~0x1; | |
141 | + | |
142 | + clps_writeb(reg, PDDR); | |
143 | +} | |
144 | + | |
145 | +static enum led_brightness p720t_led_get(struct led_classdev *cdev) | |
146 | +{ | |
147 | + u8 reg = clps_readb(PDDR); | |
148 | + | |
149 | + return (reg & 0x1) ? LED_FULL : LED_OFF; | |
150 | +} | |
151 | + | |
152 | +static int __init p720t_leds_init(void) | |
153 | +{ | |
154 | + | |
155 | + struct led_classdev *cdev; | |
156 | + int ret; | |
157 | + | |
158 | + if (!machine_is_p720t()) | |
159 | + return -ENODEV; | |
160 | + | |
161 | + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL); | |
162 | + if (!cdev) | |
163 | + return -ENOMEM; | |
164 | + | |
165 | + cdev->name = "p720t:0"; | |
166 | + cdev->brightness_set = p720t_led_set; | |
167 | + cdev->brightness_get = p720t_led_get; | |
168 | + cdev->default_trigger = "heartbeat"; | |
169 | + | |
170 | + ret = led_classdev_register(NULL, cdev); | |
171 | + if (ret < 0) { | |
172 | + kfree(cdev); | |
173 | + return ret; | |
174 | + } | |
175 | + | |
176 | + return 0; | |
177 | +} | |
178 | + | |
179 | +/* | |
180 | + * Since we may have triggers on any subsystem, defer registration | |
181 | + * until after subsystem_init. | |
182 | + */ | |
183 | +fs_initcall(p720t_leds_init); | |
184 | +#endif |