#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kbc.c,v 1.16 2026/04/26 12:49:38 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/device.h>
#include <sys/tty.h>
#include <machine/bus.h>
#include <machine/cpu.h>
#include <dev/cons.h>
#include <news68k/dev/hbvar.h>
#include <news68k/dev/kbcvar.h>
#include "ioconf.h"
#define KBC_SIZE 0x10
static int kbc_match(device_t, cfdata_t, void *);
static void kbc_attach(device_t, device_t, void *);
static int kbc_print(void *, const char *name);
CFATTACH_DECL_NEW(kbc, 0,
kbc_match, kbc_attach, NULL, NULL);
static int kbc_match(device_t parent, cfdata_t cf, void *aux)
{
struct hb_attach_args *ha = aux;
u_int addr;
if (strcmp(ha->ha_name, "kbc"))
return 0;
if (ha->ha_address == (u_int)-1)
return 0;
addr = ha->ha_address;
if (badbaddr((void *)addr))
return 0;
return 1;
}
static void
kbc_attach(device_t parent, device_t self, void *aux)
{
struct hb_attach_args *ha = aux;
struct kbc_attach_args ka;
bus_space_tag_t bt = ha->ha_bust;
bus_space_handle_t bh;
if (bus_space_map(bt, ha->ha_address, KBC_SIZE, 0, &bh) != 0) {
aprint_error(": can't map device space\n");
return;
}
aprint_normal("\n");
ka.ka_bt = bt;
ka.ka_bh = bh;
ka.ka_ipl = ha->ha_ipl;
if (ka.ka_ipl == -1)
ka.ka_ipl = KBC_PRI;
ka.ka_name = "kb";
config_found(self, (void *)&ka, kbc_print, CFARGS_NONE);
ka.ka_name = "ms";
config_found(self, (void *)&ka, kbc_print, CFARGS_NONE);
}
static int
kbc_print(void *aux, const char *name)
{
if (name != NULL)
aprint_normal("%s: ", name);
return UNCONF;
}