phy-tegra-usb.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) 2010 Google, Inc.
  4. * Copyright (C) 2013 NVIDIA Corporation
  5. *
  6. * Author:
  7. * Erik Gilling <konkers@google.com>
  8. * Benoit Goby <benoit@android.com>
  9. * Venu Byravarasu <vbyravarasu@nvidia.com>
  10. */
  11. #include <linux/resource.h>
  12. #include <linux/delay.h>
  13. #include <linux/slab.h>
  14. #include <linux/err.h>
  15. #include <linux/export.h>
  16. #include <linux/module.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/iopoll.h>
  19. #include <linux/gpio.h>
  20. #include <linux/of.h>
  21. #include <linux/of_device.h>
  22. #include <linux/of_gpio.h>
  23. #include <linux/usb/otg.h>
  24. #include <linux/usb/ulpi.h>
  25. #include <linux/usb/of.h>
  26. #include <linux/usb/ehci_def.h>
  27. #include <linux/usb/tegra_usb_phy.h>
  28. #include <linux/regulator/consumer.h>
  29. #define ULPI_VIEWPORT 0x170
  30. /* PORTSC PTS/PHCD bits, Tegra20 only */
  31. #define TEGRA_USB_PORTSC1 0x184
  32. #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30)
  33. #define TEGRA_USB_PORTSC1_PHCD (1 << 23)
  34. /* HOSTPC1 PTS/PHCD bits, Tegra30 and above */
  35. #define TEGRA_USB_HOSTPC1_DEVLC 0x1b4
  36. #define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29)
  37. #define TEGRA_USB_HOSTPC1_DEVLC_PHCD (1 << 22)
  38. /* Bits of PORTSC1, which will get cleared by writing 1 into them */
  39. #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
  40. #define USB_SUSP_CTRL 0x400
  41. #define USB_WAKE_ON_CNNT_EN_DEV (1 << 3)
  42. #define USB_WAKE_ON_DISCON_EN_DEV (1 << 4)
  43. #define USB_SUSP_CLR (1 << 5)
  44. #define USB_PHY_CLK_VALID (1 << 7)
  45. #define UTMIP_RESET (1 << 11)
  46. #define UHSIC_RESET (1 << 11)
  47. #define UTMIP_PHY_ENABLE (1 << 12)
  48. #define ULPI_PHY_ENABLE (1 << 13)
  49. #define USB_SUSP_SET (1 << 14)
  50. #define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16)
  51. #define USB1_LEGACY_CTRL 0x410
  52. #define USB1_NO_LEGACY_MODE (1 << 0)
  53. #define USB1_VBUS_SENSE_CTL_MASK (3 << 1)
  54. #define USB1_VBUS_SENSE_CTL_VBUS_WAKEUP (0 << 1)
  55. #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD_OR_VBUS_WAKEUP \
  56. (1 << 1)
  57. #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD (2 << 1)
  58. #define USB1_VBUS_SENSE_CTL_A_SESS_VLD (3 << 1)
  59. #define ULPI_TIMING_CTRL_0 0x424
  60. #define ULPI_OUTPUT_PINMUX_BYP (1 << 10)
  61. #define ULPI_CLKOUT_PINMUX_BYP (1 << 11)
  62. #define ULPI_TIMING_CTRL_1 0x428
  63. #define ULPI_DATA_TRIMMER_LOAD (1 << 0)
  64. #define ULPI_DATA_TRIMMER_SEL(x) (((x) & 0x7) << 1)
  65. #define ULPI_STPDIRNXT_TRIMMER_LOAD (1 << 16)
  66. #define ULPI_STPDIRNXT_TRIMMER_SEL(x) (((x) & 0x7) << 17)
  67. #define ULPI_DIR_TRIMMER_LOAD (1 << 24)
  68. #define ULPI_DIR_TRIMMER_SEL(x) (((x) & 0x7) << 25)
  69. #define UTMIP_PLL_CFG1 0x804
  70. #define UTMIP_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
  71. #define UTMIP_PLLU_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27)
  72. #define UTMIP_XCVR_CFG0 0x808
  73. #define UTMIP_XCVR_SETUP(x) (((x) & 0xf) << 0)
  74. #define UTMIP_XCVR_SETUP_MSB(x) ((((x) & 0x70) >> 4) << 22)
  75. #define UTMIP_XCVR_LSRSLEW(x) (((x) & 0x3) << 8)
  76. #define UTMIP_XCVR_LSFSLEW(x) (((x) & 0x3) << 10)
  77. #define UTMIP_FORCE_PD_POWERDOWN (1 << 14)
  78. #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16)
  79. #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18)
  80. #define UTMIP_XCVR_LSBIAS_SEL (1 << 21)
  81. #define UTMIP_XCVR_HSSLEW(x) (((x) & 0x3) << 4)
  82. #define UTMIP_XCVR_HSSLEW_MSB(x) ((((x) & 0x1fc) >> 2) << 25)
  83. #define UTMIP_BIAS_CFG0 0x80c
  84. #define UTMIP_OTGPD (1 << 11)
  85. #define UTMIP_BIASPD (1 << 10)
  86. #define UTMIP_HSSQUELCH_LEVEL(x) (((x) & 0x3) << 0)
  87. #define UTMIP_HSDISCON_LEVEL(x) (((x) & 0x3) << 2)
  88. #define UTMIP_HSDISCON_LEVEL_MSB(x) ((((x) & 0x4) >> 2) << 24)
  89. #define UTMIP_HSRX_CFG0 0x810
  90. #define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10)
  91. #define UTMIP_IDLE_WAIT(x) (((x) & 0x1f) << 15)
  92. #define UTMIP_HSRX_CFG1 0x814
  93. #define UTMIP_HS_SYNC_START_DLY(x) (((x) & 0x1f) << 1)
  94. #define UTMIP_TX_CFG0 0x820
  95. #define UTMIP_FS_PREABMLE_J (1 << 19)
  96. #define UTMIP_HS_DISCON_DISABLE (1 << 8)
  97. #define UTMIP_MISC_CFG0 0x824
  98. #define UTMIP_DPDM_OBSERVE (1 << 26)
  99. #define UTMIP_DPDM_OBSERVE_SEL(x) (((x) & 0xf) << 27)
  100. #define UTMIP_DPDM_OBSERVE_SEL_FS_J UTMIP_DPDM_OBSERVE_SEL(0xf)
  101. #define UTMIP_DPDM_OBSERVE_SEL_FS_K UTMIP_DPDM_OBSERVE_SEL(0xe)
  102. #define UTMIP_DPDM_OBSERVE_SEL_FS_SE1 UTMIP_DPDM_OBSERVE_SEL(0xd)
  103. #define UTMIP_DPDM_OBSERVE_SEL_FS_SE0 UTMIP_DPDM_OBSERVE_SEL(0xc)
  104. #define UTMIP_SUSPEND_EXIT_ON_EDGE (1 << 22)
  105. #define UTMIP_MISC_CFG1 0x828
  106. #define UTMIP_PLL_ACTIVE_DLY_COUNT(x) (((x) & 0x1f) << 18)
  107. #define UTMIP_PLLU_STABLE_COUNT(x) (((x) & 0xfff) << 6)
  108. #define UTMIP_DEBOUNCE_CFG0 0x82c
  109. #define UTMIP_BIAS_DEBOUNCE_A(x) (((x) & 0xffff) << 0)
  110. #define UTMIP_BAT_CHRG_CFG0 0x830
  111. #define UTMIP_PD_CHRG (1 << 0)
  112. #define UTMIP_SPARE_CFG0 0x834
  113. #define FUSE_SETUP_SEL (1 << 3)
  114. #define UTMIP_XCVR_CFG1 0x838
  115. #define UTMIP_FORCE_PDDISC_POWERDOWN (1 << 0)
  116. #define UTMIP_FORCE_PDCHRP_POWERDOWN (1 << 2)
  117. #define UTMIP_FORCE_PDDR_POWERDOWN (1 << 4)
  118. #define UTMIP_XCVR_TERM_RANGE_ADJ(x) (((x) & 0xf) << 18)
  119. #define UTMIP_BIAS_CFG1 0x83c
  120. #define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3)
  121. /* For Tegra30 and above only, the address is different in Tegra20 */
  122. #define USB_USBMODE 0x1f8
  123. #define USB_USBMODE_MASK (3 << 0)
  124. #define USB_USBMODE_HOST (3 << 0)
  125. #define USB_USBMODE_DEVICE (2 << 0)
  126. static DEFINE_SPINLOCK(utmip_pad_lock);
  127. static int utmip_pad_count;
  128. struct tegra_xtal_freq {
  129. int freq;
  130. u8 enable_delay;
  131. u8 stable_count;
  132. u8 active_delay;
  133. u8 xtal_freq_count;
  134. u16 debounce;
  135. };
  136. static const struct tegra_xtal_freq tegra_freq_table[] = {
  137. {
  138. .freq = 12000000,
  139. .enable_delay = 0x02,
  140. .stable_count = 0x2F,
  141. .active_delay = 0x04,
  142. .xtal_freq_count = 0x76,
  143. .debounce = 0x7530,
  144. },
  145. {
  146. .freq = 13000000,
  147. .enable_delay = 0x02,
  148. .stable_count = 0x33,
  149. .active_delay = 0x05,
  150. .xtal_freq_count = 0x7F,
  151. .debounce = 0x7EF4,
  152. },
  153. {
  154. .freq = 19200000,
  155. .enable_delay = 0x03,
  156. .stable_count = 0x4B,
  157. .active_delay = 0x06,
  158. .xtal_freq_count = 0xBB,
  159. .debounce = 0xBB80,
  160. },
  161. {
  162. .freq = 26000000,
  163. .enable_delay = 0x04,
  164. .stable_count = 0x66,
  165. .active_delay = 0x09,
  166. .xtal_freq_count = 0xFE,
  167. .debounce = 0xFDE8,
  168. },
  169. };
  170. static void set_pts(struct tegra_usb_phy *phy, u8 pts_val)
  171. {
  172. void __iomem *base = phy->regs;
  173. unsigned long val;
  174. if (phy->soc_config->has_hostpc) {
  175. val = readl(base + TEGRA_USB_HOSTPC1_DEVLC);
  176. val &= ~TEGRA_USB_HOSTPC1_DEVLC_PTS(~0);
  177. val |= TEGRA_USB_HOSTPC1_DEVLC_PTS(pts_val);
  178. writel(val, base + TEGRA_USB_HOSTPC1_DEVLC);
  179. } else {
  180. val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS;
  181. val &= ~TEGRA_USB_PORTSC1_PTS(~0);
  182. val |= TEGRA_USB_PORTSC1_PTS(pts_val);
  183. writel(val, base + TEGRA_USB_PORTSC1);
  184. }
  185. }
  186. static void set_phcd(struct tegra_usb_phy *phy, bool enable)
  187. {
  188. void __iomem *base = phy->regs;
  189. unsigned long val;
  190. if (phy->soc_config->has_hostpc) {
  191. val = readl(base + TEGRA_USB_HOSTPC1_DEVLC);
  192. if (enable)
  193. val |= TEGRA_USB_HOSTPC1_DEVLC_PHCD;
  194. else
  195. val &= ~TEGRA_USB_HOSTPC1_DEVLC_PHCD;
  196. writel(val, base + TEGRA_USB_HOSTPC1_DEVLC);
  197. } else {
  198. val = readl(base + TEGRA_USB_PORTSC1) & ~PORT_RWC_BITS;
  199. if (enable)
  200. val |= TEGRA_USB_PORTSC1_PHCD;
  201. else
  202. val &= ~TEGRA_USB_PORTSC1_PHCD;
  203. writel(val, base + TEGRA_USB_PORTSC1);
  204. }
  205. }
  206. static int utmip_pad_open(struct tegra_usb_phy *phy)
  207. {
  208. phy->pad_clk = devm_clk_get(phy->u_phy.dev, "utmi-pads");
  209. if (IS_ERR(phy->pad_clk)) {
  210. pr_err("%s: can't get utmip pad clock\n", __func__);
  211. return PTR_ERR(phy->pad_clk);
  212. }
  213. return 0;
  214. }
  215. static void utmip_pad_power_on(struct tegra_usb_phy *phy)
  216. {
  217. unsigned long val, flags;
  218. void __iomem *base = phy->pad_regs;
  219. struct tegra_utmip_config *config = phy->config;
  220. clk_prepare_enable(phy->pad_clk);
  221. spin_lock_irqsave(&utmip_pad_lock, flags);
  222. if (utmip_pad_count++ == 0) {
  223. val = readl(base + UTMIP_BIAS_CFG0);
  224. val &= ~(UTMIP_OTGPD | UTMIP_BIASPD);
  225. if (phy->soc_config->requires_extra_tuning_parameters) {
  226. val &= ~(UTMIP_HSSQUELCH_LEVEL(~0) |
  227. UTMIP_HSDISCON_LEVEL(~0) |
  228. UTMIP_HSDISCON_LEVEL_MSB(~0));
  229. val |= UTMIP_HSSQUELCH_LEVEL(config->hssquelch_level);
  230. val |= UTMIP_HSDISCON_LEVEL(config->hsdiscon_level);
  231. val |= UTMIP_HSDISCON_LEVEL_MSB(config->hsdiscon_level);
  232. }
  233. writel(val, base + UTMIP_BIAS_CFG0);
  234. }
  235. spin_unlock_irqrestore(&utmip_pad_lock, flags);
  236. clk_disable_unprepare(phy->pad_clk);
  237. }
  238. static int utmip_pad_power_off(struct tegra_usb_phy *phy)
  239. {
  240. unsigned long val, flags;
  241. void __iomem *base = phy->pad_regs;
  242. if (!utmip_pad_count) {
  243. pr_err("%s: utmip pad already powered off\n", __func__);
  244. return -EINVAL;
  245. }
  246. clk_prepare_enable(phy->pad_clk);
  247. spin_lock_irqsave(&utmip_pad_lock, flags);
  248. if (--utmip_pad_count == 0) {
  249. val = readl(base + UTMIP_BIAS_CFG0);
  250. val |= UTMIP_OTGPD | UTMIP_BIASPD;
  251. writel(val, base + UTMIP_BIAS_CFG0);
  252. }
  253. spin_unlock_irqrestore(&utmip_pad_lock, flags);
  254. clk_disable_unprepare(phy->pad_clk);
  255. return 0;
  256. }
  257. static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result)
  258. {
  259. u32 tmp;
  260. return readl_poll_timeout(reg, tmp, (tmp & mask) == result,
  261. 2000, 6000);
  262. }
  263. static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
  264. {
  265. unsigned long val;
  266. void __iomem *base = phy->regs;
  267. /*
  268. * The USB driver may have already initiated the phy clock
  269. * disable so wait to see if the clock turns off and if not
  270. * then proceed with gating the clock.
  271. */
  272. if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) == 0)
  273. return;
  274. if (phy->is_legacy_phy) {
  275. val = readl(base + USB_SUSP_CTRL);
  276. val |= USB_SUSP_SET;
  277. writel(val, base + USB_SUSP_CTRL);
  278. udelay(10);
  279. val = readl(base + USB_SUSP_CTRL);
  280. val &= ~USB_SUSP_SET;
  281. writel(val, base + USB_SUSP_CTRL);
  282. } else
  283. set_phcd(phy, true);
  284. if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) < 0)
  285. pr_err("%s: timeout waiting for phy to stabilize\n", __func__);
  286. }
  287. static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
  288. {
  289. unsigned long val;
  290. void __iomem *base = phy->regs;
  291. /*
  292. * The USB driver may have already initiated the phy clock
  293. * enable so wait to see if the clock turns on and if not
  294. * then proceed with ungating the clock.
  295. */
  296. if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
  297. USB_PHY_CLK_VALID) == 0)
  298. return;
  299. if (phy->is_legacy_phy) {
  300. val = readl(base + USB_SUSP_CTRL);
  301. val |= USB_SUSP_CLR;
  302. writel(val, base + USB_SUSP_CTRL);
  303. udelay(10);
  304. val = readl(base + USB_SUSP_CTRL);
  305. val &= ~USB_SUSP_CLR;
  306. writel(val, base + USB_SUSP_CTRL);
  307. } else
  308. set_phcd(phy, false);
  309. if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID,
  310. USB_PHY_CLK_VALID))
  311. pr_err("%s: timeout waiting for phy to stabilize\n", __func__);
  312. }
  313. static int utmi_phy_power_on(struct tegra_usb_phy *phy)
  314. {
  315. unsigned long val;
  316. void __iomem *base = phy->regs;
  317. struct tegra_utmip_config *config = phy->config;
  318. val = readl(base + USB_SUSP_CTRL);
  319. val |= UTMIP_RESET;
  320. writel(val, base + USB_SUSP_CTRL);
  321. if (phy->is_legacy_phy) {
  322. val = readl(base + USB1_LEGACY_CTRL);
  323. val |= USB1_NO_LEGACY_MODE;
  324. writel(val, base + USB1_LEGACY_CTRL);
  325. }
  326. val = readl(base + UTMIP_TX_CFG0);
  327. val |= UTMIP_FS_PREABMLE_J;
  328. writel(val, base + UTMIP_TX_CFG0);
  329. val = readl(base + UTMIP_HSRX_CFG0);
  330. val &= ~(UTMIP_IDLE_WAIT(~0) | UTMIP_ELASTIC_LIMIT(~0));
  331. val |= UTMIP_IDLE_WAIT(config->idle_wait_delay);
  332. val |= UTMIP_ELASTIC_LIMIT(config->elastic_limit);
  333. writel(val, base + UTMIP_HSRX_CFG0);
  334. val = readl(base + UTMIP_HSRX_CFG1);
  335. val &= ~UTMIP_HS_SYNC_START_DLY(~0);
  336. val |= UTMIP_HS_SYNC_START_DLY(config->hssync_start_delay);
  337. writel(val, base + UTMIP_HSRX_CFG1);
  338. val = readl(base + UTMIP_DEBOUNCE_CFG0);
  339. val &= ~UTMIP_BIAS_DEBOUNCE_A(~0);
  340. val |= UTMIP_BIAS_DEBOUNCE_A(phy->freq->debounce);
  341. writel(val, base + UTMIP_DEBOUNCE_CFG0);
  342. val = readl(base + UTMIP_MISC_CFG0);
  343. val &= ~UTMIP_SUSPEND_EXIT_ON_EDGE;
  344. writel(val, base + UTMIP_MISC_CFG0);
  345. if (!phy->soc_config->utmi_pll_config_in_car_module) {
  346. val = readl(base + UTMIP_MISC_CFG1);
  347. val &= ~(UTMIP_PLL_ACTIVE_DLY_COUNT(~0) |
  348. UTMIP_PLLU_STABLE_COUNT(~0));
  349. val |= UTMIP_PLL_ACTIVE_DLY_COUNT(phy->freq->active_delay) |
  350. UTMIP_PLLU_STABLE_COUNT(phy->freq->stable_count);
  351. writel(val, base + UTMIP_MISC_CFG1);
  352. val = readl(base + UTMIP_PLL_CFG1);
  353. val &= ~(UTMIP_XTAL_FREQ_COUNT(~0) |
  354. UTMIP_PLLU_ENABLE_DLY_COUNT(~0));
  355. val |= UTMIP_XTAL_FREQ_COUNT(phy->freq->xtal_freq_count) |
  356. UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay);
  357. writel(val, base + UTMIP_PLL_CFG1);
  358. }
  359. if (phy->mode == USB_DR_MODE_PERIPHERAL) {
  360. val = readl(base + USB_SUSP_CTRL);
  361. val &= ~(USB_WAKE_ON_CNNT_EN_DEV | USB_WAKE_ON_DISCON_EN_DEV);
  362. writel(val, base + USB_SUSP_CTRL);
  363. val = readl(base + UTMIP_BAT_CHRG_CFG0);
  364. val &= ~UTMIP_PD_CHRG;
  365. writel(val, base + UTMIP_BAT_CHRG_CFG0);
  366. } else {
  367. val = readl(base + UTMIP_BAT_CHRG_CFG0);
  368. val |= UTMIP_PD_CHRG;
  369. writel(val, base + UTMIP_BAT_CHRG_CFG0);
  370. }
  371. utmip_pad_power_on(phy);
  372. val = readl(base + UTMIP_XCVR_CFG0);
  373. val &= ~(UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN |
  374. UTMIP_FORCE_PDZI_POWERDOWN | UTMIP_XCVR_LSBIAS_SEL |
  375. UTMIP_XCVR_SETUP(~0) | UTMIP_XCVR_SETUP_MSB(~0) |
  376. UTMIP_XCVR_LSFSLEW(~0) | UTMIP_XCVR_LSRSLEW(~0));
  377. if (!config->xcvr_setup_use_fuses) {
  378. val |= UTMIP_XCVR_SETUP(config->xcvr_setup);
  379. val |= UTMIP_XCVR_SETUP_MSB(config->xcvr_setup);
  380. }
  381. val |= UTMIP_XCVR_LSFSLEW(config->xcvr_lsfslew);
  382. val |= UTMIP_XCVR_LSRSLEW(config->xcvr_lsrslew);
  383. if (phy->soc_config->requires_extra_tuning_parameters) {
  384. val &= ~(UTMIP_XCVR_HSSLEW(~0) | UTMIP_XCVR_HSSLEW_MSB(~0));
  385. val |= UTMIP_XCVR_HSSLEW(config->xcvr_hsslew);
  386. val |= UTMIP_XCVR_HSSLEW_MSB(config->xcvr_hsslew);
  387. }
  388. writel(val, base + UTMIP_XCVR_CFG0);
  389. val = readl(base + UTMIP_XCVR_CFG1);
  390. val &= ~(UTMIP_FORCE_PDDISC_POWERDOWN | UTMIP_FORCE_PDCHRP_POWERDOWN |
  391. UTMIP_FORCE_PDDR_POWERDOWN | UTMIP_XCVR_TERM_RANGE_ADJ(~0));
  392. val |= UTMIP_XCVR_TERM_RANGE_ADJ(config->term_range_adj);
  393. writel(val, base + UTMIP_XCVR_CFG1);
  394. val = readl(base + UTMIP_BIAS_CFG1);
  395. val &= ~UTMIP_BIAS_PDTRK_COUNT(~0);
  396. val |= UTMIP_BIAS_PDTRK_COUNT(0x5);
  397. writel(val, base + UTMIP_BIAS_CFG1);
  398. val = readl(base + UTMIP_SPARE_CFG0);
  399. if (config->xcvr_setup_use_fuses)
  400. val |= FUSE_SETUP_SEL;
  401. else
  402. val &= ~FUSE_SETUP_SEL;
  403. writel(val, base + UTMIP_SPARE_CFG0);
  404. if (!phy->is_legacy_phy) {
  405. val = readl(base + USB_SUSP_CTRL);
  406. val |= UTMIP_PHY_ENABLE;
  407. writel(val, base + USB_SUSP_CTRL);
  408. }
  409. val = readl(base + USB_SUSP_CTRL);
  410. val &= ~UTMIP_RESET;
  411. writel(val, base + USB_SUSP_CTRL);
  412. if (phy->is_legacy_phy) {
  413. val = readl(base + USB1_LEGACY_CTRL);
  414. val &= ~USB1_VBUS_SENSE_CTL_MASK;
  415. val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD;
  416. writel(val, base + USB1_LEGACY_CTRL);
  417. val = readl(base + USB_SUSP_CTRL);
  418. val &= ~USB_SUSP_SET;
  419. writel(val, base + USB_SUSP_CTRL);
  420. }
  421. utmi_phy_clk_enable(phy);
  422. if (phy->soc_config->requires_usbmode_setup) {
  423. val = readl(base + USB_USBMODE);
  424. val &= ~USB_USBMODE_MASK;
  425. if (phy->mode == USB_DR_MODE_HOST)
  426. val |= USB_USBMODE_HOST;
  427. else
  428. val |= USB_USBMODE_DEVICE;
  429. writel(val, base + USB_USBMODE);
  430. }
  431. if (!phy->is_legacy_phy)
  432. set_pts(phy, 0);
  433. return 0;
  434. }
  435. static int utmi_phy_power_off(struct tegra_usb_phy *phy)
  436. {
  437. unsigned long val;
  438. void __iomem *base = phy->regs;
  439. utmi_phy_clk_disable(phy);
  440. if (phy->mode == USB_DR_MODE_PERIPHERAL) {
  441. val = readl(base + USB_SUSP_CTRL);
  442. val &= ~USB_WAKEUP_DEBOUNCE_COUNT(~0);
  443. val |= USB_WAKE_ON_CNNT_EN_DEV | USB_WAKEUP_DEBOUNCE_COUNT(5);
  444. writel(val, base + USB_SUSP_CTRL);
  445. }
  446. val = readl(base + USB_SUSP_CTRL);
  447. val |= UTMIP_RESET;
  448. writel(val, base + USB_SUSP_CTRL);
  449. val = readl(base + UTMIP_BAT_CHRG_CFG0);
  450. val |= UTMIP_PD_CHRG;
  451. writel(val, base + UTMIP_BAT_CHRG_CFG0);
  452. val = readl(base + UTMIP_XCVR_CFG0);
  453. val |= UTMIP_FORCE_PD_POWERDOWN | UTMIP_FORCE_PD2_POWERDOWN |
  454. UTMIP_FORCE_PDZI_POWERDOWN;
  455. writel(val, base + UTMIP_XCVR_CFG0);
  456. val = readl(base + UTMIP_XCVR_CFG1);
  457. val |= UTMIP_FORCE_PDDISC_POWERDOWN | UTMIP_FORCE_PDCHRP_POWERDOWN |
  458. UTMIP_FORCE_PDDR_POWERDOWN;
  459. writel(val, base + UTMIP_XCVR_CFG1);
  460. return utmip_pad_power_off(phy);
  461. }
  462. static void utmi_phy_preresume(struct tegra_usb_phy *phy)
  463. {
  464. unsigned long val;
  465. void __iomem *base = phy->regs;
  466. val = readl(base + UTMIP_TX_CFG0);
  467. val |= UTMIP_HS_DISCON_DISABLE;
  468. writel(val, base + UTMIP_TX_CFG0);
  469. }
  470. static void utmi_phy_postresume(struct tegra_usb_phy *phy)
  471. {
  472. unsigned long val;
  473. void __iomem *base = phy->regs;
  474. val = readl(base + UTMIP_TX_CFG0);
  475. val &= ~UTMIP_HS_DISCON_DISABLE;
  476. writel(val, base + UTMIP_TX_CFG0);
  477. }
  478. static void utmi_phy_restore_start(struct tegra_usb_phy *phy,
  479. enum tegra_usb_phy_port_speed port_speed)
  480. {
  481. unsigned long val;
  482. void __iomem *base = phy->regs;
  483. val = readl(base + UTMIP_MISC_CFG0);
  484. val &= ~UTMIP_DPDM_OBSERVE_SEL(~0);
  485. if (port_speed == TEGRA_USB_PHY_PORT_SPEED_LOW)
  486. val |= UTMIP_DPDM_OBSERVE_SEL_FS_K;
  487. else
  488. val |= UTMIP_DPDM_OBSERVE_SEL_FS_J;
  489. writel(val, base + UTMIP_MISC_CFG0);
  490. udelay(1);
  491. val = readl(base + UTMIP_MISC_CFG0);
  492. val |= UTMIP_DPDM_OBSERVE;
  493. writel(val, base + UTMIP_MISC_CFG0);
  494. udelay(10);
  495. }
  496. static void utmi_phy_restore_end(struct tegra_usb_phy *phy)
  497. {
  498. unsigned long val;
  499. void __iomem *base = phy->regs;
  500. val = readl(base + UTMIP_MISC_CFG0);
  501. val &= ~UTMIP_DPDM_OBSERVE;
  502. writel(val, base + UTMIP_MISC_CFG0);
  503. udelay(10);
  504. }
  505. static int ulpi_phy_power_on(struct tegra_usb_phy *phy)
  506. {
  507. int ret;
  508. unsigned long val;
  509. void __iomem *base = phy->regs;
  510. ret = gpio_direction_output(phy->reset_gpio, 0);
  511. if (ret < 0) {
  512. dev_err(phy->u_phy.dev, "gpio %d not set to 0\n",
  513. phy->reset_gpio);
  514. return ret;
  515. }
  516. msleep(5);
  517. ret = gpio_direction_output(phy->reset_gpio, 1);
  518. if (ret < 0) {
  519. dev_err(phy->u_phy.dev, "gpio %d not set to 1\n",
  520. phy->reset_gpio);
  521. return ret;
  522. }
  523. clk_prepare_enable(phy->clk);
  524. msleep(1);
  525. val = readl(base + USB_SUSP_CTRL);
  526. val |= UHSIC_RESET;
  527. writel(val, base + USB_SUSP_CTRL);
  528. val = readl(base + ULPI_TIMING_CTRL_0);
  529. val |= ULPI_OUTPUT_PINMUX_BYP | ULPI_CLKOUT_PINMUX_BYP;
  530. writel(val, base + ULPI_TIMING_CTRL_0);
  531. val = readl(base + USB_SUSP_CTRL);
  532. val |= ULPI_PHY_ENABLE;
  533. writel(val, base + USB_SUSP_CTRL);
  534. val = 0;
  535. writel(val, base + ULPI_TIMING_CTRL_1);
  536. val |= ULPI_DATA_TRIMMER_SEL(4);
  537. val |= ULPI_STPDIRNXT_TRIMMER_SEL(4);
  538. val |= ULPI_DIR_TRIMMER_SEL(4);
  539. writel(val, base + ULPI_TIMING_CTRL_1);
  540. udelay(10);
  541. val |= ULPI_DATA_TRIMMER_LOAD;
  542. val |= ULPI_STPDIRNXT_TRIMMER_LOAD;
  543. val |= ULPI_DIR_TRIMMER_LOAD;
  544. writel(val, base + ULPI_TIMING_CTRL_1);
  545. /* Fix VbusInvalid due to floating VBUS */
  546. ret = usb_phy_io_write(phy->ulpi, 0x40, 0x08);
  547. if (ret) {
  548. pr_err("%s: ulpi write failed\n", __func__);
  549. return ret;
  550. }
  551. ret = usb_phy_io_write(phy->ulpi, 0x80, 0x0B);
  552. if (ret) {
  553. pr_err("%s: ulpi write failed\n", __func__);
  554. return ret;
  555. }
  556. val = readl(base + USB_SUSP_CTRL);
  557. val |= USB_SUSP_CLR;
  558. writel(val, base + USB_SUSP_CTRL);
  559. udelay(100);
  560. val = readl(base + USB_SUSP_CTRL);
  561. val &= ~USB_SUSP_CLR;
  562. writel(val, base + USB_SUSP_CTRL);
  563. return 0;
  564. }
  565. static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
  566. {
  567. clk_disable(phy->clk);
  568. return gpio_direction_output(phy->reset_gpio, 0);
  569. }
  570. static void tegra_usb_phy_close(struct tegra_usb_phy *phy)
  571. {
  572. if (!IS_ERR(phy->vbus))
  573. regulator_disable(phy->vbus);
  574. clk_disable_unprepare(phy->pll_u);
  575. }
  576. static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
  577. {
  578. if (phy->is_ulpi_phy)
  579. return ulpi_phy_power_on(phy);
  580. else
  581. return utmi_phy_power_on(phy);
  582. }
  583. static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
  584. {
  585. if (phy->is_ulpi_phy)
  586. return ulpi_phy_power_off(phy);
  587. else
  588. return utmi_phy_power_off(phy);
  589. }
  590. static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend)
  591. {
  592. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  593. if (suspend)
  594. return tegra_usb_phy_power_off(phy);
  595. else
  596. return tegra_usb_phy_power_on(phy);
  597. }
  598. static int ulpi_open(struct tegra_usb_phy *phy)
  599. {
  600. int err;
  601. phy->clk = devm_clk_get(phy->u_phy.dev, "ulpi-link");
  602. if (IS_ERR(phy->clk)) {
  603. pr_err("%s: can't get ulpi clock\n", __func__);
  604. return PTR_ERR(phy->clk);
  605. }
  606. err = devm_gpio_request(phy->u_phy.dev, phy->reset_gpio,
  607. "ulpi_phy_reset_b");
  608. if (err < 0) {
  609. dev_err(phy->u_phy.dev, "request failed for gpio: %d\n",
  610. phy->reset_gpio);
  611. return err;
  612. }
  613. err = gpio_direction_output(phy->reset_gpio, 0);
  614. if (err < 0) {
  615. dev_err(phy->u_phy.dev, "gpio %d direction not set to output\n",
  616. phy->reset_gpio);
  617. return err;
  618. }
  619. phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0);
  620. if (!phy->ulpi) {
  621. dev_err(phy->u_phy.dev, "otg_ulpi_create returned NULL\n");
  622. err = -ENOMEM;
  623. return err;
  624. }
  625. phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT;
  626. return 0;
  627. }
  628. static int tegra_usb_phy_init(struct tegra_usb_phy *phy)
  629. {
  630. unsigned long parent_rate;
  631. int i;
  632. int err;
  633. phy->pll_u = devm_clk_get(phy->u_phy.dev, "pll_u");
  634. if (IS_ERR(phy->pll_u)) {
  635. pr_err("Can't get pll_u clock\n");
  636. return PTR_ERR(phy->pll_u);
  637. }
  638. err = clk_prepare_enable(phy->pll_u);
  639. if (err)
  640. return err;
  641. parent_rate = clk_get_rate(clk_get_parent(phy->pll_u));
  642. for (i = 0; i < ARRAY_SIZE(tegra_freq_table); i++) {
  643. if (tegra_freq_table[i].freq == parent_rate) {
  644. phy->freq = &tegra_freq_table[i];
  645. break;
  646. }
  647. }
  648. if (!phy->freq) {
  649. pr_err("invalid pll_u parent rate %ld\n", parent_rate);
  650. err = -EINVAL;
  651. goto fail;
  652. }
  653. if (!IS_ERR(phy->vbus)) {
  654. err = regulator_enable(phy->vbus);
  655. if (err) {
  656. dev_err(phy->u_phy.dev,
  657. "failed to enable usb vbus regulator: %d\n",
  658. err);
  659. goto fail;
  660. }
  661. }
  662. if (phy->is_ulpi_phy)
  663. err = ulpi_open(phy);
  664. else
  665. err = utmip_pad_open(phy);
  666. if (err < 0)
  667. goto fail;
  668. return 0;
  669. fail:
  670. clk_disable_unprepare(phy->pll_u);
  671. return err;
  672. }
  673. void tegra_usb_phy_preresume(struct usb_phy *x)
  674. {
  675. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  676. if (!phy->is_ulpi_phy)
  677. utmi_phy_preresume(phy);
  678. }
  679. EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume);
  680. void tegra_usb_phy_postresume(struct usb_phy *x)
  681. {
  682. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  683. if (!phy->is_ulpi_phy)
  684. utmi_phy_postresume(phy);
  685. }
  686. EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
  687. void tegra_ehci_phy_restore_start(struct usb_phy *x,
  688. enum tegra_usb_phy_port_speed port_speed)
  689. {
  690. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  691. if (!phy->is_ulpi_phy)
  692. utmi_phy_restore_start(phy, port_speed);
  693. }
  694. EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start);
  695. void tegra_ehci_phy_restore_end(struct usb_phy *x)
  696. {
  697. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  698. if (!phy->is_ulpi_phy)
  699. utmi_phy_restore_end(phy);
  700. }
  701. EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
  702. static int read_utmi_param(struct platform_device *pdev, const char *param,
  703. u8 *dest)
  704. {
  705. u32 value;
  706. int err = of_property_read_u32(pdev->dev.of_node, param, &value);
  707. *dest = (u8)value;
  708. if (err < 0)
  709. dev_err(&pdev->dev, "Failed to read USB UTMI parameter %s: %d\n",
  710. param, err);
  711. return err;
  712. }
  713. static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
  714. struct platform_device *pdev)
  715. {
  716. struct resource *res;
  717. int err;
  718. struct tegra_utmip_config *config;
  719. tegra_phy->is_ulpi_phy = false;
  720. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  721. if (!res) {
  722. dev_err(&pdev->dev, "Failed to get UTMI Pad regs\n");
  723. return -ENXIO;
  724. }
  725. tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start,
  726. resource_size(res));
  727. if (!tegra_phy->pad_regs) {
  728. dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n");
  729. return -ENOMEM;
  730. }
  731. tegra_phy->config = devm_kzalloc(&pdev->dev, sizeof(*config),
  732. GFP_KERNEL);
  733. if (!tegra_phy->config)
  734. return -ENOMEM;
  735. config = tegra_phy->config;
  736. err = read_utmi_param(pdev, "nvidia,hssync-start-delay",
  737. &config->hssync_start_delay);
  738. if (err < 0)
  739. return err;
  740. err = read_utmi_param(pdev, "nvidia,elastic-limit",
  741. &config->elastic_limit);
  742. if (err < 0)
  743. return err;
  744. err = read_utmi_param(pdev, "nvidia,idle-wait-delay",
  745. &config->idle_wait_delay);
  746. if (err < 0)
  747. return err;
  748. err = read_utmi_param(pdev, "nvidia,term-range-adj",
  749. &config->term_range_adj);
  750. if (err < 0)
  751. return err;
  752. err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew",
  753. &config->xcvr_lsfslew);
  754. if (err < 0)
  755. return err;
  756. err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew",
  757. &config->xcvr_lsrslew);
  758. if (err < 0)
  759. return err;
  760. if (tegra_phy->soc_config->requires_extra_tuning_parameters) {
  761. err = read_utmi_param(pdev, "nvidia,xcvr-hsslew",
  762. &config->xcvr_hsslew);
  763. if (err < 0)
  764. return err;
  765. err = read_utmi_param(pdev, "nvidia,hssquelch-level",
  766. &config->hssquelch_level);
  767. if (err < 0)
  768. return err;
  769. err = read_utmi_param(pdev, "nvidia,hsdiscon-level",
  770. &config->hsdiscon_level);
  771. if (err < 0)
  772. return err;
  773. }
  774. config->xcvr_setup_use_fuses = of_property_read_bool(
  775. pdev->dev.of_node, "nvidia,xcvr-setup-use-fuses");
  776. if (!config->xcvr_setup_use_fuses) {
  777. err = read_utmi_param(pdev, "nvidia,xcvr-setup",
  778. &config->xcvr_setup);
  779. if (err < 0)
  780. return err;
  781. }
  782. return 0;
  783. }
  784. static const struct tegra_phy_soc_config tegra20_soc_config = {
  785. .utmi_pll_config_in_car_module = false,
  786. .has_hostpc = false,
  787. .requires_usbmode_setup = false,
  788. .requires_extra_tuning_parameters = false,
  789. };
  790. static const struct tegra_phy_soc_config tegra30_soc_config = {
  791. .utmi_pll_config_in_car_module = true,
  792. .has_hostpc = true,
  793. .requires_usbmode_setup = true,
  794. .requires_extra_tuning_parameters = true,
  795. };
  796. static const struct of_device_id tegra_usb_phy_id_table[] = {
  797. { .compatible = "nvidia,tegra30-usb-phy", .data = &tegra30_soc_config },
  798. { .compatible = "nvidia,tegra20-usb-phy", .data = &tegra20_soc_config },
  799. { },
  800. };
  801. MODULE_DEVICE_TABLE(of, tegra_usb_phy_id_table);
  802. static int tegra_usb_phy_probe(struct platform_device *pdev)
  803. {
  804. const struct of_device_id *match;
  805. struct resource *res;
  806. struct tegra_usb_phy *tegra_phy = NULL;
  807. struct device_node *np = pdev->dev.of_node;
  808. enum usb_phy_interface phy_type;
  809. int err;
  810. tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL);
  811. if (!tegra_phy)
  812. return -ENOMEM;
  813. match = of_match_device(tegra_usb_phy_id_table, &pdev->dev);
  814. if (!match) {
  815. dev_err(&pdev->dev, "Error: No device match found\n");
  816. return -ENODEV;
  817. }
  818. tegra_phy->soc_config = match->data;
  819. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  820. if (!res) {
  821. dev_err(&pdev->dev, "Failed to get I/O memory\n");
  822. return -ENXIO;
  823. }
  824. tegra_phy->regs = devm_ioremap(&pdev->dev, res->start,
  825. resource_size(res));
  826. if (!tegra_phy->regs) {
  827. dev_err(&pdev->dev, "Failed to remap I/O memory\n");
  828. return -ENOMEM;
  829. }
  830. tegra_phy->is_legacy_phy =
  831. of_property_read_bool(np, "nvidia,has-legacy-mode");
  832. phy_type = of_usb_get_phy_mode(np);
  833. switch (phy_type) {
  834. case USBPHY_INTERFACE_MODE_UTMI:
  835. err = utmi_phy_probe(tegra_phy, pdev);
  836. if (err < 0)
  837. return err;
  838. break;
  839. case USBPHY_INTERFACE_MODE_ULPI:
  840. tegra_phy->is_ulpi_phy = true;
  841. tegra_phy->reset_gpio =
  842. of_get_named_gpio(np, "nvidia,phy-reset-gpio", 0);
  843. if (!gpio_is_valid(tegra_phy->reset_gpio)) {
  844. dev_err(&pdev->dev, "invalid gpio: %d\n",
  845. tegra_phy->reset_gpio);
  846. return tegra_phy->reset_gpio;
  847. }
  848. tegra_phy->config = NULL;
  849. break;
  850. default:
  851. dev_err(&pdev->dev, "phy_type is invalid or unsupported\n");
  852. return -EINVAL;
  853. }
  854. if (of_find_property(np, "dr_mode", NULL))
  855. tegra_phy->mode = usb_get_dr_mode(&pdev->dev);
  856. else
  857. tegra_phy->mode = USB_DR_MODE_HOST;
  858. if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) {
  859. dev_err(&pdev->dev, "dr_mode is invalid\n");
  860. return -EINVAL;
  861. }
  862. /* On some boards, the VBUS regulator doesn't need to be controlled */
  863. if (of_find_property(np, "vbus-supply", NULL)) {
  864. tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus");
  865. if (IS_ERR(tegra_phy->vbus))
  866. return PTR_ERR(tegra_phy->vbus);
  867. } else {
  868. dev_notice(&pdev->dev, "no vbus regulator");
  869. tegra_phy->vbus = ERR_PTR(-ENODEV);
  870. }
  871. tegra_phy->u_phy.dev = &pdev->dev;
  872. err = tegra_usb_phy_init(tegra_phy);
  873. if (err < 0)
  874. return err;
  875. tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend;
  876. platform_set_drvdata(pdev, tegra_phy);
  877. err = usb_add_phy_dev(&tegra_phy->u_phy);
  878. if (err < 0) {
  879. tegra_usb_phy_close(tegra_phy);
  880. return err;
  881. }
  882. return 0;
  883. }
  884. static int tegra_usb_phy_remove(struct platform_device *pdev)
  885. {
  886. struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev);
  887. usb_remove_phy(&tegra_phy->u_phy);
  888. tegra_usb_phy_close(tegra_phy);
  889. return 0;
  890. }
  891. static struct platform_driver tegra_usb_phy_driver = {
  892. .probe = tegra_usb_phy_probe,
  893. .remove = tegra_usb_phy_remove,
  894. .driver = {
  895. .name = "tegra-phy",
  896. .of_match_table = tegra_usb_phy_id_table,
  897. },
  898. };
  899. module_platform_driver(tegra_usb_phy_driver);
  900. MODULE_DESCRIPTION("Tegra USB PHY driver");
  901. MODULE_LICENSE("GPL v2");