Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Make VAXstation 4000 TURBOchannel adaptor work.
details: https://anonhg.NetBSD.org/src/rev/57e01c47c9c1
branches: trunk
changeset: 354282:57e01c47c9c1
user: flxd <flxd%NetBSD.org@localhost>
date: Fri Jun 09 17:55:18 2017 +0000
description:
Make VAXstation 4000 TURBOchannel adaptor work.
PIO and IRQ tested on VS4000/60 and /96 with TC-USB (slhci) and PMAD-AA (le).
DMA is untested.
vax needs space to be mapped out, so memory space is pre-mapped for TC option
drivers not bus_space'ified yet, also providing custom bus_space methods for
this kludge.
diffstat:
sys/arch/alpha/tc/tcasic.c | 6 +-
sys/arch/pmax/tc/tcbus.c | 6 +-
sys/arch/vax/conf/files.vax | 6 +-
sys/arch/vax/vsa/tc_vsbus.c | 431 ++++++++++++++++++++++++++++++++++++-------
sys/dev/tc/tc.c | 20 +-
sys/dev/tc/tcvar.h | 4 +-
6 files changed, 381 insertions(+), 92 deletions(-)
diffs (truncated from 643 to 300 lines):
diff -r 3ac464759e4f -r 57e01c47c9c1 sys/arch/alpha/tc/tcasic.c
--- a/sys/arch/alpha/tc/tcasic.c Fri Jun 09 17:36:29 2017 +0000
+++ b/sys/arch/alpha/tc/tcasic.c Fri Jun 09 17:55:18 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcasic.c,v 1.45 2016/12/12 17:03:40 flxd Exp $ */
+/* $NetBSD: tcasic.c,v 1.46 2017/06/09 17:55:18 flxd Exp $ */
/*
* Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
@@ -32,7 +32,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.45 2016/12/12 17:03:40 flxd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcasic.c,v 1.46 2017/06/09 17:55:18 flxd Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -222,7 +222,7 @@
char tcname[TC_ROM_LLEN];
int i;
- if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname) == 0))
+ if (tc_badaddr(tcaddr) || (tc_checkslot(tcaddr, tcname, NULL) == 0))
return (EINVAL);
for (i = 0; i < sizeof(cnboards) / sizeof(cnboards[0]); i++)
diff -r 3ac464759e4f -r 57e01c47c9c1 sys/arch/pmax/tc/tcbus.c
--- a/sys/arch/pmax/tc/tcbus.c Fri Jun 09 17:36:29 2017 +0000
+++ b/sys/arch/pmax/tc/tcbus.c Fri Jun 09 17:55:18 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcbus.c,v 1.32 2016/12/12 17:03:41 flxd Exp $ */
+/* $NetBSD: tcbus.c,v 1.33 2017/06/09 17:55:18 flxd Exp $ */
/*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.32 2016/12/12 17:03:41 flxd Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcbus.c,v 1.33 2017/06/09 17:55:18 flxd Exp $");
#define _PMAX_BUS_DMA_PRIVATE
/*
@@ -221,7 +221,7 @@
int i;
tcaddr = promcall(callv->_slot_address, slotno);
- if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname) == 0)
+ if (tc_badaddr(tcaddr) || tc_checkslot(tcaddr, tcname, NULL) == 0)
panic("TC console designated by PROM does not exist!?");
for (i = 0; i < __arraycount(cnboards); i++) {
diff -r 3ac464759e4f -r 57e01c47c9c1 sys/arch/vax/conf/files.vax
--- a/sys/arch/vax/conf/files.vax Fri Jun 09 17:36:29 2017 +0000
+++ b/sys/arch/vax/conf/files.vax Fri Jun 09 17:55:18 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.vax,v 1.120 2015/07/05 03:06:27 matt Exp $
+# $NetBSD: files.vax,v 1.121 2017/06/09 17:55:18 flxd Exp $
#
# new style config file for vax architecture
#
@@ -110,8 +110,8 @@
# TurboCHANNEL bus support and device drivers
include "dev/tc/files.tc"
-attach tc at vsbus with tcbus
-file arch/vax/vsa/tc_vsbus.c tcbus
+attach tc at vsbus with tc_vsbus
+file arch/vax/vsa/tc_vsbus.c tc_vsbus
attach uba at mainbus with uba_mainbus
file arch/vax/uba/uba_mainbus.c uba_mainbus
diff -r 3ac464759e4f -r 57e01c47c9c1 sys/arch/vax/vsa/tc_vsbus.c
--- a/sys/arch/vax/vsa/tc_vsbus.c Fri Jun 09 17:36:29 2017 +0000
+++ b/sys/arch/vax/vsa/tc_vsbus.c Fri Jun 09 17:55:18 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tc_vsbus.c,v 1.7 2011/06/05 16:12:50 christos Exp $ */
+/* $NetBSD: tc_vsbus.c,v 1.8 2017/06/09 17:55:18 flxd Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -28,120 +28,407 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: tc_vsbus.c,v 1.8 2017/06/09 17:55:18 flxd Exp $");
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/device.h>
+#include <machine/cpu.h>
#include <machine/pte.h>
#include <machine/scb.h>
+#include <machine/sid.h>
#include <machine/vsbus.h>
+
#include <dev/tc/tcvar.h>
-static int tcbus_match(device_t, cfdata_t, void *);
-static void tcbus_attach(device_t, device_t, void *);
+#define NSLOTS 1
-struct tcbus_softc {
+struct tc_vsbus_softc {
struct tc_softc sc_tc;
- struct tc_slotdesc sc_slots[1];
+ struct tc_slotdesc sc_slots[NSLOTS];
struct vax_bus_dma_tag sc_dmatag;
struct vax_sgmap sc_sgmap;
struct evcnt sc_ev;
- bus_space_handle_t sc_memh;
+ int (*sc_intr_func)(void *);
+ void *sc_intr_arg;
+ bus_space_tag_t sc_bst;
+ bus_space_handle_t sc_bsh_csr;
+ int sc_cvec;
+};
+
+static int tc_vsbus_match(device_t, cfdata_t, void *);
+static void tc_vsbus_attach(device_t, device_t, void *);
+
+static int tc_vsbus_dma_init(device_t);
+static bus_dma_tag_t tc_vsbus_get_dma_tag(int);
+
+static void tc_vsbus_intr(void *);
+static void tc_vsbus_intr_establish(device_t, void *, int, int (*)(void *),
+ void *);
+static void tc_vsbus_intr_disestablish(device_t, void *);
+static const struct evcnt *tc_vsbus_intr_evcnt(device_t, void *);
+
+static int vax_tc_bus_space_map(void *, bus_addr_t, bus_size_t, int,
+ bus_space_handle_t *, int);
+static int vax_tc_bus_space_subregion(void *, bus_space_handle_t, bus_size_t,
+ bus_size_t, bus_space_handle_t *);
+static void vax_tc_bus_space_unmap(void *, bus_space_handle_t, bus_size_t, int);
+static int vax_tc_bus_space_alloc(void *, bus_addr_t, bus_addr_t, bus_size_t,
+ bus_size_t, bus_size_t, int, bus_addr_t *, bus_space_handle_t *);
+static void vax_tc_bus_space_free(void *, bus_space_handle_t, bus_size_t);
+static paddr_t vax_tc_bus_space_mmap(void *, bus_addr_t, off_t, int, int);
+
+CFATTACH_DECL_NEW(tc_vsbus, sizeof(struct tc_vsbus_softc),
+ tc_vsbus_match, tc_vsbus_attach, 0, 0);
+
+static bus_dma_tag_t tc_vsbus_dmat;
+
+struct vax_bus_space vax_tc_bus_space = {
+ NULL,
+ vax_tc_bus_space_map,
+ vax_tc_bus_space_unmap,
+ vax_tc_bus_space_subregion,
+ vax_tc_bus_space_alloc,
+ vax_tc_bus_space_free,
+ vax_tc_bus_space_mmap,
};
-static bus_dma_tag_t tcbus_dmat;
+/*
+ * taken from KA46 System Board Specification, KA46-0-DBF, Rev. X.02,
+ * 10 October 1990
+ */
+#define KA46_BWF0 0x20080014
+#define KA46_BWF0_ADP __BIT(31)
+#define KA46_BWF0_SZ 4
+
+/*
+ * taken from KA49 Processor Module Specification V 1.1, 20 August 1992
+ */
+#define KA49_CFG 0x25800000
+#define KA49_CFG_BA __BIT(0)
+#define KA49_CFG_SZ 2
-CFATTACH_DECL_NEW(tcbus, sizeof(struct tcbus_softc),
- tcbus_match, tcbus_attach, 0, 0);
+/*
+ * taken from Pmariah TURBOchannel Adapter Specification, 29 November 1991
+ */
+#define KA4x_TCA_BASE 0x30000000
+#define KA4x_TCA_DIAG_TRIG (KA4x_TCA_BASE + 0x4000000)
+#define KA4x_TCA_MAP_CHK_SEQ (KA4x_TCA_BASE + 0x4800000)
+#define KA4x_TCA_FIFO_DIAG (KA4x_TCA_BASE + 0x5000000)
+#define KA4x_TCA_SGMAP (KA4x_TCA_BASE + 0x5800000)
+#define KA4x_TCA_DIAG_ROM (KA4x_TCA_BASE + 0x6000000)
+#define KA4x_TCA_CSR (KA4x_TCA_BASE + 0x6800000)
+#define KA4x_TCA_CSR_BLK_SZ __BITS(0, 2) /* 0x00007 RW */
+#define KA4x_TCA_CSR_SPARE __BIT(3) /* 0x00008 RW */
+#define KA4x_TCA_CSR_BAD_PAR __BITS(4, 7) /* 0x000f0 RW */
+#define KA4x_TCA_CSR_RST_TC __BIT(8) /* 0x00100 RW */
+#define KA4x_TCA_CSR_EN_MAP __BIT(9) /* 0x00200 RW */
+#define KA4x_TCA_CSR_INVAL_REF __BIT(10) /* 0x00400 RW1C */
+#define KA4x_TCA_CSR_TC_TMO __BIT(11) /* 0x00800 RW */
+#define KA4x_TCA_CSR_EN_TC_IRQ __BIT(12) /* 0x01000 RW */
+#define KA4x_TCA_CSR_TC_IRQ __BIT(13) /* 0x02000 R */
+#define KA4x_TCA_CSR_ERR __BIT(14) /* 0x04000 RW1C */
+#define KA4x_TCA_CSR_ALT_CYC_ST __BIT(15) /* 0x08000 RW */
+#define KA4x_TCA_CSR_EN_PAR __BIT(16) /* 0x10000 RW */
+#define KA4x_TCA_CSR_FIFO_EMPTY __BIT(17) /* 0x20000 R */
+#define KA4x_TCA_CSR_SZ 4
-static bus_dma_tag_t
-tcbus_get_dma_tag(int slotno)
+static int
+tc_vsbus_match(device_t parent, cfdata_t cfdata, void *aux)
{
- return tcbus_dmat;
+ struct vsbus_attach_args * const va = aux;
+ uint32_t *csr;
+ bus_space_tag_t bst = va->va_memt;
+ bus_space_handle_t bsh;
+ int found, rc;
+
+ if (va->va_paddr != KA4x_TCA_CSR)
+ return 0;
+
+ /* Bus adaptor present? */
+ switch (vax_boardtype) {
+ case VAX_BTYP_46:
+ if (bus_space_map(bst, KA46_BWF0, KA46_BWF0_SZ, 0, &bsh))
+ return 0;
+ found = ((bus_space_read_4(bst, bsh, 0) & KA46_BWF0_ADP) != 0);
+ bus_space_unmap(bst, bsh, KA46_BWF0_SZ);
+ /*
+ * On VS4000/60, although interrupting on a real vector, fool
+ * vsbus interrupt, as no interrupt bit will be set in
+ * vsbus_softc's sc_intreq for TC adaptor.
+ */
+ rc = 20;
+ break;
+ case VAX_BTYP_49:
+ if (bus_space_map(bst, KA49_CFG, KA49_CFG_SZ, 0, &bsh))
+ return 0;
+ found = ((bus_space_read_2(bst, bsh, 0) & KA49_CFG_BA) != 0);
+ bus_space_unmap(bst, bsh, KA49_CFG_SZ);
+ rc = 10;
+ break;
+ default:
+ return 0;
+ }
+ if (!found)
+ return 0;
+
+ /* XXX Assume a found bus adaptor is the TC bus adaptor. */
+
+ /* Force interrupt. */
+ csr = (uint32_t *)va->va_addr;
+ *csr |= KA4x_TCA_CSR_TC_TMO;
+ DELAY(10000);
+ *csr &= ~KA4x_TCA_CSR_TC_TMO;
+ DELAY(10000);
+
+ return rc;
}
+#define INIT_SLOTSZ 1
+
static void
-tcbus_intr_establish(device_t dv, void *cookie, int level,
- int (*func)(void *), void *arg)
+tc_vsbus_attach(device_t parent, device_t self, void *aux)
{
- struct tcbus_softc * const sc = cookie;
+ struct tcbus_attach_args tba;
+ struct vsbus_attach_args * const va = aux;
+ struct tc_vsbus_softc * const sc = device_private(self);
+ struct tc_rommap *rommap;
+ bus_space_tag_t bst = va->va_memt;
+ bus_space_handle_t bsh_csr, bsh_slot;
+ const bus_size_t slotb = 4194304;
+ uint32_t csr;
+ int error, slotsz;
+
+ sc->sc_cvec = va->va_cvec;
+
+ error = bus_space_map(bst, KA4x_TCA_CSR, KA4x_TCA_CSR_SZ, 0, &bsh_csr);
+ if (error) {
+ aprint_normal(": failed to map TCA CSR: %d\n", error);
+ return;
+ }
+ sc->sc_bst = bst;
+ sc->sc_bsh_csr = bsh_csr;
+
+ /* Deassert TC option reset and clean up. */
+ csr = bus_space_read_4(bst, bsh_csr, 0);
+ csr &= ~(KA4x_TCA_CSR_TC_TMO | KA4x_TCA_CSR_RST_TC);
+ csr |= KA4x_TCA_CSR_ERR | KA4x_TCA_CSR_INVAL_REF;
+ bus_space_write_4(bst, bsh_csr, 0, csr);
- scb_vecalloc(0x51, (void (*)(void *)) func, arg, SCB_ISTACK,
- &sc->sc_ev);
+ /*
+ * Map initial number of "slots" (4 MB each) to read the option ROM
+ * header.
+ */
+ error = bus_space_map(bst, KA4x_TCA_BASE, INIT_SLOTSZ * slotb,
+ BUS_SPACE_MAP_LINEAR, &bsh_slot);
+ if (error) {
Home |
Main Index |
Thread Index |
Old Index