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