sgi_io_init.c
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:9k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* $Id$
  2.  *
  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
  5.  * for more details.
  6.  *
  7.  * Copyright (C) 1992 - 1997, 2000-2002 Silicon Graphics, Inc. All rights reserved.
  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/pci/pciba.h>
  18. #include <linux/smp.h>
  19. extern void mlreset(int );
  20. extern int init_hcl(void);
  21. extern void klgraph_hack_init(void);
  22. extern void hubspc_init(void);
  23. extern void pciio_init(void);
  24. extern void pcibr_init(void);
  25. extern void xtalk_init(void);
  26. extern void xbow_init(void);
  27. extern void xbmon_init(void);
  28. extern void pciiox_init(void);
  29. extern void usrpci_init(void);
  30. extern void ioc3_init(void);
  31. extern void initialize_io(void);
  32. #if defined(CONFIG_IA64_SGI_SN1)
  33. extern void intr_clear_all(nasid_t);
  34. #endif
  35. extern void klhwg_add_all_modules(devfs_handle_t);
  36. extern void klhwg_add_all_nodes(devfs_handle_t);
  37. void sn_mp_setup(void);
  38. extern devfs_handle_t hwgraph_root;
  39. extern void io_module_init(void);
  40. extern void pci_bus_cvlink_init(void);
  41. extern void temp_hack(void);
  42. extern int pci_bus_to_hcl_cvlink(void);
  43. /* #define DEBUG_IO_INIT 1 */
  44. #ifdef DEBUG_IO_INIT
  45. #define DBG(x...) printk(x)
  46. #else
  47. #define DBG(x...)
  48. #endif /* DEBUG_IO_INIT */
  49. /*
  50.  * per_hub_init
  51.  *
  52.  *  This code is executed once for each Hub chip.
  53.  */
  54. static void
  55. per_hub_init(cnodeid_t cnode)
  56. {
  57. nasid_t nasid;
  58. nodepda_t *npdap;
  59. ii_icmr_u_t ii_icmr;
  60. ii_ibcr_u_t ii_ibcr;
  61. nasid = COMPACT_TO_NASID_NODEID(cnode);
  62. ASSERT(nasid != INVALID_NASID);
  63. ASSERT(NASID_TO_COMPACT_NODEID(nasid) == cnode);
  64. npdap = NODEPDA(cnode);
  65. #if defined(CONFIG_IA64_SGI_SN1)
  66. /* initialize per-node synergy perf instrumentation */
  67. npdap->synergy_perf_enabled = 0; /* off by default */
  68. npdap->synergy_perf_lock = SPIN_LOCK_UNLOCKED;
  69. npdap->synergy_perf_freq = SYNERGY_PERF_FREQ_DEFAULT;
  70. npdap->synergy_inactive_intervals = 0;
  71. npdap->synergy_active_intervals = 0;
  72. npdap->synergy_perf_data = NULL;
  73. npdap->synergy_perf_first = NULL;
  74. #endif /* CONFIG_IA64_SGI_SN1 */
  75. /*
  76.  * Set the total number of CRBs that can be used.
  77.  */
  78. ii_icmr.ii_icmr_regval= 0x0;
  79. ii_icmr.ii_icmr_fld_s.i_c_cnt = 0xF;
  80. REMOTE_HUB_S(nasid, IIO_ICMR, ii_icmr.ii_icmr_regval);
  81. /*
  82.  * Set the number of CRBs that both of the BTEs combined
  83.  * can use minus 1.
  84.  */
  85. ii_ibcr.ii_ibcr_regval= 0x0;
  86. ii_ibcr.ii_ibcr_fld_s.i_count = 0x8;
  87. REMOTE_HUB_S(nasid, IIO_IBCR, ii_ibcr.ii_ibcr_regval);
  88. /*
  89.  * Set CRB timeout to be 10ms.
  90.  */
  91. REMOTE_HUB_S(nasid, IIO_ICTP, 0x1000 );
  92. REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
  93. #if defined(CONFIG_IA64_SGI_SN1)
  94. /* Reserve all of the hardwired interrupt levels. */
  95. intr_reserve_hardwired(cnode);
  96. #endif
  97. /* Initialize error interrupts for this hub. */
  98. hub_error_init(cnode);
  99. }
  100. /*
  101.  * This routine is responsible for the setup of all the IRIX hwgraph style
  102.  * stuff that's been pulled into linux.  It's called by sn_pci_find_bios which
  103.  * is called just before the generic Linux PCI layer does its probing (by 
  104.  * platform_pci_fixup aka sn_pci_fixup).
  105.  *
  106.  * It is very IMPORTANT that this call is only made by the Master CPU!
  107.  *
  108.  */
  109. void
  110. sgi_master_io_infr_init(void)
  111. {
  112. int cnode;
  113. /*
  114.  * Do any early init stuff .. einit_tbl[] etc.
  115.  */
  116. DBG("--> sgi_master_io_infr_init: calling init_hcl().n");
  117. init_hcl(); /* Sets up the hwgraph compatibility layer with devfs */
  118. #ifdef Colin
  119. printk("Testing out Xbridge Access .. if it hangs Xbridge is not init yet.n");
  120. printk(" Reading Xbridge WID at address 0xc00000080f000000 0x%pn", (* (volatile uint32_t *)(0xc00000080f000000)));
  121. printk("Testing out PCI Address Space Accessesn");
  122. printk(" Testing PCI Config Read Byte: address 0xc00000080f020000 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020000)));
  123. printk(" Testing PCI Config Read Byte: address 0xc00000080f020001 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020001)));
  124. printk(" Testing PCI Config Read Byte: address 0xc00000080f020002 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020002)));
  125. printk(" Testing PCI Config Read Byte: address 0xc00000080f020003 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020003)));
  126. printk("        Testing PCI Config Read Byte: address 0xc00000080f020004 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020004)));
  127. printk("        Testing PCI Config Read Byte: address 0xc00000080f020005 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020005)));
  128. printk("        Testing PCI Config Read Byte: address 0xc00000080f020006 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020006)));
  129. printk("        Testing PCI Config Read Byte: address 0xc00000080f020007 value 0x%xn",(* (volatile uint8_t *)(0xc00000080f020007)));
  130. printk(" Testing PCI Config Word: address 0xc00000080f020004 value 0x%xn",(* (volatile uint32_t *)(0xc00000080f020004)));
  131. printk(" Testing PCI Config Word: address 0xc00000080f020008 value 0x%xn",(* (volatile uint32_t *)(0xc00000080f020008)));
  132. #endif
  133. /*
  134.  * initialize the Linux PCI to xwidget vertexes ..
  135.  */
  136. DBG("--> sgi_master_io_infr_init: calling pci_bus_cvlink_init().n");
  137. pci_bus_cvlink_init();
  138. #ifdef BRINGUP
  139. #ifdef CONFIG_IA64_SGI_SN1
  140. /*
  141.  * Hack to provide statically initialzed klgraph entries.
  142.  */
  143. DBG("--> sgi_master_io_infr_init: calling klgraph_hack_init()n");
  144. klgraph_hack_init();
  145. #endif /* CONFIG_IA64_SGI_SN1 */
  146. #endif /* BRINGUP */
  147. /*
  148.  * This is the Master CPU.  Emulate mlsetup and main.c in Irix.
  149.  */
  150. DBG("--> sgi_master_io_infr_init: calling mlreset(0).n");
  151. mlreset(0); /* Master .. */
  152. /*
  153.  * allowboot() is called by kern/os/main.c in main()
  154.  * Emulate allowboot() ...
  155.  *   per_cpu_init() - only need per_hub_init()
  156.  *   cpu_io_setup() - Nothing to do.
  157.  * 
  158.  */
  159. DBG("--> sgi_master_io_infr_init: calling sn_mp_setup().n");
  160. sn_mp_setup();
  161. DBG("--> sgi_master_io_infr_init: calling per_hub_init(0).n");
  162. for (cnode = 0; cnode < numnodes; cnode++) {
  163. per_hub_init(cnode);
  164. }
  165. /* We can do headless hub cnodes here .. */
  166. /*
  167.  * io_init[] stuff.
  168.  *
  169.  * Get SGI IO Infrastructure drivers to init and register with 
  170.  * each other etc.
  171.  */
  172. DBG("--> sgi_master_io_infr_init: calling hubspc_init()n");
  173. hubspc_init();
  174. DBG("--> sgi_master_io_infr_init: calling pciio_init()n");
  175. pciio_init();
  176. DBG("--> sgi_master_io_infr_init: calling pcibr_init()n");
  177. pcibr_init();
  178. DBG("--> sgi_master_io_infr_init: calling xtalk_init()n");
  179. xtalk_init();
  180. DBG("--> sgi_master_io_infr_init: calling xbow_init()n");
  181. xbow_init();
  182. DBG("--> sgi_master_io_infr_init: calling xbmon_init()n");
  183. xbmon_init();
  184. DBG("--> sgi_master_io_infr_init: calling pciiox_init()n");
  185. pciiox_init();
  186. DBG("--> sgi_master_io_infr_init: calling usrpci_init()n");
  187. usrpci_init();
  188. DBG("--> sgi_master_io_infr_init: calling ioc3_init()n");
  189. ioc3_init();
  190. /*
  191.  *
  192.  * Our IO Infrastructure drivers are in place .. 
  193.  * Initialize the whole IO Infrastructure .. xwidget/device probes.
  194.  *
  195.  */
  196. DBG("--> sgi_master_io_infr_init: Start Probe and IO Initializationn");
  197. initialize_io();
  198. DBG("--> sgi_master_io_infr_init: Setting up SGI IO Links for Linux PCIn");
  199. pci_bus_to_hcl_cvlink();
  200. #ifdef CONFIG_PCIBA
  201. DBG("--> sgi_master_io_infr_init: calling pciba_init()n");
  202. pciba_init();
  203. #endif
  204. DBG("--> Leave sgi_master_io_infr_init: DONE setting up SGI Links for PCIn");
  205. }
  206. /*
  207.  * sgi_slave_io_infr_init - This routine must be called on all cpus except 
  208.  * the Master CPU.
  209.  */
  210. void
  211. sgi_slave_io_infr_init(void)
  212. {
  213. /* Emulate cboot() .. */
  214. mlreset(1); /* This is a slave cpu */
  215. // per_hub_init(0); /* Need to get and send in actual cnode number */
  216. /* Done */
  217. }
  218. /*
  219.  * One-time setup for MP SN.
  220.  * Allocate per-node data, slurp prom klconfig information and
  221.  * convert it to hwgraph information.
  222.  */
  223. void
  224. sn_mp_setup(void)
  225. {
  226. cnodeid_t cnode;
  227. cpuid_t cpu;
  228. for (cpu = 0; cpu < smp_num_cpus; cpu++) {
  229. /* Skip holes in CPU space */
  230. if (cpu_enabled(cpu)) {
  231. init_platform_pda(cpu);
  232. }
  233. }
  234. /*
  235.  * Initialize platform-dependent vertices in the hwgraph:
  236.  * module
  237.  * node
  238.  * cpu
  239.  * memory
  240.  * slot
  241.  * hub
  242.  * router
  243.  * xbow
  244.  */
  245. DBG("sn_mp_io_setup: calling io_module_init()n");
  246. io_module_init(); /* Use to be called module_init() .. */
  247. DBG("sn_mp_setup: calling klhwg_add_all_modules()n");
  248. klhwg_add_all_modules(hwgraph_root);
  249. DBG("sn_mp_setup: calling klhwg_add_all_nodes()n");
  250. klhwg_add_all_nodes(hwgraph_root);
  251. for (cnode = 0; cnode < numnodes; cnode++) {
  252. /*
  253.  * This routine clears the Hub's Interrupt registers.
  254.  */
  255. /*
  256.  * We need to move this intr_clear_all() routine 
  257.  * from SN/intr.c to a more appropriate file.
  258.  * Talk to Al Mayer.
  259.  */
  260. #if defined(CONFIG_IA64_SGI_SN1)
  261.                 intr_clear_all(COMPACT_TO_NASID_NODEID(cnode));
  262. #endif
  263. /* now init the hub */
  264. // per_hub_init(cnode);
  265. }
  266. #if defined(CONFIG_IA64_SGI_SN1)
  267. synergy_perf_init();
  268. #endif
  269. }