addr-map.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * arch/arm/mach-loki/addr-map.c
  3. *
  4. * Address map functions for Marvell Loki (88RC8480) SoCs
  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 <mach/hardware.h>
  15. #include "common.h"
  16. /*
  17. * Generic Address Decode Windows bit settings
  18. */
  19. #define TARGET_DDR 0
  20. #define TARGET_DEV_BUS 1
  21. #define TARGET_PCIE0 3
  22. #define TARGET_PCIE1 4
  23. #define ATTR_DEV_BOOT 0x0f
  24. #define ATTR_DEV_CS2 0x1b
  25. #define ATTR_DEV_CS1 0x1d
  26. #define ATTR_DEV_CS0 0x1e
  27. #define ATTR_PCIE_IO 0x51
  28. #define ATTR_PCIE_MEM 0x59
  29. /*
  30. * Helpers to get DDR bank info
  31. */
  32. #define DDR_SIZE_CS(n) DDR_REG(0x1500 + ((n) << 3))
  33. #define DDR_BASE_CS(n) DDR_REG(0x1504 + ((n) << 3))
  34. /*
  35. * CPU Address Decode Windows registers
  36. */
  37. #define CPU_WIN_CTRL(n) BRIDGE_REG(0x000 | ((n) << 4))
  38. #define CPU_WIN_BASE(n) BRIDGE_REG(0x004 | ((n) << 4))
  39. #define CPU_WIN_REMAP_LO(n) BRIDGE_REG(0x008 | ((n) << 4))
  40. #define CPU_WIN_REMAP_HI(n) BRIDGE_REG(0x00c | ((n) << 4))
  41. struct mbus_dram_target_info loki_mbus_dram_info;
  42. static void __init setup_cpu_win(int win, u32 base, u32 size,
  43. u8 target, u8 attr, int remap)
  44. {
  45. u32 ctrl;
  46. base &= 0xffff0000;
  47. ctrl = ((size - 1) & 0xffff0000) | (attr << 8) | (1 << 5) | target;
  48. writel(base, CPU_WIN_BASE(win));
  49. writel(ctrl, CPU_WIN_CTRL(win));
  50. if (win < 2) {
  51. if (remap < 0)
  52. remap = base;
  53. writel(remap & 0xffff0000, CPU_WIN_REMAP_LO(win));
  54. writel(0, CPU_WIN_REMAP_HI(win));
  55. }
  56. }
  57. void __init loki_setup_cpu_mbus(void)
  58. {
  59. int i;
  60. int cs;
  61. /*
  62. * First, disable and clear windows.
  63. */
  64. for (i = 0; i < 8; i++) {
  65. writel(0, CPU_WIN_BASE(i));
  66. writel(0, CPU_WIN_CTRL(i));
  67. if (i < 2) {
  68. writel(0, CPU_WIN_REMAP_LO(i));
  69. writel(0, CPU_WIN_REMAP_HI(i));
  70. }
  71. }
  72. /*
  73. * Setup windows for PCIe IO+MEM space.
  74. */
  75. setup_cpu_win(2, LOKI_PCIE0_MEM_PHYS_BASE, LOKI_PCIE0_MEM_SIZE,
  76. TARGET_PCIE0, ATTR_PCIE_MEM, -1);
  77. setup_cpu_win(3, LOKI_PCIE1_MEM_PHYS_BASE, LOKI_PCIE1_MEM_SIZE,
  78. TARGET_PCIE1, ATTR_PCIE_MEM, -1);
  79. /*
  80. * Setup MBUS dram target info.
  81. */
  82. loki_mbus_dram_info.mbus_dram_target_id = TARGET_DDR;
  83. for (i = 0, cs = 0; i < 4; i++) {
  84. u32 base = readl(DDR_BASE_CS(i));
  85. u32 size = readl(DDR_SIZE_CS(i));
  86. /*
  87. * Chip select enabled?
  88. */
  89. if (size & 1) {
  90. struct mbus_dram_window *w;
  91. w = &loki_mbus_dram_info.cs[cs++];
  92. w->cs_index = i;
  93. w->mbus_attr = 0xf & ~(1 << i);
  94. w->base = base & 0xffff0000;
  95. w->size = (size | 0x0000ffff) + 1;
  96. }
  97. }
  98. loki_mbus_dram_info.num_cs = cs;
  99. }
  100. void __init loki_setup_dev_boot_win(u32 base, u32 size)
  101. {
  102. setup_cpu_win(4, base, size, TARGET_DEV_BUS, ATTR_DEV_BOOT, -1);
  103. }