xusb-tegra124.c 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753
  1. /*
  2. * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. */
  13. #include <linux/delay.h>
  14. #include <linux/io.h>
  15. #include <linux/mailbox_client.h>
  16. #include <linux/module.h>
  17. #include <linux/of.h>
  18. #include <linux/phy/phy.h>
  19. #include <linux/platform_device.h>
  20. #include <linux/regulator/consumer.h>
  21. #include <linux/reset.h>
  22. #include <linux/slab.h>
  23. #include <soc/tegra/fuse.h>
  24. #include "xusb.h"
  25. #define FUSE_SKU_CALIB_HS_CURR_LEVEL_PADX_SHIFT(x) ((x) ? 15 : 0)
  26. #define FUSE_SKU_CALIB_HS_CURR_LEVEL_PAD_MASK 0x3f
  27. #define FUSE_SKU_CALIB_HS_IREF_CAP_SHIFT 13
  28. #define FUSE_SKU_CALIB_HS_IREF_CAP_MASK 0x3
  29. #define FUSE_SKU_CALIB_HS_SQUELCH_LEVEL_SHIFT 11
  30. #define FUSE_SKU_CALIB_HS_SQUELCH_LEVEL_MASK 0x3
  31. #define FUSE_SKU_CALIB_HS_TERM_RANGE_ADJ_SHIFT 7
  32. #define FUSE_SKU_CALIB_HS_TERM_RANGE_ADJ_MASK 0xf
  33. #define XUSB_PADCTL_USB2_PORT_CAP 0x008
  34. #define XUSB_PADCTL_USB2_PORT_CAP_PORTX_CAP_SHIFT(x) ((x) * 4)
  35. #define XUSB_PADCTL_USB2_PORT_CAP_PORT_CAP_MASK 0x3
  36. #define XUSB_PADCTL_USB2_PORT_CAP_DISABLED 0x0
  37. #define XUSB_PADCTL_USB2_PORT_CAP_HOST 0x1
  38. #define XUSB_PADCTL_USB2_PORT_CAP_DEVICE 0x2
  39. #define XUSB_PADCTL_USB2_PORT_CAP_OTG 0x3
  40. #define XUSB_PADCTL_SS_PORT_MAP 0x014
  41. #define XUSB_PADCTL_SS_PORT_MAP_PORTX_INTERNAL(x) (1 << (((x) * 4) + 3))
  42. #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_SHIFT(x) ((x) * 4)
  43. #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(x) (0x7 << ((x) * 4))
  44. #define XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(x, v) (((v) & 0x7) << ((x) * 4))
  45. #define XUSB_PADCTL_SS_PORT_MAP_PORT_MAP_MASK 0x7
  46. #define XUSB_PADCTL_ELPG_PROGRAM 0x01c
  47. #define XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_VCORE_DOWN (1 << 26)
  48. #define XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN_EARLY (1 << 25)
  49. #define XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN (1 << 24)
  50. #define XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_VCORE_DOWN(x) (1 << (18 + (x) * 4))
  51. #define XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN_EARLY(x) \
  52. (1 << (17 + (x) * 4))
  53. #define XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN(x) (1 << (16 + (x) * 4))
  54. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL1 0x040
  55. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL1_PLL0_LOCKDET (1 << 19)
  56. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL1_REFCLK_SEL_MASK (0xf << 12)
  57. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL1_PLL_RST (1 << 1)
  58. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL2 0x044
  59. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL2_REFCLKBUF_EN (1 << 6)
  60. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL2_TXCLKREF_EN (1 << 5)
  61. #define XUSB_PADCTL_IOPHY_PLL_P0_CTL2_TXCLKREF_SEL (1 << 4)
  62. #define XUSB_PADCTL_IOPHY_USB3_PADX_CTL2(x) (0x058 + (x) * 4)
  63. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_SHIFT 24
  64. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_MASK 0xff
  65. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_VAL 0x24
  66. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_SHIFT 16
  67. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_MASK 0x3f
  68. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_SHIFT 8
  69. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_MASK 0x3f
  70. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_SHIFT 8
  71. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_MASK 0xffff
  72. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_VAL 0xf070
  73. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_SHIFT 4
  74. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_MASK 0xf
  75. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_VAL 0xf
  76. #define XUSB_PADCTL_IOPHY_USB3_PADX_CTL4(x) (0x068 + (x) * 4)
  77. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_SHIFT 24
  78. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_MASK 0x1f
  79. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_SHIFT 16
  80. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_MASK 0x7f
  81. #define XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_VAL 0x002008ee
  82. #define XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL2(x) ((x) < 2 ? 0x078 + (x) * 4 : \
  83. 0x0f8 + (x) * 4)
  84. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_SHIFT 28
  85. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_MASK 0x3
  86. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_VAL 0x1
  87. #define XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL5(x) ((x) < 2 ? 0x090 + (x) * 4 : \
  88. 0x11c + (x) * 4)
  89. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL5_RX_QEYE_EN (1 << 8)
  90. #define XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL6(x) ((x) < 2 ? 0x098 + (x) * 4 : \
  91. 0x128 + (x) * 4)
  92. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SHIFT 24
  93. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_G_Z_MASK 0x3f
  94. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_TAP_MASK 0x1f
  95. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_AMP_MASK 0x7f
  96. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT 16
  97. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_MASK 0xff
  98. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_G_Z 0x21
  99. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_TAP 0x32
  100. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_AMP 0x33
  101. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_CTLE_Z 0x48
  102. #define XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_LATCH_G_Z 0xa1
  103. #define XUSB_PADCTL_USB2_OTG_PADX_CTL0(x) (0x0a0 + (x) * 4)
  104. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_PD_ZI (1 << 21)
  105. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_PD2 (1 << 20)
  106. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_PD (1 << 19)
  107. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_SHIFT 14
  108. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_MASK 0x3
  109. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_VAL(x) ((x) ? 0x0 : 0x3)
  110. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_SHIFT 6
  111. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_MASK 0x3f
  112. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_VAL 0x0e
  113. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_CURR_LEVEL_SHIFT 0
  114. #define XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_CURR_LEVEL_MASK 0x3f
  115. #define XUSB_PADCTL_USB2_OTG_PADX_CTL1(x) (0x0ac + (x) * 4)
  116. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_HS_IREF_CAP_SHIFT 9
  117. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_HS_IREF_CAP_MASK 0x3
  118. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_TERM_RANGE_ADJ_SHIFT 3
  119. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_TERM_RANGE_ADJ_MASK 0x7
  120. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_PD_DR (1 << 2)
  121. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_PD_DISC_FORCE_POWERUP (1 << 1)
  122. #define XUSB_PADCTL_USB2_OTG_PAD_CTL1_PD_CHRP_FORCE_POWERUP (1 << 0)
  123. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0 0x0b8
  124. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0_PD (1 << 12)
  125. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_SHIFT 2
  126. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_MASK 0x7
  127. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_VAL 0x5
  128. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_SHIFT 0
  129. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_MASK 0x3
  130. #define XUSB_PADCTL_HSIC_PADX_CTL0(x) (0x0c0 + (x) * 4)
  131. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWN_SHIFT 12
  132. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWN_MASK 0x7
  133. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWP_SHIFT 8
  134. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWP_MASK 0x7
  135. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEN_SHIFT 4
  136. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEN_MASK 0x7
  137. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEP_SHIFT 0
  138. #define XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEP_MASK 0x7
  139. #define XUSB_PADCTL_HSIC_PADX_CTL1(x) (0x0c8 + (x) * 4)
  140. #define XUSB_PADCTL_HSIC_PAD_CTL1_RPU_STROBE (1 << 10)
  141. #define XUSB_PADCTL_HSIC_PAD_CTL1_RPU_DATA (1 << 9)
  142. #define XUSB_PADCTL_HSIC_PAD_CTL1_RPD_STROBE (1 << 8)
  143. #define XUSB_PADCTL_HSIC_PAD_CTL1_RPD_DATA (1 << 7)
  144. #define XUSB_PADCTL_HSIC_PAD_CTL1_PD_ZI (1 << 5)
  145. #define XUSB_PADCTL_HSIC_PAD_CTL1_PD_RX (1 << 4)
  146. #define XUSB_PADCTL_HSIC_PAD_CTL1_PD_TRX (1 << 3)
  147. #define XUSB_PADCTL_HSIC_PAD_CTL1_PD_TX (1 << 2)
  148. #define XUSB_PADCTL_HSIC_PAD_CTL1_AUTO_TERM_EN (1 << 0)
  149. #define XUSB_PADCTL_HSIC_PADX_CTL2(x) (0x0d0 + (x) * 4)
  150. #define XUSB_PADCTL_HSIC_PAD_CTL2_RX_STROBE_TRIM_SHIFT 4
  151. #define XUSB_PADCTL_HSIC_PAD_CTL2_RX_STROBE_TRIM_MASK 0x7
  152. #define XUSB_PADCTL_HSIC_PAD_CTL2_RX_DATA_TRIM_SHIFT 0
  153. #define XUSB_PADCTL_HSIC_PAD_CTL2_RX_DATA_TRIM_MASK 0x7
  154. #define XUSB_PADCTL_HSIC_STRB_TRIM_CONTROL 0x0e0
  155. #define XUSB_PADCTL_HSIC_STRB_TRIM_CONTROL_STRB_TRIM_MASK 0x1f
  156. #define XUSB_PADCTL_USB3_PAD_MUX 0x134
  157. #define XUSB_PADCTL_USB3_PAD_MUX_PCIE_IDDQ_DISABLE(x) (1 << (1 + (x)))
  158. #define XUSB_PADCTL_USB3_PAD_MUX_SATA_IDDQ_DISABLE(x) (1 << (6 + (x)))
  159. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1 0x138
  160. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL1_LOCKDET (1 << 27)
  161. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL1_MODE (1 << 24)
  162. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL0_REFCLK_NDIV_SHIFT 20
  163. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL0_REFCLK_NDIV_MASK 0x3
  164. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_PWR_OVRD (1 << 3)
  165. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_RST (1 << 1)
  166. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_IDDQ (1 << 0)
  167. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2 0x13c
  168. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL1_CP_CNTL_SHIFT 20
  169. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL1_CP_CNTL_MASK 0xf
  170. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL0_CP_CNTL_SHIFT 16
  171. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL0_CP_CNTL_MASK 0xf
  172. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_TCLKOUT_EN (1 << 12)
  173. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_TXCLKREF_SEL (1 << 4)
  174. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_XDIGCLK_SEL_SHIFT 0
  175. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL2_XDIGCLK_SEL_MASK 0x7
  176. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL3 0x140
  177. #define XUSB_PADCTL_IOPHY_PLL_S0_CTL3_RCAL_BYPASS (1 << 7)
  178. #define XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1 0x148
  179. #define XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1_IDDQ_OVRD (1 << 1)
  180. #define XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1_IDDQ (1 << 0)
  181. #define XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL2 0x14c
  182. #define XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL5 0x158
  183. #define XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL6 0x15c
  184. struct tegra124_xusb_fuse_calibration {
  185. u32 hs_curr_level[3];
  186. u32 hs_iref_cap;
  187. u32 hs_term_range_adj;
  188. u32 hs_squelch_level;
  189. };
  190. struct tegra124_xusb_padctl {
  191. struct tegra_xusb_padctl base;
  192. struct tegra124_xusb_fuse_calibration fuse;
  193. };
  194. static inline struct tegra124_xusb_padctl *
  195. to_tegra124_xusb_padctl(struct tegra_xusb_padctl *padctl)
  196. {
  197. return container_of(padctl, struct tegra124_xusb_padctl, base);
  198. }
  199. static int tegra124_xusb_padctl_enable(struct tegra_xusb_padctl *padctl)
  200. {
  201. u32 value;
  202. mutex_lock(&padctl->lock);
  203. if (padctl->enable++ > 0)
  204. goto out;
  205. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  206. value &= ~XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN;
  207. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  208. usleep_range(100, 200);
  209. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  210. value &= ~XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN_EARLY;
  211. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  212. usleep_range(100, 200);
  213. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  214. value &= ~XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_VCORE_DOWN;
  215. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  216. out:
  217. mutex_unlock(&padctl->lock);
  218. return 0;
  219. }
  220. static int tegra124_xusb_padctl_disable(struct tegra_xusb_padctl *padctl)
  221. {
  222. u32 value;
  223. mutex_lock(&padctl->lock);
  224. if (WARN_ON(padctl->enable == 0))
  225. goto out;
  226. if (--padctl->enable > 0)
  227. goto out;
  228. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  229. value |= XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_VCORE_DOWN;
  230. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  231. usleep_range(100, 200);
  232. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  233. value |= XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN_EARLY;
  234. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  235. usleep_range(100, 200);
  236. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  237. value |= XUSB_PADCTL_ELPG_PROGRAM_AUX_MUX_LP0_CLAMP_EN;
  238. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  239. out:
  240. mutex_unlock(&padctl->lock);
  241. return 0;
  242. }
  243. static int tegra124_usb3_save_context(struct tegra_xusb_padctl *padctl,
  244. unsigned int index)
  245. {
  246. struct tegra_xusb_usb3_port *port;
  247. struct tegra_xusb_lane *lane;
  248. u32 value, offset;
  249. port = tegra_xusb_find_usb3_port(padctl, index);
  250. if (!port)
  251. return -ENODEV;
  252. port->context_saved = true;
  253. lane = port->base.lane;
  254. if (lane->pad == padctl->pcie)
  255. offset = XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL6(lane->index);
  256. else
  257. offset = XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL6;
  258. value = padctl_readl(padctl, offset);
  259. value &= ~(XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_MASK <<
  260. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT);
  261. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_TAP <<
  262. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT;
  263. padctl_writel(padctl, value, offset);
  264. value = padctl_readl(padctl, offset) >>
  265. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SHIFT;
  266. port->tap1 = value & XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_TAP_MASK;
  267. value = padctl_readl(padctl, offset);
  268. value &= ~(XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_MASK <<
  269. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT);
  270. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_AMP <<
  271. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT;
  272. padctl_writel(padctl, value, offset);
  273. value = padctl_readl(padctl, offset) >>
  274. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SHIFT;
  275. port->amp = value & XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_AMP_MASK;
  276. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_USB3_PADX_CTL4(index));
  277. value &= ~((XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_MASK <<
  278. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_SHIFT) |
  279. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_MASK <<
  280. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_SHIFT));
  281. value |= (port->tap1 <<
  282. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_SHIFT) |
  283. (port->amp <<
  284. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_SHIFT);
  285. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_USB3_PADX_CTL4(index));
  286. value = padctl_readl(padctl, offset);
  287. value &= ~(XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_MASK <<
  288. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT);
  289. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_LATCH_G_Z <<
  290. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT;
  291. padctl_writel(padctl, value, offset);
  292. value = padctl_readl(padctl, offset);
  293. value &= ~(XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_MASK <<
  294. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT);
  295. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_G_Z <<
  296. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT;
  297. padctl_writel(padctl, value, offset);
  298. value = padctl_readl(padctl, offset) >>
  299. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SHIFT;
  300. port->ctle_g = value &
  301. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_G_Z_MASK;
  302. value = padctl_readl(padctl, offset);
  303. value &= ~(XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_MASK <<
  304. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT);
  305. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_CTLE_Z <<
  306. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SEL_SHIFT;
  307. padctl_writel(padctl, value, offset);
  308. value = padctl_readl(padctl, offset) >>
  309. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_SHIFT;
  310. port->ctle_z = value &
  311. XUSB_PADCTL_IOPHY_MISC_PAD_CTL6_MISC_OUT_G_Z_MASK;
  312. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_USB3_PADX_CTL2(index));
  313. value &= ~((XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_MASK <<
  314. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_SHIFT) |
  315. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_MASK <<
  316. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_SHIFT));
  317. value |= (port->ctle_g <<
  318. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_SHIFT) |
  319. (port->ctle_z <<
  320. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_SHIFT);
  321. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_USB3_PADX_CTL2(index));
  322. return 0;
  323. }
  324. static int tegra124_hsic_set_idle(struct tegra_xusb_padctl *padctl,
  325. unsigned int index, bool idle)
  326. {
  327. u32 value;
  328. value = padctl_readl(padctl, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  329. if (idle)
  330. value |= XUSB_PADCTL_HSIC_PAD_CTL1_RPD_DATA |
  331. XUSB_PADCTL_HSIC_PAD_CTL1_RPU_STROBE;
  332. else
  333. value &= ~(XUSB_PADCTL_HSIC_PAD_CTL1_RPD_DATA |
  334. XUSB_PADCTL_HSIC_PAD_CTL1_RPU_STROBE);
  335. padctl_writel(padctl, value, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  336. return 0;
  337. }
  338. #define TEGRA124_LANE(_name, _offset, _shift, _mask, _type) \
  339. { \
  340. .name = _name, \
  341. .offset = _offset, \
  342. .shift = _shift, \
  343. .mask = _mask, \
  344. .num_funcs = ARRAY_SIZE(tegra124_##_type##_functions), \
  345. .funcs = tegra124_##_type##_functions, \
  346. }
  347. static const char * const tegra124_usb2_functions[] = {
  348. "snps",
  349. "xusb",
  350. "uart",
  351. };
  352. static const struct tegra_xusb_lane_soc tegra124_usb2_lanes[] = {
  353. TEGRA124_LANE("usb2-0", 0x004, 0, 0x3, usb2),
  354. TEGRA124_LANE("usb2-1", 0x004, 2, 0x3, usb2),
  355. TEGRA124_LANE("usb2-2", 0x004, 4, 0x3, usb2),
  356. };
  357. static struct tegra_xusb_lane *
  358. tegra124_usb2_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  359. unsigned int index)
  360. {
  361. struct tegra_xusb_usb2_lane *usb2;
  362. int err;
  363. usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
  364. if (!usb2)
  365. return ERR_PTR(-ENOMEM);
  366. INIT_LIST_HEAD(&usb2->base.list);
  367. usb2->base.soc = &pad->soc->lanes[index];
  368. usb2->base.index = index;
  369. usb2->base.pad = pad;
  370. usb2->base.np = np;
  371. err = tegra_xusb_lane_parse_dt(&usb2->base, np);
  372. if (err < 0) {
  373. kfree(usb2);
  374. return ERR_PTR(err);
  375. }
  376. return &usb2->base;
  377. }
  378. static void tegra124_usb2_lane_remove(struct tegra_xusb_lane *lane)
  379. {
  380. struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
  381. kfree(usb2);
  382. }
  383. static const struct tegra_xusb_lane_ops tegra124_usb2_lane_ops = {
  384. .probe = tegra124_usb2_lane_probe,
  385. .remove = tegra124_usb2_lane_remove,
  386. };
  387. static int tegra124_usb2_phy_init(struct phy *phy)
  388. {
  389. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  390. return tegra124_xusb_padctl_enable(lane->pad->padctl);
  391. }
  392. static int tegra124_usb2_phy_exit(struct phy *phy)
  393. {
  394. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  395. return tegra124_xusb_padctl_disable(lane->pad->padctl);
  396. }
  397. static int tegra124_usb2_phy_power_on(struct phy *phy)
  398. {
  399. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  400. struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
  401. struct tegra_xusb_usb2_pad *pad = to_usb2_pad(lane->pad);
  402. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  403. struct tegra124_xusb_padctl *priv;
  404. struct tegra_xusb_usb2_port *port;
  405. unsigned int index = lane->index;
  406. u32 value;
  407. int err;
  408. port = tegra_xusb_find_usb2_port(padctl, index);
  409. if (!port) {
  410. dev_err(&phy->dev, "no port found for USB2 lane %u\n", index);
  411. return -ENODEV;
  412. }
  413. priv = to_tegra124_xusb_padctl(padctl);
  414. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  415. value &= ~((XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_MASK <<
  416. XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_SHIFT) |
  417. (XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_MASK <<
  418. XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_SHIFT));
  419. value |= (priv->fuse.hs_squelch_level <<
  420. XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_SQUELCH_LEVEL_SHIFT) |
  421. (XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_VAL <<
  422. XUSB_PADCTL_USB2_BIAS_PAD_CTL0_HS_DISCON_LEVEL_SHIFT);
  423. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  424. value = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP);
  425. value &= ~(XUSB_PADCTL_USB2_PORT_CAP_PORT_CAP_MASK <<
  426. XUSB_PADCTL_USB2_PORT_CAP_PORTX_CAP_SHIFT(index));
  427. value |= XUSB_PADCTL_USB2_PORT_CAP_HOST <<
  428. XUSB_PADCTL_USB2_PORT_CAP_PORTX_CAP_SHIFT(index);
  429. padctl_writel(padctl, value, XUSB_PADCTL_USB2_PORT_CAP);
  430. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  431. value &= ~((XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_CURR_LEVEL_MASK <<
  432. XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_CURR_LEVEL_SHIFT) |
  433. (XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_MASK <<
  434. XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_SHIFT) |
  435. (XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_MASK <<
  436. XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_SHIFT) |
  437. XUSB_PADCTL_USB2_OTG_PAD_CTL0_PD |
  438. XUSB_PADCTL_USB2_OTG_PAD_CTL0_PD2 |
  439. XUSB_PADCTL_USB2_OTG_PAD_CTL0_PD_ZI);
  440. value |= (priv->fuse.hs_curr_level[index] +
  441. usb2->hs_curr_level_offset) <<
  442. XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_CURR_LEVEL_SHIFT;
  443. value |= XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_VAL <<
  444. XUSB_PADCTL_USB2_OTG_PAD_CTL0_HS_SLEW_SHIFT;
  445. value |= XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_VAL(index) <<
  446. XUSB_PADCTL_USB2_OTG_PAD_CTL0_LS_RSLEW_SHIFT;
  447. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  448. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  449. value &= ~((XUSB_PADCTL_USB2_OTG_PAD_CTL1_TERM_RANGE_ADJ_MASK <<
  450. XUSB_PADCTL_USB2_OTG_PAD_CTL1_TERM_RANGE_ADJ_SHIFT) |
  451. (XUSB_PADCTL_USB2_OTG_PAD_CTL1_HS_IREF_CAP_MASK <<
  452. XUSB_PADCTL_USB2_OTG_PAD_CTL1_HS_IREF_CAP_SHIFT) |
  453. XUSB_PADCTL_USB2_OTG_PAD_CTL1_PD_DR |
  454. XUSB_PADCTL_USB2_OTG_PAD_CTL1_PD_CHRP_FORCE_POWERUP |
  455. XUSB_PADCTL_USB2_OTG_PAD_CTL1_PD_DISC_FORCE_POWERUP);
  456. value |= (priv->fuse.hs_term_range_adj <<
  457. XUSB_PADCTL_USB2_OTG_PAD_CTL1_TERM_RANGE_ADJ_SHIFT) |
  458. (priv->fuse.hs_iref_cap <<
  459. XUSB_PADCTL_USB2_OTG_PAD_CTL1_HS_IREF_CAP_SHIFT);
  460. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  461. err = regulator_enable(port->supply);
  462. if (err)
  463. return err;
  464. mutex_lock(&pad->lock);
  465. if (pad->enable++ > 0)
  466. goto out;
  467. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  468. value &= ~XUSB_PADCTL_USB2_BIAS_PAD_CTL0_PD;
  469. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  470. out:
  471. mutex_unlock(&pad->lock);
  472. return 0;
  473. }
  474. static int tegra124_usb2_phy_power_off(struct phy *phy)
  475. {
  476. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  477. struct tegra_xusb_usb2_pad *pad = to_usb2_pad(lane->pad);
  478. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  479. struct tegra_xusb_usb2_port *port;
  480. u32 value;
  481. port = tegra_xusb_find_usb2_port(padctl, lane->index);
  482. if (!port) {
  483. dev_err(&phy->dev, "no port found for USB2 lane %u\n",
  484. lane->index);
  485. return -ENODEV;
  486. }
  487. mutex_lock(&pad->lock);
  488. if (WARN_ON(pad->enable == 0))
  489. goto out;
  490. if (--pad->enable > 0)
  491. goto out;
  492. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  493. value |= XUSB_PADCTL_USB2_BIAS_PAD_CTL0_PD;
  494. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  495. out:
  496. regulator_disable(port->supply);
  497. mutex_unlock(&pad->lock);
  498. return 0;
  499. }
  500. static const struct phy_ops tegra124_usb2_phy_ops = {
  501. .init = tegra124_usb2_phy_init,
  502. .exit = tegra124_usb2_phy_exit,
  503. .power_on = tegra124_usb2_phy_power_on,
  504. .power_off = tegra124_usb2_phy_power_off,
  505. .owner = THIS_MODULE,
  506. };
  507. static struct tegra_xusb_pad *
  508. tegra124_usb2_pad_probe(struct tegra_xusb_padctl *padctl,
  509. const struct tegra_xusb_pad_soc *soc,
  510. struct device_node *np)
  511. {
  512. struct tegra_xusb_usb2_pad *usb2;
  513. struct tegra_xusb_pad *pad;
  514. int err;
  515. usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
  516. if (!usb2)
  517. return ERR_PTR(-ENOMEM);
  518. mutex_init(&usb2->lock);
  519. pad = &usb2->base;
  520. pad->ops = &tegra124_usb2_lane_ops;
  521. pad->soc = soc;
  522. err = tegra_xusb_pad_init(pad, padctl, np);
  523. if (err < 0) {
  524. kfree(usb2);
  525. goto out;
  526. }
  527. err = tegra_xusb_pad_register(pad, &tegra124_usb2_phy_ops);
  528. if (err < 0)
  529. goto unregister;
  530. dev_set_drvdata(&pad->dev, pad);
  531. return pad;
  532. unregister:
  533. device_unregister(&pad->dev);
  534. out:
  535. return ERR_PTR(err);
  536. }
  537. static void tegra124_usb2_pad_remove(struct tegra_xusb_pad *pad)
  538. {
  539. struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
  540. kfree(usb2);
  541. }
  542. static const struct tegra_xusb_pad_ops tegra124_usb2_ops = {
  543. .probe = tegra124_usb2_pad_probe,
  544. .remove = tegra124_usb2_pad_remove,
  545. };
  546. static const struct tegra_xusb_pad_soc tegra124_usb2_pad = {
  547. .name = "usb2",
  548. .num_lanes = ARRAY_SIZE(tegra124_usb2_lanes),
  549. .lanes = tegra124_usb2_lanes,
  550. .ops = &tegra124_usb2_ops,
  551. };
  552. static const char * const tegra124_ulpi_functions[] = {
  553. "snps",
  554. "xusb",
  555. };
  556. static const struct tegra_xusb_lane_soc tegra124_ulpi_lanes[] = {
  557. TEGRA124_LANE("ulpi-0", 0x004, 12, 0x1, ulpi),
  558. };
  559. static struct tegra_xusb_lane *
  560. tegra124_ulpi_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  561. unsigned int index)
  562. {
  563. struct tegra_xusb_ulpi_lane *ulpi;
  564. int err;
  565. ulpi = kzalloc(sizeof(*ulpi), GFP_KERNEL);
  566. if (!ulpi)
  567. return ERR_PTR(-ENOMEM);
  568. INIT_LIST_HEAD(&ulpi->base.list);
  569. ulpi->base.soc = &pad->soc->lanes[index];
  570. ulpi->base.index = index;
  571. ulpi->base.pad = pad;
  572. ulpi->base.np = np;
  573. err = tegra_xusb_lane_parse_dt(&ulpi->base, np);
  574. if (err < 0) {
  575. kfree(ulpi);
  576. return ERR_PTR(err);
  577. }
  578. return &ulpi->base;
  579. }
  580. static void tegra124_ulpi_lane_remove(struct tegra_xusb_lane *lane)
  581. {
  582. struct tegra_xusb_ulpi_lane *ulpi = to_ulpi_lane(lane);
  583. kfree(ulpi);
  584. }
  585. static const struct tegra_xusb_lane_ops tegra124_ulpi_lane_ops = {
  586. .probe = tegra124_ulpi_lane_probe,
  587. .remove = tegra124_ulpi_lane_remove,
  588. };
  589. static int tegra124_ulpi_phy_init(struct phy *phy)
  590. {
  591. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  592. return tegra124_xusb_padctl_enable(lane->pad->padctl);
  593. }
  594. static int tegra124_ulpi_phy_exit(struct phy *phy)
  595. {
  596. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  597. return tegra124_xusb_padctl_disable(lane->pad->padctl);
  598. }
  599. static int tegra124_ulpi_phy_power_on(struct phy *phy)
  600. {
  601. return 0;
  602. }
  603. static int tegra124_ulpi_phy_power_off(struct phy *phy)
  604. {
  605. return 0;
  606. }
  607. static const struct phy_ops tegra124_ulpi_phy_ops = {
  608. .init = tegra124_ulpi_phy_init,
  609. .exit = tegra124_ulpi_phy_exit,
  610. .power_on = tegra124_ulpi_phy_power_on,
  611. .power_off = tegra124_ulpi_phy_power_off,
  612. .owner = THIS_MODULE,
  613. };
  614. static struct tegra_xusb_pad *
  615. tegra124_ulpi_pad_probe(struct tegra_xusb_padctl *padctl,
  616. const struct tegra_xusb_pad_soc *soc,
  617. struct device_node *np)
  618. {
  619. struct tegra_xusb_ulpi_pad *ulpi;
  620. struct tegra_xusb_pad *pad;
  621. int err;
  622. ulpi = kzalloc(sizeof(*ulpi), GFP_KERNEL);
  623. if (!ulpi)
  624. return ERR_PTR(-ENOMEM);
  625. pad = &ulpi->base;
  626. pad->ops = &tegra124_ulpi_lane_ops;
  627. pad->soc = soc;
  628. err = tegra_xusb_pad_init(pad, padctl, np);
  629. if (err < 0) {
  630. kfree(ulpi);
  631. goto out;
  632. }
  633. err = tegra_xusb_pad_register(pad, &tegra124_ulpi_phy_ops);
  634. if (err < 0)
  635. goto unregister;
  636. dev_set_drvdata(&pad->dev, pad);
  637. return pad;
  638. unregister:
  639. device_unregister(&pad->dev);
  640. out:
  641. return ERR_PTR(err);
  642. }
  643. static void tegra124_ulpi_pad_remove(struct tegra_xusb_pad *pad)
  644. {
  645. struct tegra_xusb_ulpi_pad *ulpi = to_ulpi_pad(pad);
  646. kfree(ulpi);
  647. }
  648. static const struct tegra_xusb_pad_ops tegra124_ulpi_ops = {
  649. .probe = tegra124_ulpi_pad_probe,
  650. .remove = tegra124_ulpi_pad_remove,
  651. };
  652. static const struct tegra_xusb_pad_soc tegra124_ulpi_pad = {
  653. .name = "ulpi",
  654. .num_lanes = ARRAY_SIZE(tegra124_ulpi_lanes),
  655. .lanes = tegra124_ulpi_lanes,
  656. .ops = &tegra124_ulpi_ops,
  657. };
  658. static const char * const tegra124_hsic_functions[] = {
  659. "snps",
  660. "xusb",
  661. };
  662. static const struct tegra_xusb_lane_soc tegra124_hsic_lanes[] = {
  663. TEGRA124_LANE("hsic-0", 0x004, 14, 0x1, hsic),
  664. TEGRA124_LANE("hsic-1", 0x004, 15, 0x1, hsic),
  665. };
  666. static struct tegra_xusb_lane *
  667. tegra124_hsic_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  668. unsigned int index)
  669. {
  670. struct tegra_xusb_hsic_lane *hsic;
  671. int err;
  672. hsic = kzalloc(sizeof(*hsic), GFP_KERNEL);
  673. if (!hsic)
  674. return ERR_PTR(-ENOMEM);
  675. INIT_LIST_HEAD(&hsic->base.list);
  676. hsic->base.soc = &pad->soc->lanes[index];
  677. hsic->base.index = index;
  678. hsic->base.pad = pad;
  679. hsic->base.np = np;
  680. err = tegra_xusb_lane_parse_dt(&hsic->base, np);
  681. if (err < 0) {
  682. kfree(hsic);
  683. return ERR_PTR(err);
  684. }
  685. return &hsic->base;
  686. }
  687. static void tegra124_hsic_lane_remove(struct tegra_xusb_lane *lane)
  688. {
  689. struct tegra_xusb_hsic_lane *hsic = to_hsic_lane(lane);
  690. kfree(hsic);
  691. }
  692. static const struct tegra_xusb_lane_ops tegra124_hsic_lane_ops = {
  693. .probe = tegra124_hsic_lane_probe,
  694. .remove = tegra124_hsic_lane_remove,
  695. };
  696. static int tegra124_hsic_phy_init(struct phy *phy)
  697. {
  698. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  699. return tegra124_xusb_padctl_enable(lane->pad->padctl);
  700. }
  701. static int tegra124_hsic_phy_exit(struct phy *phy)
  702. {
  703. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  704. return tegra124_xusb_padctl_disable(lane->pad->padctl);
  705. }
  706. static int tegra124_hsic_phy_power_on(struct phy *phy)
  707. {
  708. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  709. struct tegra_xusb_hsic_lane *hsic = to_hsic_lane(lane);
  710. struct tegra_xusb_hsic_pad *pad = to_hsic_pad(lane->pad);
  711. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  712. unsigned int index = lane->index;
  713. u32 value;
  714. int err;
  715. err = regulator_enable(pad->supply);
  716. if (err)
  717. return err;
  718. padctl_writel(padctl, hsic->strobe_trim,
  719. XUSB_PADCTL_HSIC_STRB_TRIM_CONTROL);
  720. value = padctl_readl(padctl, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  721. if (hsic->auto_term)
  722. value |= XUSB_PADCTL_HSIC_PAD_CTL1_AUTO_TERM_EN;
  723. else
  724. value &= ~XUSB_PADCTL_HSIC_PAD_CTL1_AUTO_TERM_EN;
  725. padctl_writel(padctl, value, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  726. value = padctl_readl(padctl, XUSB_PADCTL_HSIC_PADX_CTL0(index));
  727. value &= ~((XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEN_MASK <<
  728. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEN_SHIFT) |
  729. (XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEP_MASK <<
  730. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEP_SHIFT) |
  731. (XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWN_MASK <<
  732. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWN_SHIFT) |
  733. (XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWP_MASK <<
  734. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWP_SHIFT));
  735. value |= (hsic->tx_rtune_n <<
  736. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEN_SHIFT) |
  737. (hsic->tx_rtune_p <<
  738. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RTUNEP_SHIFT) |
  739. (hsic->tx_rslew_n <<
  740. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWN_SHIFT) |
  741. (hsic->tx_rslew_p <<
  742. XUSB_PADCTL_HSIC_PAD_CTL0_TX_RSLEWP_SHIFT);
  743. padctl_writel(padctl, value, XUSB_PADCTL_HSIC_PADX_CTL0(index));
  744. value = padctl_readl(padctl, XUSB_PADCTL_HSIC_PADX_CTL2(index));
  745. value &= ~((XUSB_PADCTL_HSIC_PAD_CTL2_RX_STROBE_TRIM_MASK <<
  746. XUSB_PADCTL_HSIC_PAD_CTL2_RX_STROBE_TRIM_SHIFT) |
  747. (XUSB_PADCTL_HSIC_PAD_CTL2_RX_DATA_TRIM_MASK <<
  748. XUSB_PADCTL_HSIC_PAD_CTL2_RX_DATA_TRIM_SHIFT));
  749. value |= (hsic->rx_strobe_trim <<
  750. XUSB_PADCTL_HSIC_PAD_CTL2_RX_STROBE_TRIM_SHIFT) |
  751. (hsic->rx_data_trim <<
  752. XUSB_PADCTL_HSIC_PAD_CTL2_RX_DATA_TRIM_SHIFT);
  753. padctl_writel(padctl, value, XUSB_PADCTL_HSIC_PADX_CTL2(index));
  754. value = padctl_readl(padctl, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  755. value &= ~(XUSB_PADCTL_HSIC_PAD_CTL1_RPD_STROBE |
  756. XUSB_PADCTL_HSIC_PAD_CTL1_RPU_DATA |
  757. XUSB_PADCTL_HSIC_PAD_CTL1_PD_RX |
  758. XUSB_PADCTL_HSIC_PAD_CTL1_PD_ZI |
  759. XUSB_PADCTL_HSIC_PAD_CTL1_PD_TRX |
  760. XUSB_PADCTL_HSIC_PAD_CTL1_PD_TX);
  761. value |= XUSB_PADCTL_HSIC_PAD_CTL1_RPD_DATA |
  762. XUSB_PADCTL_HSIC_PAD_CTL1_RPU_STROBE;
  763. padctl_writel(padctl, value, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  764. return 0;
  765. }
  766. static int tegra124_hsic_phy_power_off(struct phy *phy)
  767. {
  768. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  769. struct tegra_xusb_hsic_pad *pad = to_hsic_pad(lane->pad);
  770. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  771. unsigned int index = lane->index;
  772. u32 value;
  773. value = padctl_readl(padctl, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  774. value |= XUSB_PADCTL_HSIC_PAD_CTL1_PD_RX |
  775. XUSB_PADCTL_HSIC_PAD_CTL1_PD_ZI |
  776. XUSB_PADCTL_HSIC_PAD_CTL1_PD_TRX |
  777. XUSB_PADCTL_HSIC_PAD_CTL1_PD_TX;
  778. padctl_writel(padctl, value, XUSB_PADCTL_HSIC_PADX_CTL1(index));
  779. regulator_disable(pad->supply);
  780. return 0;
  781. }
  782. static const struct phy_ops tegra124_hsic_phy_ops = {
  783. .init = tegra124_hsic_phy_init,
  784. .exit = tegra124_hsic_phy_exit,
  785. .power_on = tegra124_hsic_phy_power_on,
  786. .power_off = tegra124_hsic_phy_power_off,
  787. .owner = THIS_MODULE,
  788. };
  789. static struct tegra_xusb_pad *
  790. tegra124_hsic_pad_probe(struct tegra_xusb_padctl *padctl,
  791. const struct tegra_xusb_pad_soc *soc,
  792. struct device_node *np)
  793. {
  794. struct tegra_xusb_hsic_pad *hsic;
  795. struct tegra_xusb_pad *pad;
  796. int err;
  797. hsic = kzalloc(sizeof(*hsic), GFP_KERNEL);
  798. if (!hsic)
  799. return ERR_PTR(-ENOMEM);
  800. pad = &hsic->base;
  801. pad->ops = &tegra124_hsic_lane_ops;
  802. pad->soc = soc;
  803. err = tegra_xusb_pad_init(pad, padctl, np);
  804. if (err < 0) {
  805. kfree(hsic);
  806. goto out;
  807. }
  808. err = tegra_xusb_pad_register(pad, &tegra124_hsic_phy_ops);
  809. if (err < 0)
  810. goto unregister;
  811. dev_set_drvdata(&pad->dev, pad);
  812. return pad;
  813. unregister:
  814. device_unregister(&pad->dev);
  815. out:
  816. return ERR_PTR(err);
  817. }
  818. static void tegra124_hsic_pad_remove(struct tegra_xusb_pad *pad)
  819. {
  820. struct tegra_xusb_hsic_pad *hsic = to_hsic_pad(pad);
  821. kfree(hsic);
  822. }
  823. static const struct tegra_xusb_pad_ops tegra124_hsic_ops = {
  824. .probe = tegra124_hsic_pad_probe,
  825. .remove = tegra124_hsic_pad_remove,
  826. };
  827. static const struct tegra_xusb_pad_soc tegra124_hsic_pad = {
  828. .name = "hsic",
  829. .num_lanes = ARRAY_SIZE(tegra124_hsic_lanes),
  830. .lanes = tegra124_hsic_lanes,
  831. .ops = &tegra124_hsic_ops,
  832. };
  833. static const char * const tegra124_pcie_functions[] = {
  834. "pcie",
  835. "usb3-ss",
  836. "sata",
  837. };
  838. static const struct tegra_xusb_lane_soc tegra124_pcie_lanes[] = {
  839. TEGRA124_LANE("pcie-0", 0x134, 16, 0x3, pcie),
  840. TEGRA124_LANE("pcie-1", 0x134, 18, 0x3, pcie),
  841. TEGRA124_LANE("pcie-2", 0x134, 20, 0x3, pcie),
  842. TEGRA124_LANE("pcie-3", 0x134, 22, 0x3, pcie),
  843. TEGRA124_LANE("pcie-4", 0x134, 24, 0x3, pcie),
  844. };
  845. static struct tegra_xusb_lane *
  846. tegra124_pcie_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  847. unsigned int index)
  848. {
  849. struct tegra_xusb_pcie_lane *pcie;
  850. int err;
  851. pcie = kzalloc(sizeof(*pcie), GFP_KERNEL);
  852. if (!pcie)
  853. return ERR_PTR(-ENOMEM);
  854. INIT_LIST_HEAD(&pcie->base.list);
  855. pcie->base.soc = &pad->soc->lanes[index];
  856. pcie->base.index = index;
  857. pcie->base.pad = pad;
  858. pcie->base.np = np;
  859. err = tegra_xusb_lane_parse_dt(&pcie->base, np);
  860. if (err < 0) {
  861. kfree(pcie);
  862. return ERR_PTR(err);
  863. }
  864. return &pcie->base;
  865. }
  866. static void tegra124_pcie_lane_remove(struct tegra_xusb_lane *lane)
  867. {
  868. struct tegra_xusb_pcie_lane *pcie = to_pcie_lane(lane);
  869. kfree(pcie);
  870. }
  871. static const struct tegra_xusb_lane_ops tegra124_pcie_lane_ops = {
  872. .probe = tegra124_pcie_lane_probe,
  873. .remove = tegra124_pcie_lane_remove,
  874. };
  875. static int tegra124_pcie_phy_init(struct phy *phy)
  876. {
  877. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  878. return tegra124_xusb_padctl_enable(lane->pad->padctl);
  879. }
  880. static int tegra124_pcie_phy_exit(struct phy *phy)
  881. {
  882. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  883. return tegra124_xusb_padctl_disable(lane->pad->padctl);
  884. }
  885. static int tegra124_pcie_phy_power_on(struct phy *phy)
  886. {
  887. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  888. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  889. unsigned long timeout;
  890. int err = -ETIMEDOUT;
  891. u32 value;
  892. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  893. value &= ~XUSB_PADCTL_IOPHY_PLL_P0_CTL1_REFCLK_SEL_MASK;
  894. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  895. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_P0_CTL2);
  896. value |= XUSB_PADCTL_IOPHY_PLL_P0_CTL2_REFCLKBUF_EN |
  897. XUSB_PADCTL_IOPHY_PLL_P0_CTL2_TXCLKREF_EN |
  898. XUSB_PADCTL_IOPHY_PLL_P0_CTL2_TXCLKREF_SEL;
  899. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_P0_CTL2);
  900. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  901. value |= XUSB_PADCTL_IOPHY_PLL_P0_CTL1_PLL_RST;
  902. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  903. timeout = jiffies + msecs_to_jiffies(50);
  904. while (time_before(jiffies, timeout)) {
  905. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  906. if (value & XUSB_PADCTL_IOPHY_PLL_P0_CTL1_PLL0_LOCKDET) {
  907. err = 0;
  908. break;
  909. }
  910. usleep_range(100, 200);
  911. }
  912. value = padctl_readl(padctl, XUSB_PADCTL_USB3_PAD_MUX);
  913. value |= XUSB_PADCTL_USB3_PAD_MUX_PCIE_IDDQ_DISABLE(lane->index);
  914. padctl_writel(padctl, value, XUSB_PADCTL_USB3_PAD_MUX);
  915. return err;
  916. }
  917. static int tegra124_pcie_phy_power_off(struct phy *phy)
  918. {
  919. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  920. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  921. u32 value;
  922. value = padctl_readl(padctl, XUSB_PADCTL_USB3_PAD_MUX);
  923. value &= ~XUSB_PADCTL_USB3_PAD_MUX_PCIE_IDDQ_DISABLE(lane->index);
  924. padctl_writel(padctl, value, XUSB_PADCTL_USB3_PAD_MUX);
  925. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  926. value &= ~XUSB_PADCTL_IOPHY_PLL_P0_CTL1_PLL_RST;
  927. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_P0_CTL1);
  928. return 0;
  929. }
  930. static const struct phy_ops tegra124_pcie_phy_ops = {
  931. .init = tegra124_pcie_phy_init,
  932. .exit = tegra124_pcie_phy_exit,
  933. .power_on = tegra124_pcie_phy_power_on,
  934. .power_off = tegra124_pcie_phy_power_off,
  935. .owner = THIS_MODULE,
  936. };
  937. static struct tegra_xusb_pad *
  938. tegra124_pcie_pad_probe(struct tegra_xusb_padctl *padctl,
  939. const struct tegra_xusb_pad_soc *soc,
  940. struct device_node *np)
  941. {
  942. struct tegra_xusb_pcie_pad *pcie;
  943. struct tegra_xusb_pad *pad;
  944. int err;
  945. pcie = kzalloc(sizeof(*pcie), GFP_KERNEL);
  946. if (!pcie)
  947. return ERR_PTR(-ENOMEM);
  948. pad = &pcie->base;
  949. pad->ops = &tegra124_pcie_lane_ops;
  950. pad->soc = soc;
  951. err = tegra_xusb_pad_init(pad, padctl, np);
  952. if (err < 0) {
  953. kfree(pcie);
  954. goto out;
  955. }
  956. err = tegra_xusb_pad_register(pad, &tegra124_pcie_phy_ops);
  957. if (err < 0)
  958. goto unregister;
  959. dev_set_drvdata(&pad->dev, pad);
  960. return pad;
  961. unregister:
  962. device_unregister(&pad->dev);
  963. out:
  964. return ERR_PTR(err);
  965. }
  966. static void tegra124_pcie_pad_remove(struct tegra_xusb_pad *pad)
  967. {
  968. struct tegra_xusb_pcie_pad *pcie = to_pcie_pad(pad);
  969. kfree(pcie);
  970. }
  971. static const struct tegra_xusb_pad_ops tegra124_pcie_ops = {
  972. .probe = tegra124_pcie_pad_probe,
  973. .remove = tegra124_pcie_pad_remove,
  974. };
  975. static const struct tegra_xusb_pad_soc tegra124_pcie_pad = {
  976. .name = "pcie",
  977. .num_lanes = ARRAY_SIZE(tegra124_pcie_lanes),
  978. .lanes = tegra124_pcie_lanes,
  979. .ops = &tegra124_pcie_ops,
  980. };
  981. static const struct tegra_xusb_lane_soc tegra124_sata_lanes[] = {
  982. TEGRA124_LANE("sata-0", 0x134, 26, 0x3, pcie),
  983. };
  984. static struct tegra_xusb_lane *
  985. tegra124_sata_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  986. unsigned int index)
  987. {
  988. struct tegra_xusb_sata_lane *sata;
  989. int err;
  990. sata = kzalloc(sizeof(*sata), GFP_KERNEL);
  991. if (!sata)
  992. return ERR_PTR(-ENOMEM);
  993. INIT_LIST_HEAD(&sata->base.list);
  994. sata->base.soc = &pad->soc->lanes[index];
  995. sata->base.index = index;
  996. sata->base.pad = pad;
  997. sata->base.np = np;
  998. err = tegra_xusb_lane_parse_dt(&sata->base, np);
  999. if (err < 0) {
  1000. kfree(sata);
  1001. return ERR_PTR(err);
  1002. }
  1003. return &sata->base;
  1004. }
  1005. static void tegra124_sata_lane_remove(struct tegra_xusb_lane *lane)
  1006. {
  1007. struct tegra_xusb_sata_lane *sata = to_sata_lane(lane);
  1008. kfree(sata);
  1009. }
  1010. static const struct tegra_xusb_lane_ops tegra124_sata_lane_ops = {
  1011. .probe = tegra124_sata_lane_probe,
  1012. .remove = tegra124_sata_lane_remove,
  1013. };
  1014. static int tegra124_sata_phy_init(struct phy *phy)
  1015. {
  1016. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  1017. return tegra124_xusb_padctl_enable(lane->pad->padctl);
  1018. }
  1019. static int tegra124_sata_phy_exit(struct phy *phy)
  1020. {
  1021. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  1022. return tegra124_xusb_padctl_disable(lane->pad->padctl);
  1023. }
  1024. static int tegra124_sata_phy_power_on(struct phy *phy)
  1025. {
  1026. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  1027. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  1028. unsigned long timeout;
  1029. int err = -ETIMEDOUT;
  1030. u32 value;
  1031. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1);
  1032. value &= ~XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1_IDDQ_OVRD;
  1033. value &= ~XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1_IDDQ;
  1034. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1);
  1035. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1036. value &= ~XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_PWR_OVRD;
  1037. value &= ~XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_IDDQ;
  1038. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1039. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1040. value |= XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL1_MODE;
  1041. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1042. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1043. value |= XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_RST;
  1044. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1045. timeout = jiffies + msecs_to_jiffies(50);
  1046. while (time_before(jiffies, timeout)) {
  1047. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1048. if (value & XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL1_LOCKDET) {
  1049. err = 0;
  1050. break;
  1051. }
  1052. usleep_range(100, 200);
  1053. }
  1054. value = padctl_readl(padctl, XUSB_PADCTL_USB3_PAD_MUX);
  1055. value |= XUSB_PADCTL_USB3_PAD_MUX_SATA_IDDQ_DISABLE(lane->index);
  1056. padctl_writel(padctl, value, XUSB_PADCTL_USB3_PAD_MUX);
  1057. return err;
  1058. }
  1059. static int tegra124_sata_phy_power_off(struct phy *phy)
  1060. {
  1061. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  1062. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  1063. u32 value;
  1064. value = padctl_readl(padctl, XUSB_PADCTL_USB3_PAD_MUX);
  1065. value &= ~XUSB_PADCTL_USB3_PAD_MUX_SATA_IDDQ_DISABLE(lane->index);
  1066. padctl_writel(padctl, value, XUSB_PADCTL_USB3_PAD_MUX);
  1067. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1068. value &= ~XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_RST;
  1069. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1070. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1071. value &= ~XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL1_MODE;
  1072. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1073. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1074. value |= XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_PWR_OVRD;
  1075. value |= XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL_IDDQ;
  1076. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1077. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1);
  1078. value |= ~XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1_IDDQ_OVRD;
  1079. value |= ~XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1_IDDQ;
  1080. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL1);
  1081. return 0;
  1082. }
  1083. static const struct phy_ops tegra124_sata_phy_ops = {
  1084. .init = tegra124_sata_phy_init,
  1085. .exit = tegra124_sata_phy_exit,
  1086. .power_on = tegra124_sata_phy_power_on,
  1087. .power_off = tegra124_sata_phy_power_off,
  1088. .owner = THIS_MODULE,
  1089. };
  1090. static struct tegra_xusb_pad *
  1091. tegra124_sata_pad_probe(struct tegra_xusb_padctl *padctl,
  1092. const struct tegra_xusb_pad_soc *soc,
  1093. struct device_node *np)
  1094. {
  1095. struct tegra_xusb_sata_pad *sata;
  1096. struct tegra_xusb_pad *pad;
  1097. int err;
  1098. sata = kzalloc(sizeof(*sata), GFP_KERNEL);
  1099. if (!sata)
  1100. return ERR_PTR(-ENOMEM);
  1101. pad = &sata->base;
  1102. pad->ops = &tegra124_sata_lane_ops;
  1103. pad->soc = soc;
  1104. err = tegra_xusb_pad_init(pad, padctl, np);
  1105. if (err < 0) {
  1106. kfree(sata);
  1107. goto out;
  1108. }
  1109. err = tegra_xusb_pad_register(pad, &tegra124_sata_phy_ops);
  1110. if (err < 0)
  1111. goto unregister;
  1112. dev_set_drvdata(&pad->dev, pad);
  1113. return pad;
  1114. unregister:
  1115. device_unregister(&pad->dev);
  1116. out:
  1117. return ERR_PTR(err);
  1118. }
  1119. static void tegra124_sata_pad_remove(struct tegra_xusb_pad *pad)
  1120. {
  1121. struct tegra_xusb_sata_pad *sata = to_sata_pad(pad);
  1122. kfree(sata);
  1123. }
  1124. static const struct tegra_xusb_pad_ops tegra124_sata_ops = {
  1125. .probe = tegra124_sata_pad_probe,
  1126. .remove = tegra124_sata_pad_remove,
  1127. };
  1128. static const struct tegra_xusb_pad_soc tegra124_sata_pad = {
  1129. .name = "sata",
  1130. .num_lanes = ARRAY_SIZE(tegra124_sata_lanes),
  1131. .lanes = tegra124_sata_lanes,
  1132. .ops = &tegra124_sata_ops,
  1133. };
  1134. static const struct tegra_xusb_pad_soc *tegra124_pads[] = {
  1135. &tegra124_usb2_pad,
  1136. &tegra124_ulpi_pad,
  1137. &tegra124_hsic_pad,
  1138. &tegra124_pcie_pad,
  1139. &tegra124_sata_pad,
  1140. };
  1141. static int tegra124_usb2_port_enable(struct tegra_xusb_port *port)
  1142. {
  1143. return 0;
  1144. }
  1145. static void tegra124_usb2_port_disable(struct tegra_xusb_port *port)
  1146. {
  1147. }
  1148. static struct tegra_xusb_lane *
  1149. tegra124_usb2_port_map(struct tegra_xusb_port *port)
  1150. {
  1151. return tegra_xusb_find_lane(port->padctl, "usb2", port->index);
  1152. }
  1153. static const struct tegra_xusb_port_ops tegra124_usb2_port_ops = {
  1154. .enable = tegra124_usb2_port_enable,
  1155. .disable = tegra124_usb2_port_disable,
  1156. .map = tegra124_usb2_port_map,
  1157. };
  1158. static int tegra124_ulpi_port_enable(struct tegra_xusb_port *port)
  1159. {
  1160. return 0;
  1161. }
  1162. static void tegra124_ulpi_port_disable(struct tegra_xusb_port *port)
  1163. {
  1164. }
  1165. static struct tegra_xusb_lane *
  1166. tegra124_ulpi_port_map(struct tegra_xusb_port *port)
  1167. {
  1168. return tegra_xusb_find_lane(port->padctl, "ulpi", port->index);
  1169. }
  1170. static const struct tegra_xusb_port_ops tegra124_ulpi_port_ops = {
  1171. .enable = tegra124_ulpi_port_enable,
  1172. .disable = tegra124_ulpi_port_disable,
  1173. .map = tegra124_ulpi_port_map,
  1174. };
  1175. static int tegra124_hsic_port_enable(struct tegra_xusb_port *port)
  1176. {
  1177. return 0;
  1178. }
  1179. static void tegra124_hsic_port_disable(struct tegra_xusb_port *port)
  1180. {
  1181. }
  1182. static struct tegra_xusb_lane *
  1183. tegra124_hsic_port_map(struct tegra_xusb_port *port)
  1184. {
  1185. return tegra_xusb_find_lane(port->padctl, "hsic", port->index);
  1186. }
  1187. static const struct tegra_xusb_port_ops tegra124_hsic_port_ops = {
  1188. .enable = tegra124_hsic_port_enable,
  1189. .disable = tegra124_hsic_port_disable,
  1190. .map = tegra124_hsic_port_map,
  1191. };
  1192. static int tegra124_usb3_port_enable(struct tegra_xusb_port *port)
  1193. {
  1194. struct tegra_xusb_usb3_port *usb3 = to_usb3_port(port);
  1195. struct tegra_xusb_padctl *padctl = port->padctl;
  1196. struct tegra_xusb_lane *lane = usb3->base.lane;
  1197. unsigned int index = port->index, offset;
  1198. int ret = 0;
  1199. u32 value;
  1200. value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
  1201. if (!usb3->internal)
  1202. value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_INTERNAL(index);
  1203. else
  1204. value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_INTERNAL(index);
  1205. value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(index);
  1206. value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(index, usb3->port);
  1207. padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
  1208. /*
  1209. * TODO: move this code into the PCIe/SATA PHY ->power_on() callbacks
  1210. * and conditionalize based on mux function? This seems to work, but
  1211. * might not be the exact proper sequence.
  1212. */
  1213. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_USB3_PADX_CTL2(index));
  1214. value &= ~((XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_MASK <<
  1215. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_SHIFT) |
  1216. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_MASK <<
  1217. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_SHIFT) |
  1218. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_MASK <<
  1219. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_SHIFT));
  1220. value |= (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_VAL <<
  1221. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_WANDER_SHIFT) |
  1222. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_VAL <<
  1223. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_CDR_CNTL_SHIFT) |
  1224. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_VAL <<
  1225. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_SHIFT);
  1226. if (usb3->context_saved) {
  1227. value &= ~((XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_MASK <<
  1228. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_SHIFT) |
  1229. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_MASK <<
  1230. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_SHIFT));
  1231. value |= (usb3->ctle_g <<
  1232. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_G_SHIFT) |
  1233. (usb3->ctle_z <<
  1234. XUSB_PADCTL_IOPHY_USB3_PAD_CTL2_RX_EQ_Z_SHIFT);
  1235. }
  1236. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_USB3_PADX_CTL2(index));
  1237. value = XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_VAL;
  1238. if (usb3->context_saved) {
  1239. value &= ~((XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_MASK <<
  1240. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_SHIFT) |
  1241. (XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_MASK <<
  1242. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_SHIFT));
  1243. value |= (usb3->tap1 <<
  1244. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_TAP_SHIFT) |
  1245. (usb3->amp <<
  1246. XUSB_PADCTL_IOPHY_USB3_PAD_CTL4_DFE_CNTL_AMP_SHIFT);
  1247. }
  1248. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_USB3_PADX_CTL4(index));
  1249. if (lane->pad == padctl->pcie)
  1250. offset = XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL2(lane->index);
  1251. else
  1252. offset = XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL2;
  1253. value = padctl_readl(padctl, offset);
  1254. value &= ~(XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_MASK <<
  1255. XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_SHIFT);
  1256. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_VAL <<
  1257. XUSB_PADCTL_IOPHY_MISC_PAD_CTL2_SPARE_IN_SHIFT;
  1258. padctl_writel(padctl, value, offset);
  1259. if (lane->pad == padctl->pcie)
  1260. offset = XUSB_PADCTL_IOPHY_MISC_PAD_PX_CTL5(lane->index);
  1261. else
  1262. offset = XUSB_PADCTL_IOPHY_MISC_PAD_S0_CTL5;
  1263. value = padctl_readl(padctl, offset);
  1264. value |= XUSB_PADCTL_IOPHY_MISC_PAD_CTL5_RX_QEYE_EN;
  1265. padctl_writel(padctl, value, offset);
  1266. /* Enable SATA PHY when SATA lane is used */
  1267. if (lane->pad == padctl->sata) {
  1268. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1269. value &= ~(XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL0_REFCLK_NDIV_MASK <<
  1270. XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL0_REFCLK_NDIV_SHIFT);
  1271. value |= 0x2 <<
  1272. XUSB_PADCTL_IOPHY_PLL_S0_CTL1_PLL0_REFCLK_NDIV_SHIFT;
  1273. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL1);
  1274. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL2);
  1275. value &= ~((XUSB_PADCTL_IOPHY_PLL_S0_CTL2_XDIGCLK_SEL_MASK <<
  1276. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_XDIGCLK_SEL_SHIFT) |
  1277. (XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL1_CP_CNTL_MASK <<
  1278. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL1_CP_CNTL_SHIFT) |
  1279. (XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL0_CP_CNTL_MASK <<
  1280. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL0_CP_CNTL_SHIFT) |
  1281. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_TCLKOUT_EN);
  1282. value |= (0x7 <<
  1283. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_XDIGCLK_SEL_SHIFT) |
  1284. (0x8 <<
  1285. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL1_CP_CNTL_SHIFT) |
  1286. (0x8 <<
  1287. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_PLL0_CP_CNTL_SHIFT) |
  1288. XUSB_PADCTL_IOPHY_PLL_S0_CTL2_TXCLKREF_SEL;
  1289. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL2);
  1290. value = padctl_readl(padctl, XUSB_PADCTL_IOPHY_PLL_S0_CTL3);
  1291. value &= ~XUSB_PADCTL_IOPHY_PLL_S0_CTL3_RCAL_BYPASS;
  1292. padctl_writel(padctl, value, XUSB_PADCTL_IOPHY_PLL_S0_CTL3);
  1293. }
  1294. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  1295. value &= ~XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_VCORE_DOWN(index);
  1296. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  1297. usleep_range(100, 200);
  1298. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  1299. value &= ~XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN_EARLY(index);
  1300. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  1301. usleep_range(100, 200);
  1302. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  1303. value &= ~XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN(index);
  1304. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  1305. return ret;
  1306. }
  1307. static void tegra124_usb3_port_disable(struct tegra_xusb_port *port)
  1308. {
  1309. struct tegra_xusb_padctl *padctl = port->padctl;
  1310. u32 value;
  1311. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  1312. value |= XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN_EARLY(port->index);
  1313. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  1314. usleep_range(100, 200);
  1315. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  1316. value |= XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_CLAMP_EN(port->index);
  1317. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  1318. usleep_range(250, 350);
  1319. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  1320. value |= XUSB_PADCTL_ELPG_PROGRAM_SSPX_ELPG_VCORE_DOWN(port->index);
  1321. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  1322. value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_MAP);
  1323. value &= ~XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP_MASK(port->index);
  1324. value |= XUSB_PADCTL_SS_PORT_MAP_PORTX_MAP(port->index, 0x7);
  1325. padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_MAP);
  1326. }
  1327. static const struct tegra_xusb_lane_map tegra124_usb3_map[] = {
  1328. { 0, "pcie", 0 },
  1329. { 1, "pcie", 1 },
  1330. { 1, "sata", 0 },
  1331. { 0, NULL, 0 },
  1332. };
  1333. static struct tegra_xusb_lane *
  1334. tegra124_usb3_port_map(struct tegra_xusb_port *port)
  1335. {
  1336. return tegra_xusb_port_find_lane(port, tegra124_usb3_map, "usb3-ss");
  1337. }
  1338. static const struct tegra_xusb_port_ops tegra124_usb3_port_ops = {
  1339. .enable = tegra124_usb3_port_enable,
  1340. .disable = tegra124_usb3_port_disable,
  1341. .map = tegra124_usb3_port_map,
  1342. };
  1343. static int
  1344. tegra124_xusb_read_fuse_calibration(struct tegra124_xusb_fuse_calibration *fuse)
  1345. {
  1346. unsigned int i;
  1347. int err;
  1348. u32 value;
  1349. err = tegra_fuse_readl(TEGRA_FUSE_SKU_CALIB_0, &value);
  1350. if (err < 0)
  1351. return err;
  1352. for (i = 0; i < ARRAY_SIZE(fuse->hs_curr_level); i++) {
  1353. fuse->hs_curr_level[i] =
  1354. (value >> FUSE_SKU_CALIB_HS_CURR_LEVEL_PADX_SHIFT(i)) &
  1355. FUSE_SKU_CALIB_HS_CURR_LEVEL_PAD_MASK;
  1356. }
  1357. fuse->hs_iref_cap =
  1358. (value >> FUSE_SKU_CALIB_HS_IREF_CAP_SHIFT) &
  1359. FUSE_SKU_CALIB_HS_IREF_CAP_MASK;
  1360. fuse->hs_term_range_adj =
  1361. (value >> FUSE_SKU_CALIB_HS_TERM_RANGE_ADJ_SHIFT) &
  1362. FUSE_SKU_CALIB_HS_TERM_RANGE_ADJ_MASK;
  1363. fuse->hs_squelch_level =
  1364. (value >> FUSE_SKU_CALIB_HS_SQUELCH_LEVEL_SHIFT) &
  1365. FUSE_SKU_CALIB_HS_SQUELCH_LEVEL_MASK;
  1366. return 0;
  1367. }
  1368. static struct tegra_xusb_padctl *
  1369. tegra124_xusb_padctl_probe(struct device *dev,
  1370. const struct tegra_xusb_padctl_soc *soc)
  1371. {
  1372. struct tegra124_xusb_padctl *padctl;
  1373. int err;
  1374. padctl = devm_kzalloc(dev, sizeof(*padctl), GFP_KERNEL);
  1375. if (!padctl)
  1376. return ERR_PTR(-ENOMEM);
  1377. padctl->base.dev = dev;
  1378. padctl->base.soc = soc;
  1379. err = tegra124_xusb_read_fuse_calibration(&padctl->fuse);
  1380. if (err < 0)
  1381. return ERR_PTR(err);
  1382. return &padctl->base;
  1383. }
  1384. static void tegra124_xusb_padctl_remove(struct tegra_xusb_padctl *padctl)
  1385. {
  1386. }
  1387. static const struct tegra_xusb_padctl_ops tegra124_xusb_padctl_ops = {
  1388. .probe = tegra124_xusb_padctl_probe,
  1389. .remove = tegra124_xusb_padctl_remove,
  1390. .usb3_save_context = tegra124_usb3_save_context,
  1391. .hsic_set_idle = tegra124_hsic_set_idle,
  1392. };
  1393. const struct tegra_xusb_padctl_soc tegra124_xusb_padctl_soc = {
  1394. .num_pads = ARRAY_SIZE(tegra124_pads),
  1395. .pads = tegra124_pads,
  1396. .ports = {
  1397. .usb2 = {
  1398. .ops = &tegra124_usb2_port_ops,
  1399. .count = 3,
  1400. },
  1401. .ulpi = {
  1402. .ops = &tegra124_ulpi_port_ops,
  1403. .count = 1,
  1404. },
  1405. .hsic = {
  1406. .ops = &tegra124_hsic_port_ops,
  1407. .count = 2,
  1408. },
  1409. .usb3 = {
  1410. .ops = &tegra124_usb3_port_ops,
  1411. .count = 2,
  1412. },
  1413. },
  1414. .ops = &tegra124_xusb_padctl_ops,
  1415. };
  1416. EXPORT_SYMBOL_GPL(tegra124_xusb_padctl_soc);
  1417. MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>");
  1418. MODULE_DESCRIPTION("NVIDIA Tegra 124 XUSB Pad Controller driver");
  1419. MODULE_LICENSE("GPL v2");