diff options
Diffstat (limited to 'arch/arm/mach-omap1/serial.c')
-rw-r--r-- | arch/arm/mach-omap1/serial.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c index 214e5d17c8b5..e702e0cb899e 100644 --- a/arch/arm/mach-omap1/serial.c +++ b/arch/arm/mach-omap1/serial.c | |||
@@ -24,7 +24,11 @@ | |||
24 | 24 | ||
25 | #include <asm/arch/board.h> | 25 | #include <asm/arch/board.h> |
26 | #include <asm/arch/mux.h> | 26 | #include <asm/arch/mux.h> |
27 | #include <asm/arch/gpio.h> | ||
27 | #include <asm/arch/fpga.h> | 28 | #include <asm/arch/fpga.h> |
29 | #ifdef CONFIG_PM | ||
30 | #include <asm/arch/pm.h> | ||
31 | #endif | ||
28 | 32 | ||
29 | static struct clk * uart1_ck = NULL; | 33 | static struct clk * uart1_ck = NULL; |
30 | static struct clk * uart2_ck = NULL; | 34 | static struct clk * uart2_ck = NULL; |
@@ -193,6 +197,86 @@ void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS]) | |||
193 | } | 197 | } |
194 | } | 198 | } |
195 | 199 | ||
200 | #ifdef CONFIG_OMAP_SERIAL_WAKE | ||
201 | |||
202 | static irqreturn_t omap_serial_wake_interrupt(int irq, void *dev_id, | ||
203 | struct pt_regs *regs) | ||
204 | { | ||
205 | /* Need to do something with serial port right after wake-up? */ | ||
206 | return IRQ_HANDLED; | ||
207 | } | ||
208 | |||
209 | /* | ||
210 | * Reroutes serial RX lines to GPIO lines for the duration of | ||
211 | * sleep to allow waking up the device from serial port even | ||
212 | * in deep sleep. | ||
213 | */ | ||
214 | void omap_serial_wake_trigger(int enable) | ||
215 | { | ||
216 | if (!cpu_is_omap16xx()) | ||
217 | return; | ||
218 | |||
219 | if (uart1_ck != NULL) { | ||
220 | if (enable) | ||
221 | omap_cfg_reg(V14_16XX_GPIO37); | ||
222 | else | ||
223 | omap_cfg_reg(V14_16XX_UART1_RX); | ||
224 | } | ||
225 | if (uart2_ck != NULL) { | ||
226 | if (enable) | ||
227 | omap_cfg_reg(R9_16XX_GPIO18); | ||
228 | else | ||
229 | omap_cfg_reg(R9_16XX_UART2_RX); | ||
230 | } | ||
231 | if (uart3_ck != NULL) { | ||
232 | if (enable) | ||
233 | omap_cfg_reg(L14_16XX_GPIO49); | ||
234 | else | ||
235 | omap_cfg_reg(L14_16XX_UART3_RX); | ||
236 | } | ||
237 | } | ||
238 | |||
239 | static void __init omap_serial_set_port_wakeup(int gpio_nr) | ||
240 | { | ||
241 | int ret; | ||
242 | |||
243 | ret = omap_request_gpio(gpio_nr); | ||
244 | if (ret < 0) { | ||
245 | printk(KERN_ERR "Could not request UART wake GPIO: %i\n", | ||
246 | gpio_nr); | ||
247 | return; | ||
248 | } | ||
249 | omap_set_gpio_direction(gpio_nr, 1); | ||
250 | set_irq_type(OMAP_GPIO_IRQ(gpio_nr), IRQT_RISING); | ||
251 | ret = request_irq(OMAP_GPIO_IRQ(gpio_nr), &omap_serial_wake_interrupt, | ||
252 | 0, "serial wakeup", NULL); | ||
253 | if (ret) { | ||
254 | omap_free_gpio(gpio_nr); | ||
255 | printk(KERN_ERR "No interrupt for UART wake GPIO: %i\n", | ||
256 | gpio_nr); | ||
257 | return; | ||
258 | } | ||
259 | enable_irq_wake(OMAP_GPIO_IRQ(gpio_nr)); | ||
260 | } | ||
261 | |||
262 | static int __init omap_serial_wakeup_init(void) | ||
263 | { | ||
264 | if (!cpu_is_omap16xx()) | ||
265 | return 0; | ||
266 | |||
267 | if (uart1_ck != NULL) | ||
268 | omap_serial_set_port_wakeup(37); | ||
269 | if (uart2_ck != NULL) | ||
270 | omap_serial_set_port_wakeup(18); | ||
271 | if (uart3_ck != NULL) | ||
272 | omap_serial_set_port_wakeup(49); | ||
273 | |||
274 | return 0; | ||
275 | } | ||
276 | late_initcall(omap_serial_wakeup_init); | ||
277 | |||
278 | #endif /* CONFIG_OMAP_SERIAL_WAKE */ | ||
279 | |||
196 | static int __init omap_init(void) | 280 | static int __init omap_init(void) |
197 | { | 281 | { |
198 | return platform_device_register(&serial_device); | 282 | return platform_device_register(&serial_device); |