#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
#include <machine/autoconf.h>
#include <machine/rpb.h>
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <alpha/pci/irongatereg.h>
#include <alpha/pci/irongatevar.h>
#ifdef API_UP1000
#include <alpha/pci/pci_up1000.h>
#endif
int irongate_match(struct device *, void *, void *);
void irongate_attach(struct device *, struct device *, void *);
const struct cfattach irongate_ca = {
sizeof(struct device), irongate_match, irongate_attach,
};
int irongate_print(void *, const char *pnp);
struct cfdriver irongate_cd = {
NULL, "irongate", DV_DULL,
};
struct irongate_config irongate_configuration;
int irongate_found;
void
irongate_init(struct irongate_config *icp, int mallocsafe)
{
pcitag_t tag;
pcireg_t reg;
icp->ic_mallocsafe = mallocsafe;
irongate_pci_init(&icp->ic_pc, icp);
alpha_pci_chipset = &icp->ic_pc;
alpha_pci_chipset->pc_name = "irongate";
alpha_pci_chipset->pc_mem = IRONGATE_MEM_BASE;
alpha_pci_chipset->pc_mem = IRONGATE_MEM_BASE;
alpha_pci_chipset->pc_bwx = 1;
tag = pci_make_tag(&icp->ic_pc, 0, IRONGATE_PCIHOST_DEV, 0);
reg = irongate_conf_read0(icp, tag, PCI_CLASS_REG);
icp->ic_rev = PCI_REVISION(reg);
if (icp->ic_initted == 0) {
irongate_bus_io_init(&icp->ic_iot, icp);
irongate_bus_mem_init(&icp->ic_memt, icp);
}
icp->ic_initted = 1;
}
int
irongate_match(struct device *parent, void *match, void *aux)
{
struct mainbus_attach_args *ma = aux;
if (strcmp(ma->ma_name, irongate_cd.cd_name) != 0)
return (0);
if (irongate_found)
return (0);
return (1);
}
void
irongate_attach(struct device *parent, struct device *self, void *aux)
{
struct irongate_config *icp;
struct pcibus_attach_args pba;
irongate_found = 1;
icp = &irongate_configuration;
irongate_init(icp, 1);
printf(": rev. %d\n", icp->ic_rev);
irongate_dma_init(icp);
irongate_bus_mem_init2(&icp->ic_memt, icp);
switch (cputype) {
#ifdef API_UP1000
case ST_API_NAUTILUS:
pci_up1000_pickintr(icp);
break;
#endif
default:
panic("irongate_attach: shouldn't be here, really...");
}
bzero(&pba, sizeof(pba));
pba.pba_busname = "pci";
pba.pba_iot = &icp->ic_iot;
pba.pba_memt = &icp->ic_memt;
pba.pba_dmat =
alphabus_dma_get_tag(&icp->ic_dmat_pci, ALPHA_BUS_PCI);
pba.pba_pc = &icp->ic_pc;
pba.pba_domain = pci_ndomains++;
pba.pba_bus = 0;
#ifdef notyet
pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED |
PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY | PCI_FLAGS_MWI_OKAY;
#endif
config_found(self, &pba, irongate_print);
}
int
irongate_print(void *aux, const char *pnp)
{
struct pcibus_attach_args *pba = aux;
if (pnp != NULL)
printf("%s at %s", pba->pba_busname, pnp);
printf(" bus %d", pba->pba_bus);
return (UNCONF);
}