setup.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * linux/arch/powerpc/platforms/cell/cell_setup.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Adapted from 'alpha' version by Gary Thomas
  6. * Modified by Cort Dougan (cort@cs.nmt.edu)
  7. * Modified by PPC64 Team, IBM Corp
  8. * Modified by Cell Team, IBM Deutschland Entwicklung GmbH
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version
  13. * 2 of the License, or (at your option) any later version.
  14. */
  15. #undef DEBUG
  16. #include <linux/sched.h>
  17. #include <linux/kernel.h>
  18. #include <linux/mm.h>
  19. #include <linux/stddef.h>
  20. #include <linux/unistd.h>
  21. #include <linux/slab.h>
  22. #include <linux/user.h>
  23. #include <linux/reboot.h>
  24. #include <linux/init.h>
  25. #include <linux/delay.h>
  26. #include <linux/irq.h>
  27. #include <linux/seq_file.h>
  28. #include <linux/root_dev.h>
  29. #include <linux/console.h>
  30. #include <linux/mutex.h>
  31. #include <linux/memory_hotplug.h>
  32. #include <asm/mmu.h>
  33. #include <asm/processor.h>
  34. #include <asm/io.h>
  35. #include <asm/kexec.h>
  36. #include <asm/pgtable.h>
  37. #include <asm/prom.h>
  38. #include <asm/rtas.h>
  39. #include <asm/pci-bridge.h>
  40. #include <asm/iommu.h>
  41. #include <asm/dma.h>
  42. #include <asm/machdep.h>
  43. #include <asm/time.h>
  44. #include <asm/nvram.h>
  45. #include <asm/cputable.h>
  46. #include <asm/ppc-pci.h>
  47. #include <asm/irq.h>
  48. #include <asm/spu.h>
  49. #include <asm/spu_priv1.h>
  50. #include <asm/udbg.h>
  51. #include <asm/mpic.h>
  52. #include <asm/of_platform.h>
  53. #include <asm/cell-regs.h>
  54. #include "interrupt.h"
  55. #include "pervasive.h"
  56. #include "ras.h"
  57. #ifdef DEBUG
  58. #define DBG(fmt...) udbg_printf(fmt)
  59. #else
  60. #define DBG(fmt...)
  61. #endif
  62. static void cell_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. seq_printf(m, "machine\t\t: CHRP %s\n", model);
  70. of_node_put(root);
  71. }
  72. static void cell_progress(char *s, unsigned short hex)
  73. {
  74. printk("*** %04x : %s\n", hex, s ? s : "");
  75. }
  76. static int __init cell_publish_devices(void)
  77. {
  78. int node;
  79. if (!machine_is(cell))
  80. return 0;
  81. /* Publish OF platform devices for southbridge IOs */
  82. of_platform_bus_probe(NULL, NULL, NULL);
  83. /* There is no device for the MIC memory controller, thus we create
  84. * a platform device for it to attach the EDAC driver to.
  85. */
  86. for_each_online_node(node) {
  87. if (cbe_get_cpu_mic_tm_regs(cbe_node_to_cpu(node)) == NULL)
  88. continue;
  89. platform_device_register_simple("cbe-mic", node, NULL, 0);
  90. }
  91. return 0;
  92. }
  93. device_initcall(cell_publish_devices);
  94. static void cell_mpic_cascade(unsigned int irq, struct irq_desc *desc)
  95. {
  96. struct mpic *mpic = desc->handler_data;
  97. unsigned int virq;
  98. virq = mpic_get_one_irq(mpic);
  99. if (virq != NO_IRQ)
  100. generic_handle_irq(virq);
  101. desc->chip->eoi(irq);
  102. }
  103. static void __init mpic_init_IRQ(void)
  104. {
  105. struct device_node *dn;
  106. struct mpic *mpic;
  107. unsigned int virq;
  108. for (dn = NULL;
  109. (dn = of_find_node_by_name(dn, "interrupt-controller"));) {
  110. if (!of_device_is_compatible(dn, "CBEA,platform-open-pic"))
  111. continue;
  112. /* The MPIC driver will get everything it needs from the
  113. * device-tree, just pass 0 to all arguments
  114. */
  115. mpic = mpic_alloc(dn, 0, 0, 0, 0, " MPIC ");
  116. if (mpic == NULL)
  117. continue;
  118. mpic_init(mpic);
  119. virq = irq_of_parse_and_map(dn, 0);
  120. if (virq == NO_IRQ)
  121. continue;
  122. printk(KERN_INFO "%s : hooking up to IRQ %d\n",
  123. dn->full_name, virq);
  124. set_irq_data(virq, mpic);
  125. set_irq_chained_handler(virq, cell_mpic_cascade);
  126. }
  127. }
  128. static void __init cell_init_irq(void)
  129. {
  130. iic_init_IRQ();
  131. spider_init_IRQ();
  132. mpic_init_IRQ();
  133. }
  134. static void __init cell_setup_arch(void)
  135. {
  136. #ifdef CONFIG_SPU_BASE
  137. spu_priv1_ops = &spu_priv1_mmio_ops;
  138. spu_management_ops = &spu_management_of_ops;
  139. #endif
  140. cbe_regs_init();
  141. #ifdef CONFIG_CBE_RAS
  142. cbe_ras_init();
  143. #endif
  144. #ifdef CONFIG_SMP
  145. smp_init_cell();
  146. #endif
  147. /* init to some ~sane value until calibrate_delay() runs */
  148. loops_per_jiffy = 50000000;
  149. /* Find and initialize PCI host bridges */
  150. init_pci_config_tokens();
  151. find_and_init_phbs();
  152. cbe_pervasive_init();
  153. #ifdef CONFIG_DUMMY_CONSOLE
  154. conswitchp = &dummy_con;
  155. #endif
  156. mmio_nvram_init();
  157. }
  158. static int __init cell_probe(void)
  159. {
  160. unsigned long root = of_get_flat_dt_root();
  161. if (!of_flat_dt_is_compatible(root, "IBM,CBEA") &&
  162. !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
  163. return 0;
  164. hpte_init_native();
  165. return 1;
  166. }
  167. define_machine(cell) {
  168. .name = "Cell",
  169. .probe = cell_probe,
  170. .setup_arch = cell_setup_arch,
  171. .show_cpuinfo = cell_show_cpuinfo,
  172. .restart = rtas_restart,
  173. .power_off = rtas_power_off,
  174. .halt = rtas_halt,
  175. .get_boot_time = rtas_get_boot_time,
  176. .get_rtc_time = rtas_get_rtc_time,
  177. .set_rtc_time = rtas_set_rtc_time,
  178. .calibrate_decr = generic_calibrate_decr,
  179. .progress = cell_progress,
  180. .init_IRQ = cell_init_irq,
  181. .pci_setup_phb = rtas_setup_phb,
  182. #ifdef CONFIG_KEXEC
  183. .machine_kexec = default_machine_kexec,
  184. .machine_kexec_prepare = default_machine_kexec_prepare,
  185. .machine_crash_shutdown = default_machine_crash_shutdown,
  186. #endif
  187. };