setup.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. * PS3 platform setup routines.
  3. *
  4. * Copyright (C) 2006 Sony Computer Entertainment Inc.
  5. * Copyright 2006 Sony Corp.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/delay.h>
  22. #include <linux/fs.h>
  23. #include <linux/root_dev.h>
  24. #include <linux/console.h>
  25. #include <linux/kexec.h>
  26. #include <asm/machdep.h>
  27. #include <asm/firmware.h>
  28. #include <asm/time.h>
  29. #include <asm/iommu.h>
  30. #include <asm/udbg.h>
  31. #include <asm/prom.h>
  32. #include <asm/lv1call.h>
  33. #include "platform.h"
  34. #if defined(DEBUG)
  35. #define DBG(fmt...) udbg_printf(fmt)
  36. #else
  37. #define DBG(fmt...) do{if(0)printk(fmt);}while(0)
  38. #endif
  39. static void ps3_show_cpuinfo(struct seq_file *m)
  40. {
  41. seq_printf(m, "machine\t\t: %s\n", ppc_md.name);
  42. }
  43. static void ps3_power_save(void)
  44. {
  45. /*
  46. * lv1_pause() puts the PPE thread into inactive state until an
  47. * irq on an unmasked plug exists. MSR[EE] has no effect.
  48. * flags: 0 = wake on DEC interrupt, 1 = ignore DEC interrupt.
  49. */
  50. lv1_pause(0);
  51. }
  52. static void ps3_panic(char *str)
  53. {
  54. DBG("%s:%d %s\n", __func__, __LINE__, str);
  55. #ifdef CONFIG_SMP
  56. smp_send_stop();
  57. #endif
  58. printk("\n");
  59. printk(" System does not reboot automatically.\n");
  60. printk(" Please press POWER button.\n");
  61. printk("\n");
  62. for (;;) ;
  63. }
  64. static void __init ps3_setup_arch(void)
  65. {
  66. DBG(" -> %s:%d\n", __func__, __LINE__);
  67. ps3_spu_set_platform();
  68. ps3_map_htab();
  69. #ifdef CONFIG_SMP
  70. smp_init_ps3();
  71. #endif
  72. #ifdef CONFIG_DUMMY_CONSOLE
  73. conswitchp = &dummy_con;
  74. #endif
  75. ppc_md.power_save = ps3_power_save;
  76. DBG(" <- %s:%d\n", __func__, __LINE__);
  77. }
  78. static void __init ps3_progress(char *s, unsigned short hex)
  79. {
  80. printk("*** %04x : %s\n", hex, s ? s : "");
  81. }
  82. static int __init ps3_probe(void)
  83. {
  84. unsigned long htab_size;
  85. unsigned long dt_root;
  86. DBG(" -> %s:%d\n", __func__, __LINE__);
  87. dt_root = of_get_flat_dt_root();
  88. if (!of_flat_dt_is_compatible(dt_root, "PS3"))
  89. return 0;
  90. powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
  91. ps3_os_area_init();
  92. ps3_mm_init();
  93. ps3_mm_vas_create(&htab_size);
  94. ps3_hpte_init(htab_size);
  95. DBG(" <- %s:%d\n", __func__, __LINE__);
  96. return 1;
  97. }
  98. #if defined(CONFIG_KEXEC)
  99. static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)
  100. {
  101. DBG(" -> %s:%d\n", __func__, __LINE__);
  102. if (secondary) {
  103. int cpu;
  104. for_each_online_cpu(cpu)
  105. if (cpu)
  106. ps3_smp_cleanup_cpu(cpu);
  107. } else
  108. ps3_smp_cleanup_cpu(0);
  109. DBG(" <- %s:%d\n", __func__, __LINE__);
  110. }
  111. static void ps3_machine_kexec(struct kimage *image)
  112. {
  113. unsigned long ppe_id;
  114. DBG(" -> %s:%d\n", __func__, __LINE__);
  115. lv1_get_logical_ppe_id(&ppe_id);
  116. lv1_configure_irq_state_bitmap(ppe_id, 0, 0);
  117. ps3_mm_shutdown();
  118. ps3_mm_vas_destroy();
  119. default_machine_kexec(image);
  120. DBG(" <- %s:%d\n", __func__, __LINE__);
  121. }
  122. #endif
  123. define_machine(ps3) {
  124. .name = "PS3",
  125. .probe = ps3_probe,
  126. .setup_arch = ps3_setup_arch,
  127. .show_cpuinfo = ps3_show_cpuinfo,
  128. .init_IRQ = ps3_init_IRQ,
  129. .panic = ps3_panic,
  130. .get_boot_time = ps3_get_boot_time,
  131. .set_rtc_time = ps3_set_rtc_time,
  132. .get_rtc_time = ps3_get_rtc_time,
  133. .calibrate_decr = ps3_calibrate_decr,
  134. .progress = ps3_progress,
  135. #if defined(CONFIG_KEXEC)
  136. .kexec_cpu_down = ps3_kexec_cpu_down,
  137. .machine_kexec = ps3_machine_kexec,
  138. .machine_kexec_prepare = default_machine_kexec_prepare,
  139. .machine_crash_shutdown = default_machine_crash_shutdown,
  140. #endif
  141. };