d139139322e85358bbcfb63d9ce3345607c8b461
[openwrt/svn-archive/archive.git] / target / linux / ramips / patches-3.14 / 0015-MIPS-ralink-cleanup-early_printk.patch
1 From e410b0069ee7c318a5b556f39b8b16814330a208 Mon Sep 17 00:00:00 2001
2 From: John Crispin <blogic@openwrt.org>
3 Date: Fri, 24 Jan 2014 17:01:17 +0100
4 Subject: [PATCH 15/57] MIPS: ralink: cleanup early_printk
5
6 Add support for the new MT7621/8 SoC and kill ifdefs.
7 Cleanup some whitespace error while we are at it.
8
9 Signed-off-by: John Crispin <blogic@openwrt.org>
10 ---
11 arch/mips/ralink/early_printk.c | 45 ++++++++++++++++++++++++++-------------
12 1 file changed, 30 insertions(+), 15 deletions(-)
13
14 --- a/arch/mips/ralink/early_printk.c
15 +++ b/arch/mips/ralink/early_printk.c
16 @@ -12,21 +12,24 @@
17 #include <asm/addrspace.h>
18
19 #ifdef CONFIG_SOC_RT288X
20 -#define EARLY_UART_BASE 0x300c00
21 +#define EARLY_UART_BASE 0x300c00
22 +#define CHIPID_BASE 0x300004
23 +#elif defined(CONFIG_SOC_MT7621)
24 +#define EARLY_UART_BASE 0x1E000c00
25 +#define CHIPID_BASE 0x1E000004
26 #else
27 -#define EARLY_UART_BASE 0x10000c00
28 +#define EARLY_UART_BASE 0x10000c00
29 +#define CHIPID_BASE 0x10000004
30 #endif
31
32 -#define UART_REG_RX 0x00
33 -#define UART_REG_TX 0x04
34 -#define UART_REG_IER 0x08
35 -#define UART_REG_IIR 0x0c
36 -#define UART_REG_FCR 0x10
37 -#define UART_REG_LCR 0x14
38 -#define UART_REG_MCR 0x18
39 -#define UART_REG_LSR 0x1c
40 +#define MT7628_CHIP_NAME1 0x20203832
41 +
42 +#define UART_REG_TX 0x04
43 +#define UART_REG_LSR 0x14
44 +#define UART_REG_LSR_RT2880 0x1c
45
46 static __iomem void *uart_membase = (__iomem void *) KSEG1ADDR(EARLY_UART_BASE);
47 +static __iomem void *chipid_membase = (__iomem void *) KSEG1ADDR(CHIPID_BASE);
48
49 static inline void uart_w32(u32 val, unsigned reg)
50 {
51 @@ -38,11 +41,23 @@ static inline u32 uart_r32(unsigned reg)
52 return __raw_readl(uart_membase + reg);
53 }
54
55 +static inline int soc_is_mt7628(void)
56 +{
57 + return IS_ENABLED(CONFIG_SOC_MT7620) &&
58 + (__raw_readl(chipid_membase) == MT7628_CHIP_NAME1);
59 +}
60 +
61 void prom_putchar(unsigned char ch)
62 {
63 - while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
64 - ;
65 - uart_w32(ch, UART_REG_TX);
66 - while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
67 - ;
68 + if (IS_ENABLED(CONFIG_SOC_MT7621) || soc_is_mt7628()) {
69 + uart_w32(ch, UART_TX);
70 + while ((uart_r32(UART_REG_LSR) & UART_LSR_THRE) == 0)
71 + ;
72 + } else {
73 + while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0)
74 + ;
75 + uart_w32(ch, UART_REG_TX);
76 + while ((uart_r32(UART_REG_LSR_RT2880) & UART_LSR_THRE) == 0)
77 + ;
78 + }
79 }