2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
9 #include <linux/types.h>
10 #include <linux/config.h>
11 #include <linux/slab.h>
12 #include <linux/smp.h>
13 #include <asm/sn/sgi.h>
14 #include <asm/sn/io.h>
15 #include <asm/sn/sn_cpuid.h>
16 #include <asm/sn/klconfig.h>
17 #include <asm/sn/sn_private.h>
18 #include <asm/sn/pda.h>
20 extern void init_all_devices(void);
21 extern void klhwg_add_all_modules(vertex_hdl_t);
22 extern void klhwg_add_all_nodes(vertex_hdl_t);
24 extern int init_hcl(void);
25 extern vertex_hdl_t hwgraph_root;
26 extern void io_module_init(void);
27 extern int pci_bus_to_hcl_cvlink(void);
29 cpuid_t master_procid;
30 nasid_t console_nasid = (nasid_t) - 1;
31 char master_baseio_wid;
33 nasid_t master_baseio_nasid;
34 nasid_t master_nasid = INVALID_NASID; /* This is the partition master nasid */
39 * This code is executed once for each Hub chip.
42 per_hub_init(cnodeid_t cnode)
48 ii_ilcsr_u_t ii_ilcsr;
50 nasid = COMPACT_TO_NASID_NODEID(cnode);
52 ASSERT(nasid != INVALID_NASID);
53 ASSERT(NASID_TO_COMPACT_NODEID(nasid) == cnode);
55 npdap = NODEPDA(cnode);
57 /* Disable the request and reply errors. */
58 REMOTE_HUB_S(nasid, IIO_IWEIM, 0xC000);
61 * Set the total number of CRBs that can be used.
63 ii_icmr.ii_icmr_regval = 0x0;
64 ii_icmr.ii_icmr_fld_s.i_c_cnt = 0xf;
65 if (enable_shub_wars_1_1()) {
66 // Set bit one of ICMR to prevent II from sending interrupt for II bug.
67 ii_icmr.ii_icmr_regval |= 0x1;
69 REMOTE_HUB_S(nasid, IIO_ICMR, ii_icmr.ii_icmr_regval);
72 * Set the number of CRBs that both of the BTEs combined
75 ii_ibcr.ii_ibcr_regval = 0x0;
76 ii_ilcsr.ii_ilcsr_regval = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
77 if (ii_ilcsr.ii_ilcsr_fld_s.i_llp_stat & LNK_STAT_WORKING) {
78 ii_ibcr.ii_ibcr_fld_s.i_count = 0x8;
81 * if the LLP is down, there is no attached I/O, so
82 * give BTE all the CRBs.
84 ii_ibcr.ii_ibcr_fld_s.i_count = 0x14;
86 REMOTE_HUB_S(nasid, IIO_IBCR, ii_ibcr.ii_ibcr_regval);
89 * Set CRB timeout to be 10ms.
91 REMOTE_HUB_S(nasid, IIO_ICTP, 0xffffff);
92 REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
94 /* Initialize error interrupts for this hub. */
95 hub_error_init(cnode);
99 * This routine is responsible for the setup of all the IRIX hwgraph style
100 * stuff that's been pulled into linux. It's called by sn_pci_find_bios which
101 * is called just before the generic Linux PCI layer does its probing (by
102 * platform_pci_fixup aka sn_pci_fixup).
104 * It is very IMPORTANT that this call is only made by the Master CPU!
109 sgi_master_io_infr_init(void)
113 if (init_hcl() < 0) { /* Sets up the hwgraph compatibility layer */
114 printk("sgi_master_io_infr_init: Cannot init hcl\n");
119 * Initialize platform-dependent vertices in the hwgraph:
130 io_module_init(); /* Use to be called module_init() .. */
131 klhwg_add_all_modules(hwgraph_root);
132 klhwg_add_all_nodes(hwgraph_root);
134 for (cnode = 0; cnode < numionodes; cnode++) {
135 extern void per_hub_init(cnodeid_t);
141 * Our IO Infrastructure drivers are in place ..
142 * Initialize the whole IO Infrastructure .. xwidget/device probes.
146 pci_bus_to_hcl_cvlink();
150 check_nasid_equiv(nasid_t nasida, nasid_t nasidb)
152 if ((nasida == nasidb)
153 || (nasida == NODEPDA(NASID_TO_COMPACT_NODEID(nasidb))->xbow_peer))
160 is_master_baseio_nasid_widget(nasid_t test_nasid, xwidgetnum_t test_wid)
163 * If the widget numbers are different, we're not the master.
165 if (test_wid != (xwidgetnum_t) master_baseio_wid) {
170 * If the NASIDs are the same or equivalent, we're the master.
172 if (check_nasid_equiv(test_nasid, master_baseio_nasid)) {