2009-10-20 08:26:17 +08:00
|
|
|
/* arch/arm/mach-omap2/include/mach/debug-macro.S
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Debugging macro include header
|
|
|
|
*
|
|
|
|
* Copyright (C) 1994-1999 Russell King
|
|
|
|
* Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-02-16 00:48:53 +08:00
|
|
|
#include <linux/serial_reg.h>
|
|
|
|
|
|
|
|
#include <plat/serial.h>
|
|
|
|
|
2010-02-16 00:49:01 +08:00
|
|
|
#define UART_OFFSET(addr) ((addr) & 0x00ffffff)
|
|
|
|
|
|
|
|
.pushsection .data
|
|
|
|
omap_uart_phys: .word 0
|
|
|
|
omap_uart_virt: .word 0
|
|
|
|
omap_uart_lsr: .word 0
|
|
|
|
.popsection
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note that this code won't work if the bootloader passes
|
|
|
|
* a wrong machine ID number in r1. To debug, just hardcode
|
|
|
|
* the desired UART phys and virt addresses temporarily into
|
|
|
|
* the omap_uart_phys and omap_uart_virt above.
|
|
|
|
*/
|
2011-09-01 10:55:46 +08:00
|
|
|
.macro addruart, rp, rv, tmp
|
2010-02-16 00:49:01 +08:00
|
|
|
|
|
|
|
/* Use omap_uart_phys/virt if already configured */
|
2011-09-01 12:48:04 +08:00
|
|
|
10: adr \rp, 99f @ get effective addr of 99f
|
|
|
|
ldr \rv, [\rp] @ get absolute addr of 99f
|
|
|
|
sub \rv, \rv, \rp @ offset between the two
|
|
|
|
ldr \rp, [\rp, #4] @ abs addr of omap_uart_phys
|
|
|
|
sub \tmp, \rp, \rv @ make it effective
|
|
|
|
ldr \rp, [\tmp, #0] @ omap_uart_phys
|
|
|
|
ldr \rv, [\tmp, #4] @ omap_uart_virt
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #0 @ is port configured?
|
|
|
|
cmpne \rv, #0
|
2011-09-01 12:48:04 +08:00
|
|
|
bne 100f @ already configured
|
2010-02-16 00:49:01 +08:00
|
|
|
|
2010-05-01 08:39:19 +08:00
|
|
|
/* Check the debug UART configuration set in uncompress.h */
|
2011-09-01 01:57:37 +08:00
|
|
|
mov \rp, pc
|
|
|
|
ldr \rv, =OMAP_UART_INFO_OFS
|
|
|
|
and \rp, \rp, #0xff000000
|
|
|
|
ldr \rp, [\rp, \rv]
|
2010-02-16 00:49:01 +08:00
|
|
|
|
|
|
|
/* Select the UART to use based on the UART1 scratchpad value */
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #0 @ no port configured?
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 21f @ if none, try to use UART1
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #OMAP2UART1 @ OMAP2/3/4UART1
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 21f @ configure OMAP2/3/4UART1
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #OMAP2UART2 @ OMAP2/3/4UART2
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 22f @ configure OMAP2/3/4UART2
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #OMAP2UART3 @ only on 24xx
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 23f @ configure OMAP2UART3
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #OMAP3UART3 @ only on 34xx
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 33f @ configure OMAP3UART3
|
2012-06-05 18:51:32 +08:00
|
|
|
cmp \rp, #OMAP4UART3 @ only on 44xx/54xx
|
|
|
|
beq 43f @ configure OMAP4/5UART3
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #OMAP3UART4 @ only on 36xx
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 34f @ configure OMAP3UART4
|
2012-06-05 18:51:32 +08:00
|
|
|
cmp \rp, #OMAP4UART4 @ only on 44xx/54xx
|
|
|
|
beq 44f @ configure OMAP4/5UART4
|
2011-12-14 02:46:44 +08:00
|
|
|
cmp \rp, #TI81XXUART1 @ ti81Xx UART offsets different
|
2011-02-16 01:36:17 +08:00
|
|
|
beq 81f @ configure UART1
|
2011-12-14 02:46:44 +08:00
|
|
|
cmp \rp, #TI81XXUART2 @ ti81Xx UART offsets different
|
2011-02-16 01:36:17 +08:00
|
|
|
beq 82f @ configure UART2
|
2011-12-14 02:46:44 +08:00
|
|
|
cmp \rp, #TI81XXUART3 @ ti81Xx UART offsets different
|
2011-02-16 01:36:17 +08:00
|
|
|
beq 83f @ configure UART3
|
2012-05-10 16:53:01 +08:00
|
|
|
cmp \rp, #AM33XXUART1 @ AM33XX UART offsets different
|
|
|
|
beq 84f @ configure UART1
|
2010-07-06 18:30:06 +08:00
|
|
|
cmp \rp, #ZOOM_UART @ only on zoom2/3
|
2010-02-16 00:49:01 +08:00
|
|
|
beq 95f @ configure ZOOM_UART
|
|
|
|
|
|
|
|
/* Configure the UART offset from the phys/virt base */
|
2010-07-06 18:30:06 +08:00
|
|
|
21: mov \rp, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2010-07-06 18:30:06 +08:00
|
|
|
22: mov \rp, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2010-07-06 18:30:06 +08:00
|
|
|
23: mov \rp, #UART_OFFSET(OMAP2_UART3_BASE)
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2010-07-06 18:30:06 +08:00
|
|
|
33: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
|
|
|
|
add \rp, \rp, #0x00fb0000
|
|
|
|
add \rp, \rp, #0x00006000 @ OMAP3_UART3_BASE
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2010-07-06 18:30:06 +08:00
|
|
|
34: mov \rp, #UART_OFFSET(OMAP3_UART1_BASE)
|
|
|
|
add \rp, \rp, #0x00fb0000
|
|
|
|
add \rp, \rp, #0x00028000 @ OMAP3_UART4_BASE
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2010-07-06 18:30:06 +08:00
|
|
|
43: mov \rp, #UART_OFFSET(OMAP4_UART3_BASE)
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2010-07-06 18:30:06 +08:00
|
|
|
44: mov \rp, #UART_OFFSET(OMAP4_UART4_BASE)
|
2010-02-16 00:49:01 +08:00
|
|
|
b 98f
|
2011-12-14 02:46:44 +08:00
|
|
|
81: mov \rp, #UART_OFFSET(TI81XX_UART1_BASE)
|
2011-02-16 01:36:17 +08:00
|
|
|
b 98f
|
2011-12-14 02:46:44 +08:00
|
|
|
82: mov \rp, #UART_OFFSET(TI81XX_UART2_BASE)
|
2011-02-16 01:36:17 +08:00
|
|
|
b 98f
|
2011-12-14 02:46:44 +08:00
|
|
|
83: mov \rp, #UART_OFFSET(TI81XX_UART3_BASE)
|
2011-02-16 01:36:17 +08:00
|
|
|
b 98f
|
2012-05-10 16:53:01 +08:00
|
|
|
84: ldr \rp, =AM33XX_UART1_BASE
|
|
|
|
and \rp, \rp, #0x00ffffff
|
|
|
|
b 97f
|
2010-07-06 18:30:06 +08:00
|
|
|
95: ldr \rp, =ZOOM_UART_BASE
|
2011-09-01 12:48:04 +08:00
|
|
|
str \rp, [\tmp, #0] @ omap_uart_phys
|
2010-07-06 18:30:06 +08:00
|
|
|
ldr \rp, =ZOOM_UART_VIRT
|
2011-09-01 12:48:04 +08:00
|
|
|
str \rp, [\tmp, #4] @ omap_uart_virt
|
2010-07-06 18:30:06 +08:00
|
|
|
mov \rp, #(UART_LSR << ZOOM_PORT_SHIFT)
|
2011-09-01 12:48:04 +08:00
|
|
|
str \rp, [\tmp, #8] @ omap_uart_lsr
|
2010-02-16 00:49:01 +08:00
|
|
|
b 10b
|
|
|
|
|
2012-05-10 16:53:01 +08:00
|
|
|
/* AM33XX: Store both phys and virt address for the uart */
|
|
|
|
97: add \rp, \rp, #0x44000000 @ phys base
|
|
|
|
str \rp, [\tmp, #0] @ omap_uart_phys
|
|
|
|
sub \rp, \rp, #0x44000000 @ phys base
|
|
|
|
add \rp, \rp, #0xf9000000 @ virt base
|
|
|
|
str \rp, [\tmp, #4] @ omap_uart_virt
|
|
|
|
mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
|
|
|
|
str \rp, [\tmp, #8] @ omap_uart_lsr
|
|
|
|
|
|
|
|
b 10b
|
|
|
|
|
2010-02-16 00:49:01 +08:00
|
|
|
/* Store both phys and virt address for the uart */
|
2010-07-06 18:30:06 +08:00
|
|
|
98: add \rp, \rp, #0x48000000 @ phys base
|
2011-09-01 12:48:04 +08:00
|
|
|
str \rp, [\tmp, #0] @ omap_uart_phys
|
2010-07-06 18:30:06 +08:00
|
|
|
sub \rp, \rp, #0x48000000 @ phys base
|
|
|
|
add \rp, \rp, #0xfa000000 @ virt base
|
2011-09-01 12:48:04 +08:00
|
|
|
str \rp, [\tmp, #4] @ omap_uart_virt
|
2010-07-06 18:30:06 +08:00
|
|
|
mov \rp, #(UART_LSR << OMAP_PORT_SHIFT)
|
2011-09-01 12:48:04 +08:00
|
|
|
str \rp, [\tmp, #8] @ omap_uart_lsr
|
2010-02-16 00:49:01 +08:00
|
|
|
|
|
|
|
b 10b
|
2011-09-01 12:48:04 +08:00
|
|
|
|
|
|
|
.align
|
|
|
|
99: .word .
|
|
|
|
.word omap_uart_phys
|
|
|
|
.ltorg
|
|
|
|
|
|
|
|
100: /* Pass the UART_LSR reg address */
|
|
|
|
ldr \tmp, [\tmp, #8] @ omap_uart_lsr
|
|
|
|
add \rp, \rp, \tmp
|
|
|
|
add \rv, \rv, \tmp
|
2005-04-17 06:20:36 +08:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro senduart,rd,rx
|
2011-09-01 12:48:04 +08:00
|
|
|
orr \rd, \rd, \rx, lsl #24 @ preserve LSR reg offset
|
|
|
|
bic \rx, \rx, #0xff @ get base (THR) reg address
|
|
|
|
strb \rd, [\rx] @ send lower byte of rd
|
|
|
|
orr \rx, \rx, \rd, lsr #24 @ restore original rx (LSR)
|
|
|
|
bic \rd, \rd, #(0xff << 24) @ restore original rd
|
2005-04-17 06:20:36 +08:00
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro busyuart,rd,rx
|
2011-09-01 12:48:04 +08:00
|
|
|
1001: ldrb \rd, [\rx] @ rx contains UART_LSR address
|
2010-02-16 00:48:53 +08:00
|
|
|
and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
|
|
|
|
teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
|
2005-04-17 06:20:36 +08:00
|
|
|
bne 1001b
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro waituart,rd,rx
|
|
|
|
.endm
|