aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2012-11-17 08:57:08 -0500
committerOlof Johansson <olof@lixom.net>2012-11-21 01:21:43 -0500
commitb3a076dd0270507e1976b141a2aa5c53b9b553d1 (patch)
tree6d258ff4e96763b954c1083a4b24664fc22159d7
parent200daa367c59b4952f1e86ed9761859b1bcc3dbd (diff)
ARM: clps711x: p720t: Using "leds-gpio" driver for LED control
Instead of manually create LED class device, we will use "leds-gpio" driver for LED control. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--arch/arm/mach-clps711x/common.h3
-rw-r--r--arch/arm/mach-clps711x/p720t.c74
2 files changed, 23 insertions, 54 deletions
diff --git a/arch/arm/mach-clps711x/common.h b/arch/arm/mach-clps711x/common.h
index fc0f0650dcb5..dc60caea3278 100644
--- a/arch/arm/mach-clps711x/common.h
+++ b/arch/arm/mach-clps711x/common.h
@@ -4,6 +4,9 @@
4 * Common bits. 4 * Common bits.
5 */ 5 */
6 6
7#define CLPS711X_NR_GPIO (4 * 8 + 3)
8#define CLPS711X_GPIO(prt, bit) ((prt) * 8 + (bit))
9
7struct sys_timer; 10struct sys_timer;
8 11
9extern void clps711x_map_io(void); 12extern void clps711x_map_io(void);
diff --git a/arch/arm/mach-clps711x/p720t.c b/arch/arm/mach-clps711x/p720t.c
index dd8995027dd4..8fe33b3a204c 100644
--- a/arch/arm/mach-clps711x/p720t.c
+++ b/arch/arm/mach-clps711x/p720t.c
@@ -25,6 +25,7 @@
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/leds.h> 27#include <linux/leds.h>
28#include <linux/platform_device.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/pgtable.h> 31#include <asm/pgtable.h>
@@ -38,6 +39,8 @@
38 39
39#include "common.h" 40#include "common.h"
40 41
42#define GPIO_USERLED CLPS711X_GPIO(3, 0)
43
41/* 44/*
42 * Map the P720T system PLD. It occupies two address spaces: 45 * Map the P720T system PLD. It occupies two address spaces:
43 * 0x10000000 and 0x10400000. We map both regions as one. 46 * 0x10000000 and 0x10400000. We map both regions as one.
@@ -103,71 +106,34 @@ static void __init p720t_init_early(void)
103 } 106 }
104} 107}
105 108
106/* 109static struct gpio_led p720t_gpio_leds[] = {
107 * LED controled by CPLD 110 {
108 */ 111 .name = "User LED",
109#if defined(CONFIG_NEW_LEDS) && defined(CONFIG_LEDS_CLASS) 112 .default_trigger = "heartbeat",
110static void p720t_led_set(struct led_classdev *cdev, 113 .gpio = GPIO_USERLED,
111 enum led_brightness b) 114 },
112{ 115};
113 u8 reg = clps_readb(PDDR);
114
115 if (b != LED_OFF)
116 reg |= 0x1;
117 else
118 reg &= ~0x1;
119
120 clps_writeb(reg, PDDR);
121}
122
123static enum led_brightness p720t_led_get(struct led_classdev *cdev)
124{
125 u8 reg = clps_readb(PDDR);
126 116
127 return (reg & 0x1) ? LED_FULL : LED_OFF; 117static struct gpio_led_platform_data p720t_gpio_led_pdata __initdata = {
128} 118 .leds = p720t_gpio_leds,
119 .num_leds = ARRAY_SIZE(p720t_gpio_leds),
120};
129 121
130static int __init p720t_leds_init(void) 122static void __init p720t_init_late(void)
131{ 123{
132 124 platform_device_register_data(&platform_bus, "leds-gpio", 0,
133 struct led_classdev *cdev; 125 &p720t_gpio_led_pdata,
134 int ret; 126 sizeof(p720t_gpio_led_pdata));
135
136 if (!machine_is_p720t())
137 return -ENODEV;
138
139 cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
140 if (!cdev)
141 return -ENOMEM;
142
143 cdev->name = "p720t:0";
144 cdev->brightness_set = p720t_led_set;
145 cdev->brightness_get = p720t_led_get;
146 cdev->default_trigger = "heartbeat";
147
148 ret = led_classdev_register(NULL, cdev);
149 if (ret < 0) {
150 kfree(cdev);
151 return ret;
152 }
153
154 return 0;
155} 127}
156 128
157/*
158 * Since we may have triggers on any subsystem, defer registration
159 * until after subsystem_init.
160 */
161fs_initcall(p720t_leds_init);
162#endif
163
164MACHINE_START(P720T, "ARM-Prospector720T") 129MACHINE_START(P720T, "ARM-Prospector720T")
165 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 130 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
166 .atag_offset = 0x100, 131 .atag_offset = 0x100,
167 .fixup = fixup_p720t, 132 .fixup = fixup_p720t,
168 .init_early = p720t_init_early,
169 .map_io = p720t_map_io, 133 .map_io = p720t_map_io,
134 .init_early = p720t_init_early,
170 .init_irq = clps711x_init_irq, 135 .init_irq = clps711x_init_irq,
171 .timer = &clps711x_timer, 136 .timer = &clps711x_timer,
137 .init_late = p720t_init_late,
172 .restart = clps711x_restart, 138 .restart = clps711x_restart,
173MACHINE_END 139MACHINE_END