Make the DraCo hardware clock an autoconfiguration device.
This commit is contained in:
parent
f2ab2a3550
commit
fc3de9d828
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: DRACO,v 1.13 1997/07/06 23:17:54 is Exp $
|
# $NetBSD: DRACO,v 1.14 1997/07/17 23:29:33 is Exp $
|
||||||
|
|
||||||
#
|
#
|
||||||
# Macro System GmbH "DraCo", currently 68060-only until FPE is integrated.
|
# Macro System GmbH "DraCo", currently 68060-only until FPE is integrated.
|
||||||
|
@ -129,6 +129,7 @@ mfcs1 at mfc0 unit 1 # MFC serial
|
||||||
#mfcs3 at mfc1 unit 1
|
#mfcs3 at mfc1 unit 1
|
||||||
#mfcp1 at mfc1 unit 0
|
#mfcp1 at mfc1 unit 0
|
||||||
|
|
||||||
|
drbbc0 at mainbus0 # DraCo battery backed clock
|
||||||
drcom0 at mainbus0 # DraCo serial ports
|
drcom0 at mainbus0 # DraCo serial ports
|
||||||
drcom1 at mainbus0 # unit 1 normally connected to mouse
|
drcom1 at mainbus0 # unit 1 normally connected to mouse
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: GENERIC,v 1.79 1997/07/16 00:01:52 is Exp $
|
# $NetBSD: GENERIC,v 1.80 1997/07/17 23:29:32 is Exp $
|
||||||
|
|
||||||
#
|
#
|
||||||
# GENERIC AMIGA
|
# GENERIC AMIGA
|
||||||
|
@ -192,6 +192,7 @@ mfcs1 at mfc0 unit 1 # MFC serial
|
||||||
#mfcs3 at mfc1 unit 1
|
#mfcs3 at mfc1 unit 1
|
||||||
#mfcp1 at mfc1 unit 0
|
#mfcp1 at mfc1 unit 0
|
||||||
|
|
||||||
|
drbbc0 at mainbus0 # DraCo battery backed clock
|
||||||
drcom0 at mainbus0 # DraCo serial 0
|
drcom0 at mainbus0 # DraCo serial 0
|
||||||
drcom1 at mainbus0 # DraCo serial 1, normally mouse
|
drcom1 at mainbus0 # DraCo serial 1, normally mouse
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: files.amiga,v 1.58 1997/07/16 00:01:51 is Exp $
|
# $NetBSD: files.amiga,v 1.59 1997/07/17 23:29:31 is Exp $
|
||||||
|
|
||||||
# maxpartitions must be first item in files.${ARCH}.newconf
|
# maxpartitions must be first item in files.${ARCH}.newconf
|
||||||
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
|
maxpartitions 16 # NOTE THAT AMIGA IS SPECIAL!
|
||||||
|
@ -280,6 +280,11 @@ device drsc: scsi, siop
|
||||||
attach drsc at mainbus
|
attach drsc at mainbus
|
||||||
file arch/amiga/dev/drsc.c drsc needs-flag
|
file arch/amiga/dev/drsc.c drsc needs-flag
|
||||||
|
|
||||||
|
# MacroSystem DraCo internal DS2404 hwc
|
||||||
|
device drbbc
|
||||||
|
attach drbbc at mainbus
|
||||||
|
file arch/amiga/dev/drbbc.c drbbc
|
||||||
|
|
||||||
# list of standard files...
|
# list of standard files...
|
||||||
include "arch/m68k/fpe/files.fpe"
|
include "arch/m68k/fpe/files.fpe"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: clock.c,v 1.28 1997/07/06 23:17:55 is Exp $ */
|
/* $NetBSD: clock.c,v 1.29 1997/07/17 23:29:29 is Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988 University of Utah.
|
* Copyright (c) 1988 University of Utah.
|
||||||
|
@ -52,7 +52,6 @@
|
||||||
#include <amiga/amiga/custom.h>
|
#include <amiga/amiga/custom.h>
|
||||||
#include <amiga/amiga/cia.h>
|
#include <amiga/amiga/cia.h>
|
||||||
#ifdef DRACO
|
#ifdef DRACO
|
||||||
#include <dev/ic/ds.h>
|
|
||||||
#include <amiga/amiga/drcustom.h>
|
#include <amiga/amiga/drcustom.h>
|
||||||
#endif
|
#endif
|
||||||
#include <amiga/dev/rtc.h>
|
#include <amiga/dev/rtc.h>
|
||||||
|
@ -646,10 +645,6 @@ profclock(pc, ps)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* this is a hook set by a clock driver for the configured realtime clock,
|
|
||||||
returning plain current unix-time */
|
|
||||||
time_t (*gettod) __P((void));
|
|
||||||
int (*settod) __P((time_t));
|
|
||||||
void *clockaddr;
|
void *clockaddr;
|
||||||
|
|
||||||
time_t a3gettod __P((void));
|
time_t a3gettod __P((void));
|
||||||
|
@ -657,18 +652,6 @@ time_t a2gettod __P((void));
|
||||||
int a3settod __P((time_t));
|
int a3settod __P((time_t));
|
||||||
int a2settod __P((time_t));
|
int a2settod __P((time_t));
|
||||||
|
|
||||||
#ifdef DRACO
|
|
||||||
int draco_ds_read_bit __P((void *));
|
|
||||||
void draco_ds_write_bit __P((void *, int));
|
|
||||||
void draco_ds_reset __P((void *));
|
|
||||||
|
|
||||||
time_t dracogettod __P((void));
|
|
||||||
|
|
||||||
#ifdef __NOTYET__
|
|
||||||
int dracosettod __P((time_t));
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int rtcinit __P((void));
|
int rtcinit __P((void));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -706,13 +689,7 @@ int
|
||||||
rtcinit()
|
rtcinit()
|
||||||
{
|
{
|
||||||
clockaddr = (void *)ztwomap(0xdc0000);
|
clockaddr = (void *)ztwomap(0xdc0000);
|
||||||
#ifdef DRACO
|
|
||||||
if (is_draco()) {
|
|
||||||
/* XXX to be done */
|
|
||||||
gettod = dracogettod;
|
|
||||||
settod = (void *)0;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
if (is_a3000() || is_a4000()) {
|
if (is_a3000() || is_a4000()) {
|
||||||
if (a3gettod() == 0)
|
if (a3gettod() == 0)
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -933,99 +910,3 @@ a2settod(secs)
|
||||||
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DRACO
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
draco_ds_read_bit(p)
|
|
||||||
void *p;
|
|
||||||
{
|
|
||||||
struct drioct *draco_ioct;
|
|
||||||
|
|
||||||
draco_ioct = p;
|
|
||||||
|
|
||||||
while (draco_ioct->io_status & DRSTAT_CLKBUSY);
|
|
||||||
|
|
||||||
draco_ioct->io_clockw1 = 0;
|
|
||||||
|
|
||||||
while (draco_ioct->io_status & DRSTAT_CLKBUSY);
|
|
||||||
|
|
||||||
return (draco_ioct->io_status & DRSTAT_CLKDAT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
draco_ds_write_bit(p, b)
|
|
||||||
void *p;
|
|
||||||
int b;
|
|
||||||
{
|
|
||||||
struct drioct *draco_ioct;
|
|
||||||
|
|
||||||
draco_ioct = p;
|
|
||||||
|
|
||||||
while (draco_ioct->io_status & DRSTAT_CLKBUSY);
|
|
||||||
|
|
||||||
if (b)
|
|
||||||
draco_ioct->io_clockw1 = 0;
|
|
||||||
else
|
|
||||||
draco_ioct->io_clockw0 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
draco_ds_reset(p)
|
|
||||||
void *p;
|
|
||||||
{
|
|
||||||
struct drioct *draco_ioct;
|
|
||||||
|
|
||||||
draco_ioct = p;
|
|
||||||
|
|
||||||
draco_ioct->io_clockrst = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We could return 1/256 of a seconds, but would need to change the interface
|
|
||||||
*/
|
|
||||||
|
|
||||||
time_t
|
|
||||||
dracogettod()
|
|
||||||
{
|
|
||||||
u_int32_t clkbuf;
|
|
||||||
u_int8_t rombuf[8];
|
|
||||||
int i;
|
|
||||||
struct ds_handle draco_dsh;
|
|
||||||
|
|
||||||
draco_dsh.ds_read_bit = draco_ds_read_bit;
|
|
||||||
draco_dsh.ds_write_bit = draco_ds_write_bit;
|
|
||||||
draco_dsh.ds_reset = draco_ds_reset;
|
|
||||||
draco_dsh.ds_hw_handle = (void *)(DRCCADDR + DRIOCTLPG*NBPG);
|
|
||||||
|
|
||||||
draco_dsh.ds_reset(draco_dsh.ds_hw_handle);
|
|
||||||
|
|
||||||
ds_write_byte(&draco_dsh, DS_ROM_READ);
|
|
||||||
for (i=0; i<8; ++i)
|
|
||||||
rombuf[i] = ds_read_byte(&draco_dsh);
|
|
||||||
|
|
||||||
printf("DraCo RTC: sernum %d (ROM %02x%02x%02x%02x%02x%02x%02x%02x)\n",
|
|
||||||
(rombuf[3] << 24) + (rombuf[2] << 16) +
|
|
||||||
(rombuf[1] << 8) + rombuf[7],
|
|
||||||
rombuf[7], rombuf[6], rombuf[5], rombuf[4],
|
|
||||||
rombuf[3], rombuf[2], rombuf[1], rombuf[0]);
|
|
||||||
|
|
||||||
|
|
||||||
ds_write_byte(&draco_dsh, DS_MEM_READ_MEMORY);
|
|
||||||
ds_write_byte(&draco_dsh, 0x03); /* low ads byte of realtime second */
|
|
||||||
ds_write_byte(&draco_dsh, 0x02); /* high ads byte of realtime second */
|
|
||||||
|
|
||||||
clkbuf = ds_read_byte(&draco_dsh)
|
|
||||||
+ (ds_read_byte(&draco_dsh)<<8)
|
|
||||||
+ (ds_read_byte(&draco_dsh)<<16)
|
|
||||||
+ (ds_read_byte(&draco_dsh)<<24);
|
|
||||||
|
|
||||||
/* BSD time is wr. 1.1.1970; AmigaOS time wrt. 1.1.1978 */
|
|
||||||
|
|
||||||
clkbuf += (8*365 + 2) * 86400;
|
|
||||||
|
|
||||||
return ((time_t)clkbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -0,0 +1,202 @@
|
||||||
|
/* $NetBSD: drbbc.c,v 1.1 1997/07/17 23:29:30 is Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1997 Ignatios Souvatzis.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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 Ignatios Souvatzis
|
||||||
|
* for the NetBSD project.
|
||||||
|
* 4. The name of the author may not be used to endorse or promote
|
||||||
|
* products derived from this software without specific prior written
|
||||||
|
* permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/kernel.h>
|
||||||
|
#include <sys/device.h>
|
||||||
|
#include <sys/systm.h>
|
||||||
|
#if 0
|
||||||
|
#include <machine/psl.h>
|
||||||
|
#endif
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#include <amiga/amiga/device.h>
|
||||||
|
#include <amiga/amiga/custom.h>
|
||||||
|
#include <amiga/amiga/cia.h>
|
||||||
|
#include <amiga/amiga/drcustom.h>
|
||||||
|
#include <amiga/dev/rtc.h>
|
||||||
|
|
||||||
|
#include <dev/ic/ds.h>
|
||||||
|
|
||||||
|
int draco_ds_read_bit __P((void *));
|
||||||
|
void draco_ds_write_bit __P((void *, int));
|
||||||
|
void draco_ds_reset __P((void *));
|
||||||
|
|
||||||
|
void drbbc_attach __P((struct device *, struct device *, void *));
|
||||||
|
int drbbc_match __P((struct device *, struct cfdata *, void *));
|
||||||
|
|
||||||
|
time_t dracogettod __P((void));
|
||||||
|
#ifdef __NOTYET__
|
||||||
|
int dracosettod __P((time_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct drbbc_softc {
|
||||||
|
struct device sc_dev;
|
||||||
|
struct ds_handle sc_dsh;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cfattach drbbc_ca = {
|
||||||
|
sizeof(struct drbbc_softc),
|
||||||
|
drbbc_match,
|
||||||
|
drbbc_attach
|
||||||
|
};
|
||||||
|
|
||||||
|
struct cfdriver drbbc_cd = {
|
||||||
|
NULL, "drbbc", DV_DULL, NULL, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
struct drbbc_softc *drbbc_sc;
|
||||||
|
|
||||||
|
int
|
||||||
|
drbbc_match(pdp, cfp, auxp)
|
||||||
|
struct device *pdp;
|
||||||
|
struct cfdata *cfp;
|
||||||
|
void *auxp;
|
||||||
|
{
|
||||||
|
if (is_draco() && matchname(auxp, "drbbc") && (cfp->cf_unit == 0))
|
||||||
|
return (1);
|
||||||
|
else
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drbbc_attach(pdp, dp, auxp)
|
||||||
|
struct device *pdp, *dp;
|
||||||
|
void *auxp;
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct drbbc_softc *sc;
|
||||||
|
u_int8_t rombuf[8];
|
||||||
|
|
||||||
|
sc = (struct drbbc_softc *)dp;
|
||||||
|
|
||||||
|
sc->sc_dsh.ds_read_bit = draco_ds_read_bit;
|
||||||
|
sc->sc_dsh.ds_write_bit = draco_ds_write_bit;
|
||||||
|
sc->sc_dsh.ds_reset = draco_ds_reset;
|
||||||
|
sc->sc_dsh.ds_hw_handle = (void *)(DRCCADDR + DRIOCTLPG*NBPG);
|
||||||
|
|
||||||
|
sc->sc_dsh.ds_reset(sc->sc_dsh.ds_hw_handle);
|
||||||
|
|
||||||
|
ds_write_byte(&sc->sc_dsh, DS_ROM_READ);
|
||||||
|
for (i=0; i<8; ++i)
|
||||||
|
rombuf[i] = ds_read_byte(&sc->sc_dsh);
|
||||||
|
|
||||||
|
hostid = (rombuf[3] << 24) + (rombuf[2] << 16) +
|
||||||
|
(rombuf[1] << 8) + rombuf[7];
|
||||||
|
|
||||||
|
printf(": ROM %02x %02x%02x%02x%02x%02x%02x %02x (DraCo sernum %ld)\n",
|
||||||
|
rombuf[7], rombuf[6], rombuf[5], rombuf[4],
|
||||||
|
rombuf[3], rombuf[2], rombuf[1], rombuf[0],
|
||||||
|
hostid);
|
||||||
|
|
||||||
|
gettod = dracogettod;
|
||||||
|
settod = (void *)0;
|
||||||
|
drbbc_sc = sc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
draco_ds_read_bit(p)
|
||||||
|
void *p;
|
||||||
|
{
|
||||||
|
struct drioct *draco_ioct;
|
||||||
|
|
||||||
|
draco_ioct = p;
|
||||||
|
|
||||||
|
while (draco_ioct->io_status & DRSTAT_CLKBUSY);
|
||||||
|
|
||||||
|
draco_ioct->io_clockw1 = 0;
|
||||||
|
|
||||||
|
while (draco_ioct->io_status & DRSTAT_CLKBUSY);
|
||||||
|
|
||||||
|
return (draco_ioct->io_status & DRSTAT_CLKDAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
draco_ds_write_bit(p, b)
|
||||||
|
void *p;
|
||||||
|
int b;
|
||||||
|
{
|
||||||
|
struct drioct *draco_ioct;
|
||||||
|
|
||||||
|
draco_ioct = p;
|
||||||
|
|
||||||
|
while (draco_ioct->io_status & DRSTAT_CLKBUSY);
|
||||||
|
|
||||||
|
if (b)
|
||||||
|
draco_ioct->io_clockw1 = 0;
|
||||||
|
else
|
||||||
|
draco_ioct->io_clockw0 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
draco_ds_reset(p)
|
||||||
|
void *p;
|
||||||
|
{
|
||||||
|
struct drioct *draco_ioct;
|
||||||
|
|
||||||
|
draco_ioct = p;
|
||||||
|
|
||||||
|
draco_ioct->io_clockrst = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We could return 1/256 of a seconds, but would need to change the interface
|
||||||
|
*/
|
||||||
|
|
||||||
|
time_t
|
||||||
|
dracogettod()
|
||||||
|
{
|
||||||
|
u_int32_t clkbuf;
|
||||||
|
|
||||||
|
drbbc_sc->sc_dsh.ds_reset(drbbc_sc->sc_dsh.ds_hw_handle);
|
||||||
|
|
||||||
|
ds_write_byte(&drbbc_sc->sc_dsh, DS_ROM_SKIP);
|
||||||
|
|
||||||
|
ds_write_byte(&drbbc_sc->sc_dsh, DS_MEM_READ_MEMORY);
|
||||||
|
/* address of full seconds: */
|
||||||
|
ds_write_byte(&drbbc_sc->sc_dsh, 0x03);
|
||||||
|
ds_write_byte(&drbbc_sc->sc_dsh, 0x02);
|
||||||
|
|
||||||
|
clkbuf = ds_read_byte(&drbbc_sc->sc_dsh)
|
||||||
|
+ (ds_read_byte(&drbbc_sc->sc_dsh)<<8)
|
||||||
|
+ (ds_read_byte(&drbbc_sc->sc_dsh)<<16)
|
||||||
|
+ (ds_read_byte(&drbbc_sc->sc_dsh)<<24);
|
||||||
|
|
||||||
|
/* BSD time is wr. 1.1.1970; AmigaOS time wrt. 1.1.1978 */
|
||||||
|
|
||||||
|
clkbuf += (8*365 + 2) * 86400;
|
||||||
|
|
||||||
|
return ((time_t)clkbuf);
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: rtc.h,v 1.4 1997/05/25 22:08:24 veego Exp $ */
|
/* $NetBSD: rtc.h,v 1.5 1997/07/17 23:29:28 is Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1994 Christian E. Hopps
|
* Copyright (c) 1994 Christian E. Hopps
|
||||||
|
@ -35,6 +35,12 @@
|
||||||
#ifndef _RTCVAR_H_
|
#ifndef _RTCVAR_H_
|
||||||
#define _RTCVAR_H_
|
#define _RTCVAR_H_
|
||||||
|
|
||||||
|
/* this is a hook set by a clock driver for the configured realtime clock,
|
||||||
|
returning plain current unix-time */
|
||||||
|
|
||||||
|
time_t (*gettod) __P((void));
|
||||||
|
int (*settod) __P((time_t));
|
||||||
|
|
||||||
struct rtclock2000 {
|
struct rtclock2000 {
|
||||||
u_int :28, second2:4; /* lower digit */
|
u_int :28, second2:4; /* lower digit */
|
||||||
u_int :28, second1:4; /* upper digit */
|
u_int :28, second1:4; /* upper digit */
|
||||||
|
|
Loading…
Reference in New Issue