Source-Changes-HG archive

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

[src/trunk]: src/sys Allow COM_TOLERANCE to be tweakable. If comspeed return...



details:   https://anonhg.NetBSD.org/src/rev/6d55795979fb
branches:  trunk
changeset: 765501:6d55795979fb
user:      matt <matt%NetBSD.org@localhost>
date:      Sat May 28 19:30:19 2011 +0000

description:
Allow COM_TOLERANCE to be tweakable.  If comspeed returns an invalid
rate, don't use that error value to set the speed.

diffstat:

 sys/conf/files      |   3 ++-
 sys/dev/ic/com.c    |  31 ++++++++++++++++++-------------
 sys/dev/ic/comreg.h |   8 +++++++-
 3 files changed, 27 insertions(+), 15 deletions(-)

diffs (101 lines):

diff -r 90189754446d -r 6d55795979fb sys/conf/files
--- a/sys/conf/files    Sat May 28 16:58:51 2011 +0000
+++ b/sys/conf/files    Sat May 28 19:30:19 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.1015 2011/05/23 15:37:35 drochner Exp $
+#      $NetBSD: files,v 1.1016 2011/05/28 19:30:19 matt Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -838,6 +838,7 @@
 # XXX In a perfect world, this would be done with attributes
 defflag        opt_com.h               COM_16650 COM_HAYESP COM_PXA2X0 COM_AU1X00
                                COM_REGMAP
+defparam opt_com.h             COM_TOLERANCE
 device com { } : tty
 file   dev/ic/com.c                    com                     needs-flag
 
diff -r 90189754446d -r 6d55795979fb sys/dev/ic/com.c
--- a/sys/dev/ic/com.c  Sat May 28 16:58:51 2011 +0000
+++ b/sys/dev/ic/com.c  Sat May 28 19:30:19 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.300 2011/04/24 16:26:59 rmind Exp $ */
+/* $NetBSD: com.c,v 1.301 2011/05/28 19:30:19 matt Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.300 2011/04/24 16:26:59 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com.c,v 1.301 2011/05/28 19:30:19 matt Exp $");
 
 #include "opt_com.h"
 #include "opt_ddb.h"
@@ -803,7 +803,10 @@
                }
 
                /* Turn on interrupts. */
-               sc->sc_ier = IER_ERXRDY | IER_ERLS | IER_EMSC;
+               sc->sc_ier = IER_ERXRDY | IER_ERLS;
+               if (!ISSET(tp->t_cflag, CLOCAL))
+                       sc->sc_ier |= IER_EMSC;
+
                if (sc->sc_type == COM_TYPE_PXA2x0)
                        sc->sc_ier |= IER_EUART | IER_ERXTOUT;
                CSR_WRITE_1(&sc->sc_regs, COM_REG_IER, sc->sc_ier);
@@ -2168,17 +2171,19 @@
        }
 
        rate = comspeed(rate, frequency, type);
-       if (type != COM_TYPE_AU1x00) {
-               /* no EFR on alchemy */ 
-               if (type != COM_TYPE_16550_NOERS) {
-                       CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS);
-                       CSR_WRITE_1(regsp, COM_REG_EFR, 0);
+       if (__predict_true(rate != -1)) {
+               if (type == COM_TYPE_AU1x00) {
+                       CSR_WRITE_2(regsp, COM_REG_DLBL, rate);
+               } else {
+                       /* no EFR on alchemy */ 
+                       if (type != COM_TYPE_16550_NOERS) {
+                               CSR_WRITE_1(regsp, COM_REG_LCR, LCR_EERS);
+                               CSR_WRITE_1(regsp, COM_REG_EFR, 0);
+                       }
+                       CSR_WRITE_1(regsp, COM_REG_LCR, LCR_DLAB);
+                       CSR_WRITE_1(regsp, COM_REG_DLBL, rate & 0xff);
+                       CSR_WRITE_1(regsp, COM_REG_DLBH, rate >> 8);
                }
-               CSR_WRITE_1(regsp, COM_REG_LCR, LCR_DLAB);
-               CSR_WRITE_1(regsp, COM_REG_DLBL, rate & 0xff);
-               CSR_WRITE_1(regsp, COM_REG_DLBH, rate >> 8);
-       } else {
-               CSR_WRITE_1(regsp, COM_REG_DLBL, rate);
        }
        CSR_WRITE_1(regsp, COM_REG_LCR, cflag2lcr(cflag));
        CSR_WRITE_1(regsp, COM_REG_MCR, MCR_DTR | MCR_RTS);
diff -r 90189754446d -r 6d55795979fb sys/dev/ic/comreg.h
--- a/sys/dev/ic/comreg.h       Sat May 28 16:58:51 2011 +0000
+++ b/sys/dev/ic/comreg.h       Sat May 28 19:30:19 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: comreg.h,v 1.16 2010/07/20 06:17:20 jklos Exp $        */
+/*     $NetBSD: comreg.h,v 1.17 2011/05/28 19:30:19 matt Exp $ */
 
 /*-
  * Copyright (c) 1991 The Regents of the University of California.
@@ -33,8 +33,14 @@
 
 #include <dev/ic/ns16550reg.h>
 
+#ifdef _KERNEL_OPT
+#include "opt_com.h"
+#endif
+
 #define        COM_FREQ        1843200 /* 16-bit baud rate divisor */
+#ifndef COM_TOLERANCE
 #define        COM_TOLERANCE   30      /* baud rate tolerance, in 0.1% units */
+#endif
 
 /* interrupt enable register */
 #define        IER_ERXRDY      0x1     /* Enable receiver interrupt */



Home | Main Index | Thread Index | Old Index