| 1 | /* |
| 2 | * Ralink RT3662/RT3883 SoC early printk support |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/io.h> |
| 12 | #include <linux/serial_reg.h> |
| 13 | |
| 14 | #include <asm/addrspace.h> |
| 15 | |
| 16 | #include <asm/mach-ralink/rt3883_regs.h> |
| 17 | |
| 18 | #define UART_READ(r) \ |
| 19 | __raw_readl((void __iomem *)(KSEG1ADDR(RT3883_UART1_BASE) + 4 * (r))) |
| 20 | |
| 21 | #define UART_WRITE(r, v) \ |
| 22 | __raw_writel((v), (void __iomem *)(KSEG1ADDR(RT3883_UART1_BASE) + 4 * (r))) |
| 23 | |
| 24 | void prom_putchar(unsigned char ch) |
| 25 | { |
| 26 | while (((UART_READ(RT3883_UART_REG_LSR)) & UART_LSR_THRE) == 0); |
| 27 | UART_WRITE(RT3883_UART_REG_TX, ch); |
| 28 | while (((UART_READ(RT3883_UART_REG_LSR)) & UART_LSR_THRE) == 0); |
| 29 | } |
| 30 | |