phy-tegra-usb.c 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. /*
  2. * Copyright (C) 2010 Google, Inc.
  3. * Copyright (C) 2013 NVIDIA Corporation
  4. *
  5. * Author:
  6. * Erik Gilling <konkers@google.com>
  7. * Benoit Goby <benoit@android.com>
  8. * Venu Byravarasu <vbyravarasu@nvidia.com>
  9. *
  10. * This software is licensed under the terms of the GNU General Public
  11. * License version 2, as published by the Free Software Foundation, and
  12. * may be copied, distributed, and modified under those terms.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. */
  20. #include <linux/resource.h>
  21. #include <linux/delay.h>
  22. #include <linux/slab.h>
  23. #include <linux/err.h>
  24. #include <linux/export.h>
  25. #include <linux/module.h>
  26. #include <linux/platform_device.h>
  27. #include <linux/io.h>
  28. #include <linux/gpio.h>
  29. #include <linux/of.h>
  30. #include <linux/of_device.h>
  31. #include <linux/of_gpio.h>
  32. #include <linux/usb/otg.h>
  33. #include <linux/usb/ulpi.h>
  34. #include <linux/usb/of.h>
  35. #include <asm/mach-types.h>
  36. #include <linux/usb/ehci_def.h>
  37. #include <linux/usb/tegra_usb_phy.h>
  38. #include <linux/regulator/consumer.h>
  39. #define ULPI_VIEWPORT 0x170
  40. /* PORTSC PTS/PHCD bits, Tegra20 only */
  41. #define TEGRA_USB_PORTSC1 0x184
  42. #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30)
  43. #define TEGRA_USB_PORTSC1_PHCD (1 << 23)
  44. /* HOSTPC1 PTS/PHCD bits, Tegra30 and above */
  45. #define TEGRA_USB_HOSTPC1_DEVLC 0x1b4
  46. #define TEGRA_USB_HOSTPC1_DEVLC_PTS(x) (((x) & 0x7) << 29)
  47. #define TEGRA_USB_HOSTPC1_DEVLC_PHCD (1 << 22)
  48. /* Bits of PORTSC1, which will get cleared by writing 1 into them */
  49. #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC)
  50. #define USB_SUSP_CTRL 0x400
  51. #define USB_WAKE_ON_CNNT_EN_DEV (1 << 3)
  52. #define USB_WAKE_ON_DISCON_EN_DEV (1 << 4)
  53. #define USB_SUSP_CLR (1 << 5)
  54. #define USB_PHY_CLK_VALID (1 << 7)
  55. #define UTMIP_RESET (1 << 11)
  56. #define UHSIC_RESET (1 << 11)
  57. #define UTMIP_PHY_ENABLE (1 << 12)
  58. #define ULPI_PHY_ENABLE (1 << 13)
  59. #define USB_SUSP_SET (1 << 14)
  60. #define USB_WAKEUP_DEBOUNCE_COUNT(x) (((x) & 0x7) << 16)
  61. #define USB1_LEGACY_CTRL 0x410
  62. #define USB1_NO_LEGACY_MODE (1 << 0)
  63. #define USB1_VBUS_SENSE_CTL_MASK (3 << 1)
  64. #define USB1_VBUS_SENSE_CTL_VBUS_WAKEUP (0 << 1)
  65. #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD_OR_VBUS_WAKEUP \
  66. (1 << 1)
  67. #define USB1_VBUS_SENSE_CTL_AB_SESS_VLD (2 << 1)
  68. #define USB1_VBUS_SENSE_CTL_A_SESS_VLD (3 << 1)
  69. #define ULPI_TIMING_CTRL_0 0x424
  70. #define ULPI_OUTPUT_PINMUX_BYP (1 << 10)
  71. #define ULPI_CLKOUT_PINMUX_BYP (1 << 11)
  72. #define ULPI_TIMING_CTRL_1 0x428
  73. #define ULPI_DATA_TRIMMER_LOAD (1 << 0)
  74. #define ULPI_DATA_TRIMMER_SEL(x) (((x) & 0x7) << 1)
  75. #define ULPI_STPDIRNXT_TRIMMER_LOAD (1 << 16)
  76. #define ULPI_STPDIRNXT_TRIMMER_SEL(x) (((x) & 0x7) << 17)
  77. #define ULPI_DIR_TRIMMER_LOAD (1 << 24)
  78. #define ULPI_DIR_TRIMMER_SEL(x) (((x) & 0x7) << 25)
  79. #define UTMIP_PLL_CFG1 0x804
  80. #define UTMIP_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0)
  81. #define UTMIP_PLLU_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 27)
  82. #define UTMIP_XCVR_CFG0 0x808
  83. #define UTMIP_XCVR_SETUP(x) (((x) & 0xf) << 0)
  84. #define UTMIP_XCVR_SETUP_MSB(x) ((((x) & 0x70) >> 4) << 22)
  85. #define UTMIP_XCVR_LSRSLEW(x) (((x) & 0x3) << 8)
  86. #define UTMIP_XCVR_LSFSLEW(x) (((x) & 0x3) << 10)
  87. #define UTMIP_FORCE_PD_POWERDOWN (1 << 14)
  88. #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16)
  89. #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18)
  90. #define UTMIP_XCVR_LSBIAS_SEL (1 << 21)
  91. #define UTMIP_XCVR_HSSLEW(x) (((x) & 0x3) << 4)
  92. #define UTMIP_XCVR_HSSLEW_MSB(x) ((((x) & 0x1fc) >> 2) << 25)
  93. #define UTMIP_BIAS_CFG0 0x80c
  94. #define UTMIP_OTGPD (1 << 11)
  95. #define UTMIP_BIASPD (1 << 10)
  96. #define UTMIP_HSSQUELCH_LEVEL(x) (((x) & 0x3) << 0)
  97. #define UTMIP_HSDISCON_LEVEL(x) (((x) & 0x3) << 2)
  98. #define UTMIP_HSDISCON_LEVEL_MSB(x) ((((x) & 0x4) >> 2) << 24)
  99. #define UTMIP_HSRX_CFG0 0x810
  100. #define UTMIP_ELASTIC_LIMIT(x) (((x) & 0x1f) << 10)
  101. #define UTMIP_IDLE_WAIT(x) (((x) & 0x1f) << 15)
  102. #define UTMIP_HSRX_CFG1 0x814
  103. #define UTMIP_HS_SYNC_START_DLY(x) (((x) & 0x1f) << 1)
  104. #define UTMIP_TX_CFG0 0x820
  105. #define UTMIP_FS_PREABMLE_J (1 << 19)
  106. #define UTMIP_HS_DISCON_DISABLE (1 << 8)
  107. #define UTMIP_MISC_CFG0 0x824
  108. #define UTMIP_DPDM_OBSERVE (1 << 26)
  109. #define UTMIP_DPDM_OBSERVE_SEL(x) (((x) & 0xf) << 27)
  110. #define UTMIP_DPDM_OBSERVE_SEL_FS_J UTMIP_DPDM_OBSERVE_SEL(0xf)
  111. #define UTMIP_DPDM_OBSERVE_SEL_FS_K UTMIP_DPDM_OBSERVE_SEL(0xe)
  112. #define UTMIP_DPDM_OBSERVE_SEL_FS_SE1 UTMIP_DPDM_OBSERVE_SEL(0xd)
  113. #define UTMIP_DPDM_OBSERVE_SEL_FS_SE0 UTMIP_DPDM_OBSERVE_SEL(0xc)
  114. #define UTMIP_SUSPEND_EXIT_ON_EDGE (1 << 22)
  115. #define UTMIP_MISC_CFG1 0x828
  116. #define UTMIP_PLL_ACTIVE_DLY_COUNT(x) (((x) & 0x1f) << 18)
  117. #define UTMIP_PLLU_STABLE_COUNT(x) (((x) & 0xfff) << 6)
  118. #define UTMIP_DEBOUNCE_CFG0 0x82c
  119. #define UTMIP_BIAS_DEBOUNCE_A(x) (((x) & 0xffff) << 0)
  120. #define UTMIP_BAT_CHRG_CFG0 0x830
  121. #define UTMIP_PD_CHRG (1 << 0)
  122. #define UTMIP_SPARE_CFG0 0x834
  123. #define FUSE_SETUP_SEL (1 << 3)
  124. #define UTMIP_XCVR_CFG1 0x838
  125. #define UTMIP_FORCE_PDDISC_POWERDOWN (1 << 0)
  126. #define UTMIP_FORCE_PDCHRP_POWERDOWN (1 << 2)
  127. #define UTMIP_FORCE_PDDR_POWERDOWN (1 << 4)
  128. #define UTMIP_XCVR_TERM_RANGE_ADJ(x) (((x) & 0xf) << 18)
  129. #define UTMIP_BIAS_CFG1 0x83c
  130. #define UTMIP_BIAS_PDTRK_COUNT(x) (((x) & 0x1f) << 3)
  131. /* For Tegra30 and above only, the address is different in Tegra20 */
  132. #define USB_USBMODE 0x1f8
  133. #define USB_USBMODE_MASK (3 << 0)
  134. #define USB_USBMODE_HOST (3 << 0)
  135. #define USB_USBMODE_DEVICE (2 << 0)
  136. static DEFINE_SPINLOCK(utmip_pad_lock);
  137. static int utmip_pad_count;
  138. struct tegra_xtal_freq {
  139. int freq;
  140. u8 enable_delay;
  141. u8 stable_count;
  142. u8 active_delay;
  143. u8 xtal_freq_count;
  144. u16 debounce;
  145. };
  146. static const struct tegra_xtal_freq tegra_freq_table[] = {
  147. {
  148. .freq = 12000000,
  149. .enable_delay = 0x02,
  150. .stable_count = 0x2F,
  151. .active_delay = 0x04,
  152. .xtal_freq_count = 0x76,
  153. .debounce = 0x7530,
  154. },
  155. {
  156. .freq = 13000000,
  157. .enable_delay = 0x02,
  158. .stable_count = 0x33,
  159. .active_delay = 0x05,
  160. .xtal_freq_count = 0x7F,
  161. .debounce = 0x7EF4,
  162. },
  163. {
  164. .freq = 19200000,
  165. .enable_delay = 0x03,
  166. .stable_count = 0x4B,
  167. .active_delay = 0x06,
  168. .xtal_freq_count = 0xBB,
  169. .debounce = 0xBB80,
  170. },
  171. {
  172. .freq = 26000000,
  173. .enable_delay = 0x04,
  174. .stable_count = 0x66,
  175. .active_delay = 0x09,
  176. .xtal_freq_count = 0xFE,
  177. .debounce = 0xFDE8,
  178. },
  179. };
  180. static void set_pts(struct tegra_usb_phy *phy, u8 pts_val)
  181. {
  182. void __iomem *base = phy->regs;
  183. unsigned long val;
  184. if (phy->soc_config->has_hostpc) {
  185. val = readl(base + TEGRA_USB_HOSTPC1_DEVLC);
  186. val &= ~TEGRA_USB_HOSTPC1_DEVLC_PTS(~0);
  187. val |= TEGRA_USB_HOSTPC1_DEVLC_PTS(pts_val);
  188. writel(val, base + TEGRA_USB_HOSTPC1_DEVLC);
  189. } else {
  190. val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS;
  191. val &= ~TEGRA_USB_PORTSC1_PTS(~0);
  192. val |= TEGRA_USB_PORTSC1_PTS(pts_val);
  193. writel(val, base + TEGRA_USB_PORTSC1);
  194. }
  195. }
  196. static void set_phcd(struct tegra_usb_phy *phy, bool enable)
  197. {
  198. void __iomem *base = phy->regs;
  199. unsigned long val;
  200. if (phy->soc_config->has_hostpc) {
  201. val = readl(base + TEGRA_USB_HOSTPC1_DEVLC);
  202. if (enable)
  203. val |= TEGRA_USB_HOSTPC1_DEVLC_PHCD;
  204. else
  205. val &= ~TEGRA_USB_HOSTPC1_DEVLC_PHCD;
  206. writel(val, base + TEGRA_USB_HOSTPC1_DEVLC);
  207. } else {
  208. val = readl(base + TEGRA_USB_PORTSC1) & ~PORT_RWC_BITS;
  209. if (enable)
  210. val |= TEGRA_USB_PORTSC1_PHCD;
  211. else
  212. val &= ~TEGRA_USB_PORTSC1_PHCD;
  213. writel(val, base + TEGRA_USB_PORTSC1);
  214. }
  215. }
  216. static int utmip_pad_open(struct tegra_usb_phy *phy)
  217. {
  218. phy->pad_clk = devm_clk_get(phy->u_phy.dev, "utmi-pads");
  219. if (IS_ERR(phy->pad_clk)) {
  220. pr_err("%s: can't get utmip pad clock\n", __func__);
  221. return PTR_ERR(phy->pad_clk);
  222. }
  223. return 0;
  224. }
  225. static void utmip_pad_power_on(struct tegra_usb_phy *phy)
  226. {
  227. unsigned long val, flags;
  228. void __iomem *base = phy->pad_regs;
  229. struct tegra_utmip_config *config = phy->config;
  230. clk_prepare_enable(phy->pad_clk);
  231. spin_lock_irqsave(&utmip_pad_lock, flags);
  232. if (utmip_pad_count++ == 0) {
  233. val = readl(base + UTMIP_BIAS_CFG0);
  234. val &= ~(UTMIP_OTGPD | UTMIP_BIASPD);
  235. if (phy->soc_config->requires_extra_tuning_parameters) {
  236. val &= ~(UTMIP_HSSQUELCH_LEVEL(~0) |
  237. UTMIP_HSDISCON_LEVEL(~0) |
  238. UTMIP_HSDISCON_LEVEL_MSB(~0));
  239. val |= UTMIP_HSSQUELCH_LEVEL(config->hssquelch_level);
  240. val |= UTMIP_HSDISCON_LEVEL(config->hsdiscon_level);
  241. val |= UTMIP_HSDISCON_LEVEL_MSB(config->hsdiscon_level);
  242. }
  243. writel(val, base + UTMIP_BIAS_CFG0);
  244. }
  245. spin_unlock_irqrestore(&utmip_pad_lock, flags);
  246. clk_disable_unprepare(phy->pad_clk);
  247. }
  248. static int utmip_pad_power_off(struct tegra_usb_phy *phy)
  249. {
  250. unsigned long val, flags;
  251. void __iomem *base = phy->pad_regs;
  252. if (!utmip_pad_count) {
  253. pr_err("%s: utmip pad already powered off\n", __func__);
  254. return -EINVAL;
  255. }
  256. clk_prepare_enable(phy->pad_clk);
  257. spin_lock_irqsave(&utmip_pad_lock, flags);
  258. if (--utmip_pad_count == 0) {
  259. val = readl(base + UTMIP_BIAS_CFG0);
  260. val |= UTMIP_OTGPD | UTMIP_BIASPD;
  261. writel(val, base + UTMIP_BIAS_CFG0);
  262. }
  263. spin_unlock_irqrestore(&utmip_pad_lock, flags);
  264. clk_disable_unprepare(phy->pad_clk);
  265. return 0;
  266. }
  267. static int utmi_wait_register(void __iomem *reg, u32 mask, u32 result)
  268. {
  269. unsigned long timeout = 2000;
  270. do {
  271. if ((readl(reg) & mask) == result)
  272. return 0;
  273. udelay(1);
  274. timeout--;
  275. } while (timeout);
  276. return -1;
  277. }
  278. static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
  279. {
  280. unsigned long val;
  281. void __iomem *base = phy->regs;
  282. if (phy->is_legacy_phy) {
  283. val = readl(base + USB_SUSP_CTRL);
  284. val |= USB_SUSP_SET;
  285. writel(val, base + USB_SUSP_CTRL);
  286. udelay(10);
  287. val = readl(base + USB_SUSP_CTRL);
  288. val &= ~USB_SUSP_SET;
  289. writel(val, base + USB_SUSP_CTRL);
  290. } else
  291. set_phcd(phy, true);
  292. if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) < 0)
  293. pr_err("%s: timeout waiting for phy to stabilize\n", __func__);
  294. }
  295. static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
  296. {
  297. unsigned long val;
  298. void __iomem *base = phy->regs;
  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 usb_phy *x)
  571. {
  572. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  573. if (!IS_ERR(phy->vbus))
  574. regulator_disable(phy->vbus);
  575. clk_disable_unprepare(phy->pll_u);
  576. }
  577. static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
  578. {
  579. if (phy->is_ulpi_phy)
  580. return ulpi_phy_power_on(phy);
  581. else
  582. return utmi_phy_power_on(phy);
  583. }
  584. static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
  585. {
  586. if (phy->is_ulpi_phy)
  587. return ulpi_phy_power_off(phy);
  588. else
  589. return utmi_phy_power_off(phy);
  590. }
  591. static int tegra_usb_phy_suspend(struct usb_phy *x, int suspend)
  592. {
  593. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  594. if (suspend)
  595. return tegra_usb_phy_power_off(phy);
  596. else
  597. return tegra_usb_phy_power_on(phy);
  598. }
  599. static int ulpi_open(struct tegra_usb_phy *phy)
  600. {
  601. int err;
  602. phy->clk = devm_clk_get(phy->u_phy.dev, "ulpi-link");
  603. if (IS_ERR(phy->clk)) {
  604. pr_err("%s: can't get ulpi clock\n", __func__);
  605. return PTR_ERR(phy->clk);
  606. }
  607. err = devm_gpio_request(phy->u_phy.dev, phy->reset_gpio,
  608. "ulpi_phy_reset_b");
  609. if (err < 0) {
  610. dev_err(phy->u_phy.dev, "request failed for gpio: %d\n",
  611. phy->reset_gpio);
  612. return err;
  613. }
  614. err = gpio_direction_output(phy->reset_gpio, 0);
  615. if (err < 0) {
  616. dev_err(phy->u_phy.dev, "gpio %d direction not set to output\n",
  617. phy->reset_gpio);
  618. return err;
  619. }
  620. phy->ulpi = otg_ulpi_create(&ulpi_viewport_access_ops, 0);
  621. if (!phy->ulpi) {
  622. dev_err(phy->u_phy.dev, "otg_ulpi_create returned NULL\n");
  623. err = -ENOMEM;
  624. return err;
  625. }
  626. phy->ulpi->io_priv = phy->regs + ULPI_VIEWPORT;
  627. return 0;
  628. }
  629. static int tegra_usb_phy_init(struct tegra_usb_phy *phy)
  630. {
  631. unsigned long parent_rate;
  632. int i;
  633. int err;
  634. phy->pll_u = devm_clk_get(phy->u_phy.dev, "pll_u");
  635. if (IS_ERR(phy->pll_u)) {
  636. pr_err("Can't get pll_u clock\n");
  637. return PTR_ERR(phy->pll_u);
  638. }
  639. err = clk_prepare_enable(phy->pll_u);
  640. if (err)
  641. return err;
  642. parent_rate = clk_get_rate(clk_get_parent(phy->pll_u));
  643. for (i = 0; i < ARRAY_SIZE(tegra_freq_table); i++) {
  644. if (tegra_freq_table[i].freq == parent_rate) {
  645. phy->freq = &tegra_freq_table[i];
  646. break;
  647. }
  648. }
  649. if (!phy->freq) {
  650. pr_err("invalid pll_u parent rate %ld\n", parent_rate);
  651. err = -EINVAL;
  652. goto fail;
  653. }
  654. if (!IS_ERR(phy->vbus)) {
  655. err = regulator_enable(phy->vbus);
  656. if (err) {
  657. dev_err(phy->u_phy.dev,
  658. "failed to enable usb vbus regulator: %d\n",
  659. err);
  660. goto fail;
  661. }
  662. }
  663. if (phy->is_ulpi_phy)
  664. err = ulpi_open(phy);
  665. else
  666. err = utmip_pad_open(phy);
  667. if (err < 0)
  668. goto fail;
  669. return 0;
  670. fail:
  671. clk_disable_unprepare(phy->pll_u);
  672. return err;
  673. }
  674. void tegra_usb_phy_preresume(struct usb_phy *x)
  675. {
  676. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  677. if (!phy->is_ulpi_phy)
  678. utmi_phy_preresume(phy);
  679. }
  680. EXPORT_SYMBOL_GPL(tegra_usb_phy_preresume);
  681. void tegra_usb_phy_postresume(struct usb_phy *x)
  682. {
  683. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  684. if (!phy->is_ulpi_phy)
  685. utmi_phy_postresume(phy);
  686. }
  687. EXPORT_SYMBOL_GPL(tegra_usb_phy_postresume);
  688. void tegra_ehci_phy_restore_start(struct usb_phy *x,
  689. enum tegra_usb_phy_port_speed port_speed)
  690. {
  691. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  692. if (!phy->is_ulpi_phy)
  693. utmi_phy_restore_start(phy, port_speed);
  694. }
  695. EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_start);
  696. void tegra_ehci_phy_restore_end(struct usb_phy *x)
  697. {
  698. struct tegra_usb_phy *phy = container_of(x, struct tegra_usb_phy, u_phy);
  699. if (!phy->is_ulpi_phy)
  700. utmi_phy_restore_end(phy);
  701. }
  702. EXPORT_SYMBOL_GPL(tegra_ehci_phy_restore_end);
  703. static int read_utmi_param(struct platform_device *pdev, const char *param,
  704. u8 *dest)
  705. {
  706. u32 value;
  707. int err = of_property_read_u32(pdev->dev.of_node, param, &value);
  708. *dest = (u8)value;
  709. if (err < 0)
  710. dev_err(&pdev->dev, "Failed to read USB UTMI parameter %s: %d\n",
  711. param, err);
  712. return err;
  713. }
  714. static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
  715. struct platform_device *pdev)
  716. {
  717. struct resource *res;
  718. int err;
  719. struct tegra_utmip_config *config;
  720. tegra_phy->is_ulpi_phy = false;
  721. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  722. if (!res) {
  723. dev_err(&pdev->dev, "Failed to get UTMI Pad regs\n");
  724. return -ENXIO;
  725. }
  726. tegra_phy->pad_regs = devm_ioremap(&pdev->dev, res->start,
  727. resource_size(res));
  728. if (!tegra_phy->regs) {
  729. dev_err(&pdev->dev, "Failed to remap UTMI Pad regs\n");
  730. return -ENOMEM;
  731. }
  732. tegra_phy->config = devm_kzalloc(&pdev->dev,
  733. sizeof(*tegra_phy->config), GFP_KERNEL);
  734. if (!tegra_phy->config) {
  735. dev_err(&pdev->dev,
  736. "unable to allocate memory for USB UTMIP config\n");
  737. return -ENOMEM;
  738. }
  739. config = tegra_phy->config;
  740. err = read_utmi_param(pdev, "nvidia,hssync-start-delay",
  741. &config->hssync_start_delay);
  742. if (err < 0)
  743. return err;
  744. err = read_utmi_param(pdev, "nvidia,elastic-limit",
  745. &config->elastic_limit);
  746. if (err < 0)
  747. return err;
  748. err = read_utmi_param(pdev, "nvidia,idle-wait-delay",
  749. &config->idle_wait_delay);
  750. if (err < 0)
  751. return err;
  752. err = read_utmi_param(pdev, "nvidia,term-range-adj",
  753. &config->term_range_adj);
  754. if (err < 0)
  755. return err;
  756. err = read_utmi_param(pdev, "nvidia,xcvr-lsfslew",
  757. &config->xcvr_lsfslew);
  758. if (err < 0)
  759. return err;
  760. err = read_utmi_param(pdev, "nvidia,xcvr-lsrslew",
  761. &config->xcvr_lsrslew);
  762. if (err < 0)
  763. return err;
  764. if (tegra_phy->soc_config->requires_extra_tuning_parameters) {
  765. err = read_utmi_param(pdev, "nvidia,xcvr-hsslew",
  766. &config->xcvr_hsslew);
  767. if (err < 0)
  768. return err;
  769. err = read_utmi_param(pdev, "nvidia,hssquelch-level",
  770. &config->hssquelch_level);
  771. if (err < 0)
  772. return err;
  773. err = read_utmi_param(pdev, "nvidia,hsdiscon-level",
  774. &config->hsdiscon_level);
  775. if (err < 0)
  776. return err;
  777. }
  778. config->xcvr_setup_use_fuses = of_property_read_bool(
  779. pdev->dev.of_node, "nvidia,xcvr-setup-use-fuses");
  780. if (!config->xcvr_setup_use_fuses) {
  781. err = read_utmi_param(pdev, "nvidia,xcvr-setup",
  782. &config->xcvr_setup);
  783. if (err < 0)
  784. return err;
  785. }
  786. return 0;
  787. }
  788. static const struct tegra_phy_soc_config tegra20_soc_config = {
  789. .utmi_pll_config_in_car_module = false,
  790. .has_hostpc = false,
  791. .requires_usbmode_setup = false,
  792. .requires_extra_tuning_parameters = false,
  793. };
  794. static const struct tegra_phy_soc_config tegra30_soc_config = {
  795. .utmi_pll_config_in_car_module = true,
  796. .has_hostpc = true,
  797. .requires_usbmode_setup = true,
  798. .requires_extra_tuning_parameters = true,
  799. };
  800. static struct of_device_id tegra_usb_phy_id_table[] = {
  801. { .compatible = "nvidia,tegra30-usb-phy", .data = &tegra30_soc_config },
  802. { .compatible = "nvidia,tegra20-usb-phy", .data = &tegra20_soc_config },
  803. { },
  804. };
  805. MODULE_DEVICE_TABLE(of, tegra_usb_phy_id_table);
  806. static int tegra_usb_phy_probe(struct platform_device *pdev)
  807. {
  808. const struct of_device_id *match;
  809. struct resource *res;
  810. struct tegra_usb_phy *tegra_phy = NULL;
  811. struct device_node *np = pdev->dev.of_node;
  812. enum usb_phy_interface phy_type;
  813. int err;
  814. tegra_phy = devm_kzalloc(&pdev->dev, sizeof(*tegra_phy), GFP_KERNEL);
  815. if (!tegra_phy) {
  816. dev_err(&pdev->dev, "unable to allocate memory for USB2 PHY\n");
  817. return -ENOMEM;
  818. }
  819. match = of_match_device(tegra_usb_phy_id_table, &pdev->dev);
  820. if (!match) {
  821. dev_err(&pdev->dev, "Error: No device match found\n");
  822. return -ENODEV;
  823. }
  824. tegra_phy->soc_config = match->data;
  825. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  826. if (!res) {
  827. dev_err(&pdev->dev, "Failed to get I/O memory\n");
  828. return -ENXIO;
  829. }
  830. tegra_phy->regs = devm_ioremap(&pdev->dev, res->start,
  831. resource_size(res));
  832. if (!tegra_phy->regs) {
  833. dev_err(&pdev->dev, "Failed to remap I/O memory\n");
  834. return -ENOMEM;
  835. }
  836. tegra_phy->is_legacy_phy =
  837. of_property_read_bool(np, "nvidia,has-legacy-mode");
  838. phy_type = of_usb_get_phy_mode(np);
  839. switch (phy_type) {
  840. case USBPHY_INTERFACE_MODE_UTMI:
  841. err = utmi_phy_probe(tegra_phy, pdev);
  842. if (err < 0)
  843. return err;
  844. break;
  845. case USBPHY_INTERFACE_MODE_ULPI:
  846. tegra_phy->is_ulpi_phy = true;
  847. tegra_phy->reset_gpio =
  848. of_get_named_gpio(np, "nvidia,phy-reset-gpio", 0);
  849. if (!gpio_is_valid(tegra_phy->reset_gpio)) {
  850. dev_err(&pdev->dev, "invalid gpio: %d\n",
  851. tegra_phy->reset_gpio);
  852. return tegra_phy->reset_gpio;
  853. }
  854. tegra_phy->config = NULL;
  855. break;
  856. default:
  857. dev_err(&pdev->dev, "phy_type is invalid or unsupported\n");
  858. return -EINVAL;
  859. }
  860. if (of_find_property(np, "dr_mode", NULL))
  861. tegra_phy->mode = of_usb_get_dr_mode(np);
  862. else
  863. tegra_phy->mode = USB_DR_MODE_HOST;
  864. if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) {
  865. dev_err(&pdev->dev, "dr_mode is invalid\n");
  866. return -EINVAL;
  867. }
  868. /* On some boards, the VBUS regulator doesn't need to be controlled */
  869. if (of_find_property(np, "vbus-supply", NULL)) {
  870. tegra_phy->vbus = devm_regulator_get(&pdev->dev, "vbus");
  871. if (IS_ERR(tegra_phy->vbus))
  872. return PTR_ERR(tegra_phy->vbus);
  873. } else {
  874. dev_notice(&pdev->dev, "no vbus regulator");
  875. tegra_phy->vbus = ERR_PTR(-ENODEV);
  876. }
  877. tegra_phy->u_phy.dev = &pdev->dev;
  878. err = tegra_usb_phy_init(tegra_phy);
  879. if (err < 0)
  880. return err;
  881. tegra_phy->u_phy.shutdown = tegra_usb_phy_close;
  882. tegra_phy->u_phy.set_suspend = tegra_usb_phy_suspend;
  883. platform_set_drvdata(pdev, tegra_phy);
  884. err = usb_add_phy_dev(&tegra_phy->u_phy);
  885. if (err < 0) {
  886. tegra_usb_phy_close(&tegra_phy->u_phy);
  887. return err;
  888. }
  889. return 0;
  890. }
  891. static int tegra_usb_phy_remove(struct platform_device *pdev)
  892. {
  893. struct tegra_usb_phy *tegra_phy = platform_get_drvdata(pdev);
  894. usb_remove_phy(&tegra_phy->u_phy);
  895. return 0;
  896. }
  897. static struct platform_driver tegra_usb_phy_driver = {
  898. .probe = tegra_usb_phy_probe,
  899. .remove = tegra_usb_phy_remove,
  900. .driver = {
  901. .name = "tegra-phy",
  902. .owner = THIS_MODULE,
  903. .of_match_table = of_match_ptr(tegra_usb_phy_id_table),
  904. },
  905. };
  906. module_platform_driver(tegra_usb_phy_driver);
  907. MODULE_DESCRIPTION("Tegra USB PHY driver");
  908. MODULE_LICENSE("GPL v2");