treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / mips / boot / compressed / uart-16550.c
blobaee8d7b8f09143fd8e4ce30a9552bf827ec357e4
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * 16550 compatible uart based serial debug support for zboot
4 */
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))
14 #endif
16 #ifdef CONFIG_AR7
17 #include <ar7.h>
18 #define PORT(offset) (CKSEG1ADDR(AR7_REGS_UART0) + (4 * offset))
19 #endif
21 #ifdef CONFIG_MACH_INGENIC
22 #define INGENIC_UART0_BASE_ADDR 0x10030000
23 #define PORT(offset) (CKSEG1ADDR(INGENIC_UART0_BASE_ADDR) + (4 * offset))
24 #endif
26 #ifdef CONFIG_CPU_XLR
27 #define UART0_BASE 0x1EF14000
28 #define PORT(offset) (CKSEG1ADDR(UART0_BASE) + (4 * offset))
29 #define IOTYPE unsigned int
30 #endif
32 #ifdef CONFIG_CPU_XLP
33 #define UART0_BASE 0x18030100
34 #define PORT(offset) (CKSEG1ADDR(UART0_BASE) + (4 * offset))
35 #define IOTYPE unsigned int
36 #endif
38 #ifndef IOTYPE
39 #define IOTYPE char
40 #endif
42 #ifndef PORT
43 #error please define the serial port address for your own machine
44 #endif
46 static inline unsigned int serial_in(int offset)
48 return *((volatile IOTYPE *)PORT(offset)) & 0xFF;
51 static inline void serial_out(int offset, int value)
53 *((volatile IOTYPE *)PORT(offset)) = value & 0xFF;
56 void putc(char c)
58 int timeout = 1000000;
60 while (((serial_in(UART_LSR) & UART_LSR_THRE) == 0) && (timeout-- > 0))
63 serial_out(UART_TX, c);