addr-map.c 2.9 KB

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