rts5227.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /* Driver for Realtek PCI-Express card reader
  3. *
  4. * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved.
  5. *
  6. * Author:
  7. * Wei WANG <wei_wang@realsil.com.cn>
  8. * Roger Tseng <rogerable@realtek.com>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/delay.h>
  12. #include <linux/rtsx_pci.h>
  13. #include "rtsx_pcr.h"
  14. static u8 rts5227_get_ic_version(struct rtsx_pcr *pcr)
  15. {
  16. u8 val;
  17. rtsx_pci_read_register(pcr, DUMMY_REG_RESET_0, &val);
  18. return val & 0x0F;
  19. }
  20. static void rts5227_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
  21. {
  22. u8 driving_3v3[4][3] = {
  23. {0x13, 0x13, 0x13},
  24. {0x96, 0x96, 0x96},
  25. {0x7F, 0x7F, 0x7F},
  26. {0x96, 0x96, 0x96},
  27. };
  28. u8 driving_1v8[4][3] = {
  29. {0x99, 0x99, 0x99},
  30. {0xAA, 0xAA, 0xAA},
  31. {0xFE, 0xFE, 0xFE},
  32. {0xB3, 0xB3, 0xB3},
  33. };
  34. u8 (*driving)[3], drive_sel;
  35. if (voltage == OUTPUT_3V3) {
  36. driving = driving_3v3;
  37. drive_sel = pcr->sd30_drive_sel_3v3;
  38. } else {
  39. driving = driving_1v8;
  40. drive_sel = pcr->sd30_drive_sel_1v8;
  41. }
  42. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CLK_DRIVE_SEL,
  43. 0xFF, driving[drive_sel][0]);
  44. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_CMD_DRIVE_SEL,
  45. 0xFF, driving[drive_sel][1]);
  46. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DAT_DRIVE_SEL,
  47. 0xFF, driving[drive_sel][2]);
  48. }
  49. static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr)
  50. {
  51. struct pci_dev *pdev = pcr->pci;
  52. u32 reg;
  53. pci_read_config_dword(pdev, PCR_SETTING_REG1, &reg);
  54. pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
  55. if (!rtsx_vendor_setting_valid(reg))
  56. return;
  57. pcr->aspm_en = rtsx_reg_to_aspm(reg);
  58. pcr->sd30_drive_sel_1v8 = rtsx_reg_to_sd30_drive_sel_1v8(reg);
  59. pcr->card_drive_sel &= 0x3F;
  60. pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
  61. pci_read_config_dword(pdev, PCR_SETTING_REG2, &reg);
  62. pcr_dbg(pcr, "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
  63. if (CHK_PCI_PID(pcr, 0x522A))
  64. pcr->rtd3_en = rtsx_reg_to_rtd3(reg);
  65. if (rtsx_check_mmc_support(reg))
  66. pcr->extra_caps |= EXTRA_CAPS_NO_MMC;
  67. pcr->sd30_drive_sel_3v3 = rtsx_reg_to_sd30_drive_sel_3v3(reg);
  68. if (rtsx_reg_check_reverse_socket(reg))
  69. pcr->flags |= PCR_REVERSE_SOCKET;
  70. if (rtsx_reg_check_cd_reverse(reg))
  71. pcr->option.sd_cd_reverse_en = 1;
  72. if (rtsx_reg_check_wp_reverse(reg))
  73. pcr->option.sd_wp_reverse_en = 1;
  74. }
  75. static void rts5227_init_from_cfg(struct rtsx_pcr *pcr)
  76. {
  77. struct rtsx_cr_option *option = &pcr->option;
  78. if (CHK_PCI_PID(pcr, 0x522A)) {
  79. if (rtsx_check_dev_flag(pcr, ASPM_L1_1_EN | ASPM_L1_2_EN
  80. | PM_L1_1_EN | PM_L1_2_EN))
  81. rtsx_pci_disable_oobs_polling(pcr);
  82. else
  83. rtsx_pci_enable_oobs_polling(pcr);
  84. }
  85. if (option->ltr_en) {
  86. if (option->ltr_enabled)
  87. rtsx_set_ltr_latency(pcr, option->ltr_active_latency);
  88. }
  89. }
  90. static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)
  91. {
  92. u16 cap;
  93. struct rtsx_cr_option *option = &pcr->option;
  94. rts5227_init_from_cfg(pcr);
  95. rtsx_pci_init_cmd(pcr);
  96. /* Configure GPIO as output */
  97. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, GPIO_CTL, 0x02, 0x02);
  98. /* Reset ASPM state to default value */
  99. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, ASPM_FORCE_CTL, 0x3F, 0);
  100. /* Switch LDO3318 source from DV33 to card_3v3 */
  101. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x00);
  102. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01);
  103. /* LED shine disabled, set initial shine cycle period */
  104. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02);
  105. /* Configure LTR */
  106. pcie_capability_read_word(pcr->pci, PCI_EXP_DEVCTL2, &cap);
  107. if (cap & PCI_EXP_DEVCTL2_LTR_EN)
  108. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LTR_CTL, 0xFF, 0xA3);
  109. /* Configure OBFF */
  110. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OBFF_CFG, 0x03, 0x03);
  111. /* Configure driving */
  112. rts5227_fill_driving(pcr, OUTPUT_3V3);
  113. /* Configure force_clock_req */
  114. if (pcr->flags & PCR_REVERSE_SOCKET)
  115. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x30, 0x30);
  116. else {
  117. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x20, option->sd_cd_reverse_en << 5);
  118. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0x10, option->sd_wp_reverse_en << 4);
  119. }
  120. if (CHK_PCI_PID(pcr, 0x522A))
  121. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, RTS522A_AUTOLOAD_CFG1,
  122. CD_RESUME_EN_MASK, CD_RESUME_EN_MASK);
  123. if (pcr->rtd3_en) {
  124. if (CHK_PCI_PID(pcr, 0x522A)) {
  125. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, RTS522A_PM_CTRL3, 0x01, 0x01);
  126. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, RTS522A_PME_FORCE_CTL, 0x30, 0x30);
  127. } else {
  128. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x01, 0x01);
  129. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PME_FORCE_CTL, 0xFF, 0x33);
  130. }
  131. } else {
  132. if (CHK_PCI_PID(pcr, 0x522A)) {
  133. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, RTS522A_PM_CTRL3, 0x01, 0x00);
  134. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, RTS522A_PME_FORCE_CTL, 0x30, 0x20);
  135. } else {
  136. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PME_FORCE_CTL, 0xFF, 0x30);
  137. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x01, 0x00);
  138. }
  139. }
  140. if (option->force_clkreq_0)
  141. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG,
  142. FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_LOW);
  143. else
  144. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG,
  145. FORCE_CLKREQ_DELINK_MASK, FORCE_CLKREQ_HIGH);
  146. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, pcr->reg_pm_ctrl3, 0x10, 0x00);
  147. return rtsx_pci_send_cmd(pcr, 100);
  148. }
  149. static int rts5227_optimize_phy(struct rtsx_pcr *pcr)
  150. {
  151. int err;
  152. err = rtsx_pci_write_register(pcr, PM_CTRL3, D3_DELINK_MODE_EN, 0x00);
  153. if (err < 0)
  154. return err;
  155. /* Optimize RX sensitivity */
  156. return rtsx_pci_write_phy_register(pcr, 0x00, 0xBA42);
  157. }
  158. static int rts5227_turn_on_led(struct rtsx_pcr *pcr)
  159. {
  160. return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x02);
  161. }
  162. static int rts5227_turn_off_led(struct rtsx_pcr *pcr)
  163. {
  164. return rtsx_pci_write_register(pcr, GPIO_CTL, 0x02, 0x00);
  165. }
  166. static int rts5227_enable_auto_blink(struct rtsx_pcr *pcr)
  167. {
  168. return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x08);
  169. }
  170. static int rts5227_disable_auto_blink(struct rtsx_pcr *pcr)
  171. {
  172. return rtsx_pci_write_register(pcr, OLT_LED_CTL, 0x08, 0x00);
  173. }
  174. static int rts5227_card_power_on(struct rtsx_pcr *pcr, int card)
  175. {
  176. int err;
  177. if (pcr->option.ocp_en)
  178. rtsx_pci_enable_ocp(pcr);
  179. rtsx_pci_init_cmd(pcr);
  180. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
  181. SD_POWER_MASK, SD_PARTIAL_POWER_ON);
  182. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
  183. LDO3318_PWR_MASK, 0x02);
  184. err = rtsx_pci_send_cmd(pcr, 100);
  185. if (err < 0)
  186. return err;
  187. /* To avoid too large in-rush current */
  188. msleep(20);
  189. rtsx_pci_init_cmd(pcr);
  190. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
  191. SD_POWER_MASK, SD_POWER_ON);
  192. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
  193. LDO3318_PWR_MASK, 0x06);
  194. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_OE,
  195. SD_OUTPUT_EN, SD_OUTPUT_EN);
  196. rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_OE,
  197. MS_OUTPUT_EN, MS_OUTPUT_EN);
  198. return rtsx_pci_send_cmd(pcr, 100);
  199. }
  200. static int rts5227_card_power_off(struct rtsx_pcr *pcr, int card)
  201. {
  202. if (pcr->option.ocp_en)
  203. rtsx_pci_disable_ocp(pcr);
  204. rtsx_pci_write_register(pcr, CARD_PWR_CTL, SD_POWER_MASK |
  205. PMOS_STRG_MASK, SD_POWER_OFF | PMOS_STRG_400mA);
  206. rtsx_pci_write_register(pcr, PWR_GATE_CTRL, LDO3318_PWR_MASK, 0X00);
  207. return 0;
  208. }
  209. static int rts5227_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
  210. {
  211. int err;
  212. if (voltage == OUTPUT_3V3) {
  213. err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
  214. if (err < 0)
  215. return err;
  216. } else if (voltage == OUTPUT_1V8) {
  217. err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02);
  218. if (err < 0)
  219. return err;
  220. err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C80 | 0x24);
  221. if (err < 0)
  222. return err;
  223. } else {
  224. return -EINVAL;
  225. }
  226. /* set pad drive */
  227. rtsx_pci_init_cmd(pcr);
  228. rts5227_fill_driving(pcr, voltage);
  229. return rtsx_pci_send_cmd(pcr, 100);
  230. }
  231. static const struct pcr_ops rts5227_pcr_ops = {
  232. .fetch_vendor_settings = rts5227_fetch_vendor_settings,
  233. .extra_init_hw = rts5227_extra_init_hw,
  234. .optimize_phy = rts5227_optimize_phy,
  235. .turn_on_led = rts5227_turn_on_led,
  236. .turn_off_led = rts5227_turn_off_led,
  237. .enable_auto_blink = rts5227_enable_auto_blink,
  238. .disable_auto_blink = rts5227_disable_auto_blink,
  239. .card_power_on = rts5227_card_power_on,
  240. .card_power_off = rts5227_card_power_off,
  241. .switch_output_voltage = rts5227_switch_output_voltage,
  242. .cd_deglitch = NULL,
  243. .conv_clk_and_div_n = NULL,
  244. };
  245. /* SD Pull Control Enable:
  246. * SD_DAT[3:0] ==> pull up
  247. * SD_CD ==> pull up
  248. * SD_WP ==> pull up
  249. * SD_CMD ==> pull up
  250. * SD_CLK ==> pull down
  251. */
  252. static const u32 rts5227_sd_pull_ctl_enable_tbl[] = {
  253. RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA),
  254. RTSX_REG_PAIR(CARD_PULL_CTL3, 0xE9),
  255. 0,
  256. };
  257. /* SD Pull Control Disable:
  258. * SD_DAT[3:0] ==> pull down
  259. * SD_CD ==> pull up
  260. * SD_WP ==> pull down
  261. * SD_CMD ==> pull down
  262. * SD_CLK ==> pull down
  263. */
  264. static const u32 rts5227_sd_pull_ctl_disable_tbl[] = {
  265. RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
  266. RTSX_REG_PAIR(CARD_PULL_CTL3, 0xD5),
  267. 0,
  268. };
  269. /* MS Pull Control Enable:
  270. * MS CD ==> pull up
  271. * others ==> pull down
  272. */
  273. static const u32 rts5227_ms_pull_ctl_enable_tbl[] = {
  274. RTSX_REG_PAIR(CARD_PULL_CTL5, 0x55),
  275. RTSX_REG_PAIR(CARD_PULL_CTL6, 0x15),
  276. 0,
  277. };
  278. /* MS Pull Control Disable:
  279. * MS CD ==> pull up
  280. * others ==> pull down
  281. */
  282. static const u32 rts5227_ms_pull_ctl_disable_tbl[] = {
  283. RTSX_REG_PAIR(CARD_PULL_CTL5, 0x55),
  284. RTSX_REG_PAIR(CARD_PULL_CTL6, 0x15),
  285. 0,
  286. };
  287. void rts5227_init_params(struct rtsx_pcr *pcr)
  288. {
  289. pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104;
  290. pcr->num_slots = 2;
  291. pcr->ops = &rts5227_pcr_ops;
  292. pcr->flags = 0;
  293. pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
  294. pcr->sd30_drive_sel_1v8 = CFG_DRIVER_TYPE_B;
  295. pcr->sd30_drive_sel_3v3 = CFG_DRIVER_TYPE_B;
  296. pcr->aspm_en = ASPM_L1_EN;
  297. pcr->aspm_mode = ASPM_MODE_CFG;
  298. pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15);
  299. pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7);
  300. pcr->ic_version = rts5227_get_ic_version(pcr);
  301. pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl;
  302. pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl;
  303. pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl;
  304. pcr->ms_pull_ctl_disable_tbl = rts5227_ms_pull_ctl_disable_tbl;
  305. pcr->reg_pm_ctrl3 = PM_CTRL3;
  306. pcr->option.sd_cd_reverse_en = 0;
  307. pcr->option.sd_wp_reverse_en = 0;
  308. }
  309. static int rts522a_optimize_phy(struct rtsx_pcr *pcr)
  310. {
  311. int err;
  312. err = rtsx_pci_write_register(pcr, RTS522A_PM_CTRL3, D3_DELINK_MODE_EN,
  313. 0x00);
  314. if (err < 0)
  315. return err;
  316. if (is_version(pcr, 0x522A, IC_VER_A)) {
  317. err = rtsx_pci_write_phy_register(pcr, PHY_RCR2,
  318. PHY_RCR2_INIT_27S);
  319. if (err)
  320. return err;
  321. rtsx_pci_write_phy_register(pcr, PHY_RCR1, PHY_RCR1_INIT_27S);
  322. rtsx_pci_write_phy_register(pcr, PHY_FLD0, PHY_FLD0_INIT_27S);
  323. rtsx_pci_write_phy_register(pcr, PHY_FLD3, PHY_FLD3_INIT_27S);
  324. rtsx_pci_write_phy_register(pcr, PHY_FLD4, PHY_FLD4_INIT_27S);
  325. }
  326. return 0;
  327. }
  328. static int rts522a_extra_init_hw(struct rtsx_pcr *pcr)
  329. {
  330. rts5227_extra_init_hw(pcr);
  331. /* Power down OCP for power consumption */
  332. if (!pcr->card_exist)
  333. rtsx_pci_write_register(pcr, FPDCTL, OC_POWER_DOWN,
  334. OC_POWER_DOWN);
  335. rtsx_pci_write_register(pcr, FUNC_FORCE_CTL, FUNC_FORCE_UPME_XMT_DBG,
  336. FUNC_FORCE_UPME_XMT_DBG);
  337. rtsx_pci_write_register(pcr, PCLK_CTL, 0x04, 0x04);
  338. rtsx_pci_write_register(pcr, PM_EVENT_DEBUG, PME_DEBUG_0, PME_DEBUG_0);
  339. rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 0xFF, 0x11);
  340. return 0;
  341. }
  342. static int rts522a_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
  343. {
  344. int err;
  345. if (voltage == OUTPUT_3V3) {
  346. err = rtsx_pci_write_phy_register(pcr, 0x08, 0x57E4);
  347. if (err < 0)
  348. return err;
  349. } else if (voltage == OUTPUT_1V8) {
  350. err = rtsx_pci_write_phy_register(pcr, 0x11, 0x3C02);
  351. if (err < 0)
  352. return err;
  353. err = rtsx_pci_write_phy_register(pcr, 0x08, 0x54A4);
  354. if (err < 0)
  355. return err;
  356. } else {
  357. return -EINVAL;
  358. }
  359. /* set pad drive */
  360. rtsx_pci_init_cmd(pcr);
  361. rts5227_fill_driving(pcr, voltage);
  362. return rtsx_pci_send_cmd(pcr, 100);
  363. }
  364. static void rts522a_force_power_down(struct rtsx_pcr *pcr, u8 pm_state, bool runtime)
  365. {
  366. /* Set relink_time to 0 */
  367. rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 1, MASK_8_BIT_DEF, 0);
  368. rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 2, MASK_8_BIT_DEF, 0);
  369. rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3,
  370. RELINK_TIME_MASK, 0);
  371. rtsx_pci_write_register(pcr, RTS522A_PM_CTRL3,
  372. D3_DELINK_MODE_EN, D3_DELINK_MODE_EN);
  373. if (!runtime) {
  374. rtsx_pci_write_register(pcr, RTS522A_AUTOLOAD_CFG1,
  375. CD_RESUME_EN_MASK, 0);
  376. rtsx_pci_write_register(pcr, RTS522A_PM_CTRL3, 0x01, 0x00);
  377. rtsx_pci_write_register(pcr, RTS522A_PME_FORCE_CTL, 0x30, 0x20);
  378. }
  379. rtsx_pci_write_register(pcr, FPDCTL, ALL_POWER_DOWN, ALL_POWER_DOWN);
  380. }
  381. static void rts522a_set_l1off_cfg_sub_d0(struct rtsx_pcr *pcr, int active)
  382. {
  383. struct rtsx_cr_option *option = &pcr->option;
  384. int aspm_L1_1, aspm_L1_2;
  385. u8 val = 0;
  386. aspm_L1_1 = rtsx_check_dev_flag(pcr, ASPM_L1_1_EN);
  387. aspm_L1_2 = rtsx_check_dev_flag(pcr, ASPM_L1_2_EN);
  388. if (active) {
  389. /* run, latency: 60us */
  390. if (aspm_L1_1)
  391. val = option->ltr_l1off_snooze_sspwrgate;
  392. } else {
  393. /* l1off, latency: 300us */
  394. if (aspm_L1_2)
  395. val = option->ltr_l1off_sspwrgate;
  396. }
  397. rtsx_set_l1off_sub(pcr, val);
  398. }
  399. /* rts522a operations mainly derived from rts5227, except phy/hw init setting.
  400. */
  401. static const struct pcr_ops rts522a_pcr_ops = {
  402. .fetch_vendor_settings = rts5227_fetch_vendor_settings,
  403. .extra_init_hw = rts522a_extra_init_hw,
  404. .optimize_phy = rts522a_optimize_phy,
  405. .turn_on_led = rts5227_turn_on_led,
  406. .turn_off_led = rts5227_turn_off_led,
  407. .enable_auto_blink = rts5227_enable_auto_blink,
  408. .disable_auto_blink = rts5227_disable_auto_blink,
  409. .card_power_on = rts5227_card_power_on,
  410. .card_power_off = rts5227_card_power_off,
  411. .switch_output_voltage = rts522a_switch_output_voltage,
  412. .force_power_down = rts522a_force_power_down,
  413. .cd_deglitch = NULL,
  414. .conv_clk_and_div_n = NULL,
  415. .set_l1off_cfg_sub_d0 = rts522a_set_l1off_cfg_sub_d0,
  416. };
  417. void rts522a_init_params(struct rtsx_pcr *pcr)
  418. {
  419. struct rtsx_cr_option *option = &pcr->option;
  420. rts5227_init_params(pcr);
  421. pcr->ops = &rts522a_pcr_ops;
  422. pcr->aspm_mode = ASPM_MODE_REG;
  423. pcr->tx_initial_phase = SET_CLOCK_PHASE(20, 20, 11);
  424. pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3;
  425. option->dev_flags = LTR_L1SS_PWR_GATE_EN;
  426. option->ltr_en = true;
  427. /* init latency of active, idle, L1OFF to 60us, 300us, 3ms */
  428. option->ltr_active_latency = LTR_ACTIVE_LATENCY_DEF;
  429. option->ltr_idle_latency = LTR_IDLE_LATENCY_DEF;
  430. option->ltr_l1off_latency = LTR_L1OFF_LATENCY_DEF;
  431. option->l1_snooze_delay = L1_SNOOZE_DELAY_DEF;
  432. option->ltr_l1off_sspwrgate = 0x7F;
  433. option->ltr_l1off_snooze_sspwrgate = 0x78;
  434. pcr->option.ocp_en = 1;
  435. if (pcr->option.ocp_en)
  436. pcr->hw_param.interrupt_en |= SD_OC_INT_EN;
  437. pcr->hw_param.ocp_glitch = SD_OCP_GLITCH_10M;
  438. pcr->option.sd_800mA_ocp_thd = RTS522A_OCP_THD_800;
  439. }