Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/hpcsh HD64461 UART module support.
details: https://anonhg.NetBSD.org/src/rev/00c58eaa555f
branches: trunk
changeset: 507157:00c58eaa555f
user: uch <uch%NetBSD.org@localhost>
date: Thu Mar 15 17:30:55 2001 +0000
description:
HD64461 UART module support.
diffstat:
sys/arch/hpcsh/conf/JORNADA690 | 3 +-
sys/arch/hpcsh/conf/files.hpcsh | 8 +-
sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c | 43 +-
sys/arch/hpcsh/dev/hd64461/hd64461uart.c | 228 +++++
sys/arch/hpcsh/dev/hd64461/hd64461uartvar.h | 39 +
sys/arch/hpcsh/hpcsh/bus_space.c | 266 ++++-
sys/arch/hpcsh/hpcsh/conf.c | 22 +-
sys/arch/hpcsh/hpcsh/console.c | 170 +++
sys/arch/hpcsh/hpcsh/machdep.c | 66 +-
sys/arch/hpcsh/hpcsh/shb.c | 6 +-
sys/arch/hpcsh/include/bootinfo.h | 7 +-
sys/arch/hpcsh/include/bus.h | 1173 ++++++++++++--------------
12 files changed, 1256 insertions(+), 775 deletions(-)
diffs (truncated from 2459 to 300 lines):
diff -r ba32cb1dded5 -r 00c58eaa555f sys/arch/hpcsh/conf/JORNADA690
--- a/sys/arch/hpcsh/conf/JORNADA690 Thu Mar 15 17:24:45 2001 +0000
+++ b/sys/arch/hpcsh/conf/JORNADA690 Thu Mar 15 17:30:55 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: JORNADA690,v 1.6 2001/03/08 15:21:31 uch Exp $
+# $NetBSD: JORNADA690,v 1.7 2001/03/15 17:30:55 uch Exp $
#
# JORNADA690 uch's Jornada 690
#
@@ -85,6 +85,7 @@
hd64461if* at shb? irq 4
hd64461pcmcia* at hd64461if?
+com* at hd64461if?
# PCMCIA bus support
pcmcia0 at hd64461pcmcia? controller 0 socket ? # I/O card, memory card
diff -r ba32cb1dded5 -r 00c58eaa555f sys/arch/hpcsh/conf/files.hpcsh
--- a/sys/arch/hpcsh/conf/files.hpcsh Thu Mar 15 17:24:45 2001 +0000
+++ b/sys/arch/hpcsh/conf/files.hpcsh Thu Mar 15 17:30:55 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.hpcsh,v 1.8 2001/02/24 20:17:45 uch Exp $
+# $NetBSD: files.hpcsh,v 1.9 2001/03/15 17:30:55 uch Exp $
#
maxpartitions 8
@@ -6,6 +6,7 @@
file arch/hpcsh/hpcsh/conf.c
file arch/hpcsh/hpcsh/machdep.c
+file arch/hpcsh/hpcsh/console.c
file arch/hpcsh/hpcsh/autoconf.c
file arch/hpcsh/hpcsh/bus_space.c
file arch/hpcsh/hpcsh/procfs_machdep.c procfs
@@ -63,12 +64,15 @@
define hd64461if {}
device hd64461if: hd64461if
attach hd64461if at shb
-file arch/hpcsh/dev/hd64461/hd64461.c hd64461if
+file arch/hpcsh/dev/hd64461/hd64461.c hd64461if needs-flag
device hd64461pcmcia: pcmciabus
attach hd64461pcmcia at hd64461if
file arch/hpcsh/dev/hd64461/hd64461pcmcia.c hd64461pcmcia
+attach com at hd64461if with hd64461uart
+file arch/hpcsh/dev/hd64461/hd64461uart.c hd64461uart
+
# network devices MII bus
include "dev/mii/files.mii"
diff -r ba32cb1dded5 -r 00c58eaa555f sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c
--- a/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c Thu Mar 15 17:24:45 2001 +0000
+++ b/sys/arch/hpcsh/dev/hd64461/hd64461pcmcia.c Thu Mar 15 17:30:55 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hd64461pcmcia.c,v 1.2 2001/03/08 15:13:14 uch Exp $ */
+/* $NetBSD: hd64461pcmcia.c,v 1.3 2001/03/15 17:30:55 uch Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -233,6 +233,18 @@
#ifdef DEBUG
static void hd64461pcmcia_info(struct hd64461pcmcia_softc *);
#endif
+/* fix SH3 Area[56] bug */
+static void fixup_sh3_pcmcia_area(bus_space_tag_t);
+#define _BUS_SPACE_ACCESS_HOOK() \
+{ \
+ u_int8_t dummy __attribute__((__unused__)) = \
+ *(volatile u_int8_t *)0xba000000; \
+}
+_BUS_SPACE_WRITE(_sh3_pcmcia_bug, 1, 8)
+_BUS_SPACE_WRITE_MULTI(_sh3_pcmcia_bug, 1, 8)
+_BUS_SPACE_WRITE_REGION(_sh3_pcmcia_bug, 1, 8)
+_BUS_SPACE_SET_MULTI(_sh3_pcmcia_bug, 1, 8)
+#undef _BUS_SPACE_ACCESS_HOOK
#define DELAY_MS(x) delay((x) * 1000)
@@ -364,18 +376,21 @@
/* Attibute/Common memory extent */
membase = (channel == CHANNEL_0)
? HD64461_PCC0_MEMBASE : HD64461_PCC1_MEMBASE;
- ch->ch_memt = bus_space_create("PCMCIA attribute memory",
+
+ ch->ch_memt = bus_space_create(0, "PCMCIA attribute memory",
membase, 0x01000000); /* 16MB */
- bus_space_alloc(ch->ch_memt, 0, 0x01000000, 0x01000000,
+ bus_space_alloc(ch->ch_memt, 0, 0x00ffffff, 0x01000000,
0x01000000, 0x01000000, 0, &ch->ch_membase_addr,
&ch->ch_memh);
+ fixup_sh3_pcmcia_area(ch->ch_memt);
/* Common memory space extent */
ch->ch_memsize = 0x01000000;
for (i = 0; i < MEMWIN_16M_MAX; i++) {
- ch->ch_cmemt[i] = bus_space_create("PCMCIA common memory",
+ ch->ch_cmemt[i] = bus_space_create(0, "PCMCIA common memory",
membase + 0x01000000,
ch->ch_memsize);
+ fixup_sh3_pcmcia_area(ch->ch_cmemt[i]);
}
/* I/O port extent and interrupt staff */
@@ -384,10 +399,10 @@
if (channel == CHANNEL_0) {
ch->ch_iobase = 0;
ch->ch_iosize = HD64461_PCC0_IOSIZE;
- ch->ch_iot = bus_space_create("PCMCIA I/O port",
+ ch->ch_iot = bus_space_create(0, "PCMCIA I/O port",
HD64461_PCC0_IOBASE,
ch->ch_iosize);
-
+ fixup_sh3_pcmcia_area(ch->ch_iot);
hd64461_intr_establish(HD64461_IRQ_PCC0, IST_LEVEL, IPL_TTY,
hd64461pcmcia_channel0_intr, ch);
@@ -615,7 +630,7 @@
&cookie->wc_handle) != 0)
goto bad;
- // XXX bogus. bus_space_tag should be vtbl...
+ // XXX bogus. check window per common memory access.
memory_window_16(ch->ch_channel, window);
*offsetp = ofs + 0x01000000; /* skip attribute area */
cookie->wc_window = window;
@@ -664,7 +679,7 @@
DPRINTF("map %#lx+%#lx\n", start, size);
} else {
if (bus_space_alloc(ch->ch_iot, ch->ch_iobase,
- ch->ch_iobase + ch->ch_iosize,
+ ch->ch_iobase + ch->ch_iosize - 1,
size, align, 0, 0, &pcihp->addr,
&pcihp->ioh)) {
DPRINTF("couldn't allocate %#lx\n", size);
@@ -1026,6 +1041,17 @@
SHREG_BCR2 = r16;
}
+static void
+fixup_sh3_pcmcia_area(bus_space_tag_t t)
+{
+ struct hpcsh_bus_space *hbs = (void *)t;
+
+ hbs->hbs_w_1 = _sh3_pcmcia_bug_write_1;
+ hbs->hbs_wm_1 = _sh3_pcmcia_bug_write_multi_1;
+ hbs->hbs_wr_1 = _sh3_pcmcia_bug_write_region_1;
+ hbs->hbs_sm_1 = _sh3_pcmcia_bug_set_multi_1;
+}
+
#ifdef DEBUG
static void
hd64461pcmcia_info(struct hd64461pcmcia_softc *sc)
@@ -1207,4 +1233,3 @@
dbg_banner_end();
}
#endif /* DEBUG */
-
diff -r ba32cb1dded5 -r 00c58eaa555f sys/arch/hpcsh/dev/hd64461/hd64461uart.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcsh/dev/hd64461/hd64461uart.c Thu Mar 15 17:30:55 2001 +0000
@@ -0,0 +1,228 @@
+/* $NetBSD: hd64461uart.c,v 1.1 2001/03/15 17:30:56 uch Exp $ */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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/param.h>
+#include <sys/systm.h>
+#include <sys/reboot.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+
+#include <sys/termios.h>
+#include <dev/cons.h>
+#include <sys/conf.h>
+
+#include <machine/bus.h>
+#include <machine/intr.h>
+
+#include <dev/ic/comvar.h>
+#include <dev/ic/comreg.h>
+
+#ifdef DEBUG
+#include <hpcsh/hpcsh/debug.h>
+#endif
+
+#include <hpcsh/dev/hd64461/hd64461var.h>
+#include <hpcsh/dev/hd64461/hd64461reg.h>
+#include <hpcsh/dev/hd64461/hd64461intcvar.h>
+
+#include <hpcsh/dev/hd64461/hd64461uartvar.h>
+
+static struct hd64461uart_chip {
+ struct hpcsh_bus_space __tag_body;
+ bus_space_tag_t io_tag;
+ int console;
+} hd64461uart_chip;
+
+struct hd64461uart_softc {
+ struct com_softc sc_com;
+
+ struct hd64461uart_chip *sc_chip;
+ enum hd64461_module_id sc_module_id;
+};
+
+/* boot console */
+cdev_decl(com);
+void comcnprobe(struct consdev *);
+void comcninit(struct consdev *);
+
+static int hd64461uart_match(struct device *, struct cfdata *, void *);
+static void hd64461uart_attach(struct device *, struct device *, void *);
+
+struct cfattach hd64461uart_ca = {
+ sizeof(struct hd64461uart_softc), hd64461uart_match,
+ hd64461uart_attach
+};
+
+static void hd64461uart_init(void);
+static u_int8_t hd64461uart_read_1(void *, bus_space_handle_t, bus_size_t);
+static void hd64461uart_write_1(void *, bus_space_handle_t, bus_size_t,
+ u_int8_t);
+
+#ifdef DEBUG
+static void hd64461uart_info(struct hd64461uart_softc *);
+#endif
+
+#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */
+#ifndef COMCN_SPEED
+#define COMCN_SPEED 19200
+#endif
+
+void
+hd64461uart_cnattach()
+{
+ hd64461uart_init();
+
+ comcnattach(hd64461uart_chip.io_tag, 0x0, COMCN_SPEED, COM_FREQ,
+ CONMODE);
+}
+
+void
+comcnprobe(struct consdev *cp)
+{
+ int maj;
+
+ /* locate the major number */
+ for (maj = 0; maj < nchrdev; maj++)
+ if (cdevsw[maj].d_open == comopen)
+ break;
+
+ /* Initialize required fields. */
+ cp->cn_dev = makedev(maj, 0);
+ cp->cn_pri = CN_NORMAL;
+}
+
+void
+comcninit(struct consdev *cp)
+{
+ hd64461uart_chip.console = 1;
+}
+
+static int
+hd64461uart_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+ struct hd64461_attach_args *ha = aux;
+
+ return (ha->ha_module_id == HD64461_MODULE_UART);
+}
Home |
Main Index |
Thread Index |
Old Index