setup.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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 <linux/of_platform.h>
  33. #include <asm/mmu.h>
  34. #include <asm/processor.h>
  35. #include <asm/io.h>
  36. #include <asm/kexec.h>
  37. #include <asm/pgtable.h>
  38. #include <asm/prom.h>
  39. #include <asm/rtas.h>
  40. #include <asm/pci-bridge.h>
  41. #include <asm/iommu.h>
  42. #include <asm/dma.h>
  43. #include <asm/machdep.h>
  44. #include <asm/time.h>
  45. #include <asm/nvram.h>
  46. #include <asm/cputable.h>
  47. #include <asm/ppc-pci.h>
  48. #include <asm/irq.h>
  49. #include <asm/spu.h>
  50. #include <asm/spu_priv1.h>
  51. #include <asm/udbg.h>
  52. #include <asm/mpic.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. /* Publish OF platform devices for southbridge IOs */
  80. of_platform_bus_probe(NULL, NULL, NULL);
  81. /* There is no device for the MIC memory controller, thus we create
  82. * a platform device for it to attach the EDAC driver to.
  83. */
  84. for_each_online_node(node) {
  85. if (cbe_get_cpu_mic_tm_regs(cbe_node_to_cpu(node)) == NULL)
  86. continue;
  87. platform_device_register_simple("cbe-mic", node, NULL, 0);
  88. }
  89. return 0;
  90. }
  91. machine_subsys_initcall(cell, cell_publish_devices);
  92. static void cell_mpic_cascade(unsigned int irq, struct irq_desc *desc)
  93. {
  94. struct mpic *mpic = desc->handler_data;
  95. unsigned int virq;
  96. virq = mpic_get_one_irq(mpic);
  97. if (virq != NO_IRQ)
  98. generic_handle_irq(virq);
  99. desc->chip->eoi(irq);
  100. }
  101. static void __init mpic_init_IRQ(void)
  102. {
  103. struct device_node *dn;
  104. struct mpic *mpic;
  105. unsigned int virq;
  106. for (dn = NULL;
  107. (dn = of_find_node_by_name(dn, "interrupt-controller"));) {
  108. if (!of_device_is_compatible(dn, "CBEA,platform-open-pic"))
  109. continue;
  110. /* The MPIC driver will get everything it needs from the
  111. * device-tree, just pass 0 to all arguments
  112. */
  113. mpic = mpic_alloc(dn, 0, 0, 0, 0, " MPIC ");
  114. if (mpic == NULL)
  115. continue;
  116. mpic_init(mpic);
  117. virq = irq_of_parse_and_map(dn, 0);
  118. if (virq == NO_IRQ)
  119. continue;
  120. printk(KERN_INFO "%s : hooking up to IRQ %d\n",
  121. dn->full_name, virq);
  122. set_irq_data(virq, mpic);
  123. set_irq_chained_handler(virq, cell_mpic_cascade);
  124. }
  125. }
  126. static void __init cell_init_irq(void)
  127. {
  128. iic_init_IRQ();
  129. spider_init_IRQ();
  130. mpic_init_IRQ();
  131. }
  132. static void __init cell_setup_arch(void)
  133. {
  134. #ifdef CONFIG_SPU_BASE
  135. spu_priv1_ops = &spu_priv1_mmio_ops;
  136. spu_management_ops = &spu_management_of_ops;
  137. #endif
  138. cbe_regs_init();
  139. #ifdef CONFIG_CBE_RAS
  140. cbe_ras_init();
  141. #endif
  142. #ifdef CONFIG_SMP
  143. smp_init_cell();
  144. #endif
  145. /* init to some ~sane value until calibrate_delay() runs */
  146. loops_per_jiffy = 50000000;
  147. /* Find and initialize PCI host bridges */
  148. init_pci_config_tokens();
  149. find_and_init_phbs();
  150. cbe_pervasive_init();
  151. #ifdef CONFIG_DUMMY_CONSOLE
  152. conswitchp = &dummy_con;
  153. #endif
  154. mmio_nvram_init();
  155. }
  156. static int __init cell_probe(void)
  157. {
  158. unsigned long root = of_get_flat_dt_root();
  159. if (!of_flat_dt_is_compatible(root, "IBM,CBEA") &&
  160. !of_flat_dt_is_compatible(root, "IBM,CPBW-1.0"))
  161. return 0;
  162. hpte_init_native();
  163. return 1;
  164. }
  165. define_machine(cell) {
  166. .name = "Cell",
  167. .probe = cell_probe,
  168. .setup_arch = cell_setup_arch,
  169. .show_cpuinfo = cell_show_cpuinfo,
  170. .restart = rtas_restart,
  171. .power_off = rtas_power_off,
  172. .halt = rtas_halt,
  173. .get_boot_time = rtas_get_boot_time,
  174. .get_rtc_time = rtas_get_rtc_time,
  175. .set_rtc_time = rtas_set_rtc_time,
  176. .calibrate_decr = generic_calibrate_decr,
  177. .progress = cell_progress,
  178. .init_IRQ = cell_init_irq,
  179. .pci_setup_phb = rtas_setup_phb,
  180. #ifdef CONFIG_KEXEC
  181. .machine_kexec = default_machine_kexec,
  182. .machine_kexec_prepare = default_machine_kexec_prepare,
  183. .machine_crash_shutdown = default_machine_crash_shutdown,
  184. #endif
  185. };