aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2016-06-28 15:18:51 -0400
committerFlorian Fainelli <f.fainelli@gmail.com>2016-08-08 14:14:09 -0400
commitd0cf9d8a3c78cf70e3a78e898fdc1b2adea0e6dd (patch)
tree8a2d8e6918cd143da39bdb3953ffe5a853fc751b
parent29b4817d4018df78086157ea3a55c1d9424a7cfc (diff)
ARM: brcmstb: Add earlyprintk support using run-time checks
The SUN_TOP_CTRL_FAMILY_ID register is at a fixed absolute address for all of our supported chips, so utilize its value to determine what the UARTA base address should be based on the value we read. Since the code is called both during decompressor when the MMU is off, and after the MMU has been turned on in the kernel, and we want to do the lookup only once, we use the same technique as tegra.S and have a shared storage location between the decompressor and the kernel. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-rw-r--r--arch/arm/Kconfig.debug14
-rw-r--r--arch/arm/include/debug/brcmstb.S145
-rw-r--r--arch/arm/mach-bcm/brcmstb.c16
3 files changed, 168 insertions, 7 deletions
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index a9693b6987a6..a660508a58bd 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -186,10 +186,11 @@ choice
186 config DEBUG_BRCMSTB_UART 186 config DEBUG_BRCMSTB_UART
187 bool "Use BRCMSTB UART for low-level debug" 187 bool "Use BRCMSTB UART for low-level debug"
188 depends on ARCH_BRCMSTB 188 depends on ARCH_BRCMSTB
189 select DEBUG_UART_8250
190 help 189 help
191 Say Y here if you want the debug print routines to direct 190 Say Y here if you want the debug print routines to direct
192 their output to the first serial port on these devices. 191 their output to the first serial port on these devices. The
192 UART physical and virtual address is automatically provided
193 based on the chip identification register value.
193 194
194 If you have a Broadcom STB chip and would like early print 195 If you have a Broadcom STB chip and would like early print
195 messages to appear over the UART, select this option. 196 messages to appear over the UART, select this option.
@@ -1430,6 +1431,7 @@ config DEBUG_LL_INCLUDE
1430 default "debug/zynq.S" if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1 1431 default "debug/zynq.S" if DEBUG_ZYNQ_UART0 || DEBUG_ZYNQ_UART1
1431 default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART 1432 default "debug/bcm63xx.S" if DEBUG_BCM63XX_UART
1432 default "debug/digicolor.S" if DEBUG_DIGICOLOR_UA0 1433 default "debug/digicolor.S" if DEBUG_DIGICOLOR_UA0
1434 default "debug/brcmstb.S" if DEBUG_BRCMSTB_UART
1433 default "mach/debug-macro.S" 1435 default "mach/debug-macro.S"
1434 1436
1435# Compatibility options for PL01x 1437# Compatibility options for PL01x
@@ -1520,7 +1522,6 @@ config DEBUG_UART_PHYS
1520 default 0xe6e60000 if DEBUG_RCAR_GEN2_SCIF0 1522 default 0xe6e60000 if DEBUG_RCAR_GEN2_SCIF0
1521 default 0xe8008000 if DEBUG_R7S72100_SCIF2 1523 default 0xe8008000 if DEBUG_R7S72100_SCIF2
1522 default 0xf0000be0 if ARCH_EBSA110 1524 default 0xf0000be0 if ARCH_EBSA110
1523 default 0xf040ab00 if DEBUG_BRCMSTB_UART
1524 default 0xf1012000 if DEBUG_MVEBU_UART0_ALTERNATE 1525 default 0xf1012000 if DEBUG_MVEBU_UART0_ALTERNATE
1525 default 0xf1012100 if DEBUG_MVEBU_UART1_ALTERNATE 1526 default 0xf1012100 if DEBUG_MVEBU_UART1_ALTERNATE
1526 default 0xf7fc9000 if DEBUG_BERLIN_UART 1527 default 0xf7fc9000 if DEBUG_BERLIN_UART
@@ -1604,7 +1605,6 @@ config DEBUG_UART_VIRT
1604 default 0xfb009000 if DEBUG_REALVIEW_STD_PORT 1605 default 0xfb009000 if DEBUG_REALVIEW_STD_PORT
1605 default 0xfb00c000 if DEBUG_AT91_SAMA5D4_USART3 1606 default 0xfb00c000 if DEBUG_AT91_SAMA5D4_USART3
1606 default 0xfb10c000 if DEBUG_REALVIEW_PB1176_PORT 1607 default 0xfb10c000 if DEBUG_REALVIEW_PB1176_PORT
1607 default 0xfc40ab00 if DEBUG_BRCMSTB_UART
1608 default 0xfc705000 if DEBUG_ZTE_ZX 1608 default 0xfc705000 if DEBUG_ZTE_ZX
1609 default 0xfcfe8600 if DEBUG_BCM63XX_UART 1609 default 0xfcfe8600 if DEBUG_BCM63XX_UART
1610 default 0xfd000000 if DEBUG_SPEAR3XX || DEBUG_SPEAR13XX 1610 default 0xfd000000 if DEBUG_SPEAR3XX || DEBUG_SPEAR13XX
@@ -1677,8 +1677,7 @@ config DEBUG_UART_8250_WORD
1677 DEBUG_ALPINE_UART0 || \ 1677 DEBUG_ALPINE_UART0 || \
1678 DEBUG_DAVINCI_DMx_UART0 || DEBUG_DAVINCI_DA8XX_UART1 || \ 1678 DEBUG_DAVINCI_DMx_UART0 || DEBUG_DAVINCI_DA8XX_UART1 || \
1679 DEBUG_DAVINCI_DA8XX_UART2 || \ 1679 DEBUG_DAVINCI_DA8XX_UART2 || \
1680 DEBUG_BCM_KONA_UART || DEBUG_RK32_UART2 || \ 1680 DEBUG_BCM_KONA_UART || DEBUG_RK32_UART2
1681 DEBUG_BRCMSTB_UART
1682 1681
1683config DEBUG_UART_8250_PALMCHIP 1682config DEBUG_UART_8250_PALMCHIP
1684 bool "8250 UART is Palmchip BK-310x" 1683 bool "8250 UART is Palmchip BK-310x"
@@ -1697,7 +1696,8 @@ config DEBUG_UNCOMPRESS
1697 bool 1696 bool
1698 depends on ARCH_MULTIPLATFORM || PLAT_SAMSUNG || ARM_SINGLE_ARMV7M 1697 depends on ARCH_MULTIPLATFORM || PLAT_SAMSUNG || ARM_SINGLE_ARMV7M
1699 default y if DEBUG_LL && !DEBUG_OMAP2PLUS_UART && \ 1698 default y if DEBUG_LL && !DEBUG_OMAP2PLUS_UART && \
1700 (!DEBUG_TEGRA_UART || !ZBOOT_ROM) 1699 (!DEBUG_TEGRA_UART || !ZBOOT_ROM) && \
1700 !DEBUG_BRCMSTB_UART
1701 help 1701 help
1702 This option influences the normal decompressor output for 1702 This option influences the normal decompressor output for
1703 multiplatform kernels. Normally, multiplatform kernels disable 1703 multiplatform kernels. Normally, multiplatform kernels disable
diff --git a/arch/arm/include/debug/brcmstb.S b/arch/arm/include/debug/brcmstb.S
new file mode 100644
index 000000000000..9113d7b33ae0
--- /dev/null
+++ b/arch/arm/include/debug/brcmstb.S
@@ -0,0 +1,145 @@
1/*
2 * Copyright (C) 2016 Broadcom
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13#include <linux/serial_reg.h>
14
15/* Physical register offset and virtual register offset */
16#define REG_PHYS_BASE 0xf0000000
17#define REG_VIRT_BASE 0xfc000000
18#define REG_PHYS_ADDR(x) ((x) + REG_PHYS_BASE)
19
20/* Product id can be read from here */
21#define SUN_TOP_CTRL_BASE REG_PHYS_ADDR(0x404000)
22
23#define UARTA_3390 REG_PHYS_ADDR(0x40a900)
24#define UARTA_7250 REG_PHYS_ADDR(0x40b400)
25#define UARTA_7268 REG_PHYS_ADDR(0x40c000)
26#define UARTA_7271 UARTA_7268
27#define UARTA_7364 REG_PHYS_ADDR(0x40b000)
28#define UARTA_7366 UARTA_7364
29#define UARTA_74371 REG_PHYS_ADDR(0x406b00)
30#define UARTA_7439 REG_PHYS_ADDR(0x40a900)
31#define UARTA_7445 REG_PHYS_ADDR(0x40ab00)
32
33#define UART_SHIFT 2
34
35#define checkuart(rp, rv, family_id, family) \
36 /* Load family id */ \
37 ldr rp, =family_id ; \
38 /* Compare SUN_TOP_CTRL value against it */ \
39 cmp rp, rv ; \
40 /* Passed test, load address */ \
41 ldreq rp, =UARTA_##family ; \
42 /* Jump to save UART address */ \
43 beq 91f
44
45 .macro addruart, rp, rv, tmp
46 adr \rp, 99f @ actual addr of 99f
47 ldr \rv, [\rp] @ linked addr is stored there
48 sub \rv, \rv, \rp @ offset between the two
49 ldr \rp, [\rp, #4] @ linked brcmstb_uart_config
50 sub \tmp, \rp, \rv @ actual brcmstb_uart_config
51 ldr \rp, [\tmp] @ Load brcmstb_uart_config
52 cmp \rp, #1 @ needs initialization?
53 bne 100f @ no; go load the addresses
54 mov \rv, #0 @ yes; record init is done
55 str \rv, [\tmp]
56
57 /* Check SUN_TOP_CTRL base */
58 ldr \rp, =SUN_TOP_CTRL_BASE @ load SUN_TOP_CTRL PA
59 ldr \rv, [\rp, #0] @ get register contents
60 and \rv, \rv, #0xffffff00 @ strip revision bits [7:0]
61
62 /* Chip specific detection starts here */
6320: checkuart(\rp, \rv, 0x33900000, 3390)
6421: checkuart(\rp, \rv, 0x72500000, 7250)
6522: checkuart(\rp, \rv, 0x72680000, 7268)
6623: checkuart(\rp, \rv, 0x72710000, 7271)
6724: checkuart(\rp, \rv, 0x73640000, 7364)
6825: checkuart(\rp, \rv, 0x73660000, 7366)
6926: checkuart(\rp, \rv, 0x07437100, 74371)
7027: checkuart(\rp, \rv, 0x74390000, 7439)
7128: checkuart(\rp, \rv, 0x74450000, 7445)
72
73 /* No valid UART found */
7490: mov \rp, #0
75 /* fall through */
76
77 /* Record whichever UART we chose */
7891: str \rp, [\tmp, #4] @ Store in brcmstb_uart_phys
79 cmp \rp, #0 @ Valid UART address?
80 bne 92f @ Yes, go process it
81 str \rp, [\tmp, #8] @ Store 0 in brcmstb_uart_virt
82 b 100f @ Done
8392: and \rv, \rp, #0xffffff @ offset within 16MB section
84 add \rv, \rv, #REG_VIRT_BASE
85 str \rv, [\tmp, #8] @ Store in brcmstb_uart_virt
86 b 100f
87
88 .align
8999: .word .
90 .word brcmstb_uart_config
91 .ltorg
92
93 /* Load previously selected UART address */
94100: ldr \rp, [\tmp, #4] @ Load brcmstb_uart_phys
95 ldr \rv, [\tmp, #8] @ Load brcmstb_uart_virt
96 .endm
97
98 .macro store, rd, rx:vararg
99 str \rd, \rx
100 .endm
101
102 .macro load, rd, rx:vararg
103 ldr \rd, \rx
104 .endm
105
106 .macro senduart,rd,rx
107 store \rd, [\rx, #UART_TX << UART_SHIFT]
108 .endm
109
110 .macro busyuart,rd,rx
1111002: load \rd, [\rx, #UART_LSR << UART_SHIFT]
112 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
113 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
114 bne 1002b
115 .endm
116
117 .macro waituart,rd,rx
118 .endm
119
120/*
121 * Storage for the state maintained by the macros above.
122 *
123 * In the kernel proper, this data is located in arch/arm/mach-bcm/brcmstb.c.
124 * That's because this header is included from multiple files, and we only
125 * want a single copy of the data. In particular, the UART probing code above
126 * assumes it's running using physical addresses. This is true when this file
127 * is included from head.o, but not when included from debug.o. So we need
128 * to share the probe results between the two copies, rather than having
129 * to re-run the probing again later.
130 *
131 * In the decompressor, we put the symbol/storage right here, since common.c
132 * isn't included in the decompressor build. This symbol gets put in .text
133 * even though it's really data, since .data is discarded from the
134 * decompressor. Luckily, .text is writeable in the decompressor, unless
135 * CONFIG_ZBOOT_ROM. That dependency is handled in arch/arm/Kconfig.debug.
136 */
137#if defined(ZIMAGE)
138brcmstb_uart_config:
139 /* Debug UART initialization required */
140 .word 1
141 /* Debug UART physical address */
142 .word 0
143 /* Debug UART virtual address */
144 .word 0
145#endif
diff --git a/arch/arm/mach-bcm/brcmstb.c b/arch/arm/mach-bcm/brcmstb.c
index 99a67cfb7c0d..07e3a86c6466 100644
--- a/arch/arm/mach-bcm/brcmstb.c
+++ b/arch/arm/mach-bcm/brcmstb.c
@@ -19,6 +19,22 @@
19#include <asm/mach-types.h> 19#include <asm/mach-types.h>
20#include <asm/mach/arch.h> 20#include <asm/mach/arch.h>
21 21
22/*
23 * Storage for debug-macro.S's state.
24 *
25 * This must be in .data not .bss so that it gets initialized each time the
26 * kernel is loaded. The data is declared here rather than debug-macro.S so
27 * that multiple inclusions of debug-macro.S point at the same data.
28 */
29u32 brcmstb_uart_config[3] = {
30 /* Debug UART initialization required */
31 1,
32 /* Debug UART physical address */
33 0,
34 /* Debug UART virtual address */
35 0,
36};
37
22static void __init brcmstb_init_irq(void) 38static void __init brcmstb_init_irq(void)
23{ 39{
24 irqchip_init(); 40 irqchip_init();