Tony Lindgren | aca59b8 | 2009-10-19 17:26:17 -0700 | [diff] [blame] | 1 | /* arch/arm/mach-omap1/include/mach/debug-macro.S |
| 2 | * |
| 3 | * Debugging macro include header |
| 4 | * |
| 5 | * Copyright (C) 1994-1999 Russell King |
| 6 | * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | */ |
| 13 | |
Tony Lindgren | 4f2c49f | 2010-02-15 08:48:53 -0800 | [diff] [blame] | 14 | #include <linux/serial_reg.h> |
| 15 | |
| 16 | #include <plat/serial.h> |
| 17 | |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 18 | .pushsection .data |
| 19 | omap_uart_phys: .word 0x0 |
| 20 | omap_uart_virt: .word 0x0 |
| 21 | .popsection |
| 22 | |
| 23 | /* |
| 24 | * Note that this code won't work if the bootloader passes |
| 25 | * a wrong machine ID number in r1. To debug, just hardcode |
| 26 | * the desired UART phys and virt addresses temporarily into |
| 27 | * the omap_uart_phys and omap_uart_virt above. |
| 28 | */ |
Nicolas Pitre | 639da5e | 2011-08-31 22:55:46 -0400 | [diff] [blame] | 29 | .macro addruart, rp, rv, tmp |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 30 | |
| 31 | /* Use omap_uart_phys/virt if already configured */ |
Nicolas Pitre | 28362d5 | 2011-09-01 19:17:43 -0400 | [diff] [blame] | 32 | 9: adr \rp, 99f @ get effective addr of 99f |
| 33 | ldr \rv, [\rp] @ get absolute addr of 99f |
| 34 | sub \rv, \rv, \rp @ offset between the two |
| 35 | ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys |
| 36 | sub \tmp, \rp, \rv @ make it effective |
| 37 | ldr \rp, [\tmp, #0] @ omap_uart_phys |
| 38 | ldr \rv, [\tmp, #4] @ omap_uart_virt |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 39 | cmp \rp, #0 @ is port configured? |
| 40 | cmpne \rv, #0 |
Nicolas Pitre | 28362d5 | 2011-09-01 19:17:43 -0400 | [diff] [blame] | 41 | bne 100f @ already configured |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 42 | |
Tony Lindgren | 96554d7 | 2010-04-30 17:39:19 -0700 | [diff] [blame] | 43 | /* Check the debug UART configuration set in uncompress.h */ |
Nicolas Pitre | dd185456 | 2011-08-31 13:57:37 -0400 | [diff] [blame] | 44 | and \rp, pc, #0xff000000 |
| 45 | ldr \rv, =OMAP_UART_INFO_OFS |
| 46 | ldr \rp, [\rp, \rv] |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 47 | |
| 48 | /* Select the UART to use based on the UART1 scratchpad value */ |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 49 | 10: cmp \rp, #0 @ no port configured? |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 50 | beq 11f @ if none, try to use UART1 |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 51 | cmp \rp, #OMAP1UART1 |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 52 | beq 11f @ configure OMAP1UART1 |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 53 | cmp \rp, #OMAP1UART2 |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 54 | beq 12f @ configure OMAP1UART2 |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 55 | cmp \rp, #OMAP1UART3 |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 56 | beq 13f @ configure OMAP2UART3 |
| 57 | |
| 58 | /* Configure the UART offset from the phys/virt base */ |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 59 | 11: mov \rp, #0x00fb0000 @ OMAP1UART1 |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 60 | b 98f |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 61 | 12: mov \rp, #0x00fb0000 @ OMAP1UART1 |
| 62 | orr \rp, \rp, #0x00000800 @ OMAP1UART2 |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 63 | b 98f |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 64 | 13: mov \rp, #0x00fb0000 @ OMAP1UART1 |
| 65 | orr \rp, \rp, #0x00000800 @ OMAP1UART2 |
| 66 | orr \rp, \rp, #0x00009000 @ OMAP1UART3 |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 67 | |
| 68 | /* Store both phys and virt address for the uart */ |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 69 | 98: add \rp, \rp, #0xff000000 @ phys base |
Nicolas Pitre | 28362d5 | 2011-09-01 19:17:43 -0400 | [diff] [blame] | 70 | str \rp, [\tmp, #0] @ omap_uart_phys |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame] | 71 | sub \rp, \rp, #0xff000000 @ phys base |
| 72 | add \rp, \rp, #0xfe000000 @ virt base |
Nicolas Pitre | 28362d5 | 2011-09-01 19:17:43 -0400 | [diff] [blame] | 73 | str \rp, [\tmp, #4] @ omap_uart_virt |
Tony Lindgren | 0c8219f | 2010-02-15 08:49:01 -0800 | [diff] [blame] | 74 | b 9b |
Nicolas Pitre | 28362d5 | 2011-09-01 19:17:43 -0400 | [diff] [blame] | 75 | |
| 76 | .align |
| 77 | 99: .word . |
| 78 | .word omap_uart_phys |
| 79 | .ltorg |
| 80 | |
| 81 | 100: |
Tony Lindgren | aca59b8 | 2009-10-19 17:26:17 -0700 | [diff] [blame] | 82 | .endm |
| 83 | |
| 84 | .macro senduart,rd,rx |
| 85 | strb \rd, [\rx] |
| 86 | .endm |
| 87 | |
| 88 | .macro busyuart,rd,rx |
Tony Lindgren | 4f2c49f | 2010-02-15 08:48:53 -0800 | [diff] [blame] | 89 | 1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)] |
| 90 | and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE) |
| 91 | teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE) |
Tony Lindgren | aca59b8 | 2009-10-19 17:26:17 -0700 | [diff] [blame] | 92 | beq 1002f |
Tony Lindgren | 4f2c49f | 2010-02-15 08:48:53 -0800 | [diff] [blame] | 93 | ldrb \rd, [\rx, #(UART_LSR << OMAP7XX_PORT_SHIFT)] |
| 94 | and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE) |
| 95 | teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE) |
Tony Lindgren | aca59b8 | 2009-10-19 17:26:17 -0700 | [diff] [blame] | 96 | bne 1001b |
| 97 | 1002: |
| 98 | .endm |
| 99 | |
| 100 | .macro waituart,rd,rx |
| 101 | .endm |