currituck.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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/of.h>
  24. #include <linux/of_platform.h>
  25. #include <linux/rtc.h>
  26. #include <asm/machdep.h>
  27. #include <asm/prom.h>
  28. #include <asm/udbg.h>
  29. #include <asm/time.h>
  30. #include <asm/uic.h>
  31. #include <asm/ppc4xx.h>
  32. #include <asm/mpic.h>
  33. #include <asm/mmu.h>
  34. #include <linux/pci.h>
  35. static __initdata struct of_device_id ppc47x_of_bus[] = {
  36. { .compatible = "ibm,plb4", },
  37. { .compatible = "ibm,plb6", },
  38. { .compatible = "ibm,opb", },
  39. { .compatible = "ibm,ebc", },
  40. {},
  41. };
  42. /* The EEPROM is missing and the default values are bogus. This forces USB in
  43. * to EHCI mode */
  44. static void quirk_ppc_currituck_usb_fixup(struct pci_dev *dev)
  45. {
  46. if (of_machine_is_compatible("ibm,currituck")) {
  47. pci_write_config_dword(dev, 0xe0, 0x0114231f);
  48. pci_write_config_dword(dev, 0xe4, 0x00006c40);
  49. }
  50. }
  51. DECLARE_PCI_FIXUP_HEADER(0x1033, 0x0035, quirk_ppc_currituck_usb_fixup);
  52. static int __init ppc47x_device_probe(void)
  53. {
  54. of_platform_bus_probe(NULL, ppc47x_of_bus, NULL);
  55. return 0;
  56. }
  57. machine_device_initcall(ppc47x, ppc47x_device_probe);
  58. /* We can have either UICs or MPICs */
  59. static void __init ppc47x_init_irq(void)
  60. {
  61. struct device_node *np;
  62. /* Find top level interrupt controller */
  63. for_each_node_with_property(np, "interrupt-controller") {
  64. if (of_get_property(np, "interrupts", NULL) == NULL)
  65. break;
  66. }
  67. if (np == NULL)
  68. panic("Can't find top level interrupt controller");
  69. /* Check type and do appropriate initialization */
  70. if (of_device_is_compatible(np, "chrp,open-pic")) {
  71. /* The MPIC driver will get everything it needs from the
  72. * device-tree, just pass 0 to all arguments
  73. */
  74. struct mpic *mpic =
  75. mpic_alloc(np, 0, MPIC_NO_RESET, 0, 0, " MPIC ");
  76. BUG_ON(mpic == NULL);
  77. mpic_init(mpic);
  78. ppc_md.get_irq = mpic_get_irq;
  79. } else
  80. panic("Unrecognized top level interrupt controller");
  81. }
  82. #ifdef CONFIG_SMP
  83. static void __cpuinit smp_ppc47x_setup_cpu(int cpu)
  84. {
  85. mpic_setup_this_cpu();
  86. }
  87. static int __cpuinit smp_ppc47x_kick_cpu(int cpu)
  88. {
  89. struct device_node *cpunode = of_get_cpu_node(cpu, NULL);
  90. const u64 *spin_table_addr_prop;
  91. u32 *spin_table;
  92. extern void start_secondary_47x(void);
  93. BUG_ON(cpunode == NULL);
  94. /* Assume spin table. We could test for the enable-method in
  95. * the device-tree but currently there's little point as it's
  96. * our only supported method
  97. */
  98. spin_table_addr_prop =
  99. of_get_property(cpunode, "cpu-release-addr", NULL);
  100. if (spin_table_addr_prop == NULL) {
  101. pr_err("CPU%d: Can't start, missing cpu-release-addr !\n",
  102. cpu);
  103. return 1;
  104. }
  105. /* Assume it's mapped as part of the linear mapping. This is a bit
  106. * fishy but will work fine for now
  107. *
  108. * XXX: Is there any reason to assume differently?
  109. */
  110. spin_table = (u32 *)__va(*spin_table_addr_prop);
  111. pr_debug("CPU%d: Spin table mapped at %p\n", cpu, spin_table);
  112. spin_table[3] = cpu;
  113. smp_wmb();
  114. spin_table[1] = __pa(start_secondary_47x);
  115. mb();
  116. return 0;
  117. }
  118. static struct smp_ops_t ppc47x_smp_ops = {
  119. .probe = smp_mpic_probe,
  120. .message_pass = smp_mpic_message_pass,
  121. .setup_cpu = smp_ppc47x_setup_cpu,
  122. .kick_cpu = smp_ppc47x_kick_cpu,
  123. .give_timebase = smp_generic_give_timebase,
  124. .take_timebase = smp_generic_take_timebase,
  125. };
  126. static void __init ppc47x_smp_init(void)
  127. {
  128. if (mmu_has_feature(MMU_FTR_TYPE_47x))
  129. smp_ops = &ppc47x_smp_ops;
  130. }
  131. #else /* CONFIG_SMP */
  132. static void __init ppc47x_smp_init(void) { }
  133. #endif /* CONFIG_SMP */
  134. static void __init ppc47x_setup_arch(void)
  135. {
  136. /* No need to check the DMA config as we /know/ our windows are all of
  137. * RAM. Lets hope that doesn't change */
  138. swiotlb_detect_4g();
  139. ppc47x_smp_init();
  140. }
  141. /*
  142. * Called very early, MMU is off, device-tree isn't unflattened
  143. */
  144. static int __init ppc47x_probe(void)
  145. {
  146. unsigned long root = of_get_flat_dt_root();
  147. if (!of_flat_dt_is_compatible(root, "ibm,currituck"))
  148. return 0;
  149. return 1;
  150. }
  151. /* Use USB controller should have been hardware swizzled but it wasn't :( */
  152. static void ppc47x_pci_irq_fixup(struct pci_dev *dev)
  153. {
  154. if (dev->vendor == 0x1033 && (dev->device == 0x0035 ||
  155. dev->device == 0x00e0)) {
  156. dev->irq = irq_create_mapping(NULL, 47);
  157. pr_info("%s: Mapping irq 47 %d\n", __func__, dev->irq);
  158. }
  159. }
  160. define_machine(ppc47x) {
  161. .name = "PowerPC 47x",
  162. .probe = ppc47x_probe,
  163. .progress = udbg_progress,
  164. .init_IRQ = ppc47x_init_irq,
  165. .setup_arch = ppc47x_setup_arch,
  166. .pci_irq_fixup = ppc47x_pci_irq_fixup,
  167. .restart = ppc4xx_reset_system,
  168. .calibrate_decr = generic_calibrate_decr,
  169. };