Gabor Juhos | d4a67d9 | 2011-01-04 21:28:14 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Atheros AR71XX/AR724X/AR913X SoC early printk support |
| 3 | * |
| 4 | * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published |
| 9 | * by the Free Software Foundation. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/io.h> |
| 13 | #include <linux/serial_reg.h> |
| 14 | #include <asm/addrspace.h> |
| 15 | |
| 16 | #include <asm/mach-ath79/ar71xx_regs.h> |
| 17 | |
| 18 | static inline void prom_wait_thre(void __iomem *base) |
| 19 | { |
| 20 | u32 lsr; |
| 21 | |
| 22 | do { |
| 23 | lsr = __raw_readl(base + UART_LSR * 4); |
| 24 | if (lsr & UART_LSR_THRE) |
| 25 | break; |
| 26 | } while (1); |
| 27 | } |
| 28 | |
| 29 | void prom_putchar(unsigned char ch) |
| 30 | { |
| 31 | void __iomem *base = (void __iomem *)(KSEG1ADDR(AR71XX_UART_BASE)); |
| 32 | |
| 33 | prom_wait_thre(base); |
| 34 | __raw_writel(ch, base + UART_TX * 4); |
| 35 | prom_wait_thre(base); |
| 36 | } |