p1022_ds.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /*
  2. * P1022DS board specific routines
  3. *
  4. * Authors: Travis Wheatley <travis.wheatley@freescale.com>
  5. * Dave Liu <daveliu@freescale.com>
  6. * Timur Tabi <timur@freescale.com>
  7. *
  8. * Copyright 2010 Freescale Semiconductor, Inc.
  9. *
  10. * This file is taken from the Freescale P1022DS BSP, with modifications:
  11. * 1) No DIU support (pending rewrite of DIU code)
  12. * 2) No AMP support
  13. * 3) No PCI endpoint support
  14. *
  15. * This file is licensed under the terms of the GNU General Public License
  16. * version 2. This program is licensed "as is" without any warranty of any
  17. * kind, whether express or implied.
  18. */
  19. #include <linux/pci.h>
  20. #include <linux/of_platform.h>
  21. #include <linux/memblock.h>
  22. #include <asm/mpic.h>
  23. #include <asm/swiotlb.h>
  24. #include <sysdev/fsl_soc.h>
  25. #include <sysdev/fsl_pci.h>
  26. void __init p1022_ds_pic_init(void)
  27. {
  28. struct mpic *mpic;
  29. struct resource r;
  30. struct device_node *np;
  31. np = of_find_node_by_type(NULL, "open-pic");
  32. if (!np) {
  33. pr_err("Could not find open-pic node\n");
  34. return;
  35. }
  36. if (of_address_to_resource(np, 0, &r)) {
  37. pr_err("Failed to map mpic register space\n");
  38. of_node_put(np);
  39. return;
  40. }
  41. mpic = mpic_alloc(np, r.start,
  42. MPIC_PRIMARY | MPIC_WANTS_RESET |
  43. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS |
  44. MPIC_SINGLE_DEST_CPU,
  45. 0, 256, " OpenPIC ");
  46. BUG_ON(mpic == NULL);
  47. of_node_put(np);
  48. mpic_init(mpic);
  49. }
  50. #ifdef CONFIG_SMP
  51. void __init mpc85xx_smp_init(void);
  52. #endif
  53. /*
  54. * Setup the architecture
  55. */
  56. static void __init p1022_ds_setup_arch(void)
  57. {
  58. #ifdef CONFIG_PCI
  59. struct device_node *np;
  60. #endif
  61. dma_addr_t max = 0xffffffff;
  62. if (ppc_md.progress)
  63. ppc_md.progress("p1022_ds_setup_arch()", 0);
  64. #ifdef CONFIG_PCI
  65. for_each_compatible_node(np, "pci", "fsl,p1022-pcie") {
  66. struct resource rsrc;
  67. struct pci_controller *hose;
  68. of_address_to_resource(np, 0, &rsrc);
  69. if ((rsrc.start & 0xfffff) == 0x8000)
  70. fsl_add_bridge(np, 1);
  71. else
  72. fsl_add_bridge(np, 0);
  73. hose = pci_find_hose_for_OF_device(np);
  74. max = min(max, hose->dma_window_base_cur +
  75. hose->dma_window_size);
  76. }
  77. #endif
  78. #ifdef CONFIG_SMP
  79. mpc85xx_smp_init();
  80. #endif
  81. #ifdef CONFIG_SWIOTLB
  82. if (memblock_end_of_DRAM() > max) {
  83. ppc_swiotlb_enable = 1;
  84. set_pci_dma_ops(&swiotlb_dma_ops);
  85. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
  86. }
  87. #endif
  88. pr_info("Freescale P1022 DS reference board\n");
  89. }
  90. static struct of_device_id __initdata p1022_ds_ids[] = {
  91. { .type = "soc", },
  92. { .compatible = "soc", },
  93. { .compatible = "simple-bus", },
  94. { .compatible = "gianfar", },
  95. {},
  96. };
  97. static int __init p1022_ds_publish_devices(void)
  98. {
  99. return of_platform_bus_probe(NULL, p1022_ds_ids, NULL);
  100. }
  101. machine_device_initcall(p1022_ds, p1022_ds_publish_devices);
  102. machine_arch_initcall(p1022_ds, swiotlb_setup_bus_notifier);
  103. /*
  104. * Called very early, device-tree isn't unflattened
  105. */
  106. static int __init p1022_ds_probe(void)
  107. {
  108. unsigned long root = of_get_flat_dt_root();
  109. return of_flat_dt_is_compatible(root, "fsl,p1022ds");
  110. }
  111. define_machine(p1022_ds) {
  112. .name = "P1022 DS",
  113. .probe = p1022_ds_probe,
  114. .setup_arch = p1022_ds_setup_arch,
  115. .init_IRQ = p1022_ds_pic_init,
  116. #ifdef CONFIG_PCI
  117. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  118. #endif
  119. .get_irq = mpic_get_irq,
  120. .restart = fsl_rstcr_restart,
  121. .calibrate_decr = generic_calibrate_decr,
  122. .progress = udbg_progress,
  123. };