setup.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. * SGI UV Core Functions
  7. *
  8. * Copyright (C) 2008 Silicon Graphics, Inc. All rights reserved.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/percpu.h>
  12. #include <asm/sn/simulator.h>
  13. #include <asm/uv/uv_mmrs.h>
  14. #include <asm/uv/uv_hub.h>
  15. DEFINE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
  16. EXPORT_PER_CPU_SYMBOL_GPL(__uv_hub_info);
  17. #ifdef CONFIG_IA64_SGI_UV
  18. int sn_prom_type;
  19. long sn_partition_id;
  20. EXPORT_SYMBOL(sn_partition_id);
  21. long sn_coherency_id;
  22. EXPORT_SYMBOL_GPL(sn_coherency_id);
  23. long sn_region_size;
  24. EXPORT_SYMBOL(sn_region_size);
  25. #endif
  26. struct redir_addr {
  27. unsigned long redirect;
  28. unsigned long alias;
  29. };
  30. #define DEST_SHIFT UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR_DEST_BASE_SHFT
  31. static __initdata struct redir_addr redir_addrs[] = {
  32. {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_0_MMR, UVH_SI_ALIAS0_OVERLAY_CONFIG},
  33. {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_1_MMR, UVH_SI_ALIAS1_OVERLAY_CONFIG},
  34. {UVH_RH_GAM_ALIAS210_REDIRECT_CONFIG_2_MMR, UVH_SI_ALIAS2_OVERLAY_CONFIG},
  35. };
  36. static __init void get_lowmem_redirect(unsigned long *base, unsigned long *size)
  37. {
  38. union uvh_si_alias0_overlay_config_u alias;
  39. union uvh_rh_gam_alias210_redirect_config_2_mmr_u redirect;
  40. int i;
  41. for (i = 0; i < ARRAY_SIZE(redir_addrs); i++) {
  42. alias.v = uv_read_local_mmr(redir_addrs[i].alias);
  43. if (alias.s.base == 0) {
  44. *size = (1UL << alias.s.m_alias);
  45. redirect.v = uv_read_local_mmr(redir_addrs[i].redirect);
  46. *base = (unsigned long)redirect.s.dest_base << DEST_SHIFT;
  47. return;
  48. }
  49. }
  50. BUG();
  51. }
  52. void __init uv_setup(char **cmdline_p)
  53. {
  54. union uvh_si_addr_map_config_u m_n_config;
  55. union uvh_node_id_u node_id;
  56. unsigned long gnode_upper;
  57. int nid, cpu, m_val, n_val;
  58. unsigned long mmr_base, lowmem_redir_base, lowmem_redir_size;
  59. if (IS_MEDUSA()) {
  60. lowmem_redir_base = 0;
  61. lowmem_redir_size = 0;
  62. node_id.v = 0;
  63. m_n_config.s.m_skt = 37;
  64. m_n_config.s.n_skt = 0;
  65. mmr_base = 0;
  66. #if 0
  67. /* Need BIOS calls - TDB */
  68. if (!ia64_sn_is_fake_prom())
  69. sn_prom_type = 1;
  70. else
  71. #endif
  72. sn_prom_type = 2;
  73. printk(KERN_INFO "Running on medusa with %s PROM\n",
  74. (sn_prom_type == 1) ? "real" : "fake");
  75. } else {
  76. get_lowmem_redirect(&lowmem_redir_base, &lowmem_redir_size);
  77. node_id.v = uv_read_local_mmr(UVH_NODE_ID);
  78. m_n_config.v = uv_read_local_mmr(UVH_SI_ADDR_MAP_CONFIG);
  79. mmr_base =
  80. uv_read_local_mmr(UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR) &
  81. ~UV_MMR_ENABLE;
  82. }
  83. m_val = m_n_config.s.m_skt;
  84. n_val = m_n_config.s.n_skt;
  85. printk(KERN_DEBUG "UV: global MMR base 0x%lx\n", mmr_base);
  86. gnode_upper = (((unsigned long)node_id.s.node_id) &
  87. ~((1 << n_val) - 1)) << m_val;
  88. for_each_present_cpu(cpu) {
  89. nid = cpu_to_node(cpu);
  90. uv_cpu_hub_info(cpu)->lowmem_remap_base = lowmem_redir_base;
  91. uv_cpu_hub_info(cpu)->lowmem_remap_top =
  92. lowmem_redir_base + lowmem_redir_size;
  93. uv_cpu_hub_info(cpu)->m_val = m_val;
  94. uv_cpu_hub_info(cpu)->n_val = n_val;
  95. uv_cpu_hub_info(cpu)->pnode_mask = (1 << n_val) -1;
  96. uv_cpu_hub_info(cpu)->gpa_mask = (1 << (m_val + n_val)) - 1;
  97. uv_cpu_hub_info(cpu)->gnode_upper = gnode_upper;
  98. uv_cpu_hub_info(cpu)->global_mmr_base = mmr_base;
  99. uv_cpu_hub_info(cpu)->coherency_domain_number = 0;/* ZZZ */
  100. printk(KERN_DEBUG "UV cpu %d, nid %d\n", cpu, nid);
  101. }
  102. }