#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/ofw/fdt.h>
#include <dev/ofw/openfirm.h>
#include <machine/fdt.h>
#include <octeon/dev/iobusvar.h>
#include <octeon/dev/cn30xxgmxreg.h>
struct octpip_softc {
struct device sc_dev;
};
int octpip_match(struct device *, void *, void *);
void octpip_attach(struct device *, struct device *, void *);
int octpip_print(void *, const char *);
const struct cfattach octpip_ca = {
sizeof(struct octpip_softc), octpip_match, octpip_attach
};
struct cfdriver octpip_cd = {
NULL, "octpip", DV_DULL
};
int
octpip_match(struct device *parent, void *match, void *aux)
{
struct fdt_attach_args *faa = aux;
return OF_is_compatible(faa->fa_node, "cavium,octeon-3860-pip");
}
void
octpip_attach(struct device *parent, struct device *self, void *aux)
{
struct iobus_attach_args iaa;
struct fdt_attach_args *faa = aux;
paddr_t addr;
uint32_t ifindex;
int node;
printf("\n");
for (node = OF_child(faa->fa_node); node != 0; node = OF_peer(node)) {
if (!OF_is_compatible(node, "cavium,octeon-3860-pip-interface"))
continue;
ifindex = OF_getpropint(node, "reg", (uint32_t)-1);
if (ifindex < 2)
addr = GMX0_BASE_PORT0 + GMX_BLOCK_SIZE * ifindex;
else if (ifindex == 4)
addr = AGL_BASE;
else
continue;
memset(&iaa, 0, sizeof(iaa));
iaa.aa_name = "octgmx";
iaa.aa_bust = faa->fa_iot;
iaa.aa_dmat = faa->fa_dmat;
iaa.aa_addr = addr;
iaa.aa_irq = -1;
iaa.aa_unitno = ifindex;
config_found(self, &iaa, octpip_print);
}
}
int
octpip_print(void *aux, const char *parentname)
{
struct iobus_attach_args *iaa = aux;
if (parentname != NULL)
printf("%s at %s", iaa->aa_name, parentname);
printf(" interface %d", iaa->aa_unitno);
return UNCONF;
}