blob: 6109e6058e5b3eb80cd9e58a8e871e760cc4f245 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Dmitry Eremin-Solenikove6131fa2014-11-06 10:20:23 +03002/* arch/arm/include/debug/sa1100.S
Russell Kinga09e64f2008-08-05 16:14:15 +01003 *
4 * Debugging macro include header
5 *
6 * Copyright (C) 1994-1999 Russell King
7 * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
Russell Kinga09e64f2008-08-05 16:14:15 +01008*/
Dmitry Eremin-Solenikove6131fa2014-11-06 10:20:23 +03009
10#define UTCR3 0x0c
11#define UTDR 0x14
12#define UTSR1 0x20
13#define UTCR3_TXE 0x00000002 /* Transmit Enable */
14#define UTSR1_TBY 0x00000001 /* Transmitter BusY (read) */
15#define UTSR1_TNF 0x00000004 /* Transmit FIFO Not Full (read) */
Russell Kinga09e64f2008-08-05 16:14:15 +010016
Nicolas Pitre639da5e2011-08-31 22:55:46 -040017 .macro addruart, rp, rv, tmp
Jeremy Kerr0ea12932010-07-06 18:30:06 +080018 mrc p15, 0, \rp, c1, c0
19 tst \rp, #1 @ MMU enabled?
20 moveq \rp, #0x80000000 @ physical base address
21 movne \rp, #0xf8000000 @ virtual address
Russell Kinga09e64f2008-08-05 16:14:15 +010022
23 @ We probe for the active serial port here, coherently with
24 @ the comment in arch/arm/mach-sa1100/include/mach/uncompress.h.
25 @ We assume r1 can be clobbered.
26
27 @ see if Ser3 is active
Jeremy Kerr0ea12932010-07-06 18:30:06 +080028 add \rp, \rp, #0x00050000
29 ldr \rv, [\rp, #UTCR3]
30 tst \rv, #UTCR3_TXE
Russell Kinga09e64f2008-08-05 16:14:15 +010031
32 @ if Ser3 is inactive, then try Ser1
Jeremy Kerr0ea12932010-07-06 18:30:06 +080033 addeq \rp, \rp, #(0x00010000 - 0x00050000)
34 ldreq \rv, [\rp, #UTCR3]
35 tsteq \rv, #UTCR3_TXE
Russell Kinga09e64f2008-08-05 16:14:15 +010036
37 @ if Ser1 is inactive, then try Ser2
Jeremy Kerr0ea12932010-07-06 18:30:06 +080038 addeq \rp, \rp, #(0x00030000 - 0x00010000)
39 ldreq \rv, [\rp, #UTCR3]
40 tsteq \rv, #UTCR3_TXE
Russell Kinga09e64f2008-08-05 16:14:15 +010041
Jeremy Kerr0ea12932010-07-06 18:30:06 +080042 @ clear top bits, and generate both phys and virt addresses
43 lsl \rp, \rp, #8
44 lsr \rp, \rp, #8
45 orr \rv, \rp, #0xf8000000 @ virtual
46 orr \rp, \rp, #0x80000000 @ physical
47
Russell Kinga09e64f2008-08-05 16:14:15 +010048 .endm
49
50 .macro senduart,rd,rx
51 str \rd, [\rx, #UTDR]
52 .endm
53
54 .macro waituart,rd,rx
551001: ldr \rd, [\rx, #UTSR1]
56 tst \rd, #UTSR1_TNF
57 beq 1001b
58 .endm
59
60 .macro busyuart,rd,rx
611001: ldr \rd, [\rx, #UTSR1]
62 tst \rd, #UTSR1_TBY
63 bne 1001b
64 .endm