summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorenami <enami@NetBSD.org>2001-08-27 14:27:01 +0000
committerenami <enami@NetBSD.org>2001-08-27 14:27:01 +0000
commit97e7cd9cf975d3cdcbe2f3c6a9fb23bf4ae7f7f6 (patch)
treec4c9ab220ec51ad0dd0b670a310404219975bc25 /sys/dev
parent4f924773b7e5426d631f9c353b9711256bb2bab7 (diff)
For hayes esp card, set prescaler if specified rate is grater than 115200.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/com.c34
-rw-r--r--sys/dev/ic/comvar.h6
2 files changed, 37 insertions, 3 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);
}
diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h
index 2a52e41d7c8..b3074dd946b 100644
--- a/sys/dev/ic/comvar.h
+++ b/sys/dev/ic/comvar.h
@@ -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 @@ struct com_softc {
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 *));