diff options
author | John Crispin <blogic@openwrt.org> | 2014-01-24 11:01:17 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2014-11-24 01:45:24 -0500 |
commit | a097b13c52a3607123d9c65534b7befe493c6d84 (patch) | |
tree | 161b9bd8abce223f98a28fa848b9a98361d08b31 /arch/mips | |
parent | f576fb6a0700c76a68ca7b45a3cfbd70399b24ab (diff) |
MIPS: ralink: cleanup early_printk
Add support for the new MT7621/8 SoC and kill ifdefs.
Cleanup some whitespace error while we are at it.
Signed-off-by: John Crispin <blogic@openwrt.org>
Patchwork: http://patchwork.linux-mips.org/patch/8028/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips')
-rw-r--r-- | arch/mips/ralink/early_printk.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/arch/mips/ralink/early_printk.c b/arch/mips/ralink/early_printk.c index b46d0419d09b..255d695ec8c6 100644 --- a/arch/mips/ralink/early_printk.c +++ b/arch/mips/ralink/early_printk.c | |||
@@ -12,21 +12,24 @@ | |||
12 | #include <asm/addrspace.h> | 12 | #include <asm/addrspace.h> |
13 | 13 | ||
14 | #ifdef CONFIG_SOC_RT288X | 14 | #ifdef CONFIG_SOC_RT288X |
15 | #define EARLY_UART_BASE 0x300c00 | 15 | #define EARLY_UART_BASE 0x300c00 |
16 | #define CHIPID_BASE 0x300004 | ||
17 | #elif defined(CONFIG_SOC_MT7621) | ||
18 | #define EARLY_UART_BASE 0x1E000c00 | ||
19 | #define CHIPID_BASE 0x1E000004 | ||
16 | #else | 20 | #else |
17 | #define EARLY_UART_BASE 0x10000c00 | 21 | #define EARLY_UART_BASE 0x10000c00 |
22 | #define CHIPID_BASE 0x10000004 | ||
18 | #endif | 23 | #endif |
19 | 24 | ||
20 | #define UART_REG_RX 0x00 | 25 | #define MT7628_CHIP_NAME1 0x20203832 |
21 | #define UART_REG_TX 0x04 | 26 | |
22 | #define UART_REG_IER 0x08 | 27 | #define UART_REG_TX 0x04 |
23 | #define UART_REG_IIR 0x0c | 28 | #define UART_REG_LSR 0x14 |
24 | #define UART_REG_FCR 0x10 | 29 | #define UART_REG_LSR_RT2880 0x1c |
25 | #define UART_REG_LCR 0x14 | ||
26 | #define UART_REG_MCR 0x18 | ||
27 | #define UART_REG_LSR 0x1c | ||
28 | 30 | ||
29 | static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE); | 31 | static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE); |
32 | static __iomem void *chipid_membase = (__iomem void *) KSEG1ADDR(CHIPID_BASE); | ||
30 | 33 | ||
31 | static inline void uart_w32(u32 val, unsigned reg) | 34 | static inline void uart_w32(u32 val, unsigned reg) |
32 | { | 35 | { |
@@ -38,11 +41,23 @@ static inline u32 uart_r32(unsigned reg) | |||
38 | return __raw_readl(uart_membase + reg); | 41 | return __raw_readl(uart_membase + reg); |
39 | } | 42 | } |
40 | 43 | ||
44 | static inline int soc_is_mt7628(void) | ||
45 | { | ||
46 | return IS_ENABLED(CONFIG_SOC_MT7620) && | ||
47 | (__raw_readl(chipid_membase) == MT7628_CHIP_NAME1); | ||
48 | } | ||
49 | |||
41 | void prom_putchar(unsigned char ch) | 50 | void prom_putchar(unsigned char ch) |
42 | { | 51 | { |
43 | while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0) | 52 | if (IS_ENABLED(CONFIG_SOC_MT7621) || soc_is_mt7628()) { |
44 | ; | 53 | uart_w32(ch, UART_TX); |
45 | uart_w32(ch, UART_REG_TX); | 54 | while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0) |
46 | while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0) | 55 | ; |
47 | ; | 56 | } else { |
57 | while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0) | ||
58 | ; | ||
59 | uart_w32(ch, UART_REG_TX); | ||
60 | while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0) | ||
61 | ; | ||
62 | } | ||
48 | } | 63 | } |