#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i82072.c,v 1.15 2014/07/25 08:10:34 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/event.h>
#include <machine/cpu.h>
#include <machine/autoconf.h>
#include <machine/mainboard.h>
#include <machine/bus.h>
dev_type_open(fdopen);
dev_type_strategy(fdstrategy);
const struct bdevsw fd_bdevsw = {
.d_open = fdopen,
.d_close = nullclose,
.d_strategy = fdstrategy,
.d_ioctl = noioctl,
.d_dump = nodump,
.d_psize = nosize,
.d_discard = nodiscard,
.d_flag = D_DISK
};
const struct cdevsw fd_cdevsw = {
.d_open = fdopen,
.d_close = nullclose,
.d_read = noread,
.d_write = nowrite,
.d_ioctl = noioctl,
.d_stop = nostop,
.d_tty = notty,
.d_poll = nopoll,
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
.d_flag = D_DISK
};
#define I82072_STATUS 0x000003
#define I82072_DATA 0x000007
#define I82072_TC 0x800003
struct fd_softc {
device_t dev;
struct evcnt fd_intrcnt;
bus_space_tag_t fd_bst;
bus_space_handle_t fd_bsh;
int unit;
};
static int fd_match (device_t, cfdata_t, void *);
static void fd_attach (device_t, device_t, void *);
static void fd_reset (struct fd_softc *);
CFATTACH_DECL_NEW(fd, sizeof(struct fd_softc),
fd_match, fd_attach, NULL, NULL);
static int fd_intr (void *);
int
fd_match(device_t parent, cfdata_t cf, void *aux)
{
return 1;
}
void
fd_attach(device_t parent, device_t self, void *aux)
{
struct fd_softc *sc = device_private(self);
struct confargs *ca = aux;
sc->fd_bst = ca->ca_bustag;
if (bus_space_map(ca->ca_bustag, ca->ca_addr,
0x1000000,
BUS_SPACE_MAP_LINEAR,
&sc->fd_bsh) != 0) {
printf("%s: cannot map registers\n", device_xname(self));
return;
}
evcnt_attach_dynamic(&sc->fd_intrcnt, EVCNT_TYPE_INTR, NULL,
device_xname(self), "intr");
bus_intr_establish(sc->fd_bst, SYS_INTR_FDC, 0, 0, fd_intr, sc);
fd_reset(sc);
printf(": not fully implemented\n");
}
void
fd_reset(struct fd_softc *sc)
{
bus_space_write_1(sc->fd_bst, sc->fd_bsh, I82072_STATUS, 0x80);
DELAY(1000);
bus_space_write_1(sc->fd_bst, sc->fd_bsh, I82072_TC, 0x01);
DELAY(1000);
}
int
fdopen(dev_t dev, int flags, int mode, struct lwp *l)
{
return (EBADF);
}
void
fdstrategy(struct buf *bp)
{
panic("fdstrategy");
}
static int
fd_intr(void *arg)
{
struct fd_softc *sc = arg;
sc->fd_intrcnt.ev_count++;
fd_reset(sc);
return 0;
}