diff options
| author | enami <enami@NetBSD.org> | 2001-08-27 14:27:01 +0000 |
|---|---|---|
| committer | enami <enami@NetBSD.org> | 2001-08-27 14:27:01 +0000 |
| commit | 97e7cd9cf975d3cdcbe2f3c6a9fb23bf4ae7f7f6 (patch) | |
| tree | c4c9ab220ec51ad0dd0b670a310404219975bc25 /sys/dev/ic/com.c | |
| parent | 4f924773b7e5426d631f9c353b9711256bb2bab7 (diff) | |
For hayes esp card, set prescaler if specified rate is grater than 115200.
Diffstat (limited to 'sys/dev/ic/com.c')
| -rw-r--r-- | sys/dev/ic/com.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index b9915493674..08b3b080f2e 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -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 @@ com_attach_subr(sc) } #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 @@ comparam(tp, t) 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 @@ com_loadchannelregs(sc) 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); } |
