From 2cb5caa7673b4d4ac0aaca08e8e93308f7d57bcf Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sat, 20 Nov 1999 07:23:28 +0000 Subject: [PATCH] Latest incremental efforts on newcard: o Delete pcic1 from NEWCARD o Add explicit resource hints to pcic0 o Get attach working with newbus, kinda (it does all the newbus stuff, but doesn't try to attach the pccard yet, too many panics). o Disable ie0 and le0 in NEWCARD config. There appears to be a bug in the isa_compat code wrt memory conflicts with newbus drivers for reasons unknown. o Minor cleanups. --- sys/dev/pcic/i82365_isa.c | 125 +++++++++++++++++++++++--------------- sys/dev/pcic/i82365var.h | 8 +++ sys/i386/conf/NEWCARD | 9 +-- 3 files changed, 89 insertions(+), 53 deletions(-) diff --git a/sys/dev/pcic/i82365_isa.c b/sys/dev/pcic/i82365_isa.c index 756cdffcdf59..85cfe949435a 100644 --- a/sys/dev/pcic/i82365_isa.c +++ b/sys/dev/pcic/i82365_isa.c @@ -97,16 +97,11 @@ pcic_isa_probe(device_t dev) int val, found; int rid; struct resource *res; - u_long port, portlen; /* Check isapnp ids */ if (ISA_PNP_PROBE(device_get_parent(dev), dev, pcic_ids) == ENXIO) return (ENXIO); - if (bus_get_resource(dev, SYS_RES_IOPORT, 0, &port, &portlen)) { - bus_set_resource(dev, SYS_RES_IOPORT, 0, PCIC_INDEX0, - PCIC_IOSIZE); - } rid = 0; res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, PCIC_IOSIZE, RF_ACTIVE); @@ -142,7 +137,7 @@ pcic_isa_probe(device_t dev) bus_release_resource(dev, SYS_RES_IOPORT, rid, res); - /* XXX DO I NEED TO WORRY ABOUT IRQ? XXX */ + /* XXX DO I NEED TO WORRY ABOUT the IRQ? XXX */ if (!found) return (ENXIO); @@ -153,45 +148,39 @@ pcic_isa_probe(device_t dev) int pcic_isa_attach(device_t dev) { -#if 0 - struct pcic_softc *sc = (void *) self; - struct isa_attach_args *ia = aux; - isa_chipset_tag_t ic = ia->ia_ic; - bus_space_tag_t iot = ia->ia_iot; - bus_space_tag_t memt = ia->ia_memt; - bus_space_handle_t ioh; - bus_space_handle_t memh; + struct pcic_softc *sc = (struct pcic_softc *) device_get_softc(dev); - /* Map i/o space. */ - if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) { - printf(": can't map i/o space\n"); - return; + sc->port_rid = 0; + sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, + 0, ~0, PCIC_IOSIZE, RF_ACTIVE); + if (!sc->port_res) { + device_printf(dev, "Unable to allocate I/O ports\n"); + goto error; } - - /* Map mem space. */ -#ifdef __FreeBSD__ - if (bus_space_map(memt, kvtop(ia->ia_membase), ia->ia_memsize, 0, &memh)) { -#else - if (bus_space_map(memt, ia->ia_maddr, ia->ia_msize, 0, &memh)) { -#endif - printf(": can't map mem space\n"); - return; + + sc->mem_rid = 0; + sc->mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->mem_rid, + 0, ~0, 1 << 13, RF_ACTIVE); + if (!sc->mem_res) { + device_printf(dev, "Unable to allocate memory range\n"); + goto error; } -#ifdef __FreeBSD__ - sc->membase = kvtop(ia->ia_membase); -#else - sc->membase = ia->ia_maddr; -#endif - sc->subregionmask = (1 << (ia->ia_msize / PCIC_MEM_PAGESIZE)) - 1; + + sc->subregionmask = (1 << + ((rman_get_end(sc->mem_res) - rman_get_start(sc->mem_res) + 1) / + PCIC_MEM_PAGESIZE)) - 1; - sc->intr_est = ic; sc->pct = (pccard_chipset_tag_t) & pcic_isa_functions; - sc->iot = iot; - sc->ioh = ioh; - sc->memt = memt; - sc->memh = memh; - + sc->irq_rid = 0; + sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid, + 0, ~0, 1, RF_ACTIVE); + if (!sc->irq_res) { + device_printf(dev, "Unable to allocate irq\n"); + goto error; + } + +#if 0 /* * allocate an irq. it will be used by both controllers. I could * use two different interrupts, but interrupts are relatively @@ -208,20 +197,58 @@ pcic_isa_attach(device_t dev) } printf(": using irq %d", sc->irq); } - printf("\n"); +#endif + sc->iot = rman_get_bustag(sc->port_res); + sc->ioh = rman_get_bushandle(sc->port_res);; + sc->memt = rman_get_bustag(sc->mem_res); + sc->memh = rman_get_bushandle(sc->mem_res);; - pcic_attach(sc); +#if 0 /* Not yet */ + pcic_attach(dev); - pcic_isa_bus_width_probe (sc, iot, ioh, ia->ia_iobase, ia->ia_iosize); - - sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY, - pcic_intr, sc); - if (sc->ih == NULL) { - printf("%s: can't establish interrupt\n", sc->dev.dv_xname); - return; - } + pcic_isa_bus_width_probe (dev, sc->iot, sc->ioh, + rman_get_start(sc->port_res), + rman_get_end(sc->port_res) - rman_get_end(sc->port_res) + 1); pcic_attach_sockets(sc); #endif return 0; + error: + if (sc->port_res) + bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, + sc->port_res); + if (sc->mem_res) + bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, + sc->mem_res); + if (sc->irq_res) + bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, + sc->irq_res); + return ENOMEM; } + +static int +pcic_isa_detach(device_t dev) +{ + return 0; +} + + + +static device_method_t pcic_isa_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, pcic_isa_probe), + DEVMETHOD(device_attach, pcic_isa_attach), + DEVMETHOD(device_detach, pcic_isa_detach), + + { 0, 0 } +}; + +static driver_t pcic_driver = { + "pcic", + pcic_isa_methods, + sizeof(struct pcic_softc) +}; + +static devclass_t pcic_devclass; + +DRIVER_MODULE(pcic, isa, pcic_driver, pcic_devclass, 0, 0); diff --git a/sys/dev/pcic/i82365var.h b/sys/dev/pcic/i82365var.h index 28998e78eae9..eb5b37cd9dd9 100644 --- a/sys/dev/pcic/i82365var.h +++ b/sys/dev/pcic/i82365var.h @@ -103,6 +103,14 @@ struct pcic_softc { bus_space_tag_t iot; bus_space_handle_t ioh; + struct resource *port_res; + int port_rid; + struct resource *mem_res; + int mem_rid; + struct resource *irq_res; + int irq_rid; + + /* XXX isa_chipset_tag_t, pci_chipset_tag_t, etc. */ void *intr_est; diff --git a/sys/i386/conf/NEWCARD b/sys/i386/conf/NEWCARD index d43c94a33a5b..9f9073106918 100644 --- a/sys/i386/conf/NEWCARD +++ b/sys/i386/conf/NEWCARD @@ -148,8 +148,7 @@ device npx0 at nexus? port IO_NPX irq 13 device apm0 at nexus? disable flags 0x31 # Advanced Power Management # PCCARD (PCMCIA) support -controller pcic0 at isa? -controller pcic1 at isa? +controller pcic0 at isa? port 0x3e0 irq 10 iomem 0xd0000 # controller pccbb0 # Serial (COM) ports @@ -191,13 +190,13 @@ device xl0 # 3Com 3c90x (``Boomerang'', ``Cyclone'') # ISA Ethernet NICs. # The probe order of these is presently determined by i386/isa/isa_compat.c. device ed0 at isa? port 0x280 irq 10 iomem 0xd8000 -device ie0 at isa? port 0x300 irq 10 iomem 0xd0000 +# device ie0 at isa? port 0x300 irq 10 iomem 0xd0000 # NOTE: This removes the isa attachment so that the pccard unit numbers # come out right. device ep0 device ex0 at isa? port? irq? device fe0 at isa? port 0x300 irq ? -device le0 at isa? port 0x300 irq 5 iomem 0xd0000 +# device le0 at isa? port 0x300 irq 5 iomem 0xd0000 device lnc0 at isa? port 0x280 irq 10 drq 0 device cs0 at isa? port 0x300 irq ? # requires PCCARD (PCMCIA) support to be activated @@ -226,3 +225,5 @@ pseudo-device bpf #Berkeley packet filter #device ulpt0 # Printer #controller umass0 # Disks/Mass storage - Requires scbus and da0 #device ums0 # Mouse + +options DDB