cdns_combo_phy.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /*
  2. * Copyright (c) 2022-2023, Intel Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef CDN_COMBOPHY_H
  7. #define CDN_COMBOPHY_H
  8. /* SRS */
  9. #define SDMMC_CDN_SRS02 0x8
  10. #define SDMMC_CDN_SRS03 0xC
  11. #define SDMMC_CDN_SRS04 0x10
  12. #define SDMMC_CDN_SRS05 0x14
  13. #define SDMMC_CDN_SRS06 0x18
  14. #define SDMMC_CDN_SRS07 0x1C
  15. #define SDMMC_CDN_SRS09 0x24
  16. #define SDMMC_CDN_SRS10 0x28
  17. #define SDMMC_CDN_SRS11 0x2C
  18. #define SDMMC_CDN_SRS12 0x30
  19. #define SDMMC_CDN_SRS13 0x34
  20. #define SDMMC_CDN_SRS14 0x38
  21. /* SRS03 */
  22. /* Response Type Select
  23. * Defines the expected response length.
  24. */
  25. #define SDMMC_CDN_RTS 16
  26. /* Command CRC Check Enable
  27. * When set to 1, the host checks if the CRC field of the response is valid.
  28. * When 0, the CRC check is disabled and the CRC field of the response is ignored.
  29. */
  30. #define SDMMC_CDN_CRCCE 19
  31. /* Command Index
  32. * This field contains a command number (index) of the command to be sent.
  33. */
  34. #define SDMMC_CDN_CIDX 24
  35. /* SRS09 */
  36. /* Card Inserted
  37. * Indicates if the card is inserted inside the slot.
  38. */
  39. #define SDMMC_CDN_CI 16
  40. /* SRS10 */
  41. /* Data Transfer Width
  42. * Bit used to configure DAT bus width to 1 or 4.
  43. */
  44. #define SDMMC_CDN_DTW 1
  45. /* Extended Data Transfer Width
  46. * This bit is to enable/disable 8-bit DAT bus width mode.
  47. */
  48. #define SDMMC_CDN_EDTW 5
  49. /* SD Bus Power for VDD1
  50. * When set to 1, the VDD1 voltage is supplied to card/device.
  51. */
  52. #define SDMMC_CDN_BP 8
  53. /* SD Bus Voltage Select
  54. * This field is used to configure VDD1 voltage level.
  55. */
  56. #define SDMMC_CDN_BVS 9
  57. /* SRS11 */
  58. /* Internal Clock Enable
  59. * This field is designated to controls (enable/disable) external clock generator.
  60. */
  61. #define SDMMC_CDN_ICE 0
  62. /* Internal Clock Stable
  63. * When 1, indicates that the clock on sdmclk pin of the host is stable.
  64. * When 0, indicates that the clock is not stable .
  65. */
  66. #define SDMMC_CDN_ICS 1
  67. /* SD Clock Enable
  68. * When set, SDCLK clock is enabled.
  69. * When clear, SDCLK clock is stopped.
  70. */
  71. #define SDMMC_CDN_SDCE 2
  72. /* USDCLK Frequency Select
  73. * This is used to calculate frequency of USDCLK clock.
  74. */
  75. #define SDMMC_CDN_USDCLKFS 6
  76. /* SDCLK Frequency Select
  77. * This is used to calculate frequency of SDCLK clock.
  78. */
  79. #define SDMMC_CDN_SDCLKFS 8
  80. /* Data Timeout Counter Value
  81. * This value determines the interval by which DAT line timeouts are detected
  82. */
  83. #define SDMMC_CDN_DTCV 16
  84. /* SRS12 */
  85. /* Command Complete
  86. * Generated when the end bit of the response is received.
  87. */
  88. #define SDMMC_CDN_CC 0
  89. /* Transfer Complete
  90. * Generated when the transfer which uses the DAT line is complete.
  91. */
  92. #define SDMMC_CDN_TC 1
  93. /* Error Interrupt
  94. * The software can check for an error by reading this single bit first.
  95. */
  96. #define SDMMC_CDN_EINT 15
  97. /* SRS14 */
  98. /* Command Complete Interrupt Enable */
  99. #define SDMMC_CDN_CC_IE 0
  100. /* Transfer Complete Interrupt Enable */
  101. #define SDMMC_CDN_TC_IE 1
  102. /* DMA Interrupt Enable */
  103. #define SDMMC_CDN_DMAINT_IE 3
  104. /* Combo PHY DLL registers */
  105. #define CP_DLL_REG_BASE (0x10B92000)
  106. #define CP_DLL_DQ_TIMING_REG (0x00)
  107. #define CP_DLL_DQS_TIMING_REG (0x04)
  108. #define CP_DLL_GATE_LPBK_CTRL_REG (0x08)
  109. #define CP_DLL_MASTER_CTRL_REG (0x0C)
  110. #define CP_DLL_SLAVE_CTRL_REG (0x10)
  111. #define CP_DLL_IE_TIMING_REG (0x14)
  112. #define CP_DQ_TIMING_REG_SDR (0x00000002)
  113. #define CP_DQS_TIMING_REG_SDR (0x00100004)
  114. #define CP_GATE_LPBK_CTRL_REG_SDR (0x00D80000)
  115. #define CP_DLL_MASTER_CTRL_REG_SDR (0x00800000)
  116. #define CP_DLL_SLAVE_CTRL_REG_SDR (0x00000000)
  117. #define CP_DLL(_reg) (CP_DLL_REG_BASE \
  118. + (CP_DLL_##_reg))
  119. /* Control Timing Block registers */
  120. #define CP_CTB_REG_BASE (0x10B92080)
  121. #define CP_CTB_CTRL_REG (0x00)
  122. #define CP_CTB_TSEL_REG (0x04)
  123. #define CP_CTB_GPIO_CTRL0 (0x08)
  124. #define CP_CTB_GPIO_CTRL1 (0x0C)
  125. #define CP_CTB_GPIO_STATUS0 (0x10)
  126. #define CP_CTB_GPIO_STATUS1 (0x14)
  127. #define CP_CTRL_REG_SDR (0x00004040)
  128. #define CP_TSEL_REG_SDR (0x00000000)
  129. #define CP_CTB(_reg) (CP_CTB_REG_BASE \
  130. + (CP_CTB_##_reg))
  131. /* Combo PHY */
  132. #define SDMMC_CDN_REG_BASE 0x10808200
  133. #define PHY_DQ_TIMING_REG 0x2000
  134. #define PHY_DQS_TIMING_REG 0x2004
  135. #define PHY_GATE_LPBK_CTRL_REG 0x2008
  136. #define PHY_DLL_MASTER_CTRL_REG 0x200C
  137. #define PHY_DLL_SLAVE_CTRL_REG 0x2010
  138. #define PHY_CTRL_REG 0x2080
  139. #define PHY_REG_ADDR_MASK 0xFFFF
  140. #define PHY_REG_DATA_MASK 0xFFFFFFFF
  141. /* PHY_DQS_TIMING_REG */
  142. #define CP_USE_EXT_LPBK_DQS(x) ((x) << 22) //0x1
  143. #define CP_USE_LPBK_DQS(x) ((x) << 21) //0x1
  144. #define CP_USE_PHONY_DQS(x) ((x) << 20) //0x1
  145. #define CP_USE_PHONY_DQS_CMD(x) ((x) << 19) //0x1
  146. /* PHY_GATE_LPBK_CTRL_REG */
  147. #define CP_SYNC_METHOD(x) ((x) << 31) //0x1
  148. #define CP_SW_HALF_CYCLE_SHIFT(x) ((x) << 28) //0x1
  149. #define CP_RD_DEL_SEL(x) ((x) << 19) //0x3f
  150. #define CP_UNDERRUN_SUPPRESS(x) ((x) << 18) //0x1
  151. #define CP_GATE_CFG_ALWAYS_ON(x) ((x) << 6) //0x1
  152. /* PHY_DLL_MASTER_CTRL_REG */
  153. #define CP_DLL_BYPASS_MODE(x) ((x) << 23) //0x1
  154. #define CP_DLL_START_POINT(x) ((x) << 0) //0xff
  155. /* PHY_DLL_SLAVE_CTRL_REG */
  156. #define CP_READ_DQS_CMD_DELAY(x) ((x) << 24) //0xff
  157. #define CP_CLK_WRDQS_DELAY(x) ((x) << 16) //0xff
  158. #define CP_CLK_WR_DELAY(x) ((x) << 8) //0xff
  159. #define CP_READ_DQS_DELAY(x) ((x) << 0) //0xff
  160. /* PHY_DQ_TIMING_REG */
  161. #define CP_IO_MASK_ALWAYS_ON(x) ((x) << 31) //0x1
  162. #define CP_IO_MASK_END(x) ((x) << 27) //0x7
  163. #define CP_IO_MASK_START(x) ((x) << 24) //0x7
  164. #define CP_DATA_SELECT_OE_END(x) ((x) << 0) //0x7
  165. /* PHY_CTRL_REG */
  166. #define CP_PHONY_DQS_TIMING_MASK 0x3F
  167. #define CP_PHONY_DQS_TIMING_SHIFT 4
  168. /* Shared Macros */
  169. #define SDMMC_CDN(_reg) (SDMMC_CDN_REG_BASE + \
  170. (SDMMC_CDN_##_reg))
  171. struct cdns_sdmmc_combo_phy {
  172. uint32_t cp_clk_wr_delay;
  173. uint32_t cp_clk_wrdqs_delay;
  174. uint32_t cp_data_select_oe_end;
  175. uint32_t cp_dll_bypass_mode;
  176. uint32_t cp_dll_locked_mode;
  177. uint32_t cp_dll_start_point;
  178. uint32_t cp_gate_cfg_always_on;
  179. uint32_t cp_io_mask_always_on;
  180. uint32_t cp_io_mask_end;
  181. uint32_t cp_io_mask_start;
  182. uint32_t cp_rd_del_sel;
  183. uint32_t cp_read_dqs_cmd_delay;
  184. uint32_t cp_read_dqs_delay;
  185. uint32_t cp_sw_half_cycle_shift;
  186. uint32_t cp_sync_method;
  187. uint32_t cp_underrun_suppress;
  188. uint32_t cp_use_ext_lpbk_dqs;
  189. uint32_t cp_use_lpbk_dqs;
  190. uint32_t cp_use_phony_dqs;
  191. uint32_t cp_use_phony_dqs_cmd;
  192. };
  193. /* Function Prototype */
  194. int cdns_sdmmc_write_phy_reg(uint32_t phy_reg_addr, uint32_t phy_reg_addr_value,
  195. uint32_t phy_reg_data, uint32_t phy_reg_data_value);
  196. int cdns_sd_card_detect(void);
  197. int cdns_emmc_card_reset(void);
  198. #endif