Tue Jun 18 15:37:16 2013 UTC ()
Add PL310 L2CC init for OMAP4.
Use OMAP_[345]XXX
Add OMAP4 hooks in beagle_device_register


(matt)
diff -r1.46 -r1.47 src/sys/arch/evbarm/beagle/beagle_machdep.c

cvs diff -r1.46 -r1.47 src/sys/arch/evbarm/beagle/Attic/beagle_machdep.c (switch to unified diff)

--- src/sys/arch/evbarm/beagle/Attic/beagle_machdep.c 2013/06/17 04:37:39 1.46
+++ src/sys/arch/evbarm/beagle/Attic/beagle_machdep.c 2013/06/18 15:37:16 1.47
@@ -1,932 +1,957 @@ @@ -1,932 +1,957 @@
1/* $NetBSD: beagle_machdep.c,v 1.46 2013/06/17 04:37:39 matt Exp $ */ 1/* $NetBSD: beagle_machdep.c,v 1.47 2013/06/18 15:37:16 matt Exp $ */
2 2
3/* 3/*
4 * Machine dependent functions for kernel setup for TI OSK5912 board. 4 * Machine dependent functions for kernel setup for TI OSK5912 board.
5 * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c 5 * Based on lubbock_machdep.c which in turn was based on iq80310_machhdep.c
6 * 6 *
7 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved. 7 * Copyright (c) 2002, 2003, 2005 Genetec Corporation. All rights reserved.
8 * Written by Hiroyuki Bessho for Genetec Corporation. 8 * Written by Hiroyuki Bessho for Genetec Corporation.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. The name of Genetec Corporation may not be used to endorse or 18 * 3. The name of Genetec Corporation may not be used to endorse or
19 * promote products derived from this software without specific prior 19 * promote products derived from this software without specific prior
20 * written permission. 20 * written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND 22 * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION 25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GENETEC CORPORATION
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE. 32 * POSSIBILITY OF SUCH DAMAGE.
33 * 33 *
34 * Copyright (c) 2001 Wasabi Systems, Inc. 34 * Copyright (c) 2001 Wasabi Systems, Inc.
35 * All rights reserved. 35 * All rights reserved.
36 * 36 *
37 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 37 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
38 * 38 *
39 * Redistribution and use in source and binary forms, with or without 39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions 40 * modification, are permitted provided that the following conditions
41 * are met: 41 * are met:
42 * 1. Redistributions of source code must retain the above copyright 42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer. 43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright 44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the 45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution. 46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software 47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement: 48 * must display the following acknowledgement:
49 * This product includes software developed for the NetBSD Project by 49 * This product includes software developed for the NetBSD Project by
50 * Wasabi Systems, Inc. 50 * Wasabi Systems, Inc.
51 * 4. The name of Wasabi Systems, Inc. may not be used to endorse 51 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
52 * or promote products derived from this software without specific prior 52 * or promote products derived from this software without specific prior
53 * written permission. 53 * written permission.
54 * 54 *
55 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 55 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
57 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 57 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 58 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
59 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 59 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
60 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 60 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
61 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 61 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
62 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 62 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
63 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 63 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
64 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 64 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
65 * POSSIBILITY OF SUCH DAMAGE. 65 * POSSIBILITY OF SUCH DAMAGE.
66 * 66 *
67 * Copyright (c) 1997,1998 Mark Brinicombe. 67 * Copyright (c) 1997,1998 Mark Brinicombe.
68 * Copyright (c) 1997,1998 Causality Limited. 68 * Copyright (c) 1997,1998 Causality Limited.
69 * All rights reserved. 69 * All rights reserved.
70 * 70 *
71 * Redistribution and use in source and binary forms, with or without 71 * Redistribution and use in source and binary forms, with or without
72 * modification, are permitted provided that the following conditions 72 * modification, are permitted provided that the following conditions
73 * are met: 73 * are met:
74 * 1. Redistributions of source code must retain the above copyright 74 * 1. Redistributions of source code must retain the above copyright
75 * notice, this list of conditions and the following disclaimer. 75 * notice, this list of conditions and the following disclaimer.
76 * 2. Redistributions in binary form must reproduce the above copyright 76 * 2. Redistributions in binary form must reproduce the above copyright
77 * notice, this list of conditions and the following disclaimer in the 77 * notice, this list of conditions and the following disclaimer in the
78 * documentation and/or other materials provided with the distribution. 78 * documentation and/or other materials provided with the distribution.
79 * 3. All advertising materials mentioning features or use of this software 79 * 3. All advertising materials mentioning features or use of this software
80 * must display the following acknowledgement: 80 * must display the following acknowledgement:
81 * This product includes software developed by Mark Brinicombe 81 * This product includes software developed by Mark Brinicombe
82 * for the NetBSD Project. 82 * for the NetBSD Project.
83 * 4. The name of the company nor the name of the author may be used to 83 * 4. The name of the company nor the name of the author may be used to
84 * endorse or promote products derived from this software without specific 84 * endorse or promote products derived from this software without specific
85 * prior written permission. 85 * prior written permission.
86 * 86 *
87 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 87 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
88 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 88 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
89 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 89 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
90 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 90 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
91 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 91 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
92 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 92 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
93 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 93 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
94 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 94 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
95 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 95 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
96 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 96 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
97 * SUCH DAMAGE. 97 * SUCH DAMAGE.
98 * 98 *
99 * Copyright (c) 2007 Microsoft 99 * Copyright (c) 2007 Microsoft
100 * All rights reserved. 100 * All rights reserved.
101 * 101 *
102 * Redistribution and use in source and binary forms, with or without 102 * Redistribution and use in source and binary forms, with or without
103 * modification, are permitted provided that the following conditions 103 * modification, are permitted provided that the following conditions
104 * are met: 104 * are met:
105 * 1. Redistributions of source code must retain the above copyright 105 * 1. Redistributions of source code must retain the above copyright
106 * notice, this list of conditions and the following disclaimer. 106 * notice, this list of conditions and the following disclaimer.
107 * 2. Redistributions in binary form must reproduce the above copyright 107 * 2. Redistributions in binary form must reproduce the above copyright
108 * notice, this list of conditions and the following disclaimer in the 108 * notice, this list of conditions and the following disclaimer in the
109 * documentation and/or other materials provided with the distribution. 109 * documentation and/or other materials provided with the distribution.
110 * 3. All advertising materials mentioning features or use of this software 110 * 3. All advertising materials mentioning features or use of this software
111 * must display the following acknowledgement: 111 * must display the following acknowledgement:
112 * This product includes software developed by Microsoft 112 * This product includes software developed by Microsoft
113 * 113 *
114 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 114 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
115 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 115 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
116 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 116 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
117 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT, 117 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTERS BE LIABLE FOR ANY DIRECT,
118 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 118 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
119 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 119 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 120 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
121 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 121 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
122 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 122 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
123 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 123 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
124 * SUCH DAMAGE. 124 * SUCH DAMAGE.
125 */ 125 */
126 126
127#include <sys/cdefs.h> 127#include <sys/cdefs.h>
128__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.46 2013/06/17 04:37:39 matt Exp $"); 128__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.47 2013/06/18 15:37:16 matt Exp $");
129 129
130#include "opt_machdep.h" 130#include "opt_machdep.h"
131#include "opt_ddb.h" 131#include "opt_ddb.h"
132#include "opt_kgdb.h" 132#include "opt_kgdb.h"
133#include "opt_ipkdb.h" 133#include "opt_ipkdb.h"
134#include "opt_md.h" 134#include "opt_md.h"
135#include "opt_com.h" 135#include "opt_com.h"
136#include "opt_omap.h" 136#include "opt_omap.h"
137#include "prcm.h" 137#include "prcm.h"
138#include "com.h" 138#include "com.h"
139 139
140#include <sys/param.h> 140#include <sys/param.h>
141#include <sys/systm.h> 141#include <sys/systm.h>
142#include <sys/bus.h> 142#include <sys/bus.h>
143#include <sys/cpu.h> 143#include <sys/cpu.h>
144#include <sys/device.h> 144#include <sys/device.h>
145#include <sys/exec.h> 145#include <sys/exec.h>
146#include <sys/kernel.h> 146#include <sys/kernel.h>
147#include <sys/ksyms.h> 147#include <sys/ksyms.h>
148#include <sys/msgbuf.h> 148#include <sys/msgbuf.h>
149#include <sys/proc.h> 149#include <sys/proc.h>
150#include <sys/reboot.h> 150#include <sys/reboot.h>
151#include <sys/termios.h> 151#include <sys/termios.h>
 152#include <sys/gpio.h>
152 153
153#include <uvm/uvm_extern.h> 154#include <uvm/uvm_extern.h>
154 155
155#include <sys/conf.h> 156#include <sys/conf.h>
156#include <dev/cons.h> 157#include <dev/cons.h>
157#include <dev/md.h> 158#include <dev/md.h>
158 159
159#include <machine/db_machdep.h> 160#include <machine/db_machdep.h>
160#include <ddb/db_sym.h> 161#include <ddb/db_sym.h>
161#include <ddb/db_extern.h> 162#include <ddb/db_extern.h>
162#ifdef KGDB 163#ifdef KGDB
163#include <sys/kgdb.h> 164#include <sys/kgdb.h>
164#endif 165#endif
165 166
166#include <machine/bootconfig.h> 167#include <machine/bootconfig.h>
167#include <arm/armreg.h> 168#include <arm/armreg.h>
168#include <arm/undefined.h> 169#include <arm/undefined.h>
169 170
170#include <arm/arm32/machdep.h> 171#include <arm/arm32/machdep.h>
171#include <arm/mainbus/mainbus.h> 172#include <arm/mainbus/mainbus.h>
172 173
173#include <dev/ic/ns16550reg.h> 174#include <dev/ic/ns16550reg.h>
174#include <dev/ic/comreg.h> 175#include <dev/ic/comreg.h>
175 176
176#include <arm/omap/omap_com.h> 177#include <arm/omap/omap_com.h>
177#include <arm/omap/omap_var.h> 178#include <arm/omap/omap_var.h>
178#include <arm/omap/omap_wdtvar.h> 179#include <arm/omap/omap_wdtvar.h>
179#include <arm/omap/omap2_prcm.h> 180#include <arm/omap/omap2_prcm.h>
180#include <arm/omap/omap2_gpio.h> 181#include <arm/omap/omap2_gpio.h>
181#ifdef TI_AM335X 182#ifdef TI_AM335X
182# include <arm/omap/am335x_prcm.h> 183# include <arm/omap/am335x_prcm.h>
183#endif 184#endif
184 185
 186#ifdef CPU_CORTEXA9
 187#include <arm/cortex/pl310_reg.h>
 188#include <arm/cortex/pl310_var.h>
 189#endif
 190
185#include <evbarm/include/autoconf.h> 191#include <evbarm/include/autoconf.h>
186#include <evbarm/beagle/beagle.h> 192#include <evbarm/beagle/beagle.h>
187 193
188#include <dev/i2c/i2cvar.h> 194#include <dev/i2c/i2cvar.h>
189#include <dev/i2c/ddcreg.h> 195#include <dev/i2c/ddcreg.h>
190 196
191#include "prcm.h" 197#include "prcm.h"
192#include "omapwdt32k.h" 198#include "omapwdt32k.h"
193#include "ukbd.h" 199#include "ukbd.h"
194#include <dev/usb/ukbdvar.h> 200#include <dev/usb/ukbdvar.h>
195 201
196BootConfig bootconfig; /* Boot config storage */ 202BootConfig bootconfig; /* Boot config storage */
197static char bootargs[MAX_BOOT_STRING]; 203static char bootargs[MAX_BOOT_STRING];
198char *boot_args = NULL; 204char *boot_args = NULL;
199char *boot_file = NULL; 205char *boot_file = NULL;
200 206
201static uint8_t beagle_edid[128]; /* EDID storage */ 207static uint8_t beagle_edid[128]; /* EDID storage */
202 208
203u_int uboot_args[4] = { 0 }; /* filled in by beagle_start.S (not in bss) */ 209u_int uboot_args[4] = { 0 }; /* filled in by beagle_start.S (not in bss) */
204 210
205/* Same things, but for the free (unused by the kernel) memory. */ 211/* Same things, but for the free (unused by the kernel) memory. */
206 212
207extern char KERNEL_BASE_phys[]; 213extern char KERNEL_BASE_phys[];
208extern char _end[]; 214extern char _end[];
209 215
210#if NCOM > 0 216#if NCOM > 0
211int use_fb_console = false; 217int use_fb_console = false;
212#else 218#else
213int use_fb_console = true; 219int use_fb_console = true;
214#endif 220#endif
215 221
216/* 222/*
217 * Macros to translate between physical and virtual for a subset of the 223 * Macros to translate between physical and virtual for a subset of the
218 * kernel address space. *Not* for general use. 224 * kernel address space. *Not* for general use.
219 */ 225 */
220#define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys) 226#define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
221 227
222/* Prototypes */ 228/* Prototypes */
223 229
224void consinit(void); 230void consinit(void);
225#ifdef KGDB 231#ifdef KGDB
226static void kgdb_port_init(void); 232static void kgdb_port_init(void);
227#endif 233#endif
228 234
229static void init_clocks(void); 235static void init_clocks(void);
230static void beagle_device_register(device_t, void *); 236static void beagle_device_register(device_t, void *);
231static void beagle_reset(void); 237static void beagle_reset(void);
232#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX) 238#if defined(OMAP_3XXX) || defined(TI_DM37XX)
233static void omap3_cpu_clk(void); 239static void omap3_cpu_clk(void);
234#endif 240#endif
235#if defined(OMAP_4430) || defined(OMAP_5430) 241#if defined(OMAP_4XXX) || defined(OMAP_5XXX)
236static void omap4_cpu_clk(void); 242static void omap4_cpu_clk(void);
237#endif 243#endif
238#if defined(TI_AM335X) 244#if defined(TI_AM335X)
239static void am335x_cpu_clk(void); 245static void am335x_cpu_clk(void);
240#endif 246#endif
241#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X) 247#if defined(OMAP_4XXX) || defined(OMAP_5XXX) || defined(TI_AM335X)
242static psize_t emif_memprobe(void); 248static psize_t emif_memprobe(void);
243#endif 249#endif
244 250
245#if defined(OMAP_3430) || defined(OMAP_3530) 251#if defined(OMAP_3XXX)
246static psize_t omap3530_memprobe(void); 252static psize_t omap3_memprobe(void);
247#endif 253#endif
248 254
249bs_protos(bs_notimpl); 255bs_protos(bs_notimpl);
250 256
251#if NCOM > 0 257#if NCOM > 0
252#include <dev/ic/comreg.h> 258#include <dev/ic/comreg.h>
253#include <dev/ic/comvar.h> 259#include <dev/ic/comvar.h>
254#endif 260#endif
255 261
256/* 262/*
257 * Static device mappings. These peripheral registers are mapped at 263 * Static device mappings. These peripheral registers are mapped at
258 * fixed virtual addresses very early in initarm() so that we can use 264 * fixed virtual addresses very early in initarm() so that we can use
259 * them while booting the kernel, and stay at the same address 265 * them while booting the kernel, and stay at the same address
260 * throughout whole kernel's life time. 266 * throughout whole kernel's life time.
261 * 267 *
262 * We use this table twice; once with bootstrap page table, and once 268 * We use this table twice; once with bootstrap page table, and once
263 * with kernel's page table which we build up in initarm(). 269 * with kernel's page table which we build up in initarm().
264 * 270 *
265 * Since we map these registers into the bootstrap page table using 271 * Since we map these registers into the bootstrap page table using
266 * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map 272 * pmap_devmap_bootstrap() which calls pmap_map_chunk(), we map
267 * registers segment-aligned and segment-rounded in order to avoid 273 * registers segment-aligned and segment-rounded in order to avoid
268 * using the 2nd page tables. 274 * using the 2nd page tables.
269 */ 275 */
270 276
271#define _A(a) ((a) & ~L1_S_OFFSET) 277#define _A(a) ((a) & ~L1_S_OFFSET)
272#define _S(s) (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1)) 278#define _S(s) (((s) + L1_S_SIZE - 1) & ~(L1_S_SIZE-1))
273 279
274static const struct pmap_devmap devmap[] = { 280static const struct pmap_devmap devmap[] = {
275 { 281 {
276 /* 282 /*
277 * Map the first 1MB of L4 Core area 283 * Map the first 1MB of L4 Core area
278 * this gets us the ICU, I2C, USB, GPT[10-11], MMC, McSPI 284 * this gets us the ICU, I2C, USB, GPT[10-11], MMC, McSPI
279 * UART[12], clock manager, sDMA, ... 285 * UART[12], clock manager, sDMA, ...
280 */ 286 */
281 .pd_va = _A(OMAP_L4_CORE_VBASE), 287 .pd_va = _A(OMAP_L4_CORE_VBASE),
282 .pd_pa = _A(OMAP_L4_CORE_BASE), 288 .pd_pa = _A(OMAP_L4_CORE_BASE),
283 .pd_size = _S(OMAP_L4_CORE_SIZE), 289 .pd_size = _S(OMAP_L4_CORE_SIZE),
284 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 290 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
285 .pd_cache = PTE_NOCACHE 291 .pd_cache = PTE_NOCACHE
286 }, 292 },
287 { 293 {
288 /* 294 /*
289 * Map the all 1MB of the L4 Core area 295 * Map the all 1MB of the L4 Core area
290 * this gets us the console UART3, GPT[2-9], WDT1,  296 * this gets us the console UART3, GPT[2-9], WDT1,
291 * and GPIO[2-6]. 297 * and GPIO[2-6].
292 */ 298 */
293 .pd_va = _A(OMAP_L4_PERIPHERAL_VBASE), 299 .pd_va = _A(OMAP_L4_PERIPHERAL_VBASE),
294 .pd_pa = _A(OMAP_L4_PERIPHERAL_BASE), 300 .pd_pa = _A(OMAP_L4_PERIPHERAL_BASE),
295 .pd_size = _S(OMAP_L4_PERIPHERAL_SIZE), 301 .pd_size = _S(OMAP_L4_PERIPHERAL_SIZE),
296 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 302 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
297 .pd_cache = PTE_NOCACHE 303 .pd_cache = PTE_NOCACHE
298 }, 304 },
299#if defined(OMAP_L4_WAKEUP_BASE) && defined(OMAP_L4_WAKEUP_VBASE) 305#if defined(OMAP_L4_WAKEUP_BASE) && defined(OMAP_L4_WAKEUP_VBASE)
300 { 306 {
301 /* 307 /*
302 * Map all 256KB of the L4 Wakeup area 308 * Map all 256KB of the L4 Wakeup area
303 * this gets us GPIO1, WDT2, GPT1, 32K and power/reset regs 309 * this gets us GPIO1, WDT2, GPT1, 32K and power/reset regs
304 */ 310 */
305 .pd_va = _A(OMAP_L4_WAKEUP_VBASE), 311 .pd_va = _A(OMAP_L4_WAKEUP_VBASE),
306 .pd_pa = _A(OMAP_L4_WAKEUP_BASE), 312 .pd_pa = _A(OMAP_L4_WAKEUP_BASE),
307 .pd_size = _S(OMAP_L4_WAKEUP_SIZE), 313 .pd_size = _S(OMAP_L4_WAKEUP_SIZE),
308 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 314 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
309 .pd_cache = PTE_NOCACHE 315 .pd_cache = PTE_NOCACHE
310 }, 316 },
311#endif 317#endif
312#ifdef OMAP_L4_FAST_BASE 318#ifdef OMAP_L4_FAST_BASE
313 { 319 {
314 /* 320 /*
315 * Map all of the L4 Fast area 321 * Map all of the L4 Fast area
316 * this gets us GPIO1, WDT2, GPT1, 32K and power/reset regs 322 * this gets us GPIO1, WDT2, GPT1, 32K and power/reset regs
317 */ 323 */
318 .pd_va = _A(OMAP_L4_FAST_VBASE), 324 .pd_va = _A(OMAP_L4_FAST_VBASE),
319 .pd_pa = _A(OMAP_L4_FAST_BASE), 325 .pd_pa = _A(OMAP_L4_FAST_BASE),
320 .pd_size = _S(OMAP_L4_FAST_SIZE), 326 .pd_size = _S(OMAP_L4_FAST_SIZE),
321 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 327 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
322 .pd_cache = PTE_NOCACHE 328 .pd_cache = PTE_NOCACHE
323 }, 329 },
324#endif 330#endif
325#ifdef OMAP_EMIF1_BASE 331#ifdef OMAP_EMIF1_BASE
326 { 332 {
327 /* 333 /*
328 * Map all of the L4 EMIF1 area 334 * Map all of the L4 EMIF1 area
329 */ 335 */
330 .pd_va = _A(OMAP_EMIF1_VBASE), 336 .pd_va = _A(OMAP_EMIF1_VBASE),
331 .pd_pa = _A(OMAP_EMIF1_BASE), 337 .pd_pa = _A(OMAP_EMIF1_BASE),
332 .pd_size = _S(OMAP_EMIF1_SIZE), 338 .pd_size = _S(OMAP_EMIF1_SIZE),
333 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 339 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
334 .pd_cache = PTE_NOCACHE 340 .pd_cache = PTE_NOCACHE
335 }, 341 },
336#endif 342#endif
337#ifdef OMAP_EMIF2_BASE 343#ifdef OMAP_EMIF2_BASE
338 { 344 {
339 /* 345 /*
340 * Map all of the L4 EMIF2 area 346 * Map all of the L4 EMIF2 area
341 */ 347 */
342 .pd_va = _A(OMAP_EMIF2_VBASE), 348 .pd_va = _A(OMAP_EMIF2_VBASE),
343 .pd_pa = _A(OMAP_EMIF2_BASE), 349 .pd_pa = _A(OMAP_EMIF2_BASE),
344 .pd_size = _S(OMAP_EMIF2_SIZE), 350 .pd_size = _S(OMAP_EMIF2_SIZE),
345 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 351 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
346 .pd_cache = PTE_NOCACHE 352 .pd_cache = PTE_NOCACHE
347 }, 353 },
348#endif 354#endif
349#ifdef OMAP_L4_ABE_BASE 355#ifdef OMAP_L4_ABE_BASE
350 { 356 {
351 /* 357 /*
352 * Map all of the L4 Fast area 358 * Map all of the L4 Fast area
353 * this gets us GPIO1, WDT2, GPT1, 32K and power/reset regs 359 * this gets us GPIO1, WDT2, GPT1, 32K and power/reset regs
354 */ 360 */
355 .pd_va = _A(OMAP_L4_ABE_VBASE), 361 .pd_va = _A(OMAP_L4_ABE_VBASE),
356 .pd_pa = _A(OMAP_L4_ABE_BASE), 362 .pd_pa = _A(OMAP_L4_ABE_BASE),
357 .pd_size = _S(OMAP_L4_ABE_SIZE), 363 .pd_size = _S(OMAP_L4_ABE_SIZE),
358 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 364 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
359 .pd_cache = PTE_NOCACHE 365 .pd_cache = PTE_NOCACHE
360 }, 366 },
361#endif 367#endif
362#ifdef OMAP_SDRC_BASE 368#ifdef OMAP_SDRC_BASE
363 { 369 {
364 /* 370 /*
365 * Map SDRAM Controller (SDRC) registers 371 * Map SDRAM Controller (SDRC) registers
366 */ 372 */
367 .pd_va = _A(OMAP_SDRC_VBASE), 373 .pd_va = _A(OMAP_SDRC_VBASE),
368 .pd_pa = _A(OMAP_SDRC_BASE), 374 .pd_pa = _A(OMAP_SDRC_BASE),
369 .pd_size = _S(OMAP_SDRC_SIZE), 375 .pd_size = _S(OMAP_SDRC_SIZE),
370 .pd_prot = VM_PROT_READ|VM_PROT_WRITE, 376 .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
371 .pd_cache = PTE_NOCACHE, 377 .pd_cache = PTE_NOCACHE,
372 }, 378 },
373#endif 379#endif
374 {0} 380 {0}
375}; 381};
376 382
377#undef _A 383#undef _A
378#undef _S 384#undef _S
379 385
380#ifdef DDB 386#ifdef DDB
381static void 387static void
382beagle_db_trap(int where) 388beagle_db_trap(int where)
383{ 389{
384#if NOMAPWDT32K > 0 390#if NOMAPWDT32K > 0
385 static int oldwatchdogstate; 391 static int oldwatchdogstate;
386 392
387 if (where) { 393 if (where) {
388 oldwatchdogstate = omapwdt32k_enable(0); 394 oldwatchdogstate = omapwdt32k_enable(0);
389 } else { 395 } else {
390 omapwdt32k_enable(oldwatchdogstate); 396 omapwdt32k_enable(oldwatchdogstate);
391 } 397 }
392#endif 398#endif
393} 399}
394#endif 400#endif
395 401
396void beagle_putchar(char c); 402void beagle_putchar(char c);
397void 403void
398beagle_putchar(char c) 404beagle_putchar(char c)
399{ 405{
400#if NCOM > 0 406#if NCOM > 0
401 volatile uint32_t *com0addr = (volatile uint32_t *)CONSADDR_VA; 407 volatile uint32_t *com0addr = (volatile uint32_t *)CONSADDR_VA;
402 int timo = 150000; 408 int timo = 150000;
403 409
404 while ((com0addr[com_lsr] & LSR_TXRDY) == 0) { 410 while ((com0addr[com_lsr] & LSR_TXRDY) == 0) {
405 if (--timo == 0) 411 if (--timo == 0)
406 break; 412 break;
407 } 413 }
408 414
409 com0addr[com_data] = c; 415 com0addr[com_data] = c;
410 416
411 while ((com0addr[com_lsr] & LSR_TXRDY) == 0) { 417 while ((com0addr[com_lsr] & LSR_TXRDY) == 0) {
412 if (--timo == 0) 418 if (--timo == 0)
413 break; 419 break;
414 } 420 }
415#endif 421#endif
416} 422}
417 423
418/* 424/*
419 * u_int initarm(...) 425 * u_int initarm(...)
420 * 426 *
421 * Initial entry point on startup. This gets called before main() is 427 * Initial entry point on startup. This gets called before main() is
422 * entered. 428 * entered.
423 * It should be responsible for setting up everything that must be 429 * It should be responsible for setting up everything that must be
424 * in place when main is called. 430 * in place when main is called.
425 * This includes 431 * This includes
426 * Taking a copy of the boot configuration structure. 432 * Taking a copy of the boot configuration structure.
427 * Initialising the physical console so characters can be printed. 433 * Initialising the physical console so characters can be printed.
428 * Setting up page tables for the kernel 434 * Setting up page tables for the kernel
429 * Relocating the kernel to the bottom of physical memory 435 * Relocating the kernel to the bottom of physical memory
430 */ 436 */
431u_int 437u_int
432initarm(void *arg) 438initarm(void *arg)
433{ 439{
434 psize_t ram_size = 0; 440 psize_t ram_size = 0;
435 char *ptr; 441 char *ptr;
436 442
437#if 1 443#if 1
438 beagle_putchar('d'); 444 beagle_putchar('d');
439#endif 445#endif
440 446
441 /* 447 /*
442 * When we enter here, we are using a temporary first level 448 * When we enter here, we are using a temporary first level
443 * translation table with section entries in it to cover the OBIO 449 * translation table with section entries in it to cover the OBIO
444 * peripherals and SDRAM. The temporary first level translation table 450 * peripherals and SDRAM. The temporary first level translation table
445 * is at the end of SDRAM. 451 * is at the end of SDRAM.
446 */ 452 */
447#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX) 453#if defined(OMAP_3XXX) || defined(TI_DM37XX)
448 omap3_cpu_clk(); // find our CPU speed. 454 omap3_cpu_clk(); // find our CPU speed.
449#endif 455#endif
450#if defined(OMAP_4430) || defined(OMAP_5430) 456#if defined(OMAP_4XXX) || defined(OMAP_5XXX)
451 omap4_cpu_clk(); // find our CPU speed. 457 omap4_cpu_clk(); // find our CPU speed.
452#endif 458#endif
453#if defined(TI_AM335X) 459#if defined(TI_AM335X)
454 am335x_cpu_clk(); // find our CPU speed. 460 am335x_cpu_clk(); // find our CPU speed.
455#endif 461#endif
456 /* Heads up ... Setup the CPU / MMU / TLB functions. */ 462 /* Heads up ... Setup the CPU / MMU / TLB functions. */
457 if (set_cpufuncs()) 463 if (set_cpufuncs())
458 panic("cpu not recognized!"); 464 panic("cpu not recognized!");
459 465
460 init_clocks(); 466 init_clocks();
461 467
462 /* The console is going to try to map things. Give pmap a devmap. */ 468 /* The console is going to try to map things. Give pmap a devmap. */
463 pmap_devmap_register(devmap); 469 pmap_devmap_register(devmap);
464 consinit(); 470 consinit();
 471#if defined(OMAP_4XXX)
 472 /*
 473 * Probe the PL310 L2CC
 474 */
 475 const bus_space_handle_t pl310_bh = OMAP4_L2CC_BASE +
 476 OMAP_L4_PERIPHERAL_VBASE - OMAP_L4_PERIPHERAL_BASE;
 477 arml2cc_init(&omap_bs_tag, pl310_bh, 0);
 478#endif
465#if 1 479#if 1
466 beagle_putchar('h'); 480 beagle_putchar('h');
467#endif 481#endif
468 printf("uboot arg = %#x, %#x, %#x, %#x\n", 482 printf("uboot arg = %#x, %#x, %#x, %#x\n",
469 uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]); 483 uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]);
470 484
471#ifdef KGDB 485#ifdef KGDB
472 kgdb_port_init(); 486 kgdb_port_init();
473#endif 487#endif
474 488
475 cpu_reset_address = beagle_reset; 489 cpu_reset_address = beagle_reset;
476 490
477#ifdef VERBOSE_INIT_ARM 491#ifdef VERBOSE_INIT_ARM
478 /* Talk to the user */ 492 /* Talk to the user */
479 printf("\nNetBSD/evbarm (beagle) booting ...\n"); 493 printf("\nNetBSD/evbarm (beagle) booting ...\n");
480#endif 494#endif
481 495
482#ifdef BOOT_ARGSt 496#ifdef BOOT_ARGS
483 char mi_bootargs[] = BOOT_ARGS; 497 char mi_bootargs[] = BOOT_ARGS;
484 parse_mi_bootargs(mi_bootargs); 498 parse_mi_bootargs(mi_bootargs);
485#endif 499#endif
486 500
487#ifdef VERBOSE_INIT_ARM 501#ifdef VERBOSE_INIT_ARM
488 printf("initarm: Configuring system ...\n"); 502 printf("initarm: Configuring system ...\n");
489#endif 503#endif
490 504
491 /* 505 /*
492 * Set up the variables that define the availability of physical 506 * Set up the variables that define the availability of physical
493 * memory. 507 * memory.
494 */ 508 */
495#if defined(OMAP_3430) || defined(OMAP_3530) 509#if defined(OMAP_3XXX)
496 ram_size = omap3530_memprobe(); 510 ram_size = omap3_memprobe();
497#endif 511#endif
498#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X) 512#if defined(OMAP_4XXX) || defined(OMAP_5XXX) || defined(TI_AM335X)
499 ram_size = emif_memprobe(); 513 ram_size = emif_memprobe();
500#endif 514#endif
501 515
502 /* 516 /*
503 * If MEMSIZE specified less than what we really have, limit ourselves 517 * If MEMSIZE specified less than what we really have, limit ourselves
504 * to that. 518 * to that.
505 */ 519 */
506#ifdef MEMSIZE 520#ifdef MEMSIZE
507 if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024) 521 if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024)
508 ram_size = (unsigned)MEMSIZE * 1024 * 1024; 522 ram_size = (unsigned)MEMSIZE * 1024 * 1024;
509#else 523#else
510 KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined"); 524 KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined");
511#endif 525#endif
512 526
513 /* Fake bootconfig structure for the benefit of pmap.c. */ 527 /* Fake bootconfig structure for the benefit of pmap.c. */
514 bootconfig.dramblocks = 1; 528 bootconfig.dramblocks = 1;
515 bootconfig.dram[0].address = KERNEL_BASE_PHYS & -0x400000; 529 bootconfig.dram[0].address = KERNEL_BASE_PHYS & -0x400000;
516 bootconfig.dram[0].pages = ram_size / PAGE_SIZE; 530 bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
517 531
518#if 0 
519#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X) 
520 KASSERT(cs1_p == false); 
521 if (cs1_p > 0) { 
522 bootconfig.dramblocks = 2; 
523 bootconfig.dram[1].address = 0xC0000000; 
524 bootconfig.dram[0].pages /= 2; 
525 bootconfig.dram[1].pages = bootconfig.dram[0].pages; 
526 } 
527#endif 
528#endif 
529 
530#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS 532#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
531 const bool mapallmem_p = true; 533 const bool mapallmem_p = true;
532 KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE); 534 KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
533#else 535#else
534 const bool mapallmem_p = false; 536 const bool mapallmem_p = false;
535#endif 537#endif
536 KASSERT((armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0); 538 KASSERT((armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0);
537 539
538 arm32_bootmem_init(bootconfig.dram[0].address, ram_size, 540 arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
539 KERNEL_BASE_PHYS); 541 KERNEL_BASE_PHYS);
540 arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, devmap, 542 arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_LOW, 0, devmap,
541 mapallmem_p); 543 mapallmem_p);
542 544
543 /* "bootargs" env variable is passed as 4th argument to kernel */ 545 /* "bootargs" env variable is passed as 4th argument to kernel */
544 if ((uboot_args[3] & 0xf0000000) == 0x80000000) { 546 if ((uboot_args[3] & 0xf0000000) == 0x80000000) {
545 strlcpy(bootargs, (char *)uboot_args[3], sizeof(bootargs)); 547 strlcpy(bootargs, (char *)uboot_args[3], sizeof(bootargs));
546 } 548 }
547 boot_args = bootargs; 549 boot_args = bootargs;
548 parse_mi_bootargs(boot_args); 550 parse_mi_bootargs(boot_args);
549 551
550 /* we've a specific device_register routine */ 552 /* we've a specific device_register routine */
551 evbarm_device_register = beagle_device_register; 553 evbarm_device_register = beagle_device_register;
552 554
553 db_trap_callback = beagle_db_trap; 555 db_trap_callback = beagle_db_trap;
554 556
555 if (get_bootconf_option(boot_args, "console", 557 if (get_bootconf_option(boot_args, "console",
556 BOOTOPT_TYPE_STRING, &ptr) && strncmp(ptr, "fb", 2) == 0) { 558 BOOTOPT_TYPE_STRING, &ptr) && strncmp(ptr, "fb", 2) == 0) {
557 use_fb_console = true; 559 use_fb_console = true;
558 } 560 }
559  561
560 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0); 562 return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
561 563
562} 564}
563 565
564static void 566static void
565init_clocks(void) 567init_clocks(void)
566{ 568{
567#ifdef NOTYET 569#ifdef NOTYET
568 static volatile uint32_t * const clksel_reg = (volatile uint32_t *) (OMAP3530_L4_WAKEUP_VBASE + OMAP2_CM_BASE + OMAP2_CM_CLKSEL_MPU - OMAP3530_L4_WAKEUP_BASE); 570 static volatile uint32_t * const clksel_reg = (volatile uint32_t *) (OMAP3530_L4_WAKEUP_VBASE + OMAP2_CM_BASE + OMAP2_CM_CLKSEL_MPU - OMAP3530_L4_WAKEUP_BASE);
569 uint32_t v; 571 uint32_t v;
570 beagle_putchar('E'); 572 beagle_putchar('E');
571 v = *clksel_reg; 573 v = *clksel_reg;
572 beagle_putchar('F'); 574 beagle_putchar('F');
573 if (v != OMAP3530_CM_CLKSEL_MPU_FULLSPEED) { 575 if (v != OMAP3530_CM_CLKSEL_MPU_FULLSPEED) {
574 printf("Changed CPU speed from half (%d) ", v); 576 printf("Changed CPU speed from half (%d) ", v);
575 *clksel_reg = OMAP3530_CM_CLKSEL_MPU_FULLSPEED; 577 *clksel_reg = OMAP3530_CM_CLKSEL_MPU_FULLSPEED;
576 printf("to full speed.\n"); 578 printf("to full speed.\n");
577 } 579 }
578 beagle_putchar('G'); 580 beagle_putchar('G');
579#endif 581#endif
580} 582}
581 583
582#if NCOM > 0 584#if NCOM > 0
583#ifndef CONSADDR 585#ifndef CONSADDR
584#error Specify the address of the console UART with the CONSADDR option. 586#error Specify the address of the console UART with the CONSADDR option.
585#endif 587#endif
586#ifndef CONSPEED 588#ifndef CONSPEED
587#define CONSPEED 115200 589#define CONSPEED 115200
588#endif 590#endif
589#ifndef CONMODE 591#ifndef CONMODE
590#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 592#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
591#endif 593#endif
592 594
593static const bus_addr_t consaddr = CONSADDR; 595static const bus_addr_t consaddr = CONSADDR;
594static const int conspeed = CONSPEED; 596static const int conspeed = CONSPEED;
595static const int conmode = CONMODE; 597static const int conmode = CONMODE;
596#endif 598#endif
597 599
598void 600void
599consinit(void) 601consinit(void)
600{ 602{
601#if NCOM > 0 603#if NCOM > 0
602 bus_space_handle_t bh; 604 bus_space_handle_t bh;
603#endif 605#endif
604 static int consinit_called = 0; 606 static int consinit_called = 0;
605 607
606 if (consinit_called != 0) 608 if (consinit_called != 0)
607 return; 609 return;
608 610
609 consinit_called = 1; 611 consinit_called = 1;
610 612
611 beagle_putchar('e'); 613 beagle_putchar('e');
612 614
613#if NCOM > 0 615#if NCOM > 0
614 if (bus_space_map(&omap_a4x_bs_tag, consaddr, OMAP_COM_SIZE, 0, &bh)) 616 if (bus_space_map(&omap_a4x_bs_tag, consaddr, OMAP_COM_SIZE, 0, &bh))
615 panic("Serial console can not be mapped."); 617 panic("Serial console can not be mapped.");
616 618
617 if (comcnattach(&omap_a4x_bs_tag, consaddr, conspeed, 619 if (comcnattach(&omap_a4x_bs_tag, consaddr, conspeed,
618 OMAP_COM_FREQ, COM_TYPE_NORMAL, conmode)) 620 OMAP_COM_FREQ, COM_TYPE_NORMAL, conmode))
619 panic("Serial console can not be initialized."); 621 panic("Serial console can not be initialized.");
620 622
621 bus_space_unmap(&omap_a4x_bs_tag, bh, OMAP_COM_SIZE); 623 bus_space_unmap(&omap_a4x_bs_tag, bh, OMAP_COM_SIZE);
622#endif 624#endif
623 625
624#if NUKBD > 0 626#if NUKBD > 0
625 ukbd_cnattach(); /* allow USB keyboard to become console */ 627 ukbd_cnattach(); /* allow USB keyboard to become console */
626#endif 628#endif
627 629
628 beagle_putchar('f'); 630 beagle_putchar('f');
629 beagle_putchar('g'); 631 beagle_putchar('g');
630} 632}
631 633
632void 634void
633beagle_reset(void) 635beagle_reset(void)
634{ 636{
635#if defined(OMAP_4430) 637#if defined(OMAP_4XXX) || defined(OMAP_5XXX)
636 *(volatile uint32_t *)(OMAP_L4_CORE_VBASE + (OMAP_L4_WAKEUP_BASE - OMAP_L4_CORE_BASE) + OMAP4_PRM_RSTCTRL) = OMAP4_PRM_RSTCTRL_WARM; 638 *(volatile uint32_t *)(OMAP_L4_CORE_VBASE + (OMAP_L4_WAKEUP_BASE - OMAP_L4_CORE_BASE) + OMAP4_PRM_RSTCTRL) = OMAP4_PRM_RSTCTRL_WARM;
637#elif defined(TI_AM335X) 639#elif defined(TI_AM335X)
638 *(volatile uint32_t *)(OMAP_L4_CORE_VBASE + (OMAP2_CM_BASE - OMAP_L4_CORE_BASE) + AM335X_PRCM_PRM_DEVICE + PRM_RSTCTRL) = RST_GLOBAL_WARM_SW; 640 *(volatile uint32_t *)(OMAP_L4_CORE_VBASE + (OMAP2_CM_BASE - OMAP_L4_CORE_BASE) + AM335X_PRCM_PRM_DEVICE + PRM_RSTCTRL) = RST_GLOBAL_WARM_SW;
639#else 641#else
640#if NPRCM > 0 642#if NPRCM > 0
641 prcm_cold_reset(); 643 prcm_cold_reset();
642#endif 644#endif
643#if NOMAPWDT32K > 0 645#if NOMAPWDT32K > 0
644 omapwdt32k_reboot(); 646 omapwdt32k_reboot();
645#endif 647#endif
646#endif 648#endif
647} 649}
648 650
649#ifdef KGDB 651#ifdef KGDB
650#ifndef KGDB_DEVADDR 652#ifndef KGDB_DEVADDR
651#error Specify the address of the kgdb UART with the KGDB_DEVADDR option. 653#error Specify the address of the kgdb UART with the KGDB_DEVADDR option.
652#endif 654#endif
653#ifndef KGDB_DEVRATE 655#ifndef KGDB_DEVRATE
654#define KGDB_DEVRATE 115200 656#define KGDB_DEVRATE 115200
655#endif 657#endif
656 658
657#ifndef KGDB_DEVMODE 659#ifndef KGDB_DEVMODE
658#define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 660#define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
659#endif 661#endif
660static const vaddr_t comkgdbaddr = KGDB_DEVADDR; 662static const vaddr_t comkgdbaddr = KGDB_DEVADDR;
661static const int comkgdbspeed = KGDB_DEVRATE; 663static const int comkgdbspeed = KGDB_DEVRATE;
662static const int comkgdbmode = KGDB_DEVMODE; 664static const int comkgdbmode = KGDB_DEVMODE;
663 665
664void 666void
665static kgdb_port_init(void) 667static kgdb_port_init(void)
666{ 668{
667 static int kgdbsinit_called = 0; 669 static int kgdbsinit_called = 0;
668 670
669 if (kgdbsinit_called != 0) 671 if (kgdbsinit_called != 0)
670 return; 672 return;
671 673
672 kgdbsinit_called = 1; 674 kgdbsinit_called = 1;
673 675
674 bus_space_handle_t bh; 676 bus_space_handle_t bh;
675 if (bus_space_map(&omap_a4x_bs_tag, comkgdbaddr, OMAP_COM_SIZE, 0, &bh)) 677 if (bus_space_map(&omap_a4x_bs_tag, comkgdbaddr, OMAP_COM_SIZE, 0, &bh))
676 panic("kgdb port can not be mapped."); 678 panic("kgdb port can not be mapped.");
677 679
678 if (com_kgdb_attach(&omap_a4x_bs_tag, comkgdbaddr, comkgdbspeed, 680 if (com_kgdb_attach(&omap_a4x_bs_tag, comkgdbaddr, comkgdbspeed,
679 OMAP_COM_FREQ, COM_TYPE_NORMAL, comkgdbmode)) 681 OMAP_COM_FREQ, COM_TYPE_NORMAL, comkgdbmode))
680 panic("KGDB uart can not be initialized."); 682 panic("KGDB uart can not be initialized.");
681 683
682 bus_space_unmap(&omap_a4x_bs_tag, bh, OMAP_COM_SIZE); 684 bus_space_unmap(&omap_a4x_bs_tag, bh, OMAP_COM_SIZE);
683} 685}
684#endif 686#endif
685 687
686#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX) 688#if defined(OMAP_3XXX) || defined(TI_DM37XX)
687void 689void
688omap3_cpu_clk(void) 690omap3_cpu_clk(void)
689{ 691{
690 const vaddr_t prm_base = OMAP2_PRM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE; 692 const vaddr_t prm_base = OMAP2_PRM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE;
691 const uint32_t prm_clksel = *(volatile uint32_t *)(prm_base + PLL_MOD + OMAP3_PRM_CLKSEL); 693 const uint32_t prm_clksel = *(volatile uint32_t *)(prm_base + PLL_MOD + OMAP3_PRM_CLKSEL);
692 static const uint32_t prm_clksel_freqs[] = OMAP3_PRM_CLKSEL_FREQS; 694 static const uint32_t prm_clksel_freqs[] = OMAP3_PRM_CLKSEL_FREQS;
693 const uint32_t sys_clk = prm_clksel_freqs[__SHIFTOUT(prm_clksel, OMAP3_PRM_CLKSEL_CLKIN)]; 695 const uint32_t sys_clk = prm_clksel_freqs[__SHIFTOUT(prm_clksel, OMAP3_PRM_CLKSEL_CLKIN)];
694 const vaddr_t cm_base = OMAP2_CM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE; 696 const vaddr_t cm_base = OMAP2_CM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE;
695 const uint32_t dpll1 = *(volatile uint32_t *)(cm_base + OMAP3_CM_CLKSEL1_PLL_MPU); 697 const uint32_t dpll1 = *(volatile uint32_t *)(cm_base + OMAP3_CM_CLKSEL1_PLL_MPU);
696 const uint32_t dpll2 = *(volatile uint32_t *)(cm_base + OMAP3_CM_CLKSEL2_PLL_MPU); 698 const uint32_t dpll2 = *(volatile uint32_t *)(cm_base + OMAP3_CM_CLKSEL2_PLL_MPU);
697 const uint32_t m = __SHIFTOUT(dpll1, OMAP3_CM_CLKSEL1_PLL_MPU_DPLL_MULT); 699 const uint32_t m = __SHIFTOUT(dpll1, OMAP3_CM_CLKSEL1_PLL_MPU_DPLL_MULT);
698 const uint32_t n = __SHIFTOUT(dpll1, OMAP3_CM_CLKSEL1_PLL_MPU_DPLL_DIV); 700 const uint32_t n = __SHIFTOUT(dpll1, OMAP3_CM_CLKSEL1_PLL_MPU_DPLL_DIV);
699 const uint32_t m2 = __SHIFTOUT(dpll2, OMAP3_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV); 701 const uint32_t m2 = __SHIFTOUT(dpll2, OMAP3_CM_CLKSEL2_PLL_MPU_DPLL_CLKOUT_DIV);
700 702
701 /* 703 /*
702 * MPU_CLK supplies ARM_FCLK which is twice the CPU frequency. 704 * MPU_CLK supplies ARM_FCLK which is twice the CPU frequency.
703 */ 705 */
704 curcpu()->ci_data.cpu_cc_freq = ((sys_clk * m) / ((n + 1) * m2 * 2)) * OMAP3_PRM_CLKSEL_MULT; 706 curcpu()->ci_data.cpu_cc_freq = ((sys_clk * m) / ((n + 1) * m2 * 2)) * OMAP3_PRM_CLKSEL_MULT;
705 omap_sys_clk = sys_clk * OMAP3_PRM_CLKSEL_MULT; 707 omap_sys_clk = sys_clk * OMAP3_PRM_CLKSEL_MULT;
706} 708}
707#endif /* OMAP_3430 || OMAP_3530 || TI_DM37XX */ 709#endif /* OMAP_3XXX || TI_DM37XX */
708 710
709#if defined(OMAP_4430) || defined(OMAP_5430) 711#if defined(OMAP_4XXX) || defined(OMAP_5XXX)
710void 712void
711omap4_cpu_clk(void) 713omap4_cpu_clk(void)
712{ 714{
713 const vaddr_t prm_base = OMAP2_PRM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE; 715 const vaddr_t prm_base = OMAP2_PRM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE;
714 const vaddr_t cm_base = OMAP2_CM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE; 716 const vaddr_t cm_base = OMAP2_CM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE;
715 static const uint32_t cm_clksel_freqs[] = OMAP4_CM_CLKSEL_FREQS; 717 static const uint32_t cm_clksel_freqs[] = OMAP4_CM_CLKSEL_FREQS;
716 const uint32_t prm_clksel = *(volatile uint32_t *)(prm_base + OMAP4_CM_SYS_CLKSEL); 718 const uint32_t prm_clksel = *(volatile uint32_t *)(prm_base + OMAP4_CM_SYS_CLKSEL);
717 const uint32_t sys_clk = cm_clksel_freqs[__SHIFTOUT(prm_clksel, OMAP4_CM_SYS_CLKSEL_CLKIN)]; 719 const uint32_t sys_clk = cm_clksel_freqs[__SHIFTOUT(prm_clksel, OMAP4_CM_SYS_CLKSEL_CLKIN)];
718 const uint32_t dpll1 = *(volatile uint32_t *)(cm_base + OMAP4_CM_CLKSEL_DPLL_MPU); 720 const uint32_t dpll1 = *(volatile uint32_t *)(cm_base + OMAP4_CM_CLKSEL_DPLL_MPU);
719 const uint32_t dpll2 = *(volatile uint32_t *)(cm_base + OMAP4_CM_DIV_M2_DPLL_MPU); 721 const uint32_t dpll2 = *(volatile uint32_t *)(cm_base + OMAP4_CM_DIV_M2_DPLL_MPU);
720 const uint32_t m = __SHIFTOUT(dpll1, OMAP4_CM_CLKSEL_DPLL_MPU_DPLL_MULT); 722 const uint32_t m = __SHIFTOUT(dpll1, OMAP4_CM_CLKSEL_DPLL_MPU_DPLL_MULT);
721 const uint32_t n = __SHIFTOUT(dpll1, OMAP4_CM_CLKSEL_DPLL_MPU_DPLL_DIV); 723 const uint32_t n = __SHIFTOUT(dpll1, OMAP4_CM_CLKSEL_DPLL_MPU_DPLL_DIV);
722 const uint32_t m2 = __SHIFTOUT(dpll2, OMAP4_CM_DIV_M2_DPLL_MPU_DPLL_CLKOUT_DIV); 724 const uint32_t m2 = __SHIFTOUT(dpll2, OMAP4_CM_DIV_M2_DPLL_MPU_DPLL_CLKOUT_DIV);
723 725
724 /* 726 /*
725 * MPU_CLK supplies ARM_FCLK which is twice the CPU frequency. 727 * MPU_CLK supplies ARM_FCLK which is twice the CPU frequency.
726 */ 728 */
727 curcpu()->ci_data.cpu_cc_freq = ((sys_clk * 2 * m) / ((n + 1) * m2)) * OMAP4_CM_CLKSEL_MULT / 2; 729 curcpu()->ci_data.cpu_cc_freq = ((sys_clk * 2 * m) / ((n + 1) * m2)) * OMAP4_CM_CLKSEL_MULT / 2;
728 omap_sys_clk = sys_clk * OMAP4_CM_CLKSEL_MULT; 730 omap_sys_clk = sys_clk * OMAP4_CM_CLKSEL_MULT;
729 printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u mult=%u\n", 731 printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u mult=%u\n",
730 __func__, curcpu()->ci_data.cpu_cc_freq, 732 __func__, curcpu()->ci_data.cpu_cc_freq,
731 sys_clk, m, n, n+1, m2, OMAP4_CM_CLKSEL_MULT); 733 sys_clk, m, n, n+1, m2, OMAP4_CM_CLKSEL_MULT);
732} 734}
733#endif /* OMAP_4430 || OMAP_5430 */ 735#endif /* OMAP_4XXX || OMAP_5XXX */
734 736
735#if defined(TI_AM335X) 737#if defined(TI_AM335X)
736void 738void
737am335x_cpu_clk(void) 739am335x_cpu_clk(void)
738{ 740{
739 static const uint32_t sys_clks[4] = { 741 static const uint32_t sys_clks[4] = {
740 [0] = 19200000, [1] = 24000000, [2] = 25000000, [3] = 26000000 742 [0] = 19200000, [1] = 24000000, [2] = 25000000, [3] = 26000000
741 }; 743 };
742 const vaddr_t cm_base = OMAP2_CM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE; 744 const vaddr_t cm_base = OMAP2_CM_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE;
743 const vaddr_t cm_wkup_base = cm_base + AM335X_PRCM_CM_WKUP; 745 const vaddr_t cm_wkup_base = cm_base + AM335X_PRCM_CM_WKUP;
744 const vaddr_t ctlmod_base = TI_AM335X_CTLMOD_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE; 746 const vaddr_t ctlmod_base = TI_AM335X_CTLMOD_BASE - OMAP_L4_CORE_BASE + OMAP_L4_CORE_VBASE;
745 const uint32_t control_status = *(const volatile uint32_t *)(ctlmod_base + CTLMOD_CONTROL_STATUS); 747 const uint32_t control_status = *(const volatile uint32_t *)(ctlmod_base + CTLMOD_CONTROL_STATUS);
746 const uint32_t sys_clk = sys_clks[__SHIFTOUT(control_status, CTLMOD_CONTROL_STATUS_SYSBOOT1)]; 748 const uint32_t sys_clk = sys_clks[__SHIFTOUT(control_status, CTLMOD_CONTROL_STATUS_SYSBOOT1)];
747 const uint32_t clksel_dpll_mpu = *(volatile uint32_t *)(cm_wkup_base + TI_AM335X_CM_CLKSEL_DPLL_MPU); 749 const uint32_t clksel_dpll_mpu = *(volatile uint32_t *)(cm_wkup_base + TI_AM335X_CM_CLKSEL_DPLL_MPU);
748 const uint32_t div_m2_dpll_mpu = *(volatile uint32_t *)(cm_wkup_base + TI_AM335X_CM_DIV_M2_DPLL_MPU); 750 const uint32_t div_m2_dpll_mpu = *(volatile uint32_t *)(cm_wkup_base + TI_AM335X_CM_DIV_M2_DPLL_MPU);
749 const uint32_t m = __SHIFTOUT(clksel_dpll_mpu, TI_AM335X_CM_CLKSEL_DPLL_MPU_DPLL_MULT); 751 const uint32_t m = __SHIFTOUT(clksel_dpll_mpu, TI_AM335X_CM_CLKSEL_DPLL_MPU_DPLL_MULT);
750 const uint32_t n = __SHIFTOUT(clksel_dpll_mpu, TI_AM335X_CM_CLKSEL_DPLL_MPU_DPLL_DIV); 752 const uint32_t n = __SHIFTOUT(clksel_dpll_mpu, TI_AM335X_CM_CLKSEL_DPLL_MPU_DPLL_DIV);
751 const uint32_t m2 = __SHIFTOUT(div_m2_dpll_mpu, TI_AM335X_CM_DIV_M2_DPLL_MPU_DPLL_CLKOUT_DIV); 753 const uint32_t m2 = __SHIFTOUT(div_m2_dpll_mpu, TI_AM335X_CM_DIV_M2_DPLL_MPU_DPLL_CLKOUT_DIV);
752 /* XXX This ignores CM_CLKSEL_DPLL_MPU[DPLL_REGM4XEN]. */ 754 /* XXX This ignores CM_CLKSEL_DPLL_MPU[DPLL_REGM4XEN]. */
753 curcpu()->ci_data.cpu_cc_freq = ((m * (sys_clk / (n + 1))) / m2); 755 curcpu()->ci_data.cpu_cc_freq = ((m * (sys_clk / (n + 1))) / m2);
754 printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u\n", 756 printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u\n",
755 __func__, curcpu()->ci_data.cpu_cc_freq, 757 __func__, curcpu()->ci_data.cpu_cc_freq,
756 sys_clk, m, n, n+1, m2); 758 sys_clk, m, n, n+1, m2);
757 omap_sys_clk = sys_clk; 759 omap_sys_clk = sys_clk;
758} 760}
759#endif /* TI_AM335X */ 761#endif /* TI_AM335X */
760 762
761#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X) 763#if defined(OMAP_4XXX) || defined(OMAP_5XXX) || defined(TI_AM335X)
762static inline uint32_t 764static inline uint32_t
763emif_read_sdram_config(vaddr_t emif_base) 765emif_read_sdram_config(vaddr_t emif_base)
764{ 766{
765 return *(const volatile uint32_t *)(emif_base + EMIF_SDRAM_CONFIG); 767 return *(const volatile uint32_t *)(emif_base + EMIF_SDRAM_CONFIG);
766} 768}
767 769
768static psize_t  770static psize_t
769emif_memprobe(void) 771emif_memprobe(void)
770{ 772{
771 uint32_t sdram_config = emif_read_sdram_config(OMAP_EMIF1_VBASE); 773 uint32_t sdram_config = emif_read_sdram_config(OMAP_EMIF1_VBASE);
772 psize_t memsize = 1L; 774 psize_t memsize = 1L;
773#if defined(TI_AM335X) 775#if defined(TI_AM335X)
774 /* 776 /*
775 * The original bbone's u-boot misprograms the EMIF so correct it 777 * The original bbone's u-boot misprograms the EMIF so correct it
776 * if we detect if it has the wrong value. 778 * if we detect if it has the wrong value.
777 */ 779 */
778 if (sdram_config == 0x41805332) 780 if (sdram_config == 0x41805332)
779 sdram_config -= __SHIFTIN(1, SDRAM_CONFIG_RSIZE); 781 sdram_config -= __SHIFTIN(1, SDRAM_CONFIG_RSIZE);
780#endif 782#endif
781#ifdef OMAP_EMIF2_VBASE 783#ifdef OMAP_EMIF2_VBASE
782 /* 784 /*
783 * OMAP4 and OMAP5 have two EMIFs so if the 2nd one is configured 785 * OMAP4 and OMAP5 have two EMIFs so if the 2nd one is configured
784 * like the first, we have twice the memory. 786 * like the first, we have twice the memory.
785 */ 787 */
786 const uint32_t sdram_config2 = emif_read_sdram_config(OMAP_EMIF2_VBASE); 788 const uint32_t sdram_config2 = emif_read_sdram_config(OMAP_EMIF2_VBASE);
787 if (sdram_config2 == sdram_config) 789 if (sdram_config2 == sdram_config)
788 memsize <<= 1; 790 memsize <<= 1;
789#endif 791#endif
790 792
791 const u_int ebank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_EBANK); 793 const u_int ebank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_EBANK);
792 const u_int ibank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_IBANK); 794 const u_int ibank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_IBANK);
793 const u_int rsize = 9 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_RSIZE); 795 const u_int rsize = 9 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_RSIZE);
794 const u_int pagesize = 8 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_PAGESIZE); 796 const u_int pagesize = 8 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_PAGESIZE);
795 const u_int width = 2 - __SHIFTOUT(sdram_config, SDRAM_CONFIG_WIDTH); 797 const u_int width = 2 - __SHIFTOUT(sdram_config, SDRAM_CONFIG_WIDTH);
796#ifdef TI_AM335X 798#ifdef TI_AM335X
797 KASSERT(ebank == 0); // No chip selects on Sitara 799 KASSERT(ebank == 0); // No chip selects on Sitara
798#endif 800#endif
799 memsize <<= (ebank + ibank + rsize + pagesize + width); 801 memsize <<= (ebank + ibank + rsize + pagesize + width);
800#ifdef VERBOSE_INIT_ARM 802#ifdef VERBOSE_INIT_ARM
801 printf("sdram_config = %#x, memsize = %uMB\n", sdram_config, 803 printf("sdram_config = %#x, memsize = %uMB\n", sdram_config,
802 (u_int)(memsize >> 20)); 804 (u_int)(memsize >> 20));
803#endif 805#endif
804 return memsize; 806 return memsize;
805} 807}
806#endif 808#endif
807 809
808#if defined(OMAP_3430) || defined(OMAP_3530) 810#if defined(OMAP_3XXX)
809#define SDRC_MCFG(p) (0x80 + (0x30 * (p))) 811#define SDRC_MCFG(p) (0x80 + (0x30 * (p)))
810#define SDRC_MCFG_MEMSIZE(m) ((((m) & __BITS(8,17)) >> 8) * 2) 812#define SDRC_MCFG_MEMSIZE(m) ((((m) & __BITS(8,17)) >> 8) * 2)
811static psize_t  813static psize_t
812omap3530_memprobe(void) 814omap3_memprobe(void)
813{ 815{
814 const vaddr_t gpmc_base = OMAP_SDRC_VBASE; 816 const vaddr_t gpmc_base = OMAP_SDRC_VBASE;
815 const uint32_t mcfg0 = *(volatile uint32_t *)(gpmc_base + SDRC_MCFG(0)); 817 const uint32_t mcfg0 = *(volatile uint32_t *)(gpmc_base + SDRC_MCFG(0));
816 const uint32_t mcfg1 = *(volatile uint32_t *)(gpmc_base + SDRC_MCFG(1)); 818 const uint32_t mcfg1 = *(volatile uint32_t *)(gpmc_base + SDRC_MCFG(1));
817 819
818 printf("mcfg0 = %#x, size %lld\n", mcfg0, SDRC_MCFG_MEMSIZE(mcfg0)); 820 printf("mcfg0 = %#x, size %lld\n", mcfg0, SDRC_MCFG_MEMSIZE(mcfg0));
819 printf("mcfg1 = %#x, size %lld\n", mcfg1, SDRC_MCFG_MEMSIZE(mcfg1)); 821 printf("mcfg1 = %#x, size %lld\n", mcfg1, SDRC_MCFG_MEMSIZE(mcfg1));
820 822
821 return (SDRC_MCFG_MEMSIZE(mcfg0) + SDRC_MCFG_MEMSIZE(mcfg1)) * 1024 * 1024; 823 return (SDRC_MCFG_MEMSIZE(mcfg0) + SDRC_MCFG_MEMSIZE(mcfg1)) * 1024 * 1024;
822} 824}
823#endif 825#endif
824 826
825/* 827/*
826 * EDID can be read from DVI-D (HDMI) port on BeagleBoard from 828 * EDID can be read from DVI-D (HDMI) port on BeagleBoard from
827 * If EDID data is present, this function fills in the supplied edid_buf 829 * If EDID data is present, this function fills in the supplied edid_buf
828 * and returns true. Otherwise, it returns false and the contents of the 830 * and returns true. Otherwise, it returns false and the contents of the
829 * buffer are undefined. 831 * buffer are undefined.
830 */ 832 */
831static bool 833static bool
832beagle_read_edid(uint8_t *edid_buf, size_t edid_buflen) 834beagle_read_edid(uint8_t *edid_buf, size_t edid_buflen)
833{ 835{
834#if defined(OMAP_3530) 836#if defined(OMAP_3530)
835 i2c_tag_t ic = NULL; 837 i2c_tag_t ic = NULL;
836 uint8_t reg; 838 uint8_t reg;
837 int error; 839 int error;
838 840
839 /* On Beagleboard, EDID is accessed using I2C2 ("omapiic2"). */ 841 /* On Beagleboard, EDID is accessed using I2C2 ("omapiic2"). */
840 extern i2c_tag_t omap3_i2c_get_tag(device_t); 842 extern i2c_tag_t omap3_i2c_get_tag(device_t);
841 ic = omap3_i2c_get_tag(device_find_by_xname("omapiic2")); 843 ic = omap3_i2c_get_tag(device_find_by_xname("omapiic2"));
842 844
843 if (ic == NULL) 845 if (ic == NULL)
844 return false; 846 return false;
845 847
846 iic_acquire_bus(ic, 0); 848 iic_acquire_bus(ic, 0);
847 for (reg = DDC_EDID_START; reg < edid_buflen; reg++) { 849 for (reg = DDC_EDID_START; reg < edid_buflen; reg++) {
848 error = iic_exec(ic, I2C_OP_READ_WITH_STOP, DDC_ADDR, 850 error = iic_exec(ic, I2C_OP_READ_WITH_STOP, DDC_ADDR,
849 &reg, sizeof(reg), &edid_buf[reg], 1, 0); 851 &reg, sizeof(reg), &edid_buf[reg], 1, 0);
850 if (error) 852 if (error)
851 break; 853 break;
852 } 854 }
853 iic_release_bus(ic, 0); 855 iic_release_bus(ic, 0);
854 856
855 return error == 0 ? true : false; 857 return error == 0 ? true : false;
856#else 858#else
857 return false; 859 return false;
858#endif 860#endif
859} 861}
860 862
861void 863void
862beagle_device_register(device_t self, void *aux) 864beagle_device_register(device_t self, void *aux)
863{ 865{
864 prop_dictionary_t dict = device_properties(self); 866 prop_dictionary_t dict = device_properties(self);
865 867
866 if (device_is_a(self, "armperiph") 868 if (device_is_a(self, "armperiph")
867 && device_is_a(device_parent(self), "mainbus")) { 869 && device_is_a(device_parent(self), "mainbus")) {
868 /* 870 /*
869 * XXX KLUDGE ALERT XXX 871 * XXX KLUDGE ALERT XXX
870 * The iot mainbus supplies is completely wrong since it scales 872 * The iot mainbus supplies is completely wrong since it scales
871 * addresses by 2. The simpliest remedy is to replace with our 873 * addresses by 2. The simpliest remedy is to replace with our
872 * bus space used for the armcore regisers (which armperiph uses).  874 * bus space used for the armcore regisers (which armperiph uses).
873 */ 875 */
874 struct mainbus_attach_args * const mb = aux; 876 struct mainbus_attach_args * const mb = aux;
875 mb->mb_iot = &omap_bs_tag; 877 mb->mb_iot = &omap_bs_tag;
876 return; 878 return;
877 } 879 }
878  880
879 /* 881 /*
880 * We need to tell the A9 Global/Watchdog Timer 882 * We need to tell the A9 Global/Watchdog Timer
881 * what frequency it runs at. 883 * what frequency it runs at.
882 */ 884 */
883 if (device_is_a(self, "a9tmr") || device_is_a(self, "a9wdt")) { 885 if (device_is_a(self, "a9tmr") || device_is_a(self, "a9wdt")) {
884 /* 886 /*
885 * This clock always runs at (arm_clk div 2) and only goes 887 * This clock always runs at (arm_clk div 2) and only goes
886 * to timers that are part of the A9 MP core subsystem. 888 * to timers that are part of the A9 MP core subsystem.
887 */ 889 */
888 prop_dictionary_set_uint32(dict, "frequency", 890 prop_dictionary_set_uint32(dict, "frequency",
889 curcpu()->ci_data.cpu_cc_freq / 2); 891 curcpu()->ci_data.cpu_cc_freq / 2);
890 return; 892 return;
891 }  893 }
892 894
893 if (device_is_a(self, "ehci")) { 895 if (device_is_a(self, "ehci")) {
894#if defined(OMAP_3530) 896#if defined(OMAP_3530)
895 /* XXX Beagleboard specific port configuration */ 897 /* XXX Beagleboard specific port configuration */
 898 prop_dictionary_set_uint16(dict, "nports", 3);
896 prop_dictionary_set_cstring(dict, "port0-mode", "none"); 899 prop_dictionary_set_cstring(dict, "port0-mode", "none");
897 prop_dictionary_set_cstring(dict, "port1-mode", "phy"); 900 prop_dictionary_set_cstring(dict, "port1-mode", "phy");
898 prop_dictionary_set_cstring(dict, "port2-mode", "none"); 901 prop_dictionary_set_cstring(dict, "port2-mode", "none");
899 prop_dictionary_set_bool(dict, "phy-reset", true); 902 prop_dictionary_set_bool(dict, "phy-reset", true);
900 prop_dictionary_set_int16(dict, "port0-gpio", -1); 903 prop_dictionary_set_int16(dict, "port0-gpio", -1);
901 prop_dictionary_set_int16(dict, "port1-gpio", 147); 904 prop_dictionary_set_int16(dict, "port1-gpio", 147);
 905 prop_dictionary_set_bool(dict, "port1-gpioval", true);
902 prop_dictionary_set_int16(dict, "port2-gpio", -1); 906 prop_dictionary_set_int16(dict, "port2-gpio", -1);
903 prop_dictionary_set_uint16(dict, "dpll5-m", 443); 907 prop_dictionary_set_uint16(dict, "dpll5-m", 443);
904 prop_dictionary_set_uint16(dict, "dpll5-n", 11); 908 prop_dictionary_set_uint16(dict, "dpll5-n", 11);
905 prop_dictionary_set_uint16(dict, "dpll5-m2", 4); 909 prop_dictionary_set_uint16(dict, "dpll5-m2", 4);
906#endif 910#endif
 911#if defined(OMAP_4430)
 912 prop_dictionary_set_uint16(dict, "nports", 2);
 913#if 0
 914 prop_dictionary_set_bool(dict, "phy-reset", true);
 915#else
 916 prop_dictionary_set_bool(dict, "phy-reset", false);
 917#endif
 918 prop_dictionary_set_cstring(dict, "port0-mode", "none");
 919 prop_dictionary_set_int16(dict, "port0-gpio", -1);
 920#if 0
 921 prop_dictionary_set_cstring(dict, "port1-mode", "phy");
 922#else
 923 prop_dictionary_set_cstring(dict, "port1-mode", "none");
 924#endif
 925 prop_dictionary_set_int16(dict, "port1-gpio", 62);
 926 prop_dictionary_set_bool(dict, "port1-gpioval", true);
 927#if 0
 928 omap2_gpio_ctl(1, GPIO_PIN_OUTPUT);
 929 omap2_gpio_write(1, 1); // Enable Hub
 930#endif
 931#endif
907 return; 932 return;
908 } 933 }
909 934
910 if (device_is_a(self, "sdhc")) { 935 if (device_is_a(self, "sdhc")) {
911#if defined(OMAP_3430) || defined(OMAP_3530) 936#if defined(OMAP_3430) || defined(OMAP_3530)
912 prop_dictionary_set_uint32(dict, "clkmask", 0); 937 prop_dictionary_set_uint32(dict, "clkmask", 0);
913 prop_dictionary_set_bool(dict, "8bit", true); 938 prop_dictionary_set_bool(dict, "8bit", true);
914#endif 939#endif
915 return; 940 return;
916 } 941 }
917 942
918 if (device_is_a(self, "omapfb")) { 943 if (device_is_a(self, "omapfb")) {
919 if (beagle_read_edid(beagle_edid, sizeof(beagle_edid))) { 944 if (beagle_read_edid(beagle_edid, sizeof(beagle_edid))) {
920 prop_dictionary_set(dict, "EDID", 945 prop_dictionary_set(dict, "EDID",
921 prop_data_create_data(beagle_edid, 946 prop_data_create_data(beagle_edid,
922 sizeof(beagle_edid))); 947 sizeof(beagle_edid)));
923 } 948 }
924 if (use_fb_console) 949 if (use_fb_console)
925 prop_dictionary_set_bool(dict, "is_console", true); 950 prop_dictionary_set_bool(dict, "is_console", true);
926 return; 951 return;
927 } 952 }
928 if (device_is_a(self, "com")) { 953 if (device_is_a(self, "com")) {
929 if (use_fb_console) 954 if (use_fb_console)
930 prop_dictionary_set_bool(dict, "is_console", false); 955 prop_dictionary_set_bool(dict, "is_console", false);
931 } 956 }
932} 957}