1/*
2 * xen/arch/arm/arm64/debug-pl011.S
3 *
4 * PL011 specific debug code
5 *
6 * Copyright (c) 2013 Citrix Systems.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 */
18
19#include <asm/asm_defns.h>
20
21/*
22 * PL011 UART initialization
23 * xb: register which containts the UART base address
24 * c: scratch register number
25 */
26.macro early_uart_init xb, c
27        mov   x\c, #(7372800 / EARLY_PRINTK_BAUD % 16)
28        strh  w\c, [\xb, #0x28]      /* -> UARTFBRD (Baud divisor fraction) */
29        mov   x\c, #(7372800 / EARLY_PRINTK_BAUD / 16)
30        strh  w\c, [\xb, #0x24]      /* -> UARTIBRD (Baud divisor integer) */
31        mov   x\c, #0x60             /* 8n1 */
32        str   w\c, [\xb, #0x2C]      /* -> UARTLCR_H (Line control) */
33        ldr   x\c, =0x00000301       /* RXE | TXE | UARTEN */
34        str   w\c, [\xb, #0x30]      /* -> UARTCR (Control Register) */
35.endm
36
37/*
38 * PL011 UART wait UART to be ready to transmit
39 * xb: register which contains the UART base address
40 * c: scratch register number
41 */
42.macro early_uart_ready xb, c
431:
44        ldrh  w\c, [\xb, #0x18]      /* <- UARTFR (Flag register) */
45        tst   w\c, #0x8              /* Check BUSY bit */
46        b.ne  1b                     /* Wait for the UART to be ready */
47.endm
48
49/*
50 * PL011 UART transmit character
51 * xb: register which contains the UART base address
52 * wt: register which contains the character to transmit
53 */
54.macro early_uart_transmit xb, wt
55        strb  \wt, [\xb]             /* -> UARTDR (Data Register) */
56.endm
57
58/*
59 * Local variables:
60 * mode: ASM
61 * indent-tabs-mode: nil
62 * End:
63 */
64