setup.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Celleb setup code
  3. *
  4. * (C) Copyright 2006-2007 TOSHIBA CORPORATION
  5. *
  6. * This code is based on arch/powerpc/platforms/cell/setup.c:
  7. * Copyright (C) 1995 Linus Torvalds
  8. * Adapted from 'alpha' version by Gary Thomas
  9. * Modified by Cort Dougan (cort@cs.nmt.edu)
  10. * Modified by PPC64 Team, IBM Corp
  11. * Modified by Cell Team, IBM Deutschland Entwicklung GmbH
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License along
  24. * with this program; if not, write to the Free Software Foundation, Inc.,
  25. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26. */
  27. #undef DEBUG
  28. #include <linux/cpu.h>
  29. #include <linux/sched.h>
  30. #include <linux/kernel.h>
  31. #include <linux/mm.h>
  32. #include <linux/stddef.h>
  33. #include <linux/unistd.h>
  34. #include <linux/reboot.h>
  35. #include <linux/init.h>
  36. #include <linux/delay.h>
  37. #include <linux/irq.h>
  38. #include <linux/seq_file.h>
  39. #include <linux/root_dev.h>
  40. #include <linux/console.h>
  41. #include <linux/of_platform.h>
  42. #include <asm/mmu.h>
  43. #include <asm/processor.h>
  44. #include <asm/io.h>
  45. #include <asm/kexec.h>
  46. #include <asm/prom.h>
  47. #include <asm/machdep.h>
  48. #include <asm/cputable.h>
  49. #include <asm/irq.h>
  50. #include <asm/time.h>
  51. #include <asm/spu_priv1.h>
  52. #include <asm/firmware.h>
  53. #include <asm/rtas.h>
  54. #include <asm/cell-regs.h>
  55. #include "interrupt.h"
  56. #include "beat_wrapper.h"
  57. #include "beat.h"
  58. #include "pci.h"
  59. #include "../cell/interrupt.h"
  60. #include "../cell/pervasive.h"
  61. #include "../cell/ras.h"
  62. static char celleb_machine_type[128] = "Celleb";
  63. static void celleb_show_cpuinfo(struct seq_file *m)
  64. {
  65. struct device_node *root;
  66. const char *model = "";
  67. root = of_find_node_by_path("/");
  68. if (root)
  69. model = of_get_property(root, "model", NULL);
  70. /* using "CHRP" is to trick anaconda into installing FCx into Celleb */
  71. seq_printf(m, "machine\t\t: %s %s\n", celleb_machine_type, model);
  72. of_node_put(root);
  73. }
  74. static int __init celleb_machine_type_hack(char *ptr)
  75. {
  76. strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
  77. celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
  78. return 0;
  79. }
  80. __setup("celleb_machine_type_hack=", celleb_machine_type_hack);
  81. static void celleb_progress(char *s, unsigned short hex)
  82. {
  83. printk("*** %04x : %s\n", hex, s ? s : "");
  84. }
  85. static void __init celleb_init_IRQ_native(void)
  86. {
  87. iic_init_IRQ();
  88. spider_init_IRQ();
  89. }
  90. static void __init celleb_setup_arch_beat(void)
  91. {
  92. ppc_md.restart = beat_restart;
  93. ppc_md.power_off = beat_power_off;
  94. ppc_md.halt = beat_halt;
  95. ppc_md.get_rtc_time = beat_get_rtc_time;
  96. ppc_md.set_rtc_time = beat_set_rtc_time;
  97. ppc_md.power_save = beat_power_save;
  98. ppc_md.nvram_size = beat_nvram_get_size;
  99. ppc_md.nvram_read = beat_nvram_read;
  100. ppc_md.nvram_write = beat_nvram_write;
  101. ppc_md.set_dabr = beat_set_xdabr;
  102. ppc_md.init_IRQ = beatic_init_IRQ;
  103. ppc_md.get_irq = beatic_get_irq;
  104. #ifdef CONFIG_KEXEC
  105. ppc_md.kexec_cpu_down = beat_kexec_cpu_down;
  106. #endif
  107. #ifdef CONFIG_SPU_BASE
  108. spu_priv1_ops = &spu_priv1_beat_ops;
  109. spu_management_ops = &spu_management_of_ops;
  110. #endif
  111. #ifdef CONFIG_SMP
  112. smp_init_celleb();
  113. #endif
  114. }
  115. static void __init celleb_setup_arch_native(void)
  116. {
  117. ppc_md.restart = rtas_restart;
  118. ppc_md.power_off = rtas_power_off;
  119. ppc_md.halt = rtas_halt;
  120. ppc_md.get_boot_time = rtas_get_boot_time;
  121. ppc_md.get_rtc_time = rtas_get_rtc_time;
  122. ppc_md.set_rtc_time = rtas_set_rtc_time;
  123. ppc_md.init_IRQ = celleb_init_IRQ_native;
  124. #ifdef CONFIG_SPU_BASE
  125. spu_priv1_ops = &spu_priv1_mmio_ops;
  126. spu_management_ops = &spu_management_of_ops;
  127. #endif
  128. cbe_regs_init();
  129. #ifdef CONFIG_CBE_RAS
  130. cbe_ras_init();
  131. #endif
  132. #ifdef CONFIG_SMP
  133. smp_init_cell();
  134. #endif
  135. cbe_pervasive_init();
  136. }
  137. static void __init celleb_setup_arch(void)
  138. {
  139. if (firmware_has_feature(FW_FEATURE_BEAT))
  140. celleb_setup_arch_beat();
  141. else
  142. celleb_setup_arch_native();
  143. /* init to some ~sane value until calibrate_delay() runs */
  144. loops_per_jiffy = 50000000;
  145. #ifdef CONFIG_DUMMY_CONSOLE
  146. conswitchp = &dummy_con;
  147. #endif
  148. }
  149. static int __init celleb_probe(void)
  150. {
  151. unsigned long root = of_get_flat_dt_root();
  152. if (of_flat_dt_is_compatible(root, "Beat")) {
  153. powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS
  154. | FW_FEATURE_BEAT | FW_FEATURE_LPAR;
  155. hpte_init_beat_v3();
  156. return 1;
  157. }
  158. if (of_flat_dt_is_compatible(root, "TOSHIBA,Celleb")) {
  159. powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS;
  160. hpte_init_native();
  161. return 1;
  162. }
  163. return 0;
  164. }
  165. static struct of_device_id celleb_bus_ids[] __initdata = {
  166. { .type = "scc", },
  167. { .type = "ioif", }, /* old style */
  168. {},
  169. };
  170. static int __init celleb_publish_devices(void)
  171. {
  172. if (!machine_is(celleb))
  173. return 0;
  174. /* Publish OF platform devices for southbridge IOs */
  175. of_platform_bus_probe(NULL, celleb_bus_ids, NULL);
  176. celleb_pci_workaround_init();
  177. return 0;
  178. }
  179. device_initcall(celleb_publish_devices);
  180. define_machine(celleb) {
  181. .name = "Cell Reference Set",
  182. .probe = celleb_probe,
  183. .setup_arch = celleb_setup_arch,
  184. .show_cpuinfo = celleb_show_cpuinfo,
  185. .calibrate_decr = generic_calibrate_decr,
  186. .progress = celleb_progress,
  187. .pci_probe_mode = celleb_pci_probe_mode,
  188. .pci_setup_phb = celleb_setup_phb,
  189. #ifdef CONFIG_KEXEC
  190. .machine_kexec = default_machine_kexec,
  191. .machine_kexec_prepare = default_machine_kexec_prepare,
  192. .machine_crash_shutdown = default_machine_crash_shutdown,
  193. #endif
  194. };