summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>1998-09-11 11:08:18 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>1998-09-11 11:08:18 +0000
commita9b5705d81e36e01ea0f1cdff60fba61f20366e8 (patch)
tree171324faec93feb22c80574f870b6c8c9f45e451 /sys
parent575fae519cc951e293c36f2de22b293eb27ddd67 (diff)
Remove unneeded files from the previous pcmcia framework.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/isa/pcmcia_isa.c342
-rw-r--r--sys/dev/isa/pcmcia_pcic.c1065
2 files changed, 0 insertions, 1407 deletions
diff --git a/sys/dev/isa/pcmcia_isa.c b/sys/dev/isa/pcmcia_isa.c
deleted file mode 100644
index 6c6592d910e..00000000000
--- a/sys/dev/isa/pcmcia_isa.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/* $OpenBSD: pcmcia_isa.c,v 1.10 1997/03/01 22:42:57 niklas Exp $ */
-/*
- * Copyright (c) 1995,1996 John T. Kohl. All rights reserved.
- * Copyright (c) 1994 Stefan Grefen. 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 Charles Hannum.
- * 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.
- *
- */
-
-/* TODO add modload support and loadable lists of devices */
-/* How to do cards with more than one function (modem/ethernet ..) */
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/malloc.h>
-#include <sys/device.h>
-#include <vm/vm.h>
-
-#include <machine/bus.h>
-
-#include <dev/pcmcia/pcmciavar.h>
-#include <dev/pcmcia/pcmciareg.h>
-
-#include <dev/isa/isareg.h>
-#include <dev/isa/isavar.h>
-#include <dev/ic/i8042reg.h>
-#include <i386/isa/isa_machdep.h> /* XXX USES ISA HOLE DIRECTLY */
-
-#ifdef IBM_WD
-#define PCMCIA_ISA_DEBUG
-#endif
-
-#ifdef PCMCIA_ISA_DEBUG
-#define STATIC
-#else
-#define STATIC static
-#endif
-
-STATIC int pcmcia_isa_init __P((struct device *, struct cfdata *,
- void *, struct pcmcia_adapter *, int));
-STATIC int pcmcia_isa_search __P((struct device *, void *, cfprint_t));
-STATIC int pcmcia_isa_probe __P((struct device *, void *,
- void *, struct pcmcia_link *));
-STATIC int pcmcia_isa_config __P((struct pcmcia_link *, struct device *,
- struct pcmcia_conf *, struct cfdata *));
-STATIC int pcmcia_isa_unconfig __P((struct pcmcia_link *));
-
-struct pcmciabus_link pcmcia_isa_link = {
- pcmcia_isa_config,
- pcmcia_isa_unconfig,
- pcmcia_isa_probe,
- pcmcia_isa_search,
- pcmcia_isa_init
-};
-
-/* copy out the addr and length from machine specific attach struct */
-STATIC int
-pcmcia_isa_init(parent, cf, aux, pca, flag)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
- struct pcmcia_adapter *pca;
- int flag;
-{
- struct pcmciabus_attach_args *pa = aux;
-
-#ifdef PCMCIA_ISA_DEBUG
- if (parent != NULL)
- printf("PARENT %s\n", parent->dv_xname);
-#endif
- if (flag == 0) { /* match */
- pca->scratch_memsiz = pa->pba_msize;
- pca->scratch_memh = pa->pba_memh;
- pca->pa_memt = pa->pba_memt;
-#ifdef PCMCIA_ISA_DEBUG
- printf("pbaaddr %p maddr %x msize %x\n",
- pa, pa->pba_maddr, pa->pba_msize);
- printf("PCA %p mem %p size %d memt %x memh %x\n",
- pca, pca->scratch_mem, pca->scratch_memsiz,
- pca->pa_memt, pca->scratch_memh);
-#endif
- }
- return 1;
-}
-
-/* Ease some typing by providing a nice typedef. */
-typedef int (*probe_t) __P((struct device *, void *, void *,
- struct pcmcia_link *));
-
-/* probe and attach a device, the has to be configured already */
-STATIC int
-pcmcia_isa_probe(parent, match, aux, pc_link)
- struct device *parent;
- void *match;
- void *aux;
- struct pcmcia_link *pc_link;
-{
- struct device *dev = match;
- struct cfdata *cf = aux;
- struct isa_attach_args ia;
- struct pcmciadevs *pcs = pc_link->device;
- probe_t probe = (pcs != NULL) ? pcs->dev->pcmcia_probe : NULL;
-
- if (cf->cf_loc[6] != -1 && cf->cf_loc[6] != pc_link->slot) {
-#ifdef PCMCIA_ISA_DEBUG
- printf("- isa probe slot mismatch: cf %d <> link %d\n",
- cf->cf_loc[6], pc_link->slot);
-#endif
- return 0;
- }
-#if 0
- if (pcs == NULL || pcs->dev->pcmcia_probe == NULL) {
-#ifdef PCMCIA_ISA_DEBUG
- printf("- isa probe null proberoutine %p\n", pcs);
-#endif
- return 0;
- }
-#endif
- ia.ia_iobase = cf->cf_loc[0];
- ia.ia_iosize = cf->cf_loc[1] == -1 ? 0x666 : cf->cf_loc[1];
- ia.ia_maddr = cf->cf_loc[2];
- ia.ia_msize = cf->cf_loc[3];
- ia.ia_irq = cf->cf_loc[4] == 2 ? 9 : cf->cf_loc[4] ;
- ia.ia_drq = cf->cf_loc[5];
- ia.ia_iot = pc_link->bus->sc_iot;
- ia.ia_memt = pc_link->bus->sc_memt;
-
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcmcia probe %x %x %p\n", ia.ia_iobase, ia.ia_irq,
- probe == NULL ? cf->cf_attach->ca_match : probe);
- printf("parentname = %s\n", parent->dv_xname);
- printf("devname = %s\n", dev->dv_xname);
- printf("driver name = %s\n", cf->cf_driver->cd_name);
-#endif
- if ((probe == NULL ? (*cf->cf_attach->ca_match)(parent, dev, &ia) :
- (*probe)(parent, dev, &ia, pc_link)) > 0) {
- extern int isaprint __P((void *, const char *));
-
- config_attach(parent, dev, &ia, isaprint);
-#ifdef PCMCIA_ISA_DEBUG
- printf("biomask %x netmask %x ttymask %x\n",
- (u_short) imask[IPL_BIO], (u_short) imask[IPL_NET],
- (u_short) imask[IPL_TTY]);
-#endif
- return 1;
- }
- else if (parent->dv_cfdata->cf_driver->cd_indirect == 0)
- free(dev, M_DEVBUF);
- return 0;
-}
-
-/*
- * Modify a pcmcia_conf struct to match the config entry. Pc_cf was filled
- * with config data from the card and may be modified before and after the
- * call to pcmcia_isa_config. Unless the FIXED_WIN flag is set we assume
- * contiguous windows and shift according to the offset for the first not
- * fixed window
- */
-STATIC int
-pcmcia_isa_config(pc_link, self, pc_cf, cf)
- struct pcmcia_link *pc_link;
- struct device *self;
- struct pcmcia_conf *pc_cf;
- struct cfdata *cf;
-{
- struct isa_attach_args ia;
- struct pcmciadevs *pcs = pc_link->device;
-
- ia.ia_iobase = cf->cf_loc[0];
- ia.ia_iosize = 0x666;
- ia.ia_maddr = cf->cf_loc[2];
- ia.ia_msize = cf->cf_loc[3];
- ia.ia_irq = cf->cf_loc[4];
- ia.ia_drq = cf->cf_loc[5];
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcmcia_isa_config iobase=%x maddr=%x msize=%x irq=%d drq=%d slot=%d\n",
- ia.ia_iobase, ISA_HOLE_VADDR(ia.ia_maddr), ia.ia_msize,
- ia.ia_irq, ia.ia_drq, cf->cf_loc[6]);
-#endif
-
- if (pcs && strcmp(pcs->devname, self->dv_cfdata->cf_driver->cd_name)) {
-#ifdef PCMCIA_ISA_DEBUG
- printf("- wrong driver %s vs %s\n", pcs->devname,
- self->dv_cfdata->cf_driver->cd_name);
-#endif
- return ENODEV;
- }
-
- if (ia.ia_irq != IRQUNK) {
- int irq = 1 << ia.ia_irq;
- /*
- * This is tricky irq 9 must match irq 2 in a device mask and
- * configured irq 9 must match irq 2
- */
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcmcia_isa_config irq=%x num=%x mask=%x and=%x\n", irq,
- 1 << pc_cf->irq_num, pc_cf->irq_mask,
- irq & pc_cf->irq_mask);
-#endif
- if (irq != (1 << pc_cf->irq_num) &&
- !(irq == (1 << 9) && pc_cf->irq_num == 2)) {
- if (irq == (1 << 9) || irq == (1 << 2))
- irq = (1 << 9) | (1 << 2);
- if ((irq & pc_cf->irq_mask) == 0) {
- printf("%s: slot %d requested irq %d, avail_mask %x\n",
- self->dv_parent->dv_xname,
- pc_link->slot,
- ia.ia_irq,
- pc_cf->irq_mask);
- return ENODEV;
- }
- /* 2 is 9 is 2 ... */
- irq&=~(1 << 2);
- cf->cf_loc[4] = pc_cf->irq_num = ffs(irq) - 1;
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcmcia_isa_config modify num=%x\n",
- pc_cf->irq_num);
-#endif
- }
- }
- if (ia.ia_iobase != IOBASEUNK) {
- int i;
- int offs = 0;
- if (pc_cf->iowin == 0)
- return 0;
- for (i = 0; i < pc_cf->iowin; i++) {
- if (pc_cf->io[i].flags & PCMCIA_FIXED_WIN)
- continue;
- if (offs == 0) {
- if (pc_cf->io[i].start != ia.ia_iobase) {
- offs = ia.ia_iobase -
- pc_cf->io[i].start;
- } else
- break;
- }
- pc_cf->io[i].start += offs;
- }
- } else
- pc_cf->iowin = 0;
- if (ia.ia_maddr != MADDRUNK && ia.ia_msize) {
- int i;
- unsigned long offs = 0;
- int mlen = ia.ia_msize;
- int maddr = (int) ISA_HOLE_VADDR(ia.ia_maddr);
-
- if (pc_cf->memwin == 0)
- return ENODEV;
-
-#ifdef PCMCIA_ISA_DEBUG
- printf("Doing ia=%x ma=%x ms=%d\n", ia.ia_maddr,
- maddr, ia.ia_msize);
-#endif
- for (i = 0; i < pc_cf->memwin && mlen > 0; i++) {
-#ifdef PCMCIA_ISA_DEBUG
- printf("Doing i=%d st=%x len=%d, flags=%x offs=%d mlen=%d\n",
- i, pc_cf->mem[i].start, pc_cf->mem[i].len,
- pc_cf->mem[i].flags, offs, mlen);
-#endif
- if (pc_cf->mem[i].flags & PCMCIA_FIXED_WIN)
- continue;
- if (offs == 0) {
- if (pc_cf->mem[i].start != maddr) {
- offs = maddr - pc_cf->mem[i].start;
- } else
- break;
- }
- mlen -= pc_cf->mem[i].len;
- if (mlen < 0)
- pc_cf->mem[i].len += mlen;
- pc_cf->mem[i].start += offs;
- }
- } else
- pc_cf->memwin = 0;
- return 0;
-}
-
-
-STATIC int
-pcmcia_isa_unconfig(pc_link)
- struct pcmcia_link *pc_link;
-{
-#if 0
- if (pc_link && pc_link->intr > 0) {
- /* THIS IS A GUESS ... TODO check all possible drivers */
- struct softc {
- struct device sc_dev;
- void *sc_ih;
- bus_space_tag_t sc_iot;
- bus_space_tag_t sc_memt;
- } *sc = pc_link->devp;
- if (sc)
- isa_intr_disestablish(sc->sc_ic, sc->sc_ih);
- }
-#endif
- return 0;
-}
-
-/* Searches for for configured devices on the pcmciabus */
-STATIC int
-pcmcia_isa_search(parent, aux, print)
- struct device *parent;
- void *aux;
- cfprint_t print;
-{
- static char *msgs[3] = {"", " not configured\n", " unsupported\n"};
-
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcmcia_isa_search\n");
-#endif
- if (config_search(pcmcia_configure, parent, aux) != NULL)
- return 1;
-
- if (print) {
- int i;
- i = (*print) (aux, parent->dv_xname);
- printf(msgs[i]);
- }
- return 0;
-}
diff --git a/sys/dev/isa/pcmcia_pcic.c b/sys/dev/isa/pcmcia_pcic.c
deleted file mode 100644
index 22df9794bee..00000000000
--- a/sys/dev/isa/pcmcia_pcic.c
+++ /dev/null
@@ -1,1065 +0,0 @@
-/* $OpenBSD: pcmcia_pcic.c,v 1.15 1997/04/16 23:29:28 niklas Exp $ */
-
-/*
- * Copyright (c) 1995, 1996 John T. Kohl
- * 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. 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.
- *
- */
-
-/*
- * Device Driver for Intel 82365 based pcmcia slots
- *
- * Copyright (c) 1994 Stefan Grefen. This software may be used, modified,
- * copied, distributed, and sold, in both source and binary form provided that
- * the above copyright and these terms are retained. Under no circumstances is
- * the author responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with its use.
- *
- */
-
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/kernel.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/mbuf.h>
-#include <sys/device.h>
-#include <sys/proc.h>
-#include <sys/user.h>
-
-#include <machine/bus.h>
-
-#include <dev/isa/isavar.h>
-#include <dev/ic/i82365reg.h>
-
-#include <dev/pcmcia/pcmciavar.h>
-#include <dev/pcmcia/pcmciareg.h>
-
-#ifdef IBM_WD
-#define PCIC_DEBUG 0xf
-#endif
-#if PCIC_DEBUG
-#define PCDMEM 0x01
-#define PCDIO 0x02
-#define PCDINTR 0x04
-#define PCDSERV 0x08
-#define PCDRW 0x10
-#define PCDCONF 0x20
-int pcic_debug = PCIC_DEBUG;
-#define PDEBUG(a) (pcic_debug & (a))
-#else
-#define PDEBUG(a) (0)
-#endif
-
-/*
- * pcic_softc: per line info and status
- */
-#define MAX_IOSECTION 2
-#define MAX_MEMSECTION 5
-struct slot {
- int status;
-#define SLOT_EMPTY 0x01
-#define SLOT_PROBING 0x02
-#define SLOT_INUSE 0x04
- u_short io_addr[MAX_IOSECTION], io_len[MAX_IOSECTION];
- u_short io_used[MAX_IOSECTION];
- caddr_t mem_caddr[MAX_MEMSECTION];
- u_int mem_haddr[MAX_MEMSECTION];
- u_int mem_len[MAX_MEMSECTION], mem_used[MAX_MEMSECTION];
- u_short region_flag;
- u_short ioctl_flag;
- u_short irq;
- u_short pow;
- u_short irqt;
- u_short reg_off;/* 2 chips share an address */
- void (*handler)(struct slot *, void *);
- void * handle_arg;
- struct pcmcia_link *link;
- struct pcic_softc *chip;
-};
-
-struct pcic_softc {
- struct device sc_dev;
- bus_space_tag_t sc_iot;
- bus_space_tag_t sc_memt;
- struct pcmcia_adapter sc_adapter;
- void *sc_ih;
- int sc_polltimo;
- int sc_pcic_irq;
- bus_space_handle_t sc_ioh;
- bus_space_handle_t sc_memh;
- u_short pcic_base; /* base port for each board */
- u_char chip_inf;
- struct slot slot[4]; /* treat up to 4 as on the same pcic */
-};
-#define pcic_parent(sc) ((struct pcicmaster_softc *)(sc)->sc_dev.dv_parent)
-
-int pcic_map_io __P((struct pcmcia_link *, u_int, u_int, int));
-int pcic_map_mem __P((struct pcmcia_link *, bus_space_tag_t, caddr_t,
- u_int, u_int, int));
-int pcic_map_intr __P((struct pcmcia_link *, int, int));
-int pcic_service __P((struct pcmcia_link *, int, void *, int));
-
-static struct pcmcia_funcs pcic_funcs = {
- pcic_map_io,
- pcic_map_mem,
- pcic_map_intr,
- pcic_service
-};
-
-int pcic_probe __P((struct device *, void *, void *));
-void pcic_attach __P((struct device *, struct device *, void *));
-int pcic_print __P((void *, const char *));
-
-int pcicmaster_probe __P((struct device *, void *, void *));
-void pcicmaster_attach __P((struct device *, struct device *, void *));
-int pcicmaster_print __P((void *, const char *));
-int pcic_intr __P((void *));
-
-extern struct pcmciabus_link pcmcia_isa_link;
-
-struct cfattach pcic_ca = {
- sizeof(struct pcic_softc), pcic_probe, pcic_attach,
-};
-
-struct cfdriver pcic_cd = {
- NULL, "pcic", DV_DULL
-};
-
-struct pcicmaster_softc {
- struct device sc_dev;
- isa_chipset_tag_t sc_ic;
- bus_space_tag_t sc_iot;
- bus_space_tag_t sc_memt;
- bus_space_handle_t sc_ioh;
- struct pcic_softc *sc_ctlrs[2];
- char sc_slavestate[2];
-#define SLAVE_NOTPRESENT 0
-#define SLAVE_FOUND 1
-#define SLAVE_CONFIGURED 2
-};
-
-struct cfattach pcicmaster_ca = {
- sizeof(struct pcicmaster_softc), pcicmaster_probe, pcicmaster_attach,
-};
-
-struct cfdriver pcicmaster_cd = {
- NULL, "pcicmaster", DV_DULL, 1
-};
-
-struct pcic_attach_args {
- int pia_ctlr; /* pcic ctlr number */
- isa_chipset_tag_t pia_ic; /* isa chipset tag */
- bus_space_tag_t pia_iot; /* bus chipset tag */
- bus_space_tag_t pia_memt; /* bus chipset tag */
- bus_space_handle_t pia_ioh; /* base i/o address */
- int pia_iosize; /* span of ports used */
- int pia_irq; /* interrupt request */
- int pia_drq; /* DMA request */
- int pia_maddr; /* physical i/o mem addr */
- u_int pia_msize; /* size of i/o memory */
-};
-
-static __inline u_char pcic_rd __P((struct slot *, int));
-static __inline void pcic_wr __P((struct slot *, int, int));
-static __inline int pcic_wait __P((struct slot *, int));
-
-static __inline u_char
-pcic_rd(slot, reg)
- struct slot *slot;
- int reg;
-{
- u_char res;
- bus_space_tag_t iot = slot->chip->sc_iot;
- bus_space_handle_t ioh = slot->chip->sc_ioh;
-
- if (PDEBUG(PCDRW))
- printf("pcic_rd(%x [%x %x]) = ", reg, slot->reg_off, ioh);
- bus_space_write_1(iot, ioh, 0, slot->reg_off + reg);
- delay(1);
- res = bus_space_read_1(iot, ioh, 1);
- if (PDEBUG(PCDRW))
- printf("%x\n", res);
- return res;
-}
-
-static __inline void
-pcic_wr(slot, reg, val)
- struct slot *slot;
- int reg, val;
-{
- bus_space_tag_t iot = slot->chip->sc_iot;
- bus_space_handle_t ioh = slot->chip->sc_ioh;
-
- bus_space_write_1(iot, ioh, 0, slot->reg_off + reg);
- delay(1);
- bus_space_write_1(iot, ioh, 1, val);
- if (PDEBUG(PCDRW)) {
- int res;
- delay(1);
- bus_space_write_1(iot, ioh, 0, slot->reg_off + reg);
- delay(1);
- res = bus_space_read_1(iot, ioh, 1);
- printf("pcic_wr(%x %x) = %x\n", reg, val, res);
- }
-}
-
-static __inline int
-pcic_wait(slot, i)
- struct slot *slot;
- int i;
-{
- while (i-- && ((pcic_rd(slot, PCIC_STATUS) & PCIC_READY) == 0))
- delay(500);
- return i;
-}
-
-int
-pcic_probe(parent, self, aux)
- struct device *parent;
- void *self;
- void *aux;
-{
- struct pcic_softc *pcic = self;
- struct pcicmaster_softc *pcicm = (struct pcicmaster_softc *)parent;
- struct pcic_attach_args *pia = aux;
- u_int chip_inf = 0, ochip_inf = 0;
- int first = 1;
- int i, j, maxslot;
-
- bzero(pcic->slot, sizeof(pcic->slot));
-
- if (PDEBUG(PCDCONF)) {
- printf("pcic_probe controller %d unit %d\n", pia->pia_ctlr,
- pcic->sc_dev.dv_unit);
- delay(2000000);
- }
- if (pcicm->sc_slavestate[pia->pia_ctlr] != SLAVE_FOUND)
- return 0;
- if (pcic->sc_dev.dv_cfdata->cf_loc[1] == -1 ||
- pcic->sc_dev.dv_cfdata->cf_loc[2] == 0)
- return 0;
-
- /*
- * select register offsets based on which controller we are.
- * 2 pcic controllers (w/ 2 slots each) possible at each
- * IO port location, for a total of 8 possible PCMCIA slots.
- *
- * for VLSI controllers, we probe up to 4 slots for the same chip type,
- * and handle them on one controller. This is slightly
- * cheating (two separate pcic's are required for 4 slots, according
- * to the i82365 spec).
- *
- * For other controllers, we only take up to 2 slots.
- */
- pcic->sc_ioh = pia->pia_ioh;
- pcic->sc_iot = pia->pia_iot;
- pcic->sc_memt = pia->pia_memt;
- pcic->sc_adapter.nslots = 0;
- maxslot = 2;
- for (i = j = 0; i < maxslot; i++) {
- pcic->slot[j].reg_off = 0x80 * pia->pia_ctlr + 0x40 * i;
- pcic->slot[j].chip = pcic;
-
- chip_inf = pcic_rd(&pcic->slot[j], PCIC_ID_REV);
- if (PDEBUG(PCDCONF)) {
- printf("pcic_probe read info %x\n", chip_inf);
- delay(2000000);
- }
- if (!first && ochip_inf != chip_inf)
- continue; /* don't attach, it's different */
- ochip_inf = chip_inf;
- switch (chip_inf) {
- case PCIC_INTEL0:
- pcic->chip_inf = PCMICA_CHIP_82365_0;
- goto ok;
- case PCIC_INTEL1:
- pcic->chip_inf = PCMICA_CHIP_82365_1;
- goto ok;
- case PCIC_IBM1:
- pcic->chip_inf = PCMICA_CHIP_IBM_1;
- goto ok;
- case PCIC_146FC6:
- pcic->chip_inf = PCMICA_CHIP_146FC6;
- maxslot = 4;
- goto ok;
- case PCIC_146FC7:
- pcic->chip_inf = PCMICA_CHIP_146FC7;
- maxslot = 4;
- goto ok;
- case PCIC_IBM2:
- pcic->chip_inf = PCMICA_CHIP_IBM_2;
-ok:
- if (first) {
- pcic->sc_adapter.adapter_softc = (void *)pcic;
- pcic->sc_adapter.chip_link = &pcic_funcs;
- pcic->sc_adapter.bus_link = &pcmcia_isa_link;
- pcicm->sc_ctlrs[pia->pia_ctlr] = pcic;
- pcicm->sc_slavestate[pia->pia_ctlr] =
- SLAVE_CONFIGURED;
- first = 0;
- }
- pcic->sc_adapter.nslots++;
- j++;
- default:
- if (PDEBUG(PCDCONF)) {
- printf("found ID %x at pcic%d position\n",
- chip_inf & 0xff, pcic->sc_dev.dv_unit);
- }
- continue;
- }
- }
- if (pcic->sc_adapter.nslots != 0) {
- if (bus_space_map(pia->pia_memt,
- pcic->sc_dev.dv_cfdata->cf_loc[1],
- pcic->sc_dev.dv_cfdata->cf_loc[2], 0, &pcic->sc_memh))
- return 0;
- return 1;
- }
- if (PDEBUG(PCDCONF)) {
- printf("pcic_probe failed\n");
- delay(2000000);
- }
- return 0;
-}
-
-int
-pcic_print(aux, name)
- void *aux;
- const char *name;
-{
- if (name != NULL)
- printf("%s: pcmciabus ", name);
- return UNCONF;
-}
-
-void
-pcic_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct pcic_softc *pcic = (void *) self;
- struct pcic_attach_args *pia = aux;
- struct pcmciabus_attach_args pba;
- struct slot *slot;
- int i;
- static char *pcic_names[] = {
- "Intel 82365sl Rev. 0",
- "Intel 82365sl Rev. 1",
- "IBM 82365sl clone Rev. 1",
- "IBM 82365sl clone Rev. 2",
- "VL82146 (82365sl clone) Rev. 6",
- "VL82146 (82365sl clone) Rev. 7" };
- if (PDEBUG(PCDCONF)) {
- printf("pcic_attach found\n");
- delay(2000000);
- }
- pia->pia_irq = self->dv_cfdata->cf_loc[0];
- pia->pia_maddr = self->dv_cfdata->cf_loc[1];
- pia->pia_msize = self->dv_cfdata->cf_loc[2];
-
- printf(": %s slots %d-%d iomem %x-%x",
- pcic_names[pcic->chip_inf - PCMICA_CHIP_82365_0],
- pcic->sc_dev.dv_unit * 2,
- pcic->sc_dev.dv_unit * 2 + pcic->sc_adapter.nslots - 1,
- pia->pia_maddr, pia->pia_maddr + pia->pia_msize - 1);
- if (pia->pia_irq != IRQUNK)
- printf(" irq %d\n", pia->pia_irq);
- else
- printf("\n");
- if (PDEBUG(PCDCONF))
- delay(2000000);
-
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcic %p slots %p,%p\nisaaddr %p ports %x size %d irq %d drq %d maddr %x msize %x\n",
- pcic, &pcic->slot[0], &pcic->slot[1],
- pia, pia->pia_ioh, pia->pia_iosize,
- pia->pia_irq, pia->pia_drq, pia->pia_maddr, pia->pia_msize);
- if (PDEBUG(PCDCONF))
- delay(2000000);
-#endif
-
- /* enable interrupts on events */
- if (pia->pia_irq != IRQUNK)
- pcic->sc_pcic_irq = pia->pia_irq;
- else
- pcic->sc_pcic_irq = 0;
-
- for (i = 0; i < pcic->sc_adapter.nslots; i++) {
- slot = &pcic->slot[i];
- /*
- * Arrange for card status change interrupts
- * to be steered to specified IRQ.
- * Treat all cards as I/O cards for the moment so we get
- * sensible card change interrupt codes (besides, we don't
- * support memory cards :)
- */
- pcic_wr(slot, PCIC_STAT_INT,
- (pcic->sc_pcic_irq << 4) |
- PCIC_CDTCH | PCIC_IOCARD);
- slot->irq = pcic_rd(slot, PCIC_INT_GEN) & ~PCIC_INTR_ENA;
- pcic_wr(slot, PCIC_INT_GEN, slot->irq);
- (void) pcic_rd(slot, PCIC_STAT_CHG);
- }
- if (pia->pia_irq == IRQUNK) {
- pcic->sc_polltimo = hz/2;
- timeout((void (*)(void *))pcic_intr, pcic, pcic->sc_polltimo);
- } else {
- pcic->sc_ih = isa_intr_establish(pia->pia_ic, pia->pia_irq,
- IST_EDGE, IPL_PCMCIA, pcic_intr, pcic, pcic->sc_dev.dv_xname);
- pcic->sc_polltimo = 0;
- }
- /*
- * Probe the pcmciabus at this controller.
- */
- pba.pba_iot = pia->pia_iot;
- pba.pba_memt = pia->pia_memt;
- pba.pba_memh = pcic->sc_memh;
- pba.pba_maddr = pia->pia_maddr;
- pba.pba_msize = pia->pia_msize;
- pba.pba_aux = &pcic->sc_adapter;
-#ifdef PCMCIA_DEBUG
- printf("config_found(%p, %p, %p)\n",
- self, &pba, pcic_print);
-#endif
- config_found(self, (void *)&pba, pcic_print);
-}
-
-int
-pcic_intr(arg)
- void *arg;
-{
- struct pcic_softc *pcic = arg;
- u_char statchg, intgen;
- register int i;
-
-#ifdef PCMCIA_PCIC_DEBUG
- if (pcic->sc_polltimo == 0)
- printf("%s: interrupt:", pcic->sc_dev.dv_xname);
-#endif
- for (i = 0; i < pcic->sc_adapter.nslots; i++) {
- struct pcmcia_link *link = pcic->slot[i].link;
- statchg = pcic_rd(&pcic->slot[i], PCIC_STAT_CHG);
- if (statchg == 0)
- continue;
- intgen = pcic_rd(&pcic->slot[i], PCIC_INT_GEN);
-#ifdef PCMCIA_PCIC_DEBUG
- if (intgen & PCIC_IOCARD) {
- printf("%s: slot %d iocard status %s%s\n",
- pcic->sc_dev.dv_xname, i,
- statchg & PCIC_STCH ? "statchange " : "",
- statchg & PCIC_CDTCH ? "cardchange" : "");
- } else {
- printf("%s: slot %d memcard status %x\n",
- pcic->sc_dev.dv_xname, i, statchg);
- }
-#endif
- if ((statchg & PCIC_CDTCH) &&
- (link->flags & PCMCIA_SLOT_OPEN) == 0) {
-#if 0
- if (pcic->slot[i].status & SLOT_INUSE) {
- pcmcia_unconfigure(link);
- } else {
- if (link) {
- link->fordriver = NULL;
- pcmcia_probe_bus(link, 0, link->slot,
- NULL);
- }
- }
-#endif
- }
- if (link && (link->flags & PCMCIA_SLOT_OPEN)) {
- link->flags |= PCMCIA_SLOT_EVENT;
- selwakeup(&link->pcmcialink_sel);
- }
- if (pcic->slot[i].handler == NULL)
- continue;
- (*pcic->slot[i].handler)(&pcic->slot[i],
- pcic->slot[i].handle_arg);
- }
- if (pcic->sc_polltimo)
- timeout((void (*)(void *))pcic_intr, pcic, pcic->sc_polltimo);
- return 1;
-}
-
-int
-pcic_map_io(link, start, len, flags)
- struct pcmcia_link *link;
- u_int start, len;
- int flags;
-{
- struct pcic_softc *sc = link->adapter->adapter_softc;
- struct slot *slot;
- if (link->slot >= sc->sc_adapter.nslots)
- return ENXIO;
- slot = &sc->slot[link->slot];
-
- len--;
- if (PDEBUG(PCDIO)) {
- printf("pcic_map_io %x %x %x\n", start, len, flags);
- }
- if (!(flags & PCMCIA_UNMAP)) {
- u_int stop;
- int window;
- int winid;
- int ioflags;
-
- if (flags & PCMCIA_LAST_WIN) {
- window = MAX_IOSECTION - 1;
- } else if (flags & PCMCIA_FIRST_WIN) {
- window = 0;
- } else if (flags & PCMCIA_ANY_WIN) {
- for (window = 0; window < MAX_IOSECTION; window++) {
- if (slot->io_used[window] == 0)
- break;
- if (window >= MAX_IOSECTION)
- return EBUSY;
- }
- } else {
- window = flags & 0xf;
- if (window >= MAX_IOSECTION)
- return EINVAL;
- }
- slot->status |= SLOT_INUSE;
- slot->io_used[window] = 1;
- winid = window * 0x4 + 0x08;
- stop = start + len;
-
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_LOW,
- (u_long) start & 0xff);
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_HIGH,
- ((u_long) start >> 8) & 0xff);
-
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_LOW,
- stop & 0xff);
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_HIGH,
- (stop >> 8) & 0xff);
- flags &= (PCMCIA_MAP_8 | PCMCIA_MAP_16);
- switch (flags) {
- case PCMCIA_MAP_8:
- ioflags = PCIC_IO0_0WS;
- break;
- case PCMCIA_MAP_16:
- ioflags = PCIC_IO0_16BIT;
- break;
- default:
- ioflags = PCIC_IO0_CS16;
- break;
- }
-
- if (window == 1) {
- ioflags <<= 4;
- slot->ioctl_flag &= ~(3 << 4);
- }
- else {
- slot->ioctl_flag &= ~3;
- }
-
- delay(1000);
-
- pcic_wr(slot, PCIC_IOCTL, slot->ioctl_flag |= ioflags);
- pcic_wr(slot, PCIC_ADDRWINE,
- slot->region_flag |= (0x40 << window));
- slot->io_addr[window] = start;
- slot->io_len[window] = len;
- delay(1000);
- return 0;
- } else {
- int window;
- int winid;
- if (flags & PCMCIA_LAST_WIN) {
- window = MAX_IOSECTION - 1;
- } else if (flags & PCMCIA_FIRST_WIN) {
- window = 0;
- } else if (flags & PCMCIA_ANY_WIN) {
- for (window = 0; window < MAX_IOSECTION; window++) {
- if (slot->io_addr[window] == start)
- if (len == -1 ||
- slot->io_len[window] == len)
- break;
- }
- if (window >= MAX_IOSECTION)
- return EINVAL;
- } else {
- window = flags & 0xf;
- if (window >= MAX_IOSECTION)
- return EINVAL;
- }
- slot->status &= ~SLOT_INUSE;
- winid = window * 0x4 + 0x08;
-
- pcic_wr(slot, PCIC_ADDRWINE,
- slot->region_flag &= ~(0x40 << window));
- delay(1000);
- pcic_wr(slot, PCIC_IOCTL,
- slot->ioctl_flag &= ~(0xf << window));
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_LOW, 0);
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_HIGH, 0);
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_LOW, 0);
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_HIGH, 0);
-
- slot->io_addr[window] = start;
- slot->io_len[window] = len;
- return 0;
- }
-}
-
-int
-pcic_map_mem(link, memt, haddr, start, len, flags)
- struct pcmcia_link *link;
- bus_space_tag_t memt;
- caddr_t haddr;
- u_int start, len;
- int flags;
-{
- vm_offset_t physaddr;
- struct pcic_softc *sc = link->adapter->adapter_softc;
- struct slot *slot;
-
- if (link->slot >= sc->sc_adapter.nslots)
- return ENXIO;
-
- slot = &sc->slot[link->slot];
-
- if (flags & PCMCIA_PHYSICAL_ADDR)
- physaddr = (vm_offset_t)haddr;
- else
- physaddr = pmap_extract(pmap_kernel(), (vm_offset_t)haddr);
- if (PDEBUG(PCDMEM))
- printf("pcic_map_mem %p %x %x %x %x\n", haddr, physaddr, start,
- len, flags);
-
- physaddr >>= 12;
- start >>= 12;
- len = (len - 1) >> 12;
-
- if (!(flags & PCMCIA_UNMAP)) {
- u_int offs;
- u_int stop;
- int window;
- int winid;
-
- if (flags & PCMCIA_LAST_WIN) {
- window = MAX_MEMSECTION - 1;
- } else if (flags & PCMCIA_FIRST_WIN) {
- window = 0;
- } else if (flags & PCMCIA_ANY_WIN) {
- for (window = 0; window < MAX_MEMSECTION; window++) {
- if (slot->mem_used[window] == 0)
- break;
- if (window >= MAX_MEMSECTION)
- return EBUSY;
- }
- } else {
- window = flags & 0xf;
- if (window >= MAX_MEMSECTION)
- return EINVAL;
- }
- slot->mem_used[window] = 1;
-
- offs = (start - (u_long) physaddr) & 0x3fff;
- if (PDEBUG(PCDMEM))
- printf("mapmem 2:%x %x %x\n", offs, physaddr + offs,
- start);
-
- stop = (u_long)physaddr + len;
-
- winid = window * 0x8 + 0x10;
-
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_LOW,
- (u_long)physaddr & 0xff);
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_HIGH,
- (((u_long) physaddr >> 8) & 0x3f) | /* PCIC_ZEROWS| */
- ((flags & PCMCIA_MAP_16) ? PCIC_DATA16 : 0));
-
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_LOW, stop & 0xff);
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_HIGH,
- PCIC_MW1 | ((stop >> 8) & 0x3f));
-
-
- pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_LOW, offs & 0xff);
- pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_HIGH,
- ((offs >> 8) & 0x3f) |
- ((flags & PCMCIA_MAP_ATTR) ? PCIC_REG : 0));
- delay(1000);
-
- pcic_wr(slot, PCIC_ADDRWINE,
- slot->region_flag |= ((1 << window) | PCIC_MEMCS16));
- slot->mem_caddr[window] = (caddr_t)physaddr;
- slot->mem_haddr[window] = start;
- slot->mem_len[window] = len;
- delay(1000);
- return 0;
- } else {
- int window;
- int winid;
-
- if (flags & PCMCIA_LAST_WIN) {
- window = MAX_MEMSECTION - 1;
- } else if (flags & PCMCIA_FIRST_WIN) {
- window = 0;
- } else if (flags & PCMCIA_ANY_WIN) {
- for (window = 0; window < MAX_MEMSECTION; window++) {
- if ((slot->mem_caddr[window] ==
- (caddr_t)physaddr) &&
- ((start == -1) ||
- (slot->mem_haddr[window] == start)) &&
- ((len == -1) ||
- (slot->mem_len[window] == len)))
- break;
- }
- if (window >= MAX_MEMSECTION)
- return EINVAL;
- } else {
- window = flags & 0xf;
- if (window >= MAX_MEMSECTION)
- return EINVAL;
- }
- winid = window * 0x8 + 0x10;
-
- slot->region_flag &= (~(1 << window));
- pcic_wr(slot, PCIC_ADDRWINE, slot->region_flag);
- delay(1000);
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_LOW, 0);
- pcic_wr(slot, winid | PCIC_START | PCIC_ADDR_HIGH, 0);
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_LOW, 0);
- pcic_wr(slot, winid | PCIC_END | PCIC_ADDR_HIGH, 0);
- pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_LOW, 0);
- pcic_wr(slot, winid | PCIC_MOFF | PCIC_ADDR_HIGH, 0);
- slot->mem_caddr[window] = 0;
- slot->mem_haddr[window] = 0;
- slot->mem_len[window] = 0;
- slot->mem_used[window] = 0;
- return 0;
- }
-}
-
-int
-pcic_map_intr(link, irq, flags)
- struct pcmcia_link *link;
- int irq, flags;
-{
- struct pcic_softc *sc = link->adapter->adapter_softc;
- struct slot *slot;
-
- if (link->slot >= sc->sc_adapter.nslots)
- return ENXIO;
-
- slot = &sc->slot[link->slot];
-
- if (PDEBUG(PCDINTR))
- printf("pcic_map_intr %x %x\n", irq, flags);
-
- if (flags & PCMCIA_UNMAP) {
- slot->irq &= ~(PCIC_INT_MASK|PCIC_INTR_ENA);
- pcic_wr(slot, PCIC_INT_GEN, slot->irq);
- } else {
- if (irq < 2 || irq > 15 || irq == 6 || irq == 8 || irq == 13)
- return EINVAL;
- if(irq==2)
- irq=9;
- slot->irq &= ~(PCIC_INTR_ENA|PCIC_INT_MASK);
- slot->irq |= irq | PCIC_CARDRESET; /* reset is inverted */
- pcic_wr(slot, PCIC_INT_GEN, slot->irq);
- }
- return 0;
-}
-
-
-int
-pcic_service(link, opcode, arg, flags)
- struct pcmcia_link *link;
- int opcode;
- void *arg;
- int flags;
-{
- struct pcic_softc *sc = link->adapter->adapter_softc;
- struct slot *slot;
-
- if (link->slot >= sc->sc_adapter.nslots)
- return ENXIO;
-
- slot = &sc->slot[link->slot];
-
- slot->link = link; /* save it for later :) */
- switch (opcode) {
- case PCMCIA_OP_STATUS: {
- u_char cp;
- int *iarg = arg;
-
- if (PDEBUG(PCDSERV))
- printf("pcic_service(status)\n");
- cp = pcic_rd(slot, PCIC_STATUS);
- if (PDEBUG(PCDSERV))
- printf("status for slot %d %b\n", link->slot, cp,
- PCIC_STATUSBITS);
- *iarg = 0;
-#define DO_STATUS(cp, val, map) ((cp & val) == val ? map : 0)
- *iarg |= DO_STATUS(cp, PCIC_CD, PCMCIA_CARD_PRESENT);
- *iarg |= DO_STATUS(cp, PCIC_BVD, PCMCIA_BATTERY);
- *iarg |= DO_STATUS(cp, PCIC_MWP, PCMCIA_WRITE_PROT);
- *iarg |= DO_STATUS(cp, PCIC_READY, PCMCIA_READY);
- *iarg |= DO_STATUS(cp, PCIC_POW, PCMCIA_POWER);
- *iarg |= DO_STATUS(cp, PCIC_VPPV, PCMCIA_POWER_PP);
- return 0;
- }
- case PCMCIA_OP_WAIT: {
- int iarg = (int)arg;
- int i = iarg * 4;
-
- if (PDEBUG(PCDSERV))
- printf("pcic_service(wait)\n");
- i = pcic_wait(slot, i);
- if (PDEBUG(PCDSERV))
- printf("op99 %b %d\n",
- pcic_rd(slot, PCIC_STATUS), PCIC_STATUSBITS, i);
- if (i <= 0)
- return EIO;
- else
- return 0;
- }
- case PCMCIA_OP_RESET: {
- int force = ((int) arg) < 0;
- int iarg = abs((int) arg);
- int i = iarg * 4;
-
- if (PDEBUG(PCDSERV))
- printf("pcic_service(reset)\n");
- if (flags)
- slot->irq |= PCIC_IOCARD;
- else
- slot->irq &= ~PCIC_IOCARD; /* XXX? */
- pcic_wr(slot, PCIC_POWER, slot->pow &= ~PCIC_DISRST);
- slot->irq &= ~PCIC_CARDRESET;
- pcic_wr(slot, PCIC_INT_GEN, slot->irq);
- if (iarg == 0)
- return 0;
- delay(iarg);
- pcic_wr(slot, PCIC_POWER, slot->pow |= PCIC_DISRST);
- slot->irq |= PCIC_CARDRESET;
- pcic_wr(slot, PCIC_INT_GEN, slot->irq);
- delay(iarg);
- i = pcic_wait(slot, i);
- if (PDEBUG(PCDSERV))
- printf("opreset %d %b %d\n", force,
- pcic_rd(slot, PCIC_STATUS), PCIC_STATUSBITS, i);
- if (i <= 0)
- return EIO;
- else
- return 0;
- }
- case PCMCIA_OP_POWER: {
- int iarg = (int) arg;
- if (PDEBUG(PCDSERV))
- printf("pcic_service(power): ");
- if (flags & PCMCIA_POWER_ON) {
- int nv = (PCIC_DISRST|PCIC_OUTENA);
- pcic_wr(slot, PCIC_INT_GEN,
- slot->irq = PCIC_IOCARD);
- if(flags & PCMCIA_POWER_3V)
- nv |= PCIC_VCC3V;
- if(flags & PCMCIA_POWER_5V)
- nv |= PCIC_VCC5V;
- if(flags & PCMCIA_POWER_AUTO)
- nv |= PCIC_APSENA|PCIC_VCC5V|PCIC_VCC3V;
- slot->pow &= ~(PCIC_APSENA|PCIC_VCC5V|PCIC_VCC3V|
- PCIC_VPP12V|PCIC_VPP5V);
- slot->pow |= nv;
- pcic_wr(slot, PCIC_POWER, slot->pow);
-#if 0
- delay(iarg);
- slot->pow |= PCIC_OUTENA;
- pcic_wr(slot, PCIC_POWER, slot->pow);
-#endif
- delay(iarg);
- if (PDEBUG(PCDSERV))
- printf("on\n");
- } else {
- slot->pow &= ~(PCIC_APSENA|PCIC_VCC5V|PCIC_VCC3V);
- slot->pow &= ~(PCIC_DISRST|PCIC_OUTENA);
- pcic_wr(slot,PCIC_POWER, slot->pow);
- if (PDEBUG(PCDSERV))
- printf("off\n");
- }
- return 0;
- }
- case PCMCIA_OP_GETREGS: {
- struct pcic_regs *pi = arg;
- int i;
-
- if (PDEBUG(PCDSERV))
- printf("pcic_service(getregs)\n");
- pi->chip_vers = sc->chip_inf;
- for (i = 0; i < pi->cnt; i++)
- pi->reg[i].val = pcic_rd(slot, pi->reg[i].addr);
- return 0;
- }
- default:
- if (PDEBUG(PCDSERV))
- printf("pcic_service(%x)\n", opcode);
- return EINVAL;
- }
-}
-
-/*
- * Handle I/O space mapping for children. Thin layer.
- */
-int
-pcicmaster_probe(parent, self, aux)
- struct device *parent;
- void *self;
- void *aux;
-{
- struct pcicmaster_softc *pcicm = self;
- struct isa_attach_args *ia = aux;
- struct cfdata *cf = pcicm->sc_dev.dv_cfdata;
- bus_space_tag_t iot;
- bus_space_handle_t ioh;
- u_int chip_inf = 0;
- int i, j;
- int rval = 0;
- struct pcic_softc pcic; /* faked up for probing only */
-
- if (PDEBUG(PCDCONF)) {
- printf("pcicmaster_probe\n");
- delay(2000000);
- }
- iot = ia->ia_iot;
- if (bus_space_map(iot, ia->ia_iobase, PCIC_NPORTS, 0, &ioh))
- return (0);
- /*
- * Probe the slots for each of the possible child controllers,
- * and if any are there we return a positive indication.
- */
- pcic.sc_iot = iot;
- pcic.sc_ioh = ioh;
- for (i = 0; i < 2; i++) {
- bzero(pcic.slot, sizeof(pcic.slot));
- pcic.slot[0].chip = &pcic;
- pcic.slot[0].reg_off = i * 0x80;
- chip_inf = pcic_rd(&pcic.slot[0], PCIC_ID_REV);
- switch (chip_inf) {
- case PCIC_INTEL0:
- case PCIC_INTEL1:
- case PCIC_IBM1:
- case PCIC_146FC6:
- case PCIC_146FC7:
- case PCIC_IBM2:
- if (PDEBUG(PCDCONF)) {
- printf("pcicmaster_probe found, cf=%p\n", cf);
- delay(2000000);
- }
- pcicm->sc_slavestate[i] = SLAVE_FOUND;
- rval++;
- break;
- default:
- pcicm->sc_slavestate[i] = SLAVE_NOTPRESENT;
- if (PDEBUG(PCDCONF)) {
- printf("found ID %x at slave %d\n",
- chip_inf & 0xff, i);
- }
- break;
- }
- if (pcicm->sc_slavestate[i] != SLAVE_FOUND) {
- /* reset mappings .... */
- pcic_wr(&pcic.slot[0], PCIC_POWER,
- pcic.slot[0].pow=PCIC_DISRST);
- delay(1000);
- for (j = PCIC_INT_GEN; j < 0x40; j++) {
- pcic_wr(&pcic.slot[0], j, 0);
- }
- delay(10000);
- }
- }
- if (rval) {
- ia->ia_iosize = 2;
- pcicm->sc_ic = ia->ia_ic;
- pcicm->sc_iot = iot;
- pcicm->sc_memt = ia->ia_memt;
- pcicm->sc_ioh = ioh;
- } else
- bus_space_unmap(iot, ioh, PCIC_NPORTS);
- return rval;
-}
-
-void
-pcicmaster_attach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
-{
- struct pcicmaster_softc *pcicm = (void *)self;
- struct isa_attach_args *ia = aux;
- struct pcic_attach_args pia;
- int i;
-
- printf("\n");
- if (PDEBUG(PCDCONF)) {
- printf("pcicmaster_attach\n");
- delay(2000000);
- }
-#ifdef PCMCIA_ISA_DEBUG
- printf("pcicm %p isaaddr %p ports %x size %d irq %d drq %d maddr %x "
- "msize %x\n", pcicm, ia, ia->ia_iobase, ia->ia_iosize, ia->ia_irq,
- ia->ia_drq, ia->ia_maddr, ia->ia_msize);
- if (PDEBUG(PCDCONF))
- delay(2000000);
-#endif
- /* attach up to two PCICs at this I/O address */
- for (i = 0; i < 2; i++) {
- if (pcicm->sc_slavestate[i] == SLAVE_FOUND) {
- pia.pia_ctlr = i;
- /*
- * share the I/O space and memory mapping space.
- */
- pia.pia_ic = pcicm->sc_ic;
- pia.pia_iot = pcicm->sc_iot;
- pia.pia_memt = pcicm->sc_memt;
- pia.pia_ioh = pcicm->sc_ioh;
- pia.pia_iosize = ia->ia_iosize;
- pia.pia_drq = ia->ia_drq;
-#if 0
- pia.pia_irq = ia->ia_irq;
- pia.pia_irq = cf->cf_loc[0]; /* irq from master */
-#endif
- pia.pia_maddr = ia->ia_maddr + (ia->ia_msize / 2) * i;
- pia.pia_msize = ia->ia_msize / 2;
-
- config_found(self, &pia, pcicmaster_print);
- }
- }
-}
-
-int
-pcicmaster_print(aux, name)
- void *aux;
- const char *name;
-{
- if (name != NULL)
- printf("%s: master controller", name);
- return UNCONF;
-}