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) 2001-2003 Silicon Graphics, Inc. All rights reserved.
10 #include <linux/types.h>
11 #include <linux/slab.h>
12 #include <linux/module.h>
13 #include <asm/sn/sgi.h>
14 #include <asm/sn/sn_cpuid.h>
15 #include <asm/sn/addrs.h>
16 #include <asm/sn/arch.h>
17 #include <asm/sn/iograph.h>
18 #include <asm/sn/invent.h>
19 #include <asm/sn/hcl.h>
20 #include <asm/sn/labelcl.h>
21 #include <asm/sn/xtalk/xwidget.h>
22 #include <asm/sn/pci/bridge.h>
23 #include <asm/sn/pci/pciio.h>
24 #include <asm/sn/pci/pcibr.h>
25 #include <asm/sn/pci/pcibr_private.h>
26 #include <asm/sn/pci/pci_defs.h>
27 #include <asm/sn/prio.h>
28 #include <asm/sn/xtalk/xbow.h>
29 #include <asm/sn/ioc3.h>
30 #include <asm/sn/io.h>
31 #include <asm/sn/sn_private.h>
33 pcibr_hints_t pcibr_hints_get(vertex_hdl_t, int);
34 void pcibr_hints_fix_rrbs(vertex_hdl_t);
35 void pcibr_hints_dualslot(vertex_hdl_t, pciio_slot_t, pciio_slot_t);
36 void pcibr_hints_intr_bits(vertex_hdl_t, pcibr_intr_bits_f *);
37 void pcibr_set_rrb_callback(vertex_hdl_t, rrb_alloc_funct_t);
38 void pcibr_hints_handsoff(vertex_hdl_t);
39 void pcibr_hints_subdevs(vertex_hdl_t, pciio_slot_t, uint64_t);
42 pcibr_hints_get(vertex_hdl_t xconn_vhdl, int alloc)
44 arbitrary_info_t ainfo = 0;
48 rv = hwgraph_info_get_LBL(xconn_vhdl, INFO_LBL_PCIBR_HINTS, &ainfo);
50 if (alloc && (rv != GRAPH_SUCCESS)) {
53 hint->rrb_alloc_funct = NULL;
54 hint->ph_intr_bits = NULL;
55 rv = hwgraph_info_add_LBL(xconn_vhdl,
57 (arbitrary_info_t) hint);
58 if (rv != GRAPH_SUCCESS)
61 rv = hwgraph_info_get_LBL(xconn_vhdl, INFO_LBL_PCIBR_HINTS, &ainfo);
63 if (rv != GRAPH_SUCCESS)
66 if (ainfo != (arbitrary_info_t) hint)
69 return (pcibr_hints_t) ainfo;
73 printf("SHOULD NOT BE HERE\n");
81 pcibr_hints_fix_some_rrbs(vertex_hdl_t xconn_vhdl, unsigned mask)
83 pcibr_hints_t hint = pcibr_hints_get(xconn_vhdl, 1);
86 hint->ph_rrb_fixed = mask;
88 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
89 "pcibr_hints_fix_rrbs: pcibr_hints_get failed\n"));
93 pcibr_hints_fix_rrbs(vertex_hdl_t xconn_vhdl)
95 pcibr_hints_fix_some_rrbs(xconn_vhdl, 0xFF);
99 pcibr_hints_dualslot(vertex_hdl_t xconn_vhdl,
103 pcibr_hints_t hint = pcibr_hints_get(xconn_vhdl, 1);
106 hint->ph_host_slot[guest] = host + 1;
108 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
109 "pcibr_hints_dualslot: pcibr_hints_get failed\n"));
113 pcibr_hints_intr_bits(vertex_hdl_t xconn_vhdl,
114 pcibr_intr_bits_f *xxx_intr_bits)
116 pcibr_hints_t hint = pcibr_hints_get(xconn_vhdl, 1);
119 hint->ph_intr_bits = xxx_intr_bits;
121 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
122 "pcibr_hints_intr_bits: pcibr_hints_get failed\n"));
126 pcibr_set_rrb_callback(vertex_hdl_t xconn_vhdl, rrb_alloc_funct_t rrb_alloc_funct)
128 pcibr_hints_t hint = pcibr_hints_get(xconn_vhdl, 1);
131 hint->rrb_alloc_funct = rrb_alloc_funct;
135 pcibr_hints_handsoff(vertex_hdl_t xconn_vhdl)
137 pcibr_hints_t hint = pcibr_hints_get(xconn_vhdl, 1);
140 hint->ph_hands_off = 1;
142 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
143 "pcibr_hints_handsoff: pcibr_hints_get failed\n"));
147 pcibr_hints_subdevs(vertex_hdl_t xconn_vhdl,
151 arbitrary_info_t ainfo = 0;
153 vertex_hdl_t pconn_vhdl = GRAPH_VERTEX_NONE;
155 sprintf(sdname, "%s/%d", EDGE_LBL_PCI, slot);
156 (void) hwgraph_path_add(xconn_vhdl, sdname, &pconn_vhdl);
157 if (pconn_vhdl == GRAPH_VERTEX_NONE) {
158 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
159 "pcibr_hints_subdevs: hwgraph_path_create failed\n"));
162 hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
168 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
169 "pcibr_hints_subdevs: subdev ptr alloc failed\n"));
173 hwgraph_info_add_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, (arbitrary_info_t) subdevp);
174 hwgraph_info_get_LBL(pconn_vhdl, INFO_LBL_SUBDEVS, &ainfo);
175 if (ainfo == (arbitrary_info_t) subdevp)
178 if (ainfo == (arbitrary_info_t) NULL) {
179 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
180 "pcibr_hints_subdevs: null subdevs ptr\n"));
183 PCIBR_DEBUG_ALWAYS((PCIBR_DEBUG_HINTS, xconn_vhdl,
184 "pcibr_subdevs_get: dup subdev add_LBL\n"));
186 *(uint64_t *) ainfo = subdevs;