Module Name:    src
Committed By:   jmcneill
Date:           Mon May 18 20:36:42 UTC 2015

Modified Files:
        src/sys/arch/arm/nvidia: files.tegra tegra_car.c tegra_carreg.h
            tegra_io.c tegra_reg.h tegra_var.h
        src/sys/arch/evbarm/conf: JETSONTK1
Added Files:
        src/sys/arch/arm/nvidia: tegra_host1x.c

Log Message:
Power-on Host1x subsystem


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/nvidia/files.tegra
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/nvidia/tegra_car.c
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/nvidia/tegra_carreg.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/nvidia/tegra_host1x.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/nvidia/tegra_io.c \
    src/sys/arch/arm/nvidia/tegra_reg.h
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/nvidia/tegra_var.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/evbarm/conf/JETSONTK1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/nvidia/files.tegra
diff -u src/sys/arch/arm/nvidia/files.tegra:1.12 src/sys/arch/arm/nvidia/files.tegra:1.13
--- src/sys/arch/arm/nvidia/files.tegra:1.12	Mon May 18 19:32:48 2015
+++ src/sys/arch/arm/nvidia/files.tegra	Mon May 18 20:36:42 2015
@@ -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 @@ file	arch/arm/nvidia/tegra_ahcisata.c	te
 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

Index: src/sys/arch/arm/nvidia/tegra_car.c
diff -u src/sys/arch/arm/nvidia/tegra_car.c:1.16 src/sys/arch/arm/nvidia/tegra_car.c:1.17
--- src/sys/arch/arm/nvidia/tegra_car.c:1.16	Mon May 18 19:32:48 2015
+++ src/sys/arch/arm/nvidia/tegra_car.c	Mon May 18 20:36:42 2015
@@ -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 <[email protected]>
@@ -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 @@ tegra_car_dc_enable(u_int port)
 
 	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);
+}

Index: src/sys/arch/arm/nvidia/tegra_carreg.h
diff -u src/sys/arch/arm/nvidia/tegra_carreg.h:1.15 src/sys/arch/arm/nvidia/tegra_carreg.h:1.16
--- src/sys/arch/arm/nvidia/tegra_carreg.h:1.15	Mon May 18 19:32:48 2015
+++ src/sys/arch/arm/nvidia/tegra_carreg.h	Mon May 18 20:36:42 2015
@@ -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 <[email protected]>
@@ -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

Index: src/sys/arch/arm/nvidia/tegra_io.c
diff -u src/sys/arch/arm/nvidia/tegra_io.c:1.10 src/sys/arch/arm/nvidia/tegra_io.c:1.11
--- src/sys/arch/arm/nvidia/tegra_io.c:1.10	Mon May 18 19:32:48 2015
+++ src/sys/arch/arm/nvidia/tegra_io.c	Mon May 18 20:36:42 2015
@@ -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 <[email protected]>
@@ -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 @@ static const struct tegra_locators tegra
     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_attach(device_t parent, device_t
 	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));
Index: src/sys/arch/arm/nvidia/tegra_reg.h
diff -u src/sys/arch/arm/nvidia/tegra_reg.h:1.10 src/sys/arch/arm/nvidia/tegra_reg.h:1.11
--- src/sys/arch/arm/nvidia/tegra_reg.h:1.10	Sun May 17 01:28:17 2015
+++ src/sys/arch/arm/nvidia/tegra_reg.h	Mon May 18 20:36:42 2015
@@ -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 <[email protected]>
@@ -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

Index: src/sys/arch/arm/nvidia/tegra_var.h
diff -u src/sys/arch/arm/nvidia/tegra_var.h:1.17 src/sys/arch/arm/nvidia/tegra_var.h:1.18
--- src/sys/arch/arm/nvidia/tegra_var.h:1.17	Mon May 18 19:32:48 2015
+++ src/sys/arch/arm/nvidia/tegra_var.h	Mon May 18 20:36:42 2015
@@ -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 <[email protected]>
@@ -105,6 +105,7 @@ void	tegra_car_utmip_init(void);
 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);

Index: src/sys/arch/evbarm/conf/JETSONTK1
diff -u src/sys/arch/evbarm/conf/JETSONTK1:1.21 src/sys/arch/evbarm/conf/JETSONTK1:1.22
--- src/sys/arch/evbarm/conf/JETSONTK1:1.21	Mon May 18 19:32:48 2015
+++ src/sys/arch/evbarm/conf/JETSONTK1	Mon May 18 20:36:42 2015
@@ -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 @@ wd*		at atabus? drive ?
 #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

Added files:

Index: src/sys/arch/arm/nvidia/tegra_host1x.c
diff -u /dev/null src/sys/arch/arm/nvidia/tegra_host1x.c:1.1
--- /dev/null	Mon May 18 20:36:42 2015
+++ src/sys/arch/arm/nvidia/tegra_host1x.c	Mon May 18 20:36:42 2015
@@ -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 <[email protected]>
+ * 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();
+}

Reply via email to