2 * Copyright (C) 2015 Imagination Technologies
3 * Author: Paul Burton <paul.burton@mips.com>
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
11 #include <asm/addrspace.h>
13 #include <asm/asm-offsets.h>
14 #include <asm/mipsregs.h>
15 #include <asm/regdef.h>
16 #include <linux/serial_reg.h>
18 #define UART_TX_OFS (UART_TX << CONFIG_MIPS_CPS_NS16550_SHIFT)
19 #define UART_LSR_OFS (UART_LSR << CONFIG_MIPS_CPS_NS16550_SHIFT)
22 * _mips_cps_putc() - write a character to the UART
23 * @a0: ASCII character to write
24 * @t9: UART base address
27 1: lw t0, UART_LSR_OFS(t9)
28 andi t0, t0, UART_LSR_TEMT
30 sb a0, UART_TX_OFS(t9)
35 * _mips_cps_puts() - write a string to the UART
36 * @a0: pointer to NULL-terminated ASCII string
37 * @t9: UART base address
39 * Write a null-terminated ASCII string to the UART.
41 NESTED(_mips_cps_puts, 0, ra)
55 * _mips_cps_putx4 - write a 4b hex value to the UART
56 * @a0: the 4b value to write to the UART
57 * @t9: UART base address
59 * Write a single hexadecimal character to the UART.
61 NESTED(_mips_cps_putx4, 0, ra)
72 * _mips_cps_putx8 - write an 8b hex value to the UART
73 * @a0: the 8b value to write to the UART
74 * @t9: UART base address
76 * Write an 8 bit value (ie. 2 hexadecimal characters) to the UART.
78 NESTED(_mips_cps_putx8, 0, ra)
89 * _mips_cps_putx16 - write a 16b hex value to the UART
90 * @a0: the 16b value to write to the UART
91 * @t9: UART base address
93 * Write a 16 bit value (ie. 4 hexadecimal characters) to the UART.
95 NESTED(_mips_cps_putx16, 0, ra)
103 END(_mips_cps_putx16)
106 * _mips_cps_putx32 - write a 32b hex value to the UART
107 * @a0: the 32b value to write to the UART
108 * @t9: UART base address
110 * Write a 32 bit value (ie. 8 hexadecimal characters) to the UART.
112 NESTED(_mips_cps_putx32, 0, ra)
120 END(_mips_cps_putx32)
125 * _mips_cps_putx64 - write a 64b hex value to the UART
126 * @a0: the 64b value to write to the UART
127 * @t9: UART base address
129 * Write a 64 bit value (ie. 16 hexadecimal characters) to the UART.
131 NESTED(_mips_cps_putx64, 0, ra)
139 END(_mips_cps_putx64)
141 #define _mips_cps_putxlong _mips_cps_putx64
143 #else /* !CONFIG_64BIT */
145 #define _mips_cps_putxlong _mips_cps_putx32
147 #endif /* !CONFIG_64BIT */
150 * mips_cps_bev_dump() - dump relevant exception state to UART
151 * @a0: pointer to NULL-terminated ASCII string naming the exception
153 * Write information that may be useful in debugging an exception to the
154 * UART configured by CONFIG_MIPS_CPS_NS16550_*. As this BEV exception
155 * will only be run if something goes horribly wrong very early during
156 * the bringup of a core and it is very likely to be unsafe to perform
157 * memory accesses at that point (cache state indeterminate, EVA may not
158 * be configured, coherence may be disabled) let alone have a stack,
159 * this is all written in assembly using only registers & unmapped
160 * uncached access to the UART registers.
162 LEAF(mips_cps_bev_dump)
166 li t9, CKSEG1ADDR(CONFIG_MIPS_CPS_NS16550_BASE)
168 PTR_LA a0, str_newline
174 PTR_LA a0, str_newline
176 PTR_LA a0, str_newline
179 #define DUMP_COP0_REG(reg, name, sz, _mfc0) \
181 jal _mips_cps_puts; \
183 jal _mips_cps_putx##sz; \
184 PTR_LA a0, str_newline; \
185 jal _mips_cps_puts; \
188 DUMP_COP0_REG(CP0_CAUSE, "Cause: 0x", 32, mfc0)
189 DUMP_COP0_REG(CP0_STATUS, "Status: 0x", 32, mfc0)
190 DUMP_COP0_REG(CP0_EBASE, "EBase: 0x", long, MFC0)
191 DUMP_COP0_REG(CP0_BADVADDR, "BadVAddr: 0x", long, MFC0)
192 DUMP_COP0_REG(CP0_BADINSTR, "BadInstr: 0x", 32, mfc0)
194 PTR_LA a0, str_newline
197 END(mips_cps_bev_dump)
200 str_bev: .asciiz "BEV Exception: "
201 str_newline: .asciiz "\r\n"