Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is subject to the terms and conditions of the GNU General Public
0003  * License.  See the file "COPYING" in the main directory of this archive
0004  * for more details.
0005  *
0006  * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
0007  */
0008 
0009 #include <linux/mm.h>
0010 #include <linux/io.h>
0011 #include <linux/serial_reg.h>
0012 #include <asm/setup.h>
0013 
0014 #include "devices.h"
0015 #include "ar2315_regs.h"
0016 #include "ar5312_regs.h"
0017 
0018 static inline void prom_uart_wr(void __iomem *base, unsigned reg,
0019                 unsigned char ch)
0020 {
0021     __raw_writel(ch, base + 4 * reg);
0022 }
0023 
0024 static inline unsigned char prom_uart_rr(void __iomem *base, unsigned reg)
0025 {
0026     return __raw_readl(base + 4 * reg);
0027 }
0028 
0029 void prom_putchar(char ch)
0030 {
0031     static void __iomem *base;
0032 
0033     if (unlikely(base == NULL)) {
0034         if (is_ar2315())
0035             base = (void __iomem *)(KSEG1ADDR(AR2315_UART0_BASE));
0036         else
0037             base = (void __iomem *)(KSEG1ADDR(AR5312_UART0_BASE));
0038     }
0039 
0040     while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
0041         ;
0042     prom_uart_wr(base, UART_TX, (unsigned char)ch);
0043     while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0)
0044         ;
0045 }