Module Name: src Committed By: matt Date: Sat May 28 19:30:20 UTC 2011
Modified Files: src/sys/conf: files src/sys/dev/ic: com.c comreg.h Log Message: Allow COM_TOLERANCE to be tweakable. If comspeed returns an invalid rate, don't use that error value to set the speed. To generate a diff of this commit: cvs rdiff -u -r1.1015 -r1.1016 src/sys/conf/files cvs rdiff -u -r1.300 -r1.301 src/sys/dev/ic/com.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/comreg.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/conf/files diff -u src/sys/conf/files:1.1015 src/sys/conf/files:1.1016 --- src/sys/conf/files:1.1015 Mon May 23 15:37:35 2011 +++ src/sys/conf/files Sat May 28 19:30:19 2011 @@ -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 Index: src/sys/dev/ic/com.c diff -u src/sys/dev/ic/com.c:1.300 src/sys/dev/ic/com.c:1.301 --- src/sys/dev/ic/com.c:1.300 Sun Apr 24 16:26:59 2011 +++ src/sys/dev/ic/com.c Sat May 28 19:30:19 2011 @@ -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); Index: src/sys/dev/ic/comreg.h diff -u src/sys/dev/ic/comreg.h:1.16 src/sys/dev/ic/comreg.h:1.17 --- src/sys/dev/ic/comreg.h:1.16 Tue Jul 20 06:17:20 2010 +++ src/sys/dev/ic/comreg.h Sat May 28 19:30:19 2011 @@ -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 */