Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 184670
b: refs/heads/master
c: 0c8219f
h: refs/heads/master
v: v3
  • Loading branch information
Tony Lindgren committed Feb 15, 2010
1 parent ce74cc3 commit 761bb60
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 83 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4f2c49fedf833e522001bc51824b894732900a3d
refs/heads/master: 0c8219f0302d0d27fda52c790d38406801e547ec
72 changes: 65 additions & 7 deletions trunk/arch/arm/mach-omap1/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,76 @@

#include <plat/serial.h>

.pushsection .data
omap_uart_phys: .word 0x0
omap_uart_virt: .word 0x0
.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.
*/
.macro addruart, rx, tmp

/* Use omap_uart_phys/virt if already configured */
9: mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =omap_uart_phys @ physical base address
ldrne \rx, =omap_uart_virt @ virtual base
ldr \rx, [\rx, #0]
cmp \rx, #0 @ is port configured?
bne 99f @ already configured

/* Check 7XX UART1 scratchpad register for uart to use */
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0xff000000 @ physical base address
movne \rx, #0xfe000000 @ virtual base
orr \rx, \rx, #0x00fb0000 @ OMAP1UART1
ldrb \rx, [\rx, #(UART_SCR << OMAP7XX_PORT_SHIFT)]
cmp \rx, #0 @ anything in 7XX scratchpad?
bne 10f @ found 7XX uart

/* Check 15xx/16xx UART1 scratchpad register for uart to use */
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
moveq \rx, #0xff000000 @ physical base address
movne \rx, #0xfe000000 @ virtual base
orr \rx, \rx, #0x00fb0000
#ifdef CONFIG_OMAP_LL_DEBUG_UART3
orr \rx, \rx, #0x00009000 @ UART 3
#endif
#if defined(CONFIG_OMAP_LL_DEBUG_UART2) || defined(CONFIG_OMAP_LL_DEBUG_UART3)
orr \rx, \rx, #0x00000800 @ UART 2 & 3
#endif
orr \rx, \rx, #0x00fb0000 @ OMAP1UART1
ldrb \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)]

/* Select the UART to use based on the UART1 scratchpad value */
10: cmp \rx, #0 @ no port configured?
beq 11f @ if none, try to use UART1
cmp \rx, #OMAP1UART1
beq 11f @ configure OMAP1UART1
cmp \rx, #OMAP1UART2
beq 12f @ configure OMAP1UART2
cmp \rx, #OMAP1UART3
beq 13f @ configure OMAP2UART3

/* Configure the UART offset from the phys/virt base */
11: mov \rx, #0x00fb0000 @ OMAP1UART1
b 98f
12: mov \rx, #0x00fb0000 @ OMAP1UART1
orr \rx, \rx, #0x00000800 @ OMAP1UART2
b 98f
13: mov \rx, #0x00fb0000 @ OMAP1UART1
orr \rx, \rx, #0x00000800 @ OMAP1UART2
orr \rx, \rx, #0x00009000 @ OMAP1UART3

/* Store both phys and virt address for the uart */
98: add \rx, \rx, #0xff000000 @ phys base
ldr \tmp, =omap_uart_phys
str \rx, [\tmp, #0]
sub \rx, \rx, #0xff000000 @ phys base
add \rx, \rx, #0xfe000000 @ virt base
ldr \tmp, =omap_uart_virt
str \rx, [\tmp, #0]
b 9b
99:
.endm

.macro senduart,rd,rx
Expand Down
117 changes: 95 additions & 22 deletions trunk/arch/arm/mach-omap2/include/mach/debug-macro.S
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,113 @@

#include <plat/serial.h>

#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.
*/
.macro addruart, rx, tmp

/* Use omap_uart_phys/virt if already configured */
10: mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
ldreq \rx, =omap_uart_phys @ physical base address
ldrne \rx, =omap_uart_virt @ virtual base address
ldr \rx, [\rx, #0]
cmp \rx, #0 @ is port configured?
bne 99f @ already configured

/* Check UART1 scratchpad register for uart to use */
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
#ifdef CONFIG_ARCH_OMAP2
moveq \rx, #0x48000000 @ physical base address
movne \rx, #0xfa000000 @ virtual base
orr \rx, \rx, #0x0006a000
#ifdef CONFIG_OMAP_LL_DEBUG_UART2
add \rx, \rx, #0x00002000 @ UART 2
#endif
#ifdef CONFIG_OMAP_LL_DEBUG_UART3
add \rx, \rx, #0x00004000 @ UART 3
#endif

#elif defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
moveq \rx, #0x48000000 @ physical base address
movne \rx, #0xfa000000 @ virtual base
orr \rx, \rx, #0x0006a000
#ifdef CONFIG_OMAP_LL_DEBUG_UART2
add \rx, \rx, #0x00002000 @ UART 2
#endif
#ifdef CONFIG_OMAP_LL_DEBUG_UART3
add \rx, \rx, #0x00fb0000 @ UART 3
add \rx, \rx, #0x00006000
#endif
#endif
orr \rx, \rx, #0x0006a000 @ uart1 on omap2/3/4
ldrb \rx, [\rx, #(UART_SCR << OMAP_PORT_SHIFT)] @ scratchpad

/* Select the UART to use based on the UART1 scratchpad value */
cmp \rx, #0 @ no port configured?
beq 21f @ if none, try to use UART1
cmp \rx, #OMAP2UART1 @ OMAP2/3/4UART1
beq 21f @ configure OMAP2/3/4UART1
cmp \rx, #OMAP2UART2 @ OMAP2/3/4UART2
beq 22f @ configure OMAP2/3/4UART2
cmp \rx, #OMAP2UART3 @ only on 24xx
beq 23f @ configure OMAP2UART3
cmp \rx, #OMAP3UART3 @ only on 34xx
beq 33f @ configure OMAP3UART3
cmp \rx, #OMAP4UART3 @ only on 44xx
beq 43f @ configure OMAP4UART3
cmp \rx, #OMAP3UART4 @ only on 36xx
beq 34f @ configure OMAP3UART4
cmp \rx, #OMAP4UART4 @ only on 44xx
beq 44f @ configure OMAP4UART4
cmp \rx, #ZOOM_UART @ only on zoom2/3
beq 95f @ configure ZOOM_UART

/* Configure the UART offset from the phys/virt base */
21: mov \rx, #UART_OFFSET(OMAP2_UART1_BASE) @ omap2/3/4
b 98f
22: mov \rx, #UART_OFFSET(OMAP2_UART2_BASE) @ omap2/3/4
b 98f
23: mov \rx, #UART_OFFSET(OMAP2_UART3_BASE)
b 98f
33: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
add \rx, \rx, #0x00fb0000
add \rx, \rx, #0x00006000 @ OMAP3_UART3_BASE
b 98f
34: mov \rx, #UART_OFFSET(OMAP3_UART1_BASE)
add \rx, \rx, #0x00fb0000
add \rx, \rx, #0x00028000 @ OMAP3_UART4_BASE
b 98f
43: mov \rx, #UART_OFFSET(OMAP4_UART3_BASE)
b 98f
44: mov \rx, #UART_OFFSET(OMAP4_UART4_BASE)
b 98f
95: mov \rx, #ZOOM_UART_BASE
ldr \tmp, =omap_uart_phys
str \rx, [\tmp, #0]
mov \rx, #ZOOM_UART_VIRT
ldr \tmp, =omap_uart_virt
str \rx, [\tmp, #0]
mov \rx, #(UART_LSR << ZOOM_PORT_SHIFT)
ldr \tmp, =omap_uart_lsr
str \rx, [\tmp, #0]
b 10b

/* Store both phys and virt address for the uart */
98: add \rx, \rx, #0x48000000 @ phys base
ldr \tmp, =omap_uart_phys
str \rx, [\tmp, #0]
sub \rx, \rx, #0x48000000 @ phys base
add \rx, \rx, #0xfa000000 @ virt base
ldr \tmp, =omap_uart_virt
str \rx, [\tmp, #0]
mov \rx, #(UART_LSR << OMAP_PORT_SHIFT)
ldr \tmp, =omap_uart_lsr
str \rx, [\tmp, #0]

b 10b
99:
.endm

.macro senduart,rd,rx
strb \rd, [\rx]
.endm

.macro busyuart,rd,rx
1001: ldrb \rd, [\rx, #(UART_LSR << OMAP_PORT_SHIFT)]
1001: ldr \rd, =omap_uart_lsr
ldr \rd, [\rd, #0]
ldrb \rd, [\rx, \rd]
and \rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
teq \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
bne 1001b
Expand Down
33 changes: 29 additions & 4 deletions trunk/arch/arm/plat-omap/include/plat/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,49 @@
#define OMAP2_UART3_BASE 0x4806e000

/* OMAP3 serial ports */
#define OMAP3_UART1_BASE 0x4806a000
#define OMAP3_UART2_BASE 0x4806c000
#define OMAP3_UART1_BASE OMAP2_UART1_BASE
#define OMAP3_UART2_BASE OMAP2_UART2_BASE
#define OMAP3_UART3_BASE 0x49020000
#define OMAP3_UART4_BASE 0x49042000 /* Only on 36xx */

/* OMAP4 serial ports */
#define OMAP4_UART1_BASE 0x4806a000
#define OMAP4_UART2_BASE 0x4806c000
#define OMAP4_UART1_BASE OMAP2_UART1_BASE
#define OMAP4_UART2_BASE OMAP2_UART2_BASE
#define OMAP4_UART3_BASE 0x48020000
#define OMAP4_UART4_BASE 0x4806e000

/* External port on Zoom2/3 */
#define ZOOM_UART_BASE 0x10000000
#define ZOOM_UART_VIRT 0xfb000000

#define OMAP_PORT_SHIFT 2
#define OMAP7XX_PORT_SHIFT 0
#define ZOOM_PORT_SHIFT 1

#define OMAP1510_BASE_BAUD (12000000/16)
#define OMAP16XX_BASE_BAUD (48000000/16)
#define OMAP24XX_BASE_BAUD (48000000/16)

/*
* DEBUG_LL port encoding stored into the UART1 scratchpad register by
* decomp_setup in uncompress.h
*/
#define OMAP1UART1 11
#define OMAP1UART2 12
#define OMAP1UART3 13
#define OMAP2UART1 21
#define OMAP2UART2 22
#define OMAP2UART3 23
#define OMAP3UART1 OMAP2UART1
#define OMAP3UART2 OMAP2UART2
#define OMAP3UART3 33
#define OMAP3UART4 34 /* Only on 36xx */
#define OMAP4UART1 OMAP2UART1
#define OMAP4UART2 OMAP2UART2
#define OMAP4UART3 43
#define OMAP4UART4 44
#define ZOOM_UART 95 /* Only on zoom2/3 */

/* This is only used by 8250.c for omap1510 */
#define is_omap_port(pt) ({int __ret = 0; \
if ((pt)->port.mapbase == OMAP1_UART1_BASE || \
Expand Down
Loading

0 comments on commit 761bb60

Please sign in to comment.