- Move all of the configurable parameters (alloc_iobase, alloc_iosize,

intr_alloc_mask) into one place, comment them, and defopt them.
- Rename pcic_intr_alloc_mask to pcic_isa_intr_alloc_mask, since it's
  an ISA-specific thing.
- When allocating/establishing the PCIC's interrupt (for card events),
  do error checking, and pay attention to the intr_alloc_mask.
This commit is contained in:
thorpej 1997-10-29 22:48:43 +00:00
parent c733020f4b
commit 5322570d8a
1 changed files with 59 additions and 31 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82365_isa.c,v 1.5 1997/10/29 21:33:16 thorpej Exp $ */ /* $NetBSD: i82365_isa.c,v 1.6 1997/10/29 22:48:43 thorpej Exp $ */
#define PCICISADEBUG #define PCICISADEBUG
@ -53,6 +53,52 @@
#include <dev/ic/i82365reg.h> #include <dev/ic/i82365reg.h>
#include <dev/ic/i82365var.h> #include <dev/ic/i82365var.h>
/*****************************************************************************
* Configurable parameters.
*****************************************************************************/
#include "opt_pcic_isa_alloc_iobase.h"
#include "opt_pcic_isa_alloc_iosize.h"
#include "opt_pcic_isa_intr_alloc_mask.h"
/*
* Default I/O allocation range. If both are set to non-zero, these
* values will be used instead. Otherwise, the code attempts to probe
* the bus width. Systems with 10 address bits should use 0x300 and 0xff.
* Systems with 12 address bits (most) should use 0x400 and 0xbff.
*/
#ifndef PCIC_ISA_ALLOC_IOBASE
#define PCIC_ISA_ALLOC_IOBASE 0
#endif
#ifndef PCIC_ISA_ALLOC_IOSIZE
#define PCIC_ISA_ALLOC_IOSIZE 0
#endif
int pcic_isa_alloc_iobase = PCIC_ISA_ALLOC_IOBASE;
int pcic_isa_alloc_iosize = PCIC_ISA_ALLOC_IOSIZE;
/*
* Default IRQ allocation bitmask. This defines the range of allowable
* IRQs for PCMCIA slots. Useful if order of probing would screw up other
* devices, or if PCIC hardware/cards have trouble with certain interrupt
* lines.
*
* We disable IRQ 10 by default, since some common laptops (namely, the
* NEC Versa series) reserve IRQ 10 for the docking station SCSI interface.
*/
#ifndef PCIC_ISA_INTR_ALLOC_MASK
#define PCIC_ISA_INTR_ALLOC_MASK 0xfbff
#endif
int pcic_isa_intr_alloc_mask = PCIC_ISA_INTR_ALLOC_MASK;
/*****************************************************************************
* End of configurable parameters.
*****************************************************************************/
#ifdef PCICISADEBUG #ifdef PCICISADEBUG
int pcicisa_debug = 0 /* XXX */ ; int pcicisa_debug = 0 /* XXX */ ;
#define DPRINTF(arg) if (pcicisa_debug) printf arg; #define DPRINTF(arg) if (pcicisa_debug) printf arg;
@ -162,17 +208,6 @@ pcic_isa_probe(parent, match, aux)
return (1); return (1);
} }
#ifndef PCIC_ISA_ALLOC_IOBASE
#define PCIC_ISA_ALLOC_IOBASE 0
#endif
#ifndef PCIC_ISA_ALLOC_IOSIZE
#define PCIC_ISA_ALLOC_IOSIZE 0
#endif
int pcic_isa_alloc_iobase = PCIC_ISA_ALLOC_IOBASE;
int pcic_isa_alloc_iosize = PCIC_ISA_ALLOC_IOSIZE;
void void
pcic_isa_attach(parent, self, aux) pcic_isa_attach(parent, self, aux)
struct device *parent, *self; struct device *parent, *self;
@ -218,9 +253,13 @@ pcic_isa_attach(parent, self, aux)
*/ */
if ((sc->irq = ia->ia_irq) == IRQUNK) { if ((sc->irq = ia->ia_irq) == IRQUNK) {
/* XXX CHECK RETURN VALUE */ if (isa_intr_alloc(ic,
(void) isa_intr_alloc(ic, PCIC_CSC_INTR_IRQ_VALIDMASK, PCIC_CSC_INTR_IRQ_VALIDMASK & pcic_isa_intr_alloc_mask,
IST_EDGE, &sc->irq); IST_EDGE, &sc->irq)) {
printf("\n%s: can't allocate interrupt\n",
sc->dev.dv_xname);
return;
}
printf(": using irq %d", sc->irq); printf(": using irq %d", sc->irq);
} }
printf("\n"); printf("\n");
@ -300,25 +339,14 @@ pcic_isa_attach(parent, self, aux)
} }
sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY, sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY,
pcic_intr, sc); pcic_intr, sc);
if (sc->ih == NULL) {
printf("%s: can't establish interrupt\n", sc->dev.dv_xname);
return;
}
pcic_attach_sockets(sc); pcic_attach_sockets(sc);
} }
/*
* allow patching or kernel option file override of available IRQs. Useful if
* order of probing would screw up other devices, or if PCIC hardware/cards
* have trouble with certain interrupt lines.
*
* We disable IRQ 10 by default, since some common laptops (namely, the
* NEC Versa series) reserve IRQ 10 for the docking station SCSI interface.
*/
#ifndef PCIC_INTR_ALLOC_MASK
#define PCIC_INTR_ALLOC_MASK 0xfbff
#endif
int pcic_intr_alloc_mask = PCIC_INTR_ALLOC_MASK;
void * void *
pcic_isa_chip_intr_establish(pch, pf, ipl, fct, arg) pcic_isa_chip_intr_establish(pch, pf, ipl, fct, arg)
pcmcia_chipset_handle_t pch; pcmcia_chipset_handle_t pch;
@ -340,7 +368,7 @@ pcic_isa_chip_intr_establish(pch, pf, ipl, fct, arg)
ist = IST_LEVEL; ist = IST_LEVEL;
if (isa_intr_alloc(h->sc->intr_est, if (isa_intr_alloc(h->sc->intr_est,
PCIC_INTR_IRQ_VALIDMASK & pcic_intr_alloc_mask, ist, &irq)) PCIC_INTR_IRQ_VALIDMASK & pcic_isa_intr_alloc_mask, ist, &irq))
return (NULL); return (NULL);
if ((ih = isa_intr_establish(h->sc->intr_est, irq, ist, ipl, if ((ih = isa_intr_establish(h->sc->intr_est, irq, ist, ipl,
fct, arg)) == NULL) fct, arg)) == NULL)