addr-map.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * arch/arm/mach-dove/addr-map.c
  3. *
  4. * Address map functions for Marvell Dove 88AP510 SoC
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/mbus.h>
  13. #include <linux/io.h>
  14. #include <asm/mach/arch.h>
  15. #include <asm/setup.h>
  16. #include <mach/dove.h>
  17. #include <plat/addr-map.h>
  18. #include "common.h"
  19. /*
  20. * Generic Address Decode Windows bit settings
  21. */
  22. #define TARGET_DDR 0x0
  23. #define TARGET_BOOTROM 0x1
  24. #define TARGET_CESA 0x3
  25. #define TARGET_PCIE0 0x4
  26. #define TARGET_PCIE1 0x8
  27. #define TARGET_SCRATCHPAD 0xd
  28. #define ATTR_CESA 0x01
  29. #define ATTR_BOOTROM 0xfd
  30. #define ATTR_DEV_SPI0_ROM 0xfe
  31. #define ATTR_DEV_SPI1_ROM 0xfb
  32. #define ATTR_PCIE_IO 0xe0
  33. #define ATTR_PCIE_MEM 0xe8
  34. #define ATTR_SCRATCHPAD 0x0
  35. static inline void __iomem *ddr_map_sc(int i)
  36. {
  37. return (void __iomem *)(DOVE_MC_VIRT_BASE + 0x100 + ((i) << 4));
  38. }
  39. /*
  40. * Description of the windows needed by the platform code
  41. */
  42. static struct __initdata orion_addr_map_cfg addr_map_cfg = {
  43. .num_wins = 8,
  44. .remappable_wins = 4,
  45. .bridge_virt_base = BRIDGE_VIRT_BASE,
  46. };
  47. static const struct __initdata orion_addr_map_info addr_map_info[] = {
  48. /*
  49. * Windows for PCIe IO+MEM space.
  50. */
  51. { 0, DOVE_PCIE0_IO_PHYS_BASE, DOVE_PCIE0_IO_SIZE,
  52. TARGET_PCIE0, ATTR_PCIE_IO, DOVE_PCIE0_IO_BUS_BASE
  53. },
  54. { 1, DOVE_PCIE1_IO_PHYS_BASE, DOVE_PCIE1_IO_SIZE,
  55. TARGET_PCIE1, ATTR_PCIE_IO, DOVE_PCIE1_IO_BUS_BASE
  56. },
  57. { 2, DOVE_PCIE0_MEM_PHYS_BASE, DOVE_PCIE0_MEM_SIZE,
  58. TARGET_PCIE0, ATTR_PCIE_MEM, -1
  59. },
  60. { 3, DOVE_PCIE1_MEM_PHYS_BASE, DOVE_PCIE1_MEM_SIZE,
  61. TARGET_PCIE1, ATTR_PCIE_MEM, -1
  62. },
  63. /*
  64. * Window for CESA engine.
  65. */
  66. { 4, DOVE_CESA_PHYS_BASE, DOVE_CESA_SIZE,
  67. TARGET_CESA, ATTR_CESA, -1
  68. },
  69. /*
  70. * Window to the BootROM for Standby and Sleep Resume
  71. */
  72. { 5, DOVE_BOOTROM_PHYS_BASE, DOVE_BOOTROM_SIZE,
  73. TARGET_BOOTROM, ATTR_BOOTROM, -1
  74. },
  75. /*
  76. * Window to the PMU Scratch Pad space
  77. */
  78. { 6, DOVE_SCRATCHPAD_PHYS_BASE, DOVE_SCRATCHPAD_SIZE,
  79. TARGET_SCRATCHPAD, ATTR_SCRATCHPAD, -1
  80. },
  81. /* End marker */
  82. { -1, 0, 0, 0, 0, 0 }
  83. };
  84. void __init dove_setup_cpu_mbus(void)
  85. {
  86. int i;
  87. int cs;
  88. /*
  89. * Disable, clear and configure windows.
  90. */
  91. orion_config_wins(&addr_map_cfg, addr_map_info);
  92. /*
  93. * Setup MBUS dram target info.
  94. */
  95. orion_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
  96. for (i = 0, cs = 0; i < 2; i++) {
  97. u32 map = readl(ddr_map_sc(i));
  98. /*
  99. * Chip select enabled?
  100. */
  101. if (map & 1) {
  102. struct mbus_dram_window *w;
  103. w = &orion_mbus_dram_info.cs[cs++];
  104. w->cs_index = i;
  105. w->mbus_attr = 0; /* CS address decoding done inside */
  106. /* the DDR controller, no need to */
  107. /* provide attributes */
  108. w->base = map & 0xff800000;
  109. w->size = 0x100000 << (((map & 0x000f0000) >> 16) - 4);
  110. }
  111. }
  112. orion_mbus_dram_info.num_cs = cs;
  113. }