Add new evbppc port.

This port is for OpenBlockS266.
OpenBlockS266: IBM405GPr OpenBIOS.
X1226 is a rtc chip connected with IIC bus.
This commit is contained in:
shige 2003-09-23 14:45:12 +00:00
parent 643e2f262c
commit 9c7b98f8ce
8 changed files with 1082 additions and 0 deletions

View File

@ -0,0 +1,21 @@
# $NetBSD: Makefile.obs405.inc,v 1.1 2003/09/23 14:45:12 shige Exp $
MKIMG?= ${THISPPC}/compile/walnut-mkimg.sh
CFLAGS+=-mcpu=403
AFLAGS+=-mcpu=403
TEXTADDR?= 25000
SYSTEM_FIRST_OBJ= locore.o
SYSTEM_FIRST_SFILE= ${POWERPC}/${PPCDIR}/openbios/locore.S
.ifdef DBSYM
SYSTEM_LD_TAIL_EXTRA+=; \
echo "${DBSYM} $@ || true"; \
${DBSYM} $@ || true
.endif
SYSTEM_LD_TAIL_EXTRA+=; \
echo ${MKIMG} netbsd netbsd.img ; \
OBJDUMP=${OBJDUMP}; OBJCOPY=${OBJCOPY}; export OBJDUMP OBJCOPY; \
${MKIMG} $@ $@.img

View File

@ -0,0 +1,210 @@
# $NetBSD: OPENBLOCKS266,v 1.1 2003/09/23 14:45:13 shige Exp $
#
# GENERIC -- everything that's currently supported
#
include "arch/evbppc/conf/std.obs405"
#options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "OPENBLOCKS266"
maxusers 32
#options UVMHIST
#options UVMHIST_PRINT
# Options for necessary to use MD
#options MEMORY_DISK_HOOKS
#options MEMORY_DISK_IS_ROOT # force root on memory disk
#options MEMORY_DISK_SERVER=0 # no userspace memory disk support
#options MEMORY_DISK_ROOT_SIZE=16384 # size of memory disk, in blocks
#options INSECURE # disable kernel security levels
#options NTP # NTP phase/frequency locked loop
#options KTRACE # system call tracing via ktrace(1)
options SYSVMSG # System V message queues
options SYSVSEM # System V semaphores
options SYSVSHM # System V shared memory
#options SHMMAXPGS=1024 # 1024 pages is the default
#options LKM # loadable kernel modules
#options USERCONF # userconf(4) support
#options PIPE_SOCKETPAIR # smaller, but slower pipe(2)
# Diagnostic/debugging support options
#options DIAGNOSTIC # cheap kernel consistency checks
options DEBUG # expensive debugging checks/support
options DDB # in-kernel debugger
options DDB_HISTORY_SIZE=512 # enable history editing in DDB
options TRAP_PANICWAIT
options SYMTAB_SPACE=300000 # size for embedded symbol table
makeoptions DEBUG="-g" # compile full symbol table
# Compatibility options
#options COMPAT_09 # NetBSD 0.9,
#options COMPAT_10 # NetBSD 1.0,
#options COMPAT_11 # NetBSD 1.1,
#options COMPAT_12 # NetBSD 1.2,
options COMPAT_13 # NetBSD 1.3,
options COMPAT_14 # NetBSD 1.4,
options COMPAT_43 # and 4.3BSD
#options COMPAT_386BSD_MBRPART # recognize old partition ID
#options TCP_COMPAT_42 # 4.2BSD TCP/IP bug compat. Not recommended.
# File systems
file-system FFS # UFS
file-system EXT2FS # second extended file system (linux)
file-system LFS # log-structured file system
file-system MFS # memory file system
file-system NFS # Network File System client
file-system CD9660 # ISO 9660 + Rock Ridge file system
file-system MSDOSFS # MS-DOS file system
file-system FDESC # /dev/fd
file-system KERNFS # /kern
file-system NULLFS # loopback file system
file-system OVERLAY # overlay file system
file-system PORTAL # portal filesystem (still experimental)
file-system PROCFS # /proc
file-system UMAPFS # NULLFS + uid and gid remapping
file-system UNION # union file system
# File system options
options QUOTA # UFS quotas
options FFS_EI # FFS Endian Independant support
options SOFTDEP # FFS soft updates support.
options NFSSERVER # Network File System server
options EXT2FS_SYSTEM_FLAGS # makes ext2fs file flags (append and
# immutable) behave as system flags.
options NFS_BOOT_DHCP # Support DHCP NFS root
# Networking options
options GATEWAY # packet forwarding
options INET # IP + ICMP + TCP + UDP
options INET6 # IPV6
#options IPSEC # IP security
#options IPSEC_ESP # IP security (encryption part; define w/IPSEC)
#options IPSEC_DEBUG # debug for IP security
#options MROUTING # IP multicast routing
#options DIRECTED_BROADCAST # allow broadcasts through routers
#options NS # XNS
#options NSIP # XNS tunneling over IP
options ISO,TPIP # OSI
#options EON # OSI tunneling over IP
#options CCITT,LLC,HDLC # X.25
#options NETATALK # AppleTalk networking protocols
options PPP_BSDCOMP # BSD-Compress compression support for PPP
options PPP_DEFLATE # Deflate compression support for PPP
options PPP_FILTER # Active filter support for PPP (requires bpf)
options PFIL_HOOKS # pfil(9) packet filter hooks
options IPFILTER_LOG # ipmon(8) log support
#options TCP_DEBUG # Record last TCP_NDEBUG packets with SO_DEBUG
options NMBCLUSTERS=1024
# These options enable verbose messages for several subsystems.
# Warning, these may compile large string tables into the kernel!
options PCIVERBOSE # verbose PCI device autoconfig messages
options MIIVERBOSE # verbose PHY autoconfig messages
#options PCI_CONFIG_DUMP # verbosely dump PCI config space
options SCSIVERBOSE # human readable SCSI error messages
options PCI_NETBSD_CONFIGURE # Do not rely on BIOS/whatever to configure PCI devices
#options PCI_CONFIGURE_VERBOSE # Show PCI config information
# wscons options
#options WSEMUL_SUN # sun terminal emulation
#options WSEMUL_VT100 # VT100 / VT220 emulation
# Kernel root file system and dump configuration.
config netbsd root on ? type ?
#
# Device configuration
#
plb0 at root # Processor Local Bus
cpu0 at plb?
ecc0 at plb? irq 16 # On-chip ECC controller
opb* at plb? # On-chip Peripheral Bus
wdog* at opb? # Watchdog timer
com* at opb? addr ? irq ? # UARTs
emac0 at opb? addr ? irq ? # Ethernet Media Access Controller
options EMAC_EVENT_COUNTERS
iic0 at opb? addr ? irq ? # IIC
rtc0 at iic? addr ? # RTC
todclock0 at rtc? # time-of-day device via rtc device
pchb0 at plb? # PCI-Host bridges
pci* at pchb?
ppb* at pci? dev ? function ? # PCI-PCI bridges
pciide* at pci? dev ? function ?
tlp* at pci? dev ? function ? # DECchip 21x4x and clones
lxtphy* at mii? phy ? # Level One LXT-970 PHYs
ukphy* at mii? phy ? # generic unknown PHYs
#cardslot* at cbb?
#cardbus* at cardslot?
#pcmcia* at cardslot?
#com* at pcmcia? function ? # Modems and serial cards
#wdc* at pcmcia? function ? # PCMCIA IDE controllers
#ep* at pcmcia? function ? # 3Com 3c589 and 3c562 Ethernet
#mbe* at pcmcia? function ? # MB8696x based Ethernet
#ne* at pcmcia? function ? # NE2000-compatible Ethernet
#ex* at cardbus? dev ? function ? # 3Com 3C575TX
#tlp* at cardbus? dev ? function ? # DECchip 21143
#rtk* at cardbus? dev ? function ? # Realtek 8129/8139
wd* at pciide? channel ? drive ?
atapibus* at pciide? channel ?
cd* at atapibus? drive ? flags 0x0000 # ATAPI CD-ROM drives
sd* at atapibus? drive ? flags 0x0000 # ATAPI disk drives
uk* at atapibus? drive ? flags 0x0000 # ATAPI unknown
#pckbc0 at pbus?
#pckbd* at pckbc?
#wskbd* at pckbd? console ?
#pms* at pckbc?
#wsmouse* at pms? mux 0
#vga* at pci? dev ? function ?
#wsdisplay* at vga? console ?
pseudo-device vnd 4 # disk-like interface to files
pseudo-device ccd 4 # concatenated/striped disk devices
#pseudo-device cgd 4 # cryptographic disk devices
#pseudo-device raid 4 # RAIDframe disk driver
#options RAID_AUTOCONFIG # auto-configuration of RAID components
pseudo-device md 1 # memory disk device
pseudo-device loop # network loopback
pseudo-device bpfilter 8 # packet filter
pseudo-device ipfilter # IP filter (firewall) and NAT
pseudo-device ppp 2 # Point-to-Point Protocol
pseudo-device sl 2 # Serial Line IP
pseudo-device tun 4 # network tunneling over tty
#pseudo-device gre 2 # generic L3 over IP tunnel
pseudo-device gif 4 # IPv[46] over IPv[46] tunnel (RFC1933)
#pseudo-device faith 1 # IPv[46] tcp relay translation i/f
#pseudo-device stf 1 # 6to4 IPv6 over IPv4 encapsulation
pseudo-device vlan # IEEE 802.1q encapsulation
pseudo-device pty # pseudo-terminals
pseudo-device rnd # /dev/random and in-kernel generator
#pseudo-device wsmux # ick
pseudo-device clockctl # user control of clock subsystem
pseudo-device kttcp # kernel ttcp

View File

@ -0,0 +1,47 @@
# $NetBSD: files.obs405,v 1.1 2003/09/23 14:45:13 shige Exp $
#
# obs405-specific configuration info
file arch/powerpc/ibm4xx/ibm4xxGPx_autoconf.c
file arch/powerpc/ibm4xx/ibm40x_machdep.c
file arch/evbppc/obs405/consinit.c
file arch/evbppc/obs405/machdep.c
# Memory Disk for install kernel
file dev/md_root.c memory_disk_hooks
# Machine-independent SCSI drivers
include "dev/scsipi/files.scsipi"
# Machine-independent ATA drivers
include "dev/ata/files.ata"
# Workstation Console
include "dev/wscons/files.wscons"
# Raster operations
include "dev/rasops/files.rasops"
include "dev/wsfont/files.wsfont"
define todservice {}
device todclock
attach todclock at todservice
file arch/powerpc/ibm4xx/dev/todclock.c todclock needs-count
#file arch/evbppc/obs405/dev/todclock.c todclock needs-count
device rtc: todservice
attach rtc at iic
file arch/evbppc/obs405/dev/x1226.c rtc
#
# Machine-independent CardBus drivers
#
# XXX dev/pcmcia needs fdc
device fdc {drive = -1}
include "dev/cardbus/files.cardbus"
include "dev/pcmcia/files.pcmcia"
file arch/macppc/macppc/rbus_machdep.c cardbus

View File

@ -0,0 +1,28 @@
# $NetBSD: std.obs405,v 1.1 2003/09/23 14:45:13 shige Exp $
#
# Standard/required options for NetBSD/obs405.
machine evbppc powerpc
# standard ("mandatory") kernel options.
options PPC_IBM4XX # IBM 40x family
# Executable support:
options EXEC_ELF32 # (native) ELF32 binary support
options EXEC_AOUT # (native) a.out binary support (deprecated)
options EXEC_SCRIPT # shell script support
makeoptions TEXTADDR=0x25000
makeoptions BOARDTYPE="obs405"
makeoptions PPCDIR="ibm4xx"
options PPC_INTR_IMPL="<powerpc/ibm4xx/ibm4xx_intr.h>"
options PPC_PCI_MACHDEP_IMPL="<powerpc/ibm4xx/pci_machdep.h>"
options KERNBASE=0x25000
options INTSTK=16384
options SPILLSTK=1024
include "arch/powerpc/conf/files.ibm4xx"
include "arch/powerpc/conf/files.ibm405gp"
include "arch/evbppc/conf/files.obs405"

View File

@ -0,0 +1,139 @@
/* $NetBSD: consinit.c,v 1.1 2003/09/23 14:45:14 shige Exp $ */
/*
* Copyright (c) 1998
* Matthias Drochner. 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.
*
* 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/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.1 2003/09/23 14:45:14 shige Exp $");
#include "opt_kgdb.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/bus.h>
#include <powerpc/ibm4xx/ibm405gp.h>
#include <powerpc/ibm4xx/dev/opbvar.h>
#include "com.h"
#if (NCOM > 0)
#include <sys/termios.h>
#include <dev/ic/comreg.h>
#include <dev/ic/comvar.h>
#endif
#include <dev/cons.h>
#ifndef CONSDEVNAME
#define CONSDEVNAME "com"
#endif
#if (NCOM > 0)
#ifndef CONADDR
#define CONADDR IBM405GP_UART0_BASE
#endif
#ifndef CONSPEED
#define CONSPEED B9600 /* */
// #define CONSPEED B115200 /* 9600 is too slow for my taste */
#endif
#ifndef CONMODE
#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#endif
int comcnmode = CONMODE;
#endif /* NCOM */
#ifdef KGDB
#ifndef KGDB_DEVNAME
#define KGDB_DEVNAME "com"
#endif
char kgdb_devname[] = KGDB_DEVNAME;
#if (NCOM > 1)
#ifndef KGDB_DEVADDR
#define KGDB_DEVADDR UART1_BASE
#endif
int comkgdbaddr = KGDB_DEVADDR;
#ifndef KGDB_DEVRATE
#define KGDB_DEVRATE CONSPEED
#endif
int comkgdbrate = KGDB_DEVRATE;
#ifndef KGDB_DEVMODE
#define KGDB_DEVMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
#endif
int comkgdbmode = KGDB_DEVMODE;
#endif /* NCOM */
#endif /* KGDB */
/*
* consinit:
* initialize the system console.
* XXX - shouldn't deal with this initted thing, but then,
* it shouldn't be called from initppc either.
*/
void
consinit(void)
{
static int initted = 0;
#if (NCOM > 0)
bus_space_tag_t tag;
#endif
if (initted)
return;
initted = 1;
#if (NCOM > 0)
/* We *know* the com-console attaches to opb */
tag = opb_get_bus_space_tag();
if (comcnattach(tag, CONADDR, CONSPEED, COM_FREQ*4,
COM_TYPE_NORMAL, comcnmode))
panic("can't init serial console @%x", CONADDR);
else
return;
#endif
panic("console device missing -- serial console not in kernel");
/* Of course, this is moot if there is no console... */
}
#ifdef KGDB
void
kgdb_port_init(void)
{
#if (NCOM > 0)
if(!strcmp(kgdb_devname, "com")) {
bus_space_tag_t tag = opb_get_bus_space_tag();
com_kgdb_attach(tag, comkgdbaddr, comkgdbrate, COM_FREQ * 4,
COM_TYPE_NORMAL, comkgdbmode);
}
#endif
}
#endif

View File

@ -0,0 +1,266 @@
/* $NetBSD: x1226.c,v 1.1 2003/09/23 14:45:15 shige Exp $ */
/*
* Copyright (c) 2003 Shigeyuki Fukushima.
* All rights reserved.
*
* Written by Shigeyuki Fukushima.
*
* 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 Mark Brinicombe
* for the NetBSD Project.
* 4. The name of the company nor the name of the author may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY CAUASLITY LIMITED ``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 CAUSALITY LIMITED 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: x1226.c,v 1.1 2003/09/23 14:45:15 shige Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/rtc.h>
#include <machine/bus.h>
#include <powerpc/ibm4xx/dev/iicvar.h>
#include <powerpc/ibm4xx/dev/todclockvar.h>
#include <evbppc/obs405/dev/x1226reg.h>
struct xrtc_softc {
struct device sc_dev;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
struct iic_softc *adap;
};
static void xrtc_attach(struct device *, struct device *, void *);
static int xrtc_match(struct device *, struct cfdata *, void *);
static int xrtc_read(void *, rtc_t *);
static int xrtc_write(void *, rtc_t *);
static inline u_char x1226_read(struct xrtc_softc *, u_int16_t);
static inline u_char x1226_write(struct xrtc_softc *, u_int16_t, u_char);
static int x1226_lock(struct xrtc_softc *);
static int x1226_unlock(struct xrtc_softc *);
/* device and attach structures */
CFATTACH_DECL(rtc, sizeof(struct xrtc_softc),
xrtc_match, xrtc_attach, NULL, NULL);
/*
* xrtc_match()
*/
static int
xrtc_match(struct device *parent, struct cfdata *cf, void *aux)
{
struct iicbus_attach_args *iaa = aux;
/* match only RTC devices */
if (strcmp(iaa->iicb_name, cf->cf_name) == 0)
return (1);
return (0);
}
/*
* xrtc_attach()
*/
static void
xrtc_attach(struct device *parent, struct device *self, void *aux)
{
struct xrtc_softc *sc = (struct xrtc_softc *)self;
struct iicbus_attach_args *iaa = aux;
struct todclock_attach_args ta;
sc->sc_iot = 0;
sc->sc_ioh = iaa->iicb_addr;
sc->adap = iaa->adap;
/* Make sure the clock is running */
/* x1226_unlock(sc); */
if (x1226_read(sc, X1226_SR) & X1226_SR_RTCF)
printf(": power failure, RTC unreliable");
printf("\n");
#ifdef DEBUG
{
rtc_t rtc;
xrtc_read(sc, &rtc);
printf("RTC: %02d%02d/%02d/%02d %02d:%02d:%02d\n",
rtc.rtc_cen, rtc.rtc_year,
rtc.rtc_mon, rtc.rtc_day,
rtc.rtc_hour, rtc.rtc_min, rtc.rtc_sec);
}
#endif
ta.ta_name = "todclock";
ta.ta_rtc_arg = sc;
ta.ta_rtc_write = xrtc_write;
ta.ta_rtc_read = xrtc_read;
ta.ta_flags = 0;
config_found(self, &ta, NULL);
}
static inline u_char
x1226_read(struct xrtc_softc *sc, u_int16_t addr)
{
u_char ret, baddr[2];
int addrmsk = (X1226_SIZE - 1);
baddr[0] = (((addr & addrmsk) >> 8) & 0xff);
baddr[1] = ((addr & addrmsk) & 0xff);
iic_read(sc->adap, X1226_DEVID_CCR, baddr, 2, &ret, 1);
return ret;
}
static inline u_char
x1226_write(struct xrtc_softc *sc, u_int16_t addr, u_char d)
{
u_char ret, data[1], baddr[2];
int addrmsk = (X1226_SIZE - 1);
data[0] = d;
baddr[0] = (((addr & addrmsk) >> 8) & 0xff);
baddr[1] = ((addr & addrmsk) & 0xff);
ret = iic_write(sc->adap, X1226_DEVID_CCR, baddr, 2, data, 1);
return ret;
}
#define BIN2BCD(x) ((((x) / 10) << 4) | (x % 10))
#define BCD2BIN(x) (((((x) >> 4) & 0xf) * 10) + ((x) & 0xf))
static int
x1226_unlock(struct xrtc_softc *sc)
{
u_char sr;
sr = X1226_SR_WEL;
x1226_write(sc, X1226_SR, sr);
sr |= X1226_SR_RWEL;
x1226_write(sc, X1226_SR, sr);
sr = 0;
sr = x1226_read(sc, X1226_SR);
sr &= (X1226_SR_RWEL | X1226_SR_WEL);
if (sr != (X1226_SR_RWEL | X1226_SR_WEL)) {
return 1;
}
return 0;
}
static int
x1226_lock(struct xrtc_softc *sc)
{
u_char sr;
sr = 0;
x1226_write(sc, X1226_SR, sr);
sr = 0;
sr = x1226_read(sc, X1226_SR);
sr &= (X1226_SR_RWEL | X1226_SR_WEL);
if (sr != 0) {
return 1;
}
return 0;
}
static int
xrtc_write(void * arg, rtc_t * rtc)
{
struct xrtc_softc *sc = arg;
if (x1226_unlock(sc) != 0) {
return (1);
}
x1226_write(sc, X1226_RTC_SC,
BIN2BCD(rtc->rtc_sec) & 0x7f);
x1226_write(sc, X1226_RTC_MN,
BIN2BCD(rtc->rtc_min) & 0x7f);
x1226_write(sc, X1226_RTC_HR, /* 24 hour format */
(BIN2BCD(rtc->rtc_hour) & 0x1f) | X1226_RTC_HR_MIL);
x1226_write(sc, X1226_RTC_DT,
BIN2BCD(rtc->rtc_day) & 0x3f);
x1226_write(sc, X1226_RTC_MO,
BIN2BCD(rtc->rtc_mon) & 0x1f);
x1226_write(sc, X1226_RTC_YR,
BIN2BCD(rtc->rtc_year) & 0xff);
x1226_write(sc, X1226_RTC_Y2K,
BIN2BCD(rtc->rtc_cen) & 0x3f);
x1226_lock(sc);
xrtc_read(arg, rtc);
return (0);
}
static int
xrtc_read(void *arg, rtc_t *rtc)
{
struct xrtc_softc *sc = arg;
u_char hreg;
rtc->rtc_micro = 0;
rtc->rtc_centi = 0;
/* YYYY */
rtc->rtc_cen = BCD2BIN(x1226_read(sc, X1226_RTC_Y2K) & 0x3f);
rtc->rtc_year = BCD2BIN(x1226_read(sc, X1226_RTC_YR));
/* MM */
rtc->rtc_mon = BCD2BIN(x1226_read(sc, X1226_RTC_MO) & 0x1f);
/* DD */
rtc->rtc_day = BCD2BIN(x1226_read(sc, X1226_RTC_DT) & 0x3f);
/* HH */
hreg = x1226_read(sc, X1226_RTC_HR);
rtc->rtc_hour = BCD2BIN(hreg & 0x1f);
if (!(hreg & X1226_RTC_HR_MIL)) {
if (hreg & X1226_RTC_HR_H21) {
rtc->rtc_hour += 12;
if (rtc->rtc_hour >= 24)
rtc->rtc_hour = 0;
}
}
/* MM */
rtc->rtc_min = BCD2BIN(x1226_read(sc, X1226_RTC_MN) & 0x7f);
/* SS */
rtc->rtc_sec = BCD2BIN(x1226_read(sc, X1226_RTC_SC) & 0x7f);
return (1);
}

View File

@ -0,0 +1,78 @@
/* $NetBSD: x1226reg.h,v 1.1 2003/09/23 14:45:15 shige Exp $ */
/*
* Copyright 2003 Shigeyuki Fukushima.
* All rights reserved.
*
* Written by Shigeyuki Fukushima.
*
* 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 for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
#ifndef __X1226REG_H__
#define __X1226REG_H__
/* XICOR X1226 Device Identifier */
#define X1226_DEVID_CCR 0x6f
#define X1226_DEVID_EEPROM 0x57
/* XICOR X1226 Watchdog RTC registers */
#define X1226_SR 0x3f
#define X1226_RTC_Y2K 0x37 /* century (19/20) */
#define X1226_RTC_DW 0x36 /* day of week (0-6) */
#define X1226_RTC_YR 0x35 /* year (0-99) */
#define X1226_RTC_MO 0x34 /* month (1-12) */
#define X1226_RTC_DT 0x33 /* day (1-31) */
#define X1226_RTC_HR 0x32 /* hour (0-23) */
#define X1226_RTC_MN 0x31 /* minute (0-59) */
#define X1226_RTC_SC 0x30 /* second (0-59) */
#define X1226_RTC_BASE 0x30
#define X1226_CTRL_DTR 0x13
#define X1226_CTRL_ATR 0x12
#define X1226_CTRL_INT 0x11
#define X1226_CTRL_BL 0x10
/* XICOR X1226 RTC flags */
#define X1226_SR_RTCF 0x01
#define X1226_SR_WEL 0x02
#define X1226_SR_RWEL 0x04
#define X1226_SR_AL0 0x20
#define X1226_SR_AL1 0x40
#define X1226_SR_BAT 0x80
#define X1226_RTC_HR_H21 0x20
#define X1226_RTC_HR_MIL 0x80
/* XICOR X1226 size */
#define X1226_SIZE 0x0100 /* 4kbit (512 x 8bit) */
/* Y2K definitions */
#define EPOCH 2000
#define SYS_EPOCH 1900
#endif /* __X1226REG_H__ */

View File

@ -0,0 +1,293 @@
/* $NetBSD: machdep.c,v 1.1 2003/09/23 14:45:14 shige Exp $ */
/*
* Copyright 2001, 2002 Wasabi Systems, Inc.
* All rights reserved.
*
* Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
*
* 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 for the NetBSD Project by
* Wasabi Systems, Inc.
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
* or promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC
* 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.
*/
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
* Copyright (C) 1995, 1996 TooLs GmbH.
* 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 TooLs GmbH.
* 4. The name of TooLs GmbH may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.1 2003/09/23 14:45:14 shige Exp $");
#include "opt_compat_netbsd.h"
#include "opt_ddb.h"
#include "opt_ipkdb.h"
#include <sys/param.h>
#include <sys/buf.h>
#include <sys/exec.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mount.h>
#include <sys/msgbuf.h>
#include <sys/proc.h>
#include <sys/reboot.h>
#include <sys/sa.h>
#include <sys/syscallargs.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/user.h>
#include <sys/boot_flag.h>
#include <sys/properties.h>
#include <sys/ksyms.h>
#include <uvm/uvm.h>
#include <uvm/uvm_extern.h>
#include <net/netisr.h>
#include <machine/bus.h>
#include <machine/trap.h>
#include <machine/powerpc.h>
#include <powerpc/spr.h>
#include <powerpc/ibm4xx/dcr405gp.h>
#include "ksyms.h"
/*
* Global variables used here and there
*/
char bootpath[256];
extern paddr_t msgbuf_paddr;
extern struct board_cfg_data board_data;
#if NKSYMS || defined(DDB) || defined(LKM)
void *startsym, *endsym;
#endif
void initppc(u_int, u_int, char *, void *);
int lcsplx(int);
void
initppc(u_int startkernel, u_int endkernel, char *args, void *info_block)
{
/* Disable all external interrupts */
mtdcr(DCR_UIC0_ER, 0);
ibm4xx_init_board_data(info_block, startkernel);
ibm4xx_init((void (*)(void))ext_intr);
/*
* Initialize console.
*/
consinit();
/*
* Set the page size.
*/
uvm_setpagesize();
/*
* Initialize pmap module.
*/
pmap_bootstrap(startkernel, endkernel);
#ifdef DEBUG
printf("Board config data:\n");
printf(" usr_config_ver = %s\n", board_data.usr_config_ver);
printf(" rom_sw_ver = %s\n", board_data.rom_sw_ver);
printf(" mem_size = %u\n", board_data.mem_size);
printf(" mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n",
board_data.mac_address_local[0], board_data.mac_address_local[1],
board_data.mac_address_local[2], board_data.mac_address_local[3],
board_data.mac_address_local[4], board_data.mac_address_local[5]);
printf(" mac_address_pci = %02x:%02x:%02x:%02x:%02x:%02x\n",
board_data.mac_address_pci[0], board_data.mac_address_pci[1],
board_data.mac_address_pci[2], board_data.mac_address_pci[3],
board_data.mac_address_pci[4], board_data.mac_address_pci[5]);
printf(" processor_speed = %u\n", board_data.processor_speed);
printf(" plb_speed = %u\n", board_data.plb_speed);
printf(" pci_speed = %u\n", board_data.pci_speed);
#endif
#if NKSYMS || defined(DDB) || defined(LKM)
ksyms_init((int)((u_int)endsym - (u_int)startsym), startsym, endsym);
#endif
#ifdef DDB
if (boothowto & RB_KDB)
Debugger();
#endif
#ifdef IPKDB
/*
* Now trap to IPKDB
*/
ipkdb_init();
if (boothowto & RB_KDB)
ipkdb_connect(0);
#endif
}
int
lcsplx(int ipl)
{
return spllower(ipl); /* XXX */
}
/*
* Machine dependent startup code.
*/
void
cpu_startup(void)
{
/*
* cpu common startup
*/
ibm4xx_startup("OpenBlockS266 IBM PowerPC 405GPr Board");
/*
* Set up the board properties database.
*/
ibm4xx_setup_propdb();
/*
* Now that we have VM, malloc()s are OK in bus_space.
*/
bus_space_mallocok();
/*
* no fake mapiodev
*/
fake_mapiodev = 0;
}
/*
* Halt or reboot the machine after syncing/dumping according to howto.
*/
void
cpu_reboot(int howto, char *what)
{
static int syncing;
static char str[256];
char *ap = str, *ap1 = ap;
boothowto = howto;
if (!cold && !(howto & RB_NOSYNC) && !syncing) {
syncing = 1;
vfs_shutdown(); /* sync */
resettodr(); /* set wall clock */
}
splhigh();
if (!cold && (howto & RB_DUMP))
ibm4xx_dumpsys();
doshutdownhooks();
if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
/* Power off here if we know how...*/
}
if (howto & RB_HALT) {
printf("halted\n\n");
goto reboot; /* XXX for now... */
#ifdef DDB
printf("dropping to debugger\n");
while(1)
Debugger();
#endif
}
printf("rebooting\n\n");
if (what && *what) {
if (strlen(what) > sizeof str - 5)
printf("boot string too large, ignored\n");
else {
strcpy(str, what);
ap1 = ap = str + strlen(str);
*ap++ = ' ';
}
}
*ap++ = '-';
if (howto & RB_SINGLE)
*ap++ = 's';
if (howto & RB_KDB)
*ap++ = 'd';
*ap++ = 0;
if (ap[-2] == '-')
*ap1 = 0;
/* flush cache for msgbuf */
__syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
reboot:
ppc4xx_reset();
printf("ppc4xx_reset() failed!\n");
#ifdef DDB
while(1)
Debugger();
#else
while (1)
/* nothing */;
#endif
}