xref: /linux/arch/mips/ath25/early_printk.c (revision 3eb66e91a25497065c5322b1268cbc3953642227)
18aaa7278SSergey Ryazanov /*
28aaa7278SSergey Ryazanov  * This file is subject to the terms and conditions of the GNU General Public
38aaa7278SSergey Ryazanov  * License.  See the file "COPYING" in the main directory of this archive
48aaa7278SSergey Ryazanov  * for more details.
58aaa7278SSergey Ryazanov  *
68aaa7278SSergey Ryazanov  * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
78aaa7278SSergey Ryazanov  */
88aaa7278SSergey Ryazanov 
98aaa7278SSergey Ryazanov #include <linux/mm.h>
108aaa7278SSergey Ryazanov #include <linux/io.h>
118aaa7278SSergey Ryazanov #include <linux/serial_reg.h>
12*5c93316cSAlexander Sverdlin #include <asm/setup.h>
138aaa7278SSergey Ryazanov 
148aaa7278SSergey Ryazanov #include "devices.h"
158aaa7278SSergey Ryazanov #include "ar2315_regs.h"
168aaa7278SSergey Ryazanov #include "ar5312_regs.h"
178aaa7278SSergey Ryazanov 
prom_uart_wr(void __iomem * base,unsigned reg,unsigned char ch)188aaa7278SSergey Ryazanov static inline void prom_uart_wr(void __iomem *base, unsigned reg,
198aaa7278SSergey Ryazanov 				unsigned char ch)
208aaa7278SSergey Ryazanov {
218aaa7278SSergey Ryazanov 	__raw_writel(ch, base + 4 * reg);
228aaa7278SSergey Ryazanov }
238aaa7278SSergey Ryazanov 
prom_uart_rr(void __iomem * base,unsigned reg)248aaa7278SSergey Ryazanov static inline unsigned char prom_uart_rr(void __iomem *base, unsigned reg)
258aaa7278SSergey Ryazanov {
268aaa7278SSergey Ryazanov 	return __raw_readl(base + 4 * reg);
278aaa7278SSergey Ryazanov }
288aaa7278SSergey Ryazanov 
prom_putchar(char ch)29*5c93316cSAlexander Sverdlin void prom_putchar(char ch)
308aaa7278SSergey Ryazanov {
318aaa7278SSergey Ryazanov 	static void __iomem *base;
328aaa7278SSergey Ryazanov 
338aaa7278SSergey Ryazanov 	if (unlikely(base == NULL)) {
348aaa7278SSergey Ryazanov 		if (is_ar2315())
358aaa7278SSergey Ryazanov 			base = (void __iomem *)(KSEG1ADDR(AR2315_UART0_BASE));
368aaa7278SSergey Ryazanov 		else
378aaa7278SSergey Ryazanov 			base = (void __iomem *)(KSEG1ADDR(AR5312_UART0_BASE));
388aaa7278SSergey Ryazanov 	}
398aaa7278SSergey Ryazanov 
408aaa7278SSergey Ryazanov 	while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
418aaa7278SSergey Ryazanov 		;
42*5c93316cSAlexander Sverdlin 	prom_uart_wr(base, UART_TX, (unsigned char)ch);
438aaa7278SSergey Ryazanov 	while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
448aaa7278SSergey Ryazanov 		;
458aaa7278SSergey Ryazanov }
46