currituck.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Currituck board specific routines
  3. *
  4. * Copyright © 2011 Tony Breeds IBM Corporation
  5. *
  6. * Based on earlier code:
  7. * Matt Porter <mporter@kernel.crashing.org>
  8. * Copyright 2002-2005 MontaVista Software Inc.
  9. *
  10. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  11. * Copyright (c) 2003-2005 Zultys Technologies
  12. *
  13. * Rewritten and ported to the merged powerpc tree:
  14. * Copyright 2007 David Gibson <dwg@au1.ibm.com>, IBM Corporation.
  15. * Copyright © 2011 David Kliekamp IBM Corporation
  16. *
  17. * This program is free software; you can redistribute it and/or modify it
  18. * under the terms of the GNU General Public License as published by the
  19. * Free Software Foundation; either version 2 of the License, or (at your
  20. * option) any later version.
  21. */
  22. #include <linux/init.h>
  23. #include <linux/memblock.h>
  24. #include <linux/of.h>
  25. #include <linux/of_platform.h>
  26. #include <linux/rtc.h>
  27. #include <asm/machdep.h>
  28. #include <asm/prom.h>
  29. #include <asm/udbg.h>
  30. #include <asm/time.h>
  31. #include <asm/uic.h>
  32. #include <asm/ppc4xx.h>
  33. #include <asm/mpic.h>
  34. #include <asm/mmu.h>
  35. #include <linux/pci.h>
  36. static __initdata struct of_device_id ppc47x_of_bus[] = {
  37. { .compatible = "ibm,plb4", },
  38. { .compatible = "ibm,plb6", },
  39. { .compatible = "ibm,opb", },
  40. { .compatible = "ibm,ebc", },
  41. {},
  42. };
  43. /* The EEPROM is missing and the default values are bogus. This forces USB in
  44. * to EHCI mode */
  45. static void __devinit quirk_ppc_currituck_usb_fixup(struct pci_dev *dev)
  46. {
  47. if (of_machine_is_compatible("ibm,currituck")) {
  48. pci_write_config_dword(dev, 0xe0, 0x0114231f);
  49. pci_write_config_dword(dev, 0xe4, 0x00006c40);
  50. }
  51. }
  52. DECLARE_PCI_FIXUP_HEADER(0x1033, 0x0035, quirk_ppc_currituck_usb_fixup);
  53. static int __init ppc47x_device_probe(void)
  54. {
  55. of_platform_bus_probe(NULL, ppc47x_of_bus, NULL);
  56. return 0;
  57. }
  58. machine_device_initcall(ppc47x, ppc47x_device_probe);
  59. /* We can have either UICs or MPICs */
  60. static void __init ppc47x_init_irq(void)
  61. {
  62. struct device_node *np;
  63. /* Find top level interrupt controller */
  64. for_each_node_with_property(np, "interrupt-controller") {
  65. if (of_get_property(np, "interrupts", NULL) == NULL)
  66. break;
  67. }
  68. if (np == NULL)
  69. panic("Can't find top level interrupt controller");
  70. /* Check type and do appropriate initialization */
  71. if (of_device_is_compatible(np, "chrp,open-pic")) {
  72. /* The MPIC driver will get everything it needs from the
  73. * device-tree, just pass 0 to all arguments
  74. */
  75. struct mpic *mpic =
  76. mpic_alloc(np, 0, MPIC_NO_RESET, 0, 0, " MPIC ");
  77. BUG_ON(mpic == NULL);
  78. mpic_init(mpic);
  79. ppc_md.get_irq = mpic_get_irq;
  80. } else
  81. panic("Unrecognized top level interrupt controller");
  82. }
  83. #ifdef CONFIG_SMP
  84. static void __cpuinit smp_ppc47x_setup_cpu(int cpu)
  85. {
  86. mpic_setup_this_cpu();
  87. }
  88. static int __cpuinit smp_ppc47x_kick_cpu(int cpu)
  89. {
  90. struct device_node *cpunode = of_get_cpu_node(cpu, NULL);
  91. const u64 *spin_table_addr_prop;
  92. u32 *spin_table;
  93. extern void start_secondary_47x(void);
  94. BUG_ON(cpunode == NULL);
  95. /* Assume spin table. We could test for the enable-method in
  96. * the device-tree but currently there's little point as it's
  97. * our only supported method
  98. */
  99. spin_table_addr_prop =
  100. of_get_property(cpunode, "cpu-release-addr", NULL);
  101. if (spin_table_addr_prop == NULL) {
  102. pr_err("CPU%d: Can't start, missing cpu-release-addr !\n",
  103. cpu);
  104. return 1;
  105. }
  106. /* Assume it's mapped as part of the linear mapping. This is a bit
  107. * fishy but will work fine for now
  108. *
  109. * XXX: Is there any reason to assume differently?
  110. */
  111. spin_table = (u32 *)__va(*spin_table_addr_prop);
  112. pr_debug("CPU%d: Spin table mapped at %p\n", cpu, spin_table);
  113. spin_table[3] = cpu;
  114. smp_wmb();
  115. spin_table[1] = __pa(start_secondary_47x);
  116. mb();
  117. return 0;
  118. }
  119. static struct smp_ops_t ppc47x_smp_ops = {
  120. .probe = smp_mpic_probe,
  121. .message_pass = smp_mpic_message_pass,
  122. .setup_cpu = smp_ppc47x_setup_cpu,
  123. .kick_cpu = smp_ppc47x_kick_cpu,
  124. .give_timebase = smp_generic_give_timebase,
  125. .take_timebase = smp_generic_take_timebase,
  126. };
  127. static void __init ppc47x_smp_init(void)
  128. {
  129. if (mmu_has_feature(MMU_FTR_TYPE_47x))
  130. smp_ops = &ppc47x_smp_ops;
  131. }
  132. #else /* CONFIG_SMP */
  133. static void __init ppc47x_smp_init(void) { }
  134. #endif /* CONFIG_SMP */
  135. static void __init ppc47x_setup_arch(void)
  136. {
  137. /* No need to check the DMA config as we /know/ our windows are all of
  138. * RAM. Lets hope that doesn't change */
  139. #ifdef CONFIG_SWIOTLB
  140. if (memblock_end_of_DRAM() > 0xffffffff) {
  141. ppc_swiotlb_enable = 1;
  142. set_pci_dma_ops(&swiotlb_dma_ops);
  143. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
  144. }
  145. #endif
  146. ppc47x_smp_init();
  147. }
  148. /*
  149. * Called very early, MMU is off, device-tree isn't unflattened
  150. */
  151. static int __init ppc47x_probe(void)
  152. {
  153. unsigned long root = of_get_flat_dt_root();
  154. if (!of_flat_dt_is_compatible(root, "ibm,currituck"))
  155. return 0;
  156. return 1;
  157. }
  158. /* Use USB controller should have been hardware swizzled but it wasn't :( */
  159. static void ppc47x_pci_irq_fixup(struct pci_dev *dev)
  160. {
  161. if (dev->vendor == 0x1033 && (dev->device == 0x0035 ||
  162. dev->device == 0x00e0)) {
  163. dev->irq = irq_create_mapping(NULL, 47);
  164. pr_info("%s: Mapping irq 47 %d\n", __func__, dev->irq);
  165. }
  166. }
  167. define_machine(ppc47x) {
  168. .name = "PowerPC 47x",
  169. .probe = ppc47x_probe,
  170. .progress = udbg_progress,
  171. .init_IRQ = ppc47x_init_irq,
  172. .setup_arch = ppc47x_setup_arch,
  173. .pci_irq_fixup = ppc47x_pci_irq_fixup,
  174. .restart = ppc4xx_reset_system,
  175. .calibrate_decr = generic_calibrate_decr,
  176. };