aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-s3c2410
diff options
context:
space:
mode:
authorVasily Khoruzhick <anarsoul@gmail.com>2011-01-06 14:52:48 -0500
committerBen Dooks <ben-linux@fluff.org>2011-03-20 19:14:55 -0400
commit50e2d10da82774e0733ab561c15c84cb92d9ab33 (patch)
tree95e2589290ce2e06372271286a9190d0f2896a40 /arch/arm/mach-s3c2410
parent4119242876d7d6ff539e1aa3d736a87a28fe7b67 (diff)
ARM: S3C2410: H1940: Use leds-gpio driver for LEDs managing
We can use generic leds-gpio driver, as latch api was converted to gpiolib. Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'arch/arm/mach-s3c2410')
-rw-r--r--arch/arm/mach-s3c2410/h1940-bluetooth.c8
-rw-r--r--arch/arm/mach-s3c2410/include/mach/h1940.h3
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c93
3 files changed, 101 insertions, 3 deletions
diff --git a/arch/arm/mach-s3c2410/h1940-bluetooth.c b/arch/arm/mach-s3c2410/h1940-bluetooth.c
index 6c59ef5f8e98..2c126bbca08d 100644
--- a/arch/arm/mach-s3c2410/h1940-bluetooth.c
+++ b/arch/arm/mach-s3c2410/h1940-bluetooth.c
@@ -18,12 +18,14 @@
18#include <linux/leds.h> 18#include <linux/leds.h>
19#include <linux/gpio.h> 19#include <linux/gpio.h>
20#include <linux/rfkill.h> 20#include <linux/rfkill.h>
21#include <linux/leds.h>
21 22
22#include <mach/regs-gpio.h> 23#include <mach/regs-gpio.h>
23#include <mach/hardware.h> 24#include <mach/hardware.h>
24#include <mach/h1940-latch.h> 25#include <mach/h1940-latch.h>
26#include <mach/h1940.h>
25 27
26#define DRV_NAME "h1940-bt" 28#define DRV_NAME "h1940-bt"
27 29
28/* Bluetooth control */ 30/* Bluetooth control */
29static void h1940bt_enable(int on) 31static void h1940bt_enable(int on)
@@ -37,6 +39,8 @@ static void h1940bt_enable(int on)
37 gpio_set_value(S3C2410_GPH(1), 1); 39 gpio_set_value(S3C2410_GPH(1), 1);
38 mdelay(10); 40 mdelay(10);
39 gpio_set_value(S3C2410_GPH(1), 0); 41 gpio_set_value(S3C2410_GPH(1), 0);
42
43 h1940_led_blink_set(-EINVAL, GPIO_LED_BLINK, NULL, NULL);
40 } 44 }
41 else { 45 else {
42 gpio_set_value(S3C2410_GPH(1), 1); 46 gpio_set_value(S3C2410_GPH(1), 1);
@@ -44,6 +48,8 @@ static void h1940bt_enable(int on)
44 gpio_set_value(S3C2410_GPH(1), 0); 48 gpio_set_value(S3C2410_GPH(1), 0);
45 mdelay(10); 49 mdelay(10);
46 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0); 50 gpio_set_value(H1940_LATCH_BLUETOOTH_POWER, 0);
51
52 h1940_led_blink_set(-EINVAL, GPIO_LED_NO_BLINK_LOW, NULL, NULL);
47 } 53 }
48} 54}
49 55
diff --git a/arch/arm/mach-s3c2410/include/mach/h1940.h b/arch/arm/mach-s3c2410/include/mach/h1940.h
index 4559784129c0..2aa683c8d3d6 100644
--- a/arch/arm/mach-s3c2410/include/mach/h1940.h
+++ b/arch/arm/mach-s3c2410/include/mach/h1940.h
@@ -17,5 +17,8 @@
17#define H1940_SUSPEND_CHECK (0x30080000) 17#define H1940_SUSPEND_CHECK (0x30080000)
18 18
19extern void h1940_pm_return(void); 19extern void h1940_pm_return(void);
20extern int h1940_led_blink_set(unsigned gpio, int state,
21 unsigned long *delay_on, unsigned long *delay_off);
22
20 23
21#endif /* __ASM_ARCH_H1940_H */ 24#endif /* __ASM_ARCH_H1940_H */
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 07564404fb89..36cdb7210879 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -27,6 +27,8 @@
27#include <linux/gpio_keys.h> 27#include <linux/gpio_keys.h>
28#include <linux/pwm_backlight.h> 28#include <linux/pwm_backlight.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/leds.h>
31
30#include <video/platform_lcd.h> 32#include <video/platform_lcd.h>
31 33
32#include <linux/mmc/host.h> 34#include <linux/mmc/host.h>
@@ -216,9 +218,87 @@ static struct s3c2410fb_mach_info h1940_fb_info __initdata = {
216 .gpdup_mask= 0xffffffff, 218 .gpdup_mask= 0xffffffff,
217}; 219};
218 220
221DEFINE_SPINLOCK(h1940_blink_spin);
222
223int h1940_led_blink_set(unsigned gpio, int state,
224 unsigned long *delay_on, unsigned long *delay_off)
225{
226 int blink_gpio, check_gpio1, check_gpio2;
227
228 switch (gpio) {
229 case H1940_LATCH_LED_GREEN:
230 blink_gpio = S3C2410_GPA(7);
231 check_gpio1 = S3C2410_GPA(1);
232 check_gpio2 = S3C2410_GPA(3);
233 break;
234 case H1940_LATCH_LED_RED:
235 blink_gpio = S3C2410_GPA(1);
236 check_gpio1 = S3C2410_GPA(7);
237 check_gpio2 = S3C2410_GPA(3);
238 break;
239 default:
240 blink_gpio = S3C2410_GPA(3);
241 check_gpio1 = S3C2410_GPA(1);
242 check_gpio1 = S3C2410_GPA(7);
243 break;
244 }
245
246 if (delay_on && delay_off && !*delay_on && !*delay_off)
247 *delay_on = *delay_off = 500;
248
249 spin_lock(&h1940_blink_spin);
250
251 switch (state) {
252 case GPIO_LED_NO_BLINK_LOW:
253 case GPIO_LED_NO_BLINK_HIGH:
254 if (!gpio_get_value(check_gpio1) &&
255 !gpio_get_value(check_gpio2))
256 gpio_set_value(H1940_LATCH_LED_FLASH, 0);
257 gpio_set_value(blink_gpio, 0);
258 if (gpio_is_valid(gpio))
259 gpio_set_value(gpio, state);
260 break;
261 case GPIO_LED_BLINK:
262 if (gpio_is_valid(gpio))
263 gpio_set_value(gpio, 0);
264 gpio_set_value(H1940_LATCH_LED_FLASH, 1);
265 gpio_set_value(blink_gpio, 1);
266 break;
267 }
268
269 spin_unlock(&h1940_blink_spin);
270
271 return 0;
272}
273EXPORT_SYMBOL(h1940_led_blink_set);
274
275static struct gpio_led h1940_leds_desc[] = {
276 {
277 .name = "Green",
278 .default_trigger = "main-battery-charging-or-full",
279 .gpio = H1940_LATCH_LED_GREEN,
280 .retain_state_suspended = 1,
281 },
282 {
283 .name = "Red",
284 .default_trigger = "main-battery-full",
285 .gpio = H1940_LATCH_LED_RED,
286 .retain_state_suspended = 1,
287 },
288};
289
290static struct gpio_led_platform_data h1940_leds_pdata = {
291 .num_leds = ARRAY_SIZE(h1940_leds_desc),
292 .leds = h1940_leds_desc,
293 .gpio_blink_set = h1940_led_blink_set,
294};
295
219static struct platform_device h1940_device_leds = { 296static struct platform_device h1940_device_leds = {
220 .name = "h1940-leds", 297 .name = "leds-gpio",
221 .id = -1, 298 .id = -1,
299 .dev = {
300 .platform_data = &h1940_leds_pdata,
301 },
222}; 302};
223 303
224static struct platform_device h1940_device_bluetooth = { 304static struct platform_device h1940_device_bluetooth = {
@@ -500,6 +580,15 @@ static void __init h1940_init(void)
500 580
501 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices)); 581 platform_add_devices(h1940_devices, ARRAY_SIZE(h1940_devices));
502 582
583 gpio_request(S3C2410_GPA(1), "Red LED blink");
584 gpio_request(S3C2410_GPA(3), "Blue LED blink");
585 gpio_request(S3C2410_GPA(7), "Green LED blink");
586 gpio_request(H1940_LATCH_LED_FLASH, "LED blink");
587 gpio_direction_output(S3C2410_GPA(1), 0);
588 gpio_direction_output(S3C2410_GPA(3), 0);
589 gpio_direction_output(S3C2410_GPA(7), 0);
590 gpio_direction_output(H1940_LATCH_LED_FLASH, 0);
591
503 i2c_register_board_info(0, h1940_i2c_devices, 592 i2c_register_board_info(0, h1940_i2c_devices,
504 ARRAY_SIZE(h1940_i2c_devices)); 593 ARRAY_SIZE(h1940_i2c_devices));
505} 594}