1998-05-23 22:35:56 +04:00
|
|
|
/* $NetBSD: sio.c,v 1.24 1998/05/23 18:35:56 matt Exp $ */
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
/*
|
1996-04-12 10:07:05 +04:00
|
|
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
1995-06-28 05:24:50 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Chris G. Demetriou
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
|
|
|
*
|
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
|
|
|
*/
|
|
|
|
|
1997-04-08 03:39:37 +04:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
|
|
|
|
1998-05-23 22:35:56 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: sio.c,v 1.24 1998/05/23 18:35:56 matt Exp $");
|
1997-04-07 06:01:16 +04:00
|
|
|
|
1995-06-28 05:24:50 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/eisa/eisavar.h>
|
|
|
|
|
1995-06-28 05:24:50 +04:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
#include <alpha/pci/siovar.h>
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1996-11-25 06:15:24 +03:00
|
|
|
struct sio_softc {
|
|
|
|
struct device sc_dv;
|
|
|
|
|
|
|
|
bus_space_tag_t sc_iot, sc_memt;
|
1997-06-07 03:54:24 +04:00
|
|
|
bus_dma_tag_t sc_parent_dmat;
|
1996-11-25 06:15:24 +03:00
|
|
|
int sc_haseisa;
|
1998-03-28 09:58:43 +03:00
|
|
|
int sc_is82c693;
|
1996-11-25 06:15:24 +03:00
|
|
|
};
|
|
|
|
|
1996-12-05 04:39:27 +03:00
|
|
|
int siomatch __P((struct device *, struct cfdata *, void *));
|
1995-06-28 05:24:50 +04:00
|
|
|
void sioattach __P((struct device *, struct device *, void *));
|
|
|
|
|
1996-03-17 04:03:02 +03:00
|
|
|
struct cfattach sio_ca = {
|
1996-11-25 06:15:24 +03:00
|
|
|
sizeof(struct sio_softc), siomatch, sioattach,
|
1996-03-17 04:03:02 +03:00
|
|
|
};
|
|
|
|
|
1996-12-05 04:39:27 +03:00
|
|
|
int pcebmatch __P((struct device *, struct cfdata *, void *));
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-03-17 04:03:02 +03:00
|
|
|
struct cfattach pceb_ca = {
|
1998-04-12 12:32:19 +04:00
|
|
|
sizeof(struct sio_softc), pcebmatch, sioattach,
|
1996-03-17 04:03:02 +03:00
|
|
|
};
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
union sio_attach_args {
|
|
|
|
const char *sa_name; /* XXX should be common */
|
|
|
|
struct isabus_attach_args sa_iba;
|
|
|
|
struct eisabus_attach_args sa_eba;
|
1995-11-23 05:33:17 +03:00
|
|
|
};
|
|
|
|
|
1996-08-28 01:53:46 +04:00
|
|
|
int sioprint __P((void *, const char *pnp));
|
1996-04-13 04:23:34 +04:00
|
|
|
void sio_isa_attach_hook __P((struct device *, struct device *,
|
|
|
|
struct isabus_attach_args *));
|
|
|
|
void sio_eisa_attach_hook __P((struct device *, struct device *,
|
|
|
|
struct eisabus_attach_args *));
|
|
|
|
int sio_eisa_maxslots __P((void *));
|
|
|
|
int sio_eisa_intr_map __P((void *, u_int, eisa_intr_handle_t *));
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1996-11-25 06:15:24 +03:00
|
|
|
void sio_bridge_callback __P((void *));
|
|
|
|
|
1995-06-28 05:24:50 +04:00
|
|
|
int
|
|
|
|
siomatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
1996-12-05 04:39:27 +03:00
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1995-06-28 05:24:50 +04:00
|
|
|
{
|
1996-04-12 06:11:22 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1998-03-28 09:58:43 +03:00
|
|
|
/*
|
|
|
|
* The Cypress 82C693 is more-or-less an SIO, but with
|
|
|
|
* indirect register access. (XXX for everything, or
|
|
|
|
* just the ELCR?)
|
|
|
|
*/
|
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CONTAQ &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CONTAQ_82C693 &&
|
|
|
|
pa->pa_function == 0)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_SIO)
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
return (0);
|
1995-11-23 05:33:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
pcebmatch(parent, match, aux)
|
|
|
|
struct device *parent;
|
1996-12-05 04:39:27 +03:00
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
1995-11-23 05:33:17 +03:00
|
|
|
{
|
1996-04-12 06:11:22 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1998-03-28 09:58:43 +03:00
|
|
|
if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB)
|
|
|
|
return (1);
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1998-03-28 09:58:43 +03:00
|
|
|
return (0);
|
1995-06-28 05:24:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sioattach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
1996-11-25 06:15:24 +03:00
|
|
|
struct sio_softc *sc = (struct sio_softc *)self;
|
1996-04-12 06:11:22 +04:00
|
|
|
struct pci_attach_args *pa = aux;
|
1995-11-23 05:33:17 +03:00
|
|
|
char devinfo[256];
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
|
1996-10-13 06:59:55 +04:00
|
|
|
printf(": %s (rev. 0x%02x)\n", devinfo,
|
1996-04-12 06:11:22 +04:00
|
|
|
PCI_REVISION(pa->pa_class));
|
1995-11-23 05:33:17 +03:00
|
|
|
|
1996-11-25 06:15:24 +03:00
|
|
|
sc->sc_iot = pa->pa_iot;
|
|
|
|
sc->sc_memt = pa->pa_memt;
|
1997-06-07 03:54:24 +04:00
|
|
|
sc->sc_parent_dmat = pa->pa_dmat;
|
1998-03-28 09:58:43 +03:00
|
|
|
sc->sc_haseisa = (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_INTEL &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_PCEB);
|
|
|
|
sc->sc_is82c693 = (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_CONTAQ &&
|
|
|
|
PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_CONTAQ_82C693);
|
1995-11-23 05:33:17 +03:00
|
|
|
|
|
|
|
#ifdef EVCNT_COUNTERS
|
1996-11-25 06:15:24 +03:00
|
|
|
evcnt_attach(&sc->sc_dv, "intr", &sio_intr_evcnt);
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
|
|
|
|
1996-11-25 06:15:24 +03:00
|
|
|
set_pci_isa_bridge_callback(sio_bridge_callback, sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sio_bridge_callback(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct sio_softc *sc = v;
|
|
|
|
struct alpha_eisa_chipset ec;
|
|
|
|
struct alpha_isa_chipset ic;
|
|
|
|
union sio_attach_args sa;
|
|
|
|
|
|
|
|
if (sc->sc_haseisa) {
|
1996-04-13 04:23:34 +04:00
|
|
|
ec.ec_v = NULL;
|
|
|
|
ec.ec_attach_hook = sio_eisa_attach_hook;
|
|
|
|
ec.ec_maxslots = sio_eisa_maxslots;
|
|
|
|
ec.ec_intr_map = sio_eisa_intr_map;
|
|
|
|
ec.ec_intr_string = sio_intr_string;
|
|
|
|
ec.ec_intr_establish = sio_intr_establish;
|
|
|
|
ec.ec_intr_disestablish = sio_intr_disestablish;
|
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
sa.sa_eba.eba_busname = "eisa";
|
1996-11-25 06:15:24 +03:00
|
|
|
sa.sa_eba.eba_iot = sc->sc_iot;
|
|
|
|
sa.sa_eba.eba_memt = sc->sc_memt;
|
1997-06-07 03:54:24 +04:00
|
|
|
sa.sa_eba.eba_dmat =
|
|
|
|
alphabus_dma_get_tag(sc->sc_parent_dmat, ALPHA_BUS_EISA);
|
1996-04-12 09:43:02 +04:00
|
|
|
sa.sa_eba.eba_ec = &ec;
|
1996-11-25 06:15:24 +03:00
|
|
|
config_found(&sc->sc_dv, &sa.sa_eba, sioprint);
|
1995-06-28 05:24:50 +04:00
|
|
|
}
|
1996-04-12 06:11:22 +04:00
|
|
|
|
1996-04-12 09:43:02 +04:00
|
|
|
ic.ic_v = NULL;
|
|
|
|
ic.ic_attach_hook = sio_isa_attach_hook;
|
|
|
|
ic.ic_intr_establish = sio_intr_establish;
|
|
|
|
ic.ic_intr_disestablish = sio_intr_disestablish;
|
1998-05-23 22:35:56 +04:00
|
|
|
ic.ic_intr_alloc = sio_intr_alloc;
|
1996-04-12 09:43:02 +04:00
|
|
|
|
1996-04-12 06:11:22 +04:00
|
|
|
sa.sa_iba.iba_busname = "isa";
|
1996-11-25 06:15:24 +03:00
|
|
|
sa.sa_iba.iba_iot = sc->sc_iot;
|
|
|
|
sa.sa_iba.iba_memt = sc->sc_memt;
|
1997-06-07 03:54:24 +04:00
|
|
|
sa.sa_iba.iba_dmat =
|
|
|
|
alphabus_dma_get_tag(sc->sc_parent_dmat, ALPHA_BUS_ISA);
|
1996-04-12 09:43:02 +04:00
|
|
|
sa.sa_iba.iba_ic = ⁣
|
1996-11-25 06:15:24 +03:00
|
|
|
config_found(&sc->sc_dv, &sa.sa_iba, sioprint);
|
1995-06-28 05:24:50 +04:00
|
|
|
}
|
|
|
|
|
1996-04-13 04:23:34 +04:00
|
|
|
int
|
1995-06-28 05:24:50 +04:00
|
|
|
sioprint(aux, pnp)
|
|
|
|
void *aux;
|
1996-08-28 01:53:46 +04:00
|
|
|
const char *pnp;
|
1995-06-28 05:24:50 +04:00
|
|
|
{
|
1996-04-12 06:11:22 +04:00
|
|
|
register union sio_attach_args *sa = aux;
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
if (pnp)
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("%s at %s", sa->sa_name, pnp);
|
1995-06-28 05:24:50 +04:00
|
|
|
return (UNCONF);
|
|
|
|
}
|
1996-04-12 09:43:02 +04:00
|
|
|
|
1996-04-13 04:23:34 +04:00
|
|
|
void
|
1996-04-12 09:43:02 +04:00
|
|
|
sio_isa_attach_hook(parent, self, iba)
|
|
|
|
struct device *parent, *self;
|
|
|
|
struct isabus_attach_args *iba;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Nothing to do. */
|
|
|
|
}
|
1996-04-13 04:23:34 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
sio_eisa_attach_hook(parent, self, eba)
|
|
|
|
struct device *parent, *self;
|
|
|
|
struct eisabus_attach_args *eba;
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Nothing to do. */
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sio_eisa_maxslots(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
|
|
|
|
return 16; /* as good a number as any. only 8, maybe? */
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
sio_eisa_intr_map(v, irq, ihp)
|
|
|
|
void *v;
|
|
|
|
u_int irq;
|
|
|
|
eisa_intr_handle_t *ihp;
|
|
|
|
{
|
|
|
|
|
|
|
|
#define ICU_LEN 16 /* number of ISA IRQs (XXX) */
|
|
|
|
|
|
|
|
if (irq >= ICU_LEN) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("sio_eisa_intr_map: bad IRQ %d\n", irq);
|
1996-04-13 04:23:34 +04:00
|
|
|
*ihp = -1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (irq == 2) {
|
1996-10-13 06:59:55 +04:00
|
|
|
printf("sio_eisa_intr_map: changed IRQ 2 to IRQ 9\n");
|
1996-04-13 04:23:34 +04:00
|
|
|
irq = 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ihp = irq;
|
|
|
|
return 0;
|
|
|
|
}
|