mpc8536_ds.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * MPC8536 DS Board Setup
  3. *
  4. * Copyright 2008 Freescale Semiconductor, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #include <linux/stddef.h>
  12. #include <linux/kernel.h>
  13. #include <linux/pci.h>
  14. #include <linux/kdev_t.h>
  15. #include <linux/delay.h>
  16. #include <linux/seq_file.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/of_platform.h>
  19. #include <linux/memblock.h>
  20. #include <asm/system.h>
  21. #include <asm/time.h>
  22. #include <asm/machdep.h>
  23. #include <asm/pci-bridge.h>
  24. #include <mm/mmu_decl.h>
  25. #include <asm/prom.h>
  26. #include <asm/udbg.h>
  27. #include <asm/mpic.h>
  28. #include <asm/swiotlb.h>
  29. #include <sysdev/fsl_soc.h>
  30. #include <sysdev/fsl_pci.h>
  31. #include "mpc85xx.h"
  32. void __init mpc8536_ds_pic_init(void)
  33. {
  34. struct mpic *mpic = mpic_alloc(NULL, 0,
  35. MPIC_WANTS_RESET |
  36. MPIC_BIG_ENDIAN | MPIC_BROKEN_FRR_NIRQS,
  37. 0, 256, " OpenPIC ");
  38. BUG_ON(mpic == NULL);
  39. mpic_init(mpic);
  40. }
  41. /*
  42. * Setup the architecture
  43. */
  44. static void __init mpc8536_ds_setup_arch(void)
  45. {
  46. #ifdef CONFIG_PCI
  47. struct device_node *np;
  48. struct pci_controller *hose;
  49. #endif
  50. dma_addr_t max = 0xffffffff;
  51. if (ppc_md.progress)
  52. ppc_md.progress("mpc8536_ds_setup_arch()", 0);
  53. #ifdef CONFIG_PCI
  54. for_each_node_by_type(np, "pci") {
  55. if (of_device_is_compatible(np, "fsl,mpc8540-pci") ||
  56. of_device_is_compatible(np, "fsl,mpc8548-pcie")) {
  57. struct resource rsrc;
  58. of_address_to_resource(np, 0, &rsrc);
  59. if ((rsrc.start & 0xfffff) == 0x8000)
  60. fsl_add_bridge(np, 1);
  61. else
  62. fsl_add_bridge(np, 0);
  63. hose = pci_find_hose_for_OF_device(np);
  64. max = min(max, hose->dma_window_base_cur +
  65. hose->dma_window_size);
  66. }
  67. }
  68. #endif
  69. #ifdef CONFIG_SWIOTLB
  70. if (memblock_end_of_DRAM() > max) {
  71. ppc_swiotlb_enable = 1;
  72. set_pci_dma_ops(&swiotlb_dma_ops);
  73. ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
  74. }
  75. #endif
  76. printk("MPC8536 DS board from Freescale Semiconductor\n");
  77. }
  78. machine_device_initcall(mpc8536_ds, mpc85xx_common_publish_devices);
  79. machine_arch_initcall(mpc8536_ds, swiotlb_setup_bus_notifier);
  80. /*
  81. * Called very early, device-tree isn't unflattened
  82. */
  83. static int __init mpc8536_ds_probe(void)
  84. {
  85. unsigned long root = of_get_flat_dt_root();
  86. return of_flat_dt_is_compatible(root, "fsl,mpc8536ds");
  87. }
  88. define_machine(mpc8536_ds) {
  89. .name = "MPC8536 DS",
  90. .probe = mpc8536_ds_probe,
  91. .setup_arch = mpc8536_ds_setup_arch,
  92. .init_IRQ = mpc8536_ds_pic_init,
  93. #ifdef CONFIG_PCI
  94. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  95. #endif
  96. .get_irq = mpic_get_irq,
  97. .restart = fsl_rstcr_restart,
  98. .calibrate_decr = generic_calibrate_decr,
  99. .progress = udbg_progress,
  100. };