1998-06-10 10:57:29 +00:00
|
|
|
/*
|
2000-03-18 07:42:13 +00:00
|
|
|
* Copyright (c) 1997, 2000 by Matthew Jacob
|
1998-06-10 10:57:29 +00:00
|
|
|
* NASA AMES Research Center.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Based in part upon a prototype version by Jason Thorpe
|
|
|
|
* Copyright (c) 1996 by Jason Thorpe.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-06-10 17:31:31 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1998-06-10 10:57:29 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#include <machine/cpuconf.h>
|
2003-08-17 06:42:08 +00:00
|
|
|
#include <machine/md_var.h>
|
|
|
|
#include <machine/rpb.h>
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
#include <alpha/tlsb/tlsbreg.h>
|
|
|
|
#include <alpha/tlsb/tlsbvar.h>
|
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
struct tlsb_device *tlsb_primary_cpu = NULL;
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
#define KV(_addr) ((caddr_t)ALPHA_PHYS_TO_K0SEG((_addr)))
|
|
|
|
|
|
|
|
struct tlsb_softc {
|
2000-03-18 07:42:13 +00:00
|
|
|
driver_intr_t * zsc_intr;
|
|
|
|
void * zsc_arg;
|
|
|
|
driver_intr_t * sub_intr;
|
|
|
|
device_t tlsb_dev;
|
|
|
|
int tlsb_map;
|
1998-06-10 10:57:29 +00:00
|
|
|
};
|
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
static void tlsb_add_child(struct tlsb_softc *, struct tlsb_device *);
|
|
|
|
static char *tlsb_node_type_str(u_int32_t);
|
|
|
|
static void tlsb_intr(void *, u_long);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
static struct tlsb_softc * tlsb0_softc = NULL;
|
1998-06-14 13:46:10 +00:00
|
|
|
static devclass_t tlsb_devclass;
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
/*
|
1998-06-14 13:46:10 +00:00
|
|
|
* Device methods
|
1998-06-10 10:57:29 +00:00
|
|
|
*/
|
2000-03-18 07:42:13 +00:00
|
|
|
static int tlsb_probe(device_t);
|
|
|
|
static int tlsb_print_child(device_t, device_t);
|
|
|
|
static int tlsb_read_ivar(device_t, device_t, int, u_long *);
|
|
|
|
static int tlsb_setup_intr(device_t, device_t, struct resource *, int,
|
|
|
|
driver_intr_t *, void *, void **);
|
|
|
|
static int
|
|
|
|
tlsb_teardown_intr(device_t, device_t, struct resource *, void *);
|
1998-06-14 13:46:10 +00:00
|
|
|
|
|
|
|
static device_method_t tlsb_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, tlsb_probe),
|
|
|
|
DEVMETHOD(device_attach, bus_generic_attach),
|
|
|
|
DEVMETHOD(device_detach, bus_generic_detach),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, tlsb_print_child),
|
|
|
|
DEVMETHOD(bus_read_ivar, tlsb_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, bus_generic_write_ivar),
|
1998-11-15 18:25:17 +00:00
|
|
|
DEVMETHOD(bus_setup_intr, tlsb_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, tlsb_teardown_intr),
|
1998-06-14 13:46:10 +00:00
|
|
|
|
|
|
|
{ 0, 0 }
|
1998-06-10 10:57:29 +00:00
|
|
|
};
|
|
|
|
|
1998-06-14 13:46:10 +00:00
|
|
|
static driver_t tlsb_driver = {
|
2000-03-18 07:42:13 +00:00
|
|
|
"tlsb", tlsb_methods, sizeof (struct tlsb_softc),
|
1998-06-10 10:57:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At 'probe' time, we add all the devices which we know about to the
|
|
|
|
* bus. The generic attach routine will probe and attach them if they
|
|
|
|
* are alive.
|
|
|
|
*/
|
|
|
|
static int
|
1998-06-14 13:46:10 +00:00
|
|
|
tlsb_probe(device_t dev)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
2000-03-18 07:42:13 +00:00
|
|
|
struct tlsb_softc *sc = device_get_softc(dev);
|
1998-06-10 10:57:29 +00:00
|
|
|
struct tlsb_device *tdev;
|
|
|
|
u_int32_t tldev;
|
|
|
|
int node;
|
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
device_set_desc(dev, "TurboLaser Backplane Bus");
|
1998-06-14 13:46:10 +00:00
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
sc->tlsb_dev = dev;
|
1998-06-10 10:57:29 +00:00
|
|
|
tlsb0_softc = sc;
|
|
|
|
set_iointr(tlsb_intr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt to find all devices on the bus, including
|
|
|
|
* CPUs, memory modules, and I/O modules.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (node = 0; node <= TLSB_NODE_MAX; ++node) {
|
|
|
|
/*
|
2000-03-18 07:42:13 +00:00
|
|
|
* Check for invalid address.
|
1998-06-10 10:57:29 +00:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
2000-03-18 07:42:13 +00:00
|
|
|
tdev = (struct tlsb_device *)
|
|
|
|
malloc(sizeof (struct tlsb_device), M_DEVBUF, M_NOWAIT);
|
1998-06-10 10:57:29 +00:00
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
if (!tdev) {
|
|
|
|
printf("tlsb_probe: unable to malloc softc\n");
|
1998-06-10 10:57:29 +00:00
|
|
|
continue;
|
2000-03-18 07:42:13 +00:00
|
|
|
}
|
1998-06-10 10:57:29 +00:00
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
sc->tlsb_map |= (1 << node);
|
1998-06-10 10:57:29 +00:00
|
|
|
tdev->td_node = node;
|
2000-03-18 07:42:13 +00:00
|
|
|
tdev->td_tldev = tldev;
|
|
|
|
tlsb_add_child(sc, tdev);
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
2000-03-18 07:42:13 +00:00
|
|
|
return (0);
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
1999-07-29 01:03:04 +00:00
|
|
|
static int
|
1998-06-14 13:46:10 +00:00
|
|
|
tlsb_print_child(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct tlsb_device* tdev = DEVTOTLSB(child);
|
1999-07-29 01:03:04 +00:00
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
retval += bus_print_child_header(dev, child);
|
2000-03-18 07:42:13 +00:00
|
|
|
retval += printf(" at %s node %d\n",
|
|
|
|
device_get_nameunit(dev), tdev->td_node);
|
1999-07-29 01:03:04 +00:00
|
|
|
return (retval);
|
1998-06-14 13:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-03-18 07:42:13 +00:00
|
|
|
tlsb_read_ivar(device_t dev, device_t child, int index, u_long *result)
|
1998-06-14 13:46:10 +00:00
|
|
|
{
|
2000-03-18 07:42:13 +00:00
|
|
|
struct tlsb_device *tdev = DEVTOTLSB(child);
|
1998-06-14 13:46:10 +00:00
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case TLSB_IVAR_NODE:
|
|
|
|
*result = tdev->td_node;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TLSB_IVAR_DTYPE:
|
2000-03-18 07:42:13 +00:00
|
|
|
*result = TLDEV_DTYPE(tdev->td_tldev);
|
1998-06-14 13:46:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TLSB_IVAR_SWREV:
|
2000-03-18 07:42:13 +00:00
|
|
|
*result = TLDEV_SWREV(tdev->td_tldev);
|
1998-06-14 13:46:10 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TLSB_IVAR_HWREV:
|
2000-03-18 07:42:13 +00:00
|
|
|
*result = TLDEV_HWREV(tdev->td_tldev);
|
1998-06-14 13:46:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2000-03-18 07:42:13 +00:00
|
|
|
return (ENOENT);
|
1998-06-14 13:46:10 +00:00
|
|
|
}
|
|
|
|
|
1998-11-15 18:25:17 +00:00
|
|
|
static int
|
2000-03-18 07:42:13 +00:00
|
|
|
tlsb_setup_intr(device_t dev, device_t child, struct resource *i, int f,
|
|
|
|
driver_intr_t *intr, void *arg, void **c)
|
1998-06-14 13:46:10 +00:00
|
|
|
{
|
2000-03-18 07:42:13 +00:00
|
|
|
if (strncmp(device_get_name(child), "zsc", 3) == 0) {
|
|
|
|
if (tlsb0_softc->zsc_intr)
|
|
|
|
return (EBUSY);
|
|
|
|
tlsb0_softc->zsc_intr = intr;
|
|
|
|
tlsb0_softc->zsc_arg = arg;
|
|
|
|
return (0);
|
2001-05-10 07:08:03 +00:00
|
|
|
} else if (strncmp(device_get_name(device_get_parent(child)), "kft", 3)
|
|
|
|
== 0) {
|
2000-03-18 07:42:13 +00:00
|
|
|
if (tlsb0_softc->sub_intr == NULL)
|
|
|
|
tlsb0_softc->sub_intr = intr;
|
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
1998-07-12 16:23:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-03-18 07:42:13 +00:00
|
|
|
tlsb_teardown_intr(device_t dev, device_t child, struct resource *i, void *c)
|
1998-07-12 16:23:19 +00:00
|
|
|
{
|
2000-03-18 07:42:13 +00:00
|
|
|
if (strncmp(device_get_name(child), "zsc", 3) == 0) {
|
|
|
|
tlsb0_softc->zsc_intr = NULL;
|
|
|
|
return (0);
|
2001-05-10 07:08:03 +00:00
|
|
|
} else if (strncmp(device_get_name(device_get_parent(child)), "kft", 3)
|
|
|
|
== 0) {
|
2000-03-18 07:42:13 +00:00
|
|
|
tlsb0_softc->sub_intr = NULL;
|
|
|
|
return (0);
|
|
|
|
} else {
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
}
|
1998-06-14 13:46:10 +00:00
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
static void
|
|
|
|
tlsb_intr(void *frame, u_long vector)
|
|
|
|
{
|
|
|
|
if (vector && tlsb0_softc->sub_intr)
|
|
|
|
(*tlsb0_softc->sub_intr)((void *)vector);
|
1998-06-14 13:46:10 +00:00
|
|
|
}
|
|
|
|
|
1998-06-10 10:57:29 +00:00
|
|
|
static void
|
2000-03-18 07:42:13 +00:00
|
|
|
tlsb_add_child(struct tlsb_softc *tlsb, struct tlsb_device *tdev)
|
1998-06-10 10:57:29 +00:00
|
|
|
{
|
2000-03-18 07:42:13 +00:00
|
|
|
static int kftproto, memproto, cpuproto;
|
|
|
|
u_int32_t dtype = tdev->td_tldev & TLDEV_DTYPE_MASK;
|
|
|
|
int i, unit, ordr, units = 1;
|
|
|
|
char *dn;
|
|
|
|
device_t cd;
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
/*
|
2000-03-18 07:42:13 +00:00
|
|
|
* We want CPU and Memory boards to configure first, and we want the
|
|
|
|
* I/O boards to configure in reverse slot number order. This is
|
|
|
|
* further complicated by the possibility of dual CPU nodes.
|
1998-06-10 10:57:29 +00:00
|
|
|
*/
|
2000-03-18 07:42:13 +00:00
|
|
|
ordr = tdev->td_node << 1;
|
1998-06-10 10:57:29 +00:00
|
|
|
|
2000-03-18 07:42:13 +00:00
|
|
|
switch (dtype) {
|
|
|
|
case TLDEV_DTYPE_KFTHA:
|
|
|
|
case TLDEV_DTYPE_KFTIA:
|
|
|
|
ordr = 16 + (TLSB_NODE_MAX - tdev->td_node);
|
|
|
|
dn = "kft";
|
|
|
|
unit = kftproto++;
|
|
|
|
break;
|
|
|
|
case TLDEV_DTYPE_MS7CC:
|
|
|
|
dn = "tlsbmem";
|
|
|
|
unit = memproto++;
|
|
|
|
break;
|
|
|
|
case TLDEV_DTYPE_SCPU4:
|
|
|
|
case TLDEV_DTYPE_SCPU16:
|
|
|
|
dn = "tlsbcpu";
|
|
|
|
unit = cpuproto++;
|
|
|
|
break;
|
|
|
|
case TLDEV_DTYPE_DCPU4:
|
|
|
|
case TLDEV_DTYPE_DCPU16:
|
|
|
|
units = 2;
|
|
|
|
dn = "tlsbcpu";
|
|
|
|
unit = cpuproto;
|
|
|
|
cpuproto += 2;
|
|
|
|
break;
|
|
|
|
default:
|
2000-03-27 08:20:44 +00:00
|
|
|
printf("tlsb_add_child: unknown TLSB node type 0x%x\n", dtype);
|
2000-03-18 07:42:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < units; i++, unit++) {
|
|
|
|
cd = device_add_child_ordered(tlsb->tlsb_dev, ordr, dn, unit);
|
2000-03-27 08:20:44 +00:00
|
|
|
if (cd == NULL) {
|
2000-03-18 07:42:13 +00:00
|
|
|
return;
|
2000-03-27 08:20:44 +00:00
|
|
|
}
|
2000-03-18 07:42:13 +00:00
|
|
|
device_set_ivars(cd, tdev);
|
|
|
|
device_set_desc(cd, tlsb_node_type_str(dtype));
|
|
|
|
}
|
|
|
|
}
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
static char *
|
|
|
|
tlsb_node_type_str(u_int32_t dtype)
|
|
|
|
{
|
2000-03-18 07:42:13 +00:00
|
|
|
static char tmp[64];
|
1998-06-10 10:57:29 +00:00
|
|
|
|
|
|
|
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:
|
2000-03-18 07:42:13 +00:00
|
|
|
bzero(tmp, sizeof(tmp));
|
|
|
|
snprintf(tmp, sizeof(tmp), "unknown, type 0x%x", dtype);
|
|
|
|
return (tmp);
|
1998-06-10 10:57:29 +00:00
|
|
|
}
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
2000-03-18 07:42:13 +00:00
|
|
|
DRIVER_MODULE(tlsb, root, tlsb_driver, tlsb_devclass, 0, 0);
|