addr-map.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * arch/arm/mach-mv78xx0/addr-map.c
  3. *
  4. * Address map functions for Marvell MV78xx0 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 <plat/addr-map.h>
  15. #include <mach/mv78xx0.h>
  16. #include "common.h"
  17. /*
  18. * Generic Address Decode Windows bit settings
  19. */
  20. #define TARGET_DEV_BUS 1
  21. #define TARGET_PCIE0 4
  22. #define TARGET_PCIE1 8
  23. #define TARGET_PCIE(i) ((i) ? TARGET_PCIE1 : TARGET_PCIE0)
  24. #define ATTR_DEV_SPI_ROM 0x1f
  25. #define ATTR_DEV_BOOT 0x2f
  26. #define ATTR_DEV_CS3 0x37
  27. #define ATTR_DEV_CS2 0x3b
  28. #define ATTR_DEV_CS1 0x3d
  29. #define ATTR_DEV_CS0 0x3e
  30. #define ATTR_PCIE_IO(l) (0xf0 & ~(0x10 << (l)))
  31. #define ATTR_PCIE_MEM(l) (0xf8 & ~(0x10 << (l)))
  32. /*
  33. * CPU Address Decode Windows registers
  34. */
  35. #define WIN0_OFF(n) (BRIDGE_VIRT_BASE + 0x0000 + ((n) << 4))
  36. #define WIN8_OFF(n) (BRIDGE_VIRT_BASE + 0x0900 + (((n) - 8) << 4))
  37. static void __init __iomem *win_cfg_base(const struct orion_addr_map_cfg *cfg, int win)
  38. {
  39. /*
  40. * Find the control register base address for this window.
  41. *
  42. * BRIDGE_VIRT_BASE points to the right (CPU0's or CPU1's)
  43. * MBUS bridge depending on which CPU core we're running on,
  44. * so we don't need to take that into account here.
  45. */
  46. return (win < 8) ? WIN0_OFF(win) : WIN8_OFF(win);
  47. }
  48. /*
  49. * Description of the windows needed by the platform code
  50. */
  51. static struct orion_addr_map_cfg addr_map_cfg __initdata = {
  52. .num_wins = 14,
  53. .remappable_wins = 8,
  54. .win_cfg_base = win_cfg_base,
  55. };
  56. void __init mv78xx0_setup_cpu_mbus(void)
  57. {
  58. /*
  59. * Disable, clear and configure windows.
  60. */
  61. orion_config_wins(&addr_map_cfg, NULL);
  62. /*
  63. * Setup MBUS dram target info.
  64. */
  65. if (mv78xx0_core_index() == 0)
  66. orion_setup_cpu_mbus_target(&addr_map_cfg,
  67. (void __iomem *) DDR_WINDOW_CPU0_BASE);
  68. else
  69. orion_setup_cpu_mbus_target(&addr_map_cfg,
  70. (void __iomem *) DDR_WINDOW_CPU1_BASE);
  71. }
  72. void __init mv78xx0_setup_pcie_io_win(int window, u32 base, u32 size,
  73. int maj, int min)
  74. {
  75. orion_setup_cpu_win(&addr_map_cfg, window, base, size,
  76. TARGET_PCIE(maj), ATTR_PCIE_IO(min), 0);
  77. }
  78. void __init mv78xx0_setup_pcie_mem_win(int window, u32 base, u32 size,
  79. int maj, int min)
  80. {
  81. orion_setup_cpu_win(&addr_map_cfg, window, base, size,
  82. TARGET_PCIE(maj), ATTR_PCIE_MEM(min), -1);
  83. }