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