phy-qcom-ufs-qmp-20nm.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. * Copyright (c) 2013-2015, Linux Foundation. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 and
  6. * only version 2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #ifndef UFS_QCOM_PHY_QMP_20NM_H_
  15. #define UFS_QCOM_PHY_QMP_20NM_H_
  16. #include "phy-qcom-ufs-i.h"
  17. /* QCOM UFS PHY control registers */
  18. #define COM_OFF(x) (0x000 + x)
  19. #define PHY_OFF(x) (0xC00 + x)
  20. #define TX_OFF(n, x) (0x400 + (0x400 * n) + x)
  21. #define RX_OFF(n, x) (0x600 + (0x400 * n) + x)
  22. /* UFS PHY PLL block registers */
  23. #define QSERDES_COM_SYS_CLK_CTRL COM_OFF(0x0)
  24. #define QSERDES_COM_PLL_VCOTAIL_EN COM_OFF(0x04)
  25. #define QSERDES_COM_PLL_CNTRL COM_OFF(0x14)
  26. #define QSERDES_COM_PLL_IP_SETI COM_OFF(0x24)
  27. #define QSERDES_COM_CORE_CLK_IN_SYNC_SEL COM_OFF(0x28)
  28. #define QSERDES_COM_BIAS_EN_CLKBUFLR_EN COM_OFF(0x30)
  29. #define QSERDES_COM_PLL_CP_SETI COM_OFF(0x34)
  30. #define QSERDES_COM_PLL_IP_SETP COM_OFF(0x38)
  31. #define QSERDES_COM_PLL_CP_SETP COM_OFF(0x3C)
  32. #define QSERDES_COM_SYSCLK_EN_SEL_TXBAND COM_OFF(0x48)
  33. #define QSERDES_COM_RESETSM_CNTRL COM_OFF(0x4C)
  34. #define QSERDES_COM_RESETSM_CNTRL2 COM_OFF(0x50)
  35. #define QSERDES_COM_PLLLOCK_CMP1 COM_OFF(0x90)
  36. #define QSERDES_COM_PLLLOCK_CMP2 COM_OFF(0x94)
  37. #define QSERDES_COM_PLLLOCK_CMP3 COM_OFF(0x98)
  38. #define QSERDES_COM_PLLLOCK_CMP_EN COM_OFF(0x9C)
  39. #define QSERDES_COM_BGTC COM_OFF(0xA0)
  40. #define QSERDES_COM_DEC_START1 COM_OFF(0xAC)
  41. #define QSERDES_COM_PLL_AMP_OS COM_OFF(0xB0)
  42. #define QSERDES_COM_RES_CODE_UP_OFFSET COM_OFF(0xD8)
  43. #define QSERDES_COM_RES_CODE_DN_OFFSET COM_OFF(0xDC)
  44. #define QSERDES_COM_DIV_FRAC_START1 COM_OFF(0x100)
  45. #define QSERDES_COM_DIV_FRAC_START2 COM_OFF(0x104)
  46. #define QSERDES_COM_DIV_FRAC_START3 COM_OFF(0x108)
  47. #define QSERDES_COM_DEC_START2 COM_OFF(0x10C)
  48. #define QSERDES_COM_PLL_RXTXEPCLK_EN COM_OFF(0x110)
  49. #define QSERDES_COM_PLL_CRCTRL COM_OFF(0x114)
  50. #define QSERDES_COM_PLL_CLKEPDIV COM_OFF(0x118)
  51. /* TX LANE n (0, 1) registers */
  52. #define QSERDES_TX_EMP_POST1_LVL(n) TX_OFF(n, 0x08)
  53. #define QSERDES_TX_DRV_LVL(n) TX_OFF(n, 0x0C)
  54. #define QSERDES_TX_LANE_MODE(n) TX_OFF(n, 0x54)
  55. /* RX LANE n (0, 1) registers */
  56. #define QSERDES_RX_CDR_CONTROL1(n) RX_OFF(n, 0x0)
  57. #define QSERDES_RX_CDR_CONTROL_HALF(n) RX_OFF(n, 0x8)
  58. #define QSERDES_RX_RX_EQ_GAIN1_LSB(n) RX_OFF(n, 0xA8)
  59. #define QSERDES_RX_RX_EQ_GAIN1_MSB(n) RX_OFF(n, 0xAC)
  60. #define QSERDES_RX_RX_EQ_GAIN2_LSB(n) RX_OFF(n, 0xB0)
  61. #define QSERDES_RX_RX_EQ_GAIN2_MSB(n) RX_OFF(n, 0xB4)
  62. #define QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2(n) RX_OFF(n, 0xBC)
  63. #define QSERDES_RX_CDR_CONTROL_QUARTER(n) RX_OFF(n, 0xC)
  64. #define QSERDES_RX_SIGDET_CNTRL(n) RX_OFF(n, 0x100)
  65. /* UFS PHY registers */
  66. #define UFS_PHY_PHY_START PHY_OFF(0x00)
  67. #define UFS_PHY_POWER_DOWN_CONTROL PHY_OFF(0x4)
  68. #define UFS_PHY_TX_LANE_ENABLE PHY_OFF(0x44)
  69. #define UFS_PHY_PWM_G1_CLK_DIVIDER PHY_OFF(0x08)
  70. #define UFS_PHY_PWM_G2_CLK_DIVIDER PHY_OFF(0x0C)
  71. #define UFS_PHY_PWM_G3_CLK_DIVIDER PHY_OFF(0x10)
  72. #define UFS_PHY_PWM_G4_CLK_DIVIDER PHY_OFF(0x14)
  73. #define UFS_PHY_CORECLK_PWM_G1_CLK_DIVIDER PHY_OFF(0x34)
  74. #define UFS_PHY_CORECLK_PWM_G2_CLK_DIVIDER PHY_OFF(0x38)
  75. #define UFS_PHY_CORECLK_PWM_G3_CLK_DIVIDER PHY_OFF(0x3C)
  76. #define UFS_PHY_CORECLK_PWM_G4_CLK_DIVIDER PHY_OFF(0x40)
  77. #define UFS_PHY_OMC_STATUS_RDVAL PHY_OFF(0x68)
  78. #define UFS_PHY_LINE_RESET_TIME PHY_OFF(0x28)
  79. #define UFS_PHY_LINE_RESET_GRANULARITY PHY_OFF(0x2C)
  80. #define UFS_PHY_TSYNC_RSYNC_CNTL PHY_OFF(0x48)
  81. #define UFS_PHY_PLL_CNTL PHY_OFF(0x50)
  82. #define UFS_PHY_TX_LARGE_AMP_DRV_LVL PHY_OFF(0x54)
  83. #define UFS_PHY_TX_SMALL_AMP_DRV_LVL PHY_OFF(0x5C)
  84. #define UFS_PHY_TX_LARGE_AMP_POST_EMP_LVL PHY_OFF(0x58)
  85. #define UFS_PHY_TX_SMALL_AMP_POST_EMP_LVL PHY_OFF(0x60)
  86. #define UFS_PHY_CFG_CHANGE_CNT_VAL PHY_OFF(0x64)
  87. #define UFS_PHY_RX_SYNC_WAIT_TIME PHY_OFF(0x6C)
  88. #define UFS_PHY_TX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xB4)
  89. #define UFS_PHY_RX_MIN_SLEEP_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xE0)
  90. #define UFS_PHY_TX_MIN_STALL_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xB8)
  91. #define UFS_PHY_RX_MIN_STALL_NOCONFIG_TIME_CAPABILITY PHY_OFF(0xE4)
  92. #define UFS_PHY_TX_MIN_SAVE_CONFIG_TIME_CAPABILITY PHY_OFF(0xBC)
  93. #define UFS_PHY_RX_MIN_SAVE_CONFIG_TIME_CAPABILITY PHY_OFF(0xE8)
  94. #define UFS_PHY_RX_PWM_BURST_CLOSURE_LENGTH_CAPABILITY PHY_OFF(0xFC)
  95. #define UFS_PHY_RX_MIN_ACTIVATETIME_CAPABILITY PHY_OFF(0x100)
  96. #define UFS_PHY_RX_SIGDET_CTRL3 PHY_OFF(0x14c)
  97. #define UFS_PHY_RMMI_ATTR_CTRL PHY_OFF(0x160)
  98. #define UFS_PHY_RMMI_RX_CFGUPDT_L1 (1 << 7)
  99. #define UFS_PHY_RMMI_TX_CFGUPDT_L1 (1 << 6)
  100. #define UFS_PHY_RMMI_CFGWR_L1 (1 << 5)
  101. #define UFS_PHY_RMMI_CFGRD_L1 (1 << 4)
  102. #define UFS_PHY_RMMI_RX_CFGUPDT_L0 (1 << 3)
  103. #define UFS_PHY_RMMI_TX_CFGUPDT_L0 (1 << 2)
  104. #define UFS_PHY_RMMI_CFGWR_L0 (1 << 1)
  105. #define UFS_PHY_RMMI_CFGRD_L0 (1 << 0)
  106. #define UFS_PHY_RMMI_ATTRID PHY_OFF(0x164)
  107. #define UFS_PHY_RMMI_ATTRWRVAL PHY_OFF(0x168)
  108. #define UFS_PHY_RMMI_ATTRRDVAL_L0_STATUS PHY_OFF(0x16C)
  109. #define UFS_PHY_RMMI_ATTRRDVAL_L1_STATUS PHY_OFF(0x170)
  110. #define UFS_PHY_PCS_READY_STATUS PHY_OFF(0x174)
  111. #define UFS_PHY_TX_LANE_ENABLE_MASK 0x3
  112. /*
  113. * This structure represents the 20nm specific phy.
  114. * common_cfg MUST remain the first field in this structure
  115. * in case extra fields are added. This way, when calling
  116. * get_ufs_qcom_phy() of generic phy, we can extract the
  117. * common phy structure (struct ufs_qcom_phy) out of it
  118. * regardless of the relevant specific phy.
  119. */
  120. struct ufs_qcom_phy_qmp_20nm {
  121. struct ufs_qcom_phy common_cfg;
  122. };
  123. static struct ufs_qcom_phy_calibration phy_cal_table_rate_A_1_2_0[] = {
  124. UFS_QCOM_PHY_CAL_ENTRY(UFS_PHY_POWER_DOWN_CONTROL, 0x01),
  125. UFS_QCOM_PHY_CAL_ENTRY(UFS_PHY_RX_SIGDET_CTRL3, 0x0D),
  126. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_VCOTAIL_EN, 0xe1),
  127. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CRCTRL, 0xcc),
  128. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_SYSCLK_EN_SEL_TXBAND, 0x08),
  129. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CLKEPDIV, 0x03),
  130. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_RXTXEPCLK_EN, 0x10),
  131. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DEC_START1, 0x82),
  132. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DEC_START2, 0x03),
  133. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DIV_FRAC_START1, 0x80),
  134. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DIV_FRAC_START2, 0x80),
  135. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DIV_FRAC_START3, 0x40),
  136. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP1, 0xff),
  137. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP2, 0x19),
  138. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP3, 0x00),
  139. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP_EN, 0x03),
  140. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_RESETSM_CNTRL, 0x90),
  141. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_RESETSM_CNTRL2, 0x03),
  142. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL1(0), 0xf2),
  143. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_HALF(0), 0x0c),
  144. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_QUARTER(0), 0x12),
  145. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL1(1), 0xf2),
  146. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_HALF(1), 0x0c),
  147. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_QUARTER(1), 0x12),
  148. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_LSB(0), 0xff),
  149. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_MSB(0), 0xff),
  150. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_LSB(0), 0xff),
  151. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_MSB(0), 0x00),
  152. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_LSB(1), 0xff),
  153. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_MSB(1), 0xff),
  154. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_LSB(1), 0xff),
  155. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_MSB(1), 0x00),
  156. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CP_SETI, 0x3f),
  157. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_IP_SETP, 0x1b),
  158. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CP_SETP, 0x0f),
  159. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_IP_SETI, 0x01),
  160. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_EMP_POST1_LVL(0), 0x2F),
  161. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_DRV_LVL(0), 0x20),
  162. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_EMP_POST1_LVL(1), 0x2F),
  163. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_DRV_LVL(1), 0x20),
  164. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_LANE_MODE(0), 0x68),
  165. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_LANE_MODE(1), 0x68),
  166. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2(1), 0xdc),
  167. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2(0), 0xdc),
  168. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x3),
  169. };
  170. static struct ufs_qcom_phy_calibration phy_cal_table_rate_A_1_3_0[] = {
  171. UFS_QCOM_PHY_CAL_ENTRY(UFS_PHY_POWER_DOWN_CONTROL, 0x01),
  172. UFS_QCOM_PHY_CAL_ENTRY(UFS_PHY_RX_SIGDET_CTRL3, 0x0D),
  173. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_VCOTAIL_EN, 0xe1),
  174. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CRCTRL, 0xcc),
  175. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_SYSCLK_EN_SEL_TXBAND, 0x08),
  176. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CLKEPDIV, 0x03),
  177. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_RXTXEPCLK_EN, 0x10),
  178. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DEC_START1, 0x82),
  179. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DEC_START2, 0x03),
  180. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DIV_FRAC_START1, 0x80),
  181. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DIV_FRAC_START2, 0x80),
  182. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DIV_FRAC_START3, 0x40),
  183. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP1, 0xff),
  184. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP2, 0x19),
  185. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP3, 0x00),
  186. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP_EN, 0x03),
  187. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_RESETSM_CNTRL, 0x90),
  188. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_RESETSM_CNTRL2, 0x03),
  189. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL1(0), 0xf2),
  190. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_HALF(0), 0x0c),
  191. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_QUARTER(0), 0x12),
  192. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL1(1), 0xf2),
  193. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_HALF(1), 0x0c),
  194. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_CDR_CONTROL_QUARTER(1), 0x12),
  195. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_LSB(0), 0xff),
  196. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_MSB(0), 0xff),
  197. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_LSB(0), 0xff),
  198. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_MSB(0), 0x00),
  199. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_LSB(1), 0xff),
  200. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN1_MSB(1), 0xff),
  201. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_LSB(1), 0xff),
  202. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQ_GAIN2_MSB(1), 0x00),
  203. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CP_SETI, 0x2b),
  204. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_IP_SETP, 0x38),
  205. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CP_SETP, 0x3c),
  206. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_RES_CODE_UP_OFFSET, 0x02),
  207. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_RES_CODE_DN_OFFSET, 0x02),
  208. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_IP_SETI, 0x01),
  209. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLL_CNTRL, 0x40),
  210. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_LANE_MODE(0), 0x68),
  211. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_TX_LANE_MODE(1), 0x68),
  212. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2(1), 0xdc),
  213. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_RX_RX_EQU_ADAPTOR_CNTRL2(0), 0xdc),
  214. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_BIAS_EN_CLKBUFLR_EN, 0x3),
  215. };
  216. static struct ufs_qcom_phy_calibration phy_cal_table_rate_B[] = {
  217. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_DEC_START1, 0x98),
  218. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP1, 0x65),
  219. UFS_QCOM_PHY_CAL_ENTRY(QSERDES_COM_PLLLOCK_CMP2, 0x1e),
  220. };
  221. #endif