ia64/linux-2.6.18-xen.hg

diff arch/mips/sgi-ip27/ip27-xtalk.c @ 0:831230e53067

Import 2.6.18 from kernel.org tarball.
author Ian Campbell <ian.campbell@xensource.com>
date Wed Apr 11 14:15:44 2007 +0100 (2007-04-11)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/arch/mips/sgi-ip27/ip27-xtalk.c	Wed Apr 11 14:15:44 2007 +0100
     1.3 @@ -0,0 +1,135 @@
     1.4 +/*
     1.5 + * Copyright (C) 1999, 2000 Ralf Baechle (ralf@gnu.org)
     1.6 + * Copyright (C) 1999, 2000 Silcon Graphics, Inc.
     1.7 + * Copyright (C) 2004 Christoph Hellwig.
     1.8 + *	Released under GPL v2.
     1.9 + *
    1.10 + * Generic XTALK initialization code
    1.11 + */
    1.12 +
    1.13 +#include <linux/init.h>
    1.14 +#include <linux/kernel.h>
    1.15 +#include <asm/sn/types.h>
    1.16 +#include <asm/sn/klconfig.h>
    1.17 +#include <asm/sn/hub.h>
    1.18 +#include <asm/pci/bridge.h>
    1.19 +#include <asm/xtalk/xtalk.h>
    1.20 +
    1.21 +
    1.22 +#define XBOW_WIDGET_PART_NUM    0x0
    1.23 +#define XXBOW_WIDGET_PART_NUM   0xd000  /* Xbow in Xbridge */
    1.24 +#define BASE_XBOW_PORT  	8     /* Lowest external port */
    1.25 +
    1.26 +extern int bridge_probe(nasid_t nasid, int widget, int masterwid);
    1.27 +
    1.28 +static int __init probe_one_port(nasid_t nasid, int widget, int masterwid)
    1.29 +{
    1.30 +	widgetreg_t 		widget_id;
    1.31 +	xwidget_part_num_t	partnum;
    1.32 +
    1.33 +	widget_id = *(volatile widgetreg_t *)
    1.34 +		(RAW_NODE_SWIN_BASE(nasid, widget) + WIDGET_ID);
    1.35 +	partnum = XWIDGET_PART_NUM(widget_id);
    1.36 +
    1.37 +	printk(KERN_INFO "Cpu %d, Nasid 0x%x, widget 0x%x (partnum 0x%x) is ",
    1.38 +			smp_processor_id(), nasid, widget, partnum);
    1.39 +
    1.40 +	switch (partnum) {
    1.41 +	case BRIDGE_WIDGET_PART_NUM:
    1.42 +	case XBRIDGE_WIDGET_PART_NUM:
    1.43 +		bridge_probe(nasid, widget, masterwid);
    1.44 +		break;
    1.45 +	default:
    1.46 +		break;
    1.47 +	}
    1.48 +
    1.49 +	return 0;
    1.50 +}
    1.51 +
    1.52 +static int __init xbow_probe(nasid_t nasid)
    1.53 +{
    1.54 +	lboard_t *brd;
    1.55 +	klxbow_t *xbow_p;
    1.56 +	unsigned masterwid, i;
    1.57 +
    1.58 +	printk("is xbow\n");
    1.59 +
    1.60 +	/*
    1.61 +	 * found xbow, so may have multiple bridges
    1.62 +	 * need to probe xbow
    1.63 +	 */
    1.64 +	brd = find_lboard((lboard_t *)KL_CONFIG_INFO(nasid), KLTYPE_MIDPLANE8);
    1.65 +	if (!brd)
    1.66 +		return -ENODEV;
    1.67 +
    1.68 +	xbow_p = (klxbow_t *)find_component(brd, NULL, KLSTRUCT_XBOW);
    1.69 +	if (!xbow_p)
    1.70 +		return -ENODEV;
    1.71 +
    1.72 +	/*
    1.73 +	 * Okay, here's a xbow. Lets arbitrate and find
    1.74 +	 * out if we should initialize it. Set enabled
    1.75 +	 * hub connected at highest or lowest widget as
    1.76 +	 * master.
    1.77 +	 */
    1.78 +#ifdef WIDGET_A
    1.79 +	i = HUB_WIDGET_ID_MAX + 1;
    1.80 +	do {
    1.81 +		i--;
    1.82 +	} while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
    1.83 +		 (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
    1.84 +#else
    1.85 +	i = HUB_WIDGET_ID_MIN - 1;
    1.86 +	do {
    1.87 +		i++;
    1.88 +	} while ((!XBOW_PORT_TYPE_HUB(xbow_p, i)) ||
    1.89 +		 (!XBOW_PORT_IS_ENABLED(xbow_p, i)));
    1.90 +#endif
    1.91 +
    1.92 +	masterwid = i;
    1.93 +	if (nasid != XBOW_PORT_NASID(xbow_p, i))
    1.94 +		return 1;
    1.95 +
    1.96 +	for (i = HUB_WIDGET_ID_MIN; i <= HUB_WIDGET_ID_MAX; i++) {
    1.97 +		if (XBOW_PORT_IS_ENABLED(xbow_p, i) &&
    1.98 +		    XBOW_PORT_TYPE_IO(xbow_p, i))
    1.99 +			probe_one_port(nasid, i, masterwid);
   1.100 +	}
   1.101 +
   1.102 +	return 0;
   1.103 +}
   1.104 +
   1.105 +void __init xtalk_probe_node(cnodeid_t nid)
   1.106 +{
   1.107 +	volatile u64 		hubreg;
   1.108 +	nasid_t	 		nasid;
   1.109 +	xwidget_part_num_t	partnum;
   1.110 +	widgetreg_t 		widget_id;
   1.111 +
   1.112 +	nasid = COMPACT_TO_NASID_NODEID(nid);
   1.113 +	hubreg = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
   1.114 +
   1.115 +	/* check whether the link is up */
   1.116 +	if (!(hubreg & IIO_LLP_CSR_IS_UP))
   1.117 +		return;
   1.118 +
   1.119 +	widget_id = *(volatile widgetreg_t *)
   1.120 +                       (RAW_NODE_SWIN_BASE(nasid, 0x0) + WIDGET_ID);
   1.121 +	partnum = XWIDGET_PART_NUM(widget_id);
   1.122 +
   1.123 +	printk(KERN_INFO "Cpu %d, Nasid 0x%x: partnum 0x%x is ",
   1.124 +			smp_processor_id(), nasid, partnum);
   1.125 +
   1.126 +	switch (partnum) {
   1.127 +	case BRIDGE_WIDGET_PART_NUM:
   1.128 +		bridge_probe(nasid, 0x8, 0xa);
   1.129 +		break;
   1.130 +	case XBOW_WIDGET_PART_NUM:
   1.131 +	case XXBOW_WIDGET_PART_NUM:
   1.132 +		xbow_probe(nasid);
   1.133 +		break;
   1.134 +	default:
   1.135 +		printk(" unknown widget??\n");
   1.136 +		break;
   1.137 +	}
   1.138 +}