#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.9 2025/10/19 20:52:09 thorpej Exp $");
#include <sys/param.h>
#include <sys/extent.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/bus.h>
#include <machine/autoconf.h>
#include <powerpc/pio.h>
#include "mca.h"
#if NMCA > 0
#include <dev/mca/mcavar.h>
#endif
int mainbus_match(device_t, cfdata_t, void *);
void mainbus_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(mainbus, 0,
mainbus_match, mainbus_attach, NULL, NULL);
int mainbus_print(void *, const char *);
union mainbus_attach_args {
const char *mba_busname;
#if NMCA > 0
struct mcabus_attach_args mba_mba;
#endif
};
int mainbus_found = 0;
int
mainbus_match(device_t parent, cfdata_t match, void *aux)
{
if (mainbus_found)
return 0;
return 1;
}
void
mainbus_attach(device_t parent, device_t self, void *aux)
{
union mainbus_attach_args mba;
struct confargs ca;
#if DEBUG
int slot;
#endif
mainbus_found = 1;
aprint_normal("\n");
ca.ca_name = "cpu";
ca.ca_node = 0;
config_found(self, &ca, mainbus_print,
CFARGS(.iattr = "mainbus"));
#if DEBUG
printf("scanning MCA bus\n");
for (slot=0; slot < 16; slot++) {
printf("slot %d == %x%x\n", slot,
inb(0xc0400100 + 1 + (slot<<16)),
inb(0xc0400100 + 0 + (slot<<16)));
}
printf("done\n");
printf(" CFG reg (1)= %x\n", inl(0xc0010080));
printf(" TCE reg (1)= %x\n", inl(0xc001009c));
#endif
mba.mba_mba.mba_iot = &rs6000_iocc0_io_space_tag;
mba.mba_mba.mba_memt = &rs6000_iocc0_io_space_tag;
mba.mba_mba.mba_dmat = NULL;
mba.mba_mba.mba_mc = NULL;
mba.mba_mba.mba_bus = 0;
mcabus_attach(self, &mba.mba_mba);
}
int
mainbus_print(void *aux, const char *pnp)
{
union mainbus_attach_args *mba = aux;
if (pnp)
aprint_normal("%s at %s", mba->mba_busname, pnp);
return (UNCONF);
}