xref: /OK3568_Linux_fs/kernel/arch/mips/bcm63xx/early_printk.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
3*4882a593Smuzhiyun  * License.  See the file "COPYING" in the main directory of this archive
4*4882a593Smuzhiyun  * for more details.
5*4882a593Smuzhiyun  *
6*4882a593Smuzhiyun  * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <bcm63xx_io.h>
10*4882a593Smuzhiyun #include <linux/serial_bcm63xx.h>
11*4882a593Smuzhiyun #include <asm/setup.h>
12*4882a593Smuzhiyun 
wait_xfered(void)13*4882a593Smuzhiyun static void wait_xfered(void)
14*4882a593Smuzhiyun {
15*4882a593Smuzhiyun 	unsigned int val;
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun 	/* wait for any previous char to be transmitted */
18*4882a593Smuzhiyun 	do {
19*4882a593Smuzhiyun 		val = bcm_uart0_readl(UART_IR_REG);
20*4882a593Smuzhiyun 		if (val & UART_IR_STAT(UART_IR_TXEMPTY))
21*4882a593Smuzhiyun 			break;
22*4882a593Smuzhiyun 	} while (1);
23*4882a593Smuzhiyun }
24*4882a593Smuzhiyun 
prom_putchar(char c)25*4882a593Smuzhiyun void prom_putchar(char c)
26*4882a593Smuzhiyun {
27*4882a593Smuzhiyun 	wait_xfered();
28*4882a593Smuzhiyun 	bcm_uart0_writel(c, UART_FIFO_REG);
29*4882a593Smuzhiyun 	wait_xfered();
30*4882a593Smuzhiyun }
31