Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch add Tegra124 MP support
details: https://anonhg.NetBSD.org/src/rev/2f2fcc121c4e
branches: trunk
changeset: 337769:2f2fcc121c4e
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sun Apr 26 22:04:28 2015 +0000
description:
add Tegra124 MP support
diffstat:
sys/arch/arm/nvidia/soc_tegra124.c | 28 +++++++++++++++++++--
sys/arch/arm/nvidia/tegra_pmc.c | 46 +++++++++++++++++++++++++++-------
sys/arch/arm/nvidia/tegra_pmcreg.h | 34 +++++++++++++++++++++++++-
sys/arch/arm/nvidia/tegra_reg.h | 9 +++++-
sys/arch/arm/nvidia/tegra_soc.c | 32 +++++++++++++----------
sys/arch/arm/nvidia/tegra_var.h | 4 ++-
sys/arch/evbarm/tegra/tegra_machdep.c | 17 +++++++++++-
sys/arch/evbarm/tegra/tegra_start.S | 14 +++++++++-
8 files changed, 149 insertions(+), 35 deletions(-)
diffs (truncated from 409 to 300 lines):
diff -r 37e642f2582a -r 2f2fcc121c4e sys/arch/arm/nvidia/soc_tegra124.c
--- a/sys/arch/arm/nvidia/soc_tegra124.c Sun Apr 26 21:40:48 2015 +0000
+++ b/sys/arch/arm/nvidia/soc_tegra124.c Sun Apr 26 22:04:28 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: soc_tegra124.c,v 1.1 2015/03/29 10:41:59 jmcneill Exp $ */
+/* $NetBSD: soc_tegra124.c,v 1.2 2015/04/26 22:04:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: soc_tegra124.c,v 1.1 2015/03/29 10:41:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: soc_tegra124.c,v 1.2 2015/04/26 22:04:28 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -42,16 +42,38 @@
#include <arm/cpufunc.h>
#include <arm/nvidia/tegra_reg.h>
+#include <arm/nvidia/tegra_pmcreg.h>
#include <arm/nvidia/tegra_var.h>
+#define EVP_RESET_VECTOR_0_REG 0x100
+
void
tegra124_mpinit(void)
{
#if defined(MULTIPROCESSOR)
extern void cortex_mpstart(void);
+ bus_space_tag_t bst = &armv7_generic_bs_tag;
+ bus_space_handle_t bsh;
+ u_int i;
+
+ bus_space_subregion(bst, tegra_ppsb_bsh,
+ TEGRA_EVP_OFFSET, TEGRA_EVP_SIZE, &bsh);
arm_cpu_max = 1 + __SHIFTOUT(armreg_l2ctrl_read(), L2CTRL_NUMCPU);
+ KASSERT(arm_cpu_max == 4);
- /* TODO */
+ bus_space_write_4(bst, bsh, EVP_RESET_VECTOR_0_REG, (uint32_t)cortex_mpstart);
+ bus_space_barrier(bst, bsh, EVP_RESET_VECTOR_0_REG, 4,
+ BUS_SPACE_BARRIER_READ | BUS_SPACE_BARRIER_WRITE);
+
+ tegra_pmc_power(PMC_PARTID_CPU1, true);
+ tegra_pmc_power(PMC_PARTID_CPU2, true);
+ tegra_pmc_power(PMC_PARTID_CPU3, true);
+
+ for (i = 0x10000000; i > 0; i--) {
+ __asm __volatile("dmb" ::: "memory");
+ if (arm_cpu_hatched == 0xe)
+ break;
+ }
#endif
}
diff -r 37e642f2582a -r 2f2fcc121c4e sys/arch/arm/nvidia/tegra_pmc.c
--- a/sys/arch/arm/nvidia/tegra_pmc.c Sun Apr 26 21:40:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_pmc.c Sun Apr 26 22:04:28 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_pmc.c,v 1.2 2015/03/29 22:27:04 jmcneill Exp $ */
+/* $NetBSD: tegra_pmc.c,v 1.3 2015/04/26 22:04:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_pmc.c,v 1.2 2015/03/29 22:27:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_pmc.c,v 1.3 2015/04/26 22:04:28 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -81,6 +81,19 @@
aprint_normal(": PMC\n");
}
+static void
+tegra_pmc_get_bs(bus_space_tag_t *pbst, bus_space_handle_t *pbsh)
+{
+ if (pmc_softc) {
+ *pbst = pmc_softc->sc_bst;
+ *pbsh = pmc_softc->sc_bsh;
+ } else {
+ *pbst = &armv7_generic_bs_tag;
+ bus_space_subregion(*pbst, tegra_apb_bsh,
+ TEGRA_PMC_OFFSET, TEGRA_PMC_SIZE, pbsh);
+ }
+}
+
void
tegra_pmc_reset(void)
{
@@ -88,14 +101,7 @@
bus_space_handle_t bsh;
uint32_t cntrl;
- if (pmc_softc) {
- bst = pmc_softc->sc_bst;
- bsh = pmc_softc->sc_bsh;
- } else {
- bst = &armv7_generic_bs_tag;
- bus_space_subregion(bst, tegra_apb_bsh,
- TEGRA_PMC_OFFSET, TEGRA_PMC_SIZE, &bsh);
- }
+ tegra_pmc_get_bs(&bst, &bsh);
cntrl = bus_space_read_4(bst, bsh, PMC_CNTRL_0_REG);
cntrl |= PMC_CNTRL_0_MAIN_RST;
@@ -105,3 +111,23 @@
__asm("wfi");
}
}
+
+void
+tegra_pmc_power(u_int partid, bool enable)
+{
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+ uint32_t status;
+ bool state;
+
+ tegra_pmc_get_bs(&bst, &bsh);
+
+ status = bus_space_read_4(bst, bsh, PMC_PWRGATE_STATUS_0_REG);
+ state = !!(status & __BIT(partid));
+ if (state == enable)
+ return;
+
+ bus_space_write_4(bst, bsh, PMC_PWRGATE_TOGGLE_0_REG,
+ __SHIFTIN(partid, PMC_PWRGATE_TOGGLE_0_PARTID) |
+ PMC_PWRGATE_TOGGLE_0_START);
+}
diff -r 37e642f2582a -r 2f2fcc121c4e sys/arch/arm/nvidia/tegra_pmcreg.h
--- a/sys/arch/arm/nvidia/tegra_pmcreg.h Sun Apr 26 21:40:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_pmcreg.h Sun Apr 26 22:04:28 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_pmcreg.h,v 1.1 2015/03/29 10:41:59 jmcneill Exp $ */
+/* $NetBSD: tegra_pmcreg.h,v 1.2 2015/04/26 22:04:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -53,4 +53,36 @@
#define PMC_CNTRL_0_RTC_CLK_DIS __BIT(1)
#define PMC_CNTRL_0_KBC_CLK_DIS __BIT(0)
+#define PMC_PWRGATE_TOGGLE_0_REG 0x30
+
+#define PMC_PWRGATE_TOGGLE_0_START __BIT(8)
+#define PMC_PWRGATE_TOGGLE_0_PARTID __BITS(4,0)
+
+#define PMC_PWRGATE_STATUS_0_REG 0x38
+
+#define PMC_PARTID_IRAM 24
+#define PMC_PARTID_VIC 23
+#define PMC_PARTID_XUSBC 22
+#define PMC_PARTID_XUSBB 21
+#define PMC_PARTID_XUSBA 20
+#define PMC_PARTID_DISB 19
+#define PMC_PARTID_DIS 18
+#define PMC_PARTID_SOR 17
+#define PMC_PARTID_C1NC 16
+#define PMC_PARTID_C0NC 15
+#define PMC_PARTID_CE0 14
+#define PMC_PARTID_A9LP 12
+#define PMC_PARTID_CPU3 11
+#define PMC_PARTID_CPU2 10
+#define PMC_PARTID_CPU1 9
+#define PMC_PARTID_SAX 8
+#define PMC_PARTID_HEG 7
+#define PMC_PARTID_MPE 6
+#define PMC_PARTID_L2C 5
+#define PMC_PARTID_VDE 4
+#define PMC_PARTID_PCX 3
+#define PMC_PARTID_VE 2
+#define PMC_PARTID_TD 1
+#define PMC_PARTID_CPU0 0
+
#endif /* _ARM_TEGRA_PMCREG_H */
diff -r 37e642f2582a -r 2f2fcc121c4e sys/arch/arm/nvidia/tegra_reg.h
--- a/sys/arch/arm/nvidia/tegra_reg.h Sun Apr 26 21:40:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_reg.h Sun Apr 26 22:04:28 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_reg.h,v 1.2 2015/04/26 16:24:01 jmcneill Exp $ */
+/* $NetBSD: tegra_reg.h,v 1.3 2015/04/26 22:04:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -42,7 +42,8 @@
#define TEGRA_AHB_A2_BASE 0x7c000000
#define TEGRA_AHB_A2_SIZE 0x02000000
-#define TEGRA_HOST1X_VBASE 0xfb000000
+#define TEGRA_HOST1X_VBASE 0xfaf00000
+#define TEGRA_PPSB_VBASE 0xfb000000
#define TEGRA_APB_VBASE 0xfc000000
#define TEGRA_AHB_A2_VBASE 0xfd000000
@@ -85,6 +86,10 @@
#define TEGRA_XUSB_DEV_OFFSET 0x000d0000
#define TEGRA_XUSB_DEV_SIZE 0xa000
+/* PPSB */
+#define TEGRA_EVP_OFFSET 0x0000f000
+#define TEGRA_EVP_SIZE 0x1000
+
/* AHB_A2 */
#define TEGRA_USB1_OFFSET 0x01000000
#define TEGRA_USB1_SIZE 0x1800
diff -r 37e642f2582a -r 2f2fcc121c4e sys/arch/arm/nvidia/tegra_soc.c
--- a/sys/arch/arm/nvidia/tegra_soc.c Sun Apr 26 21:40:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_soc.c Sun Apr 26 22:04:28 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_soc.c,v 1.2 2015/03/29 22:27:04 jmcneill Exp $ */
+/* $NetBSD: tegra_soc.c,v 1.3 2015/04/26 22:04:28 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_soc.c,v 1.2 2015/03/29 22:27:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_soc.c,v 1.3 2015/04/26 22:04:28 jmcneill Exp $");
#define _ARM32_BUS_DMA_PRIVATE
#include <sys/param.h>
@@ -49,6 +49,7 @@
#include <arm/nvidia/tegra_var.h>
bus_space_handle_t tegra_host1x_bsh;
+bus_space_handle_t tegra_ppsb_bsh;
bus_space_handle_t tegra_apb_bsh;
bus_space_handle_t tegra_ahb_a2_bsh;
@@ -58,34 +59,37 @@
_BUS_DMATAG_FUNCS,
};
-#if defined(MULTIPROCESSOR)
static void tegra_mpinit(void);
-#endif
void
tegra_bootstrap(void)
{
- bus_space_map(&armv7_generic_bs_tag,
+ if (bus_space_map(&armv7_generic_bs_tag,
TEGRA_HOST1X_BASE, TEGRA_HOST1X_SIZE, 0,
- &tegra_host1x_bsh);
- bus_space_map(&armv7_generic_bs_tag,
+ &tegra_host1x_bsh) != 0)
+ panic("couldn't map HOST1X");
+ if (bus_space_map(&armv7_generic_bs_tag,
+ TEGRA_PPSB_BASE, TEGRA_PPSB_SIZE, 0,
+ &tegra_ppsb_bsh) != 0)
+ panic("couldn't map PPSB");
+ if (bus_space_map(&armv7_generic_bs_tag,
TEGRA_APB_BASE, TEGRA_APB_SIZE, 0,
- &tegra_apb_bsh);
- bus_space_map(&armv7_generic_bs_tag,
+ &tegra_apb_bsh) != 0)
+ panic("couldn't map APB");
+ if (bus_space_map(&armv7_generic_bs_tag,
TEGRA_AHB_A2_BASE, TEGRA_AHB_A2_SIZE, 0,
- &tegra_ahb_a2_bsh);
+ &tegra_ahb_a2_bsh) != 0)
+ panic("couldn't map AHB A2");
curcpu()->ci_data.cpu_cc_freq = 696000000; /* XXX */
-#if defined(MULTIPROCESSOR)
tegra_mpinit();
-#endif
}
-#if defined(MULTIPROCESSOR)
static void
tegra_mpinit(void)
{
+#if defined(MULTIPROCESSOR)
switch (tegra_chip_id()) {
#ifdef SOC_TEGRA124
case CHIP_ID_TEGRA124:
@@ -95,8 +99,8 @@
default:
panic("Unsupported SOC ID %#x", tegra_chip_id());
}
+#endif
}
-#endif
u_int
tegra_chip_id(void)
diff -r 37e642f2582a -r 2f2fcc121c4e sys/arch/arm/nvidia/tegra_var.h
--- a/sys/arch/arm/nvidia/tegra_var.h Sun Apr 26 21:40:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_var.h Sun Apr 26 22:04:28 2015 +0000
Home |
Main Index |
Thread Index |
Old Index