summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoris <is@NetBSD.org>1997-09-16 20:34:23 +0000
committeris <is@NetBSD.org>1997-09-16 20:34:23 +0000
commit718fb97e11bfc33ec278b4c4a652aebf4dee181c (patch)
treebfc07610400deb3fab2234c32e0299e506ca83c7 /sys/dev
parentd1b4b492310958c0e1d2b8a94554becf97007a23 (diff)
Support for the upcoming NetBSD/Amiga Hypercom driver family:
* support chip clocks != COM_FREQ, by introducing sc_frequency (for the mainline code) and adding a frequency parameter right after the rate parameter to comcnattach() and com_kgdb_attach(). - Make com_isa and com_multi initialize sc_frequency to COM_FREQ. - Make i386/machdep.c and alpha/dec_xxx.c call com*attach() with the freq. parameter. * supio_attach_args get two more fields: a sc_ipl and a sc_arg, both ints. - com_supio uses the first for interupt establishment (all childs will, as soon as they exist) and the 2nd for sc_frequency. - drsupio passes sc_ipl alway as 5, and for the "com"s, sc_arg as 16*115200 - hyper will pass sc_ipl as 6, and sc_arg as 16 * 460800
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/com.c30
-rw-r--r--sys/dev/ic/comvar.h10
-rw-r--r--sys/dev/isa/com.c30
-rw-r--r--sys/dev/isa/com_isa.c4
-rw-r--r--sys/dev/isa/com_multi.c3
-rw-r--r--sys/dev/isa/comvar.h10
6 files changed, 47 insertions, 40 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 6d2eb766295..69326e9db35 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.108 1997/08/27 18:00:13 is Exp $ */
+/* $NetBSD: com.c,v 1.109 1997/09/16 20:34:23 is Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -109,7 +109,7 @@ static void com_enable_debugport __P((struct com_softc *));
#endif
void com_attach_subr __P((struct com_softc *sc));
void comdiag __P((void *));
-int comspeed __P((long));
+int comspeed __P((long, long));
static u_char cflag2lcr __P((tcflag_t));
int comparam __P((struct tty *, struct termios *));
void comstart __P((struct tty *));
@@ -180,8 +180,8 @@ void com_kgdb_putc __P((void *, int));
#define COMUNIT(x) (minor(x))
int
-comspeed(speed)
- long speed;
+comspeed(speed, frequency)
+ long speed, frequency;
{
#define divrnd(n, q) (((n)*2/(q)+1)/2) /* divide and round off */
@@ -193,10 +193,10 @@ comspeed(speed)
#endif
if (speed <= 0)
return (-1);
- x = divrnd((COM_FREQ / 16), speed);
+ x = divrnd(frequency / 16, speed);
if (x <= 0)
return (-1);
- err = divrnd((COM_FREQ / 16) * 1000, speed * x) - 1000;
+ err = divrnd(frequency * 1000 / 16, speed * x) - 1000;
if (err < 0)
err = -err;
if (err > COM_TOLERANCE)
@@ -847,7 +847,7 @@ comparam(tp, t)
struct termios *t;
{
struct com_softc *sc = com_cd.cd_devs[COMUNIT(tp->t_dev)];
- int ospeed = comspeed(t->c_ospeed);
+ int ospeed = comspeed(t->c_ospeed, sc->sc_frequency);
u_char lcr;
int s;
@@ -1613,10 +1613,10 @@ com_common_putc(iot, ioh, c)
* Initialize UART to known state.
*/
int
-cominit(iot, iobase, rate, cflag, iohp)
+cominit(iot, iobase, rate, frequency, cflag, iohp)
bus_space_tag_t iot;
int iobase;
- int rate;
+ int rate, frequency;
tcflag_t cflag;
bus_space_handle_t *iohp;
{
@@ -1626,7 +1626,7 @@ cominit(iot, iobase, rate, cflag, iohp)
return(ENOMEM); /* ??? */
bus_space_write_1(iot, ioh, com_lcr, LCR_DLAB);
- rate = comspeed(rate);
+ rate = comspeed(rate, frequency);
bus_space_write_1(iot, ioh, com_dlbl, rate);
bus_space_write_1(iot, ioh, com_dlbh, rate >> 8);
bus_space_write_1(iot, ioh, com_lcr, cflag2lcr(cflag));
@@ -1644,17 +1644,17 @@ cominit(iot, iobase, rate, cflag, iohp)
*/
int
-comcnattach(iot, iobase, rate, cflag)
+comcnattach(iot, iobase, rate, frequency, cflag)
bus_space_tag_t iot;
int iobase;
- int rate;
+ int rate, frequency;
tcflag_t cflag;
{
int res;
static struct consdev comcons = { NULL, NULL,
comcngetc, comcnputc, comcnpollc, NODEV, CN_NORMAL};
- res = cominit(iot, iobase, rate, cflag, &comconsioh);
+ res = cominit(iot, iobase, rate, frequency, cflag, &comconsioh);
if(res) return(res);
cn_tab = &comcons;
@@ -1697,7 +1697,7 @@ comcnpollc(dev, on)
#ifdef KGDB
int
-com_kgdb_attach(iot, iobase, rate, cflag)
+com_kgdb_attach(iot, iobase, rate, frequency, cflag)
bus_space_tag_t iot;
int iobase;
int rate;
@@ -1708,7 +1708,7 @@ com_kgdb_attach(iot, iobase, rate, cflag)
if (iot == comconstag && iobase == comconsaddr)
return(EBUSY); /* cannot share with console */
- res = cominit(iot, iobase, rate, cflag, &com_kgdb_ioh);
+ res = cominit(iot, iobase, rate, frequency, cflag, &com_kgdb_ioh);
if(res) return(res);
kgdb_attach(com_kgdb_getc, com_kgdb_putc, NULL);
diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h
index 1ad170ea2cc..fa87123bbd0 100644
--- a/sys/dev/ic/comvar.h
+++ b/sys/dev/ic/comvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: comvar.h,v 1.14 1997/08/23 14:01:34 drochner Exp $ */
+/* $NetBSD: comvar.h,v 1.15 1997/09/16 20:34:29 is Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -30,10 +30,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-int comcnattach __P((bus_space_tag_t, int, int, tcflag_t));
+int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t));
#ifdef KGDB
-int com_kgdb_attach __P((bus_space_tag_t, int, int, tcflag_t));
+int com_kgdb_attach __P((bus_space_tag_t, int, int, int, tcflag_t));
#endif
int com_is_console __P((bus_space_tag_t, int, bus_space_handle_t *));
@@ -62,6 +62,7 @@ struct com_softc {
int sc_errors;
int sc_iobase;
+ int sc_frequency;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
@@ -110,7 +111,8 @@ struct com_softc {
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
int comintr __P((void *));
void com_attach_subr __P((struct com_softc *));
-int cominit __P((bus_space_tag_t, int, int, tcflag_t, bus_space_handle_t *));
+int cominit __P((bus_space_tag_t, int, int, int, tcflag_t,
+ bus_space_handle_t *));
#ifndef __GENERIC_SOFT_INTERRUPTS
#ifdef alpha
diff --git a/sys/dev/isa/com.c b/sys/dev/isa/com.c
index 6d2eb766295..69326e9db35 100644
--- a/sys/dev/isa/com.c
+++ b/sys/dev/isa/com.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com.c,v 1.108 1997/08/27 18:00:13 is Exp $ */
+/* $NetBSD: com.c,v 1.109 1997/09/16 20:34:23 is Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -109,7 +109,7 @@ static void com_enable_debugport __P((struct com_softc *));
#endif
void com_attach_subr __P((struct com_softc *sc));
void comdiag __P((void *));
-int comspeed __P((long));
+int comspeed __P((long, long));
static u_char cflag2lcr __P((tcflag_t));
int comparam __P((struct tty *, struct termios *));
void comstart __P((struct tty *));
@@ -180,8 +180,8 @@ void com_kgdb_putc __P((void *, int));
#define COMUNIT(x) (minor(x))
int
-comspeed(speed)
- long speed;
+comspeed(speed, frequency)
+ long speed, frequency;
{
#define divrnd(n, q) (((n)*2/(q)+1)/2) /* divide and round off */
@@ -193,10 +193,10 @@ comspeed(speed)
#endif
if (speed <= 0)
return (-1);
- x = divrnd((COM_FREQ / 16), speed);
+ x = divrnd(frequency / 16, speed);
if (x <= 0)
return (-1);
- err = divrnd((COM_FREQ / 16) * 1000, speed * x) - 1000;
+ err = divrnd(frequency * 1000 / 16, speed * x) - 1000;
if (err < 0)
err = -err;
if (err > COM_TOLERANCE)
@@ -847,7 +847,7 @@ comparam(tp, t)
struct termios *t;
{
struct com_softc *sc = com_cd.cd_devs[COMUNIT(tp->t_dev)];
- int ospeed = comspeed(t->c_ospeed);
+ int ospeed = comspeed(t->c_ospeed, sc->sc_frequency);
u_char lcr;
int s;
@@ -1613,10 +1613,10 @@ com_common_putc(iot, ioh, c)
* Initialize UART to known state.
*/
int
-cominit(iot, iobase, rate, cflag, iohp)
+cominit(iot, iobase, rate, frequency, cflag, iohp)
bus_space_tag_t iot;
int iobase;
- int rate;
+ int rate, frequency;
tcflag_t cflag;
bus_space_handle_t *iohp;
{
@@ -1626,7 +1626,7 @@ cominit(iot, iobase, rate, cflag, iohp)
return(ENOMEM); /* ??? */
bus_space_write_1(iot, ioh, com_lcr, LCR_DLAB);
- rate = comspeed(rate);
+ rate = comspeed(rate, frequency);
bus_space_write_1(iot, ioh, com_dlbl, rate);
bus_space_write_1(iot, ioh, com_dlbh, rate >> 8);
bus_space_write_1(iot, ioh, com_lcr, cflag2lcr(cflag));
@@ -1644,17 +1644,17 @@ cominit(iot, iobase, rate, cflag, iohp)
*/
int
-comcnattach(iot, iobase, rate, cflag)
+comcnattach(iot, iobase, rate, frequency, cflag)
bus_space_tag_t iot;
int iobase;
- int rate;
+ int rate, frequency;
tcflag_t cflag;
{
int res;
static struct consdev comcons = { NULL, NULL,
comcngetc, comcnputc, comcnpollc, NODEV, CN_NORMAL};
- res = cominit(iot, iobase, rate, cflag, &comconsioh);
+ res = cominit(iot, iobase, rate, frequency, cflag, &comconsioh);
if(res) return(res);
cn_tab = &comcons;
@@ -1697,7 +1697,7 @@ comcnpollc(dev, on)
#ifdef KGDB
int
-com_kgdb_attach(iot, iobase, rate, cflag)
+com_kgdb_attach(iot, iobase, rate, frequency, cflag)
bus_space_tag_t iot;
int iobase;
int rate;
@@ -1708,7 +1708,7 @@ com_kgdb_attach(iot, iobase, rate, cflag)
if (iot == comconstag && iobase == comconsaddr)
return(EBUSY); /* cannot share with console */
- res = cominit(iot, iobase, rate, cflag, &com_kgdb_ioh);
+ res = cominit(iot, iobase, rate, frequency, cflag, &com_kgdb_ioh);
if(res) return(res);
kgdb_attach(com_kgdb_getc, com_kgdb_putc, NULL);
diff --git a/sys/dev/isa/com_isa.c b/sys/dev/isa/com_isa.c
index 6fd199f1dff..4b99319acb2 100644
--- a/sys/dev/isa/com_isa.c
+++ b/sys/dev/isa/com_isa.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com_isa.c,v 1.5 1997/08/23 14:03:54 drochner Exp $ */
+/* $NetBSD: com_isa.c,v 1.6 1997/09/16 20:34:25 is Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996
@@ -124,6 +124,8 @@ com_isa_attach(parent, self, aux)
if(!com_is_console(iot, iobase, &sc->sc_ioh)
&& bus_space_map(iot, iobase, COM_NPORTS, 0, &sc->sc_ioh))
panic("comattach: io mapping failed");
+
+ sc->sc_frequency = COM_FREQ;
irq = ia->ia_irq;
com_attach_subr(sc);
diff --git a/sys/dev/isa/com_multi.c b/sys/dev/isa/com_multi.c
index 787ee747ed9..959deb34d64 100644
--- a/sys/dev/isa/com_multi.c
+++ b/sys/dev/isa/com_multi.c
@@ -1,4 +1,4 @@
-/* $NetBSD: com_multi.c,v 1.5 1997/08/23 14:03:55 drochner Exp $ */
+/* $NetBSD: com_multi.c,v 1.6 1997/09/16 20:34:28 is Exp $ */
/*-
* Copyright (c) 1993, 1994, 1995, 1996
@@ -106,6 +106,7 @@ com_multi_attach(parent, self, aux)
sc->sc_iot = ca->ca_iot;
sc->sc_ioh = ca->ca_ioh;
sc->sc_iobase = ca->ca_iobase;
+ sc->sc_frequency = 115200 * 16;
if (ca->ca_noien)
sc->sc_hwflags |= COM_HW_NOIEN;
diff --git a/sys/dev/isa/comvar.h b/sys/dev/isa/comvar.h
index 1ad170ea2cc..fa87123bbd0 100644
--- a/sys/dev/isa/comvar.h
+++ b/sys/dev/isa/comvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: comvar.h,v 1.14 1997/08/23 14:01:34 drochner Exp $ */
+/* $NetBSD: comvar.h,v 1.15 1997/09/16 20:34:29 is Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
@@ -30,10 +30,10 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-int comcnattach __P((bus_space_tag_t, int, int, tcflag_t));
+int comcnattach __P((bus_space_tag_t, int, int, int, tcflag_t));
#ifdef KGDB
-int com_kgdb_attach __P((bus_space_tag_t, int, int, tcflag_t));
+int com_kgdb_attach __P((bus_space_tag_t, int, int, int, tcflag_t));
#endif
int com_is_console __P((bus_space_tag_t, int, bus_space_handle_t *));
@@ -62,6 +62,7 @@ struct com_softc {
int sc_errors;
int sc_iobase;
+ int sc_frequency;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
@@ -110,7 +111,8 @@ struct com_softc {
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int));
int comintr __P((void *));
void com_attach_subr __P((struct com_softc *));
-int cominit __P((bus_space_tag_t, int, int, tcflag_t, bus_space_handle_t *));
+int cominit __P((bus_space_tag_t, int, int, int, tcflag_t,
+ bus_space_handle_t *));
#ifndef __GENERIC_SOFT_INTERRUPTS
#ifdef alpha