mt_ssusbphy.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  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. #if defined(SUPPORT_U3) && defined(HAS_REDRIVER)
  47. #include <platform/mt_gpio.h>
  48. #endif
  49. /* used by phy scan */
  50. #define CONFIG_U3_PHY_GPIO_SUPPORT
  51. #define USB11PHY_READ8(offset) readb(USB11_PHY_BASE + offset)
  52. #define USB11PHY_WRITE8(offset, value) writeb(value, USB11_PHY_BASE+offset)
  53. #define USB11PHY_SET8(offset, mask) USB11PHY_WRITE8(offset, USB11PHY_READ8(offset) | mask)
  54. #define USB11PHY_CLR8(offset, mask) USB11PHY_WRITE8(offset, USB11PHY_READ8(offset) & ~mask)
  55. #define SSUSB_PHY_BASE (SSUSB_SIFSLV_IPPC_BASE)
  56. //#define USB20_PHY_BASE (USBSIF_BASE + 0x0800)
  57. #define USB11_PHY_BASE (USBSIF_BASE + 0x0900)
  58. #define PERI_GLOBALCON_PDN0_SET (PERICFG_BASE+0x008)
  59. #define USB0_PDN 1 << 10
  60. extern void mu3d_hal_ssusb_en(void);
  61. extern void mu3d_hal_rst_dev(void);
  62. #define USB_I2C_ID I2C1 /* 0 - 6 */
  63. #define PATH_NORMAL 0
  64. #define PATH_PMIC 1
  65. #define U3_PHY_PAGE 0xff
  66. #define I2C_CHIP 0xc0
  67. #ifdef DBG_USB_PHY
  68. #define PHY_LOG(x...) dprintf(INFO, "[USB][PHY] " x)
  69. #else
  70. #define PHY_LOG(x...) do{} while(0)
  71. #endif
  72. #define ENTER_U0_TH 5
  73. #define MAX_PHASE_RANGE 31
  74. #define MAX_TIMEOUT_COUNT 100
  75. #define DATA_DRIVING_MASK 0x06
  76. #define MAX_DRIVING_RANGE 0x04
  77. #define MAX_LATCH_SELECT 0x02
  78. #define U3_PHY_I2C_PCLK_DRV_REG 0x0A
  79. #define U3_PHY_I2C_PCLK_PHASE_REG 0x0B
  80. #define STATE_U0_STATE (13)
  81. #define CLR_RECOV_CNT (0x1 << 16) /* 16:16 */
  82. #define CLR_LINK_ERR_CNT (0x1 << 16) /* 16:16 */
  83. #define STATE_DISABLE (1)
  84. #if CFG_FPGA_PLATFORM
  85. #define USE_USB_I2C
  86. #ifdef USE_USB_I2C
  87. /* TEST CHIP PHY define, edit this in different platform */
  88. #define U3_PHY_I2C_DEV 0x60
  89. #define U3_PHY_PAGE 0xff
  90. #define _GPIO_BASE USB3_SIF_BASE+0x700 //0xf0044700 //0x80080000
  91. #define SSUSB_I2C_OUT _GPIO_BASE+0xd0
  92. #define SSUSB_I2C_IN _GPIO_BASE+0xd4
  93. /////////////////////////////////////////////////////////////////
  94. #define OUTPUT 1
  95. #define INPUT 0
  96. #define SDA 0 /// GPIO #0: I2C data pin
  97. #define SCL 1 /// GPIO #1: I2C clock pin
  98. /////////////////////////////////////////////////////////////////
  99. #define SDA_OUT (1<<0)
  100. #define SDA_OEN (1<<1)
  101. #define SCL_OUT (1<<2)
  102. #define SCL_OEN (1<<3)
  103. #define SDA_IN_OFFSET 0
  104. #define SCL_IN_OFFSET 1
  105. //#define GPIO_PULLEN1_SET (GPIO_BASE+0x0030+0x04)
  106. //#define GPIO_DIR1_SET (GPIO_BASE+0x0000+0x04)
  107. //#define GPIO_PULLEN1_CLR (GPIO_BASE+0x0030+0x08)
  108. //#define GPIO_DIR1_CLR (GPIO_BASE+0x0000+0x08)
  109. //#define GPIO_DOUT1_SET (GPIO_BASE+0x00C0+0x04)
  110. //#define GPIO_DOUT1_CLR (GPIO_BASE+0x00C0+0x08)
  111. //#define GPIO_DIN1 (GPIO_BASE+0x00F0)
  112. void gpio_dir_set(u32 pin)
  113. {
  114. u32 temp;
  115. u32 addr;
  116. addr = SSUSB_I2C_OUT;
  117. temp = DRV_Reg32(addr);
  118. if (pin == SDA) {
  119. temp |= SDA_OEN;
  120. DRV_WriteReg32(addr,temp);
  121. } else {
  122. temp |= SCL_OEN;
  123. DRV_WriteReg32(addr,temp);
  124. }
  125. }
  126. void gpio_dir_clr(u32 pin)
  127. {
  128. u32 temp;
  129. u32 addr;
  130. addr = SSUSB_I2C_OUT;
  131. temp = DRV_Reg32(addr);
  132. if (pin == SDA) {
  133. temp &= ~SDA_OEN;
  134. DRV_WriteReg32(addr,temp);
  135. } else {
  136. temp &= ~SCL_OEN;
  137. DRV_WriteReg32(addr,temp);
  138. }
  139. }
  140. void gpio_dout_set(u32 pin)
  141. {
  142. u32 temp;
  143. u32 addr;
  144. addr = SSUSB_I2C_OUT;
  145. temp = DRV_Reg32(addr);
  146. if (pin == SDA) {
  147. temp |= SDA_OUT;
  148. DRV_WriteReg32(addr,temp);
  149. } else {
  150. temp |= SCL_OUT;
  151. DRV_WriteReg32(addr,temp);
  152. }
  153. }
  154. void gpio_dout_clr(u32 pin)
  155. {
  156. u32 temp;
  157. u32 addr;
  158. addr = SSUSB_I2C_OUT;
  159. temp = DRV_Reg32(addr);
  160. if (pin == SDA) {
  161. temp &= ~SDA_OUT;
  162. DRV_WriteReg32(addr,temp);
  163. } else {
  164. temp &= ~SCL_OUT;
  165. DRV_WriteReg32(addr,temp);
  166. }
  167. }
  168. u32 gpio_din(u32 pin)
  169. {
  170. u32 temp;
  171. u32 addr;
  172. addr = SSUSB_I2C_IN;
  173. temp = DRV_Reg32(addr);
  174. if (pin == SDA) {
  175. temp = (temp >> SDA_IN_OFFSET) & 1;
  176. } else {
  177. temp = (temp >> SCL_IN_OFFSET) & 1;
  178. }
  179. return temp;
  180. }
  181. //#define GPIO_PULLEN_SET(_no) (GPIO_PULLEN1_SET+(0x10*(_no)))
  182. #define GPIO_DIR_SET(pin) gpio_dir_set(pin)
  183. #define GPIO_DOUT_SET(pin) gpio_dout_set(pin);
  184. //#define GPIO_PULLEN_CLR(_no) (GPIO_PULLEN1_CLR+(0x10*(_no)))
  185. #define GPIO_DIR_CLR(pin) gpio_dir_clr(pin)
  186. #define GPIO_DOUT_CLR(pin) gpio_dout_clr(pin)
  187. #define GPIO_DIN(pin) gpio_din(pin)
  188. u32 i2c_dummy_cnt;
  189. #define I2C_DELAY 10
  190. #define I2C_DUMMY_DELAY(_delay) for (i2c_dummy_cnt = ((_delay)) ; i2c_dummy_cnt!=0; i2c_dummy_cnt--)
  191. void GPIO_InitIO(u32 dir, u32 pin)
  192. {
  193. if (dir == OUTPUT) {
  194. // DRV_WriteReg16(GPIO_PULLEN_SET(no),(1 << remainder));
  195. GPIO_DIR_SET(pin);
  196. } else {
  197. // DRV_WriteReg16(GPIO_PULLEN_CLR(no),(1 << remainder));
  198. GPIO_DIR_CLR(pin);
  199. }
  200. I2C_DUMMY_DELAY(100);
  201. }
  202. void GPIO_WriteIO(u32 data, u32 pin)
  203. {
  204. if (data == 1) {
  205. GPIO_DOUT_SET(pin);
  206. } else {
  207. GPIO_DOUT_CLR(pin);
  208. }
  209. }
  210. u32 GPIO_ReadIO( u32 pin)
  211. {
  212. u16 data;
  213. data=GPIO_DIN(pin);
  214. return (u32)data;
  215. }
  216. void SerialCommStop(void)
  217. {
  218. GPIO_InitIO(OUTPUT,SDA);
  219. GPIO_WriteIO(0,SCL);
  220. I2C_DUMMY_DELAY(I2C_DELAY);
  221. GPIO_WriteIO(0,SDA);
  222. I2C_DUMMY_DELAY(I2C_DELAY);
  223. GPIO_WriteIO(1,SCL);
  224. I2C_DUMMY_DELAY(I2C_DELAY);
  225. GPIO_WriteIO(1,SDA);
  226. I2C_DUMMY_DELAY(I2C_DELAY);
  227. GPIO_InitIO(INPUT,SCL);
  228. GPIO_InitIO(INPUT,SDA);
  229. }
  230. void SerialCommStart(void) /* Prepare the SDA and SCL for sending/receiving */
  231. {
  232. GPIO_InitIO(OUTPUT,SCL);
  233. GPIO_InitIO(OUTPUT,SDA);
  234. GPIO_WriteIO(1,SDA);
  235. I2C_DUMMY_DELAY(I2C_DELAY);
  236. GPIO_WriteIO(1,SCL);
  237. I2C_DUMMY_DELAY(I2C_DELAY);
  238. GPIO_WriteIO(0,SDA);
  239. I2C_DUMMY_DELAY(I2C_DELAY);
  240. GPIO_WriteIO(0,SCL);
  241. I2C_DUMMY_DELAY(I2C_DELAY);
  242. }
  243. u32 SerialCommTxByte(u8 data) /* return 0 --> ack */
  244. {
  245. u32 i, ack;
  246. GPIO_InitIO(OUTPUT,SDA);
  247. for (i=8; --i>0;) {
  248. GPIO_WriteIO((data>>i)&0x01, SDA);
  249. I2C_DUMMY_DELAY(I2C_DELAY);
  250. GPIO_WriteIO( 1, SCL); /* high */
  251. I2C_DUMMY_DELAY(I2C_DELAY);
  252. GPIO_WriteIO( 0, SCL); /* low */
  253. I2C_DUMMY_DELAY(I2C_DELAY);
  254. }
  255. GPIO_WriteIO((data>>i)&0x01, SDA);
  256. I2C_DUMMY_DELAY(I2C_DELAY);
  257. GPIO_WriteIO( 1, SCL); /* high */
  258. I2C_DUMMY_DELAY(I2C_DELAY);
  259. GPIO_WriteIO( 0, SCL); /* low */
  260. I2C_DUMMY_DELAY(I2C_DELAY);
  261. GPIO_WriteIO(0, SDA);
  262. I2C_DUMMY_DELAY(I2C_DELAY);
  263. GPIO_InitIO(INPUT,SDA);
  264. I2C_DUMMY_DELAY(I2C_DELAY);
  265. GPIO_WriteIO(1, SCL);
  266. I2C_DUMMY_DELAY(I2C_DELAY);
  267. ack = GPIO_ReadIO(SDA); /// ack 1: error , 0:ok
  268. GPIO_WriteIO(0, SCL);
  269. I2C_DUMMY_DELAY(I2C_DELAY);
  270. if (ack==1)
  271. return FALSE;
  272. else
  273. return TRUE;
  274. }
  275. void SerialCommRxByte(u8 *data, u8 ack)
  276. {
  277. S32 i;
  278. u32 dataCache;
  279. dataCache = 0;
  280. GPIO_InitIO(INPUT,SDA);
  281. for (i=8; --i>=0;) {
  282. dataCache <<= 1;
  283. I2C_DUMMY_DELAY(I2C_DELAY);
  284. GPIO_WriteIO(1, SCL);
  285. I2C_DUMMY_DELAY(I2C_DELAY);
  286. dataCache |= GPIO_ReadIO(SDA);
  287. GPIO_WriteIO(0, SCL);
  288. I2C_DUMMY_DELAY(I2C_DELAY);
  289. }
  290. GPIO_InitIO(OUTPUT,SDA);
  291. GPIO_WriteIO(ack, SDA);
  292. I2C_DUMMY_DELAY(I2C_DELAY);
  293. GPIO_WriteIO(1, SCL);
  294. I2C_DUMMY_DELAY(I2C_DELAY);
  295. GPIO_WriteIO(0, SCL);
  296. I2C_DUMMY_DELAY(I2C_DELAY);
  297. *data = (unsigned char)dataCache;
  298. }
  299. u32 I2cWriteReg(u8 dev_id, u8 Addr, u8 Data)
  300. {
  301. u32 acknowledge=0;
  302. SerialCommStart();
  303. acknowledge=SerialCommTxByte((dev_id<<1) & 0xff);
  304. if (acknowledge)
  305. acknowledge=SerialCommTxByte(Addr);
  306. else
  307. return FALSE;
  308. acknowledge=SerialCommTxByte(Data);
  309. if (acknowledge) {
  310. SerialCommStop();
  311. return FALSE;
  312. } else {
  313. return TRUE;
  314. }
  315. }
  316. u32 I2cReadReg(u8 dev_id, u8 Addr, u8 *Data)
  317. {
  318. u32 acknowledge=0;
  319. SerialCommStart();
  320. acknowledge=SerialCommTxByte((dev_id<<1) & 0xff);
  321. if (acknowledge)
  322. acknowledge=SerialCommTxByte(Addr);
  323. else
  324. return FALSE;
  325. SerialCommStart();
  326. acknowledge=SerialCommTxByte(((dev_id<<1) & 0xff) | 0x01);
  327. if (acknowledge)
  328. SerialCommRxByte(Data, 1); // ack 0: ok , 1 error
  329. else
  330. return FALSE;
  331. SerialCommStop();
  332. return acknowledge;
  333. }
  334. #endif
  335. static struct mt_i2c_t usb_i2c;
  336. #define U3_PHY_I2C_DEV 0x60
  337. static u32 usb_i2c_read8(u8 addr, u8 *databuffer)
  338. {
  339. #ifdef USE_USB_I2C
  340. u32 ret;
  341. ret = I2cReadReg(U3_PHY_I2C_DEV, addr, databuffer);
  342. return ret;
  343. #else
  344. u32 ret_code = I2C_OK;
  345. u16 len;
  346. *databuffer = addr;
  347. usb_i2c.id = USB_I2C_ID;
  348. /* Since i2c will left shift 1 bit, we need to set USB I2C address to 0x60 (0xC0>>1) */
  349. usb_i2c.addr = 0x60;
  350. usb_i2c.mode = ST_MODE;
  351. usb_i2c.speed = 100;
  352. len = 1;
  353. ret_code = i2c_write_read(&usb_i2c, databuffer, len, len);
  354. return ret_code;
  355. #endif
  356. }
  357. static u32 usb_i2c_write8(u8 addr, u8 value)
  358. {
  359. #ifdef USE_USB_I2C
  360. u32 ret;
  361. ret = I2cWriteReg(U3_PHY_I2C_DEV, addr, value);
  362. return ret;
  363. #else
  364. u32 ret_code = I2C_OK;
  365. u8 write_data[2];
  366. u16 len;
  367. write_data[0]= addr;
  368. write_data[1] = value;
  369. usb_i2c.id = USB_I2C_ID;
  370. /* Since i2c will left shift 1 bit, we need to set USB I2C address to 0x60 (0xC0>>1) */
  371. usb_i2c.addr = 0x60;
  372. usb_i2c.mode = ST_MODE;
  373. usb_i2c.speed = 100;
  374. len = 2;
  375. ret_code = i2c_write(&usb_i2c, write_data, len);
  376. return ret_code;
  377. #endif
  378. }
  379. static void _u3_write_bank(u32 value)
  380. {
  381. usb_i2c_write8((u8)U3_PHY_PAGE, (u8)value);
  382. }
  383. static u32 _u3_read_reg(u32 address)
  384. {
  385. u8 databuffer = 0;
  386. usb_i2c_read8((u8)address, &databuffer);
  387. return databuffer;
  388. }
  389. static void _u3_write_reg(u32 address, u32 value)
  390. {
  391. usb_i2c_write8((u8 )address, (u8 )value);
  392. }
  393. u32 u3_phy_read_reg32(u32 addr)
  394. {
  395. u32 bank;
  396. u32 addr8;
  397. u32 data;
  398. bank = (addr >> 16) & 0xff;
  399. addr8 = addr & 0xff;
  400. _u3_write_bank(bank);
  401. data = _u3_read_reg(addr8);
  402. data |= (_u3_read_reg(addr8 + 1) << 8);
  403. data |= (_u3_read_reg(addr8 + 2) << 16);
  404. data |= (_u3_read_reg(addr8 + 3) << 24);
  405. return data;
  406. }
  407. u32 u3_phy_write_reg32(u32 addr, u32 data)
  408. {
  409. u32 bank;
  410. u32 addr8;
  411. u32 data_0, data_1, data_2, data_3;
  412. bank = (addr >> 16) & 0xff;
  413. addr8 = addr & 0xff;
  414. data_0 = data & 0xff;
  415. data_1 = (data >> 8) & 0xff;
  416. data_2 = (data >> 16) & 0xff;
  417. data_3 = (data >> 24) & 0xff;
  418. _u3_write_bank(bank);
  419. _u3_write_reg(addr8, data_0);
  420. _u3_write_reg(addr8 + 1, data_1);
  421. _u3_write_reg(addr8 + 2, data_2);
  422. _u3_write_reg(addr8 + 3, data_3);
  423. return 0;
  424. }
  425. void u3_phy_write_field32(int addr, int offset, int mask, int value)
  426. {
  427. u32 cur_value;
  428. u32 new_value;
  429. cur_value = u3_phy_read_reg32(addr);
  430. new_value = (cur_value & (~mask)) | ((value << offset) & mask);
  431. //udelay(i2cdelayus);
  432. u3_phy_write_reg32(addr, new_value);
  433. }
  434. u32 u3_phy_write_reg8(u32 addr, u8 data)
  435. {
  436. u32 bank;
  437. u32 addr8;
  438. PHY_LOG("addr8: %x\n", addr);
  439. bank = (addr >> 16) & 0xff;
  440. addr8 = addr & 0xff;
  441. _u3_write_bank(bank);
  442. _u3_write_reg(addr8, data);
  443. return 0;
  444. }
  445. char u3_phy_read_reg8(u32 addr)
  446. {
  447. int bank;
  448. int addr8;
  449. int data;
  450. bank = (addr >> 16) & 0xff;
  451. addr8 = addr & 0xff;
  452. _u3_write_bank(bank);
  453. data = _u3_read_reg(addr8);
  454. return data;
  455. }
  456. static void mu3d_hal_pdn_dis(void)
  457. {
  458. clrbits(U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
  459. #ifdef SUPPORT_U3
  460. clrbits(U3D_SSUSB_U3_CTRL_0P, (SSUSB_U3_PORT_DIS | SSUSB_U3_PORT_PDN | SSUSB_U3_PORT_U2_CG_EN));
  461. #endif
  462. clrbits(U3D_SSUSB_U2_CTRL_0P, (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN | SSUSB_U2_PORT_U2_CG_EN));
  463. }
  464. int mu3d_hal_phy_scan(struct u3phy_info *u3phy, int latch_val)
  465. {
  466. #ifdef CONFIG_U3_PHY_GPIO_SUPPORT
  467. int count, fset_phase_val, u0_count;
  468. u8 phase_val, driving;
  469. //temp, data_driving_val, clk_driving_val;
  470. #ifdef DBG_USB_PHY
  471. int link_error_count, recov_cnt;
  472. #endif
  473. /* disable ip power down,disable U2/U3 ip power down. */
  474. mu3d_hal_ssusb_en();
  475. mu3d_hal_pdn_dis();
  476. #if defined(CONFIG_D60802_SUPPORT)
  477. phy_change_pipe_phase_d60802(u3phy, 0, 0);
  478. #elif defined(CONFIG_E60802_SUPPORT)
  479. phy_change_pipe_phase_e60802(u3phy, 0, 0);
  480. #elif defined(CONFIG_A60810_SUPPORT)
  481. phy_change_pipe_phase_a60810(u3phy, 0, 0);
  482. #endif
  483. writel(latch_val, U3D_PIPE_LATCH_SELECT); /* set tx/rx latch sel */
  484. driving = 2;
  485. #if defined(CONFIG_D60802_SUPPORT)
  486. phy_change_pipe_phase_d60802(u3phy, driving, driving);
  487. #elif defined(CONFIG_E60802_SUPPORT)
  488. phy_change_pipe_phase_e60802(u3phy, driving, driving);
  489. #elif defined(CONFIG_A60810_SUPPORT)
  490. phy_change_pipe_phase_a60810(u3phy, driving, driving);
  491. #endif
  492. phase_val = 0;
  493. count = 0;
  494. fset_phase_val = TRUE;
  495. while (TRUE) {
  496. if (fset_phase_val) {
  497. #if defined(CONFIG_D60802_SUPPORT)
  498. phy_change_pipe_phase_d60802(u3phy, driving, phase_val);
  499. #elif defined(CONFIG_E60802_SUPPORT)
  500. phy_change_pipe_phase_e60802(u3phy, driving, phase_val);
  501. #elif defined(CONFIG_A60810_SUPPORT)
  502. phy_change_pipe_phase_a60810(u3phy, driving, phase_val);
  503. #endif
  504. mu3d_hal_rst_dev();
  505. mdelay(50);
  506. writel(USB3_EN, U3D_USB3_CONFIG);
  507. writel(latch_val, U3D_PIPE_LATCH_SELECT); /* set tx/rx latch sel */
  508. fset_phase_val = FALSE;
  509. u0_count = 0;
  510. #ifdef DBG_USB_PHY
  511. link_error_count = 0;
  512. recov_cnt = 0;
  513. #endif
  514. count = 0;
  515. }
  516. mdelay(50);
  517. count++;
  518. #ifdef DBG_USB_PHY
  519. /* read U0 recovery count */
  520. recov_cnt = readl(U3D_RECOVERY_COUNT);
  521. /* read link error count */
  522. link_error_count = readl(U3D_LINK_ERR_COUNT);
  523. #endif
  524. /* enter U0 state */
  525. if ((readl(U3D_LINK_STATE_MACHINE) & LTSSM) == STATE_U0_STATE) {
  526. u0_count++;
  527. }
  528. /* link up */
  529. if (u0_count > ENTER_U0_TH) {
  530. mdelay(1000);//1s
  531. #ifdef DBG_USB_PHY
  532. recov_cnt = readl(U3D_RECOVERY_COUNT);
  533. link_error_count = readl(U3D_LINK_ERR_COUNT);
  534. #endif
  535. writel(CLR_RECOV_CNT, U3D_RECOVERY_COUNT); /* clear recovery count */
  536. writel(CLR_LINK_ERR_CNT, U3D_LINK_ERR_COUNT); /* clear link error count */
  537. #ifdef DBG_USB_PHY
  538. 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",
  539. link_error_count, recov_cnt,
  540. U3_PHY_I2C_PCLK_DRV_REG, _u3_read_reg(U3_PHY_I2C_PCLK_DRV_REG),
  541. U3_PHY_I2C_PCLK_PHASE_REG, _u3_read_reg(U3_PHY_I2C_PCLK_PHASE_REG),
  542. readl(U3D_PIPE_LATCH_SELECT),
  543. phase_val, driving, latch_val);
  544. #endif
  545. phase_val++;
  546. fset_phase_val = TRUE;
  547. } else if ((readl(U3D_LINK_STATE_MACHINE) & LTSSM) == STATE_DISABLE) { /* link fail */
  548. PHY_LOG("[FAIL] STATE_DISABLE, PhaseDelay[0x%x]\n", phase_val);
  549. phase_val++;
  550. fset_phase_val=TRUE;
  551. } else if (count > MAX_TIMEOUT_COUNT) { /* link timeout */
  552. PHY_LOG("[FAIL] TIMEOUT, PhaseDelay[0x%x]\n", phase_val);
  553. phase_val++;
  554. fset_phase_val = TRUE;
  555. }
  556. if (phase_val > MAX_PHASE_RANGE) {
  557. /* reset device */
  558. mu3d_hal_rst_dev();
  559. mdelay(50);
  560. /* disable ip power down, disable U2/U3 ip power down. */
  561. mu3d_hal_ssusb_en();
  562. mu3d_hal_pdn_dis();
  563. mdelay(10);
  564. break;
  565. }
  566. }
  567. #endif /* CONFIG_U3_PHY_GPIO_SUPPORT */
  568. return 0;
  569. }
  570. void mt_usb_phy_poweron(void)
  571. {
  572. static struct u3phy_info info;
  573. #ifdef DBG_USB_PHY
  574. volatile u32 u3phy_version;
  575. #endif
  576. info.phyd_version_addr = 0x2000e4;
  577. #ifdef DBG_USB_PHY
  578. u3phy_version = u3_phy_read_reg32(info.phyd_version_addr);
  579. PHY_LOG("[USBPHY] Phy version is %x\n", u3phy_version);
  580. #endif
  581. #if defined(CONFIG_D60802_SUPPORT)
  582. info.u2phy_regs_d = (struct u2phy_reg_d *)0x0;
  583. info.u3phyd_regs_d = (struct u3phyd_reg_d *)0x100000;
  584. info.u3phyd_bank2_regs_d = (struct u3phyd_bank2_reg_d *)0x200000;
  585. info.u3phya_regs_d = (struct u3phya_reg_d *)0x300000;
  586. info.u3phya_da_regs_d = (struct u3phya_da_reg_d *)0x400000;
  587. info.sifslv_chip_regs_d = (struct sifslv_chip_reg_d *)0x500000;
  588. info.sifslv_fm_regs_d = (struct sifslv_fm_feg_d *)0xf00000;
  589. phy_init_d60802(&info);
  590. #elif defined(CONFIG_E60802_SUPPORT)
  591. info.u2phy_regs_e = (struct u2phy_reg_e *)0x0;
  592. info.u3phyd_regs_e = (struct u3phyd_reg_e *)0x100000;
  593. info.u3phyd_bank2_regs_e = (struct u3phyd_bank2_reg_e *)0x200000;
  594. info.u3phya_regs_e = (struct u3phya_reg_e *)0x300000;
  595. info.u3phya_da_regs_e = (struct u3phya_da_reg_e *)0x400000;
  596. info.sifslv_chip_regs_e = (struct sifslv_chip_reg_e *)0x500000;
  597. info.sifslv_fm_regs_e = (struct sifslv_fm_feg_e *)0xf00000;
  598. phy_init_e60802(&info);
  599. #elif defined(CONFIG_A60810_SUPPORT)
  600. info.u2phy_regs_a = (struct u2phy_reg_a *)0x0;
  601. info.u3phyd_regs_a = (struct u3phyd_reg_a *)0x100000;
  602. info.u3phyd_bank2_regs_a = (struct u3phyd_bank2_reg_a *)0x200000;
  603. info.u3phya_regs_a = (struct u3phya_reg_a *)0x300000;
  604. info.u3phya_da_regs_a = (struct u3phya_da_reg_a *)0x400000;
  605. info.sifslv_chip_regs_a = (struct sifslv_chip_reg_a *)0x500000;
  606. info.spllc_regs_a = (struct spllc_reg_a *)0x600000;
  607. info.sifslv_fm_regs_a = (struct sifslv_fm_feg_a *)0xf00000;
  608. phy_init_a60810(&info);
  609. #endif
  610. /* for RF desense */
  611. #if defined(CONFIG_D60802_SUPPORT)
  612. //u2_slew_rate_calibration_d60802(&info);
  613. #elif defined(CONFIG_E60802_SUPPORT)
  614. //u2_slew_rate_calibration_e60802(&info);
  615. #elif defined(CONFIG_A60810_SUPPORT)
  616. //u2_slew_rate_calibration_a60810(&info);
  617. #endif
  618. mu3d_hal_ssusb_en();
  619. mu3d_hal_rst_dev();
  620. }
  621. void mt_usb_phy_savecurrent(void)
  622. {
  623. }
  624. void mt_usb_phy_recover(void)
  625. {
  626. }
  627. void mt_usb11_phy_savecurrent(void)
  628. {
  629. }
  630. void Charger_Detect_Init(void)
  631. {
  632. /* no need */
  633. }
  634. void Charger_Detect_Release(void)
  635. {
  636. /* no need */
  637. }
  638. #else /* if CFG_FPGA_PLATFORM */
  639. #if defined(SUPPORT_U3) && defined(HAS_REDRIVER)
  640. void config_redriver(void)
  641. {
  642. u16 pin;
  643. u16 mode;
  644. /*
  645. * set redriver CC1 and CC2
  646. * CC2, HZ
  647. * at /sys/devices/platform/pinctrl/mt_gpio | grep 40
  648. * 40: 0000001100
  649. * CC1, HIGH
  650. * at /sys/devices/platform/pinctrl/mt_gpio | grep 41
  651. * 41: 0111001110
  652. */
  653. pin = GPIO40;
  654. mode = GPIO_MODE_00;
  655. // 1: set pin mode
  656. mt_set_gpio_mode(pin, GPIO_MODE_00);
  657. mt_set_gpio_dir(pin, GPIO_DIR_IN);
  658. mt_set_gpio_ies(pin, GPIO_IES_ENABLE);
  659. mt_set_gpio_pull_enable(pin, GPIO_PULL_DISABLE);
  660. mt_set_gpio_pull_select(pin, GPIO_PULL_DOWN);
  661. mdelay(200);
  662. pin = GPIO41;
  663. mode = GPIO_MODE_00;
  664. // 1: set pin mode
  665. mt_set_gpio_mode(pin, GPIO_MODE_00);
  666. mt_set_gpio_dir(pin, GPIO_DIR_OUT);
  667. mt_set_gpio_out(pin, GPIO_DIR_OUT);
  668. mt_set_gpio_ies(pin, GPIO_IES_ENABLE);
  669. mt_set_gpio_pull_enable(pin, GPIO_PULL_ENABLE);
  670. mt_set_gpio_pull_select(pin, GPIO_PULL_UP);
  671. mdelay(200);
  672. }
  673. #endif
  674. void switch_2_usb()
  675. {
  676. clrbits(U3D_U2PHYDTM0, A60810_FORCE_UART_EN);
  677. clrbits(U3D_U2PHYDTM1, A60810_RG_UART_EN);
  678. clrbits(U3D_U2PHYACR4, A60810_RG_USB20_GPIO_CTL);
  679. clrbits(U3D_U2PHYACR4, A60810_USB20_GPIO_MODE);
  680. }
  681. void mt_usb_phy_poweron(void)
  682. {
  683. /* 5, switch to USB function */
  684. switch_2_usb();
  685. /* 6, DP/DM BC1.1 path Disable */
  686. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_BC11_SW_EN);
  687. /* 7, dp_100k diable */
  688. clrbits(U3D_USBPHYACR4, A60810_USB20_DP_100K_EN);
  689. /* 8, rg_usb20_dp_100k_mode, 1'b1 */
  690. setbits(U3D_USBPHYACR4, A60810_RG_USB20_DP_100K_MODE);
  691. /* 9, dm_100k disable */
  692. clrbits(U3D_USBPHYACR4, A60810_RG_USB20_DM_100K_EN);
  693. /* 10, OTG enable */
  694. setbits(U3D_USBPHYACR6, A60810_RG_USB20_OTG_VBUSCMP_EN);
  695. /* 11, Release force suspendm */
  696. clrbits(U3D_U2PHYDTM0, A60810_FORCE_SUSPENDM);
  697. /* 12, Pre-emphasis level1*/
  698. setbits(U3D_USBPHYACR6, (0x1000000U << 24));
  699. /* Wait 800 usec */
  700. udelay(800);
  701. mu3d_hal_ssusb_en();
  702. }
  703. void mt_usb_phy_savecurrent(void)
  704. {
  705. /* 1, switch to usb function */
  706. switch_2_usb();
  707. /* 2, DP/DM BC1.1 path Disable */
  708. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_BC11_SW_EN);
  709. /* 3, OTG disable */
  710. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_OTG_VBUSCMP_EN);
  711. /* 4, let syspendm=1 */
  712. setbits(U3D_U2PHYDTM0, A60810_RG_SUSPENDM);
  713. /* 5, force_suspendm */
  714. setbits(U3D_U2PHYDTM0, A60810_FORCE_SUSPENDM);
  715. /* 6 wait for USBPLL stable */
  716. mdelay(2);
  717. /* 7 */
  718. setbits(U3D_U2PHYDTM0, A60810_RG_DPPULLDOWN);
  719. /* 8 */
  720. setbits(U3D_U2PHYDTM0, A60810_RG_DMPULLDOWN);
  721. /* 9 */
  722. writel((readl(U3D_U2PHYDTM0) & ~A60810_RG_XCVRSEL) | (0x1 << A60810_RG_XCVRSEL_OFST), U3D_U2PHYDTM0);
  723. /* 10 */
  724. setbits(U3D_U2PHYDTM0, A60810_RG_TERMSEL);
  725. /* 11 */
  726. clrbits(U3D_U2PHYDTM0, A60810_RG_DATAIN);
  727. /* 12 */
  728. setbits(U3D_U2PHYDTM0, A60810_FORCE_DP_PULLDOWN);
  729. /* 13 */
  730. setbits(U3D_U2PHYDTM0, A60810_FORCE_DM_PULLDOWN);
  731. /* 14 */
  732. setbits(U3D_U2PHYDTM0, A60810_FORCE_XCVRSEL);
  733. /* 15 */
  734. setbits(U3D_U2PHYDTM0, A60810_FORCE_TERMSEL);
  735. /* 16 */
  736. setbits(U3D_U2PHYDTM0, A60810_FORCE_DATAIN);
  737. /* 17 */
  738. udelay(800);
  739. /* 18 */
  740. clrbits(U3D_U2PHYDTM0, A60810_RG_SUSPENDM);
  741. /* 19 wait 1us */
  742. udelay(1);
  743. }
  744. void setting_ref_clk_e60802(void)
  745. {
  746. u32 val;
  747. /*
  748. * Reference clock use digital P&R, instead of analog path
  749. * possibly more interference
  750. * ---------REG Name---------- | -----Modification---| -----Description----
  751. * DA_SSUSB_XTAL_EXT_EN[1:0] | 2'b01-->2'b10 | 0x11290c00 bit[11:10]
  752. * DA_SSUSB_XTAL_RX_PWD[9:9] | -->1'b1 | 0x11280018 bit[9]
  753. */
  754. //USB_WRITE_FIELD32(U3D_U3PHYA_DA_REG0, A60810_RG_SSUSB_XTAL_EXT_EN_U3_OFST, A60810_RG_SSUSB_XTAL_EXT_EN_U3, 0x2);
  755. //val = readl(U3D_U3PHYA_DA_REG0) & ~A60810_RG_SSUSB_XTAL_EXT_EN_U3;
  756. val = readl(U3D_U3PHYA_DA_REG0) & ~A60810_RG_SSUSB_XTAL_EXT_EN_U3;
  757. val |= ((0x2) << A60810_RG_SSUSB_XTAL_EXT_EN_U3_OFST) & A60810_RG_SSUSB_XTAL_EXT_EN_U3;
  758. writel(val, U3D_U3PHYA_DA_REG0);
  759. //USB_WRITE_FIELD32(U3D_SPLLC_XTALCTL3, A60810_RG_SSUSB_XTAL_RX_PWD_OFST, A60810_RG_SSUSB_XTAL_RX_PWD, 0x01);
  760. val = readl(U3D_SPLLC_XTALCTL3) & ~A60810_RG_SSUSB_XTAL_RX_PWD;
  761. val |= ((0x01) << A60810_RG_SSUSB_XTAL_RX_PWD_OFST) & A60810_RG_SSUSB_XTAL_RX_PWD;
  762. writel(val, U3D_SPLLC_XTALCTL3);
  763. /*
  764. * ---------REG Name---------- | -----Modification---| -----Description----
  765. * 1 RG_SSUSB_TX_EIDLE_CM[3:0] | 1100-->1110 | low-power E-idle common mode(650mV to 600mV)
  766. * | | - 0x11290b18 bit [31:28]
  767. * 2 RG_SSUSB_CDR_BIR_LTD0[4:0]| 5'b01000-->5'b01100 | Increase BW - 0x1128095c bit [12:8]
  768. * 3 RG_XXX_CDR_BIR_LTD1[4:0] | 5'b00010-->5'b00011 | Increase BW - 0x1128095c bit [28:24]
  769. */
  770. //USB_WRITE_FIELD32(U3D_USB30_PHYA_REG6, RG_SSUSB_TX_EIDLE_CM_OFST, RG_SSUSB_TX_EIDLE_CM, 0xE);
  771. val = readl(U3D_USB30_PHYA_REG6) & ~A60810_RG_SSUSB_TX_EIDLE_CM;
  772. val |= ((0xE) << A60810_RG_SSUSB_TX_EIDLE_CM_OFST) & A60810_RG_SSUSB_TX_EIDLE_CM;
  773. writel(val, U3D_USB30_PHYA_REG6);
  774. //USB_WRITE_FIELD32(U3D_PHYD_CDR1, RG_SSUSB_CDR_BIR_LTD0_OFST, RG_SSUSB_CDR_BIR_LTD0, 0xC);
  775. val = readl(U3D_PHYD_CDR1) & ~A60810_RG_SSUSB_CDR_BIR_LTD0;
  776. val |= ((0xC) << A60810_RG_SSUSB_CDR_BIR_LTD0_OFST) & A60810_RG_SSUSB_CDR_BIR_LTD0;
  777. writel(val, U3D_PHYD_CDR1);
  778. //USB_WRITE_FIELD32(U3D_PHYD_CDR1, RG_SSUSB_CDR_BIR_LTD1_OFST, RG_SSUSB_CDR_BIR_LTD1, 0x3);
  779. val = readl(U3D_PHYD_CDR1) & ~A60810_RG_SSUSB_CDR_BIR_LTD1;
  780. val |= ((0x3) << A60810_RG_SSUSB_CDR_BIR_LTD1_OFST) & A60810_RG_SSUSB_CDR_BIR_LTD1;
  781. writel(val, U3D_PHYD_CDR1);
  782. }
  783. #if 0
  784. void setting_ref_clk_d60802(void)
  785. {
  786. u32 val;
  787. /*
  788. * Reference clock use digital P&R, instead of analog path
  789. * possibly more interference
  790. * ---------REG Name---------- | -----Modification---| -----Description----
  791. * DA_SSUSB_XTAL_EXT_EN[1:0] | 2'b01-->2'b10 | 0x11290c00 bit[11:10]
  792. * DA_SSUSB_XTAL_RX_PWD[9:9] | -->1'b1 | 0x11280018 bit[9]
  793. */
  794. /* D60802 */
  795. //USB_WRITE_FIELD32(U3D_U3PHYA_DA_REG0, D60802_RG_SSUSB_XTAL_EXT_EN_U3_OFST, D60802_RG_SSUSB_XTAL_EXT_EN_U3, 0x2);
  796. //val = readl(U3D_U3PHYA_DA_REG0) & ~D60802_RG_SSUSB_XTAL_EXT_EN_U3;
  797. val = readl(U3D_U3PHYA_DA_REG0) & ~D60802_REG0_FLD_RG_SSUSB_XTAL_EXT_EN_U3;
  798. val |= ((0x2) << D60802_REG0_FLD_RG_SSUSB_XTAL_EXT_EN_U3_OFST) & D60802_REG0_FLD_RG_SSUSB_XTAL_EXT_EN_U3;
  799. writel(val, U3D_U3PHYA_DA_REG0);
  800. /* E60802 only */
  801. #if 0
  802. USB_WRITE_FIELD32(U3D_SPLLC_XTALCTL3, D60802_RG_SSUSB_XTAL_RX_PWD_OFST, D60802_RG_SSUSB_XTAL_RX_PWD, 0x01);
  803. val = readl(U3D_SPLLC_XTALCTL3) & ~D60802_RG_SSUSB_XTAL_RX_PWD;
  804. val |= ((0x01) << D60802_RG_SSUSB_XTAL_RX_PWD_OFST) & D60802_RG_SSUSB_XTAL_RX_PWD;
  805. writel(val, U3D_SPLLC_XTALCTL3);
  806. #endif
  807. /*
  808. * ---------REG Name---------- | -----Modification---| -----Description----
  809. * 1 RG_SSUSB_TX_EIDLE_CM[3:0] | 1100-->1110 | low-power E-idle common mode(650mV to 600mV)
  810. * | | - 0x11290b18 bit [31:28]
  811. * 2 RG_SSUSB_CDR_BIR_LTD0[4:0]| 5'b01000-->5'b01100 | Increase BW - 0x1128095c bit [12:8]
  812. * 3 RG_XXX_CDR_BIR_LTD1[4:0] | 5'b00010-->5'b00011 | Increase BW - 0x1128095c bit [28:24]
  813. */
  814. // U3D_USB30_PHYA_REG6
  815. //USB_WRITE_FIELD32(U3D_USB30_PHYA_REG6, RG_SSUSB_TX_EIDLE_CM_OFST, RG_SSUSB_TX_EIDLE_CM, 0xE);
  816. val = readl(U3D_USB30_PHYA_REG6) & ~D60802_REG6_FLD_RG_SSUSB_TX_EIDLE_CM;
  817. val |= ((0xE) << D60802_REG6_FLD_RG_SSUSB_TX_EIDLE_CM_OFST) & D60802_REG6_FLD_RG_SSUSB_TX_EIDLE_CM;
  818. writel(val, U3D_USB30_PHYA_REG6);
  819. // U3D_PHYD_CDR1
  820. //USB_WRITE_FIELD32(U3D_PHYD_CDR1, RG_SSUSB_CDR_BIR_LTD0_OFST, RG_SSUSB_CDR_BIR_LTD0, 0xC);
  821. val = readl(U3D_PHYD_CDR1) & ~D60802_RG_SSUSB_CDR_BIR_LTD0;
  822. val |= ((0xC) << D60802_RG_SSUSB_CDR_BIR_LTD0_OFST) & D60802_RG_SSUSB_CDR_BIR_LTD0;
  823. writel(val, U3D_PHYD_CDR1);
  824. //USB_WRITE_FIELD32(U3D_PHYD_CDR1, RG_SSUSB_CDR_BIR_LTD1_OFST, RG_SSUSB_CDR_BIR_LTD1, 0x3);
  825. val = readl(U3D_PHYD_CDR1) & ~D60802_RG_SSUSB_CDR_BIR_LTD1;
  826. val |= ((0x3) << D60802_RG_SSUSB_CDR_BIR_LTD1_OFST) & D60802_RG_SSUSB_CDR_BIR_LTD1;
  827. writel(val, U3D_PHYD_CDR1);
  828. }
  829. #endif
  830. void mt_usb_phy_recover(void)
  831. {
  832. /* 4, switch to usb function */
  833. switch_2_usb();
  834. /* 5, force_suspendm */
  835. clrbits(U3D_U2PHYDTM0, A60810_FORCE_SUSPENDM);
  836. /* 6 */
  837. clrbits(U3D_U2PHYDTM0, A60810_RG_DPPULLDOWN);
  838. /* 7,*/
  839. clrbits(U3D_U2PHYDTM0, A60810_RG_DMPULLDOWN);
  840. /* 8 */
  841. clrbits(U3D_U2PHYDTM0, A60810_RG_XCVRSEL);
  842. /* 9 */
  843. clrbits(U3D_U2PHYDTM0, A60810_FORCE_TERMSEL);
  844. /* 10 */
  845. clrbits(U3D_U2PHYDTM0, A60810_RG_DATAIN);
  846. /* 11 */
  847. clrbits(U3D_U2PHYDTM0, A60810_FORCE_DP_PULLDOWN);
  848. /* 12 */
  849. clrbits(U3D_U2PHYDTM0, A60810_FORCE_DM_PULLDOWN);
  850. /* 13 */
  851. clrbits(U3D_U2PHYDTM0, A60810_FORCE_XCVRSEL);
  852. /* 14 */
  853. clrbits(U3D_U2PHYDTM0, A60810_FORCE_TERMSEL);
  854. /* 15 */
  855. clrbits(U3D_U2PHYDTM0, A60810_FORCE_DATAIN);
  856. /* 16, DP/DM BC1.1 path Disable */
  857. clrbits(U3D_USBPHYACR6, A60810_RG_USB20_BC11_SW_EN);
  858. /* 17, OTG enable */
  859. setbits(U3D_USBPHYACR6, A60810_RG_USB20_OTG_VBUSCMP_EN);
  860. /* 18, Pre-emphasis level1*/
  861. setbits(U3D_USBPHYACR6, (0x1000000U << 24));
  862. /* 19, wait 800us */
  863. udelay(800);
  864. }
  865. #endif