diff options
author | Robert Nagy <robert@cvs.openbsd.org> | 2007-03-16 21:22:28 +0000 |
---|---|---|
committer | Robert Nagy <robert@cvs.openbsd.org> | 2007-03-16 21:22:28 +0000 |
commit | 3313c8da15ece1bcc863ff6ed064e39102dd0844 (patch) | |
tree | db6ebdc1b60372511bb8de936db0823dc4a3472d /sys/arch/alpha/mcbus | |
parent | 0651608af8c3d57db9626a1bcc4bf9cdd16b7d9b (diff) |
add DEC_KN300 support from NetBSD;
This code makes it possible to run on some of the AlphaServers,
namely AlphaServer 4100 and 1200.
add mcbus(4) and mcpcia(4) to provide support for the system bus and
the MCPCIA-to-PCI bus adapter that can be found in these systems
allow the pci_swiz_bus code to handle variable extent names
to be able to handle more than one mcpcia(4)
"just commit it" deraadt@
Diffstat (limited to 'sys/arch/alpha/mcbus')
-rw-r--r-- | sys/arch/alpha/mcbus/mcbus.c | 211 | ||||
-rw-r--r-- | sys/arch/alpha/mcbus/mcbusreg.h | 93 | ||||
-rw-r--r-- | sys/arch/alpha/mcbus/mcbusvar.h | 80 | ||||
-rw-r--r-- | sys/arch/alpha/mcbus/mcmem.c | 85 |
4 files changed, 469 insertions, 0 deletions
diff --git a/sys/arch/alpha/mcbus/mcbus.c b/sys/arch/alpha/mcbus/mcbus.c new file mode 100644 index 00000000000..30e050bd5ac --- /dev/null +++ b/sys/arch/alpha/mcbus/mcbus.c @@ -0,0 +1,211 @@ +/* $OpenBSD: mcbus.c,v 1.1 2007/03/16 21:22:27 robert Exp $ */ +/* $NetBSD: mcbus.c,v 1.19 2007/03/04 05:59:11 christos Exp $ */ + +/* + * Copyright (c) 1998 by Matthew Jacob + * NASA AMES Research Center. + * 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 immediately at the beginning of the file, without modification, + * 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 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 AUTHOR 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. + */ + +/* + * Autoconfiguration routines for the MCBUS system + * bus found on AlphaServer 4100 systems. + */ + +#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/malloc.h> + +#include <machine/autoconf.h> +#include <machine/rpb.h> +#include <machine/pte.h> + +#include <alpha/mcbus/mcbusreg.h> +#include <alpha/mcbus/mcbusvar.h> + +#include <alpha/pci/mcpciareg.h> + +#define KV(_addr) ((caddr_t)ALPHA_PHYS_TO_K0SEG((_addr))) +#define MCPCIA_EXISTS(mid, gid) \ + (!badaddr((void *)KV(MCPCIA_BRIDGE_ADDR(gid, mid)), sizeof (u_int32_t))) + +struct mcbus_cpu_busdep mcbus_primary; + +int mcbusmatch (struct device *, void *, void *); +void mcbusattach (struct device *, struct device *, void *); +int mcbusprint (void *, const char *); +int mcbussbm (struct device *, void *, void *); + +const char *mcbus_node_type_str (u_int8_t); + +typedef struct { + struct device mcbus_dev; + u_int8_t mcbus_types[MCBUS_MID_MAX]; +} mcbus_softc_t; + +struct cfattach mcbus_ca = { + sizeof(mcbus_softc_t), mcbusmatch, mcbusattach +}; + +struct cfdriver mcbus_cd = { + NULL, "mcbus", DV_DULL, +}; + +/* + * Tru64 UNIX (formerly Digital UNIX (formerly DEC OSF/1)) probes for MCPCIAs + * in the following order: + * + * 5, 4, 7, 6 + * + * This is so that the built-in CD-ROM on the internal 53c810 is always + * dka500. We probe them in the same order, for consistency. + */ +const int mcbus_mcpcia_probe_order[] = { 5, 4, 7, 6 }; + +extern void mcpcia_config_cleanup (void); + +int +mcbusprint(aux, cp) + void *aux; + const char *cp; +{ + struct mcbus_dev_attach_args *tap = aux; + printf(" mid %d: %s", tap->ma_mid, + mcbus_node_type_str(tap->ma_type)); + return (UNCONF); +} + +int +mcbussbm(parent, cf, aux) + struct device *parent; + void *cf; + void *aux; +{ + struct mcbus_dev_attach_args *tap = aux; + struct cfdata *mcf = (struct cfdata *)cf; + + if (mcf->cf_loc[MCBUSCF_MID] != MCBUSCF_MID_DEFAULT && + mcf->cf_loc[MCBUSCF_MID] != tap->ma_mid) + return (0); + + + return ((*mcf->cf_attach->ca_match)(parent, mcf, aux)); +} + +int +mcbusmatch(parent, cf, aux) + struct device *parent; + void *cf; + void *aux; +{ + struct mainbus_attach_args *ma = aux; + + /* Make sure we're looking for a MCBUS. */ + if (strcmp(ma->ma_name, mcbus_cd.cd_name) != 0) + return (0); + + /* + * Only available on 4100 processor type platforms. + */ + if (cputype != ST_DEC_4100) + return (0); + + return (1); +} + +void +mcbusattach(parent, self, aux) + struct device *parent; + struct device *self; + void *aux; +{ + static const char *bcs[CPU_BCacheMask + 1] = { + "No", "1MB", "2MB", "4MB", + }; + struct mcbus_dev_attach_args ta; + mcbus_softc_t *mbp = (mcbus_softc_t *)self; + int i, mid; + + printf(": %s BCache\n", mcbus_primary.mcbus_valid ? + bcs[mcbus_primary.mcbus_bcache] : "Unknown"); + + mbp->mcbus_types[0] = MCBUS_TYPE_RES; + for (mid = 1; mid <= MCBUS_MID_MAX; ++mid) + mbp->mcbus_types[mid] = MCBUS_TYPE_UNK; + + /* + * Find and "configure" memory. + */ + ta.ma_name = mcbus_cd.cd_name; + ta.ma_gid = MCBUS_GID_FROM_INSTANCE(0); + ta.ma_mid = 1; + ta.ma_type = MCBUS_TYPE_MEM; + mbp->mcbus_types[1] = MCBUS_TYPE_MEM; + + (void) config_found_sm(self, &ta, mcbusprint, mcbussbm); + + /* + * Now find PCI busses. + */ + for (i = 0; i < MCPCIA_PER_MCBUS; i++) { + mid = mcbus_mcpcia_probe_order[i]; + ta.ma_name = mcbus_cd.cd_name; + ta.ma_gid = MCBUS_GID_FROM_INSTANCE(0); + ta.ma_mid = mid; + ta.ma_type = MCBUS_TYPE_PCI; + if (MCPCIA_EXISTS(ta.ma_mid, ta.ma_gid)) + (void) config_found_sm(self, &ta, mcbusprint, + mcbussbm); + } + + mcpcia_config_cleanup(); +} + +const char * +mcbus_node_type_str(type) + u_int8_t type; +{ + switch (type) { + case MCBUS_TYPE_RES: + panic ("RESERVED TYPE IN MCBUS_NODE_TYPE_STR"); + break; + case MCBUS_TYPE_UNK: + panic ("UNKNOWN TYPE IN MCBUS_NODE_TYPE_STR"); + break; + case MCBUS_TYPE_MEM: + return ("Memory"); + case MCBUS_TYPE_CPU: + return ("CPU"); + case MCBUS_TYPE_PCI: + return ("PCI Bridge"); + default: + panic("REALLY UNKNWON (%x) TYPE IN MCBUS_NODE_TYPE_STR", type); + break; + } +} diff --git a/sys/arch/alpha/mcbus/mcbusreg.h b/sys/arch/alpha/mcbus/mcbusreg.h new file mode 100644 index 00000000000..8f345beca94 --- /dev/null +++ b/sys/arch/alpha/mcbus/mcbusreg.h @@ -0,0 +1,93 @@ +/* $OpenBSD: mcbusreg.h,v 1.1 2007/03/16 21:22:27 robert Exp $ */ +/* $NetBSD: mcbusreg.h,v 1.3 1999/11/16 18:36:27 mjacob Exp $ */ + +/* + * Copyright (c) 1998 by Matthew Jacob + * NASA AMES Research Center. + * 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 immediately at the beginning of the file, without modification, + * 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 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 AUTHOR 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. + */ + +/* + * 'Register' definitions for the MCBUS main + * system bus found on AlphaServer 4100 systems. + */ + +/* + * Information gathered from: + * + * "Rawhide System Programmer's Manual, revision 1.4". + */ + +/* + * There are 7 possible MC bus modules (architecture says 10, but + * the address map details say otherwise), 1 though 7. + * Their uses are defined as follows: + * + * MID Module + * ---- ------ + * 1 Memory + * 2 CPU + * 3 CPU + * 4 CPU, PCI + * 5 CPU, PCI + * 6 CPU, PCI + * 7 CPU, PCI + * + */ +#define MCBUS_MID_MAX 7 + +/* + * For this architecture, bit 39 of a 40 bit address controls whether + * you access I/O or Memory space. Further, there *could* be multiple + * MC busses (but only one specified for now). + */ + +#define MCBUS_IOSPACE 0x0000008000000000L +#define MCBUS_GID_MASK 0x0000007000000000L +#define MCBUS_GID_SHIFT 36 +#define MCBUS_MID_MASK 0x0000000E00000000L +#define MCBUS_MID_SHIFT 33 + +#define MAX_MC_BUS 8 + +/* + * This is something of a layering violation, but it makes probing cleaner. + */ +#define MCPCIA_PER_MCBUS 4 + +/* + * defaults for locators + */ +#define MCBUSCF_NLOCS 1 +#define MCBUSCF_MID 0 +#define MCBUSCF_MID_DEFAULT -1 + +/* the MCPCIA bridge CSR addresses, offset zero, is a good thing to probe for */ +#define MCPCIA_BRIDGE_ADDR(gid, mid) \ + (MCBUS_IOSPACE | 0x1E0000000LL | \ + (((unsigned long) gid) << MCBUS_GID_SHIFT) | \ + (((unsigned long) mid) << MCBUS_MID_SHIFT)) diff --git a/sys/arch/alpha/mcbus/mcbusvar.h b/sys/arch/alpha/mcbus/mcbusvar.h new file mode 100644 index 00000000000..b77cfcc7190 --- /dev/null +++ b/sys/arch/alpha/mcbus/mcbusvar.h @@ -0,0 +1,80 @@ +/* $OpenBSD: mcbusvar.h,v 1.1 2007/03/16 21:22:27 robert Exp $ */ +/* $NetBSD: mcbusvar.h,v 1.6 2005/12/11 12:16:17 christos Exp $ */ + +/* + * Copyright (c) 1998 by Matthew Jacob + * NASA AMES Research Center. + * 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 immediately at the beginning of the file, without modification, + * 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 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 AUTHOR 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. + */ + +/* + * Soft definitions for the MCBUS main system + * bus found on AlphaServer 4100 systems. + */ + +/* + * The structure used to attach devices to the MCbus. + */ +struct mcbus_dev_attach_args { + char * ma_name; /* so things aren't confused */ + u_int8_t ma_gid; /* GID of MCBUS (MCBUS #) */ + u_int8_t ma_mid; /* Module ID on MCBUS */ + u_int8_t ma_type; /* Module "type" */ + u_int8_t ma_configured; /* nonzero if configured */ +}; +#define MCBUS_GID_FROM_INSTANCE(unit) (7 - unit) + +/* + * Bus-dependent structure for CPUs. This is dynamically allocated + * for each CPU on the MCbus, and glued into the cpu_softc as sc_busdep, + * if there is such a beast available. Otherwise, a single global version + * is used so that the MCPCIA configuration code can determine toads + * like module id and bcache size of the master CPU. + */ +struct mcbus_cpu_busdep { + u_int8_t mcbus_cpu_mid; /* MCbus Module ID */ + u_int8_t mcbus_bcache; /* BCache on this CPU */ + u_int8_t mcbus_valid; +}; + +#define MCBUS_CPU_BCACHE_0MB 0 +#define MCBUS_CPU_BCACHE_1MB 1 +#define MCBUS_CPU_BCACHE_4MB 2 + +/* + * "types" + */ +#define MCBUS_TYPE_RES 0 +#define MCBUS_TYPE_UNK 1 +#define MCBUS_TYPE_MEM 2 +#define MCBUS_TYPE_CPU 3 +#define MCBUS_TYPE_PCI 4 + +#ifdef _KERNEL +extern struct mcbus_cpu_busdep mcbus_primary; +extern const int mcbus_mcpcia_probe_order[]; +#endif diff --git a/sys/arch/alpha/mcbus/mcmem.c b/sys/arch/alpha/mcbus/mcmem.c new file mode 100644 index 00000000000..48f2aaea474 --- /dev/null +++ b/sys/arch/alpha/mcbus/mcmem.c @@ -0,0 +1,85 @@ +/* $OpenBSD: mcmem.c,v 1.1 2007/03/16 21:22:27 robert Exp $ */ +/* $NetBSD: mcmem.c,v 1.4 2002/10/02 04:06:38 thorpej Exp $ */ + +/* + * Copyright (c) 2007 Robert Nagy <robert@openbsd.org> + * Copyright (c) 1998 by Matthew Jacob + * NASA AMES Research Center. + * 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 immediately at the beginning of the file, without modification, + * 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 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 AUTHOR 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. + */ + +/* + * 'dummy' (for now) node for the memory modules attached to + * the MCBUS main system bus found on AlphaServer 4100 systems. + */ + +#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/device.h> +#include <sys/malloc.h> + +#include <machine/autoconf.h> +#include <machine/rpb.h> +#include <machine/pte.h> + +#include <alpha/mcbus/mcbusreg.h> +#include <alpha/mcbus/mcbusvar.h> + +int mcmemmatch (struct device *, void *, void *); +void mcmemattach (struct device *, struct device *, void *); + +struct cfattach mcmem_ca = { + sizeof(struct device), mcmemmatch, mcmemattach +}; + +struct cfdriver mcmem_cd = { + NULL, "mcmem", DV_DULL, +}; + +int +mcmemmatch(parent, cf, aux) + struct device *parent; + void *cf; + void *aux; +{ + struct mcbus_dev_attach_args *ta = aux; + + if (ta->ma_type == MCBUS_TYPE_MEM) + return (1); + + return (0); +} + +void +mcmemattach(parent, self, aux) + struct device *parent; + struct device *self; + void *aux; +{ + printf("\n"); +} |