More cleanup of sparc64 clock stuff:
- split mkclock attachment from sparc64/clock.c into dev/mkclock.c (now clock.s only contains clock interrupt and timecounter stuff) - rename match/attach functions of rtc at ebus to match the device name - update some comments around clock devices in GENERIC No objection on port-sparc64 for a month.
This commit is contained in:
parent
f3e033579e
commit
2ae6e40c03
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: GENERIC,v 1.73 2006/10/26 11:48:39 elad Exp $
|
||||
# $NetBSD: GENERIC,v 1.74 2006/11/09 15:08:04 tsutsui Exp $
|
||||
#
|
||||
# GENERIC machine description file
|
||||
#
|
||||
|
@ -22,7 +22,7 @@ include "arch/sparc64/conf/std.sparc64"
|
|||
|
||||
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
|
||||
|
||||
#ident "GENERIC-$Revision: 1.73 $"
|
||||
#ident "GENERIC-$Revision: 1.74 $"
|
||||
|
||||
maxusers 64
|
||||
|
||||
|
@ -256,10 +256,12 @@ auxio* at sbus? slot ? offset ? # auxio registers
|
|||
bpp* at sbus? slot ? offset ? # parallel port
|
||||
lpt* at ebus? # parallel port
|
||||
|
||||
## Mostek clock found on 4/300, sun4c, sun4m and sun4u systems.
|
||||
## The Mostek clock NVRAM is the "eeprom" on sun4/300 systems.
|
||||
## Mostek clock found on sbus on Ultra-1,2 systems
|
||||
## and found on ebus on Ultra-5 and other systems.
|
||||
clock* at sbus? slot ? offset ?
|
||||
clock* at ebus?
|
||||
|
||||
## DS1287 compatible clock found on ebus on Netra X1 and other systems.
|
||||
rtc* at ebus?
|
||||
|
||||
## Timer chip found on 4/300, sun4c, sun4m and (some) sun4u systems.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.sparc64,v 1.106 2006/10/10 12:43:11 tsutsui Exp $
|
||||
# $NetBSD: files.sparc64,v 1.107 2006/11/09 15:08:04 tsutsui Exp $
|
||||
|
||||
# @(#)files.sparc64 8.1 (Berkeley) 7/19/93
|
||||
# sparc64-specific configuration info
|
||||
|
@ -41,8 +41,9 @@ attach ebus at pci
|
|||
file arch/sparc64/dev/ebus.c ebus
|
||||
|
||||
device clock: mk48txx
|
||||
attach clock at sbus with clock_sbus
|
||||
attach clock at ebus with clock_ebus
|
||||
attach clock at sbus with mkclock_sbus
|
||||
attach clock at ebus with mkclock_ebus
|
||||
file arch/sparc64/dev/mkclock.c clock
|
||||
|
||||
device rtc: mc146818
|
||||
attach rtc at ebus with rtc_ebus
|
||||
|
|
|
@ -0,0 +1,256 @@
|
|||
/* $NetBSD: mkclock.c,v 1.1 2006/11/09 15:08:04 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
* Copyright (c) 1994 Gordon W. Ross
|
||||
* Copyright (c) 1993 Adam Glass
|
||||
* Copyright (c) 1996 Paul Kranenburg
|
||||
* Copyright (c) 1996
|
||||
* The President and Fellows of Harvard College. All rights reserved.
|
||||
*
|
||||
* This software was developed by the Computer Systems Engineering group
|
||||
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
|
||||
* contributed to Berkeley.
|
||||
*
|
||||
* All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Harvard University.
|
||||
* This product includes software developed by the University of
|
||||
* California, Lawrence Berkeley Laboratory.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* This product includes software developed by Paul Kranenburg.
|
||||
* This product includes software developed by Harvard University.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)clock.c 8.1 (Berkeley) 6/11/93
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.1 2006/11/09 15:08:04 tsutsui Exp $");
|
||||
|
||||
/*
|
||||
* Clock driver for 'mkclock' - Mostek MK48Txx TOD clock.
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/resourcevar.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/autoconf.h>
|
||||
#include <machine/eeprom.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
#include <dev/ic/mk48txxreg.h>
|
||||
#include <dev/ic/mk48txxvar.h>
|
||||
|
||||
#include <sparc64/dev/iommureg.h>
|
||||
#include <sparc64/dev/sbusreg.h>
|
||||
#include <dev/sbus/sbusvar.h>
|
||||
#include <dev/ebus/ebusreg.h>
|
||||
#include <dev/ebus/ebusvar.h>
|
||||
|
||||
/*
|
||||
* clock (eeprom) attaches at the sbus or the ebus (PCI)
|
||||
*/
|
||||
static int mkclock_sbus_match(struct device *, struct cfdata *, void *);
|
||||
static void mkclock_sbus_attach(struct device *, struct device *, void *);
|
||||
|
||||
static int mkclock_ebus_match(struct device *, struct cfdata *, void *);
|
||||
static void mkclock_ebus_attach(struct device *, struct device *, void *);
|
||||
|
||||
static void mkclock_attach(struct mk48txx_softc *, int);
|
||||
|
||||
static int mkclock_wenable(struct todr_chip_handle *, int);
|
||||
|
||||
|
||||
CFATTACH_DECL(mkclock_sbus, sizeof(struct mk48txx_softc),
|
||||
mkclock_sbus_match, mkclock_sbus_attach, NULL, NULL);
|
||||
|
||||
CFATTACH_DECL(mkclock_ebus, sizeof(struct mk48txx_softc),
|
||||
mkclock_ebus_match, mkclock_ebus_attach, NULL, NULL);
|
||||
|
||||
/*
|
||||
* The OPENPROM calls the clock the "eeprom", so we have to have our
|
||||
* own special match function to call it the "clock".
|
||||
*/
|
||||
static int
|
||||
mkclock_sbus_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct sbus_attach_args *sa = aux;
|
||||
|
||||
return (strcmp("eeprom", sa->sa_name) == 0);
|
||||
}
|
||||
|
||||
static int
|
||||
mkclock_ebus_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct ebus_attach_args *ea = aux;
|
||||
|
||||
return (strcmp("eeprom", ea->ea_name) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach a clock (really `eeprom') to the sbus or ebus.
|
||||
*
|
||||
* We ignore any existing virtual address as we need to map
|
||||
* this read-only and make it read-write only temporarily,
|
||||
* whenever we read or write the clock chip. The clock also
|
||||
* contains the ID ``PROM'', and I have already had the pleasure
|
||||
* of reloading the CPU type, Ethernet address, etc, by hand from
|
||||
* the console FORTH interpreter. I intend not to enjoy it again.
|
||||
*
|
||||
* the MK48T02 is 2K. the MK48T08 is 8K, and the MK48T59 is
|
||||
* supposed to be identical to it.
|
||||
*
|
||||
* This is *UGLY*! We probably have multiple mappings. But I do
|
||||
* know that this all fits inside an 8K page, so I'll just map in
|
||||
* once.
|
||||
*
|
||||
* What we really need is some way to record the bus attach args
|
||||
* so we can call *_bus_map() later with BUS_SPACE_MAP_READONLY
|
||||
* or not to write enable/disable the device registers. This is
|
||||
* a non-trivial operation.
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
mkclock_sbus_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mk48txx_softc *sc = (void *)self;
|
||||
struct sbus_attach_args *sa = aux;
|
||||
int sz;
|
||||
|
||||
sc->sc_bst = sa->sa_bustag;
|
||||
|
||||
/* use sa->sa_regs[0].size? */
|
||||
sz = 8192;
|
||||
|
||||
if (sbus_bus_map(sc->sc_bst,
|
||||
sa->sa_slot,
|
||||
(sa->sa_offset & ~(PAGE_SIZE - 1)),
|
||||
sz,
|
||||
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_READONLY,
|
||||
&sc->sc_bsh) != 0) {
|
||||
printf("%s: can't map register\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
mkclock_attach(sc, sa->sa_node);
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
mkclock_ebus_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mk48txx_softc *sc = (void *)self;
|
||||
struct ebus_attach_args *ea = aux;
|
||||
int sz;
|
||||
|
||||
sc->sc_bst = ea->ea_bustag;
|
||||
|
||||
/* hard code to 8K? */
|
||||
sz = ea->ea_reg[0].size;
|
||||
|
||||
if (bus_space_map(sc->sc_bst,
|
||||
EBUS_ADDR_FROM_REG(&ea->ea_reg[0]),
|
||||
sz,
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
&sc->sc_bsh) != 0) {
|
||||
printf("%s: can't map register\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
mkclock_attach(sc, ea->ea_node);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mkclock_attach(struct mk48txx_softc *sc, int node)
|
||||
{
|
||||
|
||||
sc->sc_model = prom_getpropstring(node, "model");
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (sc->sc_model == NULL)
|
||||
panic("clockattach: no model property");
|
||||
#endif
|
||||
|
||||
/* Our TOD clock year 0 is 1968 */
|
||||
sc->sc_year0 = 1968;
|
||||
mk48txx_attach(sc);
|
||||
|
||||
printf("\n");
|
||||
|
||||
/* Save info for the clock wenable call. */
|
||||
sc->sc_handle.todr_setwen = mkclock_wenable;
|
||||
|
||||
todr_attach(&sc->sc_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write en/dis-able clock registers. We coordinate so that several
|
||||
* writers can run simultaneously.
|
||||
*/
|
||||
static int
|
||||
mkclock_wenable(struct todr_chip_handle *handle, int onoff)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
vm_prot_t prot;
|
||||
vaddr_t va;
|
||||
int s, err = 0;
|
||||
static int writers;
|
||||
|
||||
s = splhigh();
|
||||
if (onoff)
|
||||
prot = writers++ == 0 ? VM_PROT_READ|VM_PROT_WRITE : 0;
|
||||
else
|
||||
prot = --writers == 0 ? VM_PROT_READ : 0;
|
||||
splx(s);
|
||||
if (prot == VM_PROT_NONE) {
|
||||
return 0;
|
||||
}
|
||||
sc = handle->cookie;
|
||||
va = (vaddr_t)bus_space_vaddr(sc->sc_bst, sc->sc_bsh);
|
||||
if (va == 0UL) {
|
||||
printf("clock_wenable: WARNING -- cannot get va\n");
|
||||
return EIO;
|
||||
}
|
||||
pmap_kprotect(va, prot);
|
||||
return (err);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rtc.c,v 1.1 2006/10/09 03:34:56 mrg Exp $ */
|
||||
/* $NetBSD: rtc.c,v 1.2 2006/11/09 15:08:04 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -56,7 +56,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.1 2006/10/09 03:34:56 mrg Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.2 2006/11/09 15:08:04 tsutsui Exp $");
|
||||
|
||||
/*
|
||||
* Clock driver for 'rtc' - mc146818 driver.
|
||||
|
@ -77,11 +77,11 @@ __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.1 2006/10/09 03:34:56 mrg Exp $");
|
|||
#include <dev/ebus/ebusreg.h>
|
||||
#include <dev/ebus/ebusvar.h>
|
||||
|
||||
static int clockmatch_rtc(struct device *, struct cfdata *, void *);
|
||||
static void clockattach_rtc(struct device *, struct device *, void *);
|
||||
static int rtc_ebus_match(struct device *, struct cfdata *, void *);
|
||||
static void rtc_ebus_attach(struct device *, struct device *, void *);
|
||||
|
||||
CFATTACH_DECL(rtc_ebus, sizeof(struct mc146818_softc),
|
||||
clockmatch_rtc, clockattach_rtc, NULL, NULL);
|
||||
rtc_ebus_match, rtc_ebus_attach, NULL, NULL);
|
||||
|
||||
u_int rtc_read_reg(struct mc146818_softc *, u_int);
|
||||
void rtc_write_reg(struct mc146818_softc *, u_int, u_int);
|
||||
|
@ -89,7 +89,7 @@ u_int rtc_getcent(struct mc146818_softc *);
|
|||
void rtc_setcent(struct mc146818_softc *, u_int);
|
||||
|
||||
static int
|
||||
clockmatch_rtc(struct device *parent, struct cfdata *cf, void *aux)
|
||||
rtc_ebus_match(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct ebus_attach_args *ea = aux;
|
||||
|
||||
|
@ -129,7 +129,7 @@ rtc_write_reg(struct mc146818_softc *sc, u_int reg, u_int val)
|
|||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
clockattach_rtc(struct device *parent, struct device *self, void *aux)
|
||||
rtc_ebus_attach(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mc146818_softc *sc = (void *)self;
|
||||
struct ebus_attach_args *ea = aux;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: clock.c,v 1.83 2006/10/10 12:43:11 tsutsui Exp $ */
|
||||
/* $NetBSD: clock.c,v 1.84 2006/11/09 15:08:04 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -55,7 +55,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.83 2006/10/10 12:43:11 tsutsui Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.84 2006/11/09 15:08:04 tsutsui Exp $");
|
||||
|
||||
#include "opt_multiprocessor.h"
|
||||
|
||||
|
@ -87,10 +87,6 @@ __KERNEL_RCSID(0, "$NetBSD: clock.c,v 1.83 2006/10/10 12:43:11 tsutsui Exp $");
|
|||
#include <machine/cpu.h>
|
||||
#include <machine/cpu_counter.h>
|
||||
|
||||
#include <dev/clock_subr.h>
|
||||
#include <dev/ic/mk48txxreg.h>
|
||||
#include <dev/ic/mk48txxvar.h>
|
||||
|
||||
#include <sparc64/sparc64/intreg.h>
|
||||
#include <sparc64/sparc64/timerreg.h>
|
||||
#include <sparc64/dev/iommureg.h>
|
||||
|
@ -121,24 +117,6 @@ static struct intrhand level0 = { .ih_fun = tickintr };
|
|||
static struct intrhand level14 = { .ih_fun = statintr };
|
||||
static struct intrhand schedint = { .ih_fun = schedintr };
|
||||
|
||||
/*
|
||||
* clock (eeprom) attaches at the sbus or the ebus (PCI)
|
||||
*/
|
||||
static int clockmatch_sbus(struct device *, struct cfdata *, void *);
|
||||
static void clockattach_sbus(struct device *, struct device *, void *);
|
||||
static int clockmatch_ebus(struct device *, struct cfdata *, void *);
|
||||
static void clockattach_ebus(struct device *, struct device *, void *);
|
||||
static void clockattach(struct mk48txx_softc *, int);
|
||||
|
||||
|
||||
CFATTACH_DECL(clock_sbus, sizeof(struct mk48txx_softc),
|
||||
clockmatch_sbus, clockattach_sbus, NULL, NULL);
|
||||
|
||||
CFATTACH_DECL(clock_ebus, sizeof(struct mk48txx_softc),
|
||||
clockmatch_ebus, clockattach_ebus, NULL, NULL);
|
||||
|
||||
extern struct cfdriver clock_cd;
|
||||
|
||||
static int timermatch(struct device *, struct cfdata *, void *);
|
||||
static void timerattach(struct device *, struct device *, void *);
|
||||
|
||||
|
@ -147,166 +125,11 @@ struct timerreg_4u timerreg_4u; /* XXX - need more cleanup */
|
|||
CFATTACH_DECL(timer, sizeof(struct device),
|
||||
timermatch, timerattach, NULL, NULL);
|
||||
|
||||
int clock_wenable(struct todr_chip_handle *, int);
|
||||
struct chiptime;
|
||||
void stopcounter(struct timer_4u *);
|
||||
|
||||
int timerblurb = 10; /* Guess a value; used before clock is attached */
|
||||
|
||||
/*
|
||||
* The OPENPROM calls the clock the "eeprom", so we have to have our
|
||||
* own special match function to call it the "clock".
|
||||
*/
|
||||
static int
|
||||
clockmatch_sbus(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct sbus_attach_args *sa = aux;
|
||||
|
||||
return (strcmp("eeprom", sa->sa_name) == 0);
|
||||
}
|
||||
|
||||
static int
|
||||
clockmatch_ebus(struct device *parent, struct cfdata *cf, void *aux)
|
||||
{
|
||||
struct ebus_attach_args *ea = aux;
|
||||
|
||||
return (strcmp("eeprom", ea->ea_name) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach a clock (really `eeprom') to the sbus or ebus.
|
||||
*
|
||||
* We ignore any existing virtual address as we need to map
|
||||
* this read-only and make it read-write only temporarily,
|
||||
* whenever we read or write the clock chip. The clock also
|
||||
* contains the ID ``PROM'', and I have already had the pleasure
|
||||
* of reloading the CPU type, Ethernet address, etc, by hand from
|
||||
* the console FORTH interpreter. I intend not to enjoy it again.
|
||||
*
|
||||
* the MK48T02 is 2K. the MK48T08 is 8K, and the MK48T59 is
|
||||
* supposed to be identical to it.
|
||||
*
|
||||
* This is *UGLY*! We probably have multiple mappings. But I do
|
||||
* know that this all fits inside an 8K page, so I'll just map in
|
||||
* once.
|
||||
*
|
||||
* What we really need is some way to record the bus attach args
|
||||
* so we can call *_bus_map() later with BUS_SPACE_MAP_READONLY
|
||||
* or not to write enable/disable the device registers. This is
|
||||
* a non-trivial operation.
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
clockattach_sbus(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mk48txx_softc *sc = (void *)self;
|
||||
struct sbus_attach_args *sa = aux;
|
||||
int sz;
|
||||
|
||||
sc->sc_bst = sa->sa_bustag;
|
||||
|
||||
/* use sa->sa_regs[0].size? */
|
||||
sz = 8192;
|
||||
|
||||
if (sbus_bus_map(sc->sc_bst,
|
||||
sa->sa_slot,
|
||||
(sa->sa_offset & ~(PAGE_SIZE - 1)),
|
||||
sz,
|
||||
BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_READONLY,
|
||||
&sc->sc_bsh) != 0) {
|
||||
printf("%s: can't map register\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
clockattach(sc, sa->sa_node);
|
||||
|
||||
/* Save info for the clock wenable call. */
|
||||
sc->sc_handle.todr_setwen = clock_wenable;
|
||||
|
||||
todr_attach(&sc->sc_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write en/dis-able clock registers. We coordinate so that several
|
||||
* writers can run simultaneously.
|
||||
*/
|
||||
int
|
||||
clock_wenable(struct todr_chip_handle *handle, int onoff)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
vm_prot_t prot;
|
||||
vaddr_t va;
|
||||
int s, err = 0;
|
||||
static int writers;
|
||||
|
||||
s = splhigh();
|
||||
if (onoff)
|
||||
prot = writers++ == 0 ? VM_PROT_READ|VM_PROT_WRITE : 0;
|
||||
else
|
||||
prot = --writers == 0 ? VM_PROT_READ : 0;
|
||||
splx(s);
|
||||
if (prot == VM_PROT_NONE) {
|
||||
return 0;
|
||||
}
|
||||
sc = handle->cookie;
|
||||
va = (vaddr_t)bus_space_vaddr(sc->sc_bst, sc->sc_bsh);
|
||||
if (va == 0UL) {
|
||||
printf("clock_wenable: WARNING -- cannot get va\n");
|
||||
return EIO;
|
||||
}
|
||||
pmap_kprotect(va, prot);
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
clockattach_ebus(struct device *parent, struct device *self, void *aux)
|
||||
{
|
||||
struct mk48txx_softc *sc = (void *)self;
|
||||
struct ebus_attach_args *ea = aux;
|
||||
int sz;
|
||||
|
||||
sc->sc_bst = ea->ea_bustag;
|
||||
|
||||
/* hard code to 8K? */
|
||||
sz = ea->ea_reg[0].size;
|
||||
|
||||
if (bus_space_map(sc->sc_bst,
|
||||
EBUS_ADDR_FROM_REG(&ea->ea_reg[0]),
|
||||
sz,
|
||||
BUS_SPACE_MAP_LINEAR,
|
||||
&sc->sc_bsh) != 0) {
|
||||
printf("%s: can't map register\n", self->dv_xname);
|
||||
return;
|
||||
}
|
||||
clockattach(sc, ea->ea_node);
|
||||
|
||||
/* Save info for the clock wenable call. */
|
||||
sc->sc_handle.todr_setwen = clock_wenable;
|
||||
|
||||
todr_attach(&sc->sc_handle);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
clockattach(struct mk48txx_softc *sc, int node)
|
||||
{
|
||||
|
||||
sc->sc_model = prom_getpropstring(node, "model");
|
||||
|
||||
#ifdef DIAGNOSTIC
|
||||
if (sc->sc_model == NULL)
|
||||
panic("clockattach: no model property");
|
||||
#endif
|
||||
|
||||
/* Our TOD clock year 0 is 1968 */
|
||||
sc->sc_year0 = 1968;
|
||||
mk48txx_attach(sc);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
static u_int timer_get_timecount(struct timecounter *);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue