| @@ -1,1335 +1,1335 @@ | | | @@ -1,1335 +1,1335 @@ |
1 | /* $NetBSD: bcm283x_platform.c,v 1.30 2019/12/30 16:06:29 skrll Exp $ */ | | 1 | /* $NetBSD: bcm283x_platform.c,v 1.31 2019/12/30 16:19:27 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2017 Jared D. McNeill <jmcneill@invisible.ca> | | 4 | * Copyright (c) 2017 Jared D. McNeill <jmcneill@invisible.ca> |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
26 | * SUCH DAMAGE. | | 26 | * SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | #include <sys/cdefs.h> | | 29 | #include <sys/cdefs.h> |
30 | __KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.30 2019/12/30 16:06:29 skrll Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: bcm283x_platform.c,v 1.31 2019/12/30 16:19:27 skrll Exp $"); |
31 | | | 31 | |
32 | #include "opt_arm_debug.h" | | 32 | #include "opt_arm_debug.h" |
33 | #include "opt_bcm283x.h" | | 33 | #include "opt_bcm283x.h" |
34 | #include "opt_cpuoptions.h" | | 34 | #include "opt_cpuoptions.h" |
35 | #include "opt_ddb.h" | | 35 | #include "opt_ddb.h" |
36 | #include "opt_evbarm_boardtype.h" | | 36 | #include "opt_evbarm_boardtype.h" |
37 | #include "opt_kgdb.h" | | 37 | #include "opt_kgdb.h" |
38 | #include "opt_fdt.h" | | 38 | #include "opt_fdt.h" |
39 | #include "opt_rpi.h" | | 39 | #include "opt_rpi.h" |
40 | #include "opt_vcprop.h" | | 40 | #include "opt_vcprop.h" |
41 | | | 41 | |
42 | #include "sdhc.h" | | 42 | #include "sdhc.h" |
43 | #include "bcmsdhost.h" | | 43 | #include "bcmsdhost.h" |
44 | #include "bcmdwctwo.h" | | 44 | #include "bcmdwctwo.h" |
45 | #include "bcmspi.h" | | 45 | #include "bcmspi.h" |
46 | #include "bsciic.h" | | 46 | #include "bsciic.h" |
47 | #include "plcom.h" | | 47 | #include "plcom.h" |
48 | #include "com.h" | | 48 | #include "com.h" |
49 | #include "genfb.h" | | 49 | #include "genfb.h" |
50 | #include "ukbd.h" | | 50 | #include "ukbd.h" |
51 | | | 51 | |
52 | #include <sys/param.h> | | 52 | #include <sys/param.h> |
53 | #include <sys/bus.h> | | 53 | #include <sys/bus.h> |
54 | #include <sys/cpu.h> | | 54 | #include <sys/cpu.h> |
55 | #include <sys/device.h> | | 55 | #include <sys/device.h> |
56 | #include <sys/termios.h> | | 56 | #include <sys/termios.h> |
57 | | | 57 | |
58 | #include <net/if_ether.h> | | 58 | #include <net/if_ether.h> |
59 | | | 59 | |
60 | #include <prop/proplib.h> | | 60 | #include <prop/proplib.h> |
61 | | | 61 | |
62 | #include <dev/fdt/fdtvar.h> | | 62 | #include <dev/fdt/fdtvar.h> |
63 | | | 63 | |
64 | #include <uvm/uvm_extern.h> | | 64 | #include <uvm/uvm_extern.h> |
65 | | | 65 | |
66 | #include <machine/bootconfig.h> | | 66 | #include <machine/bootconfig.h> |
67 | | | 67 | |
68 | #include <arm/armreg.h> | | 68 | #include <arm/armreg.h> |
69 | #include <arm/cpufunc.h> | | 69 | #include <arm/cpufunc.h> |
70 | | | 70 | |
71 | #include <libfdt.h> | | 71 | #include <libfdt.h> |
72 | | | 72 | |
73 | #include <arm/broadcom/bcm2835reg.h> | | 73 | #include <arm/broadcom/bcm2835reg.h> |
74 | #include <arm/broadcom/bcm2835var.h> | | 74 | #include <arm/broadcom/bcm2835var.h> |
75 | #include <arm/broadcom/bcm283x_platform.h> | | 75 | #include <arm/broadcom/bcm283x_platform.h> |
76 | #include <arm/broadcom/bcm2835_intr.h> | | 76 | #include <arm/broadcom/bcm2835_intr.h> |
77 | #include <arm/broadcom/bcm2835_mbox.h> | | 77 | #include <arm/broadcom/bcm2835_mbox.h> |
78 | #include <arm/broadcom/bcm2835_pmwdogvar.h> | | 78 | #include <arm/broadcom/bcm2835_pmwdogvar.h> |
79 | | | 79 | |
80 | #include <evbarm/dev/plcomreg.h> | | 80 | #include <evbarm/dev/plcomreg.h> |
81 | #include <evbarm/dev/plcomvar.h> | | 81 | #include <evbarm/dev/plcomvar.h> |
82 | #include <evbarm/fdt/machdep.h> | | 82 | #include <evbarm/fdt/machdep.h> |
83 | | | 83 | |
84 | #include <dev/ic/ns16550reg.h> | | 84 | #include <dev/ic/ns16550reg.h> |
85 | #include <dev/ic/comreg.h> | | 85 | #include <dev/ic/comreg.h> |
86 | | | 86 | |
87 | #include <evbarm/rpi/vcio.h> | | 87 | #include <evbarm/rpi/vcio.h> |
88 | #include <evbarm/rpi/vcpm.h> | | 88 | #include <evbarm/rpi/vcpm.h> |
89 | #include <evbarm/rpi/vcprop.h> | | 89 | #include <evbarm/rpi/vcprop.h> |
90 | | | 90 | |
91 | #include <arm/fdt/arm_fdtvar.h> | | 91 | #include <arm/fdt/arm_fdtvar.h> |
92 | | | 92 | |
93 | #include <arm/cortex/gtmr_var.h> | | 93 | #include <arm/cortex/gtmr_var.h> |
94 | | | 94 | |
95 | #if NGENFB > 0 | | 95 | #if NGENFB > 0 |
96 | #include <dev/videomode/videomode.h> | | 96 | #include <dev/videomode/videomode.h> |
97 | #include <dev/videomode/edidvar.h> | | 97 | #include <dev/videomode/edidvar.h> |
98 | #include <dev/wscons/wsconsio.h> | | 98 | #include <dev/wscons/wsconsio.h> |
99 | #endif | | 99 | #endif |
100 | | | 100 | |
101 | #if NUKBD > 0 | | 101 | #if NUKBD > 0 |
102 | #include <dev/usb/ukbdvar.h> | | 102 | #include <dev/usb/ukbdvar.h> |
103 | #endif | | 103 | #endif |
104 | | | 104 | |
105 | #ifdef DDB | | 105 | #ifdef DDB |
106 | #include <machine/db_machdep.h> | | 106 | #include <machine/db_machdep.h> |
107 | #include <ddb/db_sym.h> | | 107 | #include <ddb/db_sym.h> |
108 | #include <ddb/db_extern.h> | | 108 | #include <ddb/db_extern.h> |
109 | #endif | | 109 | #endif |
110 | | | 110 | |
111 | #define RPI_CPU_MAX 4 | | 111 | #define RPI_CPU_MAX 4 |
112 | | | 112 | |
113 | void bcm2835_platform_early_putchar(char c); | | 113 | void bcm2835_platform_early_putchar(char c); |
114 | void bcm2836_platform_early_putchar(char c); | | 114 | void bcm2836_platform_early_putchar(char c); |
115 | void bcm2837_platform_early_putchar(char c); | | 115 | void bcm2837_platform_early_putchar(char c); |
116 | void bcm2711_platform_early_putchar(char c); | | 116 | void bcm2711_platform_early_putchar(char c); |
117 | | | 117 | |
118 | extern void bcmgenfb_set_console_dev(device_t dev); | | 118 | extern void bcmgenfb_set_console_dev(device_t dev); |
119 | void bcmgenfb_set_ioctl(int(*)(void *, void *, u_long, void *, int, struct lwp *)); | | 119 | void bcmgenfb_set_ioctl(int(*)(void *, void *, u_long, void *, int, struct lwp *)); |
120 | extern void bcmgenfb_ddb_trap_callback(int where); | | 120 | extern void bcmgenfb_ddb_trap_callback(int where); |
121 | static int rpi_ioctl(void *, void *, u_long, void *, int, lwp_t *); | | 121 | static int rpi_ioctl(void *, void *, u_long, void *, int, lwp_t *); |
122 | | | 122 | |
123 | extern struct bus_space arm_generic_bs_tag; | | 123 | extern struct bus_space arm_generic_bs_tag; |
124 | extern struct bus_space arm_generic_a4x_bs_tag; | | 124 | extern struct bus_space arm_generic_a4x_bs_tag; |
125 | | | 125 | |
126 | /* Prototypes for all the bus_space structure functions */ | | 126 | /* Prototypes for all the bus_space structure functions */ |
127 | bs_protos(arm_generic); | | 127 | bs_protos(arm_generic); |
128 | bs_protos(arm_generic_a4x); | | 128 | bs_protos(arm_generic_a4x); |
129 | bs_protos(bcm2835); | | 129 | bs_protos(bcm2835); |
130 | bs_protos(bcm2835_a4x); | | 130 | bs_protos(bcm2835_a4x); |
131 | bs_protos(bcm2836); | | 131 | bs_protos(bcm2836); |
132 | bs_protos(bcm2836_a4x); | | 132 | bs_protos(bcm2836_a4x); |
133 | bs_protos(bcm2711); | | 133 | bs_protos(bcm2711); |
134 | bs_protos(bcm2711_a4x); | | 134 | bs_protos(bcm2711_a4x); |
135 | | | 135 | |
136 | struct bus_space bcm2835_bs_tag; | | 136 | struct bus_space bcm2835_bs_tag; |
137 | struct bus_space bcm2835_a4x_bs_tag; | | 137 | struct bus_space bcm2835_a4x_bs_tag; |
138 | struct bus_space bcm2836_bs_tag; | | 138 | struct bus_space bcm2836_bs_tag; |
139 | struct bus_space bcm2836_a4x_bs_tag; | | 139 | struct bus_space bcm2836_a4x_bs_tag; |
140 | struct bus_space bcm2711_bs_tag; | | 140 | struct bus_space bcm2711_bs_tag; |
141 | struct bus_space bcm2711_a4x_bs_tag; | | 141 | struct bus_space bcm2711_a4x_bs_tag; |
142 | | | 142 | |
143 | static paddr_t bcm2835_bus_to_phys(bus_addr_t); | | 143 | static paddr_t bcm2835_bus_to_phys(bus_addr_t); |
144 | static paddr_t bcm2836_bus_to_phys(bus_addr_t); | | 144 | static paddr_t bcm2836_bus_to_phys(bus_addr_t); |
145 | static paddr_t bcm2711_bus_to_phys(bus_addr_t); | | 145 | static paddr_t bcm2711_bus_to_phys(bus_addr_t); |
146 | | | 146 | |
147 | #ifdef VERBOSE_INIT_ARM | | 147 | #ifdef VERBOSE_INIT_ARM |
148 | #define VPRINTF(...) printf(__VA_ARGS__) | | 148 | #define VPRINTF(...) printf(__VA_ARGS__) |
149 | #else | | 149 | #else |
150 | #define VPRINTF(...) __nothing | | 150 | #define VPRINTF(...) __nothing |
151 | #endif | | 151 | #endif |
152 | | | 152 | |
153 | static paddr_t | | 153 | static paddr_t |
154 | bcm2835_bus_to_phys(bus_addr_t ba) | | 154 | bcm2835_bus_to_phys(bus_addr_t ba) |
155 | { | | 155 | { |
156 | | | 156 | |
157 | /* Attempt to find the PA device mapping */ | | 157 | /* Attempt to find the PA device mapping */ |
158 | if (ba >= BCM283X_PERIPHERALS_BASE_BUS && | | 158 | if (ba >= BCM283X_PERIPHERALS_BASE_BUS && |
159 | ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) | | 159 | ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) |
160 | return BCM2835_PERIPHERALS_BUS_TO_PHYS(ba); | | 160 | return BCM2835_PERIPHERALS_BUS_TO_PHYS(ba); |
161 | | | 161 | |
162 | return ba & ~BCM2835_BUSADDR_CACHE_MASK; | | 162 | return ba & ~BCM2835_BUSADDR_CACHE_MASK; |
163 | } | | 163 | } |
164 | | | 164 | |
165 | static paddr_t | | 165 | static paddr_t |
166 | bcm2836_bus_to_phys(bus_addr_t ba) | | 166 | bcm2836_bus_to_phys(bus_addr_t ba) |
167 | { | | 167 | { |
168 | | | 168 | |
169 | /* Attempt to find the PA device mapping */ | | 169 | /* Attempt to find the PA device mapping */ |
170 | if (ba >= BCM283X_PERIPHERALS_BASE_BUS && | | 170 | if (ba >= BCM283X_PERIPHERALS_BASE_BUS && |
171 | ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) | | 171 | ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) |
172 | return BCM2836_PERIPHERALS_BUS_TO_PHYS(ba); | | 172 | return BCM2836_PERIPHERALS_BUS_TO_PHYS(ba); |
173 | | | 173 | |
174 | if (ba >= BCM2836_ARM_LOCAL_BASE && | | 174 | if (ba >= BCM2836_ARM_LOCAL_BASE && |
175 | ba < BCM2836_ARM_LOCAL_BASE + BCM2836_ARM_LOCAL_SIZE) | | 175 | ba < BCM2836_ARM_LOCAL_BASE + BCM2836_ARM_LOCAL_SIZE) |
176 | return ba; | | 176 | return ba; |
177 | | | 177 | |
178 | return ba & ~BCM2835_BUSADDR_CACHE_MASK; | | 178 | return ba & ~BCM2835_BUSADDR_CACHE_MASK; |
179 | } | | 179 | } |
180 | | | 180 | |
181 | static paddr_t | | 181 | static paddr_t |
182 | bcm2711_bus_to_phys(bus_addr_t ba) | | 182 | bcm2711_bus_to_phys(bus_addr_t ba) |
183 | { | | 183 | { |
184 | | | 184 | |
185 | /* Attempt to find the PA device mapping */ | | 185 | /* Attempt to find the PA device mapping */ |
186 | if (ba >= BCM283X_PERIPHERALS_BASE_BUS && | | 186 | if (ba >= BCM283X_PERIPHERALS_BASE_BUS && |
187 | ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) | | 187 | ba < BCM283X_PERIPHERALS_BASE_BUS + BCM283X_PERIPHERALS_SIZE) |
188 | return BCM2711_PERIPHERALS_BUS_TO_PHYS(ba); | | 188 | return BCM2711_PERIPHERALS_BUS_TO_PHYS(ba); |
189 | | | 189 | |
190 | if (ba >= BCM2711_ARM_LOCAL_BASE && | | 190 | if (ba >= BCM2711_ARM_LOCAL_BASE_BUS && |
191 | ba < BCM2711_ARM_LOCAL_BASE + BCM2711_ARM_LOCAL_SIZE) | | 191 | ba < BCM2711_ARM_LOCAL_BASE_BUS + BCM2711_ARM_LOCAL_SIZE) |
192 | return ba; | | 192 | return BCM2711_ARM_LOCAL_BUS_TO_PHYS(ba); |
193 | | | 193 | |
194 | return ba & ~BCM2835_BUSADDR_CACHE_MASK; | | 194 | return ba & ~BCM2835_BUSADDR_CACHE_MASK; |
195 | } | | 195 | } |
196 | | | 196 | |
197 | int | | 197 | int |
198 | bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, | | 198 | bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, |
199 | bus_space_handle_t *bshp) | | 199 | bus_space_handle_t *bshp) |
200 | { | | 200 | { |
201 | const paddr_t pa = bcm2835_bus_to_phys(ba); | | 201 | const paddr_t pa = bcm2835_bus_to_phys(ba); |
202 | | | 202 | |
203 | return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); | | 203 | return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); |
204 | } | | 204 | } |
205 | | | 205 | |
206 | paddr_t | | 206 | paddr_t |
207 | bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) | | 207 | bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) |
208 | { | | 208 | { |
209 | const paddr_t pa = bcm2835_bus_to_phys(ba); | | 209 | const paddr_t pa = bcm2835_bus_to_phys(ba); |
210 | | | 210 | |
211 | return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); | | 211 | return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); |
212 | } | | 212 | } |
213 | | | 213 | |
214 | paddr_t | | 214 | paddr_t |
215 | bcm2835_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) | | 215 | bcm2835_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) |
216 | { | | 216 | { |
217 | | | 217 | |
218 | return bcm2835_bs_mmap(t, ba, 4 * offset, prot, flags); | | 218 | return bcm2835_bs_mmap(t, ba, 4 * offset, prot, flags); |
219 | } | | 219 | } |
220 | | | 220 | |
221 | int | | 221 | int |
222 | bcm2836_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, | | 222 | bcm2836_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, |
223 | bus_space_handle_t *bshp) | | 223 | bus_space_handle_t *bshp) |
224 | { | | 224 | { |
225 | const paddr_t pa = bcm2836_bus_to_phys(ba); | | 225 | const paddr_t pa = bcm2836_bus_to_phys(ba); |
226 | | | 226 | |
227 | return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); | | 227 | return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); |
228 | } | | 228 | } |
229 | | | 229 | |
230 | paddr_t | | 230 | paddr_t |
231 | bcm2836_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) | | 231 | bcm2836_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) |
232 | { | | 232 | { |
233 | const paddr_t pa = bcm2836_bus_to_phys(ba); | | 233 | const paddr_t pa = bcm2836_bus_to_phys(ba); |
234 | | | 234 | |
235 | return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); | | 235 | return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); |
236 | } | | 236 | } |
237 | | | 237 | |
238 | paddr_t | | 238 | paddr_t |
239 | bcm2836_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) | | 239 | bcm2836_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) |
240 | { | | 240 | { |
241 | | | 241 | |
242 | return bcm2836_bs_mmap(t, ba, 4 * offset, prot, flags); | | 242 | return bcm2836_bs_mmap(t, ba, 4 * offset, prot, flags); |
243 | } | | 243 | } |
244 | | | 244 | |
245 | int | | 245 | int |
246 | bcm2711_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, | | 246 | bcm2711_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, |
247 | bus_space_handle_t *bshp) | | 247 | bus_space_handle_t *bshp) |
248 | { | | 248 | { |
249 | const paddr_t pa = bcm2711_bus_to_phys(ba); | | 249 | const paddr_t pa = bcm2711_bus_to_phys(ba); |
250 | | | 250 | |
251 | return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); | | 251 | return bus_space_map(&arm_generic_bs_tag, pa, size, flag, bshp); |
252 | } | | 252 | } |
253 | | | 253 | |
254 | paddr_t | | 254 | paddr_t |
255 | bcm2711_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) | | 255 | bcm2711_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) |
256 | { | | 256 | { |
257 | const paddr_t pa = bcm2711_bus_to_phys(ba); | | 257 | const paddr_t pa = bcm2711_bus_to_phys(ba); |
258 | | | 258 | |
259 | return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); | | 259 | return bus_space_mmap(&arm_generic_bs_tag, pa, offset, prot, flags); |
260 | } | | 260 | } |
261 | | | 261 | |
262 | paddr_t | | 262 | paddr_t |
263 | bcm2711_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) | | 263 | bcm2711_a4x_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) |
264 | { | | 264 | { |
265 | | | 265 | |
266 | return bcm2711_bs_mmap(t, ba, 4 * offset, prot, flags); | | 266 | return bcm2711_bs_mmap(t, ba, 4 * offset, prot, flags); |
267 | } | | 267 | } |
268 | | | 268 | |
269 | struct arm32_dma_range bcm2835_dma_ranges[] = { | | 269 | struct arm32_dma_range bcm2835_dma_ranges[] = { |
270 | [0] = { | | 270 | [0] = { |
271 | .dr_sysbase = 0, | | 271 | .dr_sysbase = 0, |
272 | .dr_busbase = BCM2835_BUSADDR_CACHE_COHERENT, | | 272 | .dr_busbase = BCM2835_BUSADDR_CACHE_COHERENT, |
273 | } | | 273 | } |
274 | }; | | 274 | }; |
275 | | | 275 | |
276 | struct arm32_dma_range bcm2836_dma_ranges[] = { | | 276 | struct arm32_dma_range bcm2836_dma_ranges[] = { |
277 | [0] = { | | 277 | [0] = { |
278 | .dr_sysbase = 0, | | 278 | .dr_sysbase = 0, |
279 | .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT, | | 279 | .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT, |
280 | } | | 280 | } |
281 | }; | | 281 | }; |
282 | | | 282 | |
283 | struct arm32_dma_range bcm2711_dma_ranges[] = { | | 283 | struct arm32_dma_range bcm2711_dma_ranges[] = { |
284 | [0] = { | | 284 | [0] = { |
285 | .dr_sysbase = 0, | | 285 | .dr_sysbase = 0, |
286 | .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT, | | 286 | .dr_busbase = BCM2835_BUSADDR_CACHE_DIRECT, |
287 | } | | 287 | } |
288 | }; | | 288 | }; |
289 | | | 289 | |
290 | | | 290 | |
291 | #if defined(SOC_BCM2835) | | 291 | #if defined(SOC_BCM2835) |
292 | static const struct pmap_devmap * | | 292 | static const struct pmap_devmap * |
293 | bcm2835_platform_devmap(void) | | 293 | bcm2835_platform_devmap(void) |
294 | { | | 294 | { |
295 | static const struct pmap_devmap devmap[] = { | | 295 | static const struct pmap_devmap devmap[] = { |
296 | DEVMAP_ENTRY(BCM2835_PERIPHERALS_VBASE, BCM2835_PERIPHERALS_BASE, | | 296 | DEVMAP_ENTRY(BCM2835_PERIPHERALS_VBASE, BCM2835_PERIPHERALS_BASE, |
297 | BCM283X_PERIPHERALS_SIZE), /* 16Mb */ | | 297 | BCM283X_PERIPHERALS_SIZE), /* 16Mb */ |
298 | | | 298 | |
299 | DEVMAP_ENTRY_END | | 299 | DEVMAP_ENTRY_END |
300 | }; | | 300 | }; |
301 | | | 301 | |
302 | return devmap; | | 302 | return devmap; |
303 | } | | 303 | } |
304 | #endif | | 304 | #endif |
305 | | | 305 | |
306 | #if defined(SOC_BCM2836) | | 306 | #if defined(SOC_BCM2836) |
307 | static const struct pmap_devmap * | | 307 | static const struct pmap_devmap * |
308 | bcm2836_platform_devmap(void) | | 308 | bcm2836_platform_devmap(void) |
309 | { | | 309 | { |
310 | static const struct pmap_devmap devmap[] = { | | 310 | static const struct pmap_devmap devmap[] = { |
311 | DEVMAP_ENTRY(BCM2836_PERIPHERALS_VBASE, BCM2836_PERIPHERALS_BASE, | | 311 | DEVMAP_ENTRY(BCM2836_PERIPHERALS_VBASE, BCM2836_PERIPHERALS_BASE, |
312 | BCM283X_PERIPHERALS_SIZE), /* 16Mb */ | | 312 | BCM283X_PERIPHERALS_SIZE), /* 16Mb */ |
313 | DEVMAP_ENTRY(BCM2836_ARM_LOCAL_VBASE, BCM2836_ARM_LOCAL_BASE, | | 313 | DEVMAP_ENTRY(BCM2836_ARM_LOCAL_VBASE, BCM2836_ARM_LOCAL_BASE, |
314 | BCM2836_ARM_LOCAL_SIZE), | | 314 | BCM2836_ARM_LOCAL_SIZE), |
315 | #if defined(MULTIPROCESSOR) && defined(__aarch64__) | | 315 | #if defined(MULTIPROCESSOR) && defined(__aarch64__) |
316 | /* for fdt cpu spin-table */ | | 316 | /* for fdt cpu spin-table */ |
317 | DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE, | | 317 | DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE, |
318 | BCM2836_ARM_SMP_SIZE), | | 318 | BCM2836_ARM_SMP_SIZE), |
319 | #endif | | 319 | #endif |
320 | DEVMAP_ENTRY_END | | 320 | DEVMAP_ENTRY_END |
321 | }; | | 321 | }; |
322 | | | 322 | |
323 | return devmap; | | 323 | return devmap; |
324 | } | | 324 | } |
325 | | | 325 | |
326 | static const struct pmap_devmap * | | 326 | static const struct pmap_devmap * |
327 | bcm2711_platform_devmap(void) | | 327 | bcm2711_platform_devmap(void) |
328 | { | | 328 | { |
329 | static const struct pmap_devmap devmap[] = { | | 329 | static const struct pmap_devmap devmap[] = { |
330 | DEVMAP_ENTRY(BCM2711_PERIPHERALS_VBASE, BCM2711_PERIPHERALS_BASE, | | 330 | DEVMAP_ENTRY(BCM2711_PERIPHERALS_VBASE, BCM2711_PERIPHERALS_BASE, |
331 | BCM283X_PERIPHERALS_SIZE), /* 16Mb */ | | 331 | BCM283X_PERIPHERALS_SIZE), /* 16Mb */ |
332 | DEVMAP_ENTRY(BCM2711_ARM_LOCAL_VBASE, BCM2711_ARM_LOCAL_BASE, | | 332 | DEVMAP_ENTRY(BCM2711_ARM_LOCAL_VBASE, BCM2711_ARM_LOCAL_BASE, |
333 | BCM2711_ARM_LOCAL_SIZE), | | 333 | BCM2711_ARM_LOCAL_SIZE), |
334 | #if defined(MULTIPROCESSOR) && defined(__aarch64__) | | 334 | #if defined(MULTIPROCESSOR) && defined(__aarch64__) |
335 | /* for fdt cpu spin-table */ | | 335 | /* for fdt cpu spin-table */ |
336 | DEVMAP_ENTRY(BCM2836_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE, | | 336 | DEVMAP_ENTRY(BCM2711_ARM_SMP_VBASE, BCM2836_ARM_SMP_BASE, |
337 | BCM2836_ARM_SMP_SIZE), | | 337 | BCM2836_ARM_SMP_SIZE), |
338 | #endif | | 338 | #endif |
339 | DEVMAP_ENTRY_END | | 339 | DEVMAP_ENTRY_END |
340 | }; | | 340 | }; |
341 | | | 341 | |
342 | return devmap; | | 342 | return devmap; |
343 | } | | 343 | } |
344 | #endif | | 344 | #endif |
345 | | | 345 | |
346 | /* | | 346 | /* |
347 | * Macros to translate between physical and virtual for a subset of the | | 347 | * Macros to translate between physical and virtual for a subset of the |
348 | * kernel address space. *Not* for general use. | | 348 | * kernel address space. *Not* for general use. |
349 | */ | | 349 | */ |
350 | | | 350 | |
351 | #ifndef RPI_FB_WIDTH | | 351 | #ifndef RPI_FB_WIDTH |
352 | #define RPI_FB_WIDTH 1280 | | 352 | #define RPI_FB_WIDTH 1280 |
353 | #endif | | 353 | #endif |
354 | #ifndef RPI_FB_HEIGHT | | 354 | #ifndef RPI_FB_HEIGHT |
355 | #define RPI_FB_HEIGHT 720 | | 355 | #define RPI_FB_HEIGHT 720 |
356 | #endif | | 356 | #endif |
357 | | | 357 | |
358 | int uart_clk = BCM2835_UART0_CLK; | | 358 | int uart_clk = BCM2835_UART0_CLK; |
359 | int core_clk; | | 359 | int core_clk; |
360 | | | 360 | |
361 | static struct { | | 361 | static struct { |
362 | struct vcprop_buffer_hdr vb_hdr; | | 362 | struct vcprop_buffer_hdr vb_hdr; |
363 | struct vcprop_tag_clockrate vbt_uartclockrate; | | 363 | struct vcprop_tag_clockrate vbt_uartclockrate; |
364 | struct vcprop_tag_clockrate vbt_vpuclockrate; | | 364 | struct vcprop_tag_clockrate vbt_vpuclockrate; |
365 | struct vcprop_tag end; | | 365 | struct vcprop_tag end; |
366 | } vb_uart __cacheline_aligned = { | | 366 | } vb_uart __cacheline_aligned = { |
367 | .vb_hdr = { | | 367 | .vb_hdr = { |
368 | .vpb_len = sizeof(vb_uart), | | 368 | .vpb_len = sizeof(vb_uart), |
369 | .vpb_rcode = VCPROP_PROCESS_REQUEST, | | 369 | .vpb_rcode = VCPROP_PROCESS_REQUEST, |
370 | }, | | 370 | }, |
371 | .vbt_uartclockrate = { | | 371 | .vbt_uartclockrate = { |
372 | .tag = { | | 372 | .tag = { |
373 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, | | 373 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, |
374 | .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_uartclockrate), | | 374 | .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_uartclockrate), |
375 | .vpt_rcode = VCPROPTAG_REQUEST | | 375 | .vpt_rcode = VCPROPTAG_REQUEST |
376 | }, | | 376 | }, |
377 | .id = VCPROP_CLK_UART | | 377 | .id = VCPROP_CLK_UART |
378 | }, | | 378 | }, |
379 | .vbt_vpuclockrate = { | | 379 | .vbt_vpuclockrate = { |
380 | .tag = { | | 380 | .tag = { |
381 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, | | 381 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, |
382 | .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_vpuclockrate), | | 382 | .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_vpuclockrate), |
383 | .vpt_rcode = VCPROPTAG_REQUEST | | 383 | .vpt_rcode = VCPROPTAG_REQUEST |
384 | }, | | 384 | }, |
385 | .id = VCPROP_CLK_CORE | | 385 | .id = VCPROP_CLK_CORE |
386 | }, | | 386 | }, |
387 | .end = { | | 387 | .end = { |
388 | .vpt_tag = VCPROPTAG_NULL | | 388 | .vpt_tag = VCPROPTAG_NULL |
389 | } | | 389 | } |
390 | }; | | 390 | }; |
391 | | | 391 | |
392 | static struct { | | 392 | static struct { |
393 | struct vcprop_buffer_hdr vb_hdr; | | 393 | struct vcprop_buffer_hdr vb_hdr; |
394 | struct vcprop_tag_fwrev vbt_fwrev; | | 394 | struct vcprop_tag_fwrev vbt_fwrev; |
395 | struct vcprop_tag_boardmodel vbt_boardmodel; | | 395 | struct vcprop_tag_boardmodel vbt_boardmodel; |
396 | struct vcprop_tag_boardrev vbt_boardrev; | | 396 | struct vcprop_tag_boardrev vbt_boardrev; |
397 | struct vcprop_tag_macaddr vbt_macaddr; | | 397 | struct vcprop_tag_macaddr vbt_macaddr; |
398 | struct vcprop_tag_memory vbt_memory; | | 398 | struct vcprop_tag_memory vbt_memory; |
399 | struct vcprop_tag_boardserial vbt_serial; | | 399 | struct vcprop_tag_boardserial vbt_serial; |
400 | struct vcprop_tag_dmachan vbt_dmachan; | | 400 | struct vcprop_tag_dmachan vbt_dmachan; |
401 | struct vcprop_tag_cmdline vbt_cmdline; | | 401 | struct vcprop_tag_cmdline vbt_cmdline; |
402 | struct vcprop_tag_clockrate vbt_emmcclockrate; | | 402 | struct vcprop_tag_clockrate vbt_emmcclockrate; |
403 | struct vcprop_tag_clockrate vbt_armclockrate; | | 403 | struct vcprop_tag_clockrate vbt_armclockrate; |
404 | struct vcprop_tag_clockrate vbt_vpuclockrate; | | 404 | struct vcprop_tag_clockrate vbt_vpuclockrate; |
405 | struct vcprop_tag_clockrate vbt_emmc2clockrate; | | 405 | struct vcprop_tag_clockrate vbt_emmc2clockrate; |
406 | struct vcprop_tag end; | | 406 | struct vcprop_tag end; |
407 | } vb __cacheline_aligned = { | | 407 | } vb __cacheline_aligned = { |
408 | .vb_hdr = { | | 408 | .vb_hdr = { |
409 | .vpb_len = sizeof(vb), | | 409 | .vpb_len = sizeof(vb), |
410 | .vpb_rcode = VCPROP_PROCESS_REQUEST, | | 410 | .vpb_rcode = VCPROP_PROCESS_REQUEST, |
411 | }, | | 411 | }, |
412 | .vbt_fwrev = { | | 412 | .vbt_fwrev = { |
413 | .tag = { | | 413 | .tag = { |
414 | .vpt_tag = VCPROPTAG_GET_FIRMWAREREV, | | 414 | .vpt_tag = VCPROPTAG_GET_FIRMWAREREV, |
415 | .vpt_len = VCPROPTAG_LEN(vb.vbt_fwrev), | | 415 | .vpt_len = VCPROPTAG_LEN(vb.vbt_fwrev), |
416 | .vpt_rcode = VCPROPTAG_REQUEST | | 416 | .vpt_rcode = VCPROPTAG_REQUEST |
417 | }, | | 417 | }, |
418 | }, | | 418 | }, |
419 | .vbt_boardmodel = { | | 419 | .vbt_boardmodel = { |
420 | .tag = { | | 420 | .tag = { |
421 | .vpt_tag = VCPROPTAG_GET_BOARDMODEL, | | 421 | .vpt_tag = VCPROPTAG_GET_BOARDMODEL, |
422 | .vpt_len = VCPROPTAG_LEN(vb.vbt_boardmodel), | | 422 | .vpt_len = VCPROPTAG_LEN(vb.vbt_boardmodel), |
423 | .vpt_rcode = VCPROPTAG_REQUEST | | 423 | .vpt_rcode = VCPROPTAG_REQUEST |
424 | }, | | 424 | }, |
425 | }, | | 425 | }, |
426 | .vbt_boardrev = { | | 426 | .vbt_boardrev = { |
427 | .tag = { | | 427 | .tag = { |
428 | .vpt_tag = VCPROPTAG_GET_BOARDREVISION, | | 428 | .vpt_tag = VCPROPTAG_GET_BOARDREVISION, |
429 | .vpt_len = VCPROPTAG_LEN(vb.vbt_boardrev), | | 429 | .vpt_len = VCPROPTAG_LEN(vb.vbt_boardrev), |
430 | .vpt_rcode = VCPROPTAG_REQUEST | | 430 | .vpt_rcode = VCPROPTAG_REQUEST |
431 | }, | | 431 | }, |
432 | }, | | 432 | }, |
433 | .vbt_macaddr = { | | 433 | .vbt_macaddr = { |
434 | .tag = { | | 434 | .tag = { |
435 | .vpt_tag = VCPROPTAG_GET_MACADDRESS, | | 435 | .vpt_tag = VCPROPTAG_GET_MACADDRESS, |
436 | .vpt_len = VCPROPTAG_LEN(vb.vbt_macaddr), | | 436 | .vpt_len = VCPROPTAG_LEN(vb.vbt_macaddr), |
437 | .vpt_rcode = VCPROPTAG_REQUEST | | 437 | .vpt_rcode = VCPROPTAG_REQUEST |
438 | }, | | 438 | }, |
439 | }, | | 439 | }, |
440 | .vbt_memory = { | | 440 | .vbt_memory = { |
441 | .tag = { | | 441 | .tag = { |
442 | .vpt_tag = VCPROPTAG_GET_ARMMEMORY, | | 442 | .vpt_tag = VCPROPTAG_GET_ARMMEMORY, |
443 | .vpt_len = VCPROPTAG_LEN(vb.vbt_memory), | | 443 | .vpt_len = VCPROPTAG_LEN(vb.vbt_memory), |
444 | .vpt_rcode = VCPROPTAG_REQUEST | | 444 | .vpt_rcode = VCPROPTAG_REQUEST |
445 | }, | | 445 | }, |
446 | }, | | 446 | }, |
447 | .vbt_serial = { | | 447 | .vbt_serial = { |
448 | .tag = { | | 448 | .tag = { |
449 | .vpt_tag = VCPROPTAG_GET_BOARDSERIAL, | | 449 | .vpt_tag = VCPROPTAG_GET_BOARDSERIAL, |
450 | .vpt_len = VCPROPTAG_LEN(vb.vbt_serial), | | 450 | .vpt_len = VCPROPTAG_LEN(vb.vbt_serial), |
451 | .vpt_rcode = VCPROPTAG_REQUEST | | 451 | .vpt_rcode = VCPROPTAG_REQUEST |
452 | }, | | 452 | }, |
453 | }, | | 453 | }, |
454 | .vbt_dmachan = { | | 454 | .vbt_dmachan = { |
455 | .tag = { | | 455 | .tag = { |
456 | .vpt_tag = VCPROPTAG_GET_DMACHAN, | | 456 | .vpt_tag = VCPROPTAG_GET_DMACHAN, |
457 | .vpt_len = VCPROPTAG_LEN(vb.vbt_dmachan), | | 457 | .vpt_len = VCPROPTAG_LEN(vb.vbt_dmachan), |
458 | .vpt_rcode = VCPROPTAG_REQUEST | | 458 | .vpt_rcode = VCPROPTAG_REQUEST |
459 | }, | | 459 | }, |
460 | }, | | 460 | }, |
461 | .vbt_cmdline = { | | 461 | .vbt_cmdline = { |
462 | .tag = { | | 462 | .tag = { |
463 | .vpt_tag = VCPROPTAG_GET_CMDLINE, | | 463 | .vpt_tag = VCPROPTAG_GET_CMDLINE, |
464 | .vpt_len = VCPROPTAG_LEN(vb.vbt_cmdline), | | 464 | .vpt_len = VCPROPTAG_LEN(vb.vbt_cmdline), |
465 | .vpt_rcode = VCPROPTAG_REQUEST | | 465 | .vpt_rcode = VCPROPTAG_REQUEST |
466 | }, | | 466 | }, |
467 | }, | | 467 | }, |
468 | .vbt_emmcclockrate = { | | 468 | .vbt_emmcclockrate = { |
469 | .tag = { | | 469 | .tag = { |
470 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, | | 470 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, |
471 | .vpt_len = VCPROPTAG_LEN(vb.vbt_emmcclockrate), | | 471 | .vpt_len = VCPROPTAG_LEN(vb.vbt_emmcclockrate), |
472 | .vpt_rcode = VCPROPTAG_REQUEST | | 472 | .vpt_rcode = VCPROPTAG_REQUEST |
473 | }, | | 473 | }, |
474 | .id = VCPROP_CLK_EMMC | | 474 | .id = VCPROP_CLK_EMMC |
475 | }, | | 475 | }, |
476 | .vbt_armclockrate = { | | 476 | .vbt_armclockrate = { |
477 | .tag = { | | 477 | .tag = { |
478 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, | | 478 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, |
479 | .vpt_len = VCPROPTAG_LEN(vb.vbt_armclockrate), | | 479 | .vpt_len = VCPROPTAG_LEN(vb.vbt_armclockrate), |
480 | .vpt_rcode = VCPROPTAG_REQUEST | | 480 | .vpt_rcode = VCPROPTAG_REQUEST |
481 | }, | | 481 | }, |
482 | .id = VCPROP_CLK_ARM | | 482 | .id = VCPROP_CLK_ARM |
483 | }, | | 483 | }, |
484 | .vbt_vpuclockrate = { | | 484 | .vbt_vpuclockrate = { |
485 | .tag = { | | 485 | .tag = { |
486 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, | | 486 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, |
487 | .vpt_len = VCPROPTAG_LEN(vb.vbt_vpuclockrate), | | 487 | .vpt_len = VCPROPTAG_LEN(vb.vbt_vpuclockrate), |
488 | .vpt_rcode = VCPROPTAG_REQUEST | | 488 | .vpt_rcode = VCPROPTAG_REQUEST |
489 | }, | | 489 | }, |
490 | .id = VCPROP_CLK_CORE | | 490 | .id = VCPROP_CLK_CORE |
491 | }, | | 491 | }, |
492 | .vbt_emmc2clockrate = { | | 492 | .vbt_emmc2clockrate = { |
493 | .tag = { | | 493 | .tag = { |
494 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, | | 494 | .vpt_tag = VCPROPTAG_GET_CLOCKRATE, |
495 | .vpt_len = VCPROPTAG_LEN(vb.vbt_emmc2clockrate), | | 495 | .vpt_len = VCPROPTAG_LEN(vb.vbt_emmc2clockrate), |
496 | .vpt_rcode = VCPROPTAG_REQUEST | | 496 | .vpt_rcode = VCPROPTAG_REQUEST |
497 | }, | | 497 | }, |
498 | .id = VCPROP_CLK_EMMC2 | | 498 | .id = VCPROP_CLK_EMMC2 |
499 | }, | | 499 | }, |
500 | .end = { | | 500 | .end = { |
501 | .vpt_tag = VCPROPTAG_NULL | | 501 | .vpt_tag = VCPROPTAG_NULL |
502 | } | | 502 | } |
503 | }; | | 503 | }; |
504 | | | 504 | |
505 | #if NGENFB > 0 | | 505 | #if NGENFB > 0 |
506 | static struct { | | 506 | static struct { |
507 | struct vcprop_buffer_hdr vb_hdr; | | 507 | struct vcprop_buffer_hdr vb_hdr; |
508 | struct vcprop_tag_edidblock vbt_edid; | | 508 | struct vcprop_tag_edidblock vbt_edid; |
509 | struct vcprop_tag end; | | 509 | struct vcprop_tag end; |
510 | } vb_edid __cacheline_aligned = { | | 510 | } vb_edid __cacheline_aligned = { |
511 | .vb_hdr = { | | 511 | .vb_hdr = { |
512 | .vpb_len = sizeof(vb_edid), | | 512 | .vpb_len = sizeof(vb_edid), |
513 | .vpb_rcode = VCPROP_PROCESS_REQUEST, | | 513 | .vpb_rcode = VCPROP_PROCESS_REQUEST, |
514 | }, | | 514 | }, |
515 | .vbt_edid = { | | 515 | .vbt_edid = { |
516 | .tag = { | | 516 | .tag = { |
517 | .vpt_tag = VCPROPTAG_GET_EDID_BLOCK, | | 517 | .vpt_tag = VCPROPTAG_GET_EDID_BLOCK, |
518 | .vpt_len = VCPROPTAG_LEN(vb_edid.vbt_edid), | | 518 | .vpt_len = VCPROPTAG_LEN(vb_edid.vbt_edid), |
519 | .vpt_rcode = VCPROPTAG_REQUEST, | | 519 | .vpt_rcode = VCPROPTAG_REQUEST, |
520 | }, | | 520 | }, |
521 | .blockno = 0, | | 521 | .blockno = 0, |
522 | }, | | 522 | }, |
523 | .end = { | | 523 | .end = { |
524 | .vpt_tag = VCPROPTAG_NULL | | 524 | .vpt_tag = VCPROPTAG_NULL |
525 | } | | 525 | } |
526 | }; | | 526 | }; |
527 | | | 527 | |
528 | static struct { | | 528 | static struct { |
529 | struct vcprop_buffer_hdr vb_hdr; | | 529 | struct vcprop_buffer_hdr vb_hdr; |
530 | struct vcprop_tag_fbres vbt_res; | | 530 | struct vcprop_tag_fbres vbt_res; |
531 | struct vcprop_tag_fbres vbt_vres; | | 531 | struct vcprop_tag_fbres vbt_vres; |
532 | struct vcprop_tag_fbdepth vbt_depth; | | 532 | struct vcprop_tag_fbdepth vbt_depth; |
533 | struct vcprop_tag_fbalpha vbt_alpha; | | 533 | struct vcprop_tag_fbalpha vbt_alpha; |
534 | struct vcprop_tag_allocbuf vbt_allocbuf; | | 534 | struct vcprop_tag_allocbuf vbt_allocbuf; |
535 | struct vcprop_tag_blankscreen vbt_blank; | | 535 | struct vcprop_tag_blankscreen vbt_blank; |
536 | struct vcprop_tag_fbpitch vbt_pitch; | | 536 | struct vcprop_tag_fbpitch vbt_pitch; |
537 | struct vcprop_tag end; | | 537 | struct vcprop_tag end; |
538 | } vb_setfb __cacheline_aligned = { | | 538 | } vb_setfb __cacheline_aligned = { |
539 | .vb_hdr = { | | 539 | .vb_hdr = { |
540 | .vpb_len = sizeof(vb_setfb), | | 540 | .vpb_len = sizeof(vb_setfb), |
541 | .vpb_rcode = VCPROP_PROCESS_REQUEST, | | 541 | .vpb_rcode = VCPROP_PROCESS_REQUEST, |
542 | }, | | 542 | }, |
543 | .vbt_res = { | | 543 | .vbt_res = { |
544 | .tag = { | | 544 | .tag = { |
545 | .vpt_tag = VCPROPTAG_SET_FB_RES, | | 545 | .vpt_tag = VCPROPTAG_SET_FB_RES, |
546 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_res), | | 546 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_res), |
547 | .vpt_rcode = VCPROPTAG_REQUEST, | | 547 | .vpt_rcode = VCPROPTAG_REQUEST, |
548 | }, | | 548 | }, |
549 | .width = 0, | | 549 | .width = 0, |
550 | .height = 0, | | 550 | .height = 0, |
551 | }, | | 551 | }, |
552 | .vbt_vres = { | | 552 | .vbt_vres = { |
553 | .tag = { | | 553 | .tag = { |
554 | .vpt_tag = VCPROPTAG_SET_FB_VRES, | | 554 | .vpt_tag = VCPROPTAG_SET_FB_VRES, |
555 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_vres), | | 555 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_vres), |
556 | .vpt_rcode = VCPROPTAG_REQUEST, | | 556 | .vpt_rcode = VCPROPTAG_REQUEST, |
557 | }, | | 557 | }, |
558 | .width = 0, | | 558 | .width = 0, |
559 | .height = 0, | | 559 | .height = 0, |
560 | }, | | 560 | }, |
561 | .vbt_depth = { | | 561 | .vbt_depth = { |
562 | .tag = { | | 562 | .tag = { |
563 | .vpt_tag = VCPROPTAG_SET_FB_DEPTH, | | 563 | .vpt_tag = VCPROPTAG_SET_FB_DEPTH, |
564 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_depth), | | 564 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_depth), |
565 | .vpt_rcode = VCPROPTAG_REQUEST, | | 565 | .vpt_rcode = VCPROPTAG_REQUEST, |
566 | }, | | 566 | }, |
567 | .bpp = 32, | | 567 | .bpp = 32, |
568 | }, | | 568 | }, |
569 | .vbt_alpha = { | | 569 | .vbt_alpha = { |
570 | .tag = { | | 570 | .tag = { |
571 | .vpt_tag = VCPROPTAG_SET_FB_ALPHA_MODE, | | 571 | .vpt_tag = VCPROPTAG_SET_FB_ALPHA_MODE, |
572 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_alpha), | | 572 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_alpha), |
573 | .vpt_rcode = VCPROPTAG_REQUEST, | | 573 | .vpt_rcode = VCPROPTAG_REQUEST, |
574 | }, | | 574 | }, |
575 | .state = VCPROP_ALPHA_IGNORED, | | 575 | .state = VCPROP_ALPHA_IGNORED, |
576 | }, | | 576 | }, |
577 | .vbt_allocbuf = { | | 577 | .vbt_allocbuf = { |
578 | .tag = { | | 578 | .tag = { |
579 | .vpt_tag = VCPROPTAG_ALLOCATE_BUFFER, | | 579 | .vpt_tag = VCPROPTAG_ALLOCATE_BUFFER, |
580 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_allocbuf), | | 580 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_allocbuf), |
581 | .vpt_rcode = VCPROPTAG_REQUEST, | | 581 | .vpt_rcode = VCPROPTAG_REQUEST, |
582 | }, | | 582 | }, |
583 | .address = PAGE_SIZE, /* alignment */ | | 583 | .address = PAGE_SIZE, /* alignment */ |
584 | }, | | 584 | }, |
585 | .vbt_blank = { | | 585 | .vbt_blank = { |
586 | .tag = { | | 586 | .tag = { |
587 | .vpt_tag = VCPROPTAG_BLANK_SCREEN, | | 587 | .vpt_tag = VCPROPTAG_BLANK_SCREEN, |
588 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_blank), | | 588 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_blank), |
589 | .vpt_rcode = VCPROPTAG_REQUEST, | | 589 | .vpt_rcode = VCPROPTAG_REQUEST, |
590 | }, | | 590 | }, |
591 | .state = VCPROP_BLANK_OFF, | | 591 | .state = VCPROP_BLANK_OFF, |
592 | }, | | 592 | }, |
593 | .vbt_pitch = { | | 593 | .vbt_pitch = { |
594 | .tag = { | | 594 | .tag = { |
595 | .vpt_tag = VCPROPTAG_GET_FB_PITCH, | | 595 | .vpt_tag = VCPROPTAG_GET_FB_PITCH, |
596 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_pitch), | | 596 | .vpt_len = VCPROPTAG_LEN(vb_setfb.vbt_pitch), |
597 | .vpt_rcode = VCPROPTAG_REQUEST, | | 597 | .vpt_rcode = VCPROPTAG_REQUEST, |
598 | }, | | 598 | }, |
599 | }, | | 599 | }, |
600 | .end = { | | 600 | .end = { |
601 | .vpt_tag = VCPROPTAG_NULL, | | 601 | .vpt_tag = VCPROPTAG_NULL, |
602 | }, | | 602 | }, |
603 | }; | | 603 | }; |
604 | | | 604 | |
605 | #endif | | 605 | #endif |
606 | | | 606 | |
607 | static int rpi_video_on = WSDISPLAYIO_VIDEO_ON; | | 607 | static int rpi_video_on = WSDISPLAYIO_VIDEO_ON; |
608 | | | 608 | |
609 | #if defined(RPI_HWCURSOR) | | 609 | #if defined(RPI_HWCURSOR) |
610 | #define CURSOR_BITMAP_SIZE (64 * 8) | | 610 | #define CURSOR_BITMAP_SIZE (64 * 8) |
611 | #define CURSOR_ARGB_SIZE (64 * 64 * 4) | | 611 | #define CURSOR_ARGB_SIZE (64 * 64 * 4) |
612 | static uint32_t hcursor = 0; | | 612 | static uint32_t hcursor = 0; |
613 | static bus_addr_t pcursor = 0; | | 613 | static bus_addr_t pcursor = 0; |
614 | static uint32_t *cmem = NULL; | | 614 | static uint32_t *cmem = NULL; |
615 | static int cursor_x = 0, cursor_y = 0, hot_x = 0, hot_y = 0, cursor_on = 0; | | 615 | static int cursor_x = 0, cursor_y = 0, hot_x = 0, hot_y = 0, cursor_on = 0; |
616 | static uint32_t cursor_cmap[4]; | | 616 | static uint32_t cursor_cmap[4]; |
617 | static uint8_t cursor_mask[8 * 64], cursor_bitmap[8 * 64]; | | 617 | static uint8_t cursor_mask[8 * 64], cursor_bitmap[8 * 64]; |
618 | #endif | | 618 | #endif |
619 | | | 619 | |
620 | u_int | | 620 | u_int |
621 | bcm283x_clk_get_rate_uart(void) | | 621 | bcm283x_clk_get_rate_uart(void) |
622 | { | | 622 | { |
623 | | | 623 | |
624 | if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) | | 624 | if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) |
625 | return vb_uart.vbt_uartclockrate.rate; | | 625 | return vb_uart.vbt_uartclockrate.rate; |
626 | return 0; | | 626 | return 0; |
627 | } | | 627 | } |
628 | | | 628 | |
629 | u_int | | 629 | u_int |
630 | bcm283x_clk_get_rate_vpu(void) | | 630 | bcm283x_clk_get_rate_vpu(void) |
631 | { | | 631 | { |
632 | | | 632 | |
633 | if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag) && | | 633 | if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag) && |
634 | vb.vbt_vpuclockrate.rate > 0) { | | 634 | vb.vbt_vpuclockrate.rate > 0) { |
635 | return vb.vbt_vpuclockrate.rate; | | 635 | return vb.vbt_vpuclockrate.rate; |
636 | } | | 636 | } |
637 | return 0; | | 637 | return 0; |
638 | } | | 638 | } |
639 | | | 639 | |
640 | u_int | | 640 | u_int |
641 | bcm283x_clk_get_rate_emmc(void) | | 641 | bcm283x_clk_get_rate_emmc(void) |
642 | { | | 642 | { |
643 | | | 643 | |
644 | if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag) && | | 644 | if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag) && |
645 | vb.vbt_emmcclockrate.rate > 0) { | | 645 | vb.vbt_emmcclockrate.rate > 0) { |
646 | return vb.vbt_emmcclockrate.rate; | | 646 | return vb.vbt_emmcclockrate.rate; |
647 | } | | 647 | } |
648 | return 0; | | 648 | return 0; |
649 | } | | 649 | } |
650 | | | 650 | |
651 | u_int | | 651 | u_int |
652 | bcm283x_clk_get_rate_emmc2(void) | | 652 | bcm283x_clk_get_rate_emmc2(void) |
653 | { | | 653 | { |
654 | | | 654 | |
655 | if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag) && | | 655 | if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag) && |
656 | vb.vbt_emmc2clockrate.rate > 0) { | | 656 | vb.vbt_emmc2clockrate.rate > 0) { |
657 | return vb.vbt_emmc2clockrate.rate; | | 657 | return vb.vbt_emmc2clockrate.rate; |
658 | } | | 658 | } |
659 | return 0; | | 659 | return 0; |
660 | } | | 660 | } |
661 | | | 661 | |
662 | | | 662 | |
663 | | | 663 | |
664 | static void | | 664 | static void |
665 | bcm283x_uartinit(bus_space_tag_t iot, bus_space_handle_t ioh) | | 665 | bcm283x_uartinit(bus_space_tag_t iot, bus_space_handle_t ioh) |
666 | { | | 666 | { |
667 | uint32_t res; | | 667 | uint32_t res; |
668 | | | 668 | |
669 | bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, | | 669 | bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, |
670 | KERN_VTOPHYS((vaddr_t)&vb_uart)); | | 670 | KERN_VTOPHYS((vaddr_t)&vb_uart)); |
671 | | | 671 | |
672 | bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); | | 672 | bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); |
673 | | | 673 | |
674 | if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) | | 674 | if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag)) |
675 | uart_clk = vb_uart.vbt_uartclockrate.rate; | | 675 | uart_clk = vb_uart.vbt_uartclockrate.rate; |
676 | if (vcprop_tag_success_p(&vb_uart.vbt_vpuclockrate.tag)) | | 676 | if (vcprop_tag_success_p(&vb_uart.vbt_vpuclockrate.tag)) |
677 | core_clk = vb_uart.vbt_vpuclockrate.rate; | | 677 | core_clk = vb_uart.vbt_vpuclockrate.rate; |
678 | } | | 678 | } |
679 | | | 679 | |
680 | #if defined(SOC_BCM2835) | | 680 | #if defined(SOC_BCM2835) |
681 | static void | | 681 | static void |
682 | bcm2835_uartinit(void) | | 682 | bcm2835_uartinit(void) |
683 | { | | 683 | { |
684 | const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); | | 684 | const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); |
685 | const bus_space_tag_t iot = &bcm2835_bs_tag; | | 685 | const bus_space_tag_t iot = &bcm2835_bs_tag; |
686 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); | | 686 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); |
687 | | | 687 | |
688 | bcm283x_uartinit(iot, ioh); | | 688 | bcm283x_uartinit(iot, ioh); |
689 | } | | 689 | } |
690 | #endif | | 690 | #endif |
691 | | | 691 | |
692 | #if defined(SOC_BCM2836) | | 692 | #if defined(SOC_BCM2836) |
693 | static void | | 693 | static void |
694 | bcm2836_uartinit(void) | | 694 | bcm2836_uartinit(void) |
695 | { | | 695 | { |
696 | const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); | | 696 | const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); |
697 | const bus_space_tag_t iot = &bcm2836_bs_tag; | | 697 | const bus_space_tag_t iot = &bcm2836_bs_tag; |
698 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); | | 698 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); |
699 | | | 699 | |
700 | bcm283x_uartinit(iot, ioh); | | 700 | bcm283x_uartinit(iot, ioh); |
701 | } | | 701 | } |
702 | | | 702 | |
703 | static void | | 703 | static void |
704 | bcm2711_uartinit(void) | | 704 | bcm2711_uartinit(void) |
705 | { | | 705 | { |
706 | const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); | | 706 | const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); |
707 | const bus_space_tag_t iot = &bcm2711_bs_tag; | | 707 | const bus_space_tag_t iot = &bcm2711_bs_tag; |
708 | const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa); | | 708 | const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa); |
709 | | | 709 | |
710 | bcm283x_uartinit(iot, ioh); | | 710 | bcm283x_uartinit(iot, ioh); |
711 | } | | 711 | } |
712 | #endif | | 712 | #endif |
713 | | | 713 | |
714 | #define BCM283x_MINIMUM_SPLIT (128U * 1024 * 1024) | | 714 | #define BCM283x_MINIMUM_SPLIT (128U * 1024 * 1024) |
715 | | | 715 | |
716 | static size_t bcm283x_memorysize; | | 716 | static size_t bcm283x_memorysize; |
717 | | | 717 | |
718 | static void | | 718 | static void |
719 | bcm283x_bootparams(bus_space_tag_t iot, bus_space_handle_t ioh) | | 719 | bcm283x_bootparams(bus_space_tag_t iot, bus_space_handle_t ioh) |
720 | { | | 720 | { |
721 | uint32_t res; | | 721 | uint32_t res; |
722 | | | 722 | |
723 | bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANPM, ( | | 723 | bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANPM, ( |
724 | #if (NSDHC > 0) | | 724 | #if (NSDHC > 0) |
725 | (1 << VCPM_POWER_SDCARD) | | | 725 | (1 << VCPM_POWER_SDCARD) | |
726 | #endif | | 726 | #endif |
727 | #if (NPLCOM > 0) | | 727 | #if (NPLCOM > 0) |
728 | (1 << VCPM_POWER_UART0) | | | 728 | (1 << VCPM_POWER_UART0) | |
729 | #endif | | 729 | #endif |
730 | #if (NBCMDWCTWO > 0) | | 730 | #if (NBCMDWCTWO > 0) |
731 | (1 << VCPM_POWER_USB) | | | 731 | (1 << VCPM_POWER_USB) | |
732 | #endif | | 732 | #endif |
733 | #if (NBSCIIC > 0) | | 733 | #if (NBSCIIC > 0) |
734 | (1 << VCPM_POWER_I2C0) | (1 << VCPM_POWER_I2C1) | | | 734 | (1 << VCPM_POWER_I2C0) | (1 << VCPM_POWER_I2C1) | |
735 | /* (1 << VCPM_POWER_I2C2) | */ | | 735 | /* (1 << VCPM_POWER_I2C2) | */ |
736 | #endif | | 736 | #endif |
737 | #if (NBCMSPI > 0) | | 737 | #if (NBCMSPI > 0) |
738 | (1 << VCPM_POWER_SPI) | | | 738 | (1 << VCPM_POWER_SPI) | |
739 | #endif | | 739 | #endif |
740 | 0) << 4); | | 740 | 0) << 4); |
741 | | | 741 | |
742 | bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, | | 742 | bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, |
743 | KERN_VTOPHYS((vaddr_t)&vb)); | | 743 | KERN_VTOPHYS((vaddr_t)&vb)); |
744 | | | 744 | |
745 | bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); | | 745 | bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res); |
746 | | | 746 | |
747 | /* | | 747 | /* |
748 | * RPI4 has Cortex A72 processors which do speculation, so | | 748 | * RPI4 has Cortex A72 processors which do speculation, so |
749 | * we need to invalidate the cache for an updates done by | | 749 | * we need to invalidate the cache for an updates done by |
750 | * the firmware | | 750 | * the firmware |
751 | */ | | 751 | */ |
752 | cpu_dcache_inv_range((vaddr_t)&vb, sizeof(vb)); | | 752 | cpu_dcache_inv_range((vaddr_t)&vb, sizeof(vb)); |
753 | | | 753 | |
754 | if (!vcprop_buffer_success_p(&vb.vb_hdr)) { | | 754 | if (!vcprop_buffer_success_p(&vb.vb_hdr)) { |
755 | bootconfig.dramblocks = 1; | | 755 | bootconfig.dramblocks = 1; |
756 | bootconfig.dram[0].address = 0x0; | | 756 | bootconfig.dram[0].address = 0x0; |
757 | bootconfig.dram[0].pages = atop(BCM283x_MINIMUM_SPLIT); | | 757 | bootconfig.dram[0].pages = atop(BCM283x_MINIMUM_SPLIT); |
758 | return; | | 758 | return; |
759 | } | | 759 | } |
760 | | | 760 | |
761 | struct vcprop_tag_memory *vptp_mem = &vb.vbt_memory; | | 761 | struct vcprop_tag_memory *vptp_mem = &vb.vbt_memory; |
762 | if (vcprop_tag_success_p(&vptp_mem->tag)) { | | 762 | if (vcprop_tag_success_p(&vptp_mem->tag)) { |
763 | size_t n = vcprop_tag_resplen(&vptp_mem->tag) / | | 763 | size_t n = vcprop_tag_resplen(&vptp_mem->tag) / |
764 | sizeof(struct vcprop_memory); | | 764 | sizeof(struct vcprop_memory); |
765 | | | 765 | |
766 | bcm283x_memorysize = 0; | | 766 | bcm283x_memorysize = 0; |
767 | bootconfig.dramblocks = 0; | | 767 | bootconfig.dramblocks = 0; |
768 | | | 768 | |
769 | for (int i = 0; i < n && i < DRAM_BLOCKS; i++) { | | 769 | for (int i = 0; i < n && i < DRAM_BLOCKS; i++) { |
770 | bootconfig.dram[i].address = vptp_mem->mem[i].base; | | 770 | bootconfig.dram[i].address = vptp_mem->mem[i].base; |
771 | bootconfig.dram[i].pages = atop(vptp_mem->mem[i].size); | | 771 | bootconfig.dram[i].pages = atop(vptp_mem->mem[i].size); |
772 | bootconfig.dramblocks++; | | 772 | bootconfig.dramblocks++; |
773 | | | 773 | |
774 | bcm283x_memorysize += vptp_mem->mem[i].size; | | 774 | bcm283x_memorysize += vptp_mem->mem[i].size; |
775 | } | | 775 | } |
776 | } | | 776 | } |
777 | | | 777 | |
778 | if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) | | 778 | if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) |
779 | curcpu()->ci_data.cpu_cc_freq = vb.vbt_armclockrate.rate; | | 779 | curcpu()->ci_data.cpu_cc_freq = vb.vbt_armclockrate.rate; |
780 | | | 780 | |
781 | #ifdef VERBOSE_INIT_ARM | | 781 | #ifdef VERBOSE_INIT_ARM |
782 | if (vcprop_tag_success_p(&vb.vbt_memory.tag)) | | 782 | if (vcprop_tag_success_p(&vb.vbt_memory.tag)) |
783 | printf("%s: memory size %zu\n", __func__, | | 783 | printf("%s: memory size %zu\n", __func__, |
784 | bcm283x_memorysize); | | 784 | bcm283x_memorysize); |
785 | if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) | | 785 | if (vcprop_tag_success_p(&vb.vbt_armclockrate.tag)) |
786 | printf("%s: arm clock %d\n", __func__, | | 786 | printf("%s: arm clock %d\n", __func__, |
787 | vb.vbt_armclockrate.rate); | | 787 | vb.vbt_armclockrate.rate); |
788 | if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag)) | | 788 | if (vcprop_tag_success_p(&vb.vbt_vpuclockrate.tag)) |
789 | printf("%s: vpu clock %d\n", __func__, | | 789 | printf("%s: vpu clock %d\n", __func__, |
790 | vb.vbt_vpuclockrate.rate); | | 790 | vb.vbt_vpuclockrate.rate); |
791 | if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag)) | | 791 | if (vcprop_tag_success_p(&vb.vbt_emmcclockrate.tag)) |
792 | printf("%s: emmc clock %d\n", __func__, | | 792 | printf("%s: emmc clock %d\n", __func__, |
793 | vb.vbt_emmcclockrate.rate); | | 793 | vb.vbt_emmcclockrate.rate); |
794 | if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag)) | | 794 | if (vcprop_tag_success_p(&vb.vbt_emmc2clockrate.tag)) |
795 | printf("%s: emmc2 clock %d\n", __func__, | | 795 | printf("%s: emmc2 clock %d\n", __func__, |
796 | vb.vbt_emmcclockrate.rate); | | 796 | vb.vbt_emmcclockrate.rate); |
797 | if (vcprop_tag_success_p(&vb.vbt_fwrev.tag)) | | 797 | if (vcprop_tag_success_p(&vb.vbt_fwrev.tag)) |
798 | printf("%s: firmware rev %x\n", __func__, | | 798 | printf("%s: firmware rev %x\n", __func__, |
799 | vb.vbt_fwrev.rev); | | 799 | vb.vbt_fwrev.rev); |
800 | if (vcprop_tag_success_p(&vb.vbt_boardmodel.tag)) | | 800 | if (vcprop_tag_success_p(&vb.vbt_boardmodel.tag)) |
801 | printf("%s: board model %x\n", __func__, | | 801 | printf("%s: board model %x\n", __func__, |
802 | vb.vbt_boardmodel.model); | | 802 | vb.vbt_boardmodel.model); |
803 | if (vcprop_tag_success_p(&vb.vbt_macaddr.tag)) | | 803 | if (vcprop_tag_success_p(&vb.vbt_macaddr.tag)) |
804 | printf("%s: mac-address %" PRIx64 "\n", __func__, | | 804 | printf("%s: mac-address %" PRIx64 "\n", __func__, |
805 | vb.vbt_macaddr.addr); | | 805 | vb.vbt_macaddr.addr); |
806 | if (vcprop_tag_success_p(&vb.vbt_boardrev.tag)) | | 806 | if (vcprop_tag_success_p(&vb.vbt_boardrev.tag)) |
807 | printf("%s: board rev %x\n", __func__, | | 807 | printf("%s: board rev %x\n", __func__, |
808 | vb.vbt_boardrev.rev); | | 808 | vb.vbt_boardrev.rev); |
809 | if (vcprop_tag_success_p(&vb.vbt_serial.tag)) | | 809 | if (vcprop_tag_success_p(&vb.vbt_serial.tag)) |
810 | printf("%s: board serial %" PRIx64 "\n", __func__, | | 810 | printf("%s: board serial %" PRIx64 "\n", __func__, |
811 | vb.vbt_serial.sn); | | 811 | vb.vbt_serial.sn); |
812 | if (vcprop_tag_success_p(&vb.vbt_dmachan.tag)) | | 812 | if (vcprop_tag_success_p(&vb.vbt_dmachan.tag)) |
813 | printf("%s: DMA channel mask 0x%08x\n", __func__, | | 813 | printf("%s: DMA channel mask 0x%08x\n", __func__, |
814 | vb.vbt_dmachan.mask); | | 814 | vb.vbt_dmachan.mask); |
815 | | | 815 | |
816 | if (vcprop_tag_success_p(&vb.vbt_cmdline.tag)) | | 816 | if (vcprop_tag_success_p(&vb.vbt_cmdline.tag)) |
817 | printf("%s: cmdline %s\n", __func__, | | 817 | printf("%s: cmdline %s\n", __func__, |
818 | vb.vbt_cmdline.cmdline); | | 818 | vb.vbt_cmdline.cmdline); |
819 | #endif | | 819 | #endif |
820 | } | | 820 | } |
821 | | | 821 | |
822 | #if defined(SOC_BCM2835) | | 822 | #if defined(SOC_BCM2835) |
823 | static void | | 823 | static void |
824 | bcm2835_bootparams(void) | | 824 | bcm2835_bootparams(void) |
825 | { | | 825 | { |
826 | const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); | | 826 | const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); |
827 | const bus_space_tag_t iot = &bcm2835_bs_tag; | | 827 | const bus_space_tag_t iot = &bcm2835_bs_tag; |
828 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); | | 828 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); |
829 | | | 829 | |
830 | bcm283x_bootparams(iot, ioh); | | 830 | bcm283x_bootparams(iot, ioh); |
831 | } | | 831 | } |
832 | #endif | | 832 | #endif |
833 | | | 833 | |
834 | #if defined(SOC_BCM2836) | | 834 | #if defined(SOC_BCM2836) |
835 | static void | | 835 | static void |
836 | bcm2836_bootparams(void) | | 836 | bcm2836_bootparams(void) |
837 | { | | 837 | { |
838 | const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); | | 838 | const paddr_t pa = BCM2836_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); |
839 | const bus_space_tag_t iot = &bcm2836_bs_tag; | | 839 | const bus_space_tag_t iot = &bcm2836_bs_tag; |
840 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); | | 840 | const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa); |
841 | | | 841 | |
842 | bcm283x_bootparams(iot, ioh); | | 842 | bcm283x_bootparams(iot, ioh); |
843 | } | | 843 | } |
844 | | | 844 | |
845 | static void | | 845 | static void |
846 | bcm2711_bootparams(void) | | 846 | bcm2711_bootparams(void) |
847 | { | | 847 | { |
848 | const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); | | 848 | const paddr_t pa = BCM2711_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE); |
849 | const bus_space_tag_t iot = &bcm2711_bs_tag; | | 849 | const bus_space_tag_t iot = &bcm2711_bs_tag; |
850 | const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa); | | 850 | const bus_space_handle_t ioh = BCM2711_IOPHYSTOVIRT(pa); |
851 | | | 851 | |
852 | bcm283x_bootparams(iot, ioh); | | 852 | bcm283x_bootparams(iot, ioh); |
853 | } | | 853 | } |
854 | | | 854 | |
855 | #if defined(MULTIPROCESSOR) | | 855 | #if defined(MULTIPROCESSOR) |
856 | static int | | 856 | static int |
857 | cpu_enable_bcm2836(int phandle) | | 857 | cpu_enable_bcm2836(int phandle) |
858 | { | | 858 | { |
859 | bus_space_tag_t iot = &bcm2836_bs_tag; | | 859 | bus_space_tag_t iot = &bcm2836_bs_tag; |
860 | bus_space_handle_t ioh = BCM2836_ARM_LOCAL_VBASE; | | 860 | bus_space_handle_t ioh = BCM2836_ARM_LOCAL_VBASE; |
861 | uint64_t mpidr; | | 861 | uint64_t mpidr; |
862 | | | 862 | |
863 | fdtbus_get_reg64(phandle, 0, &mpidr, NULL); | | 863 | fdtbus_get_reg64(phandle, 0, &mpidr, NULL); |
864 | | | 864 | |
865 | const u_int cpuno = __SHIFTOUT(mpidr, MPIDR_AFF0); | | 865 | const u_int cpuno = __SHIFTOUT(mpidr, MPIDR_AFF0); |
866 | | | 866 | |
867 | bus_space_write_4(iot, ioh, BCM2836_LOCAL_MAILBOX3_SETN(cpuno), | | 867 | bus_space_write_4(iot, ioh, BCM2836_LOCAL_MAILBOX3_SETN(cpuno), |
868 | KERN_VTOPHYS((vaddr_t)cpu_mpstart)); | | 868 | KERN_VTOPHYS((vaddr_t)cpu_mpstart)); |
869 | | | 869 | |
870 | return 0; | | 870 | return 0; |
871 | } | | 871 | } |
872 | ARM_CPU_METHOD(bcm2836, "brcm,bcm2836-smp", cpu_enable_bcm2836); | | 872 | ARM_CPU_METHOD(bcm2836, "brcm,bcm2836-smp", cpu_enable_bcm2836); |
873 | #endif | | 873 | #endif |
874 | | | 874 | |
875 | #endif /* SOC_BCM2836 */ | | 875 | #endif /* SOC_BCM2836 */ |
876 | | | 876 | |
877 | #if NGENFB > 0 | | 877 | #if NGENFB > 0 |
878 | static bool | | 878 | static bool |
879 | rpi_fb_parse_mode(const char *s, uint32_t *pwidth, uint32_t *pheight) | | 879 | rpi_fb_parse_mode(const char *s, uint32_t *pwidth, uint32_t *pheight) |
880 | { | | 880 | { |
881 | char *x; | | 881 | char *x; |
882 | | | 882 | |
883 | if (strncmp(s, "disable", 7) == 0) | | 883 | if (strncmp(s, "disable", 7) == 0) |
884 | return false; | | 884 | return false; |
885 | | | 885 | |
886 | x = strchr(s, 'x'); | | 886 | x = strchr(s, 'x'); |
887 | if (x) { | | 887 | if (x) { |
888 | *pwidth = strtoul(s, NULL, 10); | | 888 | *pwidth = strtoul(s, NULL, 10); |
889 | *pheight = strtoul(x + 1, NULL, 10); | | 889 | *pheight = strtoul(x + 1, NULL, 10); |
890 | } | | 890 | } |
891 | | | 891 | |
892 | return true; | | 892 | return true; |
893 | } | | 893 | } |
894 | | | 894 | |
895 | static bool | | 895 | static bool |
896 | rpi_fb_get_edid_mode(uint32_t *pwidth, uint32_t *pheight) | | 896 | rpi_fb_get_edid_mode(uint32_t *pwidth, uint32_t *pheight) |
897 | { | | 897 | { |
898 | struct edid_info ei; | | 898 | struct edid_info ei; |
899 | uint8_t edid_data[1024]; | | 899 | uint8_t edid_data[1024]; |
900 | uint32_t res; | | 900 | uint32_t res; |
901 | int error; | | 901 | int error; |
902 | | | 902 | |
903 | error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_edid, | | 903 | error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_edid, |
904 | sizeof(vb_edid), &res); | | 904 | sizeof(vb_edid), &res); |
905 | if (error) { | | 905 | if (error) { |
906 | printf("%s: mbox request failed (%d)\n", __func__, error); | | 906 | printf("%s: mbox request failed (%d)\n", __func__, error); |
907 | return false; | | 907 | return false; |
908 | } | | 908 | } |
909 | | | 909 | |
910 | if (!vcprop_buffer_success_p(&vb_edid.vb_hdr) || | | 910 | if (!vcprop_buffer_success_p(&vb_edid.vb_hdr) || |
911 | !vcprop_tag_success_p(&vb_edid.vbt_edid.tag) || | | 911 | !vcprop_tag_success_p(&vb_edid.vbt_edid.tag) || |
912 | vb_edid.vbt_edid.status != 0) | | 912 | vb_edid.vbt_edid.status != 0) |
913 | return false; | | 913 | return false; |
914 | | | 914 | |
915 | memset(edid_data, 0, sizeof(edid_data)); | | 915 | memset(edid_data, 0, sizeof(edid_data)); |
916 | memcpy(edid_data, vb_edid.vbt_edid.data, | | 916 | memcpy(edid_data, vb_edid.vbt_edid.data, |
917 | sizeof(vb_edid.vbt_edid.data)); | | 917 | sizeof(vb_edid.vbt_edid.data)); |
918 | edid_parse(edid_data, &ei); | | 918 | edid_parse(edid_data, &ei); |
919 | #ifdef VERBOSE_INIT_ARM | | 919 | #ifdef VERBOSE_INIT_ARM |
920 | edid_print(&ei); | | 920 | edid_print(&ei); |
921 | #endif | | 921 | #endif |
922 | | | 922 | |
923 | if (ei.edid_preferred_mode) { | | 923 | if (ei.edid_preferred_mode) { |
924 | *pwidth = ei.edid_preferred_mode->hdisplay; | | 924 | *pwidth = ei.edid_preferred_mode->hdisplay; |
925 | *pheight = ei.edid_preferred_mode->vdisplay; | | 925 | *pheight = ei.edid_preferred_mode->vdisplay; |
926 | } | | 926 | } |
927 | | | 927 | |
928 | return true; | | 928 | return true; |
929 | } | | 929 | } |
930 | | | 930 | |
931 | /* | | 931 | /* |
932 | * Initialize framebuffer console. | | 932 | * Initialize framebuffer console. |
933 | * | | 933 | * |
934 | * Some notes about boot parameters: | | 934 | * Some notes about boot parameters: |
935 | * - If "fb=disable" is present, ignore framebuffer completely. | | 935 | * - If "fb=disable" is present, ignore framebuffer completely. |
936 | * - If "fb=<width>x<height> is present, use the specified mode. | | 936 | * - If "fb=<width>x<height> is present, use the specified mode. |
937 | * - If "console=fb" is present, attach framebuffer to console. | | 937 | * - If "console=fb" is present, attach framebuffer to console. |
938 | */ | | 938 | */ |
939 | static bool | | 939 | static bool |
940 | rpi_fb_init(prop_dictionary_t dict, void *aux) | | 940 | rpi_fb_init(prop_dictionary_t dict, void *aux) |
941 | { | | 941 | { |
942 | uint32_t width = 0, height = 0; | | 942 | uint32_t width = 0, height = 0; |
943 | uint32_t res; | | 943 | uint32_t res; |
944 | char *ptr; | | 944 | char *ptr; |
945 | int integer; | | 945 | int integer; |
946 | int error; | | 946 | int error; |
947 | bool is_bgr = true; | | 947 | bool is_bgr = true; |
948 | | | 948 | |
949 | if (get_bootconf_option(boot_args, "fb", | | 949 | if (get_bootconf_option(boot_args, "fb", |
950 | BOOTOPT_TYPE_STRING, &ptr)) { | | 950 | BOOTOPT_TYPE_STRING, &ptr)) { |
951 | if (rpi_fb_parse_mode(ptr, &width, &height) == false) | | 951 | if (rpi_fb_parse_mode(ptr, &width, &height) == false) |
952 | return false; | | 952 | return false; |
953 | } | | 953 | } |
954 | if (width == 0 || height == 0) { | | 954 | if (width == 0 || height == 0) { |
955 | rpi_fb_get_edid_mode(&width, &height); | | 955 | rpi_fb_get_edid_mode(&width, &height); |
956 | } | | 956 | } |
957 | if (width == 0 || height == 0) { | | 957 | if (width == 0 || height == 0) { |
958 | width = RPI_FB_WIDTH; | | 958 | width = RPI_FB_WIDTH; |
959 | height = RPI_FB_HEIGHT; | | 959 | height = RPI_FB_HEIGHT; |
960 | } | | 960 | } |
961 | | | 961 | |
962 | vb_setfb.vbt_res.width = width; | | 962 | vb_setfb.vbt_res.width = width; |
963 | vb_setfb.vbt_res.height = height; | | 963 | vb_setfb.vbt_res.height = height; |
964 | vb_setfb.vbt_vres.width = width; | | 964 | vb_setfb.vbt_vres.width = width; |
965 | vb_setfb.vbt_vres.height = height; | | 965 | vb_setfb.vbt_vres.height = height; |
966 | error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_setfb, | | 966 | error = bcmmbox_request(BCMMBOX_CHANARM2VC, &vb_setfb, |
967 | sizeof(vb_setfb), &res); | | 967 | sizeof(vb_setfb), &res); |
968 | if (error) { | | 968 | if (error) { |
969 | printf("%s: mbox request failed (%d)\n", __func__, error); | | 969 | printf("%s: mbox request failed (%d)\n", __func__, error); |
970 | return false; | | 970 | return false; |
971 | } | | 971 | } |
972 | | | 972 | |
973 | if (!vcprop_buffer_success_p(&vb_setfb.vb_hdr) || | | 973 | if (!vcprop_buffer_success_p(&vb_setfb.vb_hdr) || |
974 | !vcprop_tag_success_p(&vb_setfb.vbt_res.tag) || | | 974 | !vcprop_tag_success_p(&vb_setfb.vbt_res.tag) || |
975 | !vcprop_tag_success_p(&vb_setfb.vbt_vres.tag) || | | 975 | !vcprop_tag_success_p(&vb_setfb.vbt_vres.tag) || |
976 | !vcprop_tag_success_p(&vb_setfb.vbt_depth.tag) || | | 976 | !vcprop_tag_success_p(&vb_setfb.vbt_depth.tag) || |
977 | !vcprop_tag_success_p(&vb_setfb.vbt_allocbuf.tag) || | | 977 | !vcprop_tag_success_p(&vb_setfb.vbt_allocbuf.tag) || |
978 | !vcprop_tag_success_p(&vb_setfb.vbt_blank.tag) || | | 978 | !vcprop_tag_success_p(&vb_setfb.vbt_blank.tag) || |
979 | !vcprop_tag_success_p(&vb_setfb.vbt_pitch.tag)) { | | 979 | !vcprop_tag_success_p(&vb_setfb.vbt_pitch.tag)) { |
980 | printf("%s: prop tag failed\n", __func__); | | 980 | printf("%s: prop tag failed\n", __func__); |
981 | return false; | | 981 | return false; |
982 | } | | 982 | } |
983 | | | 983 | |
984 | #ifdef VERBOSE_INIT_ARM | | 984 | #ifdef VERBOSE_INIT_ARM |
985 | printf("%s: addr = 0x%x size = %d\n", __func__, | | 985 | printf("%s: addr = 0x%x size = %d\n", __func__, |
986 | vb_setfb.vbt_allocbuf.address, | | 986 | vb_setfb.vbt_allocbuf.address, |
987 | vb_setfb.vbt_allocbuf.size); | | 987 | vb_setfb.vbt_allocbuf.size); |
988 | printf("%s: depth = %d\n", __func__, vb_setfb.vbt_depth.bpp); | | 988 | printf("%s: depth = %d\n", __func__, vb_setfb.vbt_depth.bpp); |
989 | printf("%s: pitch = %d\n", __func__, | | 989 | printf("%s: pitch = %d\n", __func__, |
990 | vb_setfb.vbt_pitch.linebytes); | | 990 | vb_setfb.vbt_pitch.linebytes); |
991 | printf("%s: width = %d height = %d\n", __func__, | | 991 | printf("%s: width = %d height = %d\n", __func__, |
992 | vb_setfb.vbt_res.width, vb_setfb.vbt_res.height); | | 992 | vb_setfb.vbt_res.width, vb_setfb.vbt_res.height); |
993 | printf("%s: vwidth = %d vheight = %d\n", __func__, | | 993 | printf("%s: vwidth = %d vheight = %d\n", __func__, |
994 | vb_setfb.vbt_vres.width, vb_setfb.vbt_vres.height); | | 994 | vb_setfb.vbt_vres.width, vb_setfb.vbt_vres.height); |
995 | #endif | | 995 | #endif |
996 | | | 996 | |
997 | if (vb_setfb.vbt_allocbuf.address == 0 || | | 997 | if (vb_setfb.vbt_allocbuf.address == 0 || |
998 | vb_setfb.vbt_allocbuf.size == 0 || | | 998 | vb_setfb.vbt_allocbuf.size == 0 || |
999 | vb_setfb.vbt_res.width == 0 || | | 999 | vb_setfb.vbt_res.width == 0 || |
1000 | vb_setfb.vbt_res.height == 0 || | | 1000 | vb_setfb.vbt_res.height == 0 || |
1001 | vb_setfb.vbt_vres.width == 0 || | | 1001 | vb_setfb.vbt_vres.width == 0 || |
1002 | vb_setfb.vbt_vres.height == 0 || | | 1002 | vb_setfb.vbt_vres.height == 0 || |
1003 | vb_setfb.vbt_pitch.linebytes == 0) { | | 1003 | vb_setfb.vbt_pitch.linebytes == 0) { |
1004 | printf("%s: failed to set mode %ux%u\n", __func__, | | 1004 | printf("%s: failed to set mode %ux%u\n", __func__, |
1005 | width, height); | | 1005 | width, height); |
1006 | return false; | | 1006 | return false; |
1007 | } | | 1007 | } |
1008 | | | 1008 | |
1009 | prop_dictionary_set_uint32(dict, "width", vb_setfb.vbt_res.width); | | 1009 | prop_dictionary_set_uint32(dict, "width", vb_setfb.vbt_res.width); |
1010 | prop_dictionary_set_uint32(dict, "height", vb_setfb.vbt_res.height); | | 1010 | prop_dictionary_set_uint32(dict, "height", vb_setfb.vbt_res.height); |
1011 | prop_dictionary_set_uint8(dict, "depth", vb_setfb.vbt_depth.bpp); | | 1011 | prop_dictionary_set_uint8(dict, "depth", vb_setfb.vbt_depth.bpp); |
1012 | prop_dictionary_set_uint16(dict, "linebytes", | | 1012 | prop_dictionary_set_uint16(dict, "linebytes", |
1013 | vb_setfb.vbt_pitch.linebytes); | | 1013 | vb_setfb.vbt_pitch.linebytes); |
1014 | prop_dictionary_set_uint32(dict, "address", | | 1014 | prop_dictionary_set_uint32(dict, "address", |
1015 | vb_setfb.vbt_allocbuf.address); | | 1015 | vb_setfb.vbt_allocbuf.address); |
1016 | | | 1016 | |
1017 | /* | | 1017 | /* |
1018 | * Old firmware uses BGR. New firmware uses RGB. The get and set | | 1018 | * Old firmware uses BGR. New firmware uses RGB. The get and set |
1019 | * pixel order mailbox properties don't seem to work. The firmware | | 1019 | * pixel order mailbox properties don't seem to work. The firmware |
1020 | * adds a kernel cmdline option bcm2708_fb.fbswap=<0|1>, so use it | | 1020 | * adds a kernel cmdline option bcm2708_fb.fbswap=<0|1>, so use it |
1021 | * to determine pixel order. 0 means BGR, 1 means RGB. | | 1021 | * to determine pixel order. 0 means BGR, 1 means RGB. |
1022 | * | | 1022 | * |
1023 | * See https://github.com/raspberrypi/linux/issues/514 | | 1023 | * See https://github.com/raspberrypi/linux/issues/514 |
1024 | */ | | 1024 | */ |
1025 | if (get_bootconf_option(boot_args, "bcm2708_fb.fbswap", | | 1025 | if (get_bootconf_option(boot_args, "bcm2708_fb.fbswap", |
1026 | BOOTOPT_TYPE_INT, &integer)) { | | 1026 | BOOTOPT_TYPE_INT, &integer)) { |
1027 | is_bgr = integer == 0; | | 1027 | is_bgr = integer == 0; |
1028 | } | | 1028 | } |
1029 | prop_dictionary_set_bool(dict, "is_bgr", is_bgr); | | 1029 | prop_dictionary_set_bool(dict, "is_bgr", is_bgr); |
1030 | | | 1030 | |
1031 | /* if "genfb.type=<n>" is passed in cmdline, override wsdisplay type */ | | 1031 | /* if "genfb.type=<n>" is passed in cmdline, override wsdisplay type */ |
1032 | if (get_bootconf_option(boot_args, "genfb.type", | | 1032 | if (get_bootconf_option(boot_args, "genfb.type", |
1033 | BOOTOPT_TYPE_INT, &integer)) { | | 1033 | BOOTOPT_TYPE_INT, &integer)) { |
1034 | prop_dictionary_set_uint32(dict, "wsdisplay_type", integer); | | 1034 | prop_dictionary_set_uint32(dict, "wsdisplay_type", integer); |
1035 | } | | 1035 | } |
1036 | | | 1036 | |
1037 | #if defined(RPI_HWCURSOR) | | 1037 | #if defined(RPI_HWCURSOR) |
1038 | struct fdt_attach_args *faa = aux; | | 1038 | struct fdt_attach_args *faa = aux; |
1039 | bus_space_handle_t hc; | | 1039 | bus_space_handle_t hc; |
1040 | | | 1040 | |
1041 | hcursor = rpi_alloc_mem(CURSOR_ARGB_SIZE, PAGE_SIZE, | | 1041 | hcursor = rpi_alloc_mem(CURSOR_ARGB_SIZE, PAGE_SIZE, |
1042 | MEM_FLAG_L1_NONALLOCATING | MEM_FLAG_HINT_PERMALOCK); | | 1042 | MEM_FLAG_L1_NONALLOCATING | MEM_FLAG_HINT_PERMALOCK); |
1043 | pcursor = rpi_lock_mem(hcursor); | | 1043 | pcursor = rpi_lock_mem(hcursor); |
1044 | #ifdef RPI_IOCTL_DEBUG | | 1044 | #ifdef RPI_IOCTL_DEBUG |
1045 | printf("hcursor: %08x\n", hcursor); | | 1045 | printf("hcursor: %08x\n", hcursor); |
1046 | printf("pcursor: %08x\n", (uint32_t)pcursor); | | 1046 | printf("pcursor: %08x\n", (uint32_t)pcursor); |
1047 | printf("fb: %08x\n", (uint32_t)vb_setfb.vbt_allocbuf.address); | | 1047 | printf("fb: %08x\n", (uint32_t)vb_setfb.vbt_allocbuf.address); |
1048 | #endif | | 1048 | #endif |
1049 | if (bus_space_map(faa->faa_bst, pcursor, CURSOR_ARGB_SIZE, | | 1049 | if (bus_space_map(faa->faa_bst, pcursor, CURSOR_ARGB_SIZE, |
1050 | BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &hc) != 0) { | | 1050 | BUS_SPACE_MAP_LINEAR|BUS_SPACE_MAP_PREFETCHABLE, &hc) != 0) { |
1051 | printf("couldn't map cursor memory\n"); | | 1051 | printf("couldn't map cursor memory\n"); |
1052 | } else { | | 1052 | } else { |
1053 | int i, j, k; | | 1053 | int i, j, k; |
1054 | | | 1054 | |
1055 | cmem = bus_space_vaddr(faa->faa_bst, hc); | | 1055 | cmem = bus_space_vaddr(faa->faa_bst, hc); |
1056 | k = 0; | | 1056 | k = 0; |
1057 | for (j = 0; j < 64; j++) { | | 1057 | for (j = 0; j < 64; j++) { |
1058 | for (i = 0; i < 64; i++) { | | 1058 | for (i = 0; i < 64; i++) { |
1059 | cmem[i + k] = | | 1059 | cmem[i + k] = |
1060 | ((i & 8) ^ (j & 8)) ? 0xa0ff0000 : 0xa000ff00; | | 1060 | ((i & 8) ^ (j & 8)) ? 0xa0ff0000 : 0xa000ff00; |
1061 | } | | 1061 | } |
1062 | k += 64; | | 1062 | k += 64; |
1063 | } | | 1063 | } |
1064 | cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); | | 1064 | cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); |
1065 | rpi_fb_initcursor(pcursor, 0, 0); | | 1065 | rpi_fb_initcursor(pcursor, 0, 0); |
1066 | #ifdef RPI_IOCTL_DEBUG | | 1066 | #ifdef RPI_IOCTL_DEBUG |
1067 | rpi_fb_movecursor(600, 400, 1); | | 1067 | rpi_fb_movecursor(600, 400, 1); |
1068 | #else | | 1068 | #else |
1069 | rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); | | 1069 | rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); |
1070 | #endif | | 1070 | #endif |
1071 | } | | 1071 | } |
1072 | #endif | | 1072 | #endif |
1073 | | | 1073 | |
1074 | return true; | | 1074 | return true; |
1075 | } | | 1075 | } |
1076 | | | 1076 | |
1077 | | | 1077 | |
1078 | #if defined(RPI_HWCURSOR) | | 1078 | #if defined(RPI_HWCURSOR) |
1079 | static int | | 1079 | static int |
1080 | rpi_fb_do_cursor(struct wsdisplay_cursor *cur) | | 1080 | rpi_fb_do_cursor(struct wsdisplay_cursor *cur) |
1081 | { | | 1081 | { |
1082 | int pos = 0; | | 1082 | int pos = 0; |
1083 | int shape = 0; | | 1083 | int shape = 0; |
1084 | | | 1084 | |
1085 | if (cur->which & WSDISPLAY_CURSOR_DOCUR) { | | 1085 | if (cur->which & WSDISPLAY_CURSOR_DOCUR) { |
1086 | if (cursor_on != cur->enable) { | | 1086 | if (cursor_on != cur->enable) { |
1087 | cursor_on = cur->enable; | | 1087 | cursor_on = cur->enable; |
1088 | pos = 1; | | 1088 | pos = 1; |
1089 | } | | 1089 | } |
1090 | } | | 1090 | } |
1091 | if (cur->which & WSDISPLAY_CURSOR_DOHOT) { | | 1091 | if (cur->which & WSDISPLAY_CURSOR_DOHOT) { |
1092 | | | 1092 | |
1093 | hot_x = cur->hot.x; | | 1093 | hot_x = cur->hot.x; |
1094 | hot_y = cur->hot.y; | | 1094 | hot_y = cur->hot.y; |
1095 | pos = 1; | | 1095 | pos = 1; |
1096 | shape = 1; | | 1096 | shape = 1; |
1097 | } | | 1097 | } |
1098 | if (cur->which & WSDISPLAY_CURSOR_DOPOS) { | | 1098 | if (cur->which & WSDISPLAY_CURSOR_DOPOS) { |
1099 | | | 1099 | |
1100 | cursor_x = cur->pos.x; | | 1100 | cursor_x = cur->pos.x; |
1101 | cursor_y = cur->pos.y; | | 1101 | cursor_y = cur->pos.y; |
1102 | pos = 1; | | 1102 | pos = 1; |
1103 | } | | 1103 | } |
1104 | if (cur->which & WSDISPLAY_CURSOR_DOCMAP) { | | 1104 | if (cur->which & WSDISPLAY_CURSOR_DOCMAP) { |
1105 | int i; | | 1105 | int i; |
1106 | uint32_t val; | | 1106 | uint32_t val; |
1107 | | | 1107 | |
1108 | for (i = 0; i < uimin(cur->cmap.count, 3); i++) { | | 1108 | for (i = 0; i < uimin(cur->cmap.count, 3); i++) { |
1109 | val = (cur->cmap.red[i] << 16 ) | | | 1109 | val = (cur->cmap.red[i] << 16 ) | |
1110 | (cur->cmap.green[i] << 8) | | | 1110 | (cur->cmap.green[i] << 8) | |
1111 | (cur->cmap.blue[i] ) | | | 1111 | (cur->cmap.blue[i] ) | |
1112 | 0xff000000; | | 1112 | 0xff000000; |
1113 | cursor_cmap[i + cur->cmap.index + 2] = val; | | 1113 | cursor_cmap[i + cur->cmap.index + 2] = val; |
1114 | } | | 1114 | } |
1115 | shape = 1; | | 1115 | shape = 1; |
1116 | } | | 1116 | } |
1117 | if (cur->which & WSDISPLAY_CURSOR_DOSHAPE) { | | 1117 | if (cur->which & WSDISPLAY_CURSOR_DOSHAPE) { |
1118 | int err; | | 1118 | int err; |
1119 | | | 1119 | |
1120 | err = copyin(cur->mask, cursor_mask, CURSOR_BITMAP_SIZE); | | 1120 | err = copyin(cur->mask, cursor_mask, CURSOR_BITMAP_SIZE); |
1121 | err += copyin(cur->image, cursor_bitmap, CURSOR_BITMAP_SIZE); | | 1121 | err += copyin(cur->image, cursor_bitmap, CURSOR_BITMAP_SIZE); |
1122 | if (err != 0) | | 1122 | if (err != 0) |
1123 | return EFAULT; | | 1123 | return EFAULT; |
1124 | shape = 1; | | 1124 | shape = 1; |
1125 | } | | 1125 | } |
1126 | if (shape) { | | 1126 | if (shape) { |
1127 | int i, j, idx; | | 1127 | int i, j, idx; |
1128 | uint8_t mask; | | 1128 | uint8_t mask; |
1129 | | | 1129 | |
1130 | for (i = 0; i < CURSOR_BITMAP_SIZE; i++) { | | 1130 | for (i = 0; i < CURSOR_BITMAP_SIZE; i++) { |
1131 | mask = 0x01; | | 1131 | mask = 0x01; |
1132 | for (j = 0; j < 8; j++) { | | 1132 | for (j = 0; j < 8; j++) { |
1133 | idx = ((cursor_mask[i] & mask) ? 2 : 0) | | | 1133 | idx = ((cursor_mask[i] & mask) ? 2 : 0) | |
1134 | ((cursor_bitmap[i] & mask) ? 1 : 0); | | 1134 | ((cursor_bitmap[i] & mask) ? 1 : 0); |
1135 | cmem[i * 8 + j] = cursor_cmap[idx]; | | 1135 | cmem[i * 8 + j] = cursor_cmap[idx]; |
1136 | mask = mask << 1; | | 1136 | mask = mask << 1; |
1137 | } | | 1137 | } |
1138 | } | | 1138 | } |
1139 | /* just in case */ | | 1139 | /* just in case */ |
1140 | cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); | | 1140 | cpu_dcache_wb_range((vaddr_t)cmem, CURSOR_ARGB_SIZE); |
1141 | rpi_fb_initcursor(pcursor, hot_x, hot_y); | | 1141 | rpi_fb_initcursor(pcursor, hot_x, hot_y); |
1142 | } | | 1142 | } |
1143 | if (pos) { | | 1143 | if (pos) { |
1144 | rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); | | 1144 | rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); |
1145 | } | | 1145 | } |
1146 | return 0; | | 1146 | return 0; |
1147 | } | | 1147 | } |
1148 | #endif | | 1148 | #endif |
1149 | | | 1149 | |
1150 | static int | | 1150 | static int |
1151 | rpi_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l) | | 1151 | rpi_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, lwp_t *l) |
1152 | { | | 1152 | { |
1153 | | | 1153 | |
1154 | switch (cmd) { | | 1154 | switch (cmd) { |
1155 | case WSDISPLAYIO_SVIDEO: | | 1155 | case WSDISPLAYIO_SVIDEO: |
1156 | { | | 1156 | { |
1157 | int d = *(int *)data; | | 1157 | int d = *(int *)data; |
1158 | if (d == rpi_video_on) | | 1158 | if (d == rpi_video_on) |
1159 | return 0; | | 1159 | return 0; |
1160 | rpi_video_on = d; | | 1160 | rpi_video_on = d; |
1161 | rpi_fb_set_video(d); | | 1161 | rpi_fb_set_video(d); |
1162 | #if defined(RPI_HWCURSOR) | | 1162 | #if defined(RPI_HWCURSOR) |
1163 | rpi_fb_movecursor(cursor_x, cursor_y, | | 1163 | rpi_fb_movecursor(cursor_x, cursor_y, |
1164 | d ? cursor_on : 0); | | 1164 | d ? cursor_on : 0); |
1165 | #endif | | 1165 | #endif |
1166 | } | | 1166 | } |
1167 | return 0; | | 1167 | return 0; |
1168 | case WSDISPLAYIO_GVIDEO: | | 1168 | case WSDISPLAYIO_GVIDEO: |
1169 | *(int *)data = rpi_video_on; | | 1169 | *(int *)data = rpi_video_on; |
1170 | return 0; | | 1170 | return 0; |
1171 | #if defined(RPI_HWCURSOR) | | 1171 | #if defined(RPI_HWCURSOR) |
1172 | case WSDISPLAYIO_GCURPOS: | | 1172 | case WSDISPLAYIO_GCURPOS: |
1173 | { | | 1173 | { |
1174 | struct wsdisplay_curpos *cp = (void *)data; | | 1174 | struct wsdisplay_curpos *cp = (void *)data; |
1175 | | | 1175 | |
1176 | cp->x = cursor_x; | | 1176 | cp->x = cursor_x; |
1177 | cp->y = cursor_y; | | 1177 | cp->y = cursor_y; |
1178 | } | | 1178 | } |
1179 | return 0; | | 1179 | return 0; |
1180 | case WSDISPLAYIO_SCURPOS: | | 1180 | case WSDISPLAYIO_SCURPOS: |
1181 | { | | 1181 | { |
1182 | struct wsdisplay_curpos *cp = (void *)data; | | 1182 | struct wsdisplay_curpos *cp = (void *)data; |
1183 | | | 1183 | |
1184 | cursor_x = cp->x; | | 1184 | cursor_x = cp->x; |
1185 | cursor_y = cp->y; | | 1185 | cursor_y = cp->y; |
1186 | rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); | | 1186 | rpi_fb_movecursor(cursor_x, cursor_y, cursor_on); |
1187 | } | | 1187 | } |
1188 | return 0; | | 1188 | return 0; |
1189 | case WSDISPLAYIO_GCURMAX: | | 1189 | case WSDISPLAYIO_GCURMAX: |
1190 | { | | 1190 | { |
1191 | struct wsdisplay_curpos *cp = (void *)data; | | 1191 | struct wsdisplay_curpos *cp = (void *)data; |
1192 | | | 1192 | |
1193 | cp->x = 64; | | 1193 | cp->x = 64; |
1194 | cp->y = 64; | | 1194 | cp->y = 64; |
1195 | } | | 1195 | } |
1196 | return 0; | | 1196 | return 0; |
1197 | case WSDISPLAYIO_SCURSOR: | | 1197 | case WSDISPLAYIO_SCURSOR: |
1198 | { | | 1198 | { |
1199 | struct wsdisplay_cursor *cursor = (void *)data; | | 1199 | struct wsdisplay_cursor *cursor = (void *)data; |
1200 | | | 1200 | |
1201 | return rpi_fb_do_cursor(cursor); | | 1201 | return rpi_fb_do_cursor(cursor); |
1202 | } | | 1202 | } |
1203 | #endif | | 1203 | #endif |
1204 | default: | | 1204 | default: |
1205 | return EPASSTHROUGH; | | 1205 | return EPASSTHROUGH; |
1206 | } | | 1206 | } |
1207 | } | | 1207 | } |
1208 | | | 1208 | |
1209 | #endif | | 1209 | #endif |
1210 | | | 1210 | |
1211 | SYSCTL_SETUP(sysctl_machdep_rpi, "sysctl machdep subtree setup (rpi)") | | 1211 | SYSCTL_SETUP(sysctl_machdep_rpi, "sysctl machdep subtree setup (rpi)") |
1212 | { | | 1212 | { |
1213 | sysctl_createv(clog, 0, NULL, NULL, | | 1213 | sysctl_createv(clog, 0, NULL, NULL, |
1214 | CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, | | 1214 | CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL, |
1215 | NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); | | 1215 | NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL); |
1216 | | | 1216 | |
1217 | sysctl_createv(clog, 0, NULL, NULL, | | 1217 | sysctl_createv(clog, 0, NULL, NULL, |
1218 | CTLFLAG_PERMANENT|CTLFLAG_READONLY, | | 1218 | CTLFLAG_PERMANENT|CTLFLAG_READONLY, |
1219 | CTLTYPE_INT, "firmware_revision", NULL, NULL, 0, | | 1219 | CTLTYPE_INT, "firmware_revision", NULL, NULL, 0, |
1220 | &vb.vbt_fwrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); | | 1220 | &vb.vbt_fwrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); |
1221 | | | 1221 | |
1222 | sysctl_createv(clog, 0, NULL, NULL, | | 1222 | sysctl_createv(clog, 0, NULL, NULL, |
1223 | CTLFLAG_PERMANENT|CTLFLAG_READONLY, | | 1223 | CTLFLAG_PERMANENT|CTLFLAG_READONLY, |
1224 | CTLTYPE_INT, "board_model", NULL, NULL, 0, | | 1224 | CTLTYPE_INT, "board_model", NULL, NULL, 0, |
1225 | &vb.vbt_boardmodel.model, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); | | 1225 | &vb.vbt_boardmodel.model, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); |
1226 | | | 1226 | |
1227 | sysctl_createv(clog, 0, NULL, NULL, | | 1227 | sysctl_createv(clog, 0, NULL, NULL, |
1228 | CTLFLAG_PERMANENT|CTLFLAG_READONLY, | | 1228 | CTLFLAG_PERMANENT|CTLFLAG_READONLY, |
1229 | CTLTYPE_INT, "board_revision", NULL, NULL, 0, | | 1229 | CTLTYPE_INT, "board_revision", NULL, NULL, 0, |
1230 | &vb.vbt_boardrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); | | 1230 | &vb.vbt_boardrev.rev, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); |
1231 | | | 1231 | |
1232 | sysctl_createv(clog, 0, NULL, NULL, | | 1232 | sysctl_createv(clog, 0, NULL, NULL, |
1233 | CTLFLAG_PERMANENT|CTLFLAG_READONLY|CTLFLAG_HEX|CTLFLAG_PRIVATE, | | 1233 | CTLFLAG_PERMANENT|CTLFLAG_READONLY|CTLFLAG_HEX|CTLFLAG_PRIVATE, |
1234 | CTLTYPE_QUAD, "serial", NULL, NULL, 0, | | 1234 | CTLTYPE_QUAD, "serial", NULL, NULL, 0, |
1235 | &vb.vbt_serial.sn, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); | | 1235 | &vb.vbt_serial.sn, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL); |
1236 | } | | 1236 | } |
1237 | | | 1237 | |
1238 | #if defined(SOC_BCM2835) | | 1238 | #if defined(SOC_BCM2835) |
1239 | static void | | 1239 | static void |
1240 | bcm2835_platform_bootstrap(void) | | 1240 | bcm2835_platform_bootstrap(void) |
1241 | { | | 1241 | { |
1242 | | | 1242 | |
1243 | bcm2835_bs_tag = arm_generic_bs_tag; | | 1243 | bcm2835_bs_tag = arm_generic_bs_tag; |
1244 | bcm2835_a4x_bs_tag = arm_generic_a4x_bs_tag; | | 1244 | bcm2835_a4x_bs_tag = arm_generic_a4x_bs_tag; |
1245 | | | 1245 | |
1246 | bcm2835_bs_tag.bs_map = bcm2835_bs_map; | | 1246 | bcm2835_bs_tag.bs_map = bcm2835_bs_map; |
1247 | bcm2835_bs_tag.bs_mmap = bcm2835_bs_mmap; | | 1247 | bcm2835_bs_tag.bs_mmap = bcm2835_bs_mmap; |
1248 | bcm2835_a4x_bs_tag.bs_map = bcm2835_bs_map; | | 1248 | bcm2835_a4x_bs_tag.bs_map = bcm2835_bs_map; |
1249 | bcm2835_a4x_bs_tag.bs_mmap = bcm2835_a4x_bs_mmap; | | 1249 | bcm2835_a4x_bs_tag.bs_mmap = bcm2835_a4x_bs_mmap; |
1250 | | | 1250 | |
1251 | fdtbus_set_decoderegprop(false); | | 1251 | fdtbus_set_decoderegprop(false); |
1252 | | | 1252 | |
1253 | bcm2835_uartinit(); | | 1253 | bcm2835_uartinit(); |
1254 | | | 1254 | |
1255 | bcm2835_bootparams(); | | 1255 | bcm2835_bootparams(); |
1256 | } | | 1256 | } |
1257 | #endif | | 1257 | #endif |
1258 | | | 1258 | |
1259 | #if defined(SOC_BCM2836) | | 1259 | #if defined(SOC_BCM2836) |
1260 | static void | | 1260 | static void |
1261 | bcm2836_platform_bootstrap(void) | | 1261 | bcm2836_platform_bootstrap(void) |
1262 | { | | 1262 | { |
1263 | | | 1263 | |
1264 | bcm2836_bs_tag = arm_generic_bs_tag; | | 1264 | bcm2836_bs_tag = arm_generic_bs_tag; |
1265 | bcm2836_a4x_bs_tag = arm_generic_a4x_bs_tag; | | 1265 | bcm2836_a4x_bs_tag = arm_generic_a4x_bs_tag; |
1266 | | | 1266 | |
1267 | bcm2836_bs_tag.bs_map = bcm2836_bs_map; | | 1267 | bcm2836_bs_tag.bs_map = bcm2836_bs_map; |
1268 | bcm2836_bs_tag.bs_mmap = bcm2836_bs_mmap; | | 1268 | bcm2836_bs_tag.bs_mmap = bcm2836_bs_mmap; |
1269 | bcm2836_a4x_bs_tag.bs_map = bcm2836_bs_map; | | 1269 | bcm2836_a4x_bs_tag.bs_map = bcm2836_bs_map; |
1270 | bcm2836_a4x_bs_tag.bs_mmap = bcm2836_a4x_bs_mmap; | | 1270 | bcm2836_a4x_bs_tag.bs_mmap = bcm2836_a4x_bs_mmap; |
1271 | | | 1271 | |
1272 | fdtbus_set_decoderegprop(false); | | 1272 | fdtbus_set_decoderegprop(false); |
1273 | | | 1273 | |
1274 | bcm2836_uartinit(); | | 1274 | bcm2836_uartinit(); |
1275 | | | 1275 | |
1276 | bcm2836_bootparams(); | | 1276 | bcm2836_bootparams(); |
1277 | | | 1277 | |
1278 | #ifdef MULTIPROCESSOR | | 1278 | #ifdef MULTIPROCESSOR |
1279 | arm_cpu_max = RPI_CPU_MAX; | | 1279 | arm_cpu_max = RPI_CPU_MAX; |
1280 | arm_fdt_cpu_bootstrap(); | | 1280 | arm_fdt_cpu_bootstrap(); |
1281 | #endif | | 1281 | #endif |
1282 | } | | 1282 | } |
1283 | | | 1283 | |
1284 | static void | | 1284 | static void |
1285 | bcm2711_platform_bootstrap(void) | | 1285 | bcm2711_platform_bootstrap(void) |
1286 | { | | 1286 | { |
1287 | | | 1287 | |
1288 | bcm2711_bs_tag = arm_generic_bs_tag; | | 1288 | bcm2711_bs_tag = arm_generic_bs_tag; |
1289 | bcm2711_a4x_bs_tag = arm_generic_a4x_bs_tag; | | 1289 | bcm2711_a4x_bs_tag = arm_generic_a4x_bs_tag; |
1290 | | | 1290 | |
1291 | bcm2711_bs_tag.bs_map = bcm2711_bs_map; | | 1291 | bcm2711_bs_tag.bs_map = bcm2711_bs_map; |
1292 | bcm2711_bs_tag.bs_mmap = bcm2711_bs_mmap; | | 1292 | bcm2711_bs_tag.bs_mmap = bcm2711_bs_mmap; |
1293 | bcm2711_a4x_bs_tag.bs_map = bcm2711_bs_map; | | 1293 | bcm2711_a4x_bs_tag.bs_map = bcm2711_bs_map; |
1294 | bcm2711_a4x_bs_tag.bs_mmap = bcm2711_a4x_bs_mmap; | | 1294 | bcm2711_a4x_bs_tag.bs_mmap = bcm2711_a4x_bs_mmap; |
1295 | | | 1295 | |
1296 | fdtbus_set_decoderegprop(false); | | 1296 | fdtbus_set_decoderegprop(false); |
1297 | | | 1297 | |
1298 | bcm2711_uartinit(); | | 1298 | bcm2711_uartinit(); |
1299 | | | 1299 | |
1300 | bcm2711_bootparams(); | | 1300 | bcm2711_bootparams(); |
1301 | | | 1301 | |
1302 | #ifdef MULTIPROCESSOR | | 1302 | #ifdef MULTIPROCESSOR |
1303 | arm_cpu_max = RPI_CPU_MAX; | | 1303 | arm_cpu_max = RPI_CPU_MAX; |
1304 | arm_fdt_cpu_bootstrap(); | | 1304 | arm_fdt_cpu_bootstrap(); |
1305 | #endif | | 1305 | #endif |
1306 | } | | 1306 | } |
1307 | #endif | | 1307 | #endif |
1308 | | | 1308 | |
1309 | #if defined(SOC_BCM2835) | | 1309 | #if defined(SOC_BCM2835) |
1310 | static void | | 1310 | static void |
1311 | bcm2835_platform_init_attach_args(struct fdt_attach_args *faa) | | 1311 | bcm2835_platform_init_attach_args(struct fdt_attach_args *faa) |
1312 | { | | 1312 | { |
1313 | | | 1313 | |
1314 | faa->faa_bst = &bcm2835_bs_tag; | | 1314 | faa->faa_bst = &bcm2835_bs_tag; |
1315 | faa->faa_a4x_bst = &bcm2835_a4x_bs_tag; | | 1315 | faa->faa_a4x_bst = &bcm2835_a4x_bs_tag; |
1316 | faa->faa_dmat = &bcm2835_bus_dma_tag; | | 1316 | faa->faa_dmat = &bcm2835_bus_dma_tag; |
1317 | | | 1317 | |
1318 | bcm2835_bus_dma_tag._ranges = bcm2835_dma_ranges; | | 1318 | bcm2835_bus_dma_tag._ranges = bcm2835_dma_ranges; |
1319 | bcm2835_bus_dma_tag._nranges = __arraycount(bcm2835_dma_ranges); | | 1319 | bcm2835_bus_dma_tag._nranges = __arraycount(bcm2835_dma_ranges); |
1320 | bcm2835_dma_ranges[0].dr_len = bcm283x_memorysize; | | 1320 | bcm2835_dma_ranges[0].dr_len = bcm283x_memorysize; |
1321 | } | | 1321 | } |
1322 | #endif | | 1322 | #endif |
1323 | | | 1323 | |
1324 | #if defined(SOC_BCM2836) | | 1324 | #if defined(SOC_BCM2836) |
1325 | static void | | 1325 | static void |
1326 | bcm2836_platform_init_attach_args(struct fdt_attach_args *faa) | | 1326 | bcm2836_platform_init_attach_args(struct fdt_attach_args *faa) |
1327 | { | | 1327 | { |
1328 | | | 1328 | |
1329 | faa->faa_bst = &bcm2836_bs_tag; | | 1329 | faa->faa_bst = &bcm2836_bs_tag; |
1330 | faa->faa_a4x_bst = &bcm2836_a4x_bs_tag; | | 1330 | faa->faa_a4x_bst = &bcm2836_a4x_bs_tag; |
1331 | faa->faa_dmat = &bcm2835_bus_dma_tag; | | 1331 | faa->faa_dmat = &bcm2835_bus_dma_tag; |
1332 | | | 1332 | |
1333 | bcm2835_bus_dma_tag._ranges = bcm2836_dma_ranges; | | 1333 | bcm2835_bus_dma_tag._ranges = bcm2836_dma_ranges; |
1334 | bcm2835_bus_dma_tag._nranges = __arraycount(bcm2836_dma_ranges); | | 1334 | bcm2835_bus_dma_tag._nranges = __arraycount(bcm2836_dma_ranges); |
1335 | bcm2836_dma_ranges[0].dr_len = bcm283x_memorysize; | | 1335 | bcm2836_dma_ranges[0].dr_len = bcm283x_memorysize; |