Add support for optional Z85C30 serial console on Cobalt Qube 2700.

Bump version.
This commit is contained in:
tsutsui 2008-03-16 10:10:43 +00:00
parent c3a503482a
commit 49576266b9
5 changed files with 301 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.15 2008/03/02 06:17:41 tsutsui Exp $
# $NetBSD: Makefile,v 1.16 2008/03/16 10:10:43 tsutsui Exp $
NOMAN= # defined
@ -48,6 +48,11 @@ COMBASE?=0xbc800000
COMSPEED?=115200
COMPROBE?=0xa020001c
ZSCHAN?=0x01 # 0x01: ZS_CHAN_A, 0x00: ZS_CHAN_B
ZSBASE?=0xbc800000
ZSSPEED?=115200
ZSPROBE?=0xa020001c
AFLAGS+= -D_LOCORE -D_KERNEL -DASSEMBLER -mno-abicalls
# -I${.CURDIR}/../.. done by Makefile.inc
@ -56,6 +61,8 @@ CPPFLAGS+= -nostdinc -D_STANDALONE -DNO_ABICALLS -D_NO_PROM_DEFINES
CPPFLAGS+= -I${.OBJDIR} -I${S} -I${S}/arch -I${LIBSADIR}
CPPFLAGS+= -DCONS_SERIAL -DCOMBASE=${COMBASE} -DCOMPORT=${COMPORT}
CPPFLAGS+= -DCOMSPEED=${COMSPEED} -DCOMPROBE=${COMPROBE}
CPPFLAGS+= -DCONS_ZS -DZSBASE=${ZSBASE} -DZSCHAN=${ZSCHAN}
CPPFLAGS+= -DZSSPEED=${ZSSPEED} -DZSPROBE=${ZSPROBE}
CPPFLAGS+= -DSUPPORT_DHCP -DSUPPORT_BOOTP
#CPPFLAGS+= -DBOOTP_DEBUG -DNETIF_DEBUG -DETHER_DEBUG -DNFS_DEBUG
#CPPFLAGS+= -DRPC_DEBUG -DRARP_DEBUG -DNET_DEBUG -DDEBUG -DPARANOID
@ -76,6 +83,7 @@ PROG= boot
# common sources
SRCS+= start.S boot.c devopen.c conf.c clock.c bootinfo.c
SRCS+= prf.c com.c cons.c ns16550.c pciide.c tgets.c wdc.c wd.c
SRCS+= zs.c
SRCS+= cache.c pci.c nif_tlp.c tlp.c
# XXX dev_net.c should really be in libsa, but it doesn't

View File

@ -1,4 +1,4 @@
/* $NetBSD: cons.c,v 1.6 2008/03/01 05:15:31 tsutsui Exp $ */
/* $NetBSD: cons.c,v 1.7 2008/03/16 10:10:43 tsutsui Exp $ */
/*
* Copyright (c) 1990, 1993
@ -96,10 +96,29 @@ int siocnscan(void *);
# endif
#endif
#ifdef CONS_ZS
void zscnprobe(struct consdev *);
void zscninit(struct consdev *);
void zscnputchar(void *, int);
int zscngetchar(void *);
int zscnscan(void *);
#include "zs.h"
#ifndef ZSCHAN
#define ZSCHAN ZS_CHAN_A
#endif
#ifndef ZSSPEED
#define ZSSPEED 115200
#endif
#endif
struct consdev constab[] = {
#ifdef CONS_SERIAL
{ "com", COMPORT, COMSPEED,
siocnprobe, siocninit, siocngetchar, siocnputchar, siocnscan },
#endif
#ifdef CONS_ZS
{ "zs", ZSCHAN, ZSSPEED,
zscnprobe, zscninit, zscngetchar, zscnputchar, zscnscan },
#endif
{ 0 }
};
@ -245,7 +264,8 @@ void
siocnprobe(struct consdev *cp)
{
if (*((uint32_t *)COMPROBE) != 0)
if (*((uint32_t *)COMPROBE) != 0 &&
cobalt_id != COBALT_ID_QUBE2700)
cp->cn_pri = CN_REMOTE;
}
@ -279,3 +299,47 @@ siocnscan(void *dev)
return NS16550_scankbd((struct NS16550 *)dev);
}
#endif /* CONS_SERIAL */
#ifdef CONS_ZS
/*
* optional z85c30 serial console on Qube2700
*/
void
zscnprobe(struct consdev *cp)
{
if (*((uint32_t *)ZSPROBE) != 0 &&
cobalt_id == COBALT_ID_QUBE2700)
cp->cn_pri = CN_REMOTE;
}
void
zscninit(struct consdev *cp)
{
cp->cn_dev = zs_init(cp->address, cp->speed);
}
int
zscngetchar(void *dev)
{
return zs_getc(dev);
}
void
zscnputchar(void *dev, int c)
{
if (c == '\n')
zs_putc(dev, '\r');
zs_putc(dev, c);
}
int
zscnscan(void *dev)
{
return zs_scan(dev);
}
#endif /* CONS_ZS */

View File

@ -1,4 +1,4 @@
$NetBSD: version,v 1.8 2008/03/01 20:39:25 tsutsui Exp $
$NetBSD: version,v 1.9 2008/03/16 10:10:43 tsutsui Exp $
NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this
file is important - make sure the entries are appended on end, last item
@ -12,3 +12,4 @@ is taken as the current.
0.5: Add support for netboot via tlp0
0.6: Print a cobalt model name in banner
0.7: Add support for netboot via 21041 on Qube2700
0.8: Add support for optional Z85C30 serial console on Qube2700

View File

@ -0,0 +1,172 @@
/* $NetBSD: zs.c,v 1.1 2008/03/16 10:10:43 tsutsui Exp $ */
/*-
* Copyright (C) 2008 Izumi Tsutsui.
*
* 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. 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.
*/
#ifdef CONS_ZS
/*
* optional Z85C30 serial support for Qube 2700
*/
#include <lib/libsa/stand.h>
#include <dev/ic/z8530reg.h>
#include "boot.h"
#include "zs.h"
#define ZSCLOCK 11059200 /* 19200 * 576 */
#define ZS_DELAY() delay(2)
static uint8_t zs_read(void *, uint8_t);
static void zs_write(void *, uint8_t, uint8_t);
static void zs_write_reg(void *, uint8_t, uint8_t);
static void zs_reset(void *);
static uint8_t
zs_read(void *dev, uint8_t reg)
{
volatile uint8_t *zs = dev;
uint8_t val;
val = *(volatile uint8_t *)(zs + reg);
ZS_DELAY();
return val;
}
static void
zs_write(void *dev, uint8_t reg, uint8_t val)
{
volatile uint8_t *zs = dev;
*(volatile uint8_t *)(zs + reg) = val;
ZS_DELAY();
}
static void
zs_write_reg(void *dev, uint8_t reg, uint8_t val)
{
zs_write(dev, ZS_CSR, reg);
zs_write(dev, ZS_CSR, val);
}
static void
zs_reset(void *dev)
{
/* clear errors */
zs_write_reg(dev, 9, 0);
/* hardware reset */
zs_write_reg(dev, 9, ZSWR9_HARD_RESET);
delay(1000);
/* disable all inerttupts */
zs_write_reg(dev, 1, 0);
/* set TX/RX misc parameters and modes */
zs_write_reg(dev, 4, ZSWR4_CLK_X16 | ZSWR4_ONESB | ZSWR4_EVENP);
zs_write_reg(dev, 10, ZSWR10_NRZ);
zs_write_reg(dev, 3, ZSWR3_RX_8);
zs_write_reg(dev, 5, ZSWR5_TX_8 | ZSWR5_DTR | ZSWR5_RTS);
/* sync registers unused */
zs_write_reg(dev, 6, 0);
zs_write_reg(dev, 7, 0);
/* set baud rate generator mode */
zs_write_reg(dev, 14, ZSWR14_BAUD_FROM_PCLK);
/* set clock mode */
zs_write_reg(dev, 11, ZSWR11_RXCLK_BAUD | ZSWR11_TXCLK_BAUD);
/* set baud rate constant */
zs_write_reg(dev, 12, BPS_TO_TCONST(ZSCLOCK / 16, ZSSPEED));
zs_write_reg(dev, 13, 0);
/* enable baud rate generator */
zs_write_reg(dev, 14, ZSWR14_BAUD_FROM_PCLK | ZSWR14_BAUD_ENA);
/* disable all external interrupts */
zs_write_reg(dev, 15, 0);
/* reset external status twice (see src/sys/dev/ic/z8530sc.c) */
zs_write(dev, ZS_CSR, ZSWR0_RESET_STATUS);
zs_write(dev, ZS_CSR, ZSWR0_RESET_STATUS);
/* enable TX and RX */
zs_write_reg(dev, 3, ZSWR3_RX_8 | ZSWR3_RX_ENABLE);
zs_write_reg(dev, 5,
ZSWR5_TX_8 | ZSWR5_DTR | ZSWR5_RTS | ZSWR5_TX_ENABLE);
}
void *
zs_init(int addr, int speed)
{
void *zs;
zs = (void *)(ZSBASE + addr);
zs_reset(zs);
return zs;
}
void
zs_putc(void *dev, int c)
{
uint8_t csr;
do {
csr = zs_read(dev, ZS_CSR);
} while ((csr & ZSRR0_TX_READY) == 0);
zs_write(dev, ZS_DATA, c);
}
int
zs_getc(void *dev)
{
uint8_t csr, data;
do {
csr = zs_read(dev, ZS_CSR);
} while ((csr & ZSRR0_RX_READY) == 0);
data = zs_read(dev, ZS_DATA);
return data;
}
int
zs_scan(void *dev)
{
uint8_t csr, data;
csr = zs_read(dev, ZS_CSR);
if ((csr & ZSRR0_RX_READY) == 0)
return -1;
data = zs_read(dev, ZS_DATA);
return data;
}
#endif /* CONS_ZS */

View File

@ -0,0 +1,52 @@
/* $NetBSD: zs.h,v 1.1 2008/03/16 10:10:43 tsutsui Exp $ */
/*-
* Copyright (C) 2008 Izumi Tsutsui.
*
* 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. 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.
*/
/*
* optional Z85C30 serial on Qube 2700
*/
#ifndef ZSBASE
#define ZSBASE 0xbc800000
#endif
/* A/~B (Channel A/Channel B) pin is connected to DAdr0 */
#define ZS_CHAN_A 0x01
#define ZS_CHAN_B 0x00
/* D/~C (Data/Control) pin is connected to DAdr1 */
#define ZS_CSR 0x00
#define ZS_DATA 0x02
#ifndef ZSPROBE
#define ZSPROBE 0xa020001c
#endif
void *zs_init(int, int);
void zs_putc(void *, int);
int zs_getc(void *);
int zs_scan(void *);