mci.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. /* MCI bus driver for Marvell ARMADA 8K and 8K+ SoCs */
  8. #include <common/debug.h>
  9. #include <drivers/delay_timer.h>
  10. #include <drivers/marvell/mci.h>
  11. #include <lib/mmio.h>
  12. #include <mvebu.h>
  13. #include <mvebu_def.h>
  14. #include <plat_marvell.h>
  15. /* /HB /Units /Direct_regs /Direct regs
  16. * /Configuration Register Write/Read Data Register
  17. */
  18. #define MCI_WRITE_READ_DATA_REG(mci_index) \
  19. MVEBU_MCI_REG_BASE_REMAP(mci_index)
  20. /* /HB /Units /Direct_regs /Direct regs
  21. * /Configuration Register Access Command Register
  22. */
  23. #define MCI_ACCESS_CMD_REG(mci_index) \
  24. (MVEBU_MCI_REG_BASE_REMAP(mci_index) + 0x4)
  25. /* Access Command fields :
  26. * bit[3:0] - Sub command: 1 => Peripheral Config Register Read,
  27. * 0 => Peripheral Config Register Write,
  28. * 2 => Peripheral Assign ID request,
  29. * 3 => Circular Config Write
  30. * bit[5] - 1 => Local (same chip access) 0 => Remote
  31. * bit[15:8] - Destination hop ID. Put Global ID (GID) here (see scheme below).
  32. * bit[23:22] - 0x3 IHB PHY REG address space, 0x0 IHB Controller space
  33. * bit[21:16] - Low 6 bits of offset. Hight 2 bits are taken from bit[28:27]
  34. * of IHB_PHY_CTRL
  35. * (must be set before any PHY register access occurs):
  36. * /IHB_REG /IHB_REGInterchip Hopping Bus Registers
  37. * /IHB Version Control Register
  38. *
  39. * ixi_ihb_top IHB PHY
  40. * AXI ----------------------------- -------------
  41. * <--| axi_hb_top | ihb_pipe_top |-->| |
  42. * -->| GID=1 | GID=0 |<--| |
  43. * ----------------------------- -------------
  44. */
  45. #define MCI_INDIRECT_CTRL_READ_CMD 0x1
  46. #define MCI_INDIRECT_CTRL_ASSIGN_CMD 0x2
  47. #define MCI_INDIRECT_CTRL_CIRCULAR_CMD 0x3
  48. #define MCI_INDIRECT_CTRL_LOCAL_PKT (1 << 5)
  49. #define MCI_INDIRECT_CTRL_CMD_DONE_OFFSET 6
  50. #define MCI_INDIRECT_CTRL_CMD_DONE \
  51. (1 << MCI_INDIRECT_CTRL_CMD_DONE_OFFSET)
  52. #define MCI_INDIRECT_CTRL_DATA_READY_OFFSET 7
  53. #define MCI_INDIRECT_CTRL_DATA_READY \
  54. (1 << MCI_INDIRECT_CTRL_DATA_READY_OFFSET)
  55. #define MCI_INDIRECT_CTRL_HOPID_OFFSET 8
  56. #define MCI_INDIRECT_CTRL_HOPID(id) \
  57. (((id) & 0xFF) << MCI_INDIRECT_CTRL_HOPID_OFFSET)
  58. #define MCI_INDIRECT_CTRL_REG_CHIPID_OFFSET 16
  59. #define MCI_INDIRECT_REG_CTRL_ADDR(reg_num) \
  60. (reg_num << MCI_INDIRECT_CTRL_REG_CHIPID_OFFSET)
  61. /* Hop ID values */
  62. #define GID_IHB_PIPE 0
  63. #define GID_AXI_HB 1
  64. #define GID_IHB_EXT 2
  65. #define MCI_DID_GLOBAL_ASSIGNMENT_REQUEST_REG 0x2
  66. /* Target MCi Local ID (LID, which is = self DID) */
  67. #define MCI_DID_GLOBAL_ASSIGN_REQ_MCI_LOCAL_ID(val) (((val) & 0xFF) << 16)
  68. /* Bits [15:8]: Number of MCis on chip of target MCi */
  69. #define MCI_DID_GLOBAL_ASSIGN_REQ_MCI_COUNT(val) (((val) & 0xFF) << 8)
  70. /* Bits [7:0]: Number of hops on chip of target MCi */
  71. #define MCI_DID_GLOBAL_ASSIGN_REQ_HOPS_NUM(val) (((val) & 0xFF) << 0)
  72. /* IHB_REG domain registers */
  73. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers/
  74. * Rx Memory Configuration Register (RX_MEM_CFG)
  75. */
  76. #define MCI_CTRL_RX_MEM_CFG_REG_NUM 0x0
  77. #define MCI_CTRL_RX_TX_MEM_CFG_RQ_THRESH(val) (((val) & 0xFF) << 24)
  78. #define MCI_CTRL_RX_TX_MEM_CFG_PQ_THRESH(val) (((val) & 0xFF) << 16)
  79. #define MCI_CTRL_RX_TX_MEM_CFG_NQ_THRESH(val) (((val) & 0xFF) << 8)
  80. #define MCI_CTRL_RX_TX_MEM_CFG_DELTA_THRESH(val) (((val) & 0xF) << 4)
  81. #define MCI_CTRL_RX_TX_MEM_CFG_RTC(val) (((val) & 0x3) << 2)
  82. #define MCI_CTRL_RX_TX_MEM_CFG_WTC(val) (((val) & 0x3) << 0)
  83. #define MCI_CTRL_RX_MEM_CFG_REG_DEF_CP_VAL \
  84. (MCI_CTRL_RX_TX_MEM_CFG_RQ_THRESH(0x07) | \
  85. MCI_CTRL_RX_TX_MEM_CFG_PQ_THRESH(0x3f) | \
  86. MCI_CTRL_RX_TX_MEM_CFG_NQ_THRESH(0x3f) | \
  87. MCI_CTRL_RX_TX_MEM_CFG_DELTA_THRESH(0xf) | \
  88. MCI_CTRL_RX_TX_MEM_CFG_RTC(1) | \
  89. MCI_CTRL_RX_TX_MEM_CFG_WTC(1))
  90. #define MCI_CTRL_RX_MEM_CFG_REG_DEF_AP_VAL \
  91. (MCI_CTRL_RX_TX_MEM_CFG_RQ_THRESH(0x3f) | \
  92. MCI_CTRL_RX_TX_MEM_CFG_PQ_THRESH(0x03) | \
  93. MCI_CTRL_RX_TX_MEM_CFG_NQ_THRESH(0x3f) | \
  94. MCI_CTRL_RX_TX_MEM_CFG_DELTA_THRESH(0xf) | \
  95. MCI_CTRL_RX_TX_MEM_CFG_RTC(1) | \
  96. MCI_CTRL_RX_TX_MEM_CFG_WTC(1))
  97. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers/
  98. * Tx Memory Configuration Register (TX_MEM_CFG)
  99. */
  100. #define MCI_CTRL_TX_MEM_CFG_REG_NUM 0x1
  101. /* field mapping for TX mem config register
  102. * are the same as for RX register - see register above
  103. */
  104. #define MCI_CTRL_TX_MEM_CFG_REG_DEF_VAL \
  105. (MCI_CTRL_RX_TX_MEM_CFG_RQ_THRESH(0x20) | \
  106. MCI_CTRL_RX_TX_MEM_CFG_PQ_THRESH(0x20) | \
  107. MCI_CTRL_RX_TX_MEM_CFG_NQ_THRESH(0x20) | \
  108. MCI_CTRL_RX_TX_MEM_CFG_DELTA_THRESH(2) | \
  109. MCI_CTRL_RX_TX_MEM_CFG_RTC(1) | \
  110. MCI_CTRL_RX_TX_MEM_CFG_WTC(1))
  111. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers
  112. * /IHB Link CRC Control
  113. */
  114. /* MCi Link CRC Control Register (MCi_CRC_CTRL) */
  115. #define MCI_LINK_CRC_CTRL_REG_NUM 0x4
  116. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers
  117. * /IHB Status Register
  118. */
  119. /* MCi Status Register (MCi_STS) */
  120. #define MCI_CTRL_STATUS_REG_NUM 0x5
  121. #define MCI_CTRL_STATUS_REG_PHY_READY (1 << 12)
  122. #define MCI_CTRL_STATUS_REG_LINK_PRESENT (1 << 15)
  123. #define MCI_CTRL_STATUS_REG_PHY_CID_VIO_OFFSET 24
  124. #define MCI_CTRL_STATUS_REG_PHY_CID_VIO_MASK \
  125. (0xF << MCI_CTRL_STATUS_REG_PHY_CID_VIO_OFFSET)
  126. /* Expected successful Link result, including reserved bit */
  127. #define MCI_CTRL_PHY_READY (MCI_CTRL_STATUS_REG_PHY_READY | \
  128. MCI_CTRL_STATUS_REG_LINK_PRESENT | \
  129. MCI_CTRL_STATUS_REG_PHY_CID_VIO_MASK)
  130. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers/
  131. * MCi PHY Speed Settings Register (MCi_PHY_SETTING)
  132. */
  133. #define MCI_CTRL_MCI_PHY_SETTINGS_REG_NUM 0x8
  134. #define MCI_CTRL_MCI_PHY_SET_DLO_FIFO_FULL_TRESH(val) (((val) & 0xF) << 28)
  135. #define MCI_CTRL_MCI_PHY_SET_PHY_MAX_SPEED(val) (((val) & 0xF) << 12)
  136. #define MCI_CTRL_MCI_PHY_SET_PHYCLK_SEL(val) (((val) & 0xF) << 8)
  137. #define MCI_CTRL_MCI_PHY_SET_REFCLK_FREQ_SEL(val) (((val) & 0xF) << 4)
  138. #define MCI_CTRL_MCI_PHY_SET_AUTO_LINK_EN(val) (((val) & 0x1) << 1)
  139. #define MCI_CTRL_MCI_PHY_SET_REG_DEF_VAL \
  140. (MCI_CTRL_MCI_PHY_SET_DLO_FIFO_FULL_TRESH(0x3) | \
  141. MCI_CTRL_MCI_PHY_SET_PHY_MAX_SPEED(0x3) | \
  142. MCI_CTRL_MCI_PHY_SET_PHYCLK_SEL(0x2) | \
  143. MCI_CTRL_MCI_PHY_SET_REFCLK_FREQ_SEL(0x1))
  144. #define MCI_CTRL_MCI_PHY_SET_REG_DEF_VAL2 \
  145. (MCI_CTRL_MCI_PHY_SET_DLO_FIFO_FULL_TRESH(0x3) | \
  146. MCI_CTRL_MCI_PHY_SET_PHY_MAX_SPEED(0x3) | \
  147. MCI_CTRL_MCI_PHY_SET_PHYCLK_SEL(0x5) | \
  148. MCI_CTRL_MCI_PHY_SET_REFCLK_FREQ_SEL(0x1))
  149. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers
  150. * /IHB Mode Config
  151. */
  152. #define MCI_CTRL_IHB_MODE_CFG_REG_NUM 0x25
  153. #define MCI_CTRL_IHB_MODE_HBCLK_DIV(val) ((val) & 0xFF)
  154. #define MCI_CTRL_IHB_MODE_CHUNK_MOD_OFFSET 8
  155. #define MCI_CTRL_IHB_MODE_CHUNK_MOD \
  156. (1 << MCI_CTRL_IHB_MODE_CHUNK_MOD_OFFSET)
  157. #define MCI_CTRL_IHB_MODE_FWD_MOD_OFFSET 9
  158. #define MCI_CTRL_IHB_MODE_FWD_MOD \
  159. (1 << MCI_CTRL_IHB_MODE_FWD_MOD_OFFSET)
  160. #define MCI_CTRL_IHB_MODE_SEQFF_FINE_MOD(val) (((val) & 0xF) << 12)
  161. #define MCI_CTRL_IHB_MODE_RX_COMB_THRESH(val) (((val) & 0xFF) << 16)
  162. #define MCI_CTRL_IHB_MODE_TX_COMB_THRESH(val) (((val) & 0xFF) << 24)
  163. #define MCI_CTRL_IHB_MODE_CFG_REG_DEF_VAL \
  164. (MCI_CTRL_IHB_MODE_HBCLK_DIV(6) | \
  165. MCI_CTRL_IHB_MODE_FWD_MOD | \
  166. MCI_CTRL_IHB_MODE_SEQFF_FINE_MOD(0xF) | \
  167. MCI_CTRL_IHB_MODE_RX_COMB_THRESH(0x3f) | \
  168. MCI_CTRL_IHB_MODE_TX_COMB_THRESH(0x40))
  169. /* AXI_HB registers */
  170. #define MCI_AXI_ACCESS_DATA_REG_NUM 0x0
  171. #define MCI_AXI_ACCESS_PCIE_MODE 1
  172. #define MCI_AXI_ACCESS_CACHE_CHECK_OFFSET 5
  173. #define MCI_AXI_ACCESS_CACHE_CHECK \
  174. (1 << MCI_AXI_ACCESS_CACHE_CHECK_OFFSET)
  175. #define MCI_AXI_ACCESS_FORCE_POST_WR_OFFSET 6
  176. #define MCI_AXI_ACCESS_FORCE_POST_WR \
  177. (1 << MCI_AXI_ACCESS_FORCE_POST_WR_OFFSET)
  178. #define MCI_AXI_ACCESS_DISABLE_CLK_GATING_OFFSET 9
  179. #define MCI_AXI_ACCESS_DISABLE_CLK_GATING \
  180. (1 << MCI_AXI_ACCESS_DISABLE_CLK_GATING_OFFSET)
  181. /* /HB /Units /HB_REG /HB_REGHopping Bus Registers
  182. * /Window 0 Address Mask Register
  183. */
  184. #define MCI_HB_CTRL_WIN0_ADDRESS_MASK_REG_NUM 0x2
  185. /* /HB /Units /HB_REG /HB_REGHopping Bus Registers
  186. * /Window 0 Destination Register
  187. */
  188. #define MCI_HB_CTRL_WIN0_DESTINATION_REG_NUM 0x3
  189. #define MCI_HB_CTRL_WIN0_DEST_VALID_FLAG(val) (((val) & 0x1) << 16)
  190. #define MCI_HB_CTRL_WIN0_DEST_ID(val) (((val) & 0xFF) << 0)
  191. /* /HB /Units /HB_REG /HB_REGHopping Bus Registers /Tx Control Register */
  192. #define MCI_HB_CTRL_TX_CTRL_REG_NUM 0xD
  193. #define MCI_HB_CTRL_TX_CTRL_PCIE_MODE_OFFSET 24
  194. #define MCI_HB_CTRL_TX_CTRL_PCIE_MODE \
  195. (1 << MCI_HB_CTRL_TX_CTRL_PCIE_MODE_OFFSET)
  196. #define MCI_HB_CTRL_TX_CTRL_PRI_TH_QOS(val) (((val) & 0xF) << 12)
  197. #define MCI_HB_CTRL_TX_CTRL_MAX_RD_CNT(val) (((val) & 0x1F) << 6)
  198. #define MCI_HB_CTRL_TX_CTRL_MAX_WR_CNT(val) (((val) & 0x1F) << 0)
  199. /* /HB /Units /IHB_REG /IHB_REGInterchip Hopping Bus Registers
  200. * /IHB Version Control Register
  201. */
  202. #define MCI_PHY_CTRL_REG_NUM 0x7
  203. #define MCI_PHY_CTRL_MCI_MINOR 0x8 /* BITS [3:0] */
  204. #define MCI_PHY_CTRL_MCI_MAJOR_OFFSET 4
  205. #define MCI_PHY_CTRL_MCI_MAJOR \
  206. (1 << MCI_PHY_CTRL_MCI_MAJOR_OFFSET)
  207. #define MCI_PHY_CTRL_MCI_SLEEP_REQ_OFFSET 11
  208. #define MCI_PHY_CTRL_MCI_SLEEP_REQ \
  209. (1 << MCI_PHY_CTRL_MCI_SLEEP_REQ_OFFSET)
  210. /* Host=1 / Device=0 PHY mode */
  211. #define MCI_PHY_CTRL_MCI_PHY_MODE_OFFSET 24
  212. #define MCI_PHY_CTRL_MCI_PHY_MODE_HOST \
  213. (1 << MCI_PHY_CTRL_MCI_PHY_MODE_OFFSET)
  214. /* Register=1 / PWM=0 interface */
  215. #define MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE_OFFSET 25
  216. #define MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE \
  217. (1 << MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE_OFFSET)
  218. /* PHY code InReset=1 */
  219. #define MCI_PHY_CTRL_MCI_PHY_RESET_CORE_OFFSET 26
  220. #define MCI_PHY_CTRL_MCI_PHY_RESET_CORE \
  221. (1 << MCI_PHY_CTRL_MCI_PHY_RESET_CORE_OFFSET)
  222. #define MCI_PHY_CTRL_PHY_ADDR_MSB_OFFSET 27
  223. #define MCI_PHY_CTRL_PHY_ADDR_MSB(addr) \
  224. (((addr) & 0x3) << \
  225. MCI_PHY_CTRL_PHY_ADDR_MSB_OFFSET)
  226. #define MCI_PHY_CTRL_PIDI_MODE_OFFSET 31
  227. #define MCI_PHY_CTRL_PIDI_MODE \
  228. (1U << MCI_PHY_CTRL_PIDI_MODE_OFFSET)
  229. /* Number of times to wait for the MCI link ready after MCI configurations
  230. * Normally takes 34-35 successive reads
  231. */
  232. #define LINK_READY_TIMEOUT 100
  233. enum mci_register_type {
  234. MCI_REG_TYPE_PHY = 0,
  235. MCI_REG_TYPE_CTRL,
  236. };
  237. enum {
  238. MCI_CMD_WRITE,
  239. MCI_CMD_READ
  240. };
  241. /* Write wrapper callback for debug:
  242. * will print written data in case LOG_LEVEL >= 40
  243. */
  244. static void mci_mmio_write_32(uintptr_t addr, uint32_t value)
  245. {
  246. VERBOSE("Write:\t0x%x = 0x%x\n", (uint32_t)addr, value);
  247. mmio_write_32(addr, value);
  248. }
  249. /* Read wrapper callback for debug:
  250. * will print read data in case LOG_LEVEL >= 40
  251. */
  252. static uint32_t mci_mmio_read_32(uintptr_t addr)
  253. {
  254. uint32_t value;
  255. value = mmio_read_32(addr);
  256. VERBOSE("Read:\t0x%x = 0x%x\n", (uint32_t)addr, value);
  257. return value;
  258. }
  259. /* MCI indirect access command completion polling:
  260. * Each write/read command done via MCI indirect registers must be polled
  261. * for command completions status.
  262. *
  263. * Returns 1 in case of error
  264. * Returns 0 in case of command completed successfully.
  265. */
  266. static int mci_poll_command_completion(int mci_index, int command_type)
  267. {
  268. uint32_t mci_cmd_value = 0, retry_count = 100, ret = 0;
  269. uint32_t completion_flags = MCI_INDIRECT_CTRL_CMD_DONE;
  270. debug_enter();
  271. /* Read commands require validating that requested data is ready */
  272. if (command_type == MCI_CMD_READ)
  273. completion_flags |= MCI_INDIRECT_CTRL_DATA_READY;
  274. do {
  275. /* wait 1 ms before each polling */
  276. mdelay(1);
  277. mci_cmd_value = mci_mmio_read_32(MCI_ACCESS_CMD_REG(mci_index));
  278. } while (((mci_cmd_value & completion_flags) != completion_flags) &&
  279. (retry_count-- > 0));
  280. if (retry_count == 0) {
  281. ERROR("%s: MCI command timeout (command status = 0x%x)\n",
  282. __func__, mci_cmd_value);
  283. ret = 1;
  284. }
  285. debug_exit();
  286. return ret;
  287. }
  288. int mci_read(int mci_idx, uint32_t cmd, uint32_t *value)
  289. {
  290. int rval;
  291. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_idx), cmd);
  292. rval = mci_poll_command_completion(mci_idx, MCI_CMD_READ);
  293. *value = mci_mmio_read_32(MCI_WRITE_READ_DATA_REG(mci_idx));
  294. return rval;
  295. }
  296. int mci_write(int mci_idx, uint32_t cmd, uint32_t data)
  297. {
  298. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_idx), data);
  299. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_idx), cmd);
  300. return mci_poll_command_completion(mci_idx, MCI_CMD_WRITE);
  301. }
  302. /* Perform 3 configurations in one command: PCI mode,
  303. * queues separation and cache bit
  304. */
  305. static int mci_axi_set_pcie_mode(int mci_index)
  306. {
  307. uint32_t reg_data, ret = 1;
  308. debug_enter();
  309. /* This configuration makes MCI IP behave consistently with AXI protocol
  310. * It should be configured at one side only (for example locally at AP).
  311. * The IP takes care of performing the same configurations at MCI on
  312. * another side (for example remotely at CP).
  313. */
  314. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  315. MCI_AXI_ACCESS_PCIE_MODE |
  316. MCI_AXI_ACCESS_CACHE_CHECK |
  317. MCI_AXI_ACCESS_FORCE_POST_WR |
  318. MCI_AXI_ACCESS_DISABLE_CLK_GATING);
  319. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  320. MCI_INDIRECT_REG_CTRL_ADDR(
  321. MCI_AXI_ACCESS_DATA_REG_NUM) |
  322. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB) |
  323. MCI_INDIRECT_CTRL_LOCAL_PKT |
  324. MCI_INDIRECT_CTRL_CIRCULAR_CMD);
  325. /* if Write command was successful, verify PCIe mode */
  326. if (mci_poll_command_completion(mci_index, MCI_CMD_WRITE) == 0) {
  327. /* Verify the PCIe mode selected */
  328. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  329. MCI_INDIRECT_REG_CTRL_ADDR(
  330. MCI_HB_CTRL_TX_CTRL_REG_NUM) |
  331. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB) |
  332. MCI_INDIRECT_CTRL_LOCAL_PKT |
  333. MCI_INDIRECT_CTRL_READ_CMD);
  334. /* if read was completed, verify PCIe mode */
  335. if (mci_poll_command_completion(mci_index, MCI_CMD_READ) == 0) {
  336. reg_data = mci_mmio_read_32(
  337. MCI_WRITE_READ_DATA_REG(mci_index));
  338. if (reg_data & MCI_HB_CTRL_TX_CTRL_PCIE_MODE)
  339. ret = 0;
  340. }
  341. }
  342. debug_exit();
  343. return ret;
  344. }
  345. /* Reduce sequence FIFO timer expiration threshold */
  346. static int mci_axi_set_fifo_thresh(int mci_index)
  347. {
  348. uint32_t reg_data, ret = 0;
  349. debug_enter();
  350. /* This configuration reduces sequence FIFO timer expiration threshold
  351. * (to 0x7 instead of 0xA).
  352. * In MCI 1.6 version this configuration prevents possible functional
  353. * issues.
  354. * In version 1.82 the configuration prevents performance degradation
  355. */
  356. /* Configure local AP side */
  357. reg_data = MCI_PHY_CTRL_PIDI_MODE |
  358. MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE |
  359. MCI_PHY_CTRL_MCI_PHY_MODE_HOST |
  360. MCI_PHY_CTRL_MCI_MAJOR |
  361. MCI_PHY_CTRL_MCI_MINOR;
  362. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index), reg_data);
  363. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  364. MCI_INDIRECT_REG_CTRL_ADDR(MCI_PHY_CTRL_REG_NUM) |
  365. MCI_INDIRECT_CTRL_LOCAL_PKT);
  366. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  367. /* Reduce the threshold */
  368. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  369. MCI_CTRL_IHB_MODE_CFG_REG_DEF_VAL);
  370. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  371. MCI_INDIRECT_REG_CTRL_ADDR(
  372. MCI_CTRL_IHB_MODE_CFG_REG_NUM) |
  373. MCI_INDIRECT_CTRL_LOCAL_PKT);
  374. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  375. /* Exit PIDI mode */
  376. reg_data = MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE |
  377. MCI_PHY_CTRL_MCI_PHY_MODE_HOST |
  378. MCI_PHY_CTRL_MCI_MAJOR |
  379. MCI_PHY_CTRL_MCI_MINOR;
  380. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index), reg_data);
  381. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  382. MCI_INDIRECT_REG_CTRL_ADDR(MCI_PHY_CTRL_REG_NUM) |
  383. MCI_INDIRECT_CTRL_LOCAL_PKT);
  384. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  385. /* Configure remote CP side */
  386. reg_data = MCI_PHY_CTRL_PIDI_MODE |
  387. MCI_PHY_CTRL_MCI_MAJOR |
  388. MCI_PHY_CTRL_MCI_MINOR |
  389. MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE;
  390. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index), reg_data);
  391. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  392. MCI_INDIRECT_REG_CTRL_ADDR(MCI_PHY_CTRL_REG_NUM) |
  393. MCI_CTRL_IHB_MODE_FWD_MOD);
  394. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  395. /* Reduce the threshold */
  396. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  397. MCI_CTRL_IHB_MODE_CFG_REG_DEF_VAL);
  398. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  399. MCI_INDIRECT_REG_CTRL_ADDR(
  400. MCI_CTRL_IHB_MODE_CFG_REG_NUM) |
  401. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT));
  402. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  403. /* Exit PIDI mode */
  404. reg_data = MCI_PHY_CTRL_MCI_MAJOR |
  405. MCI_PHY_CTRL_MCI_MINOR |
  406. MCI_PHY_CTRL_MCI_PHY_REG_IF_MODE;
  407. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index), reg_data);
  408. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  409. MCI_INDIRECT_REG_CTRL_ADDR(MCI_PHY_CTRL_REG_NUM) |
  410. MCI_CTRL_IHB_MODE_FWD_MOD);
  411. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  412. debug_exit();
  413. return ret;
  414. }
  415. /* Configure:
  416. * 1. AP & CP TX thresholds and delta configurations
  417. * 2. DLO & DLI FIFO full threshold
  418. * 3. RX thresholds and delta configurations
  419. * 4. CP AR and AW outstanding
  420. * 5. AP AR and AW outstanding
  421. */
  422. static int mci_axi_set_fifo_rx_tx_thresh(int mci_index)
  423. {
  424. uint32_t ret = 0;
  425. debug_enter();
  426. /* AP TX thresholds and delta configurations (IHB_reg 0x1) */
  427. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  428. MCI_CTRL_TX_MEM_CFG_REG_DEF_VAL);
  429. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  430. MCI_INDIRECT_REG_CTRL_ADDR(
  431. MCI_CTRL_TX_MEM_CFG_REG_NUM) |
  432. MCI_INDIRECT_CTRL_LOCAL_PKT);
  433. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  434. /* CP TX thresholds and delta configurations (IHB_reg 0x1) */
  435. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  436. MCI_CTRL_TX_MEM_CFG_REG_DEF_VAL);
  437. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  438. MCI_INDIRECT_REG_CTRL_ADDR(
  439. MCI_CTRL_TX_MEM_CFG_REG_NUM) |
  440. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT));
  441. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  442. /* AP DLO & DLI FIFO full threshold & Auto-Link enable (IHB_reg 0x8) */
  443. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  444. MCI_CTRL_MCI_PHY_SET_REG_DEF_VAL |
  445. MCI_CTRL_MCI_PHY_SET_AUTO_LINK_EN(1));
  446. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  447. MCI_INDIRECT_REG_CTRL_ADDR(
  448. MCI_CTRL_MCI_PHY_SETTINGS_REG_NUM) |
  449. MCI_INDIRECT_CTRL_LOCAL_PKT);
  450. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  451. /* CP DLO & DLI FIFO full threshold (IHB_reg 0x8) */
  452. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  453. MCI_CTRL_MCI_PHY_SET_REG_DEF_VAL);
  454. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  455. MCI_INDIRECT_REG_CTRL_ADDR(
  456. MCI_CTRL_MCI_PHY_SETTINGS_REG_NUM) |
  457. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT));
  458. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  459. /* AP RX thresholds and delta configurations (IHB_reg 0x0) */
  460. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  461. MCI_CTRL_RX_MEM_CFG_REG_DEF_AP_VAL);
  462. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  463. MCI_INDIRECT_REG_CTRL_ADDR(
  464. MCI_CTRL_RX_MEM_CFG_REG_NUM) |
  465. MCI_INDIRECT_CTRL_LOCAL_PKT);
  466. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  467. /* CP RX thresholds and delta configurations (IHB_reg 0x0) */
  468. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  469. MCI_CTRL_RX_MEM_CFG_REG_DEF_CP_VAL);
  470. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  471. MCI_INDIRECT_REG_CTRL_ADDR(
  472. MCI_CTRL_RX_MEM_CFG_REG_NUM) |
  473. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT));
  474. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  475. /* AP AR & AW maximum AXI outstanding request cfg (HB_reg 0xd) */
  476. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  477. MCI_HB_CTRL_TX_CTRL_PRI_TH_QOS(8) |
  478. MCI_HB_CTRL_TX_CTRL_MAX_RD_CNT(3) |
  479. MCI_HB_CTRL_TX_CTRL_MAX_WR_CNT(3));
  480. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  481. MCI_INDIRECT_REG_CTRL_ADDR(
  482. MCI_HB_CTRL_TX_CTRL_REG_NUM) |
  483. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB) |
  484. MCI_INDIRECT_CTRL_LOCAL_PKT);
  485. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  486. /* CP AR & AW maximum AXI outstanding request cfg (HB_reg 0xd) */
  487. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  488. MCI_HB_CTRL_TX_CTRL_PRI_TH_QOS(8) |
  489. MCI_HB_CTRL_TX_CTRL_MAX_RD_CNT(0xB) |
  490. MCI_HB_CTRL_TX_CTRL_MAX_WR_CNT(0x11));
  491. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  492. MCI_INDIRECT_REG_CTRL_ADDR(
  493. MCI_HB_CTRL_TX_CTRL_REG_NUM) |
  494. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT) |
  495. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB));
  496. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  497. debug_exit();
  498. return ret;
  499. }
  500. /* configure MCI to allow read & write transactions to arrive at the same time.
  501. * Without the below configuration, MCI won't sent response to CPU for
  502. * transactions which arrived simultaneously and will lead to CPU hang.
  503. * The below will configure MCI to be able to pass transactions from/to CP/AP.
  504. */
  505. static int mci_enable_simultaneous_transactions(int mci_index)
  506. {
  507. uint32_t ret = 0;
  508. debug_enter();
  509. /* ID assignment (assigning global ID offset to CP) */
  510. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  511. MCI_DID_GLOBAL_ASSIGN_REQ_MCI_LOCAL_ID(2) |
  512. MCI_DID_GLOBAL_ASSIGN_REQ_MCI_COUNT(2) |
  513. MCI_DID_GLOBAL_ASSIGN_REQ_HOPS_NUM(2));
  514. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  515. MCI_INDIRECT_REG_CTRL_ADDR(
  516. MCI_DID_GLOBAL_ASSIGNMENT_REQUEST_REG) |
  517. MCI_INDIRECT_CTRL_ASSIGN_CMD);
  518. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  519. /* Assigning dest. ID=3 to all transactions entering from AXI at AP */
  520. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  521. MCI_HB_CTRL_WIN0_DEST_VALID_FLAG(1) |
  522. MCI_HB_CTRL_WIN0_DEST_ID(3));
  523. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  524. MCI_INDIRECT_REG_CTRL_ADDR(
  525. MCI_HB_CTRL_WIN0_DESTINATION_REG_NUM) |
  526. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB) |
  527. MCI_INDIRECT_CTRL_LOCAL_PKT);
  528. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  529. /* Assigning dest. ID=1 to all transactions entering from AXI at CP */
  530. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index),
  531. MCI_HB_CTRL_WIN0_DEST_VALID_FLAG(1) |
  532. MCI_HB_CTRL_WIN0_DEST_ID(1));
  533. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  534. MCI_INDIRECT_REG_CTRL_ADDR(
  535. MCI_HB_CTRL_WIN0_DESTINATION_REG_NUM) |
  536. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT) |
  537. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB));
  538. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  539. /* End address to all transactions entering from AXI at AP.
  540. * This will lead to get match for any AXI address
  541. * and receive destination ID=3
  542. */
  543. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index), 0xffffffff);
  544. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  545. MCI_INDIRECT_REG_CTRL_ADDR(
  546. MCI_HB_CTRL_WIN0_ADDRESS_MASK_REG_NUM) |
  547. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB) |
  548. MCI_INDIRECT_CTRL_LOCAL_PKT);
  549. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  550. /* End address to all transactions entering from AXI at CP.
  551. * This will lead to get match for any AXI address
  552. * and receive destination ID=1
  553. */
  554. mci_mmio_write_32(MCI_WRITE_READ_DATA_REG(mci_index), 0xffffffff);
  555. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  556. MCI_INDIRECT_REG_CTRL_ADDR(
  557. MCI_HB_CTRL_WIN0_ADDRESS_MASK_REG_NUM) |
  558. MCI_INDIRECT_CTRL_HOPID(GID_IHB_EXT) |
  559. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB));
  560. ret |= mci_poll_command_completion(mci_index, MCI_CMD_WRITE);
  561. debug_exit();
  562. return ret;
  563. }
  564. /* Check if MCI simultaneous transaction was already enabled.
  565. * Currently bootrom does this mci configuration only when the boot source is
  566. * SAR_MCIX4, in other cases it should be done at this stage.
  567. * It is worth noticing that in case of booting from uart, the bootrom
  568. * flow is different and this mci initialization is skipped even if boot
  569. * source is SAR_MCIX4. Therefore new verification bases on appropriate mci's
  570. * register content: if the appropriate reg contains 0x0 it means that the
  571. * bootrom didn't perform required mci configuration.
  572. *
  573. * Returns:
  574. * 0 - configuration already done
  575. * 1 - configuration missing
  576. */
  577. static _Bool mci_simulatenous_trans_missing(int mci_index)
  578. {
  579. uint32_t reg, ret;
  580. /* read 'Window 0 Destination ID assignment' from HB register 0x3
  581. * (TX_CFG_W0_DST_ID) to check whether ID assignment was already
  582. * performed by BootROM.
  583. */
  584. debug_enter();
  585. mci_mmio_write_32(MCI_ACCESS_CMD_REG(mci_index),
  586. MCI_INDIRECT_REG_CTRL_ADDR(
  587. MCI_HB_CTRL_WIN0_DESTINATION_REG_NUM) |
  588. MCI_INDIRECT_CTRL_HOPID(GID_AXI_HB) |
  589. MCI_INDIRECT_CTRL_LOCAL_PKT |
  590. MCI_INDIRECT_CTRL_READ_CMD);
  591. ret = mci_poll_command_completion(mci_index, MCI_CMD_READ);
  592. reg = mci_mmio_read_32(MCI_WRITE_READ_DATA_REG(mci_index));
  593. if (ret)
  594. ERROR("Failed to verify MCI simultaneous read/write status\n");
  595. debug_exit();
  596. /* default ID assignment is 0, so if register doesn't contain zeros
  597. * it means that bootrom already performed required configuration.
  598. */
  599. if (reg != 0)
  600. return 0;
  601. return 1;
  602. }
  603. /* For A1 revision, configure the MCI link for performance improvement:
  604. * - set MCI to support read/write transactions to arrive at the same time
  605. * - Switch AXI to PCIe mode
  606. * - Reduce sequence FIFO threshold
  607. * - Configure RX/TX FIFO thresholds
  608. *
  609. * Note:
  610. * We don't exit on error code from any sub routine, to try (best effort) to
  611. * complete the MCI configuration.
  612. * (If we exit - Bootloader will surely fail to boot)
  613. */
  614. int mci_configure(int mci_index)
  615. {
  616. int rval;
  617. debug_enter();
  618. /* According to design guidelines the MCI simultaneous transaction
  619. * shouldn't be enabled more then once - therefore make sure that it
  620. * wasn't already enabled in bootrom.
  621. */
  622. if (mci_simulatenous_trans_missing(mci_index)) {
  623. VERBOSE("Enabling MCI simultaneous transaction for mci%d\n",
  624. mci_index);
  625. /* set MCI to support read/write transactions
  626. * to arrive at the same time
  627. */
  628. rval = mci_enable_simultaneous_transactions(mci_index);
  629. if (rval)
  630. ERROR("Failed to set MCI simultaneous read/write\n");
  631. } else
  632. VERBOSE("Skip MCI ID assignment - already done by bootrom\n");
  633. /* Configure MCI for more consistent behavior with AXI protocol */
  634. rval = mci_axi_set_pcie_mode(mci_index);
  635. if (rval)
  636. ERROR("Failed to set MCI to AXI PCIe mode\n");
  637. /* reduce FIFO global threshold */
  638. rval = mci_axi_set_fifo_thresh(mci_index);
  639. if (rval)
  640. ERROR("Failed to set MCI FIFO global threshold\n");
  641. /* configure RX/TX FIFO thresholds */
  642. rval = mci_axi_set_fifo_rx_tx_thresh(mci_index);
  643. if (rval)
  644. ERROR("Failed to set MCI RX/TX FIFO threshold\n");
  645. debug_exit();
  646. return 1;
  647. }
  648. int mci_get_link_status(void)
  649. {
  650. uint32_t cmd, data;
  651. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_CTRL_STATUS_REG_NUM) |
  652. MCI_INDIRECT_CTRL_LOCAL_PKT | MCI_INDIRECT_CTRL_READ_CMD);
  653. if (mci_read(0, cmd, &data)) {
  654. ERROR("Failed to read status register\n");
  655. return -1;
  656. }
  657. /* Check if the link is ready */
  658. if (data != MCI_CTRL_PHY_READY) {
  659. ERROR("Bad link status %x\n", data);
  660. return -1;
  661. }
  662. return 0;
  663. }
  664. void mci_turn_link_down(void)
  665. {
  666. uint32_t cmd, data;
  667. int rval = 0;
  668. debug_enter();
  669. /* Turn off auto-link */
  670. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_CTRL_MCI_PHY_SETTINGS_REG_NUM) |
  671. MCI_INDIRECT_CTRL_LOCAL_PKT);
  672. data = (MCI_CTRL_MCI_PHY_SET_REG_DEF_VAL2 |
  673. MCI_CTRL_MCI_PHY_SET_AUTO_LINK_EN(0));
  674. rval = mci_write(0, cmd, data);
  675. if (rval)
  676. ERROR("Failed to turn off auto-link\n");
  677. /* Reset AP PHY */
  678. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_PHY_CTRL_REG_NUM) |
  679. MCI_INDIRECT_CTRL_LOCAL_PKT);
  680. data = (MCI_PHY_CTRL_MCI_MINOR |
  681. MCI_PHY_CTRL_MCI_MAJOR |
  682. MCI_PHY_CTRL_MCI_PHY_MODE_HOST |
  683. MCI_PHY_CTRL_MCI_PHY_RESET_CORE);
  684. rval = mci_write(0, cmd, data);
  685. if (rval)
  686. ERROR("Failed to reset AP PHY\n");
  687. /* Clear all status & CRC values */
  688. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_LINK_CRC_CTRL_REG_NUM) |
  689. MCI_INDIRECT_CTRL_LOCAL_PKT);
  690. data = 0x0;
  691. mci_write(0, cmd, data);
  692. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_CTRL_STATUS_REG_NUM) |
  693. MCI_INDIRECT_CTRL_LOCAL_PKT);
  694. data = 0x0;
  695. rval = mci_write(0, cmd, data);
  696. if (rval)
  697. ERROR("Failed to reset AP PHY\n");
  698. /* Wait 5ms before un-reset the PHY */
  699. mdelay(5);
  700. /* Un-reset AP PHY */
  701. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_PHY_CTRL_REG_NUM) |
  702. MCI_INDIRECT_CTRL_LOCAL_PKT);
  703. data = (MCI_PHY_CTRL_MCI_MINOR | MCI_PHY_CTRL_MCI_MAJOR |
  704. MCI_PHY_CTRL_MCI_PHY_MODE_HOST);
  705. rval = mci_write(0, cmd, data);
  706. if (rval)
  707. ERROR("Failed to un-reset AP PHY\n");
  708. debug_exit();
  709. }
  710. void mci_turn_link_on(void)
  711. {
  712. uint32_t cmd, data;
  713. int rval = 0;
  714. debug_enter();
  715. /* Turn on auto-link */
  716. cmd = (MCI_INDIRECT_REG_CTRL_ADDR(MCI_CTRL_MCI_PHY_SETTINGS_REG_NUM) |
  717. MCI_INDIRECT_CTRL_LOCAL_PKT);
  718. data = (MCI_CTRL_MCI_PHY_SET_REG_DEF_VAL2 |
  719. MCI_CTRL_MCI_PHY_SET_AUTO_LINK_EN(1));
  720. rval = mci_write(0, cmd, data);
  721. if (rval)
  722. ERROR("Failed to turn on auto-link\n");
  723. debug_exit();
  724. }
  725. /* Initialize MCI for performance improvements */
  726. int mci_link_tune(int mci_index)
  727. {
  728. int ret;
  729. debug_enter();
  730. INFO("MCI%d initialization:\n", mci_index);
  731. ret = mci_configure(mci_index);
  732. debug_exit();
  733. return ret;
  734. }