xref: /linux/arch/mips/lantiq/early_printk.c (revision bd628c1bed7902ec1f24ba0fe70758949146abbe)
1 /*
2  *  This program is free software; you can redistribute it and/or modify it
3  *  under the terms of the GNU General Public License version 2 as published
4  *  by the Free Software Foundation.
5  *
6  *  Copyright (C) 2010 John Crispin <john@phrozen.org>
7  */
8 
9 #include <linux/cpu.h>
10 #include <lantiq_soc.h>
11 #include <asm/setup.h>
12 
13 #define ASC_BUF		1024
14 #define LTQ_ASC_FSTAT	((u32 *)(LTQ_EARLY_ASC + 0x0048))
15 #ifdef __BIG_ENDIAN
16 #define LTQ_ASC_TBUF	((u32 *)(LTQ_EARLY_ASC + 0x0020 + 3))
17 #else
18 #define LTQ_ASC_TBUF	((u32 *)(LTQ_EARLY_ASC + 0x0020))
19 #endif
20 #define TXMASK		0x3F00
21 #define TXOFFSET	8
22 
23 void prom_putchar(char c)
24 {
25 	unsigned long flags;
26 
27 	local_irq_save(flags);
28 	do { } while ((ltq_r32(LTQ_ASC_FSTAT) & TXMASK) >> TXOFFSET);
29 	if (c == '\n')
30 		ltq_w8('\r', LTQ_ASC_TBUF);
31 	ltq_w8(c, LTQ_ASC_TBUF);
32 	local_irq_restore(flags);
33 }
34