Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/imx initialize uart register when it is not a c...



details:   https://anonhg.NetBSD.org/src/rev/702308595a05
branches:  trunk
changeset: 339578:702308595a05
user:      ryo <ryo%NetBSD.org@localhost>
date:      Wed Jul 29 08:51:03 2015 +0000

description:
initialize uart register when it is not a console.

diffstat:

 sys/arch/arm/imx/imxuart.c |  24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diffs (77 lines):

diff -r 823f309c996b -r 702308595a05 sys/arch/arm/imx/imxuart.c
--- a/sys/arch/arm/imx/imxuart.c        Wed Jul 29 08:45:28 2015 +0000
+++ b/sys/arch/arm/imx/imxuart.c        Wed Jul 29 08:51:03 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: imxuart.c,v 1.17 2015/04/13 21:18:41 riastradh Exp $ */
+/* $NetBSD: imxuart.c,v 1.18 2015/07/29 08:51:03 ryo Exp $ */
 
 /*
  * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imxuart.c,v 1.17 2015/04/13 21:18:41 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imxuart.c,v 1.18 2015/07/29 08:51:03 ryo Exp $");
 
 #include "opt_imxuart.h"
 #include "opt_ddb.h"
@@ -293,7 +293,7 @@
 void   imxuart_common_putc(dev_t, struct imxuart_regs *, int);
 
 
-int    imxuart_init(struct imxuart_regs *, int, tcflag_t);
+int    imxuart_init(struct imxuart_regs *, int, tcflag_t, int);
 
 int    imxucngetc(dev_t);
 void   imxucnputc(dev_t, int);
@@ -424,6 +424,9 @@
        callout_init(&sc->sc_diag_callout, 0);
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_HIGH);
 
+       if (regsp->ur_iobase != imxuconsregs.ur_iobase)
+               imxuart_init(&sc->sc_regs, TTYDEF_SPEED, TTYDEF_CFLAG, false);
+
        bus_space_read_region_4(iot, ioh, IMX_UCR1, sc->sc_ucr, 4);
        sc->sc_ucr2_d = sc->sc_ucr2;
 
@@ -2280,15 +2283,16 @@
  * Initialize UART for use as console or KGDB line.
  */
 int
-imxuart_init(struct imxuart_regs *regsp, int rate, tcflag_t cflag)
+imxuart_init(struct imxuart_regs *regsp, int rate, tcflag_t cflag, int domap)
 {
        struct imxuart_baudrate_ratio ratio;
        int rfdiv = IMX_UFCR_DIVIDER_TO_RFDIV(imxuart_freqdiv);
        uint32_t ufcr;
-
-       if (bus_space_map(regsp->ur_iot, regsp->ur_iobase, IMX_UART_SIZE, 0,
-               &regsp->ur_ioh))
-               return ENOMEM; /* ??? */
+       int error;
+
+       if (domap && (error = bus_space_map(regsp->ur_iot, regsp->ur_iobase,
+            IMX_UART_SIZE, 0, &regsp->ur_ioh)) != 0)
+               return error;
 
        if (imxuspeed(rate, &ratio) < 0)
                return EINVAL;
@@ -2355,7 +2359,7 @@
        regs.ur_iot = iot;
        regs.ur_iobase = iobase;
 
-       res = imxuart_init(&regs, rate, cflag);
+       res = imxuart_init(&regs, rate, cflag, true);
        if (res)
                return (res);
 
@@ -2416,7 +2420,7 @@
                imxu_kgdb_regs.ur_iot = iot;
                imxu_kgdb_regs.ur_iobase = iobase;
 
-               res = imxuart_init(&imxu_kgdb_regs, rate, cflag);
+               res = imxuart_init(&imxu_kgdb_regs, rate, cflag, true);
                if (res)
                        return (res);
 



Home | Main Index | Thread Index | Old Index