1/* arch/arm/mach-omap2/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 14#include <linux/serial_reg.h> 15 16#include <asm/memory.h> 17 18#include <plat/serial.h> 19 20#define UART_OFFSET(addr) ((addr) & 0x00ffffff) 21 22 .pushsection .data 23omap_uart_phys: .word 0 24omap_uart_virt: .word 0 25omap_uart_lsr: .word 0 26 .popsection 27 28 /* 29 * Note that this code won't work if the bootloader passes 30 * a wrong machine ID number in r1. To debug, just hardcode 31 * the desired UART phys and virt addresses temporarily into 32 * the omap_uart_phys and omap_uart_virt above. 33 */ 34 .macro addruart, rx, tmp 35 36 /* Use omap_uart_phys/virt if already configured */ 3710: mrc p15, 0, \rx, c1, c0 38 tst \rx, #1 @ MMU enabled? 39 ldreq \rx, =__virt_to_phys(omap_uart_phys) @ physical base address 40 ldrne \rx, =omap_uart_virt @ virtual base address 41 ldr \rx, [\rx, #0] 42 cmp \rx, #0 @ is port configured? 43 bne 99f @ already configured 44 45 /* Check the debug UART configuration set in uncompress.h */ 46 mrc p15, 0, \rx, c1, c0 47 tst \rx, #1 @ MMU enabled? 48 ldreq \rx, =OMAP_UART_INFO 49 ldrne \rx, =__phys_to_virt(OMAP_UART_INFO) 50 ldr \rx, [\rx, #0] 51 52 /* Select the UART to use based on the UART1 scratchpad value */ 53 cmp \rx, #0 @ no port configured? 54 beq 21f @ if none, try to use UART1 55 cmp \rx, #OMAP2UART1 @ OMAP2/3/4UART1 56 beq 21f @ configure OMAP2/3/4UART1 57 cmp \rx, #OMAP2UART2 @ OMAP2/3/4UART2 58 beq 22f @ configure OMAP2/3/4UART2 59 cmp \rx, #OMAP2UART3 @ only on 24xx 60 beq 23f @ configure OMAP2UART3 61 cmp \rx, #OMAP3UART3 @ only on 34xx 62 beq 33f @ configure OMAP3UART3 63 cmp \rx, #OMAP4UART3 @ only on 44xx 64 beq 43f @ configure OMAP4UART3 65 cmp \rx, #OMAP3UART4 @ only on 36xx 66 beq 34f @ configure OMAP3UART4 67 cmp \rx, #OMAP4UART4 @ only on 44xx 68 beq 44f @ configure OMAP4UART4 69 cmp \rx, #ZOOM_UART @ only on zoom2/3 70 beq 95f @ configure ZOOM_UART 71 72 /* Configure the UART offset from the phys/virt base */ 7321: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4 74 b 98f 7522: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4 76 b 98f 7723: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE) 78 b 98f 7933: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE) 80 add \rx, \rx, #0x00fb0000 81 add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE 82 b 98f 8334: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE) 84 add \rx, \rx, #0x00fb0000 85 add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE 86 b 98f 8743: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE) 88 b 98f 8944: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE) 90 b 98f 9195: ldr \rx, =ZOOM_UART_BASE 92 mrc p15, 0, \tmp, c1, c0 93 tst \tmp, #1 @ MMU enabled? 94 ldreq \tmp, =__virt_to_phys(omap_uart_phys) 95 ldrne \tmp, =omap_uart_phys 96 str \rx, [\tmp, #0] 97 ldr \rx, =ZOOM_UART_VIRT 98 ldreq \tmp, =__virt_to_phys(omap_uart_virt) 99 ldrne \tmp, =omap_uart_virt 100 str \rx, [\tmp, #0] 101 mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT) 102 ldreq \tmp, =__virt_to_phys(omap_uart_lsr) 103 ldrne \tmp, =omap_uart_lsr 104 str \rx, [\tmp, #0] 105 b 10b 106 107 /* Store both phys and virt address for the uart */ 10898: add \rx, \rx, #0x48000000 @ phys base 109 mrc p15, 0, \tmp, c1, c0 110 tst \tmp, #1 @ MMU enabled? 111 ldreq \tmp, =__virt_to_phys(omap_uart_phys) 112 ldrne \tmp, =omap_uart_phys 113 str \rx, [\tmp, #0] 114 sub \rx, \rx, #0x48000000 @ phys base 115 add \rx, \rx, #0xfa000000 @ virt base 116 ldreq \tmp, =__virt_to_phys(omap_uart_virt) 117 ldrne \tmp, =omap_uart_virt 118 str \rx, [\tmp, #0] 119 mov \rx, #(UART_LSR << OMAP_PORT_SHIFT) 120 ldreq \tmp, =__virt_to_phys(omap_uart_lsr) 121 ldrne \tmp, =omap_uart_lsr 122 str \rx, [\tmp, #0] 123 124 b 10b 12599: 126 .endm 127 128 .macro senduart,rd,rx 129 strb \rd, [\rx] 130 .endm 131 132 .macro busyuart,rd,rx 1331001: mrc p15, 0, \rd, c1, c0 134 tst \rd, #1 @ MMU enabled? 135 ldreq \rd, =__virt_to_phys(omap_uart_lsr) 136 ldrne \rd, =omap_uart_lsr 137 ldr \rd, [\rd, #0] 138 ldrb \rd, [\rx, \rd] 139 and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE) 140 teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE) 141 bne 1001b 142 .endm 143 144 .macro waituart,rd,rx 145 .endm 146