2001-11-15 12:47:59 +03:00
|
|
|
/* $NetBSD: i82365_isapnp.c,v 1.12 2001/11/15 09:48:10 lukem Exp $ */
|
1998-06-07 22:28:31 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998 Bill Sommerfeld. All rights reserved.
|
|
|
|
* Copyright (c) 1997 Marc Horowitz. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by Marc Horowitz.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 10:56:39 +03:00
|
|
|
#include <sys/cdefs.h>
|
2001-11-15 12:47:59 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: i82365_isapnp.c,v 1.12 2001/11/15 09:48:10 lukem Exp $");
|
1998-06-07 22:28:31 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/extent.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
|
|
|
|
#include <dev/isapnp/isapnpreg.h>
|
|
|
|
#include <dev/isapnp/isapnpvar.h>
|
1998-07-23 23:30:44 +04:00
|
|
|
#include <dev/isapnp/isapnpdevs.h>
|
1998-06-07 22:28:31 +04:00
|
|
|
|
|
|
|
#include <dev/pcmcia/pcmciareg.h>
|
|
|
|
#include <dev/pcmcia/pcmciavar.h>
|
|
|
|
#include <dev/pcmcia/pcmciachip.h>
|
|
|
|
|
|
|
|
#include <dev/ic/i82365reg.h>
|
|
|
|
#include <dev/ic/i82365var.h>
|
|
|
|
#include <dev/isa/i82365_isavar.h>
|
|
|
|
|
|
|
|
#undef DPRINTF
|
|
|
|
#ifdef PCICISADEBUG
|
|
|
|
int pcicisapnp_debug = 0 /* XXX */ ;
|
|
|
|
#define DPRINTF(arg) if (pcicisapnp_debug) printf arg;
|
|
|
|
#else
|
|
|
|
#define DPRINTF(arg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int pcic_isapnp_match __P((struct device *, struct cfdata *, void *));
|
|
|
|
void pcic_isapnp_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct cfattach pcic_isapnp_ca = {
|
2000-02-23 20:22:11 +03:00
|
|
|
sizeof(struct pcic_isa_softc), pcic_isapnp_match, pcic_isapnp_attach
|
1998-06-07 22:28:31 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct pcmcia_chip_functions pcic_isa_functions = {
|
|
|
|
pcic_chip_mem_alloc,
|
|
|
|
pcic_chip_mem_free,
|
|
|
|
pcic_chip_mem_map,
|
|
|
|
pcic_chip_mem_unmap,
|
|
|
|
|
|
|
|
pcic_chip_io_alloc,
|
|
|
|
pcic_chip_io_free,
|
|
|
|
pcic_chip_io_map,
|
|
|
|
pcic_chip_io_unmap,
|
|
|
|
|
|
|
|
pcic_isa_chip_intr_establish,
|
|
|
|
pcic_isa_chip_intr_disestablish,
|
|
|
|
|
|
|
|
pcic_chip_socket_enable,
|
|
|
|
pcic_chip_socket_disable,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
pcic_isapnp_match(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
{
|
1999-03-22 13:00:09 +03:00
|
|
|
int pri, variant;
|
1999-03-22 12:44:12 +03:00
|
|
|
|
1999-03-22 13:00:09 +03:00
|
|
|
pri = isapnp_devmatch(aux, &isapnp_pcic_devinfo, &variant);
|
|
|
|
if (pri && variant > 0)
|
|
|
|
pri = 0;
|
|
|
|
return (pri);
|
1998-06-07 22:28:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pcic_isapnp_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pcic_softc *sc = (void *) self;
|
2000-02-23 20:22:11 +03:00
|
|
|
struct pcic_isa_softc *isc = (void *) self;
|
1998-06-07 22:28:31 +04:00
|
|
|
struct isapnp_attach_args *ipa = aux;
|
|
|
|
isa_chipset_tag_t ic = ipa->ipa_ic;
|
|
|
|
bus_space_tag_t iot = ipa->ipa_iot;
|
|
|
|
bus_space_tag_t memt = ipa->ipa_memt;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
bus_space_handle_t memh;
|
|
|
|
bus_addr_t maddr;
|
|
|
|
int msize;
|
|
|
|
int tmp1;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
if (isapnp_config(iot, memt, ipa)) {
|
|
|
|
printf("%s: error in region allocation\n", sc->dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("%s: %s %s", sc->dev.dv_xname, ipa->ipa_devident,
|
|
|
|
ipa->ipa_devclass);
|
|
|
|
|
|
|
|
/* sanity check that we get at least one hunk of IO space.. */
|
|
|
|
if (ipa->ipa_nio < 1) {
|
|
|
|
printf("%s: failed to get one chunk of i/o space\n",
|
|
|
|
sc->dev.dv_xname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Find i/o space. */
|
|
|
|
ioh = ipa->ipa_io[0].h;
|
|
|
|
|
|
|
|
/* sanity check to make sure we have a real PCIC there.. */
|
|
|
|
bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SA + PCIC_IDENT);
|
|
|
|
tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
|
|
|
|
printf("(ident 0x%x", tmp1);
|
|
|
|
if (pcic_ident_ok(tmp1)) {
|
|
|
|
printf(" OK)");
|
|
|
|
} else {
|
|
|
|
printf(" Not OK)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
msize = 0x4000;
|
|
|
|
if (isa_mem_alloc (memt, msize, msize, 0, 0,
|
|
|
|
&maddr, &memh)) {
|
|
|
|
printf(": can't alloc mem space\n");
|
|
|
|
return;
|
|
|
|
}
|
1998-06-23 08:19:23 +04:00
|
|
|
printf(": using iomem 0x%lx iosiz 0x%x", maddr, msize);
|
1998-06-07 22:28:31 +04:00
|
|
|
sc->membase = maddr;
|
|
|
|
sc->subregionmask = (1 << (msize / PCIC_MEM_PAGESIZE)) - 1;
|
|
|
|
|
2000-02-23 20:22:11 +03:00
|
|
|
isc->sc_ic = ic;
|
1998-06-07 22:28:31 +04:00
|
|
|
sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;
|
|
|
|
|
|
|
|
sc->iot = iot;
|
|
|
|
sc->ioh = ioh;
|
|
|
|
sc->memt = memt;
|
|
|
|
sc->memh = memh;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* allocate an irq. it will be used by both controllers. I could
|
|
|
|
* use two different interrupts, but interrupts are relatively
|
|
|
|
* scarce, shareable, and for PCIC controllers, very infrequent.
|
|
|
|
*/
|
|
|
|
|
2000-02-02 01:39:51 +03:00
|
|
|
if (ipa->ipa_nirq > 0)
|
1998-06-07 22:28:31 +04:00
|
|
|
sc->irq = ipa->ipa_irq[0].num;
|
2000-02-02 01:39:51 +03:00
|
|
|
else
|
2001-09-26 05:17:16 +04:00
|
|
|
sc->irq = ISACF_IRQ_DEFAULT;
|
2000-02-02 01:39:51 +03:00
|
|
|
|
1998-06-07 22:28:31 +04:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
pcic_attach(sc);
|
2000-02-02 01:39:51 +03:00
|
|
|
pcic_isa_bus_width_probe(sc, iot, ioh, ipa->ipa_io[0].base,
|
|
|
|
ipa->ipa_io[0].length);
|
1998-06-07 22:28:31 +04:00
|
|
|
pcic_attach_sockets(sc);
|
2000-02-02 01:39:51 +03:00
|
|
|
config_interrupts(self, pcic_isa_config_interrupts);
|
1998-06-07 22:28:31 +04:00
|
|
|
}
|