addr-map.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * arch/arm/mach-orion5x/addr-map.c
  3. *
  4. * Address map functions for Marvell Orion 5x SoCs
  5. *
  6. * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
  7. *
  8. * This file is licensed under the terms of the GNU General Public
  9. * License version 2. This program is licensed "as is" without any
  10. * warranty of any kind, whether express or implied.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/mbus.h>
  15. #include <linux/io.h>
  16. #include <mach/hardware.h>
  17. #include <plat/addr-map.h>
  18. #include "common.h"
  19. /*
  20. * The Orion has fully programmable address map. There's a separate address
  21. * map for each of the device _master_ interfaces, e.g. CPU, PCI, PCIe, USB,
  22. * Gigabit Ethernet, DMA/XOR engines, etc. Each interface has its own
  23. * address decode windows that allow it to access any of the Orion resources.
  24. *
  25. * CPU address decoding --
  26. * Linux assumes that it is the boot loader that already setup the access to
  27. * DDR and internal registers.
  28. * Setup access to PCI and PCIe IO/MEM space is issued by this file.
  29. * Setup access to various devices located on the device bus interface (e.g.
  30. * flashes, RTC, etc) should be issued by machine-setup.c according to
  31. * specific board population (by using orion5x_setup_*_win()).
  32. *
  33. * Non-CPU Masters address decoding --
  34. * Unlike the CPU, we setup the access from Orion's master interfaces to DDR
  35. * banks only (the typical use case).
  36. * Setup access for each master to DDR is issued by platform device setup.
  37. */
  38. /*
  39. * Generic Address Decode Windows bit settings
  40. */
  41. #define TARGET_DEV_BUS 1
  42. #define TARGET_PCI 3
  43. #define TARGET_PCIE 4
  44. #define TARGET_SRAM 9
  45. #define ATTR_PCIE_MEM 0x59
  46. #define ATTR_PCIE_IO 0x51
  47. #define ATTR_PCIE_WA 0x79
  48. #define ATTR_PCI_MEM 0x59
  49. #define ATTR_PCI_IO 0x51
  50. #define ATTR_DEV_CS0 0x1e
  51. #define ATTR_DEV_CS1 0x1d
  52. #define ATTR_DEV_CS2 0x1b
  53. #define ATTR_DEV_BOOT 0xf
  54. #define ATTR_SRAM 0x0
  55. static int __initdata win_alloc_count;
  56. static int __init cpu_win_can_remap(const struct orion_addr_map_cfg *cfg,
  57. const int win)
  58. {
  59. u32 dev, rev;
  60. orion5x_pcie_id(&dev, &rev);
  61. if ((dev == MV88F5281_DEV_ID && win < 4)
  62. || (dev == MV88F5182_DEV_ID && win < 2)
  63. || (dev == MV88F5181_DEV_ID && win < 2)
  64. || (dev == MV88F6183_DEV_ID && win < 4))
  65. return 1;
  66. return 0;
  67. }
  68. /*
  69. * Description of the windows needed by the platform code
  70. */
  71. static struct __initdata orion_addr_map_cfg addr_map_cfg = {
  72. .num_wins = 8,
  73. .cpu_win_can_remap = cpu_win_can_remap,
  74. .bridge_virt_base = ORION5X_BRIDGE_VIRT_BASE,
  75. };
  76. static const struct __initdata orion_addr_map_info addr_map_info[] = {
  77. /*
  78. * Setup windows for PCI+PCIe IO+MEM space.
  79. */
  80. { 0, ORION5X_PCIE_IO_PHYS_BASE, ORION5X_PCIE_IO_SIZE,
  81. TARGET_PCIE, ATTR_PCIE_IO, ORION5X_PCIE_IO_BUS_BASE
  82. },
  83. { 1, ORION5X_PCI_IO_PHYS_BASE, ORION5X_PCI_IO_SIZE,
  84. TARGET_PCI, ATTR_PCI_IO, ORION5X_PCI_IO_BUS_BASE
  85. },
  86. { 2, ORION5X_PCIE_MEM_PHYS_BASE, ORION5X_PCIE_MEM_SIZE,
  87. TARGET_PCIE, ATTR_PCIE_MEM, -1
  88. },
  89. { 3, ORION5X_PCI_MEM_PHYS_BASE, ORION5X_PCI_MEM_SIZE,
  90. TARGET_PCI, ATTR_PCI_MEM, -1
  91. },
  92. /* End marker */
  93. { -1, 0, 0, 0, 0, 0 }
  94. };
  95. void __init orion5x_setup_cpu_mbus_bridge(void)
  96. {
  97. /*
  98. * Disable, clear and configure windows.
  99. */
  100. orion_config_wins(&addr_map_cfg, addr_map_info);
  101. win_alloc_count = 4;
  102. /*
  103. * Setup MBUS dram target info.
  104. */
  105. orion_setup_cpu_mbus_target(&addr_map_cfg, ORION5X_DDR_WINDOW_CPU_BASE);
  106. }
  107. void __init orion5x_setup_dev_boot_win(u32 base, u32 size)
  108. {
  109. orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
  110. TARGET_DEV_BUS, ATTR_DEV_BOOT, -1);
  111. }
  112. void __init orion5x_setup_dev0_win(u32 base, u32 size)
  113. {
  114. orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
  115. TARGET_DEV_BUS, ATTR_DEV_CS0, -1);
  116. }
  117. void __init orion5x_setup_dev1_win(u32 base, u32 size)
  118. {
  119. orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
  120. TARGET_DEV_BUS, ATTR_DEV_CS1, -1);
  121. }
  122. void __init orion5x_setup_dev2_win(u32 base, u32 size)
  123. {
  124. orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
  125. TARGET_DEV_BUS, ATTR_DEV_CS2, -1);
  126. }
  127. void __init orion5x_setup_pcie_wa_win(u32 base, u32 size)
  128. {
  129. orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++, base, size,
  130. TARGET_PCIE, ATTR_PCIE_WA, -1);
  131. }
  132. void __init orion5x_setup_sram_win(void)
  133. {
  134. orion_setup_cpu_win(&addr_map_cfg, win_alloc_count++,
  135. ORION5X_SRAM_PHYS_BASE, ORION5X_SRAM_SIZE,
  136. TARGET_SRAM, ATTR_SRAM, -1);
  137. }