cam_enc_4xx: Set CONFIG_SYS_NAND_MAX_OOBFREE / CONFIG_SYS_NAND_MAX_ECCPOS
[platform/kernel/u-boot.git] / board / logicpd / zoom2 / led.c
1 /*
2  * Copyright (c) 2009 Wind River Systems, Inc.
3  * Tom Rix <Tom.Rix@windriver.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7 #include <common.h>
8 #include <status_led.h>
9 #include <asm/arch/cpu.h>
10 #include <asm/io.h>
11 #include <asm/arch/sys_proto.h>
12 #include <asm/gpio.h>
13
14 static unsigned int saved_state[2] = {STATUS_LED_OFF, STATUS_LED_OFF};
15
16 /*
17  * GPIO LEDs
18  * 173 red
19  * 154 blue
20  * 61  blue2
21  */
22 #define ZOOM2_LED_RED   173
23 #define ZOOM2_LED_BLUE  154
24 #define ZOOM2_LED_BLUE2 61
25
26 void red_led_off(void)
27 {
28         /* red */
29         if (!gpio_request(ZOOM2_LED_RED, "")) {
30                 gpio_direction_output(ZOOM2_LED_RED, 0);
31                 gpio_set_value(ZOOM2_LED_RED, 0);
32         }
33         saved_state[STATUS_LED_RED] = STATUS_LED_OFF;
34 }
35
36 void blue_led_off(void)
37 {
38         /* blue */
39         if (!gpio_request(ZOOM2_LED_BLUE, "")) {
40                 gpio_direction_output(ZOOM2_LED_BLUE, 0);
41                 gpio_set_value(ZOOM2_LED_BLUE, 0);
42         }
43
44         /* blue 2 */
45         if (!gpio_request(ZOOM2_LED_BLUE2, "")) {
46                 gpio_direction_output(ZOOM2_LED_BLUE2, 0);
47                 gpio_set_value(ZOOM2_LED_BLUE2, 0);
48         }
49         saved_state[STATUS_LED_BLUE] = STATUS_LED_OFF;
50 }
51
52 void red_led_on(void)
53 {
54         blue_led_off();
55
56         /* red */
57         if (!gpio_request(ZOOM2_LED_RED, "")) {
58                 gpio_direction_output(ZOOM2_LED_RED, 0);
59                 gpio_set_value(ZOOM2_LED_RED, 1);
60         }
61         saved_state[STATUS_LED_RED] = STATUS_LED_ON;
62 }
63
64 void blue_led_on(void)
65 {
66         red_led_off();
67
68         /* blue */
69         if (!gpio_request(ZOOM2_LED_BLUE, "")) {
70                 gpio_direction_output(ZOOM2_LED_BLUE, 0);
71                 gpio_set_value(ZOOM2_LED_BLUE, 1);
72         }
73
74         /* blue 2 */
75         if (!gpio_request(ZOOM2_LED_BLUE2, "")) {
76                 gpio_direction_output(ZOOM2_LED_BLUE2, 0);
77                 gpio_set_value(ZOOM2_LED_BLUE2, 1);
78         }
79
80         saved_state[STATUS_LED_BLUE] = STATUS_LED_ON;
81 }
82
83 void __led_init (led_id_t mask, int state)
84 {
85         __led_set (mask, state);
86 }
87
88 void __led_toggle (led_id_t mask)
89 {
90         if (STATUS_LED_BLUE == mask) {
91                 if (STATUS_LED_ON == saved_state[STATUS_LED_BLUE])
92                         blue_led_off();
93                 else
94                         blue_led_on();
95         } else if (STATUS_LED_RED == mask) {
96                 if (STATUS_LED_ON == saved_state[STATUS_LED_RED])
97                         red_led_off();
98                 else
99                         red_led_on();
100         }
101 }
102
103 void __led_set (led_id_t mask, int state)
104 {
105         if (STATUS_LED_BLUE == mask) {
106                 if (STATUS_LED_ON == state)
107                         blue_led_on();
108                 else
109                         blue_led_off();
110         } else if (STATUS_LED_RED == mask) {
111                 if (STATUS_LED_ON == state)
112                         red_led_on();
113                 else
114                         red_led_off();
115         }
116 }