ip27-init.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General
  3. * Public License. See the file "COPYING" in the main directory of this
  4. * archive for more details.
  5. *
  6. * Copyright (C) 2000 - 2001 by Kanoj Sarcar ([email protected])
  7. * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <linux/sched.h>
  12. #include <linux/smp.h>
  13. #include <linux/mm.h>
  14. #include <linux/export.h>
  15. #include <linux/cpumask.h>
  16. #include <asm/bootinfo.h>
  17. #include <asm/cpu.h>
  18. #include <asm/io.h>
  19. #include <asm/sgialib.h>
  20. #include <asm/time.h>
  21. #include <asm/sn/agent.h>
  22. #include <asm/sn/types.h>
  23. #include <asm/sn/klconfig.h>
  24. #include <asm/sn/ioc3.h>
  25. #include <asm/mipsregs.h>
  26. #include <asm/sn/gda.h>
  27. #include <asm/sn/intr.h>
  28. #include <asm/current.h>
  29. #include <asm/processor.h>
  30. #include <asm/mmu_context.h>
  31. #include <asm/thread_info.h>
  32. #include <asm/sn/launch.h>
  33. #include <asm/sn/mapped_kernel.h>
  34. #include "ip27-common.h"
  35. #define CPU_NONE (cpuid_t)-1
  36. static DECLARE_BITMAP(hub_init_mask, MAX_NUMNODES);
  37. nasid_t master_nasid = INVALID_NASID;
  38. struct cpuinfo_ip27 sn_cpu_info[NR_CPUS];
  39. EXPORT_SYMBOL_GPL(sn_cpu_info);
  40. static void per_hub_init(nasid_t nasid)
  41. {
  42. struct hub_data *hub = hub_data(nasid);
  43. cpumask_set_cpu(smp_processor_id(), &hub->h_cpus);
  44. if (test_and_set_bit(nasid, hub_init_mask))
  45. return;
  46. /*
  47. * Set CRB timeout at 5ms, (< PI timeout of 10ms)
  48. */
  49. REMOTE_HUB_S(nasid, IIO_ICTP, 0x800);
  50. REMOTE_HUB_S(nasid, IIO_ICTO, 0xff);
  51. hub_rtc_init(nasid);
  52. if (nasid) {
  53. /* copy exception handlers from first node to current node */
  54. memcpy((void *)NODE_OFFSET_TO_K0(nasid, 0),
  55. (void *)CKSEG0, 0x200);
  56. __flush_cache_all();
  57. /* switch to node local exception handlers */
  58. REMOTE_HUB_S(nasid, PI_CALIAS_SIZE, PI_CALIAS_SIZE_8K);
  59. }
  60. }
  61. void per_cpu_init(void)
  62. {
  63. int cpu = smp_processor_id();
  64. nasid_t nasid = get_nasid();
  65. clear_c0_status(ST0_IM);
  66. per_hub_init(nasid);
  67. pr_info("CPU %d clock is %dMHz.\n", cpu, sn_cpu_info[cpu].p_speed);
  68. install_ipi();
  69. /* Install our NMI handler if symmon hasn't installed one. */
  70. install_cpu_nmi_handler(cputoslice(cpu));
  71. enable_percpu_irq(IP27_HUB_PEND0_IRQ, IRQ_TYPE_NONE);
  72. enable_percpu_irq(IP27_HUB_PEND1_IRQ, IRQ_TYPE_NONE);
  73. }
  74. void __init plat_mem_setup(void)
  75. {
  76. u64 p, e, n_mode;
  77. nasid_t nid;
  78. register_smp_ops(&ip27_smp_ops);
  79. ip27_reboot_setup();
  80. /*
  81. * hub_rtc init and cpu clock intr enabled for later calibrate_delay.
  82. */
  83. nid = get_nasid();
  84. printk("IP27: Running on node %d.\n", nid);
  85. p = LOCAL_HUB_L(PI_CPU_PRESENT_A) & 1;
  86. e = LOCAL_HUB_L(PI_CPU_ENABLE_A) & 1;
  87. printk("Node %d has %s primary CPU%s.\n", nid,
  88. p ? "a" : "no",
  89. e ? ", CPU is running" : "");
  90. p = LOCAL_HUB_L(PI_CPU_PRESENT_B) & 1;
  91. e = LOCAL_HUB_L(PI_CPU_ENABLE_B) & 1;
  92. printk("Node %d has %s secondary CPU%s.\n", nid,
  93. p ? "a" : "no",
  94. e ? ", CPU is running" : "");
  95. /*
  96. * Try to catch kernel missconfigurations and give user an
  97. * indication what option to select.
  98. */
  99. n_mode = LOCAL_HUB_L(NI_STATUS_REV_ID) & NSRI_MORENODES_MASK;
  100. printk("Machine is in %c mode.\n", n_mode ? 'N' : 'M');
  101. #ifdef CONFIG_SGI_SN_N_MODE
  102. if (!n_mode)
  103. panic("Kernel compiled for M mode.");
  104. #else
  105. if (n_mode)
  106. panic("Kernel compiled for N mode.");
  107. #endif
  108. ioport_resource.start = 0;
  109. ioport_resource.end = ~0UL;
  110. set_io_port_base(IO_BASE);
  111. }
  112. const char *get_system_type(void)
  113. {
  114. return "SGI Origin";
  115. }
  116. void __init prom_init(void)
  117. {
  118. prom_init_cmdline(fw_arg0, (LONG *)fw_arg1);
  119. prom_meminit();
  120. }