#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hyper.c,v 1.24 2021/08/07 16:18:41 thorpej Exp $");
#include <sys/types.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/systm.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <amiga/include/cpu.h>
#include <amiga/amiga/device.h>
#include <amiga/amiga/drcustom.h>
#include <amiga/dev/supio.h>
#include <amiga/dev/zbusvar.h>
struct hyper_softc {
struct bus_space_tag sc_bst;
};
int hypermatch(device_t, cfdata_t, void *);
void hyperattach(device_t, device_t, void *);
int hyperprint(void *, const char *);
CFATTACH_DECL_NEW(hyper, sizeof(struct hyper_softc),
hypermatch, hyperattach, NULL, NULL);
struct hyper_prods {
const char *name;
unsigned baseoff;
} hyperproducts [] = {
{0, 0},
{0, 0},
{"4", 1},
{"Z3", 0},
{0, 0},
{0, 0},
{"4+", 0x8000},
{"3+", 0x8000}
};
int
hypermatch(device_t parent, cfdata_t cf, void *aux)
{
struct zbus_args *zap;
zap = aux;
if (zap->manid != 5001)
return (0);
if (zap->prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) &&
hyperproducts[zap->prodid].name)
return (1);
return (0);
}
#define HYPERPROD3 (1<<3)
#define HYPERPROD4 (1<<2)
#define HYPERPROD4PLUS (1<<6)
#define HYPERPROD3PLUS (1<<7)
struct hyper_devs {
const char *name;
unsigned off;
int arg;
u_int32_t productmask;
} hyperdevices[] = {
{ "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
{ "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
{ "com", 0x10, 115200 * 16 * 4, HYPERPROD4 },
{ "com", 0x18, 115200 * 16 * 4, HYPERPROD4 },
{ "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
{ "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
{ "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS },
{ "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS },
{ "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS },
{ "lpt", 0x1400, 0, HYPERPROD4PLUS },
};
void
hyperattach(device_t parent, device_t self, void *aux)
{
struct hyper_softc *hprsc;
struct hyper_devs *hprsd;
struct zbus_args *zap;
struct supio_attach_args supa;
struct hyper_prods *hprpp;
hprsc = device_private(self);
zap = aux;
hprpp = &hyperproducts[zap->prodid];
if (parent)
printf(": Hypercom %s\n", hprpp->name);
hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff;
hprsc->sc_bst.absm = &amiga_bus_stride_4;
supa.supio_iot = &hprsc->sc_bst;
supa.supio_ipl = 6;
hprsd = hyperdevices;
while (hprsd->name) {
if (hprsd->productmask & (1 << zap->prodid)) {
supa.supio_name = hprsd->name;
supa.supio_iobase = hprsd->off;
supa.supio_arg = hprsd->arg;
config_found(self, &supa, hyperprint, CFARGS_NONE);
}
++hprsd;
}
}
int
hyperprint(void *aux, const char *pnp)
{
struct supio_attach_args *supa;
supa = aux;
if (pnp == NULL)
return(QUIET);
aprint_normal("%s at %s port 0x%02x",
supa->supio_name, pnp, supa->supio_iobase);
return(UNCONF);
}