ep405.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Architecture- / platform-specific boot-time initialization code for
  3. * IBM PowerPC 4xx based boards. Adapted from original
  4. * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
  5. * <dan@net4x.com>.
  6. *
  7. * Copyright(c) 1999-2000 Grant Erickson <grant@lcse.umn.edu>
  8. *
  9. * Rewritten and ported to the merged powerpc tree:
  10. * Copyright 2007 IBM Corporation
  11. * Josh Boyer <jwboyer@linux.vnet.ibm.com>
  12. *
  13. * Adapted to EP405 by Ben. Herrenschmidt <benh@kernel.crashing.org>
  14. *
  15. * TODO: Wire up the PCI IRQ mux and the southbridge interrupts
  16. *
  17. * 2002 (c) MontaVista, Software, Inc. This file is licensed under
  18. * the terms of the GNU General Public License version 2. This program
  19. * is licensed "as is" without any warranty of any kind, whether express
  20. * or implied.
  21. */
  22. #include <linux/init.h>
  23. #include <linux/of_platform.h>
  24. #include <asm/machdep.h>
  25. #include <asm/prom.h>
  26. #include <asm/udbg.h>
  27. #include <asm/time.h>
  28. #include <asm/uic.h>
  29. #include <asm/pci-bridge.h>
  30. static struct device_node *bcsr_node;
  31. static void __iomem *bcsr_regs;
  32. /* BCSR registers */
  33. #define BCSR_ID 0
  34. #define BCSR_PCI_CTRL 1
  35. #define BCSR_FLASH_NV_POR_CTRL 2
  36. #define BCSR_FENET_UART_CTRL 3
  37. #define BCSR_PCI_IRQ 4
  38. #define BCSR_XIRQ_SELECT 5
  39. #define BCSR_XIRQ_ROUTING 6
  40. #define BCSR_XIRQ_STATUS 7
  41. #define BCSR_XIRQ_STATUS2 8
  42. #define BCSR_SW_STAT_LED_CTRL 9
  43. #define BCSR_GPIO_IRQ_PAR_CTRL 10
  44. /* there's more, can't be bothered typing them tho */
  45. static __initdata struct of_device_id ep405_of_bus[] = {
  46. { .compatible = "ibm,plb3", },
  47. { .compatible = "ibm,opb", },
  48. { .compatible = "ibm,ebc", },
  49. {},
  50. };
  51. static int __init ep405_device_probe(void)
  52. {
  53. of_platform_bus_probe(NULL, ep405_of_bus, NULL);
  54. return 0;
  55. }
  56. machine_device_initcall(ep405, ep405_device_probe);
  57. static void __init ep405_init_bcsr(void)
  58. {
  59. const u8 *irq_routing;
  60. int i;
  61. /* Find the bloody thing & map it */
  62. bcsr_node = of_find_compatible_node(NULL, NULL, "ep405-bcsr");
  63. if (bcsr_node == NULL) {
  64. printk(KERN_ERR "EP405 BCSR not found !\n");
  65. return;
  66. }
  67. bcsr_regs = of_iomap(bcsr_node, 0);
  68. if (bcsr_regs == NULL) {
  69. printk(KERN_ERR "EP405 BCSR failed to map !\n");
  70. return;
  71. }
  72. /* Get the irq-routing property and apply the routing to the CPLD */
  73. irq_routing = of_get_property(bcsr_node, "irq-routing", NULL);
  74. if (irq_routing == NULL)
  75. return;
  76. for (i = 0; i < 16; i++) {
  77. u8 irq = irq_routing[i];
  78. out_8(bcsr_regs + BCSR_XIRQ_SELECT, i);
  79. out_8(bcsr_regs + BCSR_XIRQ_ROUTING, irq);
  80. }
  81. in_8(bcsr_regs + BCSR_XIRQ_SELECT);
  82. mb();
  83. out_8(bcsr_regs + BCSR_GPIO_IRQ_PAR_CTRL, 0xfe);
  84. }
  85. static void __init ep405_setup_arch(void)
  86. {
  87. /* Find & init the BCSR CPLD */
  88. ep405_init_bcsr();
  89. ppc_pci_flags = PPC_PCI_REASSIGN_ALL_RSRC;
  90. }
  91. static int __init ep405_probe(void)
  92. {
  93. unsigned long root = of_get_flat_dt_root();
  94. if (!of_flat_dt_is_compatible(root, "ep405"))
  95. return 0;
  96. return 1;
  97. }
  98. define_machine(ep405) {
  99. .name = "EP405",
  100. .probe = ep405_probe,
  101. .setup_arch = ep405_setup_arch,
  102. .progress = udbg_progress,
  103. .init_IRQ = uic_init_tree,
  104. .get_irq = uic_get_irq,
  105. .calibrate_decr = generic_calibrate_decr,
  106. };