xref: /linux-6.15/arch/arm/include/debug/omap2plus.S (revision d2b310b0)
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_UART3_BASE	0x49020000
17#define OMAP3_UART4_BASE	0x49042000	/* Only on 36xx */
18#define OMAP3_UART4_AM35XX_BASE	0x4809E000	/* Only on AM35xx */
19
20/* OMAP4 serial ports */
21#define OMAP4_UART3_BASE	0x48020000
22#define OMAP4_UART4_BASE	0x4806e000
23
24/* TI81XX serial ports */
25#define TI81XX_UART1_BASE	0x48020000
26#define TI81XX_UART2_BASE	0x48022000
27#define TI81XX_UART3_BASE	0x48024000
28
29/* AM3505/3517 UART4 */
30#define AM35XX_UART4_BASE	0x4809E000	/* Only on AM3505/3517 */
31
32/* AM33XX serial port */
33#define AM33XX_UART1_BASE	0x44E09000
34
35/* OMAP5 serial ports */
36#define OMAP5_UART3_BASE	OMAP4_UART3_BASE
37#define OMAP5_UART4_BASE	OMAP4_UART4_BASE
38#define OMAP5_UART5_BASE	0x48066000
39#define OMAP5_UART6_BASE	0x48068000
40
41/* External port on Zoom2/3 */
42#define ZOOM_UART_BASE		0x10000000
43#define ZOOM_UART_VIRT		0xfa400000
44
45#define OMAP_PORT_SHIFT		2
46#define ZOOM_PORT_SHIFT		1
47
48#define UART_OFFSET(addr)	((addr) & 0x00ffffff)
49
50		.pushsection .data
51omap_uart_phys:	.word	0
52omap_uart_virt:	.word	0
53omap_uart_lsr:	.word	0
54		.popsection
55
56		.macro	addruart, rp, rv, tmp
57
58		/* Use omap_uart_phys/virt if already configured */
5910:		adr	\rp, 99f		@ get effective addr of 99f
60		ldr	\rv, [\rp]		@ get absolute addr of 99f
61		sub	\rv, \rv, \rp		@ offset between the two
62		ldr	\rp, [\rp, #4]		@ abs addr of omap_uart_phys
63		sub	\tmp, \rp, \rv		@ make it effective
64		ldr	\rp, [\tmp, #0]		@ omap_uart_phys
65		ldr	\rv, [\tmp, #4]		@ omap_uart_virt
66		cmp	\rp, #0			@ is port configured?
67		cmpne	\rv, #0
68		bne	100f			@ already configured
69
70		/* Configure the UART offset from the phys/virt base */
71#ifdef CONFIG_DEBUG_OMAP3UART3
72		mov	\rp, #UART_OFFSET(OMAP3_UART1_BASE)
73		add	\rp, \rp, #0x00fb0000
74		add	\rp, \rp, #0x00006000		@ OMAP3_UART3_BASE
75		b	98f
76#endif
77#ifdef CONFIG_DEBUG_OMAP4UART3
78		mov	\rp, #UART_OFFSET(OMAP4_UART3_BASE)
79		b	98f
80#endif
81#ifdef CONFIG_DEBUG_OMAP3UART4
82		mov	\rp, #UART_OFFSET(OMAP3_UART1_BASE)
83		add	\rp, \rp, #0x00fb0000
84		add	\rp, \rp, #0x00028000		@ OMAP3_UART4_BASE
85		b	98f
86#endif
87#ifdef CONFIG_DEBUG_OMAP4UART4
88		mov	\rp, #UART_OFFSET(OMAP4_UART4_BASE)
89		b	98f
90#endif
91#ifdef CONFIG_DEBUG_TI81XXUART1
92		mov	\rp, #UART_OFFSET(TI81XX_UART1_BASE)
93		b	98f
94#endif
95#ifdef CONFIG_DEBUG_TI81XXUART2
96		mov	\rp, #UART_OFFSET(TI81XX_UART2_BASE)
97		b	98f
98#endif
99#ifdef CONFIG_DEBUG_TI81XXUART3
100		mov	\rp, #UART_OFFSET(TI81XX_UART3_BASE)
101		b	98f
102#endif
103#ifdef CONFIG_DEBUG_AM33XXUART1
104		ldr	\rp, =AM33XX_UART1_BASE
105		and	\rp, \rp, #0x00ffffff
106		b	97f
107#endif
108#ifdef CONFIG_DEBUG_ZOOM_UART
109		ldr	\rp, =ZOOM_UART_BASE
110		str	\rp, [\tmp, #0]		@ omap_uart_phys
111		ldr	\rp, =ZOOM_UART_VIRT
112		str	\rp, [\tmp, #4]		@ omap_uart_virt
113		mov	\rp, #(UART_LSR << ZOOM_PORT_SHIFT)
114		str	\rp, [\tmp, #8]		@ omap_uart_lsr
115#endif
116		b	10b
117
118		/* AM33XX: Store both phys and virt address for the uart */
11997:		add	\rp, \rp, #0x44000000	@ phys base
120		str	\rp, [\tmp, #0]		@ omap_uart_phys
121		sub	\rp, \rp, #0x44000000	@ phys base
122		add	\rp, \rp, #0xf9000000	@ virt base
123		str	\rp, [\tmp, #4]		@ omap_uart_virt
124		mov	\rp, #(UART_LSR << OMAP_PORT_SHIFT)
125		str	\rp, [\tmp, #8]		@ omap_uart_lsr
126
127		b	10b
128
129		/* Store both phys and virt address for the uart */
13098:		add	\rp, \rp, #0x48000000	@ phys base
131		str	\rp, [\tmp, #0]		@ omap_uart_phys
132		sub	\rp, \rp, #0x48000000	@ phys base
133		add	\rp, \rp, #0xfa000000	@ virt base
134		str	\rp, [\tmp, #4]		@ omap_uart_virt
135		mov	\rp, #(UART_LSR << OMAP_PORT_SHIFT)
136		str	\rp, [\tmp, #8]		@ omap_uart_lsr
137
138		b	10b
139
140		.align
14199:		.word	.
142		.word	omap_uart_phys
143		.ltorg
144
145100:		/* Pass the UART_LSR reg address */
146		ldr	\tmp, [\tmp, #8]	@ omap_uart_lsr
147		add	\rp, \rp, \tmp
148		add	\rv, \rv, \tmp
149		.endm
150
151		.macro	senduart,rd,rx
152		orr	\rd, \rd, \rx, lsl #24	@ preserve LSR reg offset
153		bic	\rx, \rx, #0xff		@ get base (THR) reg address
154		strb	\rd, [\rx]		@ send lower byte of rd
155		orr	\rx, \rx, \rd, lsr #24	@ restore original rx (LSR)
156		bic	\rd, \rd, #(0xff << 24)	@ restore original rd
157		.endm
158
159		.macro	busyuart,rd,rx
1601001:		ldrb	\rd, [\rx]		@ rx contains UART_LSR address
161		and	\rd, \rd, #(UART_LSR_TEMT | UART_LSR_THRE)
162		teq	\rd, #(UART_LSR_TEMT | UART_LSR_THRE)
163		bne	1001b
164		.endm
165
166		.macro	waituart,rd,rx
167		.endm
168