marvell_plat_config.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #include <drivers/delay_timer.h>
  8. #include <lib/mmio.h>
  9. #include <armada_common.h>
  10. /*
  11. * If bootrom is currently at BLE there's no need to include the memory
  12. * maps structure at this point
  13. */
  14. #include <mvebu_def.h>
  15. #ifndef IMAGE_BLE
  16. /*****************************************************************************
  17. * GPIO Configuration
  18. *****************************************************************************
  19. */
  20. #define MPP_CONTROL_REGISTER 0xf2440018
  21. #define MPP_CONTROL_MPP_SEL_52_MASK 0xf0000
  22. #define GPIO_DATA_OUT1_REGISTER 0xf2440140
  23. #define GPIO_DATA_OUT_EN_CTRL1_REGISTER 0xf2440144
  24. #define GPIO52_MASK 0x100000
  25. /* Reset PCIe via GPIO number 52 */
  26. int marvell_gpio_config(void)
  27. {
  28. uint32_t reg;
  29. reg = mmio_read_32(MPP_CONTROL_REGISTER);
  30. reg |= MPP_CONTROL_MPP_SEL_52_MASK;
  31. mmio_write_32(MPP_CONTROL_REGISTER, reg);
  32. reg = mmio_read_32(GPIO_DATA_OUT1_REGISTER);
  33. reg |= GPIO52_MASK;
  34. mmio_write_32(GPIO_DATA_OUT1_REGISTER, reg);
  35. reg = mmio_read_32(GPIO_DATA_OUT_EN_CTRL1_REGISTER);
  36. reg &= ~GPIO52_MASK;
  37. mmio_write_32(GPIO_DATA_OUT_EN_CTRL1_REGISTER, reg);
  38. udelay(100);
  39. return 0;
  40. }
  41. /*****************************************************************************
  42. * AMB Configuration
  43. *****************************************************************************
  44. */
  45. struct addr_map_win amb_memory_map[] = {
  46. /* CP1 SPI1 CS0 Direct Mode access */
  47. {0xf900, 0x1000000, AMB_SPI1_CS0_ID},
  48. };
  49. int marvell_get_amb_memory_map(struct addr_map_win **win, uint32_t *size,
  50. uintptr_t base)
  51. {
  52. *win = amb_memory_map;
  53. if (*win == NULL)
  54. *size = 0;
  55. else
  56. *size = ARRAY_SIZE(amb_memory_map);
  57. return 0;
  58. }
  59. #endif
  60. /*****************************************************************************
  61. * IO WIN Configuration
  62. *****************************************************************************
  63. */
  64. struct addr_map_win io_win_memory_map[] = {
  65. /* CP1 (MCI0) internal regs */
  66. {0x00000000f4000000, 0x2000000, MCI_0_TID},
  67. #ifndef IMAGE_BLE
  68. /* PCIe0 and SPI1_CS0 (RUNIT) on CP1*/
  69. {0x00000000f9000000, 0x2000000, MCI_0_TID},
  70. /* PCIe1 on CP1*/
  71. {0x00000000fb000000, 0x1000000, MCI_0_TID},
  72. /* PCIe2 on CP1*/
  73. {0x00000000fc000000, 0x1000000, MCI_0_TID},
  74. /* MCI 0 indirect window */
  75. {MVEBU_MCI_REG_BASE_REMAP(0), 0x100000, MCI_0_TID},
  76. /* MCI 1 indirect window */
  77. {MVEBU_MCI_REG_BASE_REMAP(1), 0x100000, MCI_1_TID},
  78. #endif
  79. };
  80. uint32_t marvell_get_io_win_gcr_target(int ap_index)
  81. {
  82. return PIDI_TID;
  83. }
  84. int marvell_get_io_win_memory_map(int ap_index, struct addr_map_win **win,
  85. uint32_t *size)
  86. {
  87. *win = io_win_memory_map;
  88. if (*win == NULL)
  89. *size = 0;
  90. else
  91. *size = ARRAY_SIZE(io_win_memory_map);
  92. return 0;
  93. }
  94. #ifndef IMAGE_BLE
  95. /*****************************************************************************
  96. * IOB Configuration
  97. *****************************************************************************
  98. */
  99. struct addr_map_win iob_memory_map_cp0[] = {
  100. /* CP0 */
  101. /* PEX1_X1 window */
  102. {0x00000000f7000000, 0x1000000, PEX1_TID},
  103. /* PEX2_X1 window */
  104. {0x00000000f8000000, 0x1000000, PEX2_TID},
  105. /* PEX0_X4 window */
  106. {0x00000000f6000000, 0x1000000, PEX0_TID},
  107. {0x00000000c0000000, 0x30000000, PEX0_TID},
  108. {0x0000000800000000, 0x100000000, PEX0_TID},
  109. };
  110. struct addr_map_win iob_memory_map_cp1[] = {
  111. /* CP1 */
  112. /* SPI1_CS0 (RUNIT) window */
  113. {0x00000000f9000000, 0x1000000, RUNIT_TID},
  114. /* PEX1_X1 window */
  115. {0x00000000fb000000, 0x1000000, PEX1_TID},
  116. /* PEX2_X1 window */
  117. {0x00000000fc000000, 0x1000000, PEX2_TID},
  118. /* PEX0_X4 window */
  119. {0x00000000fa000000, 0x1000000, PEX0_TID}
  120. };
  121. int marvell_get_iob_memory_map(struct addr_map_win **win, uint32_t *size,
  122. uintptr_t base)
  123. {
  124. switch (base) {
  125. case MVEBU_CP_REGS_BASE(0):
  126. *win = iob_memory_map_cp0;
  127. *size = ARRAY_SIZE(iob_memory_map_cp0);
  128. return 0;
  129. case MVEBU_CP_REGS_BASE(1):
  130. *win = iob_memory_map_cp1;
  131. *size = ARRAY_SIZE(iob_memory_map_cp1);
  132. return 0;
  133. default:
  134. *size = 0;
  135. *win = 0;
  136. return 1;
  137. }
  138. }
  139. #endif
  140. /*****************************************************************************
  141. * CCU Configuration
  142. *****************************************************************************
  143. */
  144. struct addr_map_win ccu_memory_map[] = {
  145. #ifdef IMAGE_BLE
  146. {0x00000000f2000000, 0x4000000, IO_0_TID}, /* IO window */
  147. #else
  148. #if LLC_SRAM
  149. {PLAT_MARVELL_LLC_SRAM_BASE, PLAT_MARVELL_LLC_SRAM_SIZE, SRAM_TID},
  150. #endif
  151. {0x00000000f2000000, 0xe000000, IO_0_TID}, /* IO window */
  152. {0x00000000c0000000, 0x30000000, IO_0_TID}, /* IO window */
  153. {0x0000000800000000, 0x100000000, IO_0_TID}, /* IO window */
  154. #endif
  155. };
  156. uint32_t marvell_get_ccu_gcr_target(int ap)
  157. {
  158. return DRAM_0_TID;
  159. }
  160. int marvell_get_ccu_memory_map(int ap_index, struct addr_map_win **win,
  161. uint32_t *size)
  162. {
  163. *win = ccu_memory_map;
  164. *size = ARRAY_SIZE(ccu_memory_map);
  165. return 0;
  166. }
  167. /* In reference to #ifndef IMAGE_BLE, this part is used for BLE only. */
  168. /*****************************************************************************
  169. * SKIP IMAGE Configuration
  170. *****************************************************************************
  171. */
  172. void *plat_marvell_get_skip_image_data(void)
  173. {
  174. /* No recovery button on A8k-MCBIN board */
  175. return NULL;
  176. }