setup.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. int ps3_get_firmware_version(union ps3_firmware_version *v)
  40. {
  41. int result = lv1_get_version_info(&v->raw);
  42. if (result) {
  43. v->raw = 0;
  44. return -1;
  45. }
  46. return result;
  47. }
  48. EXPORT_SYMBOL_GPL(ps3_get_firmware_version);
  49. static void ps3_power_save(void)
  50. {
  51. /*
  52. * lv1_pause() puts the PPE thread into inactive state until an
  53. * irq on an unmasked plug exists. MSR[EE] has no effect.
  54. * flags: 0 = wake on DEC interrupt, 1 = ignore DEC interrupt.
  55. */
  56. lv1_pause(0);
  57. }
  58. static void ps3_panic(char *str)
  59. {
  60. DBG("%s:%d %s\n", __func__, __LINE__, str);
  61. #ifdef CONFIG_SMP
  62. smp_send_stop();
  63. #endif
  64. printk("\n");
  65. printk(" System does not reboot automatically.\n");
  66. printk(" Please press POWER button.\n");
  67. printk("\n");
  68. for (;;) ;
  69. }
  70. static void __init ps3_setup_arch(void)
  71. {
  72. union ps3_firmware_version v;
  73. DBG(" -> %s:%d\n", __func__, __LINE__);
  74. ps3_get_firmware_version(&v);
  75. printk(KERN_INFO "PS3 firmware version %u.%u.%u\n", v.major, v.minor,
  76. v.rev);
  77. ps3_spu_set_platform();
  78. ps3_map_htab();
  79. #ifdef CONFIG_SMP
  80. smp_init_ps3();
  81. #endif
  82. #ifdef CONFIG_DUMMY_CONSOLE
  83. conswitchp = &dummy_con;
  84. #endif
  85. ppc_md.power_save = ps3_power_save;
  86. DBG(" <- %s:%d\n", __func__, __LINE__);
  87. }
  88. static void __init ps3_progress(char *s, unsigned short hex)
  89. {
  90. printk("*** %04x : %s\n", hex, s ? s : "");
  91. }
  92. static int __init ps3_probe(void)
  93. {
  94. unsigned long htab_size;
  95. unsigned long dt_root;
  96. DBG(" -> %s:%d\n", __func__, __LINE__);
  97. dt_root = of_get_flat_dt_root();
  98. if (!of_flat_dt_is_compatible(dt_root, "PS3"))
  99. return 0;
  100. powerpc_firmware_features |= FW_FEATURE_PS3_POSSIBLE;
  101. ps3_os_area_init();
  102. ps3_mm_init();
  103. ps3_mm_vas_create(&htab_size);
  104. ps3_hpte_init(htab_size);
  105. DBG(" <- %s:%d\n", __func__, __LINE__);
  106. return 1;
  107. }
  108. #if defined(CONFIG_KEXEC)
  109. static void ps3_kexec_cpu_down(int crash_shutdown, int secondary)
  110. {
  111. DBG(" -> %s:%d\n", __func__, __LINE__);
  112. if (secondary) {
  113. int cpu;
  114. for_each_online_cpu(cpu)
  115. if (cpu)
  116. ps3_smp_cleanup_cpu(cpu);
  117. } else
  118. ps3_smp_cleanup_cpu(0);
  119. DBG(" <- %s:%d\n", __func__, __LINE__);
  120. }
  121. static void ps3_machine_kexec(struct kimage *image)
  122. {
  123. unsigned long ppe_id;
  124. DBG(" -> %s:%d\n", __func__, __LINE__);
  125. lv1_get_logical_ppe_id(&ppe_id);
  126. lv1_configure_irq_state_bitmap(ppe_id, 0, 0);
  127. ps3_mm_shutdown();
  128. ps3_mm_vas_destroy();
  129. default_machine_kexec(image);
  130. DBG(" <- %s:%d\n", __func__, __LINE__);
  131. }
  132. #endif
  133. define_machine(ps3) {
  134. .name = "PS3",
  135. .probe = ps3_probe,
  136. .setup_arch = ps3_setup_arch,
  137. .init_IRQ = ps3_init_IRQ,
  138. .panic = ps3_panic,
  139. .get_boot_time = ps3_get_boot_time,
  140. .set_rtc_time = ps3_set_rtc_time,
  141. .get_rtc_time = ps3_get_rtc_time,
  142. .calibrate_decr = ps3_calibrate_decr,
  143. .progress = ps3_progress,
  144. #if defined(CONFIG_KEXEC)
  145. .kexec_cpu_down = ps3_kexec_cpu_down,
  146. .machine_kexec = ps3_machine_kexec,
  147. .machine_kexec_prepare = default_machine_kexec_prepare,
  148. .machine_crash_shutdown = default_machine_crash_shutdown,
  149. #endif
  150. };