celleb_setup.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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/prom.h>
  46. #include <asm/machdep.h>
  47. #include <asm/cputable.h>
  48. #include <asm/irq.h>
  49. #include <asm/time.h>
  50. #include <asm/spu_priv1.h>
  51. #include <asm/firmware.h>
  52. #include <asm/rtas.h>
  53. #include <asm/cell-regs.h>
  54. #include "beat_interrupt.h"
  55. #include "beat_wrapper.h"
  56. #include "beat.h"
  57. #include "celleb_pci.h"
  58. #include "interrupt.h"
  59. #include "pervasive.h"
  60. #include "ras.h"
  61. static char celleb_machine_type[128] = "Celleb";
  62. static void celleb_show_cpuinfo(struct seq_file *m)
  63. {
  64. struct device_node *root;
  65. const char *model = "";
  66. root = of_find_node_by_path("/");
  67. if (root)
  68. model = of_get_property(root, "model", NULL);
  69. /* using "CHRP" is to trick anaconda into installing FCx into Celleb */
  70. seq_printf(m, "machine\t\t: %s %s\n", celleb_machine_type, model);
  71. of_node_put(root);
  72. }
  73. static int __init celleb_machine_type_hack(char *ptr)
  74. {
  75. strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
  76. celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
  77. return 0;
  78. }
  79. __setup("celleb_machine_type_hack=", celleb_machine_type_hack);
  80. static void celleb_progress(char *s, unsigned short hex)
  81. {
  82. printk("*** %04x : %s\n", hex, s ? s : "");
  83. }
  84. static void __init celleb_setup_arch_common(void)
  85. {
  86. /* init to some ~sane value until calibrate_delay() runs */
  87. loops_per_jiffy = 50000000;
  88. #ifdef CONFIG_DUMMY_CONSOLE
  89. conswitchp = &dummy_con;
  90. #endif
  91. }
  92. static struct of_device_id celleb_bus_ids[] __initdata = {
  93. { .type = "scc", },
  94. { .type = "ioif", }, /* old style */
  95. {},
  96. };
  97. static int __init celleb_publish_devices(void)
  98. {
  99. /* Publish OF platform devices for southbridge IOs */
  100. of_platform_bus_probe(NULL, celleb_bus_ids, NULL);
  101. return 0;
  102. }
  103. machine_device_initcall(celleb_beat, celleb_publish_devices);
  104. machine_device_initcall(celleb_native, celleb_publish_devices);
  105. /*
  106. * functions for Celleb-Beat
  107. */
  108. static void __init celleb_setup_arch_beat(void)
  109. {
  110. #ifdef CONFIG_SPU_BASE
  111. spu_priv1_ops = &spu_priv1_beat_ops;
  112. spu_management_ops = &spu_management_of_ops;
  113. #endif
  114. #ifdef CONFIG_SMP
  115. smp_init_celleb();
  116. #endif
  117. celleb_setup_arch_common();
  118. }
  119. static int __init celleb_probe_beat(void)
  120. {
  121. unsigned long root = of_get_flat_dt_root();
  122. if (!of_flat_dt_is_compatible(root, "Beat"))
  123. return 0;
  124. powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS
  125. | FW_FEATURE_BEAT | FW_FEATURE_LPAR;
  126. hpte_init_beat_v3();
  127. return 1;
  128. }
  129. /*
  130. * functions for Celleb-native
  131. */
  132. static void __init celleb_init_IRQ_native(void)
  133. {
  134. iic_init_IRQ();
  135. spider_init_IRQ();
  136. }
  137. static void __init celleb_setup_arch_native(void)
  138. {
  139. #ifdef CONFIG_SPU_BASE
  140. spu_priv1_ops = &spu_priv1_mmio_ops;
  141. spu_management_ops = &spu_management_of_ops;
  142. #endif
  143. cbe_regs_init();
  144. #ifdef CONFIG_CBE_RAS
  145. cbe_ras_init();
  146. #endif
  147. #ifdef CONFIG_SMP
  148. smp_init_cell();
  149. #endif
  150. cbe_pervasive_init();
  151. /* XXX: nvram initialization should be added */
  152. celleb_setup_arch_common();
  153. }
  154. static int __init celleb_probe_native(void)
  155. {
  156. unsigned long root = of_get_flat_dt_root();
  157. if (of_flat_dt_is_compatible(root, "Beat") ||
  158. !of_flat_dt_is_compatible(root, "TOSHIBA,Celleb"))
  159. return 0;
  160. powerpc_firmware_features |= FW_FEATURE_CELLEB_ALWAYS;
  161. hpte_init_native();
  162. return 1;
  163. }
  164. /*
  165. * machine definitions
  166. */
  167. define_machine(celleb_beat) {
  168. .name = "Cell Reference Set (Beat)",
  169. .probe = celleb_probe_beat,
  170. .setup_arch = celleb_setup_arch_beat,
  171. .show_cpuinfo = celleb_show_cpuinfo,
  172. .restart = beat_restart,
  173. .power_off = beat_power_off,
  174. .halt = beat_halt,
  175. .get_rtc_time = beat_get_rtc_time,
  176. .set_rtc_time = beat_set_rtc_time,
  177. .calibrate_decr = generic_calibrate_decr,
  178. .progress = celleb_progress,
  179. .power_save = beat_power_save,
  180. .nvram_size = beat_nvram_get_size,
  181. .nvram_read = beat_nvram_read,
  182. .nvram_write = beat_nvram_write,
  183. .set_dabr = beat_set_xdabr,
  184. .init_IRQ = beatic_init_IRQ,
  185. .get_irq = beatic_get_irq,
  186. .pci_probe_mode = celleb_pci_probe_mode,
  187. .pci_setup_phb = celleb_setup_phb,
  188. #ifdef CONFIG_KEXEC
  189. .kexec_cpu_down = beat_kexec_cpu_down,
  190. #endif
  191. };
  192. define_machine(celleb_native) {
  193. .name = "Cell Reference Set (native)",
  194. .probe = celleb_probe_native,
  195. .setup_arch = celleb_setup_arch_native,
  196. .show_cpuinfo = celleb_show_cpuinfo,
  197. .restart = rtas_restart,
  198. .power_off = rtas_power_off,
  199. .halt = rtas_halt,
  200. .get_boot_time = rtas_get_boot_time,
  201. .get_rtc_time = rtas_get_rtc_time,
  202. .set_rtc_time = rtas_set_rtc_time,
  203. .calibrate_decr = generic_calibrate_decr,
  204. .progress = celleb_progress,
  205. .pci_probe_mode = celleb_pci_probe_mode,
  206. .pci_setup_phb = celleb_setup_phb,
  207. .init_IRQ = celleb_init_IRQ_native,
  208. };