setup.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * linux/arch/powerpc/platforms/cell/cell_setup.c
  4. *
  5. * Copyright (C) 1995 Linus Torvalds
  6. * Adapted from 'alpha' version by Gary Thomas
  7. * Modified by Cort Dougan ([email protected])
  8. * Modified by PPC64 Team, IBM Corp
  9. * Modified by Cell Team, IBM Deutschland Entwicklung GmbH
  10. */
  11. #undef DEBUG
  12. #include <linux/sched.h>
  13. #include <linux/kernel.h>
  14. #include <linux/mm.h>
  15. #include <linux/stddef.h>
  16. #include <linux/export.h>
  17. #include <linux/unistd.h>
  18. #include <linux/user.h>
  19. #include <linux/reboot.h>
  20. #include <linux/init.h>
  21. #include <linux/delay.h>
  22. #include <linux/irq.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/root_dev.h>
  25. #include <linux/console.h>
  26. #include <linux/mutex.h>
  27. #include <linux/memory_hotplug.h>
  28. #include <linux/of_platform.h>
  29. #include <asm/mmu.h>
  30. #include <asm/processor.h>
  31. #include <asm/io.h>
  32. #include <asm/rtas.h>
  33. #include <asm/pci-bridge.h>
  34. #include <asm/iommu.h>
  35. #include <asm/dma.h>
  36. #include <asm/machdep.h>
  37. #include <asm/time.h>
  38. #include <asm/nvram.h>
  39. #include <asm/cputable.h>
  40. #include <asm/ppc-pci.h>
  41. #include <asm/irq.h>
  42. #include <asm/spu.h>
  43. #include <asm/spu_priv1.h>
  44. #include <asm/udbg.h>
  45. #include <asm/mpic.h>
  46. #include <asm/cell-regs.h>
  47. #include <asm/io-workarounds.h>
  48. #include "cell.h"
  49. #include "interrupt.h"
  50. #include "pervasive.h"
  51. #include "ras.h"
  52. #ifdef DEBUG
  53. #define DBG(fmt...) udbg_printf(fmt)
  54. #else
  55. #define DBG(fmt...)
  56. #endif
  57. static void cell_show_cpuinfo(struct seq_file *m)
  58. {
  59. struct device_node *root;
  60. const char *model = "";
  61. root = of_find_node_by_path("/");
  62. if (root)
  63. model = of_get_property(root, "model", NULL);
  64. seq_printf(m, "machine\t\t: CHRP %s\n", model);
  65. of_node_put(root);
  66. }
  67. static void cell_progress(char *s, unsigned short hex)
  68. {
  69. printk("*** %04x : %s\n", hex, s ? s : "");
  70. }
  71. static void cell_fixup_pcie_rootcomplex(struct pci_dev *dev)
  72. {
  73. struct pci_controller *hose;
  74. const char *s;
  75. int i;
  76. if (!machine_is(cell))
  77. return;
  78. /* We're searching for a direct child of the PHB */
  79. if (dev->bus->self != NULL || dev->devfn != 0)
  80. return;
  81. hose = pci_bus_to_host(dev->bus);
  82. if (hose == NULL)
  83. return;
  84. /* Only on PCIE */
  85. if (!of_device_is_compatible(hose->dn, "pciex"))
  86. return;
  87. /* And only on axon */
  88. s = of_get_property(hose->dn, "model", NULL);
  89. if (!s || strcmp(s, "Axon") != 0)
  90. return;
  91. for (i = 0; i < PCI_BRIDGE_RESOURCES; i++) {
  92. dev->resource[i].start = dev->resource[i].end = 0;
  93. dev->resource[i].flags = 0;
  94. }
  95. printk(KERN_DEBUG "PCI: Hiding resources on Axon PCIE RC %s\n",
  96. pci_name(dev));
  97. }
  98. DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, cell_fixup_pcie_rootcomplex);
  99. static int cell_setup_phb(struct pci_controller *phb)
  100. {
  101. const char *model;
  102. struct device_node *np;
  103. int rc = rtas_setup_phb(phb);
  104. if (rc)
  105. return rc;
  106. phb->controller_ops = cell_pci_controller_ops;
  107. np = phb->dn;
  108. model = of_get_property(np, "model", NULL);
  109. if (model == NULL || !of_node_name_eq(np, "pci"))
  110. return 0;
  111. /* Setup workarounds for spider */
  112. if (strcmp(model, "Spider"))
  113. return 0;
  114. iowa_register_bus(phb, &spiderpci_ops, &spiderpci_iowa_init,
  115. (void *)SPIDER_PCI_REG_BASE);
  116. return 0;
  117. }
  118. static const struct of_device_id cell_bus_ids[] __initconst = {
  119. { .type = "soc", },
  120. { .compatible = "soc", },
  121. { .type = "spider", },
  122. { .type = "axon", },
  123. { .type = "plb5", },
  124. { .type = "plb4", },
  125. { .type = "opb", },
  126. { .type = "ebc", },
  127. {},
  128. };
  129. static int __init cell_publish_devices(void)
  130. {
  131. struct device_node *root = of_find_node_by_path("/");
  132. struct device_node *np;
  133. int node;
  134. /* Publish OF platform devices for southbridge IOs */
  135. of_platform_bus_probe(NULL, cell_bus_ids, NULL);
  136. /* On spider based blades, we need to manually create the OF
  137. * platform devices for the PCI host bridges
  138. */
  139. for_each_child_of_node(root, np) {
  140. if (!of_node_is_type(np, "pci") && !of_node_is_type(np, "pciex"))
  141. continue;
  142. of_platform_device_create(np, NULL, NULL);
  143. }
  144. of_node_put(root);
  145. /* There is no device for the MIC memory controller, thus we create
  146. * a platform device for it to attach the EDAC driver to.
  147. */
  148. for_each_online_node(node) {
  149. if (cbe_get_cpu_mic_tm_regs(cbe_node_to_cpu(node)) == NULL)
  150. continue;
  151. platform_device_register_simple("cbe-mic", node, NULL, 0);
  152. }
  153. return 0;
  154. }
  155. machine_subsys_initcall(cell, cell_publish_devices);
  156. static void __init mpic_init_IRQ(void)
  157. {
  158. struct device_node *dn;
  159. struct mpic *mpic;
  160. for_each_node_by_name(dn, "interrupt-controller") {
  161. if (!of_device_is_compatible(dn, "CBEA,platform-open-pic"))
  162. continue;
  163. /* The MPIC driver will get everything it needs from the
  164. * device-tree, just pass 0 to all arguments
  165. */
  166. mpic = mpic_alloc(dn, 0, MPIC_SECONDARY | MPIC_NO_RESET,
  167. 0, 0, " MPIC ");
  168. if (mpic == NULL)
  169. continue;
  170. mpic_init(mpic);
  171. }
  172. }
  173. static void __init cell_init_irq(void)
  174. {
  175. iic_init_IRQ();
  176. spider_init_IRQ();
  177. mpic_init_IRQ();
  178. }
  179. static void __init cell_set_dabrx(void)
  180. {
  181. mtspr(SPRN_DABRX, DABRX_KERNEL | DABRX_USER);
  182. }
  183. static void __init cell_setup_arch(void)
  184. {
  185. #ifdef CONFIG_SPU_BASE
  186. spu_priv1_ops = &spu_priv1_mmio_ops;
  187. spu_management_ops = &spu_management_of_ops;
  188. #endif
  189. cbe_regs_init();
  190. cell_set_dabrx();
  191. #ifdef CONFIG_CBE_RAS
  192. cbe_ras_init();
  193. #endif
  194. #ifdef CONFIG_SMP
  195. smp_init_cell();
  196. #endif
  197. /* init to some ~sane value until calibrate_delay() runs */
  198. loops_per_jiffy = 50000000;
  199. /* Find and initialize PCI host bridges */
  200. init_pci_config_tokens();
  201. cbe_pervasive_init();
  202. mmio_nvram_init();
  203. }
  204. static int __init cell_probe(void)
  205. {
  206. if (!of_machine_is_compatible("IBM,CBEA") &&
  207. !of_machine_is_compatible("IBM,CPBW-1.0"))
  208. return 0;
  209. pm_power_off = rtas_power_off;
  210. return 1;
  211. }
  212. define_machine(cell) {
  213. .name = "Cell",
  214. .probe = cell_probe,
  215. .setup_arch = cell_setup_arch,
  216. .show_cpuinfo = cell_show_cpuinfo,
  217. .restart = rtas_restart,
  218. .halt = rtas_halt,
  219. .get_boot_time = rtas_get_boot_time,
  220. .get_rtc_time = rtas_get_rtc_time,
  221. .set_rtc_time = rtas_set_rtc_time,
  222. .calibrate_decr = generic_calibrate_decr,
  223. .progress = cell_progress,
  224. .init_IRQ = cell_init_irq,
  225. .pci_setup_phb = cell_setup_phb,
  226. };
  227. struct pci_controller_ops cell_pci_controller_ops;