Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move console initialization out of platform code into th...
details: https://anonhg.NetBSD.org/src/rev/a3325d2cfc7b
branches: trunk
changeset: 353959:a3325d2cfc7b
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Mon May 29 23:13:03 2017 +0000
description:
Move console initialization out of platform code into the console drivers
themselves.
diffstat:
sys/arch/arm/fdt/armv7_fdt.c | 22 +++------
sys/arch/arm/fdt/armv7_fdtvar.h | 20 ++++++---
sys/arch/arm/nvidia/tegra_com.c | 56 ++++++++++++++++++++++---
sys/arch/arm/nvidia/tegra_platform.c | 61 +++++++---------------------
sys/arch/evbarm/tegra/tegra_machdep.c | 18 ++++++-
sys/dev/fdt/fdt_subr.c | 74 ++++++++++++++++++++++++++++++++++-
sys/dev/fdt/fdtvar.h | 26 +++++++++++-
7 files changed, 195 insertions(+), 82 deletions(-)
diffs (truncated from 495 to 300 lines):
diff -r 023f137fc1da -r a3325d2cfc7b sys/arch/arm/fdt/armv7_fdt.c
--- a/sys/arch/arm/fdt/armv7_fdt.c Mon May 29 22:54:07 2017 +0000
+++ b/sys/arch/arm/fdt/armv7_fdt.c Mon May 29 23:13:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: armv7_fdt.c,v 1.2 2017/05/28 23:39:30 jmcneill Exp $ */
+/* $NetBSD: armv7_fdt.c,v 1.3 2017/05/29 23:13:03 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: armv7_fdt.c,v 1.2 2017/05/28 23:39:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: armv7_fdt.c,v 1.3 2017/05/29 23:13:03 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -47,8 +47,6 @@
CFATTACH_DECL_NEW(armv7_fdt, 0,
armv7_fdt_match, armv7_fdt_attach, NULL, NULL);
-static bool armv7_fdt_found = false;
-
extern struct bus_space armv7_generic_bs_tag;
extern struct bus_space armv7_generic_a4x_bs_tag;
extern struct arm32_bus_dma_tag armv7_generic_dma_tag;
@@ -59,26 +57,22 @@
int
armv7_fdt_match(device_t parent, cfdata_t cf, void *aux)
{
- if (armv7_fdt_found)
- return 0;
return 1;
}
void
armv7_fdt_attach(device_t parent, device_t self, void *aux)
{
- armv7_fdt_found = true;
+ const struct armv7_platform *plat = armv7_fdt_platform();
+ struct fdt_attach_args faa;
aprint_naive("\n");
aprint_normal("\n");
- struct fdt_attach_args faa = {
- .faa_name = "",
- .faa_bst = &armv7_generic_bs_tag,
- .faa_a4x_bst = &armv7_generic_a4x_bs_tag,
- .faa_dmat = &armv7_generic_dma_tag,
- .faa_phandle = OF_peer(0),
- };
+ plat->init_attach_args(&faa);
+ faa.faa_name = "";
+ faa.faa_phandle = OF_peer(0);
+
config_found(self, &faa, NULL);
}
diff -r 023f137fc1da -r a3325d2cfc7b sys/arch/arm/fdt/armv7_fdtvar.h
--- a/sys/arch/arm/fdt/armv7_fdtvar.h Mon May 29 22:54:07 2017 +0000
+++ b/sys/arch/arm/fdt/armv7_fdtvar.h Mon May 29 23:13:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: armv7_fdtvar.h,v 1.1 2017/05/28 23:39:30 jmcneill Exp $ */
+/* $NetBSD: armv7_fdtvar.h,v 1.2 2017/05/29 23:13:03 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,13 +29,19 @@
#ifndef _ARM_ARMV7_FDTVAR_H
#define _ARM_ARMV7_FDTVAR_H
+/*
+ * Platform-specific data
+ */
+
+struct fdt_attach_args;
+
struct armv7_platform {
- const struct pmap_devmap * (*devmap)(void);
- void (*bootstrap)(void);
- void (*early_putchar)(char);
- void (*device_register)(device_t, void *);
- void (*reset)(void);
- void (*consinit)(void);
+ const struct pmap_devmap * (*devmap)(void);
+ void (*bootstrap)(void);
+ void (*init_attach_args)(struct fdt_attach_args *);
+ void (*early_putchar)(char);
+ void (*device_register)(device_t, void *);
+ void (*reset)(void);
};
struct armv7_platform_info {
diff -r 023f137fc1da -r a3325d2cfc7b sys/arch/arm/nvidia/tegra_com.c
--- a/sys/arch/arm/nvidia/tegra_com.c Mon May 29 22:54:07 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_com.c Mon May 29 23:13:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_com.c,v 1.6 2017/05/25 23:42:44 jmcneill Exp $ */
+/* $NetBSD: tegra_com.c,v 1.7 2017/05/29 23:13:03 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.6 2017/05/25 23:42:44 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.7 2017/05/29 23:13:03 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -48,9 +48,18 @@
#include <dev/fdt/fdtvar.h>
+#define PLLP_OUT0_FREQ 408000000
+
static int tegra_com_match(device_t, cfdata_t, void *);
static void tegra_com_attach(device_t, device_t, void *);
+static const char * const compatible[] = {
+ "nvidia,tegra210-uart",
+ "nvidia,tegra124-uart",
+ "nvidia,tegra20-uart",
+ NULL
+};
+
struct tegra_com_softc {
struct com_softc tsc_sc;
void *tsc_ih;
@@ -65,12 +74,6 @@
static int
tegra_com_match(device_t parent, cfdata_t cf, void *aux)
{
- const char * const compatible[] = {
- "nvidia,tegra210-uart",
- "nvidia,tegra124-uart",
- "nvidia,tegra20-uart",
- NULL
- };
struct fdt_attach_args * const faa = aux;
return of_match_compatible(faa->faa_phandle, compatible);
@@ -147,3 +150,40 @@
}
aprint_normal_dev(self, "interrupting on %s\n", intrstr);
}
+
+/*
+ * Console support
+ */
+
+static int
+tegra_com_console_match(int phandle)
+{
+ return of_match_compatible(phandle, compatible);
+}
+
+static void
+tegra_com_console_consinit(struct fdt_attach_args *faa)
+{
+ const u_int freq = PLLP_OUT0_FREQ;
+ const int phandle = faa->faa_phandle;
+ bus_space_tag_t bst = faa->faa_a4x_bst;
+ bus_addr_t addr;
+ tcflag_t flags;
+ int speed;
+
+ fdtbus_get_reg(phandle, 0, &addr, NULL);
+ speed = fdtbus_get_stdout_speed();
+ if (speed < 0)
+ speed = 115200; /* default */
+ flags = fdtbus_get_stdout_flags();
+
+ if (comcnattach(bst, addr, speed, freq, COM_TYPE_TEGRA, flags))
+ panic("Cannot initialize tegra com console");
+}
+
+static const struct fdt_console tegra_com_console = {
+ .match = tegra_com_console_match,
+ .consinit = tegra_com_console_consinit,
+};
+
+FDT_CONSOLE(tegra_com, &tegra_com_console);
diff -r 023f137fc1da -r a3325d2cfc7b sys/arch/arm/nvidia/tegra_platform.c
--- a/sys/arch/arm/nvidia/tegra_platform.c Mon May 29 22:54:07 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_platform.c Mon May 29 23:13:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_platform.c,v 1.1 2017/05/28 23:39:30 jmcneill Exp $ */
+/* $NetBSD: tegra_platform.c,v 1.2 2017/05/29 23:13:03 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -33,7 +33,7 @@
#include "ukbd.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.1 2017/05/28 23:39:30 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.2 2017/05/29 23:13:03 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -57,15 +57,6 @@
#include <dev/usb/ukbdvar.h>
#endif
-#if NCOM > 0
-#include <dev/ic/ns16550reg.h>
-#include <dev/ic/comreg.h>
-#include <dev/ic/comvar.h>
-#ifndef CONMODE
-#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
-#endif
-#endif
-
#define DEVMAP_ALIGN(a) ((a) & ~L1_S_OFFSET)
#define DEVMAP_SIZE(s) roundup2((s), L1_S_SIZE)
#define DEVMAP_ENTRY(va, pa, sz) \
@@ -107,6 +98,18 @@
}
static void
+tegra_platform_init_attach_args(struct fdt_attach_args *faa)
+{
+ extern struct bus_space armv7_generic_bs_tag;
+ extern struct bus_space armv7_generic_a4x_bs_tag;
+ extern struct arm32_bus_dma_tag armv7_generic_dma_tag;
+
+ faa->faa_bst = &armv7_generic_bs_tag;
+ faa->faa_a4x_bst = &armv7_generic_a4x_bs_tag;
+ faa->faa_dmat = &armv7_generic_dma_tag;
+}
+
+static void
tegra_platform_early_putchar(char c)
{
#ifdef CONSADDR
@@ -176,47 +179,13 @@
tegra_pmc_reset();
}
-static void
-tegra_platform_consinit(void)
-{
- static bool consinit_called = false;
-
- if (consinit_called)
- return;
- consinit_called = true;
-
-#if NCOM > 0
- bus_addr_t addr;
- int speed;
-
-#ifdef CONSADDR
- addr = CONSADDR;
-#else
- fdtbus_get_reg(fdtbus_get_stdout_phandle(), 0, &addr, NULL);
-#endif
-
-#ifdef CONSPEED
- speed = CONSPEED;
-#else
- speed = fdtbus_get_stdout_speed();
- if (speed < 0)
- speed = 115200; /* default */
-#endif
-
- const bus_space_tag_t bst = &armv7_generic_a4x_bs_tag;
- const u_int freq = 408000000; /* 408MHz PLLP_OUT0 */
- if (comcnattach(bst, addr, speed, freq, COM_TYPE_TEGRA, CONMODE))
- panic("Serial console cannot be initialized.");
-#endif
-}
-
static const struct armv7_platform tegra_platform = {
.devmap = tegra_platform_devmap,
.bootstrap = tegra_platform_bootstrap,
+ .init_attach_args = tegra_platform_init_attach_args,
.early_putchar = tegra_platform_early_putchar,
.device_register = tegra_platform_device_register,
.reset = tegra_platform_reset,
- .consinit = tegra_platform_consinit,
};
ARMV7_PLATFORM(tegra124, "nvidia,tegra124", &tegra_platform);
diff -r 023f137fc1da -r a3325d2cfc7b sys/arch/evbarm/tegra/tegra_machdep.c
--- a/sys/arch/evbarm/tegra/tegra_machdep.c Mon May 29 22:54:07 2017 +0000
+++ b/sys/arch/evbarm/tegra/tegra_machdep.c Mon May 29 23:13:03 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_machdep.c,v 1.46 2017/05/28 23:39:30 jmcneill Exp $ */
+/* $NetBSD: tegra_machdep.c,v 1.47 2017/05/29 23:13:03 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
Home |
Main Index |
Thread Index |
Old Index