1 // SPDX-License-Identifier: GPL-2.0
3 * 16550 compatible uart based serial debug support for zboot
6 #include <linux/types.h>
7 #include <linux/serial_reg.h>
9 #include <asm/addrspace.h>
11 #if defined(CONFIG_MACH_LOONGSON64) || defined(CONFIG_MIPS_MALTA)
12 #define UART_BASE 0x1fd003f8
13 #define PORT(offset) (CKSEG1ADDR(UART_BASE) + (offset))
16 #ifdef CONFIG_MACH_INGENIC
17 #define INGENIC_UART_BASE_ADDR (0x10030000 + 0x1000 * CONFIG_ZBOOT_INGENIC_UART)
18 #define PORT(offset) (CKSEG1ADDR(INGENIC_UART_BASE_ADDR) + (4 * offset))
26 #error please define the serial port address for your own machine
29 static inline unsigned int serial_in(int offset)
31 return *((volatile IOTYPE *)PORT(offset)) & 0xFF;
34 static inline void serial_out(int offset, int value)
36 *((volatile IOTYPE *)PORT(offset)) = value & 0xFF;
41 int timeout = 1000000;
43 while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
46 serial_out(UART_TX, c);