bus_space-ify.
This commit is contained in:
parent
8eb9eddb64
commit
5216fa0690
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mcclock_gbus.c,v 1.2 2024/03/02 22:58:29 thorpej Exp $ */
|
||||
/* $NetBSD: mcclock_gbus.c,v 1.3 2024/03/06 05:44:44 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 by Matthew Jacob
|
||||
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
||||
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.2 2024/03/02 22:58:29 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.3 2024/03/06 05:44:44 thorpej Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
|
@ -43,8 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.2 2024/03/02 22:58:29 thorpej Exp
|
|||
|
||||
#include <alpha/gbus/gbusvar.h>
|
||||
|
||||
#include <alpha/tlsb/tlsbreg.h> /* XXX */
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
|
||||
#include <dev/ic/mc146818reg.h>
|
||||
|
@ -54,27 +52,15 @@ __KERNEL_RCSID(0, "$NetBSD: mcclock_gbus.c,v 1.2 2024/03/02 22:58:29 thorpej Exp
|
|||
|
||||
#include "ioconf.h"
|
||||
|
||||
#define KV(_addr) ((void *)ALPHA_PHYS_TO_K0SEG((_addr)))
|
||||
/*
|
||||
* Registers are 64 bytes apart (and 1 byte wide)
|
||||
*/
|
||||
#define REGSHIFT 6
|
||||
|
||||
struct mcclock_gbus_softc {
|
||||
struct mc146818_softc sc_mc146818;
|
||||
unsigned long regbase;
|
||||
};
|
||||
|
||||
static int mcclock_gbus_match(device_t, cfdata_t, void *);
|
||||
static void mcclock_gbus_attach(device_t, device_t, void *);
|
||||
|
||||
CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mcclock_gbus_softc),
|
||||
CFATTACH_DECL_NEW(mcclock_gbus, sizeof(struct mc146818_softc),
|
||||
mcclock_gbus_match, mcclock_gbus_attach, NULL, NULL);
|
||||
|
||||
static void mcclock_gbus_write(struct mc146818_softc *, u_int, u_int);
|
||||
static u_int mcclock_gbus_read(struct mc146818_softc *, u_int);
|
||||
|
||||
|
||||
static int
|
||||
mcclock_gbus_match(device_t parent, cfdata_t cf, void *aux)
|
||||
{
|
||||
|
@ -88,14 +74,17 @@ mcclock_gbus_match(device_t parent, cfdata_t cf, void *aux)
|
|||
static void
|
||||
mcclock_gbus_attach(device_t parent, device_t self, void *aux)
|
||||
{
|
||||
struct mcclock_gbus_softc *tsc = device_private(self);
|
||||
struct mc146818_softc *sc = device_private(self);
|
||||
struct gbus_attach_args *ga = aux;
|
||||
struct mc146818_softc *sc = &tsc->sc_mc146818;
|
||||
|
||||
/* XXX Should be bus.h'd, so we can accommodate the kn7aa. */
|
||||
tsc->regbase = TLSB_GBUS_BASE + ga->ga_offset;
|
||||
|
||||
sc->sc_dev = self;
|
||||
sc->sc_bst = ga->ga_iot;
|
||||
|
||||
if (bus_space_map(sc->sc_bst, ga->ga_offset, MC_NREGS+MC_NVRAM_SIZE,
|
||||
0, &sc->sc_bsh) != 0) {
|
||||
panic("mcclock_gbus_attach: couldn't map clock I/O space");
|
||||
}
|
||||
|
||||
sc->sc_mcread = mcclock_gbus_read;
|
||||
sc->sc_mcwrite = mcclock_gbus_write;
|
||||
|
||||
|
@ -105,19 +94,11 @@ mcclock_gbus_attach(device_t parent, device_t self, void *aux)
|
|||
static void
|
||||
mcclock_gbus_write(struct mc146818_softc *sc, u_int reg, u_int val)
|
||||
{
|
||||
struct mcclock_gbus_softc *tsc = (void *)sc;
|
||||
unsigned char *ptr = (unsigned char *)
|
||||
KV(tsc->regbase + (reg << REGSHIFT));
|
||||
|
||||
*ptr = val;
|
||||
bus_space_write_1(sc->sc_bst, sc->sc_bsh, reg, (uint8_t)val);
|
||||
}
|
||||
|
||||
static u_int
|
||||
mcclock_gbus_read(struct mc146818_softc *sc, u_int reg)
|
||||
{
|
||||
struct mcclock_gbus_softc *tsc = (void *)sc;
|
||||
unsigned char *ptr = (unsigned char *)
|
||||
KV(tsc->regbase + (reg << REGSHIFT));
|
||||
|
||||
return *ptr;
|
||||
return bus_space_read_1(sc->sc_bst, sc->sc_bsh, reg);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue