Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbarm Setup the console serial port using the /cho...
details: https://anonhg.NetBSD.org/src/rev/7c5c66291101
branches: trunk
changeset: 353154:7c5c66291101
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Apr 21 23:36:57 2017 +0000
description:
Setup the console serial port using the /chosen/stdout-path property
instead of the compile-time CONSADDR setting.
diffstat:
sys/arch/evbarm/conf/TEGRA | 8 ++-
sys/arch/evbarm/tegra/tegra_machdep.c | 83 +++++++++++++++++++++-------------
sys/arch/evbarm/tegra/tegra_start.S | 6 +-
3 files changed, 58 insertions(+), 39 deletions(-)
diffs (190 lines):
diff -r a994d6956b02 -r 7c5c66291101 sys/arch/evbarm/conf/TEGRA
--- a/sys/arch/evbarm/conf/TEGRA Fri Apr 21 23:35:29 2017 +0000
+++ b/sys/arch/evbarm/conf/TEGRA Fri Apr 21 23:36:57 2017 +0000
@@ -1,5 +1,5 @@
#
-# $NetBSD: TEGRA,v 1.14 2017/04/16 12:29:40 jmcneill Exp $
+# $NetBSD: TEGRA,v 1.15 2017/04/21 23:36:57 jmcneill Exp $
#
# NVIDIA Tegra K1 (T124)
#
@@ -18,7 +18,10 @@
#options LOCKDEBUG
#options PMAP_DEBUG # Enable pmap_debug_level code
#options IPKDB # remote kernel debugging
-#options VERBOSE_INIT_ARM # verbose bootstraping messages
+#options VERBOSE_INIT_ARM # verbose bootstrapping messages
+# CONSADDR is required for early init messages from VERBOSE_INIT_ARM.
+#options CONSADDR=0x70006300, CONSPEED=115200
+
makeoptions DEBUG="-g" # compile full symbol table
makeoptions COPY_SYMTAB=1
@@ -87,7 +90,6 @@
# UART
com* at fdt? # UART
-options CONSADDR=0x70006300, CONSPEED=115200
# I2C
tegrai2c* at fdt? # I2C
diff -r a994d6956b02 -r 7c5c66291101 sys/arch/evbarm/tegra/tegra_machdep.c
--- a/sys/arch/evbarm/tegra/tegra_machdep.c Fri Apr 21 23:35:29 2017 +0000
+++ b/sys/arch/evbarm/tegra/tegra_machdep.c Fri Apr 21 23:36:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.39 2017/04/21 21:13:04 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.40 2017/04/21 23:36:58 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.39 2017/04/21 21:13:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_machdep.c,v 1.40 2017/04/21 23:36:58 jmcneill Exp $");
#include "opt_tegra.h"
#include "opt_machdep.h"
@@ -167,20 +167,14 @@
static void
tegra_putchar(char c)
{
+#ifdef CONSADDR
volatile uint32_t *uartaddr = (volatile uint32_t *)CONSADDR_VA;
- int timo = 150000;
- while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) {
- if (--timo == 0)
- break;
- }
+ while ((uartaddr[com_lsr] & LSR_TXRDY) == 0)
+ ;
uartaddr[com_data] = c;
-
- while ((uartaddr[com_lsr] & LSR_TXRDY) == 0) {
- if (--timo == 0)
- break;
- }
+#endif
}
static void
tegra_putstr(const char *s)
@@ -251,6 +245,21 @@
if (set_cpufuncs())
panic("cpu not recognized!");
+ /* Load FDT */
+ const uint8_t *fdt_addr_r = (const uint8_t *)uboot_args[2];
+ int error = fdt_check_header(fdt_addr_r);
+ if (error == 0) {
+ error = fdt_move(fdt_addr_r, fdt_data, sizeof(fdt_data));
+ if (error != 0) {
+ DPRINT(" (fdt_move failed!)\n");
+ panic("fdt_move failed: %s", fdt_strerror(error));
+ }
+ fdtbus_set_data(fdt_data);
+ } else {
+ DPRINT(" (fdt_check_header failed!)\n");
+ panic("fdt_check_header failed: %s", fdt_strerror(error));
+ }
+
DPRINT(" consinit");
consinit();
@@ -272,18 +281,6 @@
parse_mi_bootargs(mi_bootargs);
#endif
- const uint8_t *fdt_addr_r = (const uint8_t *)uboot_args[2];
- int error = fdt_check_header(fdt_addr_r);
- if (error == 0) {
- error = fdt_move(fdt_addr_r, fdt_data, sizeof(fdt_data));
- if (error != 0) {
- panic("fdt_move failed: %s", fdt_strerror(error));
- }
- fdtbus_set_data(fdt_data);
- } else {
- panic("fdt_check_header failed: %s", fdt_strerror(error));
- }
-
const u_int chip_id = tegra_chip_id();
switch (chip_id) {
#ifdef SOC_TEGRA124
@@ -383,12 +380,6 @@
}
#if NCOM > 0
-#ifndef CONSADDR
-#error Specify the address of the console UART with the CONSADDR option.
-#endif
-#ifndef CONSPEED
-#define CONSPEED 115200
-#endif
#ifndef CONMODE
#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#endif
@@ -404,12 +395,38 @@
consinit_called = true;
#if NCOM > 0
+ bus_addr_t addr;
+ int speed;
+
+#ifdef CONSADDR
+ addr = CONSADDR;
+#else
+ const char *stdout_path = fdtbus_get_stdout_path();
+ if (stdout_path == NULL) {
+ DPRINT(" (can't find stdout-path!)\n");
+ panic("Cannot find console device");
+ }
+ DPRINT(" ");
+ DPRINT(stdout_path);
+ fdtbus_get_reg(fdtbus_get_stdout_phandle(), 0, &addr, NULL);
+#endif
+ DPRINT(" 0x");
+ DPRINTN((uint32_t)addr, 16);
+
+#ifdef CONSPEED
+ speed = CONSPEED;
+#else
+ speed = fdtbus_get_stdout_speed();
+ if (speed < 0)
+ speed = 115200; /* default */
+#endif
+ DPRINT(" ");
+ DPRINTN((uint32_t)speed, 10);
+
const bus_space_tag_t bst = &armv7_generic_a4x_bs_tag;
const u_int freq = 408000000; /* 408MHz PLLP_OUT0 */
- if (comcnattach(bst, CONSADDR, CONSPEED, freq,
- COM_TYPE_TEGRA, CONMODE)) {
+ if (comcnattach(bst, addr, speed, freq, COM_TYPE_TEGRA, CONMODE))
panic("Serial console cannot be initialized.");
- }
#else
#error only COM console is supported
#endif
diff -r a994d6956b02 -r 7c5c66291101 sys/arch/evbarm/tegra/tegra_start.S
--- a/sys/arch/evbarm/tegra/tegra_start.S Fri Apr 21 23:35:29 2017 +0000
+++ b/sys/arch/evbarm/tegra/tegra_start.S Fri Apr 21 23:36:57 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_start.S,v 1.9 2015/12/13 22:55:05 jmcneill Exp $ */
+/* $NetBSD: tegra_start.S,v 1.10 2017/04/21 23:36:58 jmcneill Exp $ */
/*-
* Copyright (c) 2014, 2015 The NetBSD Foundation, Inc.
@@ -43,9 +43,9 @@
#include <arm/nvidia/tegra_reg.h>
#include <evbarm/tegra/platform.h>
-RCSID("$NetBSD: tegra_start.S,v 1.9 2015/12/13 22:55:05 jmcneill Exp $")
+RCSID("$NetBSD: tegra_start.S,v 1.10 2017/04/21 23:36:58 jmcneill Exp $")
-#if defined(VERBOSE_INIT_ARM)
+#if defined(VERBOSE_INIT_ARM) && defined(CONSADDR)
#define XPUTC(n) mov r0, n; bl xputc
#if KERNEL_BASE_VOFFSET == 0
#define XPUTC2(n) mov r0, n; bl xputc
Home |
Main Index |
Thread Index |
Old Index