mt_ssusbphy.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /*
  2. * Copyright (c) 2012 MediaTek Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining
  5. * a copy of this software and associated documentation files
  6. * (the "Software"), to deal in the Software without restriction,
  7. * including without limitation the rights to use, copy, modify, merge,
  8. * publish, distribute, sublicense, and/or sell copies of the Software,
  9. * and to permit persons to whom the Software is furnished to do so,
  10. * subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  19. * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  20. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  21. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #include <reg.h>
  24. #include <platform/bitops.h>
  25. #include <platform/mt_reg_base.h>
  26. #include <platform/mt_typedefs.h>
  27. #include <platform/timer.h>
  28. #include <mt_ssusb.h>
  29. #include <mt_ssusbphy.h>
  30. #include <mt_ssusb_sifslv_ippc.h>
  31. #if defined(CONFIG_D60802_SUPPORT)
  32. #include <mt_usbphy_d60802.h>
  33. #elif defined(CONFIG_E60802_SUPPORT)
  34. #include <mt_usbphy_e60802.h>
  35. #elif defined(CONFIG_A60810_SUPPORT)
  36. #include <mt_usbphy_a60810.h>
  37. #endif
  38. /* for usb phy */
  39. #include <mt_i2c.h>
  40. #include <mt_ssusb_usb3_mac_csr.h>
  41. #ifdef MACH_FPGA
  42. #define CFG_FPGA_PLATFORM (1)
  43. #else
  44. #define DBG_PHY_CALIBRATION 1
  45. #endif
  46. /* used by phy scan */
  47. #define CONFIG_U3_PHY_GPIO_SUPPORT
  48. #define USB11PHY_READ8(offset) readb(USB11_PHY_BASE + offset)
  49. #define USB11PHY_WRITE8(offset, value) writeb(value, USB11_PHY_BASE+offset)
  50. #define USB11PHY_SET8(offset, mask) USB11PHY_WRITE8(offset, USB11PHY_READ8(offset) | mask)
  51. #define USB11PHY_CLR8(offset, mask) USB11PHY_WRITE8(offset, USB11PHY_READ8(offset) & ~mask)
  52. #define SSUSB_PHY_BASE (SSUSB_SIFSLV_IPPC_BASE)
  53. //#define USB20_PHY_BASE (USBSIF_BASE + 0x0800)
  54. #define USB11_PHY_BASE (USBSIF_BASE + 0x0900)
  55. #define PERI_GLOBALCON_PDN0_SET (PERICFG_BASE+0x008)
  56. #define USB0_PDN 1 << 10
  57. extern void mu3d_hal_ssusb_en(void);
  58. extern void mu3d_hal_rst_dev(void);
  59. #define USB_I2C_ID I2C1 /* 0 - 6 */
  60. #define PATH_NORMAL 0
  61. #define PATH_PMIC 1
  62. #define U3_PHY_PAGE 0xff
  63. #define I2C_CHIP 0xc0
  64. #ifdef DBG_USB_PHY
  65. #define PHY_LOG(x...) dprintf(INFO, "[USB][PHY] " x)
  66. #else
  67. #define PHY_LOG(x...) do{} while(0)
  68. #endif
  69. #define ENTER_U0_TH 5
  70. #define MAX_PHASE_RANGE 31
  71. #define MAX_TIMEOUT_COUNT 100
  72. #define DATA_DRIVING_MASK 0x06
  73. #define MAX_DRIVING_RANGE 0x04
  74. #define MAX_LATCH_SELECT 0x02
  75. #define U3_PHY_I2C_PCLK_DRV_REG 0x0A
  76. #define U3_PHY_I2C_PCLK_PHASE_REG 0x0B
  77. #define STATE_U0_STATE (13)
  78. #define CLR_RECOV_CNT (0x1 << 16) /* 16:16 */
  79. #define CLR_LINK_ERR_CNT (0x1 << 16) /* 16:16 */
  80. #define STATE_DISABLE (1)
  81. #if CFG_FPGA_PLATFORM
  82. static struct mt_i2c_t usb_i2c;
  83. #define U3_PHY_I2C_DEV 0x60
  84. static u32 usb_i2c_read8(u8 addr, u8 *databuffer)
  85. {
  86. u32 ret_code = I2C_OK;
  87. u16 len;
  88. *databuffer = addr;
  89. usb_i2c.id = USB_I2C_ID;
  90. /* Since i2c will left shift 1 bit, we need to set USB I2C address to 0x60 (0xC0>>1) */
  91. usb_i2c.addr = 0x60;
  92. usb_i2c.mode = ST_MODE;
  93. usb_i2c.speed = 100;
  94. len = 1;
  95. ret_code = i2c_write_read(&usb_i2c, databuffer, len, len);
  96. return ret_code;
  97. }
  98. static u32 usb_i2c_write8(u8 addr, u8 value)
  99. {
  100. u32 ret_code = I2C_OK;
  101. u8 write_data[2];
  102. u16 len;
  103. write_data[0]= addr;
  104. write_data[1] = value;
  105. usb_i2c.id = USB_I2C_ID;
  106. /* Since i2c will left shift 1 bit, we need to set USB I2C address to 0x60 (0xC0>>1) */
  107. usb_i2c.addr = 0x60;
  108. usb_i2c.mode = ST_MODE;
  109. usb_i2c.speed = 100;
  110. len = 2;
  111. ret_code = i2c_write(&usb_i2c, write_data, len);
  112. return ret_code;
  113. }
  114. static void _u3_write_bank(u32 value)
  115. {
  116. usb_i2c_write8((u8)U3_PHY_PAGE, (u8)value);
  117. }
  118. static u32 _u3_read_reg(u32 address)
  119. {
  120. u8 databuffer = 0;
  121. usb_i2c_read8((u8)address, &databuffer);
  122. return databuffer;
  123. }
  124. static void _u3_write_reg(u32 address, u32 value)
  125. {
  126. usb_i2c_write8((u8 )address, (u8 )value);
  127. }
  128. u32 u3_phy_read_reg32(u32 addr)
  129. {
  130. u32 bank;
  131. u32 addr8;
  132. u32 data;
  133. bank = (addr >> 16) & 0xff;
  134. addr8 = addr & 0xff;
  135. _u3_write_bank(bank);
  136. data = _u3_read_reg(addr8);
  137. data |= (_u3_read_reg(addr8 + 1) << 8);
  138. data |= (_u3_read_reg(addr8 + 2) << 16);
  139. data |= (_u3_read_reg(addr8 + 3) << 24);
  140. return data;
  141. }
  142. u32 u3_phy_write_reg32(u32 addr, u32 data)
  143. {
  144. u32 bank;
  145. u32 addr8;
  146. u32 data_0, data_1, data_2, data_3;
  147. bank = (addr >> 16) & 0xff;
  148. addr8 = addr & 0xff;
  149. data_0 = data & 0xff;
  150. data_1 = (data >> 8) & 0xff;
  151. data_2 = (data >> 16) & 0xff;
  152. data_3 = (data >> 24) & 0xff;
  153. _u3_write_bank(bank);
  154. _u3_write_reg(addr8, data_0);
  155. _u3_write_reg(addr8 + 1, data_1);
  156. _u3_write_reg(addr8 + 2, data_2);
  157. _u3_write_reg(addr8 + 3, data_3);
  158. return 0;
  159. }
  160. void u3_phy_write_field32(int addr, int offset, int mask, int value)
  161. {
  162. u32 cur_value;
  163. u32 new_value;
  164. cur_value = u3_phy_read_reg32(addr);
  165. new_value = (cur_value & (~mask)) | ((value << offset) & mask);
  166. //udelay(i2cdelayus);
  167. u3_phy_write_reg32(addr, new_value);
  168. }
  169. u32 u3_phy_write_reg8(u32 addr, u8 data)
  170. {
  171. u32 bank;
  172. u32 addr8;
  173. PHY_LOG("addr8: %x\n", addr);
  174. bank = (addr >> 16) & 0xff;
  175. addr8 = addr & 0xff;
  176. _u3_write_bank(bank);
  177. _u3_write_reg(addr8, data);
  178. return 0;
  179. }
  180. char u3_phy_read_reg8(u32 addr)
  181. {
  182. int bank;
  183. int addr8;
  184. int data;
  185. bank = (addr >> 16) & 0xff;
  186. addr8 = addr & 0xff;
  187. _u3_write_bank(bank);
  188. data = _u3_read_reg(addr8);
  189. return data;
  190. }
  191. static void mu3d_hal_pdn_dis(void)
  192. {
  193. clrbits(U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
  194. #ifdef SUPPORT_U3
  195. clrbits(U3D_SSUSB_U3_CTRL_0P, (SSUSB_U3_PORT_DIS | SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_U2_CG_EN));
  196. #endif
  197. clrbits(U3D_SSUSB_U2_CTRL_0P, (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | SSUSB_U2_PORT_U2_CG_EN));
  198. }
  199. int mu3d_hal_phy_scan(struct u3phy_info *u3phy, int latch_val)
  200. {
  201. #ifdef CONFIG_U3_PHY_GPIO_SUPPORT
  202. int count, fset_phase_val, u0_count;
  203. u8 phase_val, driving;
  204. //temp, data_driving_val, clk_driving_val;
  205. #ifdef DBG_USB_PHY
  206. int link_error_count, recov_cnt;
  207. #endif
  208. /* disable ip power down,disable U2/U3 ip power down. */
  209. mu3d_hal_ssusb_en();
  210. mu3d_hal_pdn_dis();
  211. #if defined(CONFIG_D60802_SUPPORT)
  212. phy_change_pipe_phase_d60802(u3phy, 0, 0);
  213. #elif defined(CONFIG_E60802_SUPPORT)
  214. phy_change_pipe_phase_e60802(u3phy, 0, 0);
  215. #endif
  216. writel(latch_val, U3D_PIPE_LATCH_SELECT); /* set tx/rx latch sel */
  217. driving = 2;
  218. #if defined(CONFIG_D60802_SUPPORT)
  219. phy_change_pipe_phase_d60802(u3phy, driving, driving);
  220. #elif defined(CONFIG_E60802_SUPPORT)
  221. phy_change_pipe_phase_e60802(u3phy, driving, driving);
  222. #endif
  223. phase_val = 0;
  224. count = 0;
  225. fset_phase_val = TRUE;
  226. while (TRUE) {
  227. if (fset_phase_val) {
  228. #if defined(CONFIG_D60802_SUPPORT)
  229. phy_change_pipe_phase_d60802(u3phy, driving, phase_val);
  230. #elif defined(CONFIG_E60802_SUPPORT)
  231. phy_change_pipe_phase_e60802(u3phy, driving, phase_val);
  232. #endif
  233. mu3d_hal_rst_dev();
  234. mdelay(50);
  235. writel(USB3_EN, U3D_USB3_CONFIG);
  236. writel(latch_val, U3D_PIPE_LATCH_SELECT); /* set tx/rx latch sel */
  237. fset_phase_val = FALSE;
  238. u0_count = 0;
  239. #ifdef DBG_USB_PHY
  240. link_error_count = 0;
  241. recov_cnt = 0;
  242. #endif
  243. count = 0;
  244. }
  245. mdelay(50);
  246. count++;
  247. #ifdef DBG_USB_PHY
  248. /* read U0 recovery count */
  249. recov_cnt = readl(U3D_RECOVERY_COUNT);
  250. /* read link error count */
  251. link_error_count = readl(U3D_LINK_ERR_COUNT);
  252. #endif
  253. /* enter U0 state */
  254. if ((readl(U3D_LINK_STATE_MACHINE) & LTSSM) == STATE_U0_STATE) {
  255. u0_count++;
  256. }
  257. /* link up */
  258. if (u0_count > ENTER_U0_TH) {
  259. mdelay(1000);//1s
  260. #ifdef DBG_USB_PHY
  261. recov_cnt = readl(U3D_RECOVERY_COUNT);
  262. link_error_count = readl(U3D_LINK_ERR_COUNT);
  263. #endif
  264. writel(CLR_RECOV_CNT, U3D_RECOVERY_COUNT); /* clear recovery count */
  265. writel(CLR_LINK_ERR_CNT, U3D_LINK_ERR_COUNT); /* clear link error count */
  266. #ifdef DBG_USB_PHY
  267. PHY_LOG("[PASS] Link Error Count=%d, Recovery Count=%d, I2C(0x%x) : [0x%x], I2C(0x%x) : [0x%x], Reg(0x130) : [0x%x], PhaseDelay[0x%x], Driving[0x%x], Latch[0x%x]\n",
  268. link_error_count, recov_cnt,
  269. U3_PHY_I2C_PCLK_DRV_REG, _u3_read_reg(U3_PHY_I2C_PCLK_DRV_REG),
  270. U3_PHY_I2C_PCLK_PHASE_REG, _u3_read_reg(U3_PHY_I2C_PCLK_PHASE_REG),
  271. readl(U3D_PIPE_LATCH_SELECT),
  272. phase_val, driving, latch_val);
  273. #endif
  274. phase_val++;
  275. fset_phase_val = TRUE;
  276. } else if ((readl(U3D_LINK_STATE_MACHINE) & LTSSM) == STATE_DISABLE) { /* link fail */
  277. PHY_LOG("[FAIL] STATE_DISABLE, PhaseDelay[0x%x]\n", phase_val);
  278. phase_val++;
  279. fset_phase_val=TRUE;
  280. } else if (count > MAX_TIMEOUT_COUNT) { /* link timeout */
  281. PHY_LOG("[FAIL] TIMEOUT, PhaseDelay[0x%x]\n", phase_val);
  282. phase_val++;
  283. fset_phase_val = TRUE;
  284. }
  285. if (phase_val > MAX_PHASE_RANGE) {
  286. /* reset device */
  287. mu3d_hal_rst_dev();
  288. mdelay(50);
  289. /* disable ip power down, disable U2/U3 ip power down. */
  290. mu3d_hal_ssusb_en();
  291. mu3d_hal_pdn_dis();
  292. mdelay(10);
  293. break;
  294. }
  295. }
  296. #endif /* CONFIG_U3_PHY_GPIO_SUPPORT */
  297. return 0;
  298. }
  299. void mt_usb_phy_poweron(void)
  300. {
  301. static struct u3phy_info info;
  302. #ifdef DBG_USB_PHY
  303. volatile u32 u3phy_version;
  304. #endif
  305. info.phyd_version_addr = 0x2000e4;
  306. #ifdef DBG_USB_PHY
  307. u3phy_version = u3_phy_read_reg32(info.phyd_version_addr);
  308. PHY_LOG("[USBPHY] Phy version is %x\n", u3phy_version);
  309. #endif
  310. #if defined(CONFIG_D60802_SUPPORT)
  311. info.u2phy_regs_d = (struct u2phy_reg_d *)0x0;
  312. info.u3phyd_regs_d = (struct u3phyd_reg_d *)0x100000;
  313. info.u3phyd_bank2_regs_d = (struct u3phyd_bank2_reg_d *)0x200000;
  314. info.u3phya_regs_d = (struct u3phya_reg_d *)0x300000;
  315. info.u3phya_da_regs_d = (struct u3phya_da_reg_d *)0x400000;
  316. info.sifslv_chip_regs_d = (struct sifslv_chip_reg_d *)0x500000;
  317. info.sifslv_fm_regs_d = (struct sifslv_fm_feg_d *)0xf00000;
  318. phy_init_d60802(&info);
  319. #elif defined(CONFIG_E60802_SUPPORT)
  320. info.u2phy_regs_e = (struct u2phy_reg_e *)0x0;
  321. info.u3phyd_regs_e = (struct u3phyd_reg_e *)0x100000;
  322. info.u3phyd_bank2_regs_e = (struct u3phyd_bank2_reg_e *)0x200000;
  323. info.u3phya_regs_e = (struct u3phya_reg_e *)0x300000;
  324. info.u3phya_da_regs_e = (struct u3phya_da_reg_e *)0x400000;
  325. info.sifslv_chip_regs_e = (struct sifslv_chip_reg_e *)0x500000;
  326. info.sifslv_fm_regs_e = (struct sifslv_fm_feg_e *)0xf00000;
  327. phy_init_e60802(&info);
  328. #endif
  329. /* for RF desense */
  330. #if defined(CONFIG_D60802_SUPPORT)
  331. //u2_slew_rate_calibration_d60802(&info);
  332. #elif defined(CONFIG_E60802_SUPPORT)
  333. //u2_slew_rate_calibration_e60802(&info);
  334. #endif
  335. mu3d_hal_ssusb_en();
  336. mu3d_hal_rst_dev();
  337. }
  338. void mt_usb_phy_savecurrent(void)
  339. {
  340. }
  341. void mt_usb_phy_recover(void)
  342. {
  343. }
  344. void mt_usb11_phy_savecurrent(void)
  345. {
  346. }
  347. #else
  348. //#include <platform/project.h>
  349. void switch_2_usb()
  350. {
  351. clrbits(U3D_U2PHYDTM0, A60810_FORCE_UART_EN);
  352. clrbits(U3D_U2PHYDTM1, A60810_RG_UART_EN);
  353. clrbits(U3D_U2PHYACR4, A60810_RG_USB20_GPIO_CTL);
  354. clrbits(U3D_U2PHYACR4, A60810_USB20_GPIO_MODE);
  355. }
  356. void mt_usb_phy_poweron(void)
  357. {
  358. /* 5, power domain iso disable */
  359. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_ISO_EN);
  360. /* 6, switch to USB function */
  361. switch_2_usb();
  362. /* 7, DP/DM BC1.1 path Disable */
  363. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_BC11_SW_EN);
  364. /* 8, dp_100k diable */
  365. clrbits(U3D_USBPHYACR4, A60810_USB20_DP_100K_EN);
  366. /* 9, dm_100k disable */
  367. clrbits(U3D_USBPHYACR4, A60810_RG_USB20_DM_100K_EN);
  368. /* 10, Change 100uA current switch to SSUSB */
  369. setbits(U3D_USBPHYACR5, A60810_RG_USB20_HS_100U_U3_EN);
  370. /* 11, OTG enable */
  371. setbits(U3D_USBPHYACR6, A60810_RG_USB20_OTG_VBUSCMP_EN);
  372. /* 12, Release force suspendm */
  373. clrbits(U3D_U2PHYDTM0, A60810_FORCE_SUSPENDM);
  374. }
  375. void mt_usb_phy_savecurrent(void)
  376. {
  377. /* 1, switch to usb function */
  378. switch_2_usb();
  379. /* 2, let syspendm=1 */
  380. setbits(U3D_U2PHYDTM0, A60810_RG_SUSPENDM);
  381. /* 3, force_suspendm */
  382. setbits(U3D_U2PHYDTM0, A60810_FORCE_SUSPENDM);
  383. /* 4 wait for USBPLL stable */
  384. mdelay(2);
  385. /* 5 */
  386. setbits(U3D_U2PHYDTM0, A60810_RG_DPPULLDOWN);
  387. /* 6 */
  388. setbits(U3D_U2PHYDTM0, A60810_RG_DMPULLDOWN);
  389. /* 7 */
  390. writel((readl(U3D_U2PHYDTM0) & ~A60810_RG_XCVRSEL) | (0x1 << A60810_RG_XCVRSEL_OFST), U3D_U2PHYDTM0);
  391. /* 8 */
  392. setbits(U3D_U2PHYDTM0, A60810_RG_TERMSEL);
  393. /* 9 */
  394. clrbits(U3D_U2PHYDTM0, A60810_RG_DATAIN);
  395. /* 10 */
  396. setbits(U3D_U2PHYDTM0, A60810_FORCE_DP_PULLDOWN);
  397. /* 11 */
  398. setbits(U3D_U2PHYDTM0, A60810_FORCE_DM_PULLDOWN);
  399. /* 12 */
  400. setbits(U3D_U2PHYDTM0, A60810_FORCE_XCVRSEL);
  401. /* 13 */
  402. setbits(U3D_U2PHYDTM0, A60810_FORCE_TERMSEL);
  403. /* 14 */
  404. setbits(U3D_U2PHYDTM0, A60810_FORCE_DATAIN);
  405. /* 15, DP/DM BC1.1 path Disable */
  406. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_BC11_SW_EN);
  407. /* 16, OTG disable */
  408. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_OTG_VBUSCMP_EN);
  409. /* 17, Change 100uA current switch to USB2.0 */
  410. clrbits(U3D_USBPHYACR5, A60810_RG_USB20_HS_100U_U3_EN);
  411. /* 18, wait 800us */
  412. mdelay(1);
  413. /* 19 */
  414. clrbits(U3D_U2PHYDTM0, A60810_RG_SUSPENDM);
  415. /* 20, wait 1us */
  416. mdelay(1);
  417. clrbits(U3D_USB30_PHYA_REG0, RG_SSUSB_VUSB10_ON);
  418. }
  419. void setting_ref_clk_e60802(void)
  420. {
  421. u32 val;
  422. /*
  423. * Reference clock use digital P&R, instead of analog path
  424. * possibly more interference
  425. * ---------REG Name---------- | -----Modification---| -----Description----
  426. * DA_SSUSB_XTAL_EXT_EN[1:0] | 2'b01-->2'b10 | 0x11290c00 bit[11:10]
  427. * DA_SSUSB_XTAL_RX_PWD[9:9] | -->1'b1 | 0x11280018 bit[9]
  428. */
  429. val = readl(U3D_U3PHYA_DA_REG0) & ~A60810_RG_SSUSB_XTAL_EXT_EN_U3;
  430. val |= ((0x2) << A60810_RG_SSUSB_XTAL_EXT_EN_U3_OFST) & A60810_RG_SSUSB_XTAL_EXT_EN_U3;
  431. writel(val, U3D_U3PHYA_DA_REG0);
  432. val = readl(U3D_SPLLC_XTALCTL3) & ~A60810_RG_SSUSB_XTAL_RX_PWD;
  433. val |= ((0x01) << A60810_RG_SSUSB_XTAL_RX_PWD_OFST) & A60810_RG_SSUSB_XTAL_RX_PWD;
  434. writel(val, U3D_SPLLC_XTALCTL3);
  435. /*
  436. * ---------REG Name---------- | -----Modification---| -----Description----
  437. * 1 RG_SSUSB_TX_EIDLE_CM[3:0] | 1100-->1110 | low-power E-idle common mode(650mV to 600mV)
  438. * | | - 0x11290b18 bit [31:28]
  439. * 2 RG_SSUSB_CDR_BIR_LTD0[4:0]| 5'b01000-->5'b01100 | Increase BW - 0x1128095c bit [12:8]
  440. * 3 RG_XXX_CDR_BIR_LTD1[4:0] | 5'b00010-->5'b00011 | Increase BW - 0x1128095c bit [28:24]
  441. */
  442. val = readl(U3D_USB30_PHYA_REG6) & ~A60810_RG_SSUSB_TX_EIDLE_CM;
  443. val |= ((0xE) << A60810_RG_SSUSB_TX_EIDLE_CM_OFST) & A60810_RG_SSUSB_TX_EIDLE_CM;
  444. writel(val, U3D_USB30_PHYA_REG6);
  445. val = readl(U3D_PHYD_CDR1) & ~A60810_RG_SSUSB_CDR_BIR_LTD0;
  446. val |= ((0xC) << A60810_RG_SSUSB_CDR_BIR_LTD0_OFST) & A60810_RG_SSUSB_CDR_BIR_LTD0;
  447. writel(val, U3D_PHYD_CDR1);
  448. val = readl(U3D_PHYD_CDR1) & ~A60810_RG_SSUSB_CDR_BIR_LTD1;
  449. val |= ((0x3) << A60810_RG_SSUSB_CDR_BIR_LTD1_OFST) & A60810_RG_SSUSB_CDR_BIR_LTD1;
  450. writel(val, U3D_PHYD_CDR1);
  451. }
  452. void mt_usb_phy_recover(void)
  453. {
  454. #if (MACH_TYPE == 6755)
  455. setbits(U3D_USB30_PHYA_REG0, RG_SSUSB_VUSB10_ON);
  456. #endif
  457. /* 4, power domain iso disable */
  458. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_ISO_EN);
  459. /* 5, switch to usb function */
  460. switch_2_usb();
  461. /* 6, force_suspendm */
  462. clrbits(U3D_U2PHYDTM0, A60810_FORCE_SUSPENDM);
  463. /* 7 */
  464. clrbits(U3D_U2PHYDTM0, A60810_RG_DPPULLDOWN);
  465. /* 8 */
  466. clrbits(U3D_U2PHYDTM0, A60810_RG_DMPULLDOWN);
  467. /* 9 */
  468. clrbits(U3D_U2PHYDTM0, A60810_RG_XCVRSEL);
  469. /* 10 */
  470. clrbits(U3D_U2PHYDTM0, A60810_FORCE_TERMSEL);
  471. /* 11 */
  472. clrbits(U3D_U2PHYDTM0, A60810_RG_DATAIN);
  473. /* 12 */
  474. clrbits(U3D_U2PHYDTM0, A60810_FORCE_DP_PULLDOWN);
  475. /* 13 */
  476. clrbits(U3D_U2PHYDTM0, A60810_FORCE_DM_PULLDOWN);
  477. /* 14 */
  478. clrbits(U3D_U2PHYDTM0, A60810_FORCE_XCVRSEL);
  479. /* 15 */
  480. clrbits(U3D_U2PHYDTM0, A60810_FORCE_TERMSEL);
  481. /* 16 */
  482. clrbits(U3D_U2PHYDTM0, A60810_FORCE_DATAIN);
  483. /* 17, DP/DM BC1.1 path Disable */
  484. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_BC11_SW_EN);
  485. /* 18, OTG enable */
  486. setbits(U3D_USBPHYACR6, A60810_RG_USB20_OTG_VBUSCMP_EN);
  487. #if (MACH_TYPE == 6755)
  488. /* 19, Change 100uA current switch to SSUSB */
  489. setbits(U3D_USBPHYACR5, A60810_RG_USB20_HS_100U_U3_EN);
  490. #endif
  491. setting_ref_clk_e60802();
  492. /* 20, wait 800us */
  493. mdelay(1);
  494. }
  495. #endif