Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Power-on Host1x subsystem
details: https://anonhg.NetBSD.org/src/rev/12579749dcc6
branches: trunk
changeset: 338331:12579749dcc6
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon May 18 20:36:42 2015 +0000
description:
Power-on Host1x subsystem
diffstat:
sys/arch/arm/nvidia/files.tegra | 7 ++-
sys/arch/arm/nvidia/tegra_car.c | 28 ++++++++++++-
sys/arch/arm/nvidia/tegra_carreg.h | 13 +++++-
sys/arch/arm/nvidia/tegra_host1x.c | 81 ++++++++++++++++++++++++++++++++++++++
sys/arch/arm/nvidia/tegra_io.c | 10 +++-
sys/arch/arm/nvidia/tegra_reg.h | 4 +-
sys/arch/arm/nvidia/tegra_var.h | 3 +-
sys/arch/evbarm/conf/JETSONTK1 | 5 +-
8 files changed, 141 insertions(+), 10 deletions(-)
diffs (272 lines):
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/files.tegra
--- a/sys/arch/arm/nvidia/files.tegra Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/arm/nvidia/files.tegra Mon May 18 20:36:42 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.tegra,v 1.12 2015/05/18 19:32:48 jmcneill Exp $
+# $NetBSD: files.tegra,v 1.13 2015/05/18 20:36:42 jmcneill Exp $
#
# Configuration info for NVIDIA Tegra ARM Peripherals
#
@@ -87,6 +87,11 @@
attach hdaudio at tegraio with tegra_hdaudio
file arch/arm/nvidia/tegra_hdaudio.c tegra_hdaudio
+# Host1x subsystem
+device tegrahost1x
+attach tegrahost1x at tegraio with tegra_host1x
+file arch/arm/nvidia/tegra_host1x.c tegra_host1x
+
# Display controller
device tegradc { }
attach tegradc at tegraio with tegra_dc
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/tegra_car.c
--- a/sys/arch/arm/nvidia/tegra_car.c Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_car.c Mon May 18 20:36:42 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_car.c,v 1.16 2015/05/18 19:32:48 jmcneill Exp $ */
+/* $NetBSD: tegra_car.c,v 1.17 2015/05/18 20:36:42 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_car.c,v 1.16 2015/05/18 19:32:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_car.c,v 1.17 2015/05/18 20:36:42 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -671,3 +671,27 @@
return 0;
}
+
+void
+tegra_car_host1x_enable(void)
+{
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+
+ tegra_car_get_bs(&bst, &bsh);
+
+ /* Enter reset, enable clock */
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_L_SET_REG, CAR_DEV_L_HOST1X);
+ bus_space_write_4(bst, bsh, CAR_CLK_ENB_L_SET_REG, CAR_DEV_L_HOST1X);
+
+ /* Select PLLP for clock source, 408 MHz */
+ bus_space_write_4(bst, bsh, CAR_CLKSRC_HOST1X_REG,
+ __SHIFTIN(CAR_CLKSRC_HOST1X_SRC_PLLP_OUT0,
+ CAR_CLKSRC_HOST1X_SRC) |
+ __SHIFTIN(0, CAR_CLKSRC_HOST1X_CLK_DIVISOR));
+
+ delay(2);
+
+ /* Leave reset */
+ bus_space_write_4(bst, bsh, CAR_RST_DEV_L_CLR_REG, CAR_DEV_L_HOST1X);
+}
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/tegra_carreg.h
--- a/sys/arch/arm/nvidia/tegra_carreg.h Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_carreg.h Mon May 18 20:36:42 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_carreg.h,v 1.15 2015/05/18 19:32:48 jmcneill Exp $ */
+/* $NetBSD: tegra_carreg.h,v 1.16 2015/05/18 20:36:42 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -196,6 +196,17 @@
#define CAR_CLKSRC_DISP_SRC_PLLD2_OUT0 5
#define CAR_CLKSRC_DISP_SRC_CLK_M 6
+#define CAR_CLKSRC_HOST1X_REG 0x180
+#define CAR_CLKSRC_HOST1X_SRC __BITS(31,29)
+#define CAR_CLKSRC_HOST1X_SRC_PLLM_OUT0 0
+#define CAR_CLKSRC_HOST1X_SRC_PLLC2_OUT0 1
+#define CAR_CLKSRC_HOST1X_SRC_PLLC_OUT0 2
+#define CAR_CLKSRC_HOST1X_SRC_PLLC3_OUT0 3
+#define CAR_CLKSRC_HOST1X_SRC_PLLP_OUT0 4
+#define CAR_CLKSRC_HOST1X_SRC_PLLA_OUT0 6
+#define CAR_CLKSRC_HOST1X_IDLE_DIVISOR __BITS(15,8)
+#define CAR_CLKSRC_HOST1X_CLK_DIVISOR __BITS(7,0)
+
#define CAR_RST_DEV_L_SET_REG 0x300
#define CAR_RST_DEV_L_CLR_REG 0x304
#define CAR_RST_DEV_H_SET_REG 0x308
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/tegra_host1x.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/nvidia/tegra_host1x.c Mon May 18 20:36:42 2015 +0000
@@ -0,0 +1,81 @@
+/* $NetBSD: tegra_host1x.c,v 1.1 2015/05/18 20:36:42 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "locators.h"
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: tegra_host1x.c,v 1.1 2015/05/18 20:36:42 jmcneill Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/intr.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+
+#include <arm/nvidia/tegra_reg.h>
+#include <arm/nvidia/tegra_var.h>
+
+static int tegra_host1x_match(device_t, cfdata_t, void *);
+static void tegra_host1x_attach(device_t, device_t, void *);
+
+struct tegra_host1x_softc {
+ device_t sc_dev;
+ bus_space_tag_t sc_bst;
+ bus_space_handle_t sc_bsh;
+};
+
+CFATTACH_DECL_NEW(tegra_host1x, sizeof(struct tegra_host1x_softc),
+ tegra_host1x_match, tegra_host1x_attach, NULL, NULL);
+
+static int
+tegra_host1x_match(device_t parent, cfdata_t cf, void *aux)
+{
+ return 1;
+}
+
+static void
+tegra_host1x_attach(device_t parent, device_t self, void *aux)
+{
+ struct tegra_host1x_softc * const sc = device_private(self);
+ struct tegraio_attach_args * const tio = aux;
+ const struct tegra_locators * const loc = &tio->tio_loc;
+
+ sc->sc_dev = self;
+ sc->sc_bst = tio->tio_bst;
+ if (bus_space_map(sc->sc_bst, TEGRA_HOST1X_BASE + loc->loc_offset,
+ loc->loc_size, 0, &sc->sc_bsh) != 0) {
+ aprint_error(": couldn't map HOST1X\n");
+ return;
+ }
+
+ aprint_naive("\n");
+ aprint_normal(": HOST1X\n");
+
+ tegra_car_host1x_enable();
+}
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/tegra_io.c
--- a/sys/arch/arm/nvidia/tegra_io.c Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_io.c Mon May 18 20:36:42 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_io.c,v 1.10 2015/05/18 19:32:48 jmcneill Exp $ */
+/* $NetBSD: tegra_io.c,v 1.11 2015/05/18 20:36:42 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "opt_tegra.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_io.c,v 1.10 2015/05/18 19:32:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_io.c,v 1.11 2015/05/18 20:36:42 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -127,6 +127,10 @@
TEGRA_PCIE_OFFSET, TEGRA_PCIE_SIZE, NOPORT, TEGRA_INTR_PCIE_INT },
};
+static const struct tegra_locators tegra_host1x_locators[] = {
+ { "tegrahost1x", 0, TEGRA_HOST1X_SIZE, NOPORT, NOINTR }
+};
+
static const struct tegra_locators tegra_ghost_locators[] = {
{ "tegradc",
TEGRA_DISPLAYA_OFFSET, TEGRA_DISPLAYA_SIZE, 0, TEGRA_INTR_DISPLAYA },
@@ -159,6 +163,8 @@
tegraio_scan(self, tegra_ahb_a2_bsh,
tegra_ahb_a2_locators, __arraycount(tegra_ahb_a2_locators));
tegraio_scan(self, (bus_space_handle_t)NULL,
+ tegra_host1x_locators, __arraycount(tegra_host1x_locators));
+ tegraio_scan(self, (bus_space_handle_t)NULL,
tegra_ghost_locators, __arraycount(tegra_ghost_locators));
tegraio_scan(self, (bus_space_handle_t)NULL,
tegra_pcie_locators, __arraycount(tegra_pcie_locators));
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/tegra_reg.h
--- a/sys/arch/arm/nvidia/tegra_reg.h Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_reg.h Mon May 18 20:36:42 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_reg.h,v 1.10 2015/05/17 01:28:17 jmcneill Exp $ */
+/* $NetBSD: tegra_reg.h,v 1.11 2015/05/18 20:36:42 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -52,7 +52,7 @@
#define TEGRA_PCIE_PMEM_SIZE 0x20000000
#define TEGRA_HOST1X_BASE 0x50000000
-#define TEGRA_HOST1X_SIZE 0x00100000
+#define TEGRA_HOST1X_SIZE 0x00034000
#define TEGRA_GHOST_BASE 0x54000000
#define TEGRA_GHOST_SIZE 0x01000000
#define TEGRA_PPSB_BASE 0x60000000
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/arm/nvidia/tegra_var.h
--- a/sys/arch/arm/nvidia/tegra_var.h Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_var.h Mon May 18 20:36:42 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_var.h,v 1.17 2015/05/18 19:32:48 jmcneill Exp $ */
+/* $NetBSD: tegra_var.h,v 1.18 2015/05/18 20:36:42 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -105,6 +105,7 @@
void tegra_car_utmip_enable(u_int);
void tegra_car_hdmi_enable(u_int);
int tegra_car_dc_enable(u_int);
+void tegra_car_host1x_enable(void);
struct tegra_gpio_pin;
struct tegra_gpio_pin *tegra_gpio_acquire(const char *, u_int);
diff -r d5718c01de08 -r 12579749dcc6 sys/arch/evbarm/conf/JETSONTK1
--- a/sys/arch/evbarm/conf/JETSONTK1 Mon May 18 19:32:48 2015 +0000
+++ b/sys/arch/evbarm/conf/JETSONTK1 Mon May 18 20:36:42 2015 +0000
@@ -1,5 +1,5 @@
#
-# $NetBSD: JETSONTK1,v 1.21 2015/05/18 19:32:48 jmcneill Exp $
+# $NetBSD: JETSONTK1,v 1.22 2015/05/18 20:36:42 jmcneill Exp $
#
# NVIDIA Jetson TK1 - Tegra K1 development kit
# https://developer.nvidia.com/jetson-tk1
@@ -116,6 +116,9 @@
#options HDAUDIO_ENABLE_HDMI
#options HDAUDIO_ENABLE_DISPLAYPORT
+# Host1x subsystem
+tegrahost1x0 at tegraio? # HOST1X
+
# Display controller
tegradc0 at tegraio? port 0 # DISPLAYA
tegradc1 at tegraio? port 1 # DISPLAYB
Home |
Main Index |
Thread Index |
Old Index