Merge tag 'mmc-v5.2-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
[sfrench/cifs-2.6.git] / arch / mips / loongson64 / common / early_printk.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*  early printk support
3  *
4  *  Copyright (c) 2009 Philippe Vachon <philippe@cowpig.ca>
5  *  Copyright (c) 2009 Lemote Inc.
6  *  Author: Wu Zhangjin, wuzhangjin@gmail.com
7  */
8 #include <linux/serial_reg.h>
9 #include <asm/setup.h>
10
11 #include <loongson.h>
12
13 #define PORT(base, offset) (u8 *)(base + offset)
14
15 static inline unsigned int serial_in(unsigned char *base, int offset)
16 {
17         return readb(PORT(base, offset));
18 }
19
20 static inline void serial_out(unsigned char *base, int offset, int value)
21 {
22         writeb(value, PORT(base, offset));
23 }
24
25 void prom_putchar(char c)
26 {
27         int timeout;
28         unsigned char *uart_base;
29
30         uart_base = (unsigned char *)_loongson_uart_base[0];
31         timeout = 1024;
32
33         while (((serial_in(uart_base, UART_LSR) & UART_LSR_THRE) == 0) &&
34                         (timeout-- > 0))
35                 ;
36
37         serial_out(uart_base, UART_TX, c);
38 }