Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Allow platform code to specify the UART frequency for co...



details:   https://anonhg.NetBSD.org/src/rev/e9693df90af7
branches:  trunk
changeset: 354049:e9693df90af7
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Jun 02 13:53:28 2017 +0000

description:
Allow platform code to specify the UART frequency for consinit

diffstat:

 sys/arch/arm/fdt/arm_fdtvar.h        |   3 ++-
 sys/arch/arm/nvidia/tegra_com.c      |  11 ++++-------
 sys/arch/arm/nvidia/tegra_platform.c |  13 +++++++++++--
 sys/arch/evbarm/fdt/fdt_machdep.c    |  10 +++++++---
 sys/dev/fdt/fdtvar.h                 |   4 ++--
 5 files changed, 26 insertions(+), 15 deletions(-)

diffs (168 lines):

diff -r 17ea7105fa8d -r e9693df90af7 sys/arch/arm/fdt/arm_fdtvar.h
--- a/sys/arch/arm/fdt/arm_fdtvar.h     Fri Jun 02 13:12:33 2017 +0000
+++ b/sys/arch/arm/fdt/arm_fdtvar.h     Fri Jun 02 13:53:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arm_fdtvar.h,v 1.4 2017/06/02 00:16:27 jmcneill Exp $ */
+/* $NetBSD: arm_fdtvar.h,v 1.5 2017/06/02 13:53:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -43,6 +43,7 @@
        void                    (*device_register)(device_t, void *);
        void                    (*reset)(void);
        void                    (*delay)(u_int);
+       u_int                   (*uart_freq)(void);
 };
 
 struct arm_platform_info {
diff -r 17ea7105fa8d -r e9693df90af7 sys/arch/arm/nvidia/tegra_com.c
--- a/sys/arch/arm/nvidia/tegra_com.c   Fri Jun 02 13:12:33 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_com.c   Fri Jun 02 13:53:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_com.c,v 1.7 2017/05/29 23:13:03 jmcneill Exp $ */
+/* $NetBSD: tegra_com.c,v 1.8 2017/06/02 13:53:29 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.7 2017/05/29 23:13:03 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.8 2017/06/02 13:53:29 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -48,8 +48,6 @@
 
 #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 *);
 
@@ -162,9 +160,8 @@
 }
 
 static void
-tegra_com_console_consinit(struct fdt_attach_args *faa)
+tegra_com_console_consinit(struct fdt_attach_args *faa, u_int uart_freq)
 {
-       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;
@@ -177,7 +174,7 @@
                speed = 115200; /* default */
        flags = fdtbus_get_stdout_flags();
 
-       if (comcnattach(bst, addr, speed, freq, COM_TYPE_TEGRA, flags))
+       if (comcnattach(bst, addr, speed, uart_freq, COM_TYPE_TEGRA, flags))
                panic("Cannot initialize tegra com console");
 }
 
diff -r 17ea7105fa8d -r e9693df90af7 sys/arch/arm/nvidia/tegra_platform.c
--- a/sys/arch/arm/nvidia/tegra_platform.c      Fri Jun 02 13:12:33 2017 +0000
+++ b/sys/arch/arm/nvidia/tegra_platform.c      Fri Jun 02 13:53:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_platform.c,v 1.5 2017/06/02 00:16:27 jmcneill Exp $ */
+/* $NetBSD: tegra_platform.c,v 1.6 2017/06/02 13:53:29 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.5 2017/06/02 00:16:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_platform.c,v 1.6 2017/06/02 13:53:29 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -60,6 +60,8 @@
 #include <dev/ic/ns16550reg.h>
 #include <dev/ic/comreg.h>
 
+#define        PLLP_OUT0_FREQ  408000000
+
 #define        DEVMAP_ALIGN(a) ((a) & ~L1_S_OFFSET)
 #define        DEVMAP_SIZE(s)  roundup2((s), L1_S_SIZE)
 #define        DEVMAP_ENTRY(va, pa, sz)                        \
@@ -188,6 +190,12 @@
        tegra_timer_delay(us);
 }
 
+static u_int
+tegra_platform_uart_freq(void)
+{
+       return PLLP_OUT0_FREQ;
+}
+
 static const struct arm_platform tegra_platform = {
        .devmap = tegra_platform_devmap,
        .bootstrap = tegra_platform_bootstrap,
@@ -196,6 +204,7 @@
        .device_register = tegra_platform_device_register,
        .reset = tegra_platform_reset,
        .delay = tegra_platform_delay,
+       .uart_freq = tegra_platform_uart_freq,
 };
 
 ARM_PLATFORM(tegra124, "nvidia,tegra124", &tegra_platform);
diff -r 17ea7105fa8d -r e9693df90af7 sys/arch/evbarm/fdt/fdt_machdep.c
--- a/sys/arch/evbarm/fdt/fdt_machdep.c Fri Jun 02 13:12:33 2017 +0000
+++ b/sys/arch/evbarm/fdt/fdt_machdep.c Fri Jun 02 13:53:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_machdep.c,v 1.3 2017/06/02 00:16:28 jmcneill Exp $ */
+/* $NetBSD: fdt_machdep.c,v 1.4 2017/06/02 13:53:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.3 2017/06/02 00:16:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_machdep.c,v 1.4 2017/06/02 13:53:29 jmcneill Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -272,6 +272,7 @@
        const struct arm_platform *plat = arm_fdt_platform();
        const struct fdt_console *cons = fdtbus_get_console();
        struct fdt_attach_args faa;
+       u_int uart_freq = 0;
 
        if (initialized || cons == NULL)
                return;
@@ -279,7 +280,10 @@
        plat->init_attach_args(&faa);
        faa.faa_phandle = fdtbus_get_stdout_phandle();
 
-       cons->consinit(&faa);
+       if (plat->uart_freq != NULL)
+               uart_freq = plat->uart_freq();
+
+       cons->consinit(&faa, uart_freq);
 
        initialized = true;
 }
diff -r 17ea7105fa8d -r e9693df90af7 sys/dev/fdt/fdtvar.h
--- a/sys/dev/fdt/fdtvar.h      Fri Jun 02 13:12:33 2017 +0000
+++ b/sys/dev/fdt/fdtvar.h      Fri Jun 02 13:53:28 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtvar.h,v 1.19 2017/05/29 23:13:03 jmcneill Exp $ */
+/* $NetBSD: fdtvar.h,v 1.20 2017/06/02 13:53:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -174,7 +174,7 @@
 
 struct fdt_console {
        int     (*match)(int);
-       void    (*consinit)(struct fdt_attach_args *);
+       void    (*consinit)(struct fdt_attach_args *, u_int);
 };
 
 struct fdt_console_info {



Home | Main Index | Thread Index | Old Index