diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-11-29 22:55:11 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1996-11-29 22:55:11 +0000 |
commit | bde17508b795638ded93ae6976d40b145b7078e6 (patch) | |
tree | 68391b84ae17a5232bca6900696cbb9b92502ab9 /sys/dev/ic | |
parent | fc7f8028698e121cef42396d8352c0357be86aa7 (diff) |
Missing pieces of new bus.h that CVS lost behind my back
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/com.c | 346 | ||||
-rw-r--r-- | sys/dev/ic/comvar.h | 14 |
2 files changed, 204 insertions, 156 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 7c06bfbed0e..81b15473c45 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,4 +1,4 @@ -/* $OpenBSD: com.c,v 1.27 1996/11/12 20:30:27 niklas Exp $ */ +/* $OpenBSD: com.c,v 1.28 1996/11/29 22:54:52 niklas Exp $ */ /* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */ /*- @@ -57,7 +57,7 @@ #include <sys/types.h> #include <sys/device.h> -#include <machine/bus.old.h> +#include <machine/bus.h> #include <machine/intr.h> #include <dev/isa/isavar.h> @@ -78,7 +78,7 @@ struct com_softc { struct device sc_dev; void *sc_ih; - bus_chipset_tag_t sc_bc; + bus_space_tag_t sc_iot; struct tty *sc_tty; int sc_overflows; @@ -92,8 +92,9 @@ struct com_softc { int sc_hayespbase; #endif - bus_io_handle_t sc_ioh; - bus_io_handle_t sc_hayespioh; + bus_space_handle_t sc_ioh; + bus_space_handle_t sc_hayespioh; + isa_chipset_tag_t sc_ic; u_char sc_hwflags; #define COM_HW_NOIEN 0x01 @@ -120,7 +121,7 @@ struct com_softc { }; #ifdef COM_HAYESP -int comprobeHAYESP __P((bus_io_handle_t hayespioh, struct com_softc *sc)); +int comprobeHAYESP __P((bus_space_handle_t hayespioh, struct com_softc *sc)); #endif void comdiag __P((void *)); int comspeed __P((long)); @@ -162,6 +163,15 @@ struct cfattach com_commulti_ca = { }; #endif +#if NCOM_PICA +#undef CONADDR /* This is stupid but using devs before config .. */ +#define CONADDR 0xe0006000 + +struct cfattach com_pica_ca = { + sizeof(struct com_softc), comprobe, comattach +}; +#endif + struct cfdriver com_cd = { NULL, "com", DV_TTY }; @@ -178,8 +188,8 @@ int comdefaultrate = TTYDEF_SPEED; int comconsaddr; int comconsinit; int comconsattached; -bus_chipset_tag_t comconsbc; -bus_io_handle_t comconsioh; +bus_space_tag_t comconsiot; +bus_space_handle_t comconsioh; tcflag_t comconscflag = TTYDEF_CFLAG; int commajor; @@ -294,6 +304,7 @@ com_pcmcia_isa_attach(parent, match, aux, pc_link) (sc->sc_hwflags & (COM_HW_ABSENT_PENDING|COM_HW_CONSOLE)); } else sc->sc_hwflags = 0; + sc->sc_ic = ia->ia_ic; } return rval; } @@ -339,7 +350,7 @@ com_pcmcia_remove(pc_link, self) ttyfree(sc->sc_tty); sc->sc_tty = NULL; ok: - isa_intr_disestablish(sc->sc_bc, sc->sc_ih); + isa_intr_disestablish(sc->sc_ic, sc->sc_ih); sc->sc_ih = NULL; SET(sc->sc_hwflags, COM_HW_ABSENT); return 0; /* OK! */ @@ -420,20 +431,20 @@ comspeed(speed) } int -comprobe1(bc, ioh, iobase) - bus_chipset_tag_t bc; - bus_io_handle_t ioh; +comprobe1(iot, ioh, iobase) + bus_space_tag_t iot; + bus_space_handle_t ioh; int iobase; { int i, k; /* force access to id reg */ - bus_io_write_1(bc, ioh, com_lcr, 0); - bus_io_write_1(bc, ioh, com_iir, 0); + bus_space_write_1(iot, ioh, com_lcr, 0); + bus_space_write_1(iot, ioh, com_iir, 0); for (i = 0; i < 32; i++) { - k = bus_io_read_1(bc, ioh, com_iir); + k = bus_space_read_1(iot, ioh, com_iir); if (k & 0x38) { - bus_io_read_1(bc, ioh, com_data); /* cleanup */ + bus_space_read_1(iot, ioh, com_data); /* cleanup */ } else break; } @@ -446,12 +457,12 @@ comprobe1(bc, ioh, iobase) #ifdef COM_HAYESP int comprobeHAYESP(hayespioh, sc) - bus_io_handle_t hayespioh; + bus_space_handle_t hayespioh; struct com_softc *sc; { char val, dips; int combaselist[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 }; - bus_chipset_tag_t bc = sc->sc_bc; + bus_space_tag_t iot = sc->sc_iot; /* * Hayes ESP cards have two iobases. One is for compatibility with @@ -461,7 +472,7 @@ comprobeHAYESP(hayespioh, sc) */ /* Test for ESP signature */ - if ((bus_io_read_1(bc, hayespioh, 0) & 0xf3) == 0) + if ((bus_space_read_1(iot, hayespioh, 0) & 0xf3) == 0) return 0; /* @@ -469,8 +480,8 @@ comprobeHAYESP(hayespioh, sc) */ /* Get the dip-switch configurations */ - bus_io_write_1(bc, hayespioh, HAYESP_CMD1, HAYESP_GETDIPS); - dips = bus_io_read_1(bc, hayespioh, HAYESP_STATUS1); + bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_GETDIPS); + dips = bus_space_read_1(iot, hayespioh, HAYESP_STATUS1); /* Determine which com port this ESP card services: bits 0,1 of */ /* dips is the port # (0-3); combaselist[val] is the com_iobase */ @@ -481,9 +492,9 @@ comprobeHAYESP(hayespioh, sc) /* Check ESP Self Test bits. */ /* Check for ESP version 2.0: bits 4,5,6 == 010 */ - bus_io_write_1(bc, hayespioh, HAYESP_CMD1, HAYESP_GETTEST); - val = bus_io_read_1(bc, hayespioh, HAYESP_STATUS1); /* Clear reg 1 */ - val = bus_io_read_1(bc, hayespioh, HAYESP_STATUS2); + bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_GETTEST); + val = bus_space_read_1(iot, hayespioh, HAYESP_STATUS1); /* Clear reg 1 */ + val = bus_space_read_1(iot, hayespioh, HAYESP_STATUS2); if ((val & 0x70) < 0x20) { printf("-old (%o)", val & 0x70); /* we do not support the necessary features */ @@ -513,8 +524,8 @@ comprobe(parent, match, aux) struct device *parent; void *match, *aux; { - bus_chipset_tag_t bc; - bus_io_handle_t ioh; + bus_space_tag_t iot; + bus_space_handle_t ioh; int iobase, needioh; int rv = 1; @@ -526,6 +537,10 @@ comprobe(parent, match, aux) #define IS_ISA(parent) \ !strcmp((parent)->dv_cfdata->cf_driver->cd_name, "isa") #endif +#if NCOM_PICA +#define IS_PICA(parent) \ + !strcmp((parent)->dv_cfdata->cf_driver->cd_name, "pica") +#endif /* * XXX should be broken out into functions for isa probe and * XXX for commulti probe, with a helper function that contains @@ -535,7 +550,7 @@ comprobe(parent, match, aux) if (IS_ISA(parent)) { struct isa_attach_args *ia = aux; - bc = ia->ia_bc; + iot = ia->ia_iot; iobase = ia->ia_iobase; needioh = 1; } else @@ -548,25 +563,35 @@ comprobe(parent, match, aux) if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave) return (0); - bc = ca->ca_bc; + iot = ca->ca_iot; iobase = ca->ca_iobase; ioh = ca->ca_ioh; needioh = 0; } else #endif +#if NCOM_PICA + if(IS_PICA(parent)) { + struct confargs *ca = aux; + if(!BUS_MATCHNAME(ca, "com")) + return(0); + iobase = (long)BUS_CVTADDR(ca); + iot = 0; + needioh = 1; + } else +#endif return(0); /* This cannot happen */ /* if it's in use as console, it's there. */ if (iobase == comconsaddr && !comconsattached) goto out; - if (needioh && bus_io_map(bc, iobase, COM_NPORTS, &ioh)) { + if (needioh && bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) { rv = 0; goto out; } - rv = comprobe1(bc, ioh, iobase); + rv = comprobe1(iot, ioh, iobase); if (needioh) - bus_io_unmap(bc, ioh, COM_NPORTS); + bus_space_unmap(iot, ioh, COM_NPORTS); out: #if NCOM_ISA || NCOM_PCMCIA @@ -587,8 +612,8 @@ comattach(parent, self, aux) { struct com_softc *sc = (void *)self; int iobase, irq; - bus_chipset_tag_t bc; - bus_io_handle_t ioh; + bus_space_tag_t iot; + bus_space_handle_t ioh; #ifdef COM_HAYESP int hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 }; int *hayespp; @@ -615,9 +640,9 @@ comattach(parent, self, aux) * We're living on an isa. */ iobase = ia->ia_iobase; - bc = ia->ia_bc; + iot = ia->ia_iot; if (iobase != comconsaddr) { - if (bus_io_map(bc, iobase, COM_NPORTS, &ioh)) + if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh)) panic("comattach: io mapping failed"); } else ioh = comconsioh; @@ -632,7 +657,7 @@ comattach(parent, self, aux) * We're living on a commulti. */ iobase = ca->ca_iobase; - bc = ca->ca_bc; + iot = ca->ca_iot; ioh = ca->ca_ioh; irq = IRQUNK; @@ -640,9 +665,18 @@ comattach(parent, self, aux) SET(sc->sc_hwflags, COM_HW_NOIEN); } else #endif +#if NCOM_PICA + if(IS_PICA(parent)) { + struct confargs *ca = aux; + iobase = (long)BUS_CVTADDR(ca); + iot = 0; + irq = 0; + ioh = iobase; + } else +#endif panic("comattach: impossible"); - sc->sc_bc = bc; + sc->sc_iot = iot; sc->sc_ioh = ioh; sc->sc_iobase = iobase; @@ -662,29 +696,29 @@ comattach(parent, self, aux) #ifdef COM_HAYESP /* Look for a Hayes ESP board. */ for (hayespp = hayesp_ports; *hayespp != 0; hayespp++) { - bus_io_handle_t hayespioh; + bus_space_handle_t hayespioh; #define HAYESP_NPORTS 8 /* XXX XXX XXX ??? ??? ??? */ - if (bus_io_map(bc, *hayespp, HAYESP_NPORTS, &hayespioh)) + if (bus_space_map(iot, *hayespp, HAYESP_NPORTS, 0, &hayespioh)) continue; if (comprobeHAYESP(hayespioh, sc)) { sc->sc_hayespbase = *hayespp; sc->sc_hayespioh = hayespioh; break; } - bus_io_unmap(bc, hayespioh, HAYESP_NPORTS); + bus_space_unmap(iot, hayespioh, HAYESP_NPORTS); } /* No ESP; look for other things. */ if (*hayespp == 0) { #endif /* look for a NS 16550AF UART with FIFOs */ - bus_io_write_1(bc, ioh, com_fifo, + bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14); delay(100); - if (ISSET(bus_io_read_1(bc, ioh, com_iir), IIR_FIFO_MASK) == + if (ISSET(bus_space_read_1(iot, ioh, com_iir), IIR_FIFO_MASK) == IIR_FIFO_MASK) - if (ISSET(bus_io_read_1(bc, ioh, com_fifo), FIFO_TRIGGER_14) == + if (ISSET(bus_space_read_1(iot, ioh, com_fifo), FIFO_TRIGGER_14) == FIFO_TRIGGER_14) { SET(sc->sc_hwflags, COM_HW_FIFO); printf(": ns16550a, working fifo\n"); @@ -692,14 +726,14 @@ comattach(parent, self, aux) printf(": ns16550, broken fifo\n"); else printf(": ns8250 or ns16450, no fifo\n"); - bus_io_write_1(bc, ioh, com_fifo, 0); + bus_space_write_1(iot, ioh, com_fifo, 0); #ifdef COM_HAYESP } #endif /* disable interrupts */ - bus_io_write_1(bc, ioh, com_ier, 0); - bus_io_write_1(bc, ioh, com_mcr, 0); + bus_space_write_1(iot, ioh, com_ier, 0); + bus_space_write_1(iot, ioh, com_mcr, 0); if (irq != IRQUNK) { #if NCOM_ISA || NCOM_PCMCIA @@ -711,6 +745,12 @@ comattach(parent, self, aux) sc->sc_dev.dv_xname); } else #endif +#if NCOM_PICA + if (IS_PICA(parent)) { + struct confargs *ca = aux; + BUS_INTR_ESTABLISH(ca, comintr, (void *)(long)sc); + } else +#endif panic("comattach: IRQ but can't have one"); } @@ -719,7 +759,7 @@ comattach(parent, self, aux) if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) kgdb_dev = -1; /* can't debug over console port */ else { - cominit(bc, ioh, kgdb_rate); + cominit(iot, ioh, kgdb_rate); if (kgdb_debug_init) { /* * Print prefix of device name, @@ -747,8 +787,8 @@ comopen(dev, flag, mode, p) { int unit = DEVUNIT(dev); struct com_softc *sc; - bus_chipset_tag_t bc; - bus_io_handle_t ioh; + bus_space_tag_t iot; + bus_space_handle_t ioh; struct tty *tp; int s; int error = 0; @@ -801,37 +841,37 @@ comopen(dev, flag, mode, p) sc->sc_ibufhigh = sc->sc_ibuf + COM_IHIGHWATER; sc->sc_ibufend = sc->sc_ibuf + COM_IBUFSIZE; - bc = sc->sc_bc; + iot = sc->sc_iot; ioh = sc->sc_ioh; #ifdef COM_HAYESP /* Setup the ESP board */ if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) { - bus_io_handle_t hayespioh = sc->sc_hayespioh; + bus_space_handle_t hayespioh = sc->sc_hayespioh; - bus_io_write_1(bc, ioh, com_fifo, + bus_space_write_1(iot, ioh, com_fifo, FIFO_DMA_MODE|FIFO_ENABLE| FIFO_RCV_RST|FIFO_XMT_RST|FIFO_TRIGGER_8); /* Set 16550 compatibility mode */ - bus_io_write_1(bc, hayespioh, HAYESP_CMD1, HAYESP_SETMODE); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_SETMODE); + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_MODE_FIFO|HAYESP_MODE_RTS| HAYESP_MODE_SCALE); /* Set RTS/CTS flow control */ - bus_io_write_1(bc, hayespioh, HAYESP_CMD1, HAYESP_SETFLOWTYPE); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, HAYESP_FLOW_RTS); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, HAYESP_FLOW_CTS); + bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_SETFLOWTYPE); + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_FLOW_RTS); + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_FLOW_CTS); /* Set flow control levels */ - bus_io_write_1(bc, hayespioh, HAYESP_CMD1, HAYESP_SETRXFLOW); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_SETRXFLOW); + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_HIBYTE(HAYESP_RXHIWMARK)); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_LOBYTE(HAYESP_RXHIWMARK)); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_HIBYTE(HAYESP_RXLOWMARK)); - bus_io_write_1(bc, hayespioh, HAYESP_CMD2, + bus_space_write_1(iot, hayespioh, HAYESP_CMD2, HAYESP_LOBYTE(HAYESP_RXLOWMARK)); } else #endif @@ -848,32 +888,32 @@ comopen(dev, flag, mode, p) * Set the FIFO threshold based on the receive speed. */ for (;;) { - bus_io_write_1(bc, ioh, com_fifo, 0); + bus_space_write_1(iot, ioh, com_fifo, 0); delay(100); - (void) bus_io_read_1(bc, ioh, com_data); - bus_io_write_1(bc, ioh, com_fifo, + (void) bus_space_read_1(iot, ioh, com_data); + bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | (tp->t_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); delay(100); - if(!ISSET(bus_io_read_1(bc, ioh, + if(!ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY)) break; } } /* flush any pending I/O */ - while (ISSET(bus_io_read_1(bc, ioh, com_lsr), LSR_RXRDY)) - (void) bus_io_read_1(bc, ioh, com_data); + while (ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY)) + (void) bus_space_read_1(iot, ioh, com_data); /* you turn me on, baby */ sc->sc_mcr = MCR_DTR | MCR_RTS; if (!ISSET(sc->sc_hwflags, COM_HW_NOIEN)) SET(sc->sc_mcr, MCR_IENABLE); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); sc->sc_ier = IER_ERXRDY | IER_ERLS | IER_EMSC; - bus_io_write_1(bc, ioh, com_ier, sc->sc_ier); + bus_space_write_1(iot, ioh, com_ier, sc->sc_ier); - sc->sc_msr = bus_io_read_1(bc, ioh, com_msr); + sc->sc_msr = bus_space_read_1(iot, ioh, com_msr); if (ISSET(sc->sc_swflags, COM_SW_SOFTCAR) || DEVCUA(dev) || ISSET(sc->sc_msr, MSR_DCD) || ISSET(tp->t_cflag, MDMBUF)) SET(tp->t_state, TS_CARR_ON); @@ -931,8 +971,8 @@ comclose(dev, flag, mode, p) int unit = DEVUNIT(dev); struct com_softc *sc = com_cd.cd_devs[unit]; struct tty *tp = sc->sc_tty; - bus_chipset_tag_t bc = sc->sc_bc; - bus_io_handle_t ioh = sc->sc_ioh; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; int s; /* XXX This is for cons.c. */ @@ -944,12 +984,12 @@ comclose(dev, flag, mode, p) if (!ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) { /* can't do any of this stuff .... */ CLR(sc->sc_lcr, LCR_SBREAK); - bus_io_write_1(bc, ioh, com_lcr, sc->sc_lcr); - bus_io_write_1(bc, ioh, com_ier, 0); + bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr); + bus_space_write_1(iot, ioh, com_ier, 0); if (ISSET(tp->t_cflag, HUPCL) && !ISSET(sc->sc_swflags, COM_SW_SOFTCAR)) { /* XXX perhaps only clear DTR */ - bus_io_write_1(bc, ioh, com_mcr, 0); + bus_space_write_1(iot, ioh, com_mcr, 0); } } CLR(tp->t_state, TS_BUSY | TS_FLUSH); @@ -1047,8 +1087,8 @@ comioctl(dev, cmd, data, flag, p) int unit = DEVUNIT(dev); struct com_softc *sc = com_cd.cd_devs[unit]; struct tty *tp = sc->sc_tty; - bus_chipset_tag_t bc = sc->sc_bc; - bus_io_handle_t ioh = sc->sc_ioh; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; int error; if (ISSET(sc->sc_hwflags, COM_HW_ABSENT|COM_HW_ABSENT_PENDING)) { @@ -1068,29 +1108,29 @@ comioctl(dev, cmd, data, flag, p) switch (cmd) { case TIOCSBRK: SET(sc->sc_lcr, LCR_SBREAK); - bus_io_write_1(bc, ioh, com_lcr, sc->sc_lcr); + bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr); break; case TIOCCBRK: CLR(sc->sc_lcr, LCR_SBREAK); - bus_io_write_1(bc, ioh, com_lcr, sc->sc_lcr); + bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr); break; case TIOCSDTR: SET(sc->sc_mcr, sc->sc_dtr); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); break; case TIOCCDTR: CLR(sc->sc_mcr, sc->sc_dtr); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); break; case TIOCMSET: CLR(sc->sc_mcr, MCR_DTR | MCR_RTS); case TIOCMBIS: SET(sc->sc_mcr, tiocm_xxx2mcr(*(int *)data)); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); break; case TIOCMBIC: CLR(sc->sc_mcr, tiocm_xxx2mcr(*(int *)data)); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); break; case TIOCMGET: { u_char m; @@ -1110,7 +1150,7 @@ comioctl(dev, cmd, data, flag, p) SET(bits, TIOCM_DSR); if (ISSET(m, MSR_RI | MSR_TERI)) SET(bits, TIOCM_RI); - if (bus_io_read_1(bc, ioh, com_ier)) + if (bus_space_read_1(iot, ioh, com_ier)) SET(bits, TIOCM_LE); *(int *)data = bits; break; @@ -1165,8 +1205,8 @@ comparam(tp, t) struct termios *t; { struct com_softc *sc = com_cd.cd_devs[DEVUNIT(tp->t_dev)]; - bus_chipset_tag_t bc = sc->sc_bc; - bus_io_handle_t ioh = sc->sc_ioh; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; int ospeed = comspeed(t->c_ospeed); u_char lcr; tcflag_t oldcflag; @@ -1213,7 +1253,7 @@ comparam(tp, t) if (ospeed == 0) { CLR(sc->sc_mcr, MCR_DTR); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } /* @@ -1246,34 +1286,34 @@ comparam(tp, t) } } - bus_io_write_1(bc, ioh, com_lcr, lcr | LCR_DLAB); - bus_io_write_1(bc, ioh, com_dlbl, ospeed); - bus_io_write_1(bc, ioh, com_dlbh, ospeed >> 8); - bus_io_write_1(bc, ioh, com_lcr, lcr); + bus_space_write_1(iot, ioh, com_lcr, lcr | LCR_DLAB); + bus_space_write_1(iot, ioh, com_dlbl, ospeed); + bus_space_write_1(iot, ioh, com_dlbh, ospeed >> 8); + bus_space_write_1(iot, ioh, com_lcr, lcr); SET(sc->sc_mcr, MCR_DTR); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } else - bus_io_write_1(bc, ioh, com_lcr, lcr); + bus_space_write_1(iot, ioh, com_lcr, lcr); if (!ISSET(sc->sc_hwflags, COM_HW_HAYESP) && ISSET(sc->sc_hwflags, COM_HW_FIFO)) - bus_io_write_1(bc, ioh, com_fifo, + bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE | (t->c_ispeed <= 1200 ? FIFO_TRIGGER_1 : FIFO_TRIGGER_8)); } else - bus_io_write_1(bc, ioh, com_lcr, lcr); + bus_space_write_1(iot, ioh, com_lcr, lcr); /* When not using CRTSCTS, RTS follows DTR. */ if (!ISSET(t->c_cflag, CRTSCTS)) { if (ISSET(sc->sc_mcr, MCR_DTR)) { if (!ISSET(sc->sc_mcr, MCR_RTS)) { SET(sc->sc_mcr, MCR_RTS); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } } else { if (ISSET(sc->sc_mcr, MCR_RTS)) { CLR(sc->sc_mcr, MCR_RTS); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } } sc->sc_dtr = MCR_DTR | MCR_RTS; @@ -1295,7 +1335,7 @@ comparam(tp, t) ISSET(oldcflag, MDMBUF) != ISSET(tp->t_cflag, MDMBUF) && (*linesw[tp->t_line].l_modem)(tp, 0) == 0) { CLR(sc->sc_mcr, sc->sc_dtr); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } /* Just to be sure... */ @@ -1321,8 +1361,8 @@ comstart(tp) struct tty *tp; { struct com_softc *sc = com_cd.cd_devs[DEVUNIT(tp->t_dev)]; - bus_chipset_tag_t bc = sc->sc_bc; - bus_io_handle_t ioh = sc->sc_ioh; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; int s; s = spltty(); @@ -1356,14 +1396,14 @@ comstart(tp) if (!ISSET(sc->sc_ier, IER_ETXRDY)) { SET(sc->sc_ier, IER_ETXRDY); - bus_io_write_1(bc, ioh, com_ier, sc->sc_ier); + bus_space_write_1(iot, ioh, com_ier, sc->sc_ier); } #ifdef COM_HAYESP if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) { u_char buffer[1024], *cp = buffer; int n = q_to_b(&tp->t_outq, cp, sizeof buffer); do - bus_io_write_1(bc, ioh, com_data, *cp++); + bus_space_write_1(iot, ioh, com_data, *cp++); while (--n); } else @@ -1372,17 +1412,17 @@ comstart(tp) u_char buffer[16], *cp = buffer; int n = q_to_b(&tp->t_outq, cp, sizeof buffer); do { - bus_io_write_1(bc, ioh, com_data, *cp++); + bus_space_write_1(iot, ioh, com_data, *cp++); } while (--n); } else - bus_io_write_1(bc, ioh, com_data, getc(&tp->t_outq)); + bus_space_write_1(iot, ioh, com_data, getc(&tp->t_outq)); out: splx(s); return; stopped: if (ISSET(sc->sc_ier, IER_ETXRDY)) { CLR(sc->sc_ier, IER_ETXRDY); - bus_io_write_1(bc, ioh, com_ier, sc->sc_ier); + bus_space_write_1(iot, ioh, com_ier, sc->sc_ier); } splx(s); } @@ -1484,7 +1524,7 @@ compoll(arg) !ISSET(sc->sc_mcr, MCR_RTS)) { /* XXX */ SET(sc->sc_mcr, MCR_RTS); - bus_io_write_1(sc->sc_bc, sc->sc_ioh, com_mcr, + bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_mcr, sc->sc_mcr); } @@ -1512,8 +1552,8 @@ comintr(arg) void *arg; { struct com_softc *sc = arg; - bus_chipset_tag_t bc = sc->sc_bc; - bus_io_handle_t ioh = sc->sc_ioh; + bus_space_tag_t iot = sc->sc_iot; + bus_space_handle_t ioh = sc->sc_ioh; struct tty *tp; u_char lsr, data, msr, delta; #ifdef COM_DEBUG @@ -1528,10 +1568,10 @@ comintr(arg) #ifdef COM_DEBUG n = 0; - if (ISSET(iter[n].iir = bus_io_read_1(bc, ioh, com_iir), IIR_NOPEND)) + if (ISSET(iter[n].iir = bus_space_read_1(iot, ioh, com_iir), IIR_NOPEND)) return (0); #else - if (ISSET(bus_io_read_1(bc, ioh, com_iir), IIR_NOPEND)) + if (ISSET(bus_space_read_1(iot, ioh, com_iir), IIR_NOPEND)) return (0); #endif @@ -1541,14 +1581,14 @@ comintr(arg) #ifdef COM_DEBUG iter[n].lsr = #endif - lsr = bus_io_read_1(bc, ioh, com_lsr); + lsr = bus_space_read_1(iot, ioh, com_lsr); if (ISSET(lsr, LSR_RXRDY)) { register u_char *p = sc->sc_ibufp; comevents = 1; do { - data = bus_io_read_1(bc, ioh, com_data); + data = bus_space_read_1(iot, ioh, com_data); if (ISSET(lsr, LSR_BI)) { #ifdef notdef printf("break %02x %02x %02x %02x\n", @@ -1575,7 +1615,7 @@ comintr(arg) ISSET(tp->t_cflag, CRTSCTS)) { /* XXX */ CLR(sc->sc_mcr, MCR_RTS); - bus_io_write_1(bc, ioh, com_mcr, + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } } @@ -1587,7 +1627,7 @@ comintr(arg) goto ohfudge; iter[n].lsr = #endif - lsr = bus_io_read_1(bc, ioh, com_lsr); + lsr = bus_space_read_1(iot, ioh, com_lsr); } while (ISSET(lsr, LSR_RXRDY)); sc->sc_ibufp = p; @@ -1600,7 +1640,7 @@ comintr(arg) #ifdef COM_DEBUG iter[n].msr = #endif - msr = bus_io_read_1(bc, ioh, com_msr); + msr = bus_space_read_1(iot, ioh, com_msr); if (msr != sc->sc_msr) { delta = msr ^ sc->sc_msr; @@ -1609,7 +1649,7 @@ comintr(arg) !ISSET(sc->sc_swflags, COM_SW_SOFTCAR) && (*linesw[tp->t_line].l_modem)(tp, ISSET(msr, MSR_DCD)) == 0) { CLR(sc->sc_mcr, sc->sc_dtr); - bus_io_write_1(bc, ioh, com_mcr, sc->sc_mcr); + bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr); } if (ISSET(delta & msr, MSR_CTS) && ISSET(tp->t_cflag, CRTSCTS)) { @@ -1628,10 +1668,10 @@ comintr(arg) #ifdef COM_DEBUG if (++n >= 32) goto ohfudge; - if (ISSET(iter[n].iir = bus_io_read_1(bc, ioh, com_iir), IIR_NOPEND)) + if (ISSET(iter[n].iir = bus_space_read_1(iot, ioh, com_iir), IIR_NOPEND)) return (1); #else - if (ISSET(bus_io_read_1(bc, ioh, com_iir), IIR_NOPEND)) + if (ISSET(bus_space_read_1(iot, ioh, com_iir), IIR_NOPEND)) return (1); #endif } @@ -1661,16 +1701,24 @@ comcnprobe(cp) struct consdev *cp; { /* XXX NEEDS TO BE FIXED XXX */ - bus_chipset_tag_t bc = 0; - bus_io_handle_t ioh; + bus_space_tag_t iot = 0; + bus_space_handle_t ioh; int found; +#if NCOM_PICA + /* XXX */ +#include <arc/arc/arctype.h> + extern int cputype; + + if(cputype != ACER_PICA_61) + return; +#endif - if (bus_io_map(bc, CONADDR, COM_NPORTS, &ioh)) { + if (bus_space_map(iot, CONADDR, COM_NPORTS, 0, &ioh)) { cp->cn_pri = CN_DEAD; return; } - found = comprobe1(bc, ioh, CONADDR); - bus_io_unmap(bc, ioh, COM_NPORTS); + found = comprobe1(iot, ioh, CONADDR); + bus_space_unmap(iot, ioh, COM_NPORTS); if (!found) { cp->cn_pri = CN_DEAD; return; @@ -1697,33 +1745,33 @@ comcninit(cp) #if 0 XXX NEEDS TO BE FIXED XXX - comconsbc = ???; + comconsiot = ???; #endif - if (bus_io_map(comconsbc, CONADDR, COM_NPORTS, &comconsioh)) + if (bus_space_map(comconsiot, CONADDR, COM_NPORTS, 0, &comconsioh)) panic("comcninit: mapping failed"); - cominit(comconsbc, comconsioh, comdefaultrate); + cominit(comconsiot, comconsioh, comdefaultrate); comconsaddr = CONADDR; comconsinit = 0; } void -cominit(bc, ioh, rate) - bus_chipset_tag_t bc; - bus_io_handle_t ioh; +cominit(iot, ioh, rate) + bus_space_tag_t iot; + bus_space_handle_t ioh; int rate; { int s = splhigh(); u_char stat; - bus_io_write_1(bc, ioh, com_lcr, LCR_DLAB); + bus_space_write_1(iot, ioh, com_lcr, LCR_DLAB); rate = comspeed(comdefaultrate); - bus_io_write_1(bc, ioh, com_dlbl, rate); - bus_io_write_1(bc, ioh, com_dlbh, rate >> 8); - bus_io_write_1(bc, ioh, com_lcr, LCR_8BITS); - bus_io_write_1(bc, ioh, com_ier, IER_ERXRDY | IER_ETXRDY); - bus_io_write_1(bc, ioh, com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_4); - stat = bus_io_read_1(bc, ioh, com_iir); + 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, LCR_8BITS); + bus_space_write_1(iot, ioh, com_ier, IER_ERXRDY | IER_ETXRDY); + bus_space_write_1(iot, ioh, com_fifo, FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_4); + stat = bus_space_read_1(iot, ioh, com_iir); splx(s); } @@ -1732,14 +1780,14 @@ comcngetc(dev) dev_t dev; { int s = splhigh(); - bus_chipset_tag_t bc = comconsbc; - bus_io_handle_t ioh = comconsioh; + bus_space_tag_t iot = comconsiot; + bus_space_handle_t ioh = comconsioh; u_char stat, c; - while (!ISSET(stat = bus_io_read_1(bc, ioh, com_lsr), LSR_RXRDY)) + while (!ISSET(stat = bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY)) ; - c = bus_io_read_1(bc, ioh, com_data); - stat = bus_io_read_1(bc, ioh, com_iir); + c = bus_space_read_1(iot, ioh, com_data); + stat = bus_space_read_1(iot, ioh, com_iir); splx(s); return c; } @@ -1753,8 +1801,8 @@ comcnputc(dev, c) int c; { int s = splhigh(); - bus_chipset_tag_t bc = comconsbc; - bus_io_handle_t ioh = comconsioh; + bus_space_tag_t iot = comconsiot; + bus_space_handle_t ioh = comconsioh; u_char stat; register int timo; @@ -1762,20 +1810,20 @@ comcnputc(dev, c) if (dev != kgdb_dev) #endif if (comconsinit == 0) { - cominit(bc, ioh, comdefaultrate); + cominit(iot, ioh, comdefaultrate); comconsinit = 1; } /* wait for any pending transmission to finish */ timo = 50000; - while (!ISSET(stat = bus_io_read_1(bc, ioh, com_lsr), LSR_TXRDY) && --timo) + while (!ISSET(stat = bus_space_read_1(iot, ioh, com_lsr), LSR_TXRDY) && --timo) ; - bus_io_write_1(bc, ioh, com_data, c); + bus_space_write_1(iot, ioh, com_data, c); /* wait for this transmission to complete */ timo = 1500000; - while (!ISSET(stat = bus_io_read_1(bc, ioh, com_lsr), LSR_TXRDY) && --timo) + while (!ISSET(stat = bus_space_read_1(iot, ioh, com_lsr), LSR_TXRDY) && --timo) ; /* clear any interrupts generated by this transmission */ - stat = bus_io_read_1(bc, ioh, com_iir); + stat = bus_space_read_1(iot, ioh, com_iir); splx(s); } diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h index ece4b98bb73..6895af5d813 100644 --- a/sys/dev/ic/comvar.h +++ b/sys/dev/ic/comvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comvar.h,v 1.4 1996/10/30 15:01:50 niklas Exp $ */ +/* $OpenBSD: comvar.h,v 1.5 1996/11/29 22:54:52 niklas Exp $ */ /* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */ /* @@ -34,18 +34,18 @@ struct commulti_attach_args { int ca_slave; /* slave number */ - bus_chipset_tag_t ca_bc; - bus_io_handle_t ca_ioh; + bus_space_tag_t ca_iot; + bus_space_handle_t ca_ioh; int ca_iobase; int ca_noien; }; -int comprobe1 __P((bus_chipset_tag_t, bus_io_handle_t, int)); -void cominit __P((bus_chipset_tag_t, bus_io_handle_t, int)); +int comprobe1 __P((bus_space_tag_t, bus_space_handle_t, int)); +void cominit __P((bus_space_tag_t, bus_space_handle_t, int)); int comintr __P((void *)); extern int comconsaddr; extern int comconsattached; -extern bus_chipset_tag_t comconsbc; -extern bus_io_handle_t comconsioh; +extern bus_space_tag_t comconsiot; +extern bus_space_handle_t comconsioh; extern tcflag_t comconscflag; |