ep405.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. #include <asm/ppc4xx.h>
  31. static struct device_node *bcsr_node;
  32. static void __iomem *bcsr_regs;
  33. /* BCSR registers */
  34. #define BCSR_ID 0
  35. #define BCSR_PCI_CTRL 1
  36. #define BCSR_FLASH_NV_POR_CTRL 2
  37. #define BCSR_FENET_UART_CTRL 3
  38. #define BCSR_PCI_IRQ 4
  39. #define BCSR_XIRQ_SELECT 5
  40. #define BCSR_XIRQ_ROUTING 6
  41. #define BCSR_XIRQ_STATUS 7
  42. #define BCSR_XIRQ_STATUS2 8
  43. #define BCSR_SW_STAT_LED_CTRL 9
  44. #define BCSR_GPIO_IRQ_PAR_CTRL 10
  45. /* there's more, can't be bothered typing them tho */
  46. static const struct of_device_id ep405_of_bus[] __initconst = {
  47. { .compatible = "ibm,plb3", },
  48. { .compatible = "ibm,opb", },
  49. { .compatible = "ibm,ebc", },
  50. {},
  51. };
  52. static int __init ep405_device_probe(void)
  53. {
  54. of_platform_bus_probe(NULL, ep405_of_bus, NULL);
  55. return 0;
  56. }
  57. machine_device_initcall(ep405, ep405_device_probe);
  58. static void __init ep405_init_bcsr(void)
  59. {
  60. const u8 *irq_routing;
  61. int i;
  62. /* Find the bloody thing & map it */
  63. bcsr_node = of_find_compatible_node(NULL, NULL, "ep405-bcsr");
  64. if (bcsr_node == NULL) {
  65. printk(KERN_ERR "EP405 BCSR not found !\n");
  66. return;
  67. }
  68. bcsr_regs = of_iomap(bcsr_node, 0);
  69. if (bcsr_regs == NULL) {
  70. printk(KERN_ERR "EP405 BCSR failed to map !\n");
  71. return;
  72. }
  73. /* Get the irq-routing property and apply the routing to the CPLD */
  74. irq_routing = of_get_property(bcsr_node, "irq-routing", NULL);
  75. if (irq_routing == NULL)
  76. return;
  77. for (i = 0; i < 16; i++) {
  78. u8 irq = irq_routing[i];
  79. out_8(bcsr_regs + BCSR_XIRQ_SELECT, i);
  80. out_8(bcsr_regs + BCSR_XIRQ_ROUTING, irq);
  81. }
  82. in_8(bcsr_regs + BCSR_XIRQ_SELECT);
  83. mb();
  84. out_8(bcsr_regs + BCSR_GPIO_IRQ_PAR_CTRL, 0xfe);
  85. }
  86. static void __init ep405_setup_arch(void)
  87. {
  88. /* Find & init the BCSR CPLD */
  89. ep405_init_bcsr();
  90. pci_set_flags(PCI_REASSIGN_ALL_RSRC);
  91. }
  92. static int __init ep405_probe(void)
  93. {
  94. unsigned long root = of_get_flat_dt_root();
  95. if (!of_flat_dt_is_compatible(root, "ep405"))
  96. return 0;
  97. return 1;
  98. }
  99. define_machine(ep405) {
  100. .name = "EP405",
  101. .probe = ep405_probe,
  102. .setup_arch = ep405_setup_arch,
  103. .progress = udbg_progress,
  104. .init_IRQ = uic_init_tree,
  105. .get_irq = uic_get_irq,
  106. .restart = ppc4xx_reset_system,
  107. .calibrate_decr = generic_calibrate_decr,
  108. };