1998-01-12 12:39:57 +03:00
|
|
|
/* $NetBSD: isa.c,v 1.98 1998/01/12 09:43:41 thorpej Exp $ */
|
1994-10-27 07:14:23 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*-
|
1994-11-04 02:53:19 +03:00
|
|
|
* Copyright (c) 1993, 1994 Charles Hannum. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* 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:
|
1994-11-04 02:53:19 +03:00
|
|
|
* 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.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
1994-11-04 02:53:19 +03:00
|
|
|
* 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.
|
1993-03-21 12:45:37 +03:00
|
|
|
*/
|
|
|
|
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
1994-03-06 20:37:56 +03:00
|
|
|
#include <sys/kernel.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/malloc.h>
|
1994-03-29 08:34:18 +04:00
|
|
|
#include <sys/device.h>
|
1993-12-20 12:05:17 +03:00
|
|
|
|
1996-05-14 04:31:04 +04:00
|
|
|
#include <machine/intr.h>
|
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
#include <dev/isa/isavar.h>
|
1997-06-07 03:43:45 +04:00
|
|
|
#include <dev/isa/isadmareg.h>
|
1993-05-28 13:10:52 +04:00
|
|
|
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
1996-02-28 04:43:45 +03:00
|
|
|
int isamatch __P((struct device *, void *, void *));
|
1996-12-05 04:25:23 +03:00
|
|
|
#else
|
|
|
|
int isamatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
#endif
|
1996-02-28 04:43:45 +03:00
|
|
|
void isaattach __P((struct device *, struct device *, void *));
|
1996-08-28 01:53:46 +04:00
|
|
|
int isaprint __P((void *, const char *));
|
1996-02-28 04:43:45 +03:00
|
|
|
|
1996-03-17 03:43:52 +03:00
|
|
|
struct cfattach isa_ca = {
|
|
|
|
sizeof(struct isa_softc), isamatch, isaattach
|
|
|
|
};
|
|
|
|
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
|
|
|
void isascan __P((struct device *, void *));
|
|
|
|
#else
|
|
|
|
int isasearch __P((struct device *, struct cfdata *, void *));
|
|
|
|
#endif
|
|
|
|
|
1996-02-28 04:43:45 +03:00
|
|
|
int
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
1996-02-28 04:43:45 +03:00
|
|
|
isamatch(parent, match, aux)
|
1996-12-05 04:25:23 +03:00
|
|
|
#else
|
|
|
|
isamatch(parent, cf, aux)
|
|
|
|
#endif
|
1996-02-28 04:43:45 +03:00
|
|
|
struct device *parent;
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
|
|
|
void *match;
|
|
|
|
#else
|
|
|
|
struct cfdata *cf;
|
|
|
|
#endif
|
|
|
|
void *aux;
|
1996-02-28 04:43:45 +03:00
|
|
|
{
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
1996-02-28 04:43:45 +03:00
|
|
|
struct cfdata *cf = match;
|
1996-12-05 04:25:23 +03:00
|
|
|
#endif
|
1996-02-28 04:43:45 +03:00
|
|
|
struct isabus_attach_args *iba = aux;
|
|
|
|
|
|
|
|
if (strcmp(iba->iba_busname, cf->cf_driver->cd_name))
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
/* XXX check other indicators */
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
isaattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct isa_softc *sc = (struct isa_softc *)self;
|
|
|
|
struct isabus_attach_args *iba = aux;
|
|
|
|
|
1998-01-12 12:39:57 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
|
|
|
extern struct cfdriver isa_cd;
|
|
|
|
|
|
|
|
isa_cd.cd_indirect = 1;
|
|
|
|
#endif
|
|
|
|
|
1996-04-12 02:25:44 +04:00
|
|
|
isa_attach_hook(parent, self, iba);
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("\n");
|
1996-02-28 04:43:45 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
sc->sc_iot = iba->iba_iot;
|
|
|
|
sc->sc_memt = iba->iba_memt;
|
1997-06-07 03:43:45 +04:00
|
|
|
sc->sc_dmat = iba->iba_dmat;
|
1996-04-12 02:25:44 +04:00
|
|
|
sc->sc_ic = iba->iba_ic;
|
1996-03-08 23:36:21 +03:00
|
|
|
|
1997-06-07 03:43:45 +04:00
|
|
|
/*
|
|
|
|
* Map the registers used by the ISA DMA controller.
|
|
|
|
*/
|
|
|
|
if (bus_space_map(sc->sc_iot, IO_DMA1, DMA1_IOSIZE, 0, &sc->sc_dma1h))
|
|
|
|
panic("isaattach: can't map DMA controller #1");
|
|
|
|
if (bus_space_map(sc->sc_iot, IO_DMA2, DMA2_IOSIZE, 0, &sc->sc_dma2h))
|
|
|
|
panic("isaattach: can't map DMA controller #2");
|
|
|
|
if (bus_space_map(sc->sc_iot, IO_DMAPG, 0xf, 0, &sc->sc_dmapgh))
|
|
|
|
panic("isaattach: can't map DMA page registers");
|
|
|
|
|
1996-05-05 05:14:07 +04:00
|
|
|
/*
|
1996-05-09 03:32:31 +04:00
|
|
|
* Map port 0x84, which causes a 1.25us delay when read.
|
1996-05-05 05:14:07 +04:00
|
|
|
* We do this now, since several drivers need it.
|
|
|
|
*/
|
1997-06-07 03:43:45 +04:00
|
|
|
if (bus_space_subregion(sc->sc_iot, sc->sc_dmapgh, 0x04, 1,
|
|
|
|
&sc->sc_delaybah))
|
1996-05-05 05:14:07 +04:00
|
|
|
panic("isaattach: can't map `delay port'"); /* XXX */
|
|
|
|
|
1996-02-28 04:43:45 +03:00
|
|
|
TAILQ_INIT(&sc->sc_subdevs);
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
1996-02-28 04:43:45 +03:00
|
|
|
config_scan(isascan, self);
|
1996-12-05 04:25:23 +03:00
|
|
|
#else
|
|
|
|
config_search(isasearch, self, NULL);
|
|
|
|
#endif
|
1996-02-28 04:43:45 +03:00
|
|
|
}
|
|
|
|
|
1994-03-29 08:34:18 +04:00
|
|
|
int
|
|
|
|
isaprint(aux, isa)
|
|
|
|
void *aux;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *isa;
|
1994-03-29 08:34:18 +04:00
|
|
|
{
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
|
|
|
|
if (ia->ia_iosize)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" port 0x%x", ia->ia_iobase);
|
1994-03-29 08:34:18 +04:00
|
|
|
if (ia->ia_iosize > 1)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("-0x%x", ia->ia_iobase + ia->ia_iosize - 1);
|
1994-03-29 08:34:18 +04:00
|
|
|
if (ia->ia_msize)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" iomem 0x%x", ia->ia_maddr);
|
1994-03-29 08:34:18 +04:00
|
|
|
if (ia->ia_msize > 1)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("-0x%x", ia->ia_maddr + ia->ia_msize - 1);
|
1994-11-19 01:25:12 +03:00
|
|
|
if (ia->ia_irq != IRQUNK)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" irq %d", ia->ia_irq);
|
1994-11-19 01:25:12 +03:00
|
|
|
if (ia->ia_drq != DRQUNK)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" drq %d", ia->ia_drq);
|
1997-08-26 23:26:38 +04:00
|
|
|
if (ia->ia_drq2 != DRQUNK)
|
|
|
|
printf(" drq2 %d", ia->ia_drq2);
|
1995-01-16 13:36:26 +03:00
|
|
|
return (UNCONF);
|
1994-03-29 08:34:18 +04:00
|
|
|
}
|
|
|
|
|
1996-12-05 04:25:23 +03:00
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
1994-11-04 09:40:11 +03:00
|
|
|
void
|
|
|
|
isascan(parent, match)
|
|
|
|
struct device *parent;
|
|
|
|
void *match;
|
|
|
|
{
|
1996-03-08 23:36:21 +03:00
|
|
|
struct isa_softc *sc = (struct isa_softc *)parent;
|
1994-11-04 09:40:11 +03:00
|
|
|
struct device *dev = match;
|
|
|
|
struct cfdata *cf = dev->dv_cfdata;
|
|
|
|
struct isa_attach_args ia;
|
|
|
|
|
1997-01-26 06:49:28 +03:00
|
|
|
#if defined(__i386__)
|
1994-11-04 09:40:11 +03:00
|
|
|
if (cf->cf_fstate == FSTATE_STAR)
|
1996-01-16 10:52:38 +03:00
|
|
|
panic("clone devices not supported on ISA bus");
|
1996-11-24 00:36:44 +03:00
|
|
|
#endif
|
1994-11-04 09:40:11 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
ia.ia_iot = sc->sc_iot;
|
|
|
|
ia.ia_memt = sc->sc_memt;
|
1997-06-07 03:43:45 +04:00
|
|
|
ia.ia_dmat = sc->sc_dmat;
|
1996-04-12 02:25:44 +04:00
|
|
|
ia.ia_ic = sc->sc_ic;
|
1997-07-17 04:58:48 +04:00
|
|
|
ia.ia_iobase = cf->cf_iobase;
|
|
|
|
ia.ia_iosize = 0x666;/* cf->cf_iosize; */
|
|
|
|
ia.ia_maddr = cf->cf_maddr;
|
|
|
|
ia.ia_msize = cf->cf_msize;
|
|
|
|
ia.ia_irq = cf->cf_irq == 2 ? 9 : cf->cf_irq;
|
|
|
|
ia.ia_drq = cf->cf_drq;
|
1997-08-26 23:26:38 +04:00
|
|
|
ia.ia_drq2 = cf->cf_drq2;
|
1996-10-22 02:34:38 +04:00
|
|
|
ia.ia_delaybah = sc->sc_delaybah;
|
1994-11-04 09:40:11 +03:00
|
|
|
|
1996-12-06 01:16:04 +03:00
|
|
|
if ((*cf->cf_attach->ca_match)(parent, match, &ia) > 0)
|
|
|
|
config_attach(parent, match, &ia, isaprint);
|
1994-11-04 09:40:11 +03:00
|
|
|
else
|
|
|
|
free(dev, M_DEVBUF);
|
1997-01-26 06:49:28 +03:00
|
|
|
}
|
|
|
|
#else /* !__BROKEN_INDIRECT_CONFIG */
|
|
|
|
int
|
|
|
|
isasearch(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct isa_softc *sc = (struct isa_softc *)parent;
|
|
|
|
struct isa_attach_args ia;
|
|
|
|
int tryagain;
|
|
|
|
|
|
|
|
do {
|
|
|
|
ia.ia_iot = sc->sc_iot;
|
|
|
|
ia.ia_memt = sc->sc_memt;
|
1997-06-07 03:43:45 +04:00
|
|
|
ia.ia_dmat = sc->sc_dmat;
|
1997-01-26 06:49:28 +03:00
|
|
|
ia.ia_ic = sc->sc_ic;
|
1997-07-17 04:58:48 +04:00
|
|
|
ia.ia_iobase = cf->cf_iobase;
|
|
|
|
ia.ia_iosize = 0x666; /* cf->cf_iosize; */
|
|
|
|
ia.ia_maddr = cf->cf_maddr;
|
|
|
|
ia.ia_msize = cf->cf_msize;
|
|
|
|
ia.ia_irq = cf->cf_irq == 2 ? 9 : cf->cf_irq;
|
|
|
|
ia.ia_drq = cf->cf_drq;
|
1997-08-26 23:26:38 +04:00
|
|
|
ia.ia_drq2 = cf->cf_drq2;
|
1997-01-26 06:49:28 +03:00
|
|
|
ia.ia_delaybah = sc->sc_delaybah;
|
|
|
|
|
|
|
|
tryagain = 0;
|
|
|
|
if ((*cf->cf_attach->ca_match)(parent, cf, &ia) > 0) {
|
|
|
|
config_attach(parent, cf, &ia, isaprint);
|
|
|
|
tryagain = (cf->cf_fstate == FSTATE_STAR);
|
|
|
|
}
|
|
|
|
} while (tryagain);
|
|
|
|
|
1996-12-05 04:25:23 +03:00
|
|
|
return (0);
|
1994-11-04 09:40:11 +03:00
|
|
|
}
|
1997-01-26 06:49:28 +03:00
|
|
|
#endif /* __BROKEN_INDIRECT_CONFIG */
|
1994-11-04 09:40:11 +03:00
|
|
|
|
1995-04-17 16:06:30 +04:00
|
|
|
char *
|
|
|
|
isa_intr_typename(type)
|
1995-12-24 05:29:35 +03:00
|
|
|
int type;
|
1995-04-17 16:06:30 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
switch (type) {
|
1995-12-24 05:29:35 +03:00
|
|
|
case IST_NONE :
|
1995-04-17 16:06:30 +04:00
|
|
|
return ("none");
|
1995-12-24 05:29:35 +03:00
|
|
|
case IST_PULSE:
|
1995-04-17 16:06:30 +04:00
|
|
|
return ("pulsed");
|
1995-12-24 05:29:35 +03:00
|
|
|
case IST_EDGE:
|
1995-04-17 16:06:30 +04:00
|
|
|
return ("edge-triggered");
|
1995-12-24 05:29:35 +03:00
|
|
|
case IST_LEVEL:
|
1995-04-17 16:06:30 +04:00
|
|
|
return ("level-triggered");
|
|
|
|
default:
|
|
|
|
panic("isa_intr_typename: invalid type %d", type);
|
|
|
|
}
|
|
|
|
}
|