CVS commit: src/sys/arch/evbarm/tegra

2017-05-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 26 20:04:56 UTC 2017

Modified Files:
src/sys/arch/evbarm/tegra: tegra_start.S

Log Message:
Adjust a comment that refers to Tegra124; this code can be used on more
than one Tegra SoC.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbarm/tegra/tegra_start.S

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/evbarm/tegra/tegra_start.S
diff -u src/sys/arch/evbarm/tegra/tegra_start.S:1.11 src/sys/arch/evbarm/tegra/tegra_start.S:1.12
--- src/sys/arch/evbarm/tegra/tegra_start.S:1.11	Fri May 26 00:00:25 2017
+++ src/sys/arch/evbarm/tegra/tegra_start.S	Fri May 26 20:04:56 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.11 2017/05/26 00:00:25 jmcneill Exp $ */
+/* $NetBSD: tegra_start.S,v 1.12 2017/05/26 20:04:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include 
 #include 
 
-RCSID("$NetBSD: tegra_start.S,v 1.11 2017/05/26 00:00:25 jmcneill Exp $")
+RCSID("$NetBSD: tegra_start.S,v 1.12 2017/05/26 20:04:56 jmcneill Exp $")
 
 #if defined(VERBOSE_INIT_ARM) && defined(CONSADDR)
 #define	XPUTC(n)	mov r0, n; bl xputc
@@ -68,7 +68,7 @@ RCSID("$NetBSD: tegra_start.S,v 1.11 201
 #define	MD_CPU_HATCH	_C_LABEL(gtmr_init_cpu_clock)
 
 /*
- * Kernel start routine for Tegra 124 SoC.
+ * Kernel start routine for Tegra SoCs.
  * At this point, this code has been loaded into SDRAM
  * and the MMU maybe on or maybe off.
  */



CVS commit: src/sys/arch/evbarm/tegra

2017-05-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 26 18:58:55 UTC 2017

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
Don't try to use memory above 4GB PA.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.41 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.42
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.41	Fri May 26 00:15:12 2017
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Fri May 26 18:58:55 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.41 2017/05/26 00:15:12 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.42 2017/05/26 18:58:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.41 2017/05/26 00:15:12 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.42 2017/05/26 18:58:55 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -225,8 +225,7 @@ extern void cortex_mpstart(void);
 u_int
 initarm(void *arg)
 {
-	bus_addr_t memory_addr;
-	bus_size_t memory_size;
+	uint64_t memory_addr, memory_size;
 	psize_t ram_size = 0;
 	DPRINT("initarm:");
 
@@ -285,20 +284,24 @@ initarm(void *arg)
 		KERNEL_BASE, KERNEL_VM_BASE, KERNEL_VM_BASE - KERNEL_BASE, KERNEL_BASE_VOFFSET);
 
 	const int memory = OF_finddevice("/memory");
-	if (fdtbus_get_reg(memory, 0, _addr, _size) != 0)
+	if (fdtbus_get_reg64(memory, 0, _addr, _size) != 0)
 		panic("Cannot determine memory size");
 
 	DPRINTF("FDT memory node = %d, addr %llx, size %llu\n",
 	memory, (unsigned long long)memory_addr,
 	(unsigned long long)memory_size);
 
-	ram_size = memory_size;
+	/* Cannot map memory above 4GB */
+	if (memory_addr + memory_size > 0x1)
+		memory_size = 0x1 - memory_addr;
+
+	ram_size = (bus_size_t)memory_size;
 
 #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
 	const bool mapallmem_p = true;
 #ifndef PMAP_NEED_ALLOC_POOLPAGE
 	if (ram_size > KERNEL_VM_BASE - KERNEL_BASE) {
-		printf("%s: dropping RAM size from %luMB to %uMB\n",
+		DPRINTF("%s: dropping RAM size from %luMB to %uMB\n",
 		__func__, (unsigned long) (ram_size >> 20), 
 		(KERNEL_VM_BASE - KERNEL_BASE) >> 20);
 		ram_size = KERNEL_VM_BASE - KERNEL_BASE;
@@ -325,7 +328,7 @@ initarm(void *arg)
 
 	/* Fake bootconfig structure for the benefit of pmap.c. */
 	bootconfig.dramblocks = 1;
-	bootconfig.dram[0].address = memory_addr;
+	bootconfig.dram[0].address = (bus_addr_t)memory_addr;
 	bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
 
 	KASSERT((armreg_pfr1_read() & ARM_PFR1_SEC_MASK) != 0);



CVS commit: src/sys/arch/evbarm/tegra

2017-05-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 26 00:15:12 UTC 2017

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
Remove tegra_chip_id vs compat string test in initarm.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.40 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.41
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.40	Fri Apr 21 23:36:58 2017
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Fri May 26 00:15:12 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.40 2017/04/21 23:36:58 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.41 2017/05/26 00:15:12 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.40 2017/04/21 23:36:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.41 2017/05/26 00:15:12 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -281,25 +281,6 @@ initarm(void *arg)
 	parse_mi_bootargs(mi_bootargs);
 #endif
 
-	const u_int chip_id = tegra_chip_id();
-	switch (chip_id) {
-#ifdef SOC_TEGRA124
-case CHIP_ID_TEGRA124: {
-		const char * const tegra124_compatible_strings[] = {
-			"nvidia,tegra124",
-			NULL
-		};
-		const int node = OF_peer(0);
-if (of_compatible(node, tegra124_compatible_strings) < 0) {
-			panic("FDT is not compatible with Tegra124");
-		}
-break;
-	}
-#endif
-	default:
-		panic("Kernel does not support Tegra SOC ID %#x", chip_id);
-	}
-
 	DPRINTF("KERNEL_BASE=0x%x, KERNEL_VM_BASE=0x%x, KERNEL_VM_BASE - KERNEL_BASE=0x%x, KERNEL_BASE_VOFFSET=0x%x\n",
 		KERNEL_BASE, KERNEL_VM_BASE, KERNEL_VM_BASE - KERNEL_BASE, KERNEL_BASE_VOFFSET);
 



CVS commit: src/sys/arch/evbarm/tegra

2017-05-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 26 00:00:25 UTC 2017

Modified Files:
src/sys/arch/evbarm/tegra: tegra_start.S

Log Message:
Remove unused SOC_MPINIT definition


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/tegra/tegra_start.S

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/evbarm/tegra/tegra_start.S
diff -u src/sys/arch/evbarm/tegra/tegra_start.S:1.10 src/sys/arch/evbarm/tegra/tegra_start.S:1.11
--- src/sys/arch/evbarm/tegra/tegra_start.S:1.10	Fri Apr 21 23:36:58 2017
+++ src/sys/arch/evbarm/tegra/tegra_start.S	Fri May 26 00:00:25 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.10 2017/04/21 23:36:58 jmcneill Exp $ */
+/* $NetBSD: tegra_start.S,v 1.11 2017/05/26 00:00:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include 
 #include 
 
-RCSID("$NetBSD: tegra_start.S,v 1.10 2017/04/21 23:36:58 jmcneill Exp $")
+RCSID("$NetBSD: tegra_start.S,v 1.11 2017/05/26 00:00:25 jmcneill Exp $")
 
 #if defined(VERBOSE_INIT_ARM) && defined(CONSADDR)
 #define	XPUTC(n)	mov r0, n; bl xputc
@@ -67,10 +67,6 @@ RCSID("$NetBSD: tegra_start.S,v 1.10 201
 
 #define	MD_CPU_HATCH	_C_LABEL(gtmr_init_cpu_clock)
 
-#if defined(SOC_TEGRA124)
-#define SOC_MPINIT	_C_LABEL(tegra124_mpinit)
-#endif
-
 /*
  * Kernel start routine for Tegra 124 SoC.
  * At this point, this code has been loaded into SDRAM



CVS commit: src/sys/arch/evbarm/tegra

2015-12-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 16 12:18:02 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
fdt_openfirm_set_data -> fdtbus_set_data


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.35 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.36
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.35	Sun Dec 13 22:55:05 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Wed Dec 16 12:18:02 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.35 2015/12/13 22:55:05 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.36 2015/12/16 12:18:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.35 2015/12/13 22:55:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.36 2015/12/16 12:18:02 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -104,8 +104,6 @@ char *boot_args = NULL;
 u_int uboot_args[4] = { 0 };	/* filled in by tegra_start.S (not in bss) */
 
 #include 
-#include 
-#include 
 #include 
 #define FDT_BUF_SIZE	(128*1024)
 static uint8_t fdt_data[FDT_BUF_SIZE];
@@ -266,7 +264,7 @@ initarm(void *arg)
 		if (error != 0) {
 			panic("fdt_move failed: %s", fdt_strerror(error));
 		}
-		fdt_openfirm_set_data(fdt_data);
+		fdtbus_set_data(fdt_data);
 	} else {
 		panic("fdt_check_header failed: %s", fdt_strerror(error));
 	}



CVS commit: src/sys/arch/evbarm/tegra

2015-11-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 21 12:22:26 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
Try to reboot with the PMIC if available, falling back to PMC.

When the PMIC watchdog is armed and we reboot via PMC, the watchdog stays
armed on the next boot (and we end up being reset mid-boot the second time).
By rebooting with PMIC, we can ensure that the watchdog is not armed after
reset.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.32 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.33
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.32	Fri Nov 20 16:44:23 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat Nov 21 12:22:25 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.32 2015/11/20 16:44:23 jakllsch Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.33 2015/11/21 12:22:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.32 2015/11/20 16:44:23 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.33 2015/11/21 12:22:25 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -109,6 +109,7 @@ extern char KERNEL_BASE_phys[];
 #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
 
 static void tegra_device_register(device_t, void *);
+static void tegra_reset(void);
 static void tegra_powerdown(void);
 
 bs_protos(bs_notimpl);
@@ -244,7 +245,7 @@ initarm(void *arg)
 	uboot_args[0], uboot_args[1], uboot_args[2], uboot_args[3]);
 #endif
 
-	cpu_reset_address = tegra_pmc_reset;
+	cpu_reset_address = tegra_reset;
 	cpu_powerdown_address = tegra_powerdown;
 
 	/* Talk to the user */
@@ -524,6 +525,22 @@ tegra_device_register(device_t self, voi
 }
 
 static void
+tegra_reset(void)
+{
+#if NAS3722PMIC > 0
+	device_t pmic = device_find_by_driver_unit("as3722pmic", 0);
+	if (pmic != NULL) {
+		delay(100);
+		if (as3722_reboot(pmic) != 0) {
+			printf("WARNING: AS3722 reset failed\n");
+			return;
+		}
+	}
+#endif
+	tegra_pmc_reset();
+}
+
+static void
 tegra_powerdown(void)
 {
 #if NAS3722PMIC > 0



CVS commit: src/sys/arch/evbarm/tegra

2015-11-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Nov 20 16:44:23 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
Fix up tegrausbphy attach args and stuff from previous.

>From jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.31 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.32
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.31	Thu Nov 19 22:09:16 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Fri Nov 20 16:44:23 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.31 2015/11/19 22:09:16 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.32 2015/11/20 16:44:23 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.31 2015/11/19 22:09:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.32 2015/11/20 16:44:23 jakllsch Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -475,12 +475,11 @@ tegra_device_register(device_t self, voi
 	}
 
 	if (device_is_a(self, "tegrausbphy")) {
-		struct tegraio_attach_args * const tio = aux;
-		const struct tegra_locators * const loc = >tio_loc;
+		struct tegrausbphy_attach_args * const tup = aux;
 
-		if (loc->loc_port == 0) {
+		if (tup->tup_port == 0) {
 			prop_dictionary_set_cstring(dict, "vbus-gpio", "N4");
-		} else if (loc->loc_port == 2) {
+		} else if (tup->tup_port == 2) {
 			prop_dictionary_set_cstring(dict, "vbus-gpio", "N5");
 		}
 	}
@@ -506,12 +505,11 @@ tegra_device_register(device_t self, voi
 	}
 
 	if (device_is_a(self, "tegrausbphy")) {
-		struct tegraio_attach_args * const tio = aux;
-		const struct tegra_locators * const loc = >tio_loc;
+		struct tegrausbphy_attach_args * const tup = aux;
 
-		if (loc->loc_port == 0) {
+		if (tup->tup_port == 0) {
 			prop_dictionary_set_cstring(dict, "vbus-gpio", "N4");
-		} else if (loc->loc_port == 2) {
+		} else if (tup->tup_port == 2) {
 			prop_dictionary_set_cstring(dict, "vbus-gpio", "N5");
 		}
 	}



CVS commit: src/sys/arch/evbarm/tegra

2015-11-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 14 13:28:53 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
support video= kernel cmdline for setting HDMI-A-1 preferred video mode


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.26 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.27
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.26	Wed Nov 11 12:37:52 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat Nov 14 13:28:53 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.26 2015/11/11 12:37:52 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.27 2015/11/14 13:28:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.26 2015/11/11 12:37:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.27 2015/11/14 13:28:53 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -431,9 +431,15 @@ tegra_device_register(device_t self, voi
 	}
 
 	if (device_is_a(self, "tegradrm")) {
+		const char *video = tegra_bootconf_strdup("video");
+
 		if (tegra_bootconf_match("hdmi.forcemode", "dvi")) {
 			prop_dictionary_set_bool(dict, "force-dvi", true);
 		}
+
+		if (video) {
+			prop_dictionary_set_cstring(dict, "HDMI-A-1", video);
+		}
 	}
 
 	if (device_is_a(self, "tegracec")) {



CVS commit: src/sys/arch/evbarm/tegra

2015-11-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 14 23:04:30 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
sleep before asking the PMIC to power off


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.27 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.28
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.27	Sat Nov 14 13:28:53 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat Nov 14 23:04:30 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.27 2015/11/14 13:28:53 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.28 2015/11/14 23:04:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.27 2015/11/14 13:28:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.28 2015/11/14 23:04:30 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -547,11 +547,11 @@ tegra_powerdown(void)
 #if NAS3722PMIC > 0
 	device_t pmic = device_find_by_driver_unit("as3722pmic", 0);
 	if (pmic != NULL) {
+		delay(100);
 		if (as3722_poweroff(pmic) != 0) {
 			printf("WARNING: AS3722 poweroff failed\n");
 			return;
 		}
-		delay(100);
 	}
 #endif
 }



CVS commit: src/sys/arch/evbarm/tegra

2015-11-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 14 23:17:40 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
tegracec can get physical address from tegradrm now


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.28 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.29
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.28	Sat Nov 14 23:04:30 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat Nov 14 23:17:39 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.28 2015/11/14 23:04:30 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.29 2015/11/14 23:17:39 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.28 2015/11/14 23:04:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.29 2015/11/14 23:17:39 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -443,7 +443,7 @@ tegra_device_register(device_t self, voi
 	}
 
 	if (device_is_a(self, "tegracec")) {
-		prop_dictionary_set_cstring(dict, "hdmi-device", "tegrahdmi0");
+		prop_dictionary_set_cstring(dict, "hdmi-device", "tegradrm0");
 	}
 
 	if (device_is_a(self, "nouveau")) {



CVS commit: src/sys/arch/evbarm/tegra

2015-11-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 14 23:32:32 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
set vbus-gpio property on tegrausbphy, not ehci


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.29 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.30
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.29	Sat Nov 14 23:17:39 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat Nov 14 23:32:31 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.29 2015/11/14 23:17:39 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.30 2015/11/14 23:32:31 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.29 2015/11/14 23:17:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.30 2015/11/14 23:32:31 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -488,8 +488,7 @@ tegra_device_register(device_t self, voi
 		prop_dictionary_set_cstring(dict, "power-gpio", "EE2");
 	}
 
-	if (device_is_a(self, "ehci")
-	&& device_is_a(device_parent(self), "tegraio")) {
+	if (device_is_a(self, "tegrausbphy")) {
 		struct tegraio_attach_args * const tio = aux;
 		const struct tegra_locators * const loc = >tio_loc;
 
@@ -520,8 +519,7 @@ tegra_device_register(device_t self, voi
 		}
 	}
 
-	if (device_is_a(self, "ehci")
-	&& device_is_a(device_parent(self), "tegraio")) {
+	if (device_is_a(self, "tegrausbphy")) {
 		struct tegraio_attach_args * const tio = aux;
 		const struct tegra_locators * const loc = >tio_loc;
 



CVS commit: src/sys/arch/evbarm/tegra

2015-11-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 11 12:37:52 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
support RB_POWERDOWN using the AMS AS3722 PMIC when available


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.25 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.26
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.25	Mon Nov  9 23:05:58 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Wed Nov 11 12:37:52 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.25 2015/11/09 23:05:58 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.26 2015/11/11 12:37:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.25 2015/11/09 23:05:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.26 2015/11/11 12:37:52 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_machde
 #include "ukbd.h"
 #include "genfb.h"
 #include "ether.h"
+#include "as3722pmic.h"
 
 #include 
 #include 
@@ -89,6 +90,10 @@ __KERNEL_RCSID(0, "$NetBSD: tegra_machde
 #include 
 #include 
 
+#if NAS3722PMIC > 0
+#include 
+#endif
+
 #ifndef TEGRA_MAX_BOOT_STRING
 #define TEGRA_MAX_BOOT_STRING 1024
 #endif
@@ -104,6 +109,7 @@ extern char KERNEL_BASE_phys[];
 #define KERNEL_BASE_PHYS ((paddr_t)KERNEL_BASE_phys)
 
 static void tegra_device_register(device_t, void *);
+static void tegra_powerdown(void);
 
 bs_protos(bs_notimpl);
 
@@ -253,6 +259,7 @@ initarm(void *arg)
 #endif
 
 	cpu_reset_address = tegra_pmc_reset;
+	cpu_powerdown_address = tegra_powerdown;
 
 	/* Talk to the user */
 	DPRINTF("\nNetBSD/evbarm (tegra) booting ...\n");
@@ -527,3 +534,18 @@ tegra_device_register(device_t self, voi
 	}
 #endif
 }
+
+static void
+tegra_powerdown(void)
+{
+#if NAS3722PMIC > 0
+	device_t pmic = device_find_by_driver_unit("as3722pmic", 0);
+	if (pmic != NULL) {
+		if (as3722_poweroff(pmic) != 0) {
+			printf("WARNING: AS3722 poweroff failed\n");
+			return;
+		}
+		delay(100);
+	}
+#endif
+}



CVS commit: src/sys/arch/evbarm/tegra

2015-10-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 22 23:29:01 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
fix string copy for bootconf args


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.23 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.24
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.23	Wed Oct 21 20:02:13 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Thu Oct 22 23:29:01 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.23 2015/10/21 20:02:13 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.24 2015/10/22 23:29:01 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.23 2015/10/21 20:02:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.24 2015/10/22 23:29:01 jmcneill Exp $");
 
 #include "opt_tegra.h"
 #include "opt_machdep.h"
@@ -390,7 +390,7 @@ tegra_bootconf_strdup(const char *key)
 	if (ret == NULL)
 		return NULL;
 
-	strncpy(ret, s, i + 1);
+	strlcpy(ret, s, i + 1);
 	return ret;
 }
 



CVS commit: src/sys/arch/evbarm/tegra

2015-05-31 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun May 31 22:15:52 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: platform.h

Log Message:
Increase kernel VA space for kernels that don't use direct mapped memory.
(512MB - 1.25GB)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/tegra/platform.h

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/evbarm/tegra/platform.h
diff -u src/sys/arch/evbarm/tegra/platform.h:1.1 src/sys/arch/evbarm/tegra/platform.h:1.2
--- src/sys/arch/evbarm/tegra/platform.h:1.1	Sun Mar 29 10:41:59 2015
+++ src/sys/arch/evbarm/tegra/platform.h	Sun May 31 22:15:52 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: platform.h,v 1.1 2015/03/29 10:41:59 jmcneill Exp $ */
+/* $NetBSD: platform.h,v 1.2 2015/05/31 22:15:52 matt Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -31,8 +31,13 @@
 
 #include arm/nvidia/tegra_reg.h
 
+#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
 #define KERNEL_VM_BASE		0xc000
 #define KERNEL_VM_SIZE		0x2000 /* 0x2000 = 512MB */
+#else
+#define KERNEL_VM_BASE		0x9000
+#define KERNEL_VM_SIZE		0x5000 /* 0x5000 = 1.25GB */
+#endif
 
 #define CONSADDR_VA (CONSADDR - TEGRA_APB_BASE + TEGRA_APB_VBASE)
 



CVS commit: src/sys/arch/evbarm/tegra

2015-05-30 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sat May 30 23:17:37 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
Use the first1g for kernel memory, not the 2nd one.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.16 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.17
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.16	Mon May 18 19:32:48 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat May 30 23:17:37 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.16 2015/05/18 19:32:48 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.17 2015/05/30 23:17:37 matt Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.16 2015/05/18 19:32:48 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.17 2015/05/30 23:17:37 matt Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -143,7 +143,7 @@ static const struct pmap_devmap devmap[]
 #undef	_S
 
 #ifdef PMAP_NEED_ALLOC_POOLPAGE
-static struct boot_physmem bp_highgig = {
+static struct boot_physmem bp_lowgig = {
 	.bp_start = TEGRA_EXTMEM_BASE / NBPG,
 	.bp_pages = (KERNEL_VM_BASE - KERNEL_BASE) / NBPG,
 	.bp_freelist = VM_FREELIST_ISADMA,
@@ -311,11 +311,10 @@ initarm(void *arg)
 	evbarm_device_register = tegra_device_register;
 
 #ifdef PMAP_NEED_ALLOC_POOLPAGE
-	if (atop(ram_size)  bp_highgig.bp_pages) {
-		bp_highgig.bp_start += atop(ram_size) - bp_highgig.bp_pages;
-		arm_poolpage_vmfreelist = bp_highgig.bp_freelist;
+	if (atop(ram_size)  bp_lowgig.bp_pages) {
+		arm_poolpage_vmfreelist = bp_lowgig.bp_freelist;
 		return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE,
-		bp_highgig, 1);
+		bp_lowgig, 1);
 	}
 #endif
 



CVS commit: src/sys/arch/evbarm/tegra

2015-05-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed May 13 11:07:02 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
initialize cpufreq subsystem


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.13 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.14
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.13	Tue May 12 10:37:20 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Wed May 13 11:07:02 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.13 2015/05/12 10:37:20 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.14 2015/05/13 11:07:02 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.13 2015/05/12 10:37:20 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.14 2015/05/13 11:07:02 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -373,6 +373,10 @@ tegra_device_register(device_t self, voi
 		return;
 	}
 
+	if (device_is_a(self, cpu)  device_unit(self) == 0) {
+		tegra_cpuinit();
+	}
+
 #ifdef BOARD_JETSONTK1
 	if (device_is_a(self, sdhc)
 	 device_is_a(device_parent(self), tegraio)) {



CVS commit: src/sys/arch/evbarm/tegra

2015-05-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed May 13 11:21:38 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_start.S

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/evbarm/tegra/tegra_start.S

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/evbarm/tegra/tegra_start.S
diff -u src/sys/arch/evbarm/tegra/tegra_start.S:1.5 src/sys/arch/evbarm/tegra/tegra_start.S:1.6
--- src/sys/arch/evbarm/tegra/tegra_start.S:1.5	Wed May 13 11:21:04 2015
+++ src/sys/arch/evbarm/tegra/tegra_start.S	Wed May 13 11:21:38 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.5 2015/05/13 11:21:04 skrll Exp $ */
+/* $NetBSD: tegra_start.S,v 1.6 2015/05/13 11:21:38 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -41,9 +41,9 @@
 #include assym.h
 
 #include arm/nvidia/tegra_reg.h
-#include evbarm/tegra/platform.h  
+#include evbarm/tegra/platform.h
 
-RCSID($NetBSD: tegra_start.S,v 1.5 2015/05/13 11:21:04 skrll Exp $)
+RCSID($NetBSD: tegra_start.S,v 1.6 2015/05/13 11:21:38 skrll Exp $)
 
 #if defined(VERBOSE_INIT_ARM)
 #define	XPUTC(n)	mov r0, n; bl xputc



CVS commit: src/sys/arch/evbarm/tegra

2015-05-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed May 13 11:21:04 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_start.S

Log Message:
One comment is enough for anybody


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/tegra/tegra_start.S

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/evbarm/tegra/tegra_start.S
diff -u src/sys/arch/evbarm/tegra/tegra_start.S:1.4 src/sys/arch/evbarm/tegra/tegra_start.S:1.5
--- src/sys/arch/evbarm/tegra/tegra_start.S:1.4	Tue May 12 10:37:20 2015
+++ src/sys/arch/evbarm/tegra/tegra_start.S	Wed May 13 11:21:04 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.4 2015/05/12 10:37:20 jmcneill Exp $ */
+/* $NetBSD: tegra_start.S,v 1.5 2015/05/13 11:21:04 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include arm/nvidia/tegra_reg.h
 #include evbarm/tegra/platform.h  
 
-RCSID($NetBSD: tegra_start.S,v 1.4 2015/05/12 10:37:20 jmcneill Exp $)
+RCSID($NetBSD: tegra_start.S,v 1.5 2015/05/13 11:21:04 skrll Exp $)
 
 #if defined(VERBOSE_INIT_ARM)
 #define	XPUTC(n)	mov r0, n; bl xputc
@@ -117,10 +117,6 @@ _C_LABEL(tegra_start):
 	bne	2b
 1:
 
-/*
- * Turn on the SMP bit
- */
-
 	/*
 	 * Turn on the SMP bit
 	 */



CVS commit: src/sys/arch/evbarm/tegra

2015-05-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu May 14 00:02:00 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
5V/12V power to molex connector on Jetson TK1 is controlled by GPIO EE2


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.14 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.15
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.14	Wed May 13 11:07:02 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Thu May 14 00:02:00 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.14 2015/05/13 11:07:02 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.15 2015/05/14 00:02:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.14 2015/05/13 11:07:02 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.15 2015/05/14 00:02:00 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -390,6 +390,11 @@ tegra_device_register(device_t self, voi
 		}
 	}
 
+	if (device_is_a(self, ahcisata)
+	 device_is_a(device_parent(self), tegraio)) {
+		prop_dictionary_set_cstring(dict, power-gpio, EE2);
+	}
+
 	if (device_is_a(self, ehci)
 	 device_is_a(device_parent(self), tegraio)) {
 		struct tegraio_attach_args * const tio = aux;



CVS commit: src/sys/arch/evbarm/tegra

2015-05-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May 12 10:37:20 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c tegra_start.S

Log Message:
copy bootargs from uboot before we turn on the MMU, for the benefit of kernels 
without __HAVE_MM_MD_DIRECT_MAPPED_PHYS


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/evbarm/tegra/tegra_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbarm/tegra/tegra_start.S

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.12 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.13
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.12	Sat May  9 18:57:30 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Tue May 12 10:37:20 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.12 2015/05/09 18:57:30 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.13 2015/05/12 10:37:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.12 2015/05/09 18:57:30 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.13 2015/05/12 10:37:20 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -93,7 +93,7 @@ __KERNEL_RCSID(0, $NetBSD: tegra_machde
 #endif
 
 BootConfig bootconfig;
-static char bootargs[TEGRA_MAX_BOOT_STRING];
+char bootargs[TEGRA_MAX_BOOT_STRING] = ;
 char *boot_args = NULL;
 u_int uboot_args[4] = { 0 };	/* filled in by tegra_start.S (not in bss) */
 
@@ -303,14 +303,6 @@ initarm(void *arg)
 	arm32_kernel_vm_init(KERNEL_VM_BASE, ARM_VECTORS_HIGH, 0, devmap,
 	mapallmem_p);
 
-	if (mapallmem_p) {
-		if (uboot_args[3]  ram_size) {
-			const char * const args = (const char *)
-			(uboot_args[3] + KERNEL_BASE_VOFFSET);
-			strlcpy(bootargs, args, sizeof(bootargs));
-		}
-	}
-
 	DPRINTF(bootargs: %s\n, bootargs);
 
 	boot_args = bootargs;

Index: src/sys/arch/evbarm/tegra/tegra_start.S
diff -u src/sys/arch/evbarm/tegra/tegra_start.S:1.3 src/sys/arch/evbarm/tegra/tegra_start.S:1.4
--- src/sys/arch/evbarm/tegra/tegra_start.S:1.3	Sun Apr 26 22:04:28 2015
+++ src/sys/arch/evbarm/tegra/tegra_start.S	Tue May 12 10:37:20 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.3 2015/04/26 22:04:28 jmcneill Exp $ */
+/* $NetBSD: tegra_start.S,v 1.4 2015/05/12 10:37:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -43,7 +43,7 @@
 #include arm/nvidia/tegra_reg.h
 #include evbarm/tegra/platform.h  
 
-RCSID($NetBSD: tegra_start.S,v 1.3 2015/04/26 22:04:28 jmcneill Exp $)
+RCSID($NetBSD: tegra_start.S,v 1.4 2015/05/12 10:37:20 jmcneill Exp $)
 
 #if defined(VERBOSE_INIT_ARM)
 #define	XPUTC(n)	mov r0, n; bl xputc
@@ -102,6 +102,26 @@ _C_LABEL(tegra_start):
 	stmia	r4, {r0-r3}		// Save the arguments
 
 	/*
+	 * Copy the value of the bootargs environment variable from r3.
+	 */
+	movw	r4, #:lower16:bootargs
+	movt	r4, #:upper16:bootargs
+	sub	r4, r4, #KERNEL_BASE_VOFFSET
+
+	cmp	r3, #0
+	beq	1f
+2:
+	ldrb	r0, [r3], #1
+	strb	r0, [r4], #1
+	teq	r0, #0
+	bne	2b
+1:
+
+/*
+ * Turn on the SMP bit
+ */
+
+	/*
 	 * Turn on the SMP bit
 	 */
 	bl	cortex_init



CVS commit: src/sys/arch/evbarm/tegra

2015-05-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat May  9 12:08:30 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
for Jetson TK1, GPIO N5 controls vbus vdd for USB2


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.10 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.11
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.10	Sun May  3 17:24:45 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat May  9 12:08:30 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.10 2015/05/03 17:24:45 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.11 2015/05/09 12:08:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.10 2015/05/03 17:24:45 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.11 2015/05/09 12:08:30 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -393,5 +393,15 @@ tegra_device_register(device_t self, voi
 			prop_dictionary_set_cstring(dict, wp-gpio, Q4);
 		}
 	}
+
+	if (device_is_a(self, ehci)
+	 device_is_a(device_parent(self), tegraio)) {
+		struct tegraio_attach_args * const tio = aux;
+		const struct tegra_locators * const loc = tio-tio_loc;
+
+		if (loc-loc_port == 2) {
+			prop_dictionary_set_cstring(dict, vbus-gpio, N5);
+		}
+	}
 #endif
 }



CVS commit: src/sys/arch/evbarm/tegra

2015-05-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat May  9 18:57:30 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
Jetson TK1: USB1 VBUS power is controlled by GPIO N4


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.11 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.12
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.11	Sat May  9 12:08:30 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sat May  9 18:57:30 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.11 2015/05/09 12:08:30 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.12 2015/05/09 18:57:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.11 2015/05/09 12:08:30 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.12 2015/05/09 18:57:30 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -399,7 +399,9 @@ tegra_device_register(device_t self, voi
 		struct tegraio_attach_args * const tio = aux;
 		const struct tegra_locators * const loc = tio-tio_loc;
 
-		if (loc-loc_port == 2) {
+		if (loc-loc_port == 0) {
+			prop_dictionary_set_cstring(dict, vbus-gpio, N4);
+		} else if (loc-loc_port == 2) {
 			prop_dictionary_set_cstring(dict, vbus-gpio, N5);
 		}
 	}



CVS commit: src/sys/arch/evbarm/tegra

2015-04-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Apr 27 00:33:46 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
remove unnecessary debug print


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.6 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.7
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.6	Sun Apr 26 22:04:28 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Mon Apr 27 00:33:46 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.6 2015/04/26 22:04:28 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.7 2015/04/27 00:33:46 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.6 2015/04/26 22:04:28 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.7 2015/04/27 00:33:46 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -222,10 +222,6 @@ initarm(void *arg)
 	psize_t ram_size = 0;
 	DPRINT(initarm:);
 
-	DPRINT( sctlr0x);
-	DPRINTN(armreg_sctlr_read(), 16);
-	DPRINT();
-
 	DPRINT( mpstart0x);
 	DPRINTN((uint32_t)cortex_mpstart, 16);
 	DPRINT();



CVS commit: src/sys/arch/evbarm/tegra

2015-04-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Apr 26 17:40:59 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
handle PMAP_NEED_ALLOC_POOLPAGE


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.4 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.5
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.4	Sun Apr 26 16:24:01 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sun Apr 26 17:40:59 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.4 2015/04/26 16:24:01 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.5 2015/04/26 17:40:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.4 2015/04/26 16:24:01 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.5 2015/04/26 17:40:59 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -135,6 +135,15 @@ static const struct pmap_devmap devmap[]
 #undef	_A
 #undef	_S
 
+#ifdef PMAP_NEED_ALLOC_POOLPAGE
+static struct boot_physmem bp_highgig = {
+	.bp_start = TEGRA_EXTMEM_BASE / NBPG,
+	.bp_pages = (KERNEL_VM_BASE - KERNEL_BASE) / NBPG,
+	.bp_freelist = VM_FREELIST_ISADMA,
+	.bp_flags = 0
+};
+#endif
+
 #ifdef VERBOSE_INIT_ARM
 static void
 tegra_putchar(char c)
@@ -245,6 +254,8 @@ initarm(void *arg)
 	ram_size = tegra_mc_memsize();
 
 #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
+	const bool mapallmem_p = true;
+#ifndef PMAP_NEED_ALLOC_POOLPAGE
 	if (ram_size  KERNEL_VM_BASE - KERNEL_BASE) {
 		printf(%s: dropping RAM size from %luMB to %uMB\n,
 		__func__, (unsigned long) (ram_size  20), 
@@ -252,6 +263,9 @@ initarm(void *arg)
 		ram_size = KERNEL_VM_BASE - KERNEL_BASE;
 	}
 #endif
+#else
+	const bool mapallmem_p = false;
+#endif
 
 	/*
 	 * If MEMSIZE specified less than what we really have, limit ourselves
@@ -270,12 +284,6 @@ initarm(void *arg)
 	bootconfig.dram[0].address = TEGRA_EXTMEM_BASE; /* DDR PHY addr */
 	bootconfig.dram[0].pages = ram_size / PAGE_SIZE;
 
-#ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS
-	const bool mapallmem_p = true;
-	KASSERT(ram_size = KERNEL_VM_BASE - KERNEL_BASE);
-#else
-	const bool mapallmem_p = false;
-#endif
 	KASSERT((armreg_pfr1_read()  ARM_PFR1_SEC_MASK) != 0);
 
 	arm32_bootmem_init(bootconfig.dram[0].address, ram_size,
@@ -298,6 +306,15 @@ initarm(void *arg)
 
 	evbarm_device_register = tegra_device_register;
 
+#ifdef PMAP_NEED_ALLOC_POOLPAGE
+	if (atop(ram_size)  bp_highgig.bp_pages) {
+		bp_highgig.bp_start += atop(ram_size) - bp_highgig.bp_pages;
+		arm_poolpage_vmfreelist = bp_highgig.bp_freelist;
+		return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE,
+		bp_highgig, 1);
+	}
+#endif
+
 	return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
 
 }



CVS commit: src/sys/arch/evbarm/tegra

2015-03-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Mar 29 10:55:11 UTC 2015

Modified Files:
src/sys/arch/evbarm/tegra: tegra_machdep.c

Log Message:
no need to set arm_cpu_max here, it is done in soc specific code


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/tegra/tegra_machdep.c

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/evbarm/tegra/tegra_machdep.c
diff -u src/sys/arch/evbarm/tegra/tegra_machdep.c:1.1 src/sys/arch/evbarm/tegra/tegra_machdep.c:1.2
--- src/sys/arch/evbarm/tegra/tegra_machdep.c:1.1	Sun Mar 29 10:41:59 2015
+++ src/sys/arch/evbarm/tegra/tegra_machdep.c	Sun Mar 29 10:55:11 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.1 2015/03/29 10:41:59 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.2 2015/03/29 10:55:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill jmcne...@invisible.ca
@@ -27,7 +27,7 @@
  */
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.1 2015/03/29 10:41:59 jmcneill Exp $);
+__KERNEL_RCSID(0, $NetBSD: tegra_machdep.c,v 1.2 2015/03/29 10:55:11 jmcneill Exp $);
 
 #include opt_tegra.h
 #include opt_machdep.h
@@ -186,11 +186,6 @@ initarm(void *arg)
 	DPRINT( bootstrap);
 	tegra_bootstrap();
 
-#ifdef MULTIPROCESSOR
-	DPRINT( ncpu);
-	arm_cpu_max = 1 + __SHIFTOUT(armreg_l2ctrl_read(), L2CTRL_NUMCPU);
-#endif
-
 	/* Heads up ... Setup the CPU / MMU / TLB functions. */
 	DPRINT( cpufunc);
 	if (set_cpufuncs())