Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic For hayes esp card, set prescaler if specified ra...



details:   https://anonhg.NetBSD.org/src/rev/fa8a1021d7f3
branches:  trunk
changeset: 514283:fa8a1021d7f3
user:      enami <enami%NetBSD.org@localhost>
date:      Mon Aug 27 14:27:01 2001 +0000

description:
For hayes esp card, set prescaler if specified rate is grater than 115200.

diffstat:

 sys/dev/ic/com.c    |  34 ++++++++++++++++++++++++++++++++--
 sys/dev/ic/comvar.h |   6 +++++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diffs (88 lines):

diff -r 574ef9448ba2 -r fa8a1021d7f3 sys/dev/ic/com.c
--- a/sys/dev/ic/com.c  Mon Aug 27 14:10:20 2001 +0000
+++ b/sys/dev/ic/com.c  Mon Aug 27 14:27:01 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: com.c,v 1.187 2001/08/22 12:44:10 simonb Exp $ */
+/*     $NetBSD: com.c,v 1.188 2001/08/27 14:27:01 enami Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -442,6 +442,8 @@
        }
 
 #ifdef COM_HAYESP
+       sc->sc_prescaler = 0;                   /* set prescaler to x1. */
+
        /* Look for a Hayes ESP board. */
        for (hayespp = hayesp_ports; *hayespp != 0; hayespp++) {
                bus_space_handle_t hayespioh;
@@ -1356,13 +1358,33 @@
        struct termios *t;
 {
        struct com_softc *sc = device_lookup(&com_cd, COMUNIT(tp->t_dev));
-       int ospeed = comspeed(t->c_ospeed, sc->sc_frequency);
+       int ospeed;
        u_char lcr;
        int s;
 
        if (COM_ISALIVE(sc) == 0)
                return (EIO);
 
+#ifdef COM_HAYESP
+       if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) {
+               int prescaler, speed;
+
+               /*
+                * Calculate UART clock prescaler.  It should be in
+                * range of 0 .. 3.
+                */
+               for (prescaler = 0, speed = t->c_ospeed; prescaler < 4;
+                   prescaler++, speed /= 2)
+                       if ((ospeed = comspeed(speed, sc->sc_frequency)) > 0)
+                               break;
+
+               if (prescaler == 4)
+                       return (EINVAL);
+               sc->sc_prescaler = prescaler;
+       } else
+#endif
+       ospeed = comspeed(t->c_ospeed, sc->sc_frequency);
+
        /* Check requested parameters. */
        if (ospeed < 0)
                return (EINVAL);
@@ -1575,6 +1597,14 @@
        bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr);
        bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr_active = sc->sc_mcr);
        bus_space_write_1(iot, ioh, com_fifo, sc->sc_fifo);
+#ifdef COM_HAYESP
+       if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) {
+               bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD1,
+                   HAYESP_SETPRESCALER);
+               bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,
+                   sc->sc_prescaler);
+       }
+#endif
 
        bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);
 }
diff -r 574ef9448ba2 -r fa8a1021d7f3 sys/dev/ic/comvar.h
--- a/sys/dev/ic/comvar.h       Mon Aug 27 14:10:20 2001 +0000
+++ b/sys/dev/ic/comvar.h       Mon Aug 27 14:27:01 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: comvar.h,v 1.41 2001/08/22 12:44:10 simonb Exp $       */
+/*     $NetBSD: comvar.h,v 1.42 2001/08/27 14:27:01 enami Exp $        */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -118,6 +118,10 @@
            sc_mcr_active, sc_lcr, sc_ier, sc_fifo, sc_dlbl, sc_dlbh, sc_efr;
        u_char sc_mcr_dtr, sc_mcr_rts, sc_msr_cts, sc_msr_dcd;
 
+#ifdef COM_HAYESP
+       u_char sc_prescaler;
+#endif
+
        /* power management hooks */
        int (*enable) __P((struct com_softc *));
        void (*disable) __P((struct com_softc *));



Home | Main Index | Thread Index | Old Index