import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / ia64 / sn / io / platform_init / sgi_io_init.c
1 /*
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
4  * for more details.
5  *
6  * Copyright (C) 1992 - 1997, 2000-2003 Silicon Graphics, Inc. All rights reserved.
7  */
8
9 #include <linux/types.h>
10 #include <linux/config.h>
11 #include <linux/slab.h>
12 #include <asm/sn/sgi.h>
13 #include <asm/sn/io.h>
14 #include <asm/sn/sn_cpuid.h>
15 #include <asm/sn/klconfig.h>
16 #include <asm/sn/sn_private.h>
17 #include <asm/sn/pda.h>
18 #include <linux/smp.h>
19
20 extern int init_hcl(void);
21
22 /*
23  * per_hub_init
24  *
25  *      This code is executed once for each Hub chip.
26  */
27 void
28 per_hub_init(cnodeid_t cnode)
29 {
30         nasid_t         nasid;
31         nodepda_t       *npdap;
32         ii_icmr_u_t     ii_icmr;
33         ii_ibcr_u_t     ii_ibcr;
34         ii_ilcsr_u_t    ii_ilcsr;
35
36         nasid = COMPACT_TO_NASID_NODEID(cnode);
37
38         ASSERT(nasid != INVALID_NASID);
39         ASSERT(NASID_TO_COMPACT_NODEID(nasid) == cnode);
40
41         npdap = NODEPDA(cnode);
42
43         /* Disable the request and reply errors. */
44         REMOTE_HUB_S(nasid, IIO_IWEIM, 0xC000);
45
46         /*
47          * Set the total number of CRBs that can be used.
48          */
49         ii_icmr.ii_icmr_regval= 0x0;
50         ii_icmr.ii_icmr_fld_s.i_c_cnt = 0xf;
51         if (enable_shub_wars_1_1() ) {
52                 // Set bit one of ICMR to prevent II from sending interrupt for II bug.
53                 ii_icmr.ii_icmr_regval |= 0x1; 
54         }
55         REMOTE_HUB_S(nasid, IIO_ICMR, ii_icmr.ii_icmr_regval);
56
57         /*
58          * Set the number of CRBs that both of the BTEs combined
59          * can use minus 1.
60          */
61         ii_ibcr.ii_ibcr_regval= 0x0;
62         ii_ilcsr.ii_ilcsr_regval = REMOTE_HUB_L(nasid, IIO_LLP_CSR);
63         if (ii_ilcsr.ii_ilcsr_fld_s.i_llp_stat & LNK_STAT_WORKING) {
64             ii_ibcr.ii_ibcr_fld_s.i_count = 0x8;
65         } else {
66             /*
67              * if the LLP is down, there is no attached I/O, so
68             * give BTE all the CRBs.
69             */
70             ii_ibcr.ii_ibcr_fld_s.i_count = 0x14;
71         }
72         REMOTE_HUB_S(nasid, IIO_IBCR, ii_ibcr.ii_ibcr_regval);
73
74         /*
75          * Set CRB timeout to be 10ms.
76          */
77         REMOTE_HUB_S(nasid, IIO_ICTP, 0xffffff );
78         REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
79
80         /* Initialize error interrupts for this hub. */
81         hub_error_init(cnode);
82 }
83
84 /*
85  * This routine is responsible for the setup of all the IRIX hwgraph style
86  * stuff that's been pulled into linux.  It's called by sn_pci_find_bios which
87  * is called just before the generic Linux PCI layer does its probing (by 
88  * platform_pci_fixup aka sn_pci_fixup).
89  *
90  * It is very IMPORTANT that this call is only made by the Master CPU!
91  *
92  */
93
94 void
95 sgi_master_io_infr_init(void)
96 {
97         extern void irix_io_init(void);
98
99         init_hcl(); /* Sets up the hwgraph compatibility layer with devfs */
100         irix_io_init(); /* Do IRIX Compatibility IO Init */
101
102 #ifdef  CONFIG_KDB
103         {
104                 extern void kdba_io_init(void);
105                 kdba_io_init();
106         }
107 #endif
108
109 }