3 * This file is subject to the terms and conditions of the GNU General Public
4 * License. See the file "COPYING" in the main directory of this archive
7 * Copyright (c) 1992-1997,2000-2003 Silicon Graphics, Inc. All rights reserved.
10 #include <linux/types.h>
11 #include <linux/slab.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/sn/driver.h>
14 #include <asm/sn/iograph.h>
15 #include <asm/sn/invent.h>
16 #include <asm/sn/hcl.h>
17 #include <asm/sn/labelcl.h>
18 #include <asm/sn/xtalk/xtalk.h>
19 #include <asm/sn/xtalk/xswitch.h>
20 #include <asm/sn/xtalk/xwidget.h>
21 #include <asm/sn/xtalk/xtalk_private.h>
23 #define NEW(ptr) (ptr = kmalloc(sizeof (*(ptr)), GFP_KERNEL))
24 #define DEL(ptr) (kfree(ptr))
27 * This file provides generic support for Crosstalk
28 * Switches, in a way that insulates crosstalk providers
29 * from specifics about the switch chips being used.
32 #include <asm/sn/xtalk/xbow.h>
34 #define XSWITCH_CENSUS_BIT(port) (1<<(port))
35 #define XSWITCH_CENSUS_PORT_MAX (0xF)
36 #define XSWITCH_CENSUS_PORTS (0x10)
37 #define XSWITCH_WIDGET_PRESENT(infop,port) ((infop)->census & XSWITCH_CENSUS_BIT(port))
39 static char xswitch_info_fingerprint[] = "xswitch_info";
41 struct xswitch_info_s {
44 vertex_hdl_t vhdl[XSWITCH_CENSUS_PORTS];
45 vertex_hdl_t master_vhdl[XSWITCH_CENSUS_PORTS];
46 xswitch_provider_t *xswitch_fns;
50 xswitch_info_get(vertex_hdl_t xwidget)
52 xswitch_info_t xswitch_info;
54 xswitch_info = (xswitch_info_t)
55 hwgraph_fastinfo_get(xwidget);
57 return (xswitch_info);
61 xswitch_info_vhdl_set(xswitch_info_t xswitch_info,
65 if (port > XSWITCH_CENSUS_PORT_MAX)
68 xswitch_info->vhdl[port] = xwidget;
72 xswitch_info_vhdl_get(xswitch_info_t xswitch_info,
75 if (port > XSWITCH_CENSUS_PORT_MAX)
76 return GRAPH_VERTEX_NONE;
78 return xswitch_info->vhdl[port];
82 * Some systems may allow for multiple switch masters. On such systems,
83 * we assign a master for each port on the switch. These interfaces
84 * establish and retrieve that assignment.
87 xswitch_info_master_assignment_set(xswitch_info_t xswitch_info,
89 vertex_hdl_t master_vhdl)
91 if (port > XSWITCH_CENSUS_PORT_MAX)
94 xswitch_info->master_vhdl[port] = master_vhdl;
98 xswitch_info_master_assignment_get(xswitch_info_t xswitch_info,
101 if (port > XSWITCH_CENSUS_PORT_MAX)
102 return GRAPH_VERTEX_NONE;
104 return xswitch_info->master_vhdl[port];
108 xswitch_info_set(vertex_hdl_t xwidget, xswitch_info_t xswitch_info)
110 xswitch_info->fingerprint = xswitch_info_fingerprint;
111 hwgraph_fastinfo_set(xwidget, (arbitrary_info_t) xswitch_info);
115 xswitch_info_new(vertex_hdl_t xwidget)
117 xswitch_info_t xswitch_info;
119 xswitch_info = xswitch_info_get(xwidget);
120 if (xswitch_info == NULL) {
124 xswitch_info->census = 0;
125 for (port = 0; port <= XSWITCH_CENSUS_PORT_MAX; port++) {
126 xswitch_info_vhdl_set(xswitch_info, port,
129 xswitch_info_master_assignment_set(xswitch_info,
133 xswitch_info_set(xwidget, xswitch_info);
139 xswitch_provider_register(vertex_hdl_t busv,
140 xswitch_provider_t * xswitch_fns)
142 xswitch_info_t xswitch_info = xswitch_info_get(busv);
144 ASSERT(xswitch_info);
145 xswitch_info->xswitch_fns = xswitch_fns;
149 xswitch_info_link_is_ok(xswitch_info_t xswitch_info, xwidgetnum_t port)
151 xswitch_info->census |= XSWITCH_CENSUS_BIT(port);
155 xswitch_info_link_ok(xswitch_info_t xswitch_info, xwidgetnum_t port)
157 if (port > XSWITCH_CENSUS_PORT_MAX)
160 return (xswitch_info->census & XSWITCH_CENSUS_BIT(port));
164 xswitch_reset_link(vertex_hdl_t xconn_vhdl)
166 return xbow_reset_link(xconn_vhdl);