2003-01-01 03:39:19 +03:00
|
|
|
/* $NetBSD: tlsb.c,v 1.26 2003/01/01 00:39:21 thorpej Exp $ */
|
1997-03-12 22:19:54 +03:00
|
|
|
/*
|
1997-03-13 00:09:43 +03:00
|
|
|
* Copyright (c) 1997 by Matthew Jacob
|
1997-03-12 22:19:54 +03:00
|
|
|
* NASA AMES Research Center.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Based in part upon a prototype version by Jason Thorpe
|
1998-09-29 08:22:36 +04:00
|
|
|
* Copyright (c) 1996, 1998 by Jason Thorpe.
|
1997-03-12 22:19:54 +03:00
|
|
|
*
|
|
|
|
* 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 and support routines for the TurboLaser System Bus
|
|
|
|
* found on AlphaServer 8200 and 8400 systems.
|
|
|
|
*/
|
|
|
|
|
1997-04-08 03:39:37 +04:00
|
|
|
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
|
|
|
|
|
2003-01-01 03:39:19 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tlsb.c,v 1.26 2003/01/01 00:39:21 thorpej Exp $");
|
1998-09-29 08:22:36 +04:00
|
|
|
|
|
|
|
#include "opt_multiprocessor.h"
|
1997-04-07 00:09:04 +04:00
|
|
|
|
1997-03-12 22:19:54 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#include <machine/autoconf.h>
|
1999-08-11 03:35:43 +04:00
|
|
|
#include <machine/cpu.h>
|
2001-04-20 22:03:27 +04:00
|
|
|
#include <machine/cpuvar.h>
|
1997-03-12 22:19:54 +03:00
|
|
|
#include <machine/rpb.h>
|
|
|
|
#include <machine/pte.h>
|
1998-11-19 05:53:47 +03:00
|
|
|
#include <machine/alpha.h>
|
1997-03-12 22:19:54 +03:00
|
|
|
|
|
|
|
#include <alpha/tlsb/tlsbreg.h>
|
|
|
|
#include <alpha/tlsb/tlsbvar.h>
|
|
|
|
|
1997-07-17 05:17:45 +04:00
|
|
|
#include "locators.h"
|
|
|
|
|
1997-03-12 22:19:54 +03:00
|
|
|
#define KV(_addr) ((caddr_t)ALPHA_PHYS_TO_K0SEG((_addr)))
|
|
|
|
|
|
|
|
static int tlsbmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void tlsbattach __P((struct device *, struct device *, void *));
|
1998-01-12 13:21:02 +03:00
|
|
|
|
2002-10-02 08:06:36 +04:00
|
|
|
CFATTACH_DECL(tlsb, sizeof (struct device),
|
|
|
|
tlsbmatch, tlsbattach, NULL, NULL);
|
1997-03-12 22:19:54 +03:00
|
|
|
|
1998-01-12 13:21:02 +03:00
|
|
|
extern struct cfdriver tlsb_cd;
|
1997-03-12 22:19:54 +03:00
|
|
|
|
|
|
|
static int tlsbprint __P((void *, const char *));
|
|
|
|
static int tlsbsubmatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
static char *tlsb_node_type_str __P((u_int32_t));
|
|
|
|
|
1998-07-08 05:03:41 +04:00
|
|
|
/*
|
|
|
|
* There can be only one TurboLaser, and we'll overload it
|
|
|
|
* with a bitmap of found turbo laser nodes. Note that
|
|
|
|
* these are just the actual hard TL node IDS that we
|
|
|
|
* discover here, not the virtual IDs that get assigned
|
|
|
|
* to CPUs. During TLSB specific error handling we
|
|
|
|
* only need to know which actual TLSB slots have boards
|
|
|
|
* in them (irrespective of how many CPUs they have).
|
|
|
|
*/
|
1998-05-14 03:23:23 +04:00
|
|
|
int tlsb_found;
|
|
|
|
|
1997-03-12 22:19:54 +03:00
|
|
|
static int
|
1998-05-14 03:23:23 +04:00
|
|
|
tlsbprint(aux, pnp)
|
1997-03-12 22:19:54 +03:00
|
|
|
void *aux;
|
1998-05-14 03:23:23 +04:00
|
|
|
const char *pnp;
|
1997-03-12 22:19:54 +03:00
|
|
|
{
|
|
|
|
struct tlsb_dev_attach_args *tap = aux;
|
1998-05-14 03:23:23 +04:00
|
|
|
|
|
|
|
if (pnp)
|
2003-01-01 03:39:19 +03:00
|
|
|
aprint_normal("%s at %s node %d",
|
|
|
|
tlsb_node_type_str(tap->ta_dtype), pnp, tap->ta_node);
|
1998-05-14 03:23:23 +04:00
|
|
|
else
|
2003-01-01 03:39:19 +03:00
|
|
|
aprint_normal(" node %d: %s", tap->ta_node,
|
1998-05-14 03:23:23 +04:00
|
|
|
tlsb_node_type_str(tap->ta_dtype));
|
|
|
|
|
1997-03-12 22:19:54 +03:00
|
|
|
return (UNCONF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tlsbsubmatch(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct tlsb_dev_attach_args *tap = aux;
|
1998-05-14 03:23:23 +04:00
|
|
|
|
1997-07-17 05:17:45 +04:00
|
|
|
if (cf->cf_loc[TLSBCF_NODE] != TLSBCF_NODE_DEFAULT &&
|
|
|
|
cf->cf_loc[TLSBCF_NODE] != tap->ta_node)
|
1997-03-12 22:19:54 +03:00
|
|
|
return (0);
|
1998-05-14 03:23:23 +04:00
|
|
|
|
2002-09-27 07:17:40 +04:00
|
|
|
return (config_match(parent, cf, aux));
|
1997-03-12 22:19:54 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tlsbmatch(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
1998-05-14 04:01:30 +04:00
|
|
|
struct mainbus_attach_args *ma = aux;
|
1997-03-12 22:19:54 +03:00
|
|
|
|
|
|
|
/* Make sure we're looking for a TurboLaser. */
|
1998-05-14 04:01:30 +04:00
|
|
|
if (strcmp(ma->ma_name, tlsb_cd.cd_name) != 0)
|
1997-03-12 22:19:54 +03:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Only one instance of TurboLaser allowed,
|
|
|
|
* and only available on 21000 processor type
|
|
|
|
* platforms.
|
|
|
|
*/
|
1998-05-14 03:23:23 +04:00
|
|
|
if ((cputype != ST_DEC_21000) || tlsb_found)
|
1997-03-12 22:19:54 +03:00
|
|
|
return (0);
|
|
|
|
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tlsbattach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct tlsb_dev_attach_args ta;
|
|
|
|
u_int32_t tldev;
|
|
|
|
int node;
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to find all devices on the bus, including
|
|
|
|
* CPUs, memory modules, and I/O modules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sigh. I would like to just start off nicely,
|
|
|
|
* but I need to treat I/O modules differently-
|
|
|
|
* The highest priority I/O node has to be in
|
|
|
|
* node #8, and I want to find it *first*, since
|
|
|
|
* it will have the primary disks (most likely)
|
|
|
|
* on it.
|
|
|
|
*/
|
|
|
|
for (node = 0; node <= TLSB_NODE_MAX; ++node) {
|
|
|
|
/*
|
|
|
|
* Check for invalid address. This may not really
|
|
|
|
* be necessary, but what the heck...
|
|
|
|
*/
|
|
|
|
if (badaddr(TLSB_NODE_REG_ADDR(node, TLDEV), sizeof(u_int32_t)))
|
|
|
|
continue;
|
|
|
|
tldev = TLSB_GET_NODEREG(node, TLDEV);
|
|
|
|
if (tldev == 0) {
|
|
|
|
/* Nothing at this node. */
|
|
|
|
continue;
|
|
|
|
}
|
1998-07-08 04:47:53 +04:00
|
|
|
/*
|
|
|
|
* Store up that we found something at this node.
|
|
|
|
* We do this so that we don't have to do something
|
|
|
|
* silly at fault time like try a 'baddadr'...
|
|
|
|
*/
|
|
|
|
tlsb_found |= (1 << node);
|
1997-03-12 22:19:54 +03:00
|
|
|
if (TLDEV_ISIOPORT(tldev))
|
|
|
|
continue; /* not interested right now */
|
|
|
|
ta.ta_node = node;
|
|
|
|
ta.ta_dtype = TLDEV_DTYPE(tldev);
|
|
|
|
ta.ta_swrev = TLDEV_SWREV(tldev);
|
|
|
|
ta.ta_hwrev = TLDEV_HWREV(tldev);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Deal with hooking CPU instances to TurboLaser nodes.
|
|
|
|
*/
|
|
|
|
if (TLDEV_ISCPU(tldev)) {
|
1998-09-29 08:22:36 +04:00
|
|
|
printf("%s node %d: %s\n", self->dv_xname,
|
1997-03-12 22:19:54 +03:00
|
|
|
node, tlsb_node_type_str(tldev));
|
|
|
|
}
|
|
|
|
/*
|
1998-09-29 08:22:36 +04:00
|
|
|
* Attach any children nodes, including a CPU's GBus
|
1997-03-12 22:19:54 +03:00
|
|
|
*/
|
|
|
|
config_found_sm(self, &ta, tlsbprint, tlsbsubmatch);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* *Now* search for I/O nodes (in descending order)
|
|
|
|
*/
|
|
|
|
while (--node > 0) {
|
|
|
|
if (badaddr(TLSB_NODE_REG_ADDR(node, TLDEV), sizeof(u_int32_t)))
|
|
|
|
continue;
|
|
|
|
tldev = TLSB_GET_NODEREG(node, TLDEV);
|
|
|
|
if (tldev == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (TLDEV_ISIOPORT(tldev)) {
|
1998-09-29 08:22:36 +04:00
|
|
|
#if defined(MULTIPROCESSOR)
|
|
|
|
/*
|
|
|
|
* XXX Eventually, we want to select a secondary
|
|
|
|
* XXX processor on which to field interrupts for
|
|
|
|
* XXX this node. However, we just send them to
|
|
|
|
* XXX the primary CPU for now.
|
|
|
|
*
|
|
|
|
* XXX Maybe multiple CPUs? Does the hardware
|
|
|
|
* XXX round-robin, or check the length of the
|
|
|
|
* XXX per-CPU interrupt queue?
|
|
|
|
*/
|
|
|
|
printf("%s node %d: routing interrupts to %s\n",
|
1999-02-23 06:20:00 +03:00
|
|
|
self->dv_xname, node,
|
2001-04-21 20:27:10 +04:00
|
|
|
cpu_info[hwrpb->rpb_primary_cpu_id]->ci_softc->sc_dev.dv_xname);
|
1998-09-29 08:22:36 +04:00
|
|
|
TLSB_PUT_NODEREG(node, TLCPUMASK,
|
|
|
|
(1UL << hwrpb->rpb_primary_cpu_id));
|
|
|
|
#else
|
|
|
|
/*
|
1999-02-23 06:20:00 +03:00
|
|
|
* Make sure interrupts are sent to the primary CPU.
|
1998-09-29 08:22:36 +04:00
|
|
|
*/
|
|
|
|
TLSB_PUT_NODEREG(node, TLCPUMASK,
|
|
|
|
(1UL << hwrpb->rpb_primary_cpu_id));
|
|
|
|
#endif /* MULTIPROCESSOR */
|
|
|
|
|
1997-03-12 22:19:54 +03:00
|
|
|
ta.ta_node = node;
|
|
|
|
ta.ta_dtype = TLDEV_DTYPE(tldev);
|
|
|
|
ta.ta_swrev = TLDEV_SWREV(tldev);
|
|
|
|
ta.ta_hwrev = TLDEV_HWREV(tldev);
|
|
|
|
config_found_sm(self, &ta, tlsbprint, tlsbsubmatch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
tlsb_node_type_str(dtype)
|
|
|
|
u_int32_t dtype;
|
|
|
|
{
|
|
|
|
static char tlsb_line[64];
|
|
|
|
|
|
|
|
switch (dtype & TLDEV_DTYPE_MASK) {
|
|
|
|
case TLDEV_DTYPE_KFTHA:
|
|
|
|
return ("KFTHA I/O interface");
|
|
|
|
|
|
|
|
case TLDEV_DTYPE_KFTIA:
|
|
|
|
return ("KFTIA I/O interface");
|
|
|
|
|
|
|
|
case TLDEV_DTYPE_MS7CC:
|
|
|
|
return ("MS7CC Memory Module");
|
|
|
|
|
|
|
|
case TLDEV_DTYPE_SCPU4:
|
|
|
|
return ("Single CPU, 4MB cache");
|
|
|
|
|
|
|
|
case TLDEV_DTYPE_SCPU16:
|
|
|
|
return ("Single CPU, 16MB cache");
|
|
|
|
|
|
|
|
case TLDEV_DTYPE_DCPU4:
|
|
|
|
return ("Dual CPU, 4MB cache");
|
|
|
|
|
|
|
|
case TLDEV_DTYPE_DCPU16:
|
|
|
|
return ("Dual CPU, 16MB cache");
|
|
|
|
|
|
|
|
default:
|
2001-07-13 03:25:39 +04:00
|
|
|
memset(tlsb_line, 0, sizeof(tlsb_line));
|
1997-03-12 22:19:54 +03:00
|
|
|
sprintf(tlsb_line, "unknown, dtype 0x%x", dtype);
|
|
|
|
return (tlsb_line);
|
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|