#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: octeon_bootbus.c,v 1.3 2021/08/07 16:18:59 thorpej Exp $");
#include "locators.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#define _MIPS_BUS_DMA_PRIVATE
#include <sys/bus.h>
#include <mips/cavium/octeonvar.h>
#include <mips/cavium/include/bootbusvar.h>
static int bootbus_match(device_t, struct cfdata *, void *);
static void bootbus_attach(device_t, device_t, void *);
static int bootbus_submatch(device_t, struct cfdata *,
const int *, void *);
static int bootbus_print(void *, const char *);
static void bootbus_init(void);
static void bootbus_bus_io_init(bus_space_tag_t, void *);
static struct mips_bus_space *bootbus_bust;
static struct mips_bus_dma_tag *bootbus_dmat;
void
bootbus_bootstrap(struct octeon_config *mcp)
{
bootbus_bus_io_init(&mcp->mc_bootbus_bust, mcp);
bootbus_bust = &mcp->mc_bootbus_bust;
bootbus_dmat = &mcp->mc_bootbus_dmat;
}
CFATTACH_DECL_NEW(bootbus, sizeof(device_t), bootbus_match, bootbus_attach, NULL,
NULL);
static int
bootbus_match(device_t parent, struct cfdata *match, void *aux)
{
return 1;
}
static void
bootbus_attach(device_t parent, device_t self, void *aux)
{
const struct bootbus_dev *dev;
struct bootbus_attach_args aa;
int i, j;
aprint_normal("\n");
bootbus_init();
for (i = 0; i < (int)bootbus_ndevs; i++) {
dev = bootbus_devs[i];
for (j = 0; j < dev->nunits; j++) {
aa.aa_name = dev->name;
aa.aa_unitno = j;
aa.aa_unit = &dev->units[j];
aa.aa_bust = bootbus_bust;
aa.aa_dmat = bootbus_dmat;
config_found(self, &aa, bootbus_print,
CFARGS(.submatch = bootbus_submatch));
}
}
}
static int
bootbus_submatch(device_t parent, struct cfdata *cf,
const int *ldesc, void *aux)
{
return config_match(parent, cf, aux);
}
static int
bootbus_print(void *aux, const char *pnp)
{
struct bootbus_attach_args *aa = aux;
if (pnp)
aprint_normal("%s at %s", aa->aa_name, pnp);
aprint_normal(": address=0x%016" PRIx64, aa->aa_unit->addr);
return UNCONF;
}
static void
bootbus_init(void)
{
}
#define CHIP bootbus
#define CHIP_IO
#define CHIP_ACCESS_SIZE 8
#define CHIP_W1_BUS_START(v) 0x0000000000000000ULL
#define CHIP_W1_BUS_END(v) 0x000000001fffffffULL
#define CHIP_W1_SYS_START(v) 0x00000000a0000000ULL
#define CHIP_W1_SYS_END(v) 0x00000000bfffffffULL
#include <mips/mips/bus_space_alignstride_chipdep.c>