| 1 | --- /dev/null |
| 2 | +++ b/arch/mips/ar231x/early_printk.c |
| 3 | @@ -0,0 +1,44 @@ |
| 4 | +/* |
| 5 | + * This file is subject to the terms and conditions of the GNU General Public |
| 6 | + * License. See the file "COPYING" in the main directory of this archive |
| 7 | + * for more details. |
| 8 | + * |
| 9 | + * Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org> |
| 10 | + */ |
| 11 | + |
| 12 | +#include <linux/mm.h> |
| 13 | +#include <linux/io.h> |
| 14 | +#include <linux/serial_reg.h> |
| 15 | +#include <asm/addrspace.h> |
| 16 | + |
| 17 | +#include <asm/mach-ar231x/ar2315_regs.h> |
| 18 | +#include <asm/mach-ar231x/ar5312_regs.h> |
| 19 | +#include "devices.h" |
| 20 | + |
| 21 | +static inline void prom_uart_wr(void __iomem *base, unsigned reg, |
| 22 | + unsigned char ch) |
| 23 | +{ |
| 24 | + __raw_writeb(ch, base + 4 * reg); |
| 25 | +} |
| 26 | + |
| 27 | +static inline unsigned char prom_uart_rr(void __iomem *base, unsigned reg) |
| 28 | +{ |
| 29 | + return __raw_readb(base + 4 * reg); |
| 30 | +} |
| 31 | + |
| 32 | +void prom_putchar(unsigned char ch) |
| 33 | +{ |
| 34 | + static void __iomem *base; |
| 35 | + |
| 36 | + if (unlikely(base == NULL)) { |
| 37 | + if (is_2315()) |
| 38 | + base = (void __iomem *)(KSEG1ADDR(AR2315_UART0)); |
| 39 | + else |
| 40 | + base = (void __iomem *)(KSEG1ADDR(AR531X_UART0)); |
| 41 | + } |
| 42 | + |
| 43 | + while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0); |
| 44 | + prom_uart_wr(base, UART_TX, ch); |
| 45 | + while ((prom_uart_rr(base, UART_LSR) & UART_LSR_THRE) == 0); |
| 46 | +} |
| 47 | + |
| 48 | --- a/arch/mips/ar231x/Makefile |
| 49 | +++ b/arch/mips/ar231x/Makefile |
| 50 | @@ -9,5 +9,8 @@ |
| 51 | # |
| 52 | |
| 53 | obj-y += board.o prom.o devices.o |
| 54 | + |
| 55 | +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
| 56 | + |
| 57 | obj-$(CONFIG_ATHEROS_AR5312) += ar5312.o |
| 58 | obj-$(CONFIG_ATHEROS_AR2315) += ar2315.o |
| 59 | --- a/arch/mips/Kconfig |
| 60 | +++ b/arch/mips/Kconfig |
| 61 | @@ -106,6 +106,7 @@ config ATHEROS_AR231X |
| 62 | select SYS_SUPPORTS_BIG_ENDIAN |
| 63 | select SYS_SUPPORTS_32BIT_KERNEL |
| 64 | select GENERIC_GPIO |
| 65 | + select SYS_HAS_EARLY_PRINTK |
| 66 | help |
| 67 | Support for AR231x and AR531x based boards |
| 68 | |
| 69 | |