diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-22 10:38:37 -0500 |
commit | fcc9d2e5a6c89d22b8b773a64fb4ad21ac318446 (patch) | |
tree | a57612d1888735a2ec7972891b68c1ac5ec8faea /arch/arm/mach-omap1 | |
parent | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (diff) |
Diffstat (limited to 'arch/arm/mach-omap1')
-rw-r--r-- | arch/arm/mach-omap1/include/mach/gpio.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-omap1/include/mach/smp.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-omap1/include/mach/system.h | 5 | ||||
-rw-r--r-- | arch/arm/mach-omap1/include/mach/vmalloc.h | 20 | ||||
-rw-r--r-- | arch/arm/mach-omap1/leds-h2p2-debug.c | 167 | ||||
-rw-r--r-- | arch/arm/mach-omap1/leds-innovator.c | 99 | ||||
-rw-r--r-- | arch/arm/mach-omap1/leds-osk.c | 115 | ||||
-rw-r--r-- | arch/arm/mach-omap1/leds.c | 69 | ||||
-rw-r--r-- | arch/arm/mach-omap1/leds.h | 3 |
9 files changed, 488 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/include/mach/gpio.h b/arch/arm/mach-omap1/include/mach/gpio.h new file mode 100644 index 00000000000..e737706a8fe --- /dev/null +++ b/arch/arm/mach-omap1/include/mach/gpio.h | |||
@@ -0,0 +1,5 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-omap1/include/mach/gpio.h | ||
3 | */ | ||
4 | |||
5 | #include <plat/gpio.h> | ||
diff --git a/arch/arm/mach-omap1/include/mach/smp.h b/arch/arm/mach-omap1/include/mach/smp.h new file mode 100644 index 00000000000..80a371c06e5 --- /dev/null +++ b/arch/arm/mach-omap1/include/mach/smp.h | |||
@@ -0,0 +1,5 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-omap1/include/mach/smp.h | ||
3 | */ | ||
4 | |||
5 | #include <plat/smp.h> | ||
diff --git a/arch/arm/mach-omap1/include/mach/system.h b/arch/arm/mach-omap1/include/mach/system.h new file mode 100644 index 00000000000..a6c1b3a16df --- /dev/null +++ b/arch/arm/mach-omap1/include/mach/system.h | |||
@@ -0,0 +1,5 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-omap1/include/mach/system.h | ||
3 | */ | ||
4 | |||
5 | #include <plat/system.h> | ||
diff --git a/arch/arm/mach-omap1/include/mach/vmalloc.h b/arch/arm/mach-omap1/include/mach/vmalloc.h new file mode 100644 index 00000000000..22ec4a47957 --- /dev/null +++ b/arch/arm/mach-omap1/include/mach/vmalloc.h | |||
@@ -0,0 +1,20 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-omap1/include/mach/vmalloc.h | ||
3 | * | ||
4 | * Copyright (C) 2000 Russell King. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | #define VMALLOC_END 0xd8000000UL | ||
diff --git a/arch/arm/mach-omap1/leds-h2p2-debug.c b/arch/arm/mach-omap1/leds-h2p2-debug.c new file mode 100644 index 00000000000..b4f9be52e1e --- /dev/null +++ b/arch/arm/mach-omap1/leds-h2p2-debug.c | |||
@@ -0,0 +1,167 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-omap1/leds-h2p2-debug.c | ||
3 | * | ||
4 | * Copyright 2003 by Texas Instruments Incorporated | ||
5 | * | ||
6 | * There are 16 LEDs on the debug board (all green); four may be used | ||
7 | * for logical 'green', 'amber', 'red', and 'blue' (after "claiming"). | ||
8 | * | ||
9 | * The "surfer" expansion board and H2 sample board also have two-color | ||
10 | * green+red LEDs (in parallel), used here for timer and idle indicators. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel_stat.h> | ||
14 | #include <linux/sched.h> | ||
15 | #include <linux/io.h> | ||
16 | |||
17 | #include <mach/hardware.h> | ||
18 | #include <asm/leds.h> | ||
19 | #include <asm/system.h> | ||
20 | #include <asm/mach-types.h> | ||
21 | |||
22 | #include <plat/fpga.h> | ||
23 | #include <mach/gpio.h> | ||
24 | |||
25 | #include "leds.h" | ||
26 | |||
27 | |||
28 | #define GPIO_LED_RED 3 | ||
29 | #define GPIO_LED_GREEN OMAP_MPUIO(4) | ||
30 | |||
31 | |||
32 | #define LED_STATE_ENABLED 0x01 | ||
33 | #define LED_STATE_CLAIMED 0x02 | ||
34 | #define LED_TIMER_ON 0x04 | ||
35 | |||
36 | #define GPIO_IDLE GPIO_LED_GREEN | ||
37 | #define GPIO_TIMER GPIO_LED_RED | ||
38 | |||
39 | |||
40 | void h2p2_dbg_leds_event(led_event_t evt) | ||
41 | { | ||
42 | unsigned long flags; | ||
43 | |||
44 | static struct h2p2_dbg_fpga __iomem *fpga; | ||
45 | static u16 led_state, hw_led_state; | ||
46 | |||
47 | local_irq_save(flags); | ||
48 | |||
49 | if (!(led_state & LED_STATE_ENABLED) && evt != led_start) | ||
50 | goto done; | ||
51 | |||
52 | switch (evt) { | ||
53 | case led_start: | ||
54 | if (!fpga) | ||
55 | fpga = ioremap(H2P2_DBG_FPGA_START, | ||
56 | H2P2_DBG_FPGA_SIZE); | ||
57 | if (fpga) { | ||
58 | led_state |= LED_STATE_ENABLED; | ||
59 | __raw_writew(~0, &fpga->leds); | ||
60 | } | ||
61 | break; | ||
62 | |||
63 | case led_stop: | ||
64 | case led_halted: | ||
65 | /* all leds off during suspend or shutdown */ | ||
66 | |||
67 | if (! machine_is_omap_perseus2()) { | ||
68 | gpio_set_value(GPIO_TIMER, 0); | ||
69 | gpio_set_value(GPIO_IDLE, 0); | ||
70 | } | ||
71 | |||
72 | __raw_writew(~0, &fpga->leds); | ||
73 | led_state &= ~LED_STATE_ENABLED; | ||
74 | if (evt == led_halted) { | ||
75 | iounmap(fpga); | ||
76 | fpga = NULL; | ||
77 | } | ||
78 | |||
79 | goto done; | ||
80 | |||
81 | case led_claim: | ||
82 | led_state |= LED_STATE_CLAIMED; | ||
83 | hw_led_state = 0; | ||
84 | break; | ||
85 | |||
86 | case led_release: | ||
87 | led_state &= ~LED_STATE_CLAIMED; | ||
88 | break; | ||
89 | |||
90 | #ifdef CONFIG_LEDS_TIMER | ||
91 | case led_timer: | ||
92 | led_state ^= LED_TIMER_ON; | ||
93 | |||
94 | if (machine_is_omap_perseus2()) | ||
95 | hw_led_state ^= H2P2_DBG_FPGA_P2_LED_TIMER; | ||
96 | else { | ||
97 | gpio_set_value(GPIO_TIMER, led_state & LED_TIMER_ON); | ||
98 | goto done; | ||
99 | } | ||
100 | |||
101 | break; | ||
102 | #endif | ||
103 | |||
104 | #ifdef CONFIG_LEDS_CPU | ||
105 | case led_idle_start: | ||
106 | if (machine_is_omap_perseus2()) | ||
107 | hw_led_state |= H2P2_DBG_FPGA_P2_LED_IDLE; | ||
108 | else { | ||
109 | gpio_set_value(GPIO_IDLE, 1); | ||
110 | goto done; | ||
111 | } | ||
112 | |||
113 | break; | ||
114 | |||
115 | case led_idle_end: | ||
116 | if (machine_is_omap_perseus2()) | ||
117 | hw_led_state &= ~H2P2_DBG_FPGA_P2_LED_IDLE; | ||
118 | else { | ||
119 | gpio_set_value(GPIO_IDLE, 0); | ||
120 | goto done; | ||
121 | } | ||
122 | |||
123 | break; | ||
124 | #endif | ||
125 | |||
126 | case led_green_on: | ||
127 | hw_led_state |= H2P2_DBG_FPGA_LED_GREEN; | ||
128 | break; | ||
129 | case led_green_off: | ||
130 | hw_led_state &= ~H2P2_DBG_FPGA_LED_GREEN; | ||
131 | break; | ||
132 | |||
133 | case led_amber_on: | ||
134 | hw_led_state |= H2P2_DBG_FPGA_LED_AMBER; | ||
135 | break; | ||
136 | case led_amber_off: | ||
137 | hw_led_state &= ~H2P2_DBG_FPGA_LED_AMBER; | ||
138 | break; | ||
139 | |||
140 | case led_red_on: | ||
141 | hw_led_state |= H2P2_DBG_FPGA_LED_RED; | ||
142 | break; | ||
143 | case led_red_off: | ||
144 | hw_led_state &= ~H2P2_DBG_FPGA_LED_RED; | ||
145 | break; | ||
146 | |||
147 | case led_blue_on: | ||
148 | hw_led_state |= H2P2_DBG_FPGA_LED_BLUE; | ||
149 | break; | ||
150 | case led_blue_off: | ||
151 | hw_led_state &= ~H2P2_DBG_FPGA_LED_BLUE; | ||
152 | break; | ||
153 | |||
154 | default: | ||
155 | break; | ||
156 | } | ||
157 | |||
158 | |||
159 | /* | ||
160 | * Actually burn the LEDs | ||
161 | */ | ||
162 | if (led_state & LED_STATE_ENABLED) | ||
163 | __raw_writew(~hw_led_state, &fpga->leds); | ||
164 | |||
165 | done: | ||
166 | local_irq_restore(flags); | ||
167 | } | ||
diff --git a/arch/arm/mach-omap1/leds-innovator.c b/arch/arm/mach-omap1/leds-innovator.c new file mode 100644 index 00000000000..9b99c289462 --- /dev/null +++ b/arch/arm/mach-omap1/leds-innovator.c | |||
@@ -0,0 +1,99 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-omap1/leds-innovator.c | ||
3 | */ | ||
4 | #include <linux/init.h> | ||
5 | |||
6 | #include <mach/hardware.h> | ||
7 | #include <asm/leds.h> | ||
8 | #include <asm/system.h> | ||
9 | |||
10 | #include "leds.h" | ||
11 | |||
12 | |||
13 | #define LED_STATE_ENABLED 1 | ||
14 | #define LED_STATE_CLAIMED 2 | ||
15 | |||
16 | static unsigned int led_state; | ||
17 | static unsigned int hw_led_state; | ||
18 | |||
19 | void innovator_leds_event(led_event_t evt) | ||
20 | { | ||
21 | unsigned long flags; | ||
22 | |||
23 | local_irq_save(flags); | ||
24 | |||
25 | switch (evt) { | ||
26 | case led_start: | ||
27 | hw_led_state = 0; | ||
28 | led_state = LED_STATE_ENABLED; | ||
29 | break; | ||
30 | |||
31 | case led_stop: | ||
32 | led_state &= ~LED_STATE_ENABLED; | ||
33 | hw_led_state = 0; | ||
34 | break; | ||
35 | |||
36 | case led_claim: | ||
37 | led_state |= LED_STATE_CLAIMED; | ||
38 | hw_led_state = 0; | ||
39 | break; | ||
40 | |||
41 | case led_release: | ||
42 | led_state &= ~LED_STATE_CLAIMED; | ||
43 | hw_led_state = 0; | ||
44 | break; | ||
45 | |||
46 | #ifdef CONFIG_LEDS_TIMER | ||
47 | case led_timer: | ||
48 | if (!(led_state & LED_STATE_CLAIMED)) | ||
49 | hw_led_state ^= 0; | ||
50 | break; | ||
51 | #endif | ||
52 | |||
53 | #ifdef CONFIG_LEDS_CPU | ||
54 | case led_idle_start: | ||
55 | if (!(led_state & LED_STATE_CLAIMED)) | ||
56 | hw_led_state |= 0; | ||
57 | break; | ||
58 | |||
59 | case led_idle_end: | ||
60 | if (!(led_state & LED_STATE_CLAIMED)) | ||
61 | hw_led_state &= ~0; | ||
62 | break; | ||
63 | #endif | ||
64 | |||
65 | case led_halted: | ||
66 | break; | ||
67 | |||
68 | case led_green_on: | ||
69 | if (led_state & LED_STATE_CLAIMED) | ||
70 | hw_led_state &= ~0; | ||
71 | break; | ||
72 | |||
73 | case led_green_off: | ||
74 | if (led_state & LED_STATE_CLAIMED) | ||
75 | hw_led_state |= 0; | ||
76 | break; | ||
77 | |||
78 | case led_amber_on: | ||
79 | break; | ||
80 | |||
81 | case led_amber_off: | ||
82 | break; | ||
83 | |||
84 | case led_red_on: | ||
85 | if (led_state & LED_STATE_CLAIMED) | ||
86 | hw_led_state &= ~0; | ||
87 | break; | ||
88 | |||
89 | case led_red_off: | ||
90 | if (led_state & LED_STATE_CLAIMED) | ||
91 | hw_led_state |= 0; | ||
92 | break; | ||
93 | |||
94 | default: | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | local_irq_restore(flags); | ||
99 | } | ||
diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c new file mode 100644 index 00000000000..499d7ad8697 --- /dev/null +++ b/arch/arm/mach-omap1/leds-osk.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-omap1/leds-osk.c | ||
3 | * | ||
4 | * LED driver for OSK with optional Mistral QVGA board | ||
5 | */ | ||
6 | #include <linux/init.h> | ||
7 | |||
8 | #include <mach/hardware.h> | ||
9 | #include <asm/leds.h> | ||
10 | #include <asm/system.h> | ||
11 | |||
12 | #include <mach/gpio.h> | ||
13 | |||
14 | #include "leds.h" | ||
15 | |||
16 | |||
17 | #define LED_STATE_ENABLED (1 << 0) | ||
18 | #define LED_STATE_CLAIMED (1 << 1) | ||
19 | static u8 led_state; | ||
20 | |||
21 | #define TIMER_LED (1 << 3) /* Mistral board */ | ||
22 | #define IDLE_LED (1 << 4) /* Mistral board */ | ||
23 | static u8 hw_led_state; | ||
24 | |||
25 | |||
26 | #ifdef CONFIG_OMAP_OSK_MISTRAL | ||
27 | |||
28 | /* For now, all system indicators require the Mistral board, since that | ||
29 | * LED can be manipulated without a task context. This LED is either red, | ||
30 | * or green, but not both; it can't give the full "disco led" effect. | ||
31 | */ | ||
32 | |||
33 | #define GPIO_LED_RED 3 | ||
34 | #define GPIO_LED_GREEN OMAP_MPUIO(4) | ||
35 | |||
36 | static void mistral_setled(void) | ||
37 | { | ||
38 | int red = 0; | ||
39 | int green = 0; | ||
40 | |||
41 | if (hw_led_state & TIMER_LED) | ||
42 | red = 1; | ||
43 | else if (hw_led_state & IDLE_LED) | ||
44 | green = 1; | ||
45 | /* else both sides are disabled */ | ||
46 | |||
47 | gpio_set_value(GPIO_LED_GREEN, green); | ||
48 | gpio_set_value(GPIO_LED_RED, red); | ||
49 | } | ||
50 | |||
51 | #endif | ||
52 | |||
53 | void osk_leds_event(led_event_t evt) | ||
54 | { | ||
55 | unsigned long flags; | ||
56 | u16 leds; | ||
57 | |||
58 | local_irq_save(flags); | ||
59 | |||
60 | if (!(led_state & LED_STATE_ENABLED) && evt != led_start) | ||
61 | goto done; | ||
62 | |||
63 | leds = hw_led_state; | ||
64 | switch (evt) { | ||
65 | case led_start: | ||
66 | led_state |= LED_STATE_ENABLED; | ||
67 | hw_led_state = 0; | ||
68 | leds = ~0; | ||
69 | break; | ||
70 | |||
71 | case led_halted: | ||
72 | case led_stop: | ||
73 | led_state &= ~LED_STATE_ENABLED; | ||
74 | hw_led_state = 0; | ||
75 | break; | ||
76 | |||
77 | case led_claim: | ||
78 | led_state |= LED_STATE_CLAIMED; | ||
79 | hw_led_state = 0; | ||
80 | leds = ~0; | ||
81 | break; | ||
82 | |||
83 | case led_release: | ||
84 | led_state &= ~LED_STATE_CLAIMED; | ||
85 | hw_led_state = 0; | ||
86 | break; | ||
87 | |||
88 | #ifdef CONFIG_OMAP_OSK_MISTRAL | ||
89 | |||
90 | case led_timer: | ||
91 | hw_led_state ^= TIMER_LED; | ||
92 | mistral_setled(); | ||
93 | break; | ||
94 | |||
95 | case led_idle_start: /* idle == off */ | ||
96 | hw_led_state &= ~IDLE_LED; | ||
97 | mistral_setled(); | ||
98 | break; | ||
99 | |||
100 | case led_idle_end: | ||
101 | hw_led_state |= IDLE_LED; | ||
102 | mistral_setled(); | ||
103 | break; | ||
104 | |||
105 | #endif /* CONFIG_OMAP_OSK_MISTRAL */ | ||
106 | |||
107 | default: | ||
108 | break; | ||
109 | } | ||
110 | |||
111 | leds ^= hw_led_state; | ||
112 | |||
113 | done: | ||
114 | local_irq_restore(flags); | ||
115 | } | ||
diff --git a/arch/arm/mach-omap1/leds.c b/arch/arm/mach-omap1/leds.c new file mode 100644 index 00000000000..22eb11dde9e --- /dev/null +++ b/arch/arm/mach-omap1/leds.c | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-omap1/leds.c | ||
3 | * | ||
4 | * OMAP LEDs dispatcher | ||
5 | */ | ||
6 | #include <linux/kernel.h> | ||
7 | #include <linux/init.h> | ||
8 | |||
9 | #include <asm/leds.h> | ||
10 | #include <asm/mach-types.h> | ||
11 | |||
12 | #include <mach/gpio.h> | ||
13 | #include <plat/mux.h> | ||
14 | |||
15 | #include "leds.h" | ||
16 | |||
17 | static int __init | ||
18 | omap_leds_init(void) | ||
19 | { | ||
20 | if (!cpu_class_is_omap1()) | ||
21 | return -ENODEV; | ||
22 | |||
23 | if (machine_is_omap_innovator()) | ||
24 | leds_event = innovator_leds_event; | ||
25 | |||
26 | else if (machine_is_omap_h2() | ||
27 | || machine_is_omap_h3() | ||
28 | || machine_is_omap_perseus2()) | ||
29 | leds_event = h2p2_dbg_leds_event; | ||
30 | |||
31 | else if (machine_is_omap_osk()) | ||
32 | leds_event = osk_leds_event; | ||
33 | |||
34 | else | ||
35 | return -1; | ||
36 | |||
37 | if (machine_is_omap_h2() | ||
38 | || machine_is_omap_h3() | ||
39 | #ifdef CONFIG_OMAP_OSK_MISTRAL | ||
40 | || machine_is_omap_osk() | ||
41 | #endif | ||
42 | ) { | ||
43 | |||
44 | /* LED1/LED2 pins can be used as GPIO (as done here), or by | ||
45 | * the LPG (works even in deep sleep!), to drive a bicolor | ||
46 | * LED on the H2 sample board, and another on the H2/P2 | ||
47 | * "surfer" expansion board. | ||
48 | * | ||
49 | * The same pins drive a LED on the OSK Mistral board, but | ||
50 | * that's a different kind of LED (just one color at a time). | ||
51 | */ | ||
52 | omap_cfg_reg(P18_1610_GPIO3); | ||
53 | if (gpio_request(3, "LED red") == 0) | ||
54 | gpio_direction_output(3, 1); | ||
55 | else | ||
56 | printk(KERN_WARNING "LED: can't get GPIO3/red?\n"); | ||
57 | |||
58 | omap_cfg_reg(MPUIO4); | ||
59 | if (gpio_request(OMAP_MPUIO(4), "LED green") == 0) | ||
60 | gpio_direction_output(OMAP_MPUIO(4), 1); | ||
61 | else | ||
62 | printk(KERN_WARNING "LED: can't get MPUIO4/green?\n"); | ||
63 | } | ||
64 | |||
65 | leds_event(led_start); | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | __initcall(omap_leds_init); | ||
diff --git a/arch/arm/mach-omap1/leds.h b/arch/arm/mach-omap1/leds.h new file mode 100644 index 00000000000..a1e9fedc376 --- /dev/null +++ b/arch/arm/mach-omap1/leds.h | |||
@@ -0,0 +1,3 @@ | |||
1 | extern void innovator_leds_event(led_event_t evt); | ||
2 | extern void h2p2_dbg_leds_event(led_event_t evt); | ||
3 | extern void osk_leds_event(led_event_t evt); | ||