2 * linux/arch/unicore32/kernel/debug-macro.S
4 * Code specific to PKUnity SoC and UniCore ISA
6 * Copyright (C) 2001-2010 GUAN Xue-tao
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Debugging macro include header
14 #include <generated/asm-offsets.h>
15 #include <mach/hardware.h>
17 .macro put_word_ocd, rd, rx=r16
18 1001: movc \rx, p1.c0, #0
24 #ifdef CONFIG_DEBUG_OCD
25 /* debug using UniCore On-Chip-Debugger */
29 .macro senduart, rd, rx
33 .macro busyuart, rd, rx
36 .macro waituart, rd, rx
39 #define UART_CLK_DEFAULT 3686400 * 20
40 /* Uartclk = MCLK/ 2, The MCLK on my board is 3686400 * 40 */
41 #define BAUD_RATE_DEFAULT 115200
42 /* The baud rate of the serial port */
44 #define UART_DIVISOR_DEFAULT (UART_CLK_DEFAULT \
45 / (16 * BAUD_RATE_DEFAULT) - 1)
48 mrc p0, #0, \rx, c1, c0
49 tst \rx, #1 @ MMU enabled?
50 moveq \rx, #0xee000000 @ physical base address
51 movne \rx, #0x6e000000 @ virtual address
53 @ We probe for the active serial port here
54 @ However, now we assume UART0 is active: epip4d
55 @ We assume r1 and r2 can be clobbered.
57 movl r2, #UART_DIVISOR_DEFAULT
59 str r1, [\rx, #UART_LCR_OFFSET]
62 str r1, [\rx, #UART_DLH_OFFSET]
64 str r1, [\rx, #UART_DLL_OFFSET]
66 str r1, [\rx, #UART_FCR_OFFSET]
68 str r1, [\rx, #UART_LCR_OFFSET]
70 str r1, [\rx, #UART_IER_OFFSET]
74 str \rd, [\rx, #UART_THR_OFFSET]
78 1001: ldr \rd, [\rx, #UART_LSR_OFFSET]
79 tst \rd, #UART_LSR_THRE
84 1001: ldr \rd, [\rx, #UART_LSR_OFFSET]
85 tst \rd, #UART_LSR_TEMT