1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* early printk support
4 * Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
5 * Copyright (c) 2009 Lemote Inc.
6 * Author: Wu Zhangjin, wuzhangjin@gmail.com
8 #include <linux/serial_reg.h>
13 #define PORT(base, offset) (u8 *)(base + offset)
15 static inline unsigned int serial_in(unsigned char *base, int offset)
17 return readb(PORT(base, offset));
20 static inline void serial_out(unsigned char *base, int offset, int value)
22 writeb(value, PORT(base, offset));
25 void prom_putchar(char c)
28 unsigned char *uart_base;
30 uart_base = (unsigned char *)_loongson_uart_base[0];
33 while (((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) &&
37 serial_out(uart_base, UART_TX, c);