xref: /linux-6.15/arch/arm/include/debug/omap2plus.S (revision 2d1f7d2e)
1/*
2 * Debugging macro include header
3 *
4 *  Copyright (C) 1994-1999 Russell King
5 *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11*/
12
13#include <linux/serial_reg.h>
14
15/* OMAP3 serial ports */
16#define OMAP3_UART4_AM35XX_BASE	0x4809E000	/* Only on AM35xx */
17
18/* AM3505/3517 UART4 */
19#define AM35XX_UART4_BASE	0x4809E000	/* Only on AM3505/3517 */
20
21/* AM33XX serial port */
22#define AM33XX_UART1_BASE	0x44E09000
23
24/* External port on Zoom2/3 */
25#define ZOOM_UART_BASE		0x10000000
26#define ZOOM_UART_VIRT		0xfa400000
27
28#define OMAP_PORT_SHIFT		2
29#define ZOOM_PORT_SHIFT		1
30
31#define UART_OFFSET(addr)	((addr) & 0x00ffffff)
32
33		.pushsection .data
34omap_uart_phys:	.word	0
35omap_uart_virt:	.word	0
36omap_uart_lsr:	.word	0
37		.popsection
38
39		.macro	addruart, rp, rv, tmp
40
41		/* Use omap_uart_phys/virt if already configured */
4210:		adr	\rp, 99f		@ get effective addr of 99f
43		ldr	\rv, [\rp]		@ get absolute addr of 99f
44		sub	\rv, \rv, \rp		@ offset between the two
45		ldr	\rp, [\rp, #4]		@ abs addr of omap_uart_phys
46		sub	\tmp, \rp, \rv		@ make it effective
47		ldr	\rp, [\tmp, #0]		@ omap_uart_phys
48		ldr	\rv, [\tmp, #4]		@ omap_uart_virt
49		cmp	\rp, #0			@ is port configured?
50		cmpne	\rv, #0
51		bne	100f			@ already configured
52
53		/* Configure the UART offset from the phys/virt base */
54#ifdef CONFIG_DEBUG_AM33XXUART1
55		ldr	\rp, =AM33XX_UART1_BASE
56		and	\rp, \rp, #0x00ffffff
57		b	97f
58#endif
59#ifdef CONFIG_DEBUG_ZOOM_UART
60		ldr	\rp, =ZOOM_UART_BASE
61		str	\rp, [\tmp, #0]		@ omap_uart_phys
62		ldr	\rp, =ZOOM_UART_VIRT
63		str	\rp, [\tmp, #4]		@ omap_uart_virt
64		mov	\rp, #(UART_LSR << ZOOM_PORT_SHIFT)
65		str	\rp, [\tmp, #8]		@ omap_uart_lsr
66#endif
67		b	10b
68
69		/* AM33XX: Store both phys and virt address for the uart */
7097:		add	\rp, \rp, #0x44000000	@ phys base
71		str	\rp, [\tmp, #0]		@ omap_uart_phys
72		sub	\rp, \rp, #0x44000000	@ phys base
73		add	\rp, \rp, #0xf9000000	@ virt base
74		str	\rp, [\tmp, #4]		@ omap_uart_virt
75		mov	\rp, #(UART_LSR << OMAP_PORT_SHIFT)
76		str	\rp, [\tmp, #8]		@ omap_uart_lsr
77
78		b	10b
79
80		.align
8199:		.word	.
82		.word	omap_uart_phys
83		.ltorg
84
85100:		/* Pass the UART_LSR reg address */
86		ldr	\tmp, [\tmp, #8]	@ omap_uart_lsr
87		add	\rp, \rp, \tmp
88		add	\rv, \rv, \tmp
89		.endm
90
91		.macro	senduart,rd,rx
92		orr	\rd, \rd, \rx, lsl #24	@ preserve LSR reg offset
93		bic	\rx, \rx, #0xff		@ get base (THR) reg address
94		strb	\rd, [\rx]		@ send lower byte of rd
95		orr	\rx, \rx, \rd, lsr #24	@ restore original rx (LSR)
96		bic	\rd, \rd, #(0xff << 24)	@ restore original rd
97		.endm
98
99		.macro	busyuart,rd,rx
1001001:		ldrb	\rd, [\rx]		@ rx contains UART_LSR address
101		and	\rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
102		teq	\rd, #(UART_LSR_TEMT | UART_LSR_THRE)
103		bne	1001b
104		.endm
105
106		.macro	waituart,rd,rx
107		.endm
108