Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbarm adapt am335x memprobe so it can be used by o...
details: https://anonhg.NetBSD.org/src/rev/a637dad403a5
branches: trunk
changeset: 787410:a637dad403a5
user: matt <matt%NetBSD.org@localhost>
date: Sun Jun 16 16:48:23 2013 +0000
description:
adapt am335x memprobe so it can be used by omap4/omap5.
Fill in the reference clock (omap_sys_clk) when determining speed.
Make sure memory controller are mapped.
Make sure to map console PA in bootstrap page table.
diffstat:
sys/arch/evbarm/beagle/beagle.h | 43 ++++++++++---
sys/arch/evbarm/beagle/beagle_machdep.c | 100 ++++++++++++++++++++++++-------
sys/arch/evbarm/beagle/beagle_start.S | 33 ++++++++-
sys/arch/evbarm/conf/BEAGLEBOARD | 3 +-
sys/arch/evbarm/conf/BEAGLEBONE | 6 +-
5 files changed, 141 insertions(+), 44 deletions(-)
diffs (truncated from 391 to 300 lines):
diff -r 723c56d3698a -r a637dad403a5 sys/arch/evbarm/beagle/beagle.h
--- a/sys/arch/evbarm/beagle/beagle.h Sun Jun 16 16:44:39 2013 +0000
+++ b/sys/arch/evbarm/beagle/beagle.h Sun Jun 16 16:48:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: beagle.h,v 1.10 2013/04/30 00:18:01 matt Exp $ */
+/* $NetBSD: beagle.h,v 1.11 2013/06/16 16:48:23 matt Exp $ */
/*
* Copyright (c) 2007 Microsoft
* All rights reserved.
@@ -71,6 +71,25 @@
#define OMAP_L4_WAKEUP_SIZE OMAP4430_L4_WAKEUP_SIZE
#define OMAP_L4_ABE_BASE OMAP4430_L4_ABE_BASE
#define OMAP_L4_ABE_SIZE OMAP4430_L4_ABE_SIZE
+#define OMAP_EMIF1_BASE OMAP4430_EMIF1_BASE
+#define OMAP_EMIF1_SIZE OMAP4430_EMIF1_SIZE
+#define OMAP_EMIF2_BASE OMAP4430_EMIF2_BASE
+#define OMAP_EMIF2_SIZE OMAP4430_EMIF2_SIZE
+#endif
+
+#ifdef OMAP_5430
+#define OMAP_L4_CORE_BASE OMAP5430_L4_CORE_BASE
+#define OMAP_L4_CORE_SIZE OMAP5430_L4_CORE_SIZE
+#define OMAP_L4_PERIPHERAL_BASE OMAP5430_L4_PERIPHERAL_BASE
+#define OMAP_L4_PERIPHERAL_SIZE OMAP5430_L4_PERIPHERAL_SIZE
+#define OMAP_L4_WAKEUP_BASE OMAP5430_L4_WAKEUP_BASE
+#define OMAP_L4_WAKEUP_SIZE OMAP5430_L4_WAKEUP_SIZE
+#define OMAP_L4_ABE_BASE OMAP5430_L4_ABE_BASE
+#define OMAP_L4_ABE_SIZE OMAP5430_L4_ABE_SIZE
+#define OMAP_EMIF1_BASE OMAP5430_EMIF1_BASE
+#define OMAP_EMIF1_SIZE OMAP5430_EMIF1_SIZE
+#define OMAP_EMIF2_BASE OMAP5430_EMIF2_BASE
+#define OMAP_EMIF2_SIZE OMAP5430_EMIF2_SIZE
#endif
#ifdef TI_AM335X
@@ -80,8 +99,8 @@
#define OMAP_L4_PERIPHERAL_SIZE TI_AM335X_L4_PERIPHERAL_SIZE
#define OMAP_L4_FAST_BASE TI_AM335X_L4_FAST_BASE
#define OMAP_L4_FAST_SIZE TI_AM335X_L4_FAST_SIZE
-#define OMAP_EMIF_BASE TI_AM335X_EMIF0_BASE
-#define OMAP_EMIF_SIZE TI_AM335X_EMIF0_SIZE
+#define OMAP_EMIF1_BASE TI_AM335X_EMIF1_BASE
+#define OMAP_EMIF1_SIZE TI_AM335X_EMIF1_SIZE
#endif
#ifdef TI_DM37XX
@@ -104,18 +123,20 @@
#define OMAP_SDRC_VBASE (OMAP_L4_WAKEUP_VBASE + OMAP_L4_WAKEUP_SIZE)
#define OMAP_KERNEL_IO_VEND (OMAP_SDRC_VBASE + OMAP_SDRC_SIZE)
#define CONSADDR_VA ((CONSADDR - OMAP_L4_PERIPHERAL_BASE) + OMAP_L4_PERIPHERAL_VBASE)
-#elif defined(OMAP_4430)
+#elif defined(OMAP_4430) || defined(OMAP_5430)
#define OMAP_L4_CORE_VBASE OMAP_KERNEL_IO_VBASE
-#define OMAP_L4_PERIPHERAL_VBASE (OMAP_L4_CORE_VBASE + OMAP_L4_CORE_SIZE)
+#define OMAP_L4_PERIPHERAL_VBASE (OMAP_L4_CORE_VBASE + OMAP_L4_CORE_SIZE)
#define OMAP_L4_ABE_VBASE (OMAP_L4_PERIPHERAL_VBASE + OMAP_L4_PERIPHERAL_SIZE)
-#define OMAP_KERNEL_IO_VEND (OMAP_L4_ABE_VBASE + OMAP_L4_ABE_SIZE)
-#define CONSADDR_VA ((CONSADDR - OMAP_L4_PERIPHERAL_BASE) + OMAP_L4_PERIPHERAL_VBASE)
+#define OMAP_EMIF1_VBASE (OMAP_L4_ABE_VBASE + OMAP_L4_ABE_SIZE)
+#define OMAP_EMIF2_VBASE (OMAP_EMIF1_VBASE + OMAP_EMIF1_SIZE)
+#define OMAP_KERNEL_IO_VEND (OMAP_EMIF2_VBASE + OMAP_EMIF2_SIZE)
+#define CONSADDR_VA ((CONSADDR - OMAP_L4_CORE_BASE) + OMAP_L4_CORE_VBASE)
#elif defined(TI_AM335X)
-#define OMAP_L4_CORE_VBASE OMAP_KERNEL_IO_VBASE
-#define OMAP_L4_PERIPHERAL_VBASE (OMAP_L4_CORE_VBASE + OMAP_L4_CORE_SIZE)
+#define OMAP_L4_PERIPHERAL_VBASE OMAP_KERNEL_IO_VBASE
#define OMAP_L4_FAST_VBASE (OMAP_L4_PERIPHERAL_VBASE + OMAP_L4_PERIPHERAL_SIZE)
-#define OMAP_EMIF_VBASE (OMAP_L4_FAST_VBASE + OMAP_L4_FAST_SIZE)
-#define OMAP_KERNEL_IO_VEND (OMAP_EMIF_VBASE + OMAP_EMIF_SIZE)
+#define OMAP_EMIF1_VBASE (OMAP_L4_FAST_VBASE + OMAP_L4_FAST_SIZE)
+#define OMAP_L4_CORE_VBASE (OMAP_EMIF1_VBASE + OMAP_EMIF1_SIZE)
+#define OMAP_KERNEL_IO_VEND (OMAP_L4_CORE_VBASE + OMAP_L4_CORE_SIZE)
#define CONSADDR_VA ((CONSADDR - OMAP_L4_CORE_BASE) + OMAP_L4_CORE_VBASE)
#elif defined(TI_DM37XX)
#define OMAP_L4_CORE_VBASE OMAP_KERNEL_IO_VBASE
diff -r 723c56d3698a -r a637dad403a5 sys/arch/evbarm/beagle/beagle_machdep.c
--- a/sys/arch/evbarm/beagle/beagle_machdep.c Sun Jun 16 16:44:39 2013 +0000
+++ b/sys/arch/evbarm/beagle/beagle_machdep.c Sun Jun 16 16:48:23 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: beagle_machdep.c,v 1.44 2013/06/12 20:36:53 matt Exp $ */
+/* $NetBSD: beagle_machdep.c,v 1.45 2013/06/16 16:48:23 matt Exp $ */
/*
* Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.44 2013/06/12 20:36:53 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.45 2013/06/16 16:48:23 matt Exp $");
#include "opt_machdep.h"
#include "opt_ddb.h"
@@ -229,12 +229,14 @@
#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX)
static void omap3_cpu_clk(void);
#endif
-#if defined(OMAP_4430)
+#if defined(OMAP_4430) || defined(OMAP_5430)
static void omap4_cpu_clk(void);
#endif
#if defined(TI_AM335X)
static void am335x_cpu_clk(void);
-static psize_t am335x_memprobe(void);
+#endif
+#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X)
+static psize_t emif_memprobe(void);
#endif
#if defined(OMAP_3430) || defined(OMAP_3530)
@@ -317,14 +319,26 @@
.pd_cache = PTE_NOCACHE
},
#endif
-#ifdef OMAP_EMIF_BASE
+#ifdef OMAP_EMIF1_BASE
{
/*
- * Map all of the L4 EMIF area
+ * Map all of the L4 EMIF1 area
*/
- .pd_va = _A(OMAP_EMIF_VBASE),
- .pd_pa = _A(OMAP_EMIF_BASE),
- .pd_size = _S(OMAP_EMIF_SIZE),
+ .pd_va = _A(OMAP_EMIF1_VBASE),
+ .pd_pa = _A(OMAP_EMIF1_BASE),
+ .pd_size = _S(OMAP_EMIF1_SIZE),
+ .pd_prot = VM_PROT_READ|VM_PROT_WRITE,
+ .pd_cache = PTE_NOCACHE
+ },
+#endif
+#ifdef OMAP_EMIF2_BASE
+ {
+ /*
+ * Map all of the L4 EMIF2 area
+ */
+ .pd_va = _A(OMAP_EMIF2_VBASE),
+ .pd_pa = _A(OMAP_EMIF2_BASE),
+ .pd_size = _S(OMAP_EMIF2_SIZE),
.pd_prot = VM_PROT_READ|VM_PROT_WRITE,
.pd_cache = PTE_NOCACHE
},
@@ -426,11 +440,11 @@
#if defined(OMAP_3430) || defined(OMAP_3530) || defined(TI_DM37XX)
omap3_cpu_clk(); // find our CPU speed.
#endif
-#if defined(OMAP_4430)
+#if defined(OMAP_4430) || defined(OMAP_5430)
omap4_cpu_clk(); // find our CPU speed.
#endif
#if defined(TI_AM335X)
- am335x_cpu_clk();
+ am335x_cpu_clk(); // find our CPU speed.
#endif
/* Heads up ... Setup the CPU / MMU / TLB functions. */
if (set_cpufuncs())
@@ -474,16 +488,17 @@
#if defined(OMAP_3430) || defined(OMAP_3530)
ram_size = omap3530_memprobe();
#endif
-#if defined(TI_AM335X)
- ram_size = am335x_memprobe();
+#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X)
+ ram_size = emif_memprobe();
#endif
+
/*
* If MEMSIZE specified less than what we really have, limit ourselves
* to that.
*/
#ifdef MEMSIZE
- if (ram_size == 0 || ram_size > MEMSIZE * 1024 * 1024)
- ram_size = MEMSIZE * 1024 * 1024;
+ if (ram_size == 0 || ram_size > (unsigned)MEMSIZE * 1024 * 1024)
+ ram_size = (unsigned)MEMSIZE * 1024 * 1024;
#else
KASSERTMSG(ram_size > 0, "RAM size unknown and MEMSIZE undefined");
#endif
@@ -493,6 +508,18 @@
bootconfig.dram[0].address = KERNEL_BASE_PHYS & -0x400000;
bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
+#if 0
+#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X)
+ KASSERT(cs1_p == false);
+ if (cs1_p > 0) {
+ bootconfig.dramblocks = 2;
+ bootconfig.dram[1].address = 0xC0000000;
+ bootconfig.dram[0].pages /= 2;
+ bootconfig.dram[1].pages = bootconfig.dram[0].pages;
+ }
+#endif
+#endif
+
#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
const bool mapallmem_p = true;
KASSERT(ram_size <= KERNEL_VM_BASE - KERNEL_BASE);
@@ -668,10 +695,11 @@
* MPU_CLK supplies ARM_FCLK which is twice the CPU frequency.
*/
curcpu()->ci_data.cpu_cc_freq = ((sys_clk * m) / ((n + 1) * m2 * 2)) * OMAP3_PRM_CLKSEL_MULT;
+ omap_sys_clk = sys_clk * OMAP3_PRM_CLKSEL_MULT;
}
#endif /* OMAP_3430 || OMAP_3530 || TI_DM37XX */
-#if defined(OMAP_4430)
+#if defined(OMAP_4430) || defined(OMAP_5430)
void
omap4_cpu_clk(void)
{
@@ -690,11 +718,12 @@
* MPU_CLK supplies ARM_FCLK which is twice the CPU frequency.
*/
curcpu()->ci_data.cpu_cc_freq = ((sys_clk * 2 * m) / ((n + 1) * m2)) * OMAP4_CM_CLKSEL_MULT / 2;
+ omap_sys_clk = sys_clk * OMAP4_CM_CLKSEL_MULT;
printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u mult=%u\n",
__func__, curcpu()->ci_data.cpu_cc_freq,
sys_clk, m, n, n+1, m2, OMAP4_CM_CLKSEL_MULT);
}
-#endif /* OMAP_4400 */
+#endif /* OMAP_4430 || OMAP_5430 */
#if defined(TI_AM335X)
void
@@ -718,26 +747,53 @@
printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u\n",
__func__, curcpu()->ci_data.cpu_cc_freq,
sys_clk, m, n, n+1, m2);
+ omap_sys_clk = sys_clk;
+}
+#endif /* TI_AM335X */
+
+#if defined(OMAP_4430) || defined(OMAP_5430) || defined(TI_AM335X)
+static inline uint32_t
+emif_read_sdram_config(vaddr_t emif_base)
+{
+ return *(const volatile uint32_t *)(emif_base + EMIF_SDRAM_CONFIG);
}
static psize_t
-am335x_memprobe(void)
+emif_memprobe(void)
{
- const vaddr_t emif_base = OMAP_EMIF_VBASE;
- uint32_t sdram_config = *(const volatile uint32_t *)(emif_base + EMIF_SDRAM_CONFIG);
+ uint32_t sdram_config = emif_read_sdram_config(OMAP_EMIF1_VBASE);
+ psize_t memsize = 1L;
+#if defined(TI_AM335X)
/*
* The original bbone's u-boot misprograms the EMIF so correct it
* if we detect if it has the wrong value.
*/
if (sdram_config == 0x41805332)
sdram_config -= __SHIFTIN(1, SDRAM_CONFIG_RSIZE);
+#endif
+#ifdef OMAP_EMIF2_VBASE
+ /*
+ * OMAP4 and OMAP5 have two EMIFs so if the 2nd one is configured
+ * like the first, we have twice the memory.
+ */
+ if (emif_read_sdram_config(OMAP_EMIF2_VBASE) == sdram_config)
+ memsize <<= 1;
+#endif
+ const u_int ebank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_EBANK);
const u_int ibank = __SHIFTOUT(sdram_config, SDRAM_CONFIG_IBANK);
const u_int rsize = 9 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_RSIZE);
const u_int pagesize = 8 + __SHIFTOUT(sdram_config, SDRAM_CONFIG_PAGESIZE);
const u_int width = 2 - __SHIFTOUT(sdram_config, SDRAM_CONFIG_WIDTH);
- printf("sdram_config = %#x\n", sdram_config);
- return 1L << (ibank + rsize + pagesize + width);
+#ifdef TI_AM335X
+ KASSERT(ebank == 0); // No chip selects on Sitara
+#endif
+ memsize <<= (ebank + ibank + rsize + pagesize + width);
+#ifdef VERBOSE_INIT_ARM
+ printf("sdram_config = %#x, memsize = %uMB\n", sdram_config,
+ (u_int)(memsize >> 20));
+#endif
+ return memsize;
}
#endif
diff -r 723c56d3698a -r a637dad403a5 sys/arch/evbarm/beagle/beagle_start.S
--- a/sys/arch/evbarm/beagle/beagle_start.S Sun Jun 16 16:44:39 2013 +0000
+++ b/sys/arch/evbarm/beagle/beagle_start.S Sun Jun 16 16:48:23 2013 +0000
@@ -98,7 +98,7 @@
#define INIT_MEMSIZE 128
#endif
-RCSID("$NetBSD: beagle_start.S,v 1.13 2013/04/30 00:18:02 matt Exp $")
+RCSID("$NetBSD: beagle_start.S,v 1.14 2013/06/16 16:48:23 matt Exp $")
#define Invalidate_I_cache(reg) \
mcr p15, 0, reg, c7, c5, 0 /* Invalidate Entire I cache */
@@ -284,11 +284,27 @@
(OMAP_L4_CORE_SIZE + L1_S_SIZE - 1) / L1_S_SIZE,
L1_S_PROTO | L1_S_APv7_KRW)
+#if OMAP_L4_CORE_BASE <= CONSADDR \
Home |
Main Index |
Thread Index |
Old Index