1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/kernel/debug-macro.S
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
9 * Debugging macro include header
11 #include <generated/asm-offsets.h>
12 #include <mach/hardware.h>
14 .macro put_word_ocd, rd, rx=r16
15 1001: movc \rx, p1.c0, #0
21 #ifdef CONFIG_DEBUG_OCD
22 /* debug using UniCore On-Chip-Debugger */
26 .macro senduart, rd, rx
30 .macro busyuart, rd, rx
33 .macro waituart, rd, rx
36 #define UART_CLK_DEFAULT 3686400 * 20
37 /* Uartclk = MCLK/ 2, The MCLK on my board is 3686400 * 40 */
38 #define BAUD_RATE_DEFAULT 115200
39 /* The baud rate of the serial port */
41 #define UART_DIVISOR_DEFAULT (UART_CLK_DEFAULT \
42 / (16 * BAUD_RATE_DEFAULT) - 1)
45 mrc p0, #0, \rx, c1, c0
46 tst \rx, #1 @ MMU enabled?
47 moveq \rx, #0xee000000 @ physical base address
48 movne \rx, #0x6e000000 @ virtual address
50 @ We probe for the active serial port here
51 @ However, now we assume UART0 is active: epip4d
52 @ We assume r1 and r2 can be clobbered.
54 movl r2, #UART_DIVISOR_DEFAULT
56 str r1, [\rx, #UART_LCR_OFFSET]
59 str r1, [\rx, #UART_DLH_OFFSET]
61 str r1, [\rx, #UART_DLL_OFFSET]
63 str r1, [\rx, #UART_FCR_OFFSET]
65 str r1, [\rx, #UART_LCR_OFFSET]
67 str r1, [\rx, #UART_IER_OFFSET]
71 str \rd, [\rx, #UART_THR_OFFSET]
75 1001: ldr \rd, [\rx, #UART_LSR_OFFSET]
76 tst \rd, #UART_LSR_THRE
81 1001: ldr \rd, [\rx, #UART_LSR_OFFSET]
82 tst \rd, #UART_LSR_TEMT