1
2
3
4
5
6
7
8
9
10
11
12
13 #include <linux/serial_reg.h>
14 #include <asm/cputype.h>
15
16
17 #define REG_PHYS_BASE 0xf0000000
18 #define REG_PHYS_BASE_V7 0x08000000
19 #define REG_VIRT_BASE 0xfc000000
20 #define REG_PHYS_ADDR(x) ((x) + REG_PHYS_BASE)
21 #define REG_PHYS_ADDR_V7(x) ((x) + REG_PHYS_BASE_V7)
22
23
24 #define SUN_TOP_CTRL_BASE REG_PHYS_ADDR(0x404000)
25 #define SUN_TOP_CTRL_BASE_V7 REG_PHYS_ADDR_V7(0x404000)
26
27 #define UARTA_3390 REG_PHYS_ADDR(0x40a900)
28 #define UARTA_7250 REG_PHYS_ADDR(0x40b400)
29 #define UARTA_7255 REG_PHYS_ADDR(0x40c000)
30 #define UARTA_7260 UARTA_7255
31 #define UARTA_7268 UARTA_7255
32 #define UARTA_7271 UARTA_7268
33 #define UARTA_7278 REG_PHYS_ADDR_V7(0x40c000)
34 #define UARTA_7364 REG_PHYS_ADDR(0x40b000)
35 #define UARTA_7366 UARTA_7364
36 #define UARTA_74371 REG_PHYS_ADDR(0x406b00)
37 #define UARTA_7439 REG_PHYS_ADDR(0x40a900)
38 #define UARTA_7445 REG_PHYS_ADDR(0x40ab00)
39
40 #define UART_SHIFT 2
41
42 #define checkuart(rp, rv, family_id, family) \
43 \
44 ldr rp, =family_id ; \
45 \
46 cmp rp, rv ; \
47 \
48 ldreq rp, =UARTA_##family ; \
49 \
50 beq 91f
51
52 .macro addruart, rp, rv, tmp
53 adr \rp, 99f @ actual addr of 99f
54 ldr \rv, [\rp] @ linked addr is stored there
55 sub \rv, \rv, \rp @ offset between the two
56 ldr \rp, [\rp, #4] @ linked brcmstb_uart_config
57 sub \tmp, \rp, \rv @ actual brcmstb_uart_config
58 ldr \rp, [\tmp] @ Load brcmstb_uart_config
59 cmp \rp, #1 @ needs initialization?
60 bne 100f @ no; go load the addresses
61 mov \rv, #0 @ yes; record init is done
62 str \rv, [\tmp]
63
64
65 mrc p15, 0, \rv, c0, c0, 0 @ get Main ID register
66 ldr \rp, =ARM_CPU_PART_MASK
67 and \rv, \rv, \rp
68 ldr \rp, =ARM_CPU_PART_BRAHMA_B53 @ check for B53 CPU
69 cmp \rv, \rp
70 bne 10f
71
72
73 mrc p15, 1, \rv, c15, c3, 0 @ get PERIPHBASE from CBAR
74 ands \rv, \rv, #REG_PHYS_BASE
75 ldreq \rp, =SUN_TOP_CTRL_BASE_V7
76
77
78 10: ldrne \rp, =SUN_TOP_CTRL_BASE @ load SUN_TOP_CTRL PA
79 ldr \rv, [\rp, #0] @ get register contents
80 ARM_BE8( rev \rv, \rv )
81 and \rv, \rv, #0xffffff00 @ strip revision bits [7:0]
82
83
84 20: checkuart(\rp, \rv, 0x33900000, 3390)
85 21: checkuart(\rp, \rv, 0x72500000, 7250)
86 22: checkuart(\rp, \rv, 0x72550000, 7255)
87 23: checkuart(\rp, \rv, 0x72600000, 7260)
88 24: checkuart(\rp, \rv, 0x72680000, 7268)
89 25: checkuart(\rp, \rv, 0x72710000, 7271)
90 26: checkuart(\rp, \rv, 0x72780000, 7278)
91 27: checkuart(\rp, \rv, 0x73640000, 7364)
92 28: checkuart(\rp, \rv, 0x73660000, 7366)
93 29: checkuart(\rp, \rv, 0x07437100, 74371)
94 30: checkuart(\rp, \rv, 0x74390000, 7439)
95 31: checkuart(\rp, \rv, 0x74450000, 7445)
96
97
98 90: mov \rp, #0
99
100
101
102 91: str \rp, [\tmp, #4] @ Store in brcmstb_uart_phys
103 cmp \rp, #0 @ Valid UART address?
104 bne 92f @ Yes, go process it
105 str \rp, [\tmp, #8] @ Store 0 in brcmstb_uart_virt
106 b 100f @ Done
107 92: and \rv, \rp, #0xffffff @ offset within 16MB section
108 add \rv, \rv, #REG_VIRT_BASE
109 str \rv, [\tmp, #8] @ Store in brcmstb_uart_virt
110 b 100f
111
112 .align
113 99: .word .
114 .word brcmstb_uart_config
115 .ltorg
116
117
118 100: ldr \rp, [\tmp, #4] @ Load brcmstb_uart_phys
119 ldr \rv, [\tmp, #8] @ Load brcmstb_uart_virt
120 .endm
121
122 .macro store, rd, rx:vararg
123 ARM_BE8( rev \rd, \rd )
124 str \rd, \rx
125 .endm
126
127 .macro load, rd, rx:vararg
128 ldr \rd, \rx
129 ARM_BE8( rev \rd, \rd )
130 .endm
131
132 .macro senduart,rd,rx
133 store \rd, [\rx, #UART_TX << UART_SHIFT]
134 .endm
135
136 .macro busyuart,rd,rx
137 1002: load \rd, [\rx, #UART_LSR << UART_SHIFT]
138 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
139 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
140 bne 1002b
141 .endm
142
143 .macro waituart,rd,rx
144 .endm
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 #if defined(ZIMAGE)
164 brcmstb_uart_config:
165
166 .word 1
167
168 .word 0
169
170 .word 0
171 #endif