xusb-tegra186.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2016-2022, NVIDIA CORPORATION. All rights reserved.
  4. */
  5. #include <linux/delay.h>
  6. #include <linux/io.h>
  7. #include <linux/module.h>
  8. #include <linux/of.h>
  9. #include <linux/phy/phy.h>
  10. #include <linux/regulator/consumer.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/clk.h>
  13. #include <linux/slab.h>
  14. #include <soc/tegra/fuse.h>
  15. #include "xusb.h"
  16. /* FUSE USB_CALIB registers */
  17. #define HS_CURR_LEVEL_PADX_SHIFT(x) ((x) ? (11 + (x - 1) * 6) : 0)
  18. #define HS_CURR_LEVEL_PAD_MASK 0x3f
  19. #define HS_TERM_RANGE_ADJ_SHIFT 7
  20. #define HS_TERM_RANGE_ADJ_MASK 0xf
  21. #define HS_SQUELCH_SHIFT 29
  22. #define HS_SQUELCH_MASK 0x7
  23. #define RPD_CTRL_SHIFT 0
  24. #define RPD_CTRL_MASK 0x1f
  25. /* XUSB PADCTL registers */
  26. #define XUSB_PADCTL_USB2_PAD_MUX 0x4
  27. #define USB2_PORT_SHIFT(x) ((x) * 2)
  28. #define USB2_PORT_MASK 0x3
  29. #define PORT_XUSB 1
  30. #define HSIC_PORT_SHIFT(x) ((x) + 20)
  31. #define HSIC_PORT_MASK 0x1
  32. #define PORT_HSIC 0
  33. #define XUSB_PADCTL_USB2_PORT_CAP 0x8
  34. #define XUSB_PADCTL_SS_PORT_CAP 0xc
  35. #define PORTX_CAP_SHIFT(x) ((x) * 4)
  36. #define PORT_CAP_MASK 0x3
  37. #define PORT_CAP_DISABLED 0x0
  38. #define PORT_CAP_HOST 0x1
  39. #define PORT_CAP_DEVICE 0x2
  40. #define PORT_CAP_OTG 0x3
  41. #define XUSB_PADCTL_ELPG_PROGRAM 0x20
  42. #define USB2_PORT_WAKE_INTERRUPT_ENABLE(x) BIT(x)
  43. #define USB2_PORT_WAKEUP_EVENT(x) BIT((x) + 7)
  44. #define SS_PORT_WAKE_INTERRUPT_ENABLE(x) BIT((x) + 14)
  45. #define SS_PORT_WAKEUP_EVENT(x) BIT((x) + 21)
  46. #define USB2_HSIC_PORT_WAKE_INTERRUPT_ENABLE(x) BIT((x) + 28)
  47. #define USB2_HSIC_PORT_WAKEUP_EVENT(x) BIT((x) + 30)
  48. #define ALL_WAKE_EVENTS \
  49. (USB2_PORT_WAKEUP_EVENT(0) | USB2_PORT_WAKEUP_EVENT(1) | \
  50. USB2_PORT_WAKEUP_EVENT(2) | SS_PORT_WAKEUP_EVENT(0) | \
  51. SS_PORT_WAKEUP_EVENT(1) | SS_PORT_WAKEUP_EVENT(2) | \
  52. USB2_HSIC_PORT_WAKEUP_EVENT(0))
  53. #define XUSB_PADCTL_ELPG_PROGRAM_1 0x24
  54. #define SSPX_ELPG_CLAMP_EN(x) BIT(0 + (x) * 3)
  55. #define SSPX_ELPG_CLAMP_EN_EARLY(x) BIT(1 + (x) * 3)
  56. #define SSPX_ELPG_VCORE_DOWN(x) BIT(2 + (x) * 3)
  57. #define XUSB_PADCTL_SS_PORT_CFG 0x2c
  58. #define PORTX_SPEED_SUPPORT_SHIFT(x) ((x) * 4)
  59. #define PORTX_SPEED_SUPPORT_MASK (0x3)
  60. #define PORT_SPEED_SUPPORT_GEN1 (0x0)
  61. #define XUSB_PADCTL_USB2_OTG_PADX_CTL0(x) (0x88 + (x) * 0x40)
  62. #define HS_CURR_LEVEL(x) ((x) & 0x3f)
  63. #define TERM_SEL BIT(25)
  64. #define USB2_OTG_PD BIT(26)
  65. #define USB2_OTG_PD2 BIT(27)
  66. #define USB2_OTG_PD2_OVRD_EN BIT(28)
  67. #define USB2_OTG_PD_ZI BIT(29)
  68. #define XUSB_PADCTL_USB2_OTG_PADX_CTL1(x) (0x8c + (x) * 0x40)
  69. #define USB2_OTG_PD_DR BIT(2)
  70. #define TERM_RANGE_ADJ(x) (((x) & 0xf) << 3)
  71. #define RPD_CTRL(x) (((x) & 0x1f) << 26)
  72. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0 0x284
  73. #define BIAS_PAD_PD BIT(11)
  74. #define HS_SQUELCH_LEVEL(x) (((x) & 0x7) << 0)
  75. #define XUSB_PADCTL_USB2_BIAS_PAD_CTL1 0x288
  76. #define USB2_TRK_START_TIMER(x) (((x) & 0x7f) << 12)
  77. #define USB2_TRK_DONE_RESET_TIMER(x) (((x) & 0x7f) << 19)
  78. #define USB2_PD_TRK BIT(26)
  79. #define XUSB_PADCTL_HSIC_PADX_CTL0(x) (0x300 + (x) * 0x20)
  80. #define HSIC_PD_TX_DATA0 BIT(1)
  81. #define HSIC_PD_TX_STROBE BIT(3)
  82. #define HSIC_PD_RX_DATA0 BIT(4)
  83. #define HSIC_PD_RX_STROBE BIT(6)
  84. #define HSIC_PD_ZI_DATA0 BIT(7)
  85. #define HSIC_PD_ZI_STROBE BIT(9)
  86. #define HSIC_RPD_DATA0 BIT(13)
  87. #define HSIC_RPD_STROBE BIT(15)
  88. #define HSIC_RPU_DATA0 BIT(16)
  89. #define HSIC_RPU_STROBE BIT(18)
  90. #define XUSB_PADCTL_HSIC_PAD_TRK_CTL0 0x340
  91. #define HSIC_TRK_START_TIMER(x) (((x) & 0x7f) << 5)
  92. #define HSIC_TRK_DONE_RESET_TIMER(x) (((x) & 0x7f) << 12)
  93. #define HSIC_PD_TRK BIT(19)
  94. #define USB2_VBUS_ID 0x360
  95. #define VBUS_OVERRIDE BIT(14)
  96. #define ID_OVERRIDE(x) (((x) & 0xf) << 18)
  97. #define ID_OVERRIDE_FLOATING ID_OVERRIDE(8)
  98. #define ID_OVERRIDE_GROUNDED ID_OVERRIDE(0)
  99. /* XUSB AO registers */
  100. #define XUSB_AO_USB_DEBOUNCE_DEL (0x4)
  101. #define UHSIC_LINE_DEB_CNT(x) (((x) & 0xf) << 4)
  102. #define UTMIP_LINE_DEB_CNT(x) ((x) & 0xf)
  103. #define XUSB_AO_UTMIP_TRIGGERS(x) (0x40 + (x) * 4)
  104. #define CLR_WALK_PTR BIT(0)
  105. #define CAP_CFG BIT(1)
  106. #define CLR_WAKE_ALARM BIT(3)
  107. #define XUSB_AO_UHSIC_TRIGGERS(x) (0x60 + (x) * 4)
  108. #define HSIC_CLR_WALK_PTR BIT(0)
  109. #define HSIC_CLR_WAKE_ALARM BIT(3)
  110. #define HSIC_CAP_CFG BIT(4)
  111. #define XUSB_AO_UTMIP_SAVED_STATE(x) (0x70 + (x) * 4)
  112. #define SPEED(x) ((x) & 0x3)
  113. #define UTMI_HS SPEED(0)
  114. #define UTMI_FS SPEED(1)
  115. #define UTMI_LS SPEED(2)
  116. #define UTMI_RST SPEED(3)
  117. #define XUSB_AO_UHSIC_SAVED_STATE(x) (0x90 + (x) * 4)
  118. #define MODE(x) ((x) & 0x1)
  119. #define MODE_HS MODE(0)
  120. #define MODE_RST MODE(1)
  121. #define XUSB_AO_UTMIP_SLEEPWALK_CFG(x) (0xd0 + (x) * 4)
  122. #define XUSB_AO_UHSIC_SLEEPWALK_CFG(x) (0xf0 + (x) * 4)
  123. #define FAKE_USBOP_VAL BIT(0)
  124. #define FAKE_USBON_VAL BIT(1)
  125. #define FAKE_USBOP_EN BIT(2)
  126. #define FAKE_USBON_EN BIT(3)
  127. #define FAKE_STROBE_VAL BIT(0)
  128. #define FAKE_DATA_VAL BIT(1)
  129. #define FAKE_STROBE_EN BIT(2)
  130. #define FAKE_DATA_EN BIT(3)
  131. #define WAKE_WALK_EN BIT(14)
  132. #define MASTER_ENABLE BIT(15)
  133. #define LINEVAL_WALK_EN BIT(16)
  134. #define WAKE_VAL(x) (((x) & 0xf) << 17)
  135. #define WAKE_VAL_NONE WAKE_VAL(12)
  136. #define WAKE_VAL_ANY WAKE_VAL(15)
  137. #define WAKE_VAL_DS10 WAKE_VAL(2)
  138. #define LINE_WAKEUP_EN BIT(21)
  139. #define MASTER_CFG_SEL BIT(22)
  140. #define XUSB_AO_UTMIP_SLEEPWALK(x) (0x100 + (x) * 4)
  141. /* phase A */
  142. #define USBOP_RPD_A BIT(0)
  143. #define USBON_RPD_A BIT(1)
  144. #define AP_A BIT(4)
  145. #define AN_A BIT(5)
  146. #define HIGHZ_A BIT(6)
  147. /* phase B */
  148. #define USBOP_RPD_B BIT(8)
  149. #define USBON_RPD_B BIT(9)
  150. #define AP_B BIT(12)
  151. #define AN_B BIT(13)
  152. #define HIGHZ_B BIT(14)
  153. /* phase C */
  154. #define USBOP_RPD_C BIT(16)
  155. #define USBON_RPD_C BIT(17)
  156. #define AP_C BIT(20)
  157. #define AN_C BIT(21)
  158. #define HIGHZ_C BIT(22)
  159. /* phase D */
  160. #define USBOP_RPD_D BIT(24)
  161. #define USBON_RPD_D BIT(25)
  162. #define AP_D BIT(28)
  163. #define AN_D BIT(29)
  164. #define HIGHZ_D BIT(30)
  165. #define XUSB_AO_UHSIC_SLEEPWALK(x) (0x120 + (x) * 4)
  166. /* phase A */
  167. #define RPD_STROBE_A BIT(0)
  168. #define RPD_DATA0_A BIT(1)
  169. #define RPU_STROBE_A BIT(2)
  170. #define RPU_DATA0_A BIT(3)
  171. /* phase B */
  172. #define RPD_STROBE_B BIT(8)
  173. #define RPD_DATA0_B BIT(9)
  174. #define RPU_STROBE_B BIT(10)
  175. #define RPU_DATA0_B BIT(11)
  176. /* phase C */
  177. #define RPD_STROBE_C BIT(16)
  178. #define RPD_DATA0_C BIT(17)
  179. #define RPU_STROBE_C BIT(18)
  180. #define RPU_DATA0_C BIT(19)
  181. /* phase D */
  182. #define RPD_STROBE_D BIT(24)
  183. #define RPD_DATA0_D BIT(25)
  184. #define RPU_STROBE_D BIT(26)
  185. #define RPU_DATA0_D BIT(27)
  186. #define XUSB_AO_UTMIP_PAD_CFG(x) (0x130 + (x) * 4)
  187. #define FSLS_USE_XUSB_AO BIT(3)
  188. #define TRK_CTRL_USE_XUSB_AO BIT(4)
  189. #define RPD_CTRL_USE_XUSB_AO BIT(5)
  190. #define RPU_USE_XUSB_AO BIT(6)
  191. #define VREG_USE_XUSB_AO BIT(7)
  192. #define USBOP_VAL_PD BIT(8)
  193. #define USBON_VAL_PD BIT(9)
  194. #define E_DPD_OVRD_EN BIT(10)
  195. #define E_DPD_OVRD_VAL BIT(11)
  196. #define XUSB_AO_UHSIC_PAD_CFG(x) (0x150 + (x) * 4)
  197. #define STROBE_VAL_PD BIT(0)
  198. #define DATA0_VAL_PD BIT(1)
  199. #define USE_XUSB_AO BIT(4)
  200. #define TEGRA186_LANE(_name, _offset, _shift, _mask, _type) \
  201. { \
  202. .name = _name, \
  203. .offset = _offset, \
  204. .shift = _shift, \
  205. .mask = _mask, \
  206. .num_funcs = ARRAY_SIZE(tegra186_##_type##_functions), \
  207. .funcs = tegra186_##_type##_functions, \
  208. }
  209. struct tegra_xusb_fuse_calibration {
  210. u32 *hs_curr_level;
  211. u32 hs_squelch;
  212. u32 hs_term_range_adj;
  213. u32 rpd_ctrl;
  214. };
  215. struct tegra186_xusb_padctl_context {
  216. u32 vbus_id;
  217. u32 usb2_pad_mux;
  218. u32 usb2_port_cap;
  219. u32 ss_port_cap;
  220. };
  221. struct tegra186_xusb_padctl {
  222. struct tegra_xusb_padctl base;
  223. void __iomem *ao_regs;
  224. struct tegra_xusb_fuse_calibration calib;
  225. /* UTMI bias and tracking */
  226. struct clk *usb2_trk_clk;
  227. unsigned int bias_pad_enable;
  228. /* padctl context */
  229. struct tegra186_xusb_padctl_context context;
  230. };
  231. static inline void ao_writel(struct tegra186_xusb_padctl *priv, u32 value, unsigned int offset)
  232. {
  233. writel(value, priv->ao_regs + offset);
  234. }
  235. static inline u32 ao_readl(struct tegra186_xusb_padctl *priv, unsigned int offset)
  236. {
  237. return readl(priv->ao_regs + offset);
  238. }
  239. static inline struct tegra186_xusb_padctl *
  240. to_tegra186_xusb_padctl(struct tegra_xusb_padctl *padctl)
  241. {
  242. return container_of(padctl, struct tegra186_xusb_padctl, base);
  243. }
  244. /* USB 2.0 UTMI PHY support */
  245. static struct tegra_xusb_lane *
  246. tegra186_usb2_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  247. unsigned int index)
  248. {
  249. struct tegra_xusb_usb2_lane *usb2;
  250. int err;
  251. usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
  252. if (!usb2)
  253. return ERR_PTR(-ENOMEM);
  254. INIT_LIST_HEAD(&usb2->base.list);
  255. usb2->base.soc = &pad->soc->lanes[index];
  256. usb2->base.index = index;
  257. usb2->base.pad = pad;
  258. usb2->base.np = np;
  259. err = tegra_xusb_lane_parse_dt(&usb2->base, np);
  260. if (err < 0) {
  261. kfree(usb2);
  262. return ERR_PTR(err);
  263. }
  264. return &usb2->base;
  265. }
  266. static void tegra186_usb2_lane_remove(struct tegra_xusb_lane *lane)
  267. {
  268. struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
  269. kfree(usb2);
  270. }
  271. static int tegra186_utmi_enable_phy_sleepwalk(struct tegra_xusb_lane *lane,
  272. enum usb_device_speed speed)
  273. {
  274. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  275. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  276. unsigned int index = lane->index;
  277. u32 value;
  278. mutex_lock(&padctl->lock);
  279. /* ensure sleepwalk logic is disabled */
  280. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  281. value &= ~MASTER_ENABLE;
  282. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  283. /* ensure sleepwalk logics are in low power mode */
  284. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  285. value |= MASTER_CFG_SEL;
  286. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  287. /* set debounce time */
  288. value = ao_readl(priv, XUSB_AO_USB_DEBOUNCE_DEL);
  289. value &= ~UTMIP_LINE_DEB_CNT(~0);
  290. value |= UTMIP_LINE_DEB_CNT(1);
  291. ao_writel(priv, value, XUSB_AO_USB_DEBOUNCE_DEL);
  292. /* ensure fake events of sleepwalk logic are desiabled */
  293. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  294. value &= ~(FAKE_USBOP_VAL | FAKE_USBON_VAL |
  295. FAKE_USBOP_EN | FAKE_USBON_EN);
  296. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  297. /* ensure wake events of sleepwalk logic are not latched */
  298. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  299. value &= ~LINE_WAKEUP_EN;
  300. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  301. /* disable wake event triggers of sleepwalk logic */
  302. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  303. value &= ~WAKE_VAL(~0);
  304. value |= WAKE_VAL_NONE;
  305. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  306. /* power down the line state detectors of the pad */
  307. value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
  308. value |= (USBOP_VAL_PD | USBON_VAL_PD);
  309. ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
  310. /* save state per speed */
  311. value = ao_readl(priv, XUSB_AO_UTMIP_SAVED_STATE(index));
  312. value &= ~SPEED(~0);
  313. switch (speed) {
  314. case USB_SPEED_HIGH:
  315. value |= UTMI_HS;
  316. break;
  317. case USB_SPEED_FULL:
  318. value |= UTMI_FS;
  319. break;
  320. case USB_SPEED_LOW:
  321. value |= UTMI_LS;
  322. break;
  323. default:
  324. value |= UTMI_RST;
  325. break;
  326. }
  327. ao_writel(priv, value, XUSB_AO_UTMIP_SAVED_STATE(index));
  328. /* enable the trigger of the sleepwalk logic */
  329. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  330. value |= LINEVAL_WALK_EN;
  331. value &= ~WAKE_WALK_EN;
  332. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  333. /* reset the walk pointer and clear the alarm of the sleepwalk logic,
  334. * as well as capture the configuration of the USB2.0 pad
  335. */
  336. value = ao_readl(priv, XUSB_AO_UTMIP_TRIGGERS(index));
  337. value |= (CLR_WALK_PTR | CLR_WAKE_ALARM | CAP_CFG);
  338. ao_writel(priv, value, XUSB_AO_UTMIP_TRIGGERS(index));
  339. /* setup the pull-ups and pull-downs of the signals during the four
  340. * stages of sleepwalk.
  341. * if device is connected, program sleepwalk logic to maintain a J and
  342. * keep driving K upon seeing remote wake.
  343. */
  344. value = USBOP_RPD_A | USBOP_RPD_B | USBOP_RPD_C | USBOP_RPD_D;
  345. value |= USBON_RPD_A | USBON_RPD_B | USBON_RPD_C | USBON_RPD_D;
  346. switch (speed) {
  347. case USB_SPEED_HIGH:
  348. case USB_SPEED_FULL:
  349. /* J state: D+/D- = high/low, K state: D+/D- = low/high */
  350. value |= HIGHZ_A;
  351. value |= AP_A;
  352. value |= AN_B | AN_C | AN_D;
  353. break;
  354. case USB_SPEED_LOW:
  355. /* J state: D+/D- = low/high, K state: D+/D- = high/low */
  356. value |= HIGHZ_A;
  357. value |= AN_A;
  358. value |= AP_B | AP_C | AP_D;
  359. break;
  360. default:
  361. value |= HIGHZ_A | HIGHZ_B | HIGHZ_C | HIGHZ_D;
  362. break;
  363. }
  364. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK(index));
  365. /* power up the line state detectors of the pad */
  366. value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
  367. value &= ~(USBOP_VAL_PD | USBON_VAL_PD);
  368. ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
  369. usleep_range(150, 200);
  370. /* switch the electric control of the USB2.0 pad to XUSB_AO */
  371. value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
  372. value |= FSLS_USE_XUSB_AO | TRK_CTRL_USE_XUSB_AO | RPD_CTRL_USE_XUSB_AO |
  373. RPU_USE_XUSB_AO | VREG_USE_XUSB_AO;
  374. ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
  375. /* set the wake signaling trigger events */
  376. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  377. value &= ~WAKE_VAL(~0);
  378. value |= WAKE_VAL_ANY;
  379. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  380. /* enable the wake detection */
  381. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  382. value |= MASTER_ENABLE | LINE_WAKEUP_EN;
  383. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  384. mutex_unlock(&padctl->lock);
  385. return 0;
  386. }
  387. static int tegra186_utmi_disable_phy_sleepwalk(struct tegra_xusb_lane *lane)
  388. {
  389. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  390. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  391. unsigned int index = lane->index;
  392. u32 value;
  393. mutex_lock(&padctl->lock);
  394. /* disable the wake detection */
  395. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  396. value &= ~(MASTER_ENABLE | LINE_WAKEUP_EN);
  397. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  398. /* switch the electric control of the USB2.0 pad to XUSB vcore logic */
  399. value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
  400. value &= ~(FSLS_USE_XUSB_AO | TRK_CTRL_USE_XUSB_AO | RPD_CTRL_USE_XUSB_AO |
  401. RPU_USE_XUSB_AO | VREG_USE_XUSB_AO);
  402. ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
  403. /* disable wake event triggers of sleepwalk logic */
  404. value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  405. value &= ~WAKE_VAL(~0);
  406. value |= WAKE_VAL_NONE;
  407. ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
  408. /* power down the line state detectors of the port */
  409. value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
  410. value |= USBOP_VAL_PD | USBON_VAL_PD;
  411. ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
  412. /* clear alarm of the sleepwalk logic */
  413. value = ao_readl(priv, XUSB_AO_UTMIP_TRIGGERS(index));
  414. value |= CLR_WAKE_ALARM;
  415. ao_writel(priv, value, XUSB_AO_UTMIP_TRIGGERS(index));
  416. mutex_unlock(&padctl->lock);
  417. return 0;
  418. }
  419. static int tegra186_utmi_enable_phy_wake(struct tegra_xusb_lane *lane)
  420. {
  421. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  422. unsigned int index = lane->index;
  423. u32 value;
  424. mutex_lock(&padctl->lock);
  425. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  426. value &= ~ALL_WAKE_EVENTS;
  427. value |= USB2_PORT_WAKEUP_EVENT(index);
  428. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  429. usleep_range(10, 20);
  430. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  431. value &= ~ALL_WAKE_EVENTS;
  432. value |= USB2_PORT_WAKE_INTERRUPT_ENABLE(index);
  433. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  434. mutex_unlock(&padctl->lock);
  435. return 0;
  436. }
  437. static int tegra186_utmi_disable_phy_wake(struct tegra_xusb_lane *lane)
  438. {
  439. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  440. unsigned int index = lane->index;
  441. u32 value;
  442. mutex_lock(&padctl->lock);
  443. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  444. value &= ~ALL_WAKE_EVENTS;
  445. value &= ~USB2_PORT_WAKE_INTERRUPT_ENABLE(index);
  446. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  447. usleep_range(10, 20);
  448. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  449. value &= ~ALL_WAKE_EVENTS;
  450. value |= USB2_PORT_WAKEUP_EVENT(index);
  451. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  452. mutex_unlock(&padctl->lock);
  453. return 0;
  454. }
  455. static bool tegra186_utmi_phy_remote_wake_detected(struct tegra_xusb_lane *lane)
  456. {
  457. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  458. unsigned int index = lane->index;
  459. u32 value;
  460. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  461. if ((value & USB2_PORT_WAKE_INTERRUPT_ENABLE(index)) &&
  462. (value & USB2_PORT_WAKEUP_EVENT(index)))
  463. return true;
  464. return false;
  465. }
  466. static const struct tegra_xusb_lane_ops tegra186_usb2_lane_ops = {
  467. .probe = tegra186_usb2_lane_probe,
  468. .remove = tegra186_usb2_lane_remove,
  469. .enable_phy_sleepwalk = tegra186_utmi_enable_phy_sleepwalk,
  470. .disable_phy_sleepwalk = tegra186_utmi_disable_phy_sleepwalk,
  471. .enable_phy_wake = tegra186_utmi_enable_phy_wake,
  472. .disable_phy_wake = tegra186_utmi_disable_phy_wake,
  473. .remote_wake_detected = tegra186_utmi_phy_remote_wake_detected,
  474. };
  475. static void tegra186_utmi_bias_pad_power_on(struct tegra_xusb_padctl *padctl)
  476. {
  477. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  478. struct device *dev = padctl->dev;
  479. u32 value;
  480. int err;
  481. mutex_lock(&padctl->lock);
  482. if (priv->bias_pad_enable++ > 0) {
  483. mutex_unlock(&padctl->lock);
  484. return;
  485. }
  486. err = clk_prepare_enable(priv->usb2_trk_clk);
  487. if (err < 0)
  488. dev_warn(dev, "failed to enable USB2 trk clock: %d\n", err);
  489. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
  490. value &= ~USB2_TRK_START_TIMER(~0);
  491. value |= USB2_TRK_START_TIMER(0x1e);
  492. value &= ~USB2_TRK_DONE_RESET_TIMER(~0);
  493. value |= USB2_TRK_DONE_RESET_TIMER(0xa);
  494. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
  495. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  496. value &= ~BIAS_PAD_PD;
  497. value &= ~HS_SQUELCH_LEVEL(~0);
  498. value |= HS_SQUELCH_LEVEL(priv->calib.hs_squelch);
  499. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
  500. udelay(1);
  501. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
  502. value &= ~USB2_PD_TRK;
  503. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
  504. mutex_unlock(&padctl->lock);
  505. }
  506. static void tegra186_utmi_bias_pad_power_off(struct tegra_xusb_padctl *padctl)
  507. {
  508. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  509. u32 value;
  510. mutex_lock(&padctl->lock);
  511. if (WARN_ON(priv->bias_pad_enable == 0)) {
  512. mutex_unlock(&padctl->lock);
  513. return;
  514. }
  515. if (--priv->bias_pad_enable > 0) {
  516. mutex_unlock(&padctl->lock);
  517. return;
  518. }
  519. value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
  520. value |= USB2_PD_TRK;
  521. padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
  522. clk_disable_unprepare(priv->usb2_trk_clk);
  523. mutex_unlock(&padctl->lock);
  524. }
  525. static void tegra186_utmi_pad_power_on(struct phy *phy)
  526. {
  527. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  528. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  529. struct tegra_xusb_usb2_port *port;
  530. struct device *dev = padctl->dev;
  531. unsigned int index = lane->index;
  532. u32 value;
  533. if (!phy)
  534. return;
  535. port = tegra_xusb_find_usb2_port(padctl, index);
  536. if (!port) {
  537. dev_err(dev, "no port found for USB2 lane %u\n", index);
  538. return;
  539. }
  540. dev_dbg(dev, "power on UTMI pad %u\n", index);
  541. tegra186_utmi_bias_pad_power_on(padctl);
  542. udelay(2);
  543. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  544. value &= ~USB2_OTG_PD;
  545. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  546. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  547. value &= ~USB2_OTG_PD_DR;
  548. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  549. }
  550. static void tegra186_utmi_pad_power_down(struct phy *phy)
  551. {
  552. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  553. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  554. unsigned int index = lane->index;
  555. u32 value;
  556. if (!phy)
  557. return;
  558. dev_dbg(padctl->dev, "power down UTMI pad %u\n", index);
  559. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  560. value |= USB2_OTG_PD;
  561. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  562. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  563. value |= USB2_OTG_PD_DR;
  564. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  565. udelay(2);
  566. tegra186_utmi_bias_pad_power_off(padctl);
  567. }
  568. static int tegra186_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
  569. bool status)
  570. {
  571. u32 value;
  572. dev_dbg(padctl->dev, "%s vbus override\n", status ? "set" : "clear");
  573. value = padctl_readl(padctl, USB2_VBUS_ID);
  574. if (status) {
  575. value |= VBUS_OVERRIDE;
  576. value &= ~ID_OVERRIDE(~0);
  577. value |= ID_OVERRIDE_FLOATING;
  578. } else {
  579. value &= ~VBUS_OVERRIDE;
  580. }
  581. padctl_writel(padctl, value, USB2_VBUS_ID);
  582. return 0;
  583. }
  584. static int tegra186_xusb_padctl_id_override(struct tegra_xusb_padctl *padctl,
  585. bool status)
  586. {
  587. u32 value;
  588. dev_dbg(padctl->dev, "%s id override\n", status ? "set" : "clear");
  589. value = padctl_readl(padctl, USB2_VBUS_ID);
  590. if (status) {
  591. if (value & VBUS_OVERRIDE) {
  592. value &= ~VBUS_OVERRIDE;
  593. padctl_writel(padctl, value, USB2_VBUS_ID);
  594. usleep_range(1000, 2000);
  595. value = padctl_readl(padctl, USB2_VBUS_ID);
  596. }
  597. value &= ~ID_OVERRIDE(~0);
  598. value |= ID_OVERRIDE_GROUNDED;
  599. } else {
  600. value &= ~ID_OVERRIDE(~0);
  601. value |= ID_OVERRIDE_FLOATING;
  602. }
  603. padctl_writel(padctl, value, USB2_VBUS_ID);
  604. return 0;
  605. }
  606. static int tegra186_utmi_phy_set_mode(struct phy *phy, enum phy_mode mode,
  607. int submode)
  608. {
  609. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  610. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  611. struct tegra_xusb_usb2_port *port = tegra_xusb_find_usb2_port(padctl,
  612. lane->index);
  613. int err = 0;
  614. mutex_lock(&padctl->lock);
  615. dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode);
  616. if (mode == PHY_MODE_USB_OTG) {
  617. if (submode == USB_ROLE_HOST) {
  618. tegra186_xusb_padctl_id_override(padctl, true);
  619. err = regulator_enable(port->supply);
  620. } else if (submode == USB_ROLE_DEVICE) {
  621. tegra186_xusb_padctl_vbus_override(padctl, true);
  622. } else if (submode == USB_ROLE_NONE) {
  623. /*
  624. * When port is peripheral only or role transitions to
  625. * USB_ROLE_NONE from USB_ROLE_DEVICE, regulator is not
  626. * enabled.
  627. */
  628. if (regulator_is_enabled(port->supply))
  629. regulator_disable(port->supply);
  630. tegra186_xusb_padctl_id_override(padctl, false);
  631. tegra186_xusb_padctl_vbus_override(padctl, false);
  632. }
  633. }
  634. mutex_unlock(&padctl->lock);
  635. return err;
  636. }
  637. static int tegra186_utmi_phy_power_on(struct phy *phy)
  638. {
  639. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  640. struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
  641. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  642. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  643. struct tegra_xusb_usb2_port *port;
  644. unsigned int index = lane->index;
  645. struct device *dev = padctl->dev;
  646. u32 value;
  647. port = tegra_xusb_find_usb2_port(padctl, index);
  648. if (!port) {
  649. dev_err(dev, "no port found for USB2 lane %u\n", index);
  650. return -ENODEV;
  651. }
  652. value = padctl_readl(padctl, XUSB_PADCTL_USB2_PAD_MUX);
  653. value &= ~(USB2_PORT_MASK << USB2_PORT_SHIFT(index));
  654. value |= (PORT_XUSB << USB2_PORT_SHIFT(index));
  655. padctl_writel(padctl, value, XUSB_PADCTL_USB2_PAD_MUX);
  656. value = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP);
  657. value &= ~(PORT_CAP_MASK << PORTX_CAP_SHIFT(index));
  658. if (port->mode == USB_DR_MODE_UNKNOWN)
  659. value |= (PORT_CAP_DISABLED << PORTX_CAP_SHIFT(index));
  660. else if (port->mode == USB_DR_MODE_PERIPHERAL)
  661. value |= (PORT_CAP_DEVICE << PORTX_CAP_SHIFT(index));
  662. else if (port->mode == USB_DR_MODE_HOST)
  663. value |= (PORT_CAP_HOST << PORTX_CAP_SHIFT(index));
  664. else if (port->mode == USB_DR_MODE_OTG)
  665. value |= (PORT_CAP_OTG << PORTX_CAP_SHIFT(index));
  666. padctl_writel(padctl, value, XUSB_PADCTL_USB2_PORT_CAP);
  667. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  668. value &= ~USB2_OTG_PD_ZI;
  669. value |= TERM_SEL;
  670. value &= ~HS_CURR_LEVEL(~0);
  671. if (usb2->hs_curr_level_offset) {
  672. int hs_current_level;
  673. hs_current_level = (int)priv->calib.hs_curr_level[index] +
  674. usb2->hs_curr_level_offset;
  675. if (hs_current_level < 0)
  676. hs_current_level = 0;
  677. if (hs_current_level > 0x3f)
  678. hs_current_level = 0x3f;
  679. value |= HS_CURR_LEVEL(hs_current_level);
  680. } else {
  681. value |= HS_CURR_LEVEL(priv->calib.hs_curr_level[index]);
  682. }
  683. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
  684. value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  685. value &= ~TERM_RANGE_ADJ(~0);
  686. value |= TERM_RANGE_ADJ(priv->calib.hs_term_range_adj);
  687. value &= ~RPD_CTRL(~0);
  688. value |= RPD_CTRL(priv->calib.rpd_ctrl);
  689. padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
  690. tegra186_utmi_pad_power_on(phy);
  691. return 0;
  692. }
  693. static int tegra186_utmi_phy_power_off(struct phy *phy)
  694. {
  695. tegra186_utmi_pad_power_down(phy);
  696. return 0;
  697. }
  698. static int tegra186_utmi_phy_init(struct phy *phy)
  699. {
  700. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  701. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  702. struct tegra_xusb_usb2_port *port;
  703. unsigned int index = lane->index;
  704. struct device *dev = padctl->dev;
  705. int err;
  706. port = tegra_xusb_find_usb2_port(padctl, index);
  707. if (!port) {
  708. dev_err(dev, "no port found for USB2 lane %u\n", index);
  709. return -ENODEV;
  710. }
  711. if (port->supply && port->mode == USB_DR_MODE_HOST) {
  712. err = regulator_enable(port->supply);
  713. if (err) {
  714. dev_err(dev, "failed to enable port %u VBUS: %d\n",
  715. index, err);
  716. return err;
  717. }
  718. }
  719. return 0;
  720. }
  721. static int tegra186_utmi_phy_exit(struct phy *phy)
  722. {
  723. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  724. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  725. struct tegra_xusb_usb2_port *port;
  726. unsigned int index = lane->index;
  727. struct device *dev = padctl->dev;
  728. int err;
  729. port = tegra_xusb_find_usb2_port(padctl, index);
  730. if (!port) {
  731. dev_err(dev, "no port found for USB2 lane %u\n", index);
  732. return -ENODEV;
  733. }
  734. if (port->supply && port->mode == USB_DR_MODE_HOST) {
  735. err = regulator_disable(port->supply);
  736. if (err) {
  737. dev_err(dev, "failed to disable port %u VBUS: %d\n",
  738. index, err);
  739. return err;
  740. }
  741. }
  742. return 0;
  743. }
  744. static const struct phy_ops utmi_phy_ops = {
  745. .init = tegra186_utmi_phy_init,
  746. .exit = tegra186_utmi_phy_exit,
  747. .power_on = tegra186_utmi_phy_power_on,
  748. .power_off = tegra186_utmi_phy_power_off,
  749. .set_mode = tegra186_utmi_phy_set_mode,
  750. .owner = THIS_MODULE,
  751. };
  752. static struct tegra_xusb_pad *
  753. tegra186_usb2_pad_probe(struct tegra_xusb_padctl *padctl,
  754. const struct tegra_xusb_pad_soc *soc,
  755. struct device_node *np)
  756. {
  757. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  758. struct tegra_xusb_usb2_pad *usb2;
  759. struct tegra_xusb_pad *pad;
  760. int err;
  761. usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
  762. if (!usb2)
  763. return ERR_PTR(-ENOMEM);
  764. pad = &usb2->base;
  765. pad->ops = &tegra186_usb2_lane_ops;
  766. pad->soc = soc;
  767. err = tegra_xusb_pad_init(pad, padctl, np);
  768. if (err < 0) {
  769. kfree(usb2);
  770. goto out;
  771. }
  772. priv->usb2_trk_clk = devm_clk_get(&pad->dev, "trk");
  773. if (IS_ERR(priv->usb2_trk_clk)) {
  774. err = PTR_ERR(priv->usb2_trk_clk);
  775. dev_dbg(&pad->dev, "failed to get usb2 trk clock: %d\n", err);
  776. goto unregister;
  777. }
  778. err = tegra_xusb_pad_register(pad, &utmi_phy_ops);
  779. if (err < 0)
  780. goto unregister;
  781. dev_set_drvdata(&pad->dev, pad);
  782. return pad;
  783. unregister:
  784. device_unregister(&pad->dev);
  785. out:
  786. return ERR_PTR(err);
  787. }
  788. static void tegra186_usb2_pad_remove(struct tegra_xusb_pad *pad)
  789. {
  790. struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
  791. kfree(usb2);
  792. }
  793. static const struct tegra_xusb_pad_ops tegra186_usb2_pad_ops = {
  794. .probe = tegra186_usb2_pad_probe,
  795. .remove = tegra186_usb2_pad_remove,
  796. };
  797. static const char * const tegra186_usb2_functions[] = {
  798. "xusb",
  799. };
  800. static int tegra186_usb2_port_enable(struct tegra_xusb_port *port)
  801. {
  802. return 0;
  803. }
  804. static void tegra186_usb2_port_disable(struct tegra_xusb_port *port)
  805. {
  806. }
  807. static struct tegra_xusb_lane *
  808. tegra186_usb2_port_map(struct tegra_xusb_port *port)
  809. {
  810. return tegra_xusb_find_lane(port->padctl, "usb2", port->index);
  811. }
  812. static const struct tegra_xusb_port_ops tegra186_usb2_port_ops = {
  813. .release = tegra_xusb_usb2_port_release,
  814. .remove = tegra_xusb_usb2_port_remove,
  815. .enable = tegra186_usb2_port_enable,
  816. .disable = tegra186_usb2_port_disable,
  817. .map = tegra186_usb2_port_map,
  818. };
  819. /* SuperSpeed PHY support */
  820. static struct tegra_xusb_lane *
  821. tegra186_usb3_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
  822. unsigned int index)
  823. {
  824. struct tegra_xusb_usb3_lane *usb3;
  825. int err;
  826. usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
  827. if (!usb3)
  828. return ERR_PTR(-ENOMEM);
  829. INIT_LIST_HEAD(&usb3->base.list);
  830. usb3->base.soc = &pad->soc->lanes[index];
  831. usb3->base.index = index;
  832. usb3->base.pad = pad;
  833. usb3->base.np = np;
  834. err = tegra_xusb_lane_parse_dt(&usb3->base, np);
  835. if (err < 0) {
  836. kfree(usb3);
  837. return ERR_PTR(err);
  838. }
  839. return &usb3->base;
  840. }
  841. static void tegra186_usb3_lane_remove(struct tegra_xusb_lane *lane)
  842. {
  843. struct tegra_xusb_usb3_lane *usb3 = to_usb3_lane(lane);
  844. kfree(usb3);
  845. }
  846. static int tegra186_usb3_enable_phy_sleepwalk(struct tegra_xusb_lane *lane,
  847. enum usb_device_speed speed)
  848. {
  849. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  850. unsigned int index = lane->index;
  851. u32 value;
  852. mutex_lock(&padctl->lock);
  853. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  854. value |= SSPX_ELPG_CLAMP_EN_EARLY(index);
  855. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  856. usleep_range(100, 200);
  857. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  858. value |= SSPX_ELPG_CLAMP_EN(index);
  859. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  860. usleep_range(250, 350);
  861. mutex_unlock(&padctl->lock);
  862. return 0;
  863. }
  864. static int tegra186_usb3_disable_phy_sleepwalk(struct tegra_xusb_lane *lane)
  865. {
  866. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  867. unsigned int index = lane->index;
  868. u32 value;
  869. mutex_lock(&padctl->lock);
  870. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  871. value &= ~SSPX_ELPG_CLAMP_EN_EARLY(index);
  872. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  873. usleep_range(100, 200);
  874. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  875. value &= ~SSPX_ELPG_CLAMP_EN(index);
  876. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  877. mutex_unlock(&padctl->lock);
  878. return 0;
  879. }
  880. static int tegra186_usb3_enable_phy_wake(struct tegra_xusb_lane *lane)
  881. {
  882. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  883. unsigned int index = lane->index;
  884. u32 value;
  885. mutex_lock(&padctl->lock);
  886. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  887. value &= ~ALL_WAKE_EVENTS;
  888. value |= SS_PORT_WAKEUP_EVENT(index);
  889. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  890. usleep_range(10, 20);
  891. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  892. value &= ~ALL_WAKE_EVENTS;
  893. value |= SS_PORT_WAKE_INTERRUPT_ENABLE(index);
  894. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  895. mutex_unlock(&padctl->lock);
  896. return 0;
  897. }
  898. static int tegra186_usb3_disable_phy_wake(struct tegra_xusb_lane *lane)
  899. {
  900. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  901. unsigned int index = lane->index;
  902. u32 value;
  903. mutex_lock(&padctl->lock);
  904. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  905. value &= ~ALL_WAKE_EVENTS;
  906. value &= ~SS_PORT_WAKE_INTERRUPT_ENABLE(index);
  907. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  908. usleep_range(10, 20);
  909. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  910. value &= ~ALL_WAKE_EVENTS;
  911. value |= SS_PORT_WAKEUP_EVENT(index);
  912. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
  913. mutex_unlock(&padctl->lock);
  914. return 0;
  915. }
  916. static bool tegra186_usb3_phy_remote_wake_detected(struct tegra_xusb_lane *lane)
  917. {
  918. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  919. unsigned int index = lane->index;
  920. u32 value;
  921. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
  922. if ((value & SS_PORT_WAKE_INTERRUPT_ENABLE(index)) && (value & SS_PORT_WAKEUP_EVENT(index)))
  923. return true;
  924. return false;
  925. }
  926. static const struct tegra_xusb_lane_ops tegra186_usb3_lane_ops = {
  927. .probe = tegra186_usb3_lane_probe,
  928. .remove = tegra186_usb3_lane_remove,
  929. .enable_phy_sleepwalk = tegra186_usb3_enable_phy_sleepwalk,
  930. .disable_phy_sleepwalk = tegra186_usb3_disable_phy_sleepwalk,
  931. .enable_phy_wake = tegra186_usb3_enable_phy_wake,
  932. .disable_phy_wake = tegra186_usb3_disable_phy_wake,
  933. .remote_wake_detected = tegra186_usb3_phy_remote_wake_detected,
  934. };
  935. static int tegra186_usb3_port_enable(struct tegra_xusb_port *port)
  936. {
  937. return 0;
  938. }
  939. static void tegra186_usb3_port_disable(struct tegra_xusb_port *port)
  940. {
  941. }
  942. static struct tegra_xusb_lane *
  943. tegra186_usb3_port_map(struct tegra_xusb_port *port)
  944. {
  945. return tegra_xusb_find_lane(port->padctl, "usb3", port->index);
  946. }
  947. static const struct tegra_xusb_port_ops tegra186_usb3_port_ops = {
  948. .release = tegra_xusb_usb3_port_release,
  949. .remove = tegra_xusb_usb3_port_remove,
  950. .enable = tegra186_usb3_port_enable,
  951. .disable = tegra186_usb3_port_disable,
  952. .map = tegra186_usb3_port_map,
  953. };
  954. static int tegra186_usb3_phy_power_on(struct phy *phy)
  955. {
  956. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  957. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  958. struct tegra_xusb_usb3_port *port;
  959. struct tegra_xusb_usb2_port *usb2;
  960. unsigned int index = lane->index;
  961. struct device *dev = padctl->dev;
  962. u32 value;
  963. port = tegra_xusb_find_usb3_port(padctl, index);
  964. if (!port) {
  965. dev_err(dev, "no port found for USB3 lane %u\n", index);
  966. return -ENODEV;
  967. }
  968. usb2 = tegra_xusb_find_usb2_port(padctl, port->port);
  969. if (!usb2) {
  970. dev_err(dev, "no companion port found for USB3 lane %u\n",
  971. index);
  972. return -ENODEV;
  973. }
  974. mutex_lock(&padctl->lock);
  975. value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CAP);
  976. value &= ~(PORT_CAP_MASK << PORTX_CAP_SHIFT(index));
  977. if (usb2->mode == USB_DR_MODE_UNKNOWN)
  978. value |= (PORT_CAP_DISABLED << PORTX_CAP_SHIFT(index));
  979. else if (usb2->mode == USB_DR_MODE_PERIPHERAL)
  980. value |= (PORT_CAP_DEVICE << PORTX_CAP_SHIFT(index));
  981. else if (usb2->mode == USB_DR_MODE_HOST)
  982. value |= (PORT_CAP_HOST << PORTX_CAP_SHIFT(index));
  983. else if (usb2->mode == USB_DR_MODE_OTG)
  984. value |= (PORT_CAP_OTG << PORTX_CAP_SHIFT(index));
  985. padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_CAP);
  986. if (padctl->soc->supports_gen2 && port->disable_gen2) {
  987. value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CFG);
  988. value &= ~(PORTX_SPEED_SUPPORT_MASK <<
  989. PORTX_SPEED_SUPPORT_SHIFT(index));
  990. value |= (PORT_SPEED_SUPPORT_GEN1 <<
  991. PORTX_SPEED_SUPPORT_SHIFT(index));
  992. padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_CFG);
  993. }
  994. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  995. value &= ~SSPX_ELPG_VCORE_DOWN(index);
  996. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  997. usleep_range(100, 200);
  998. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  999. value &= ~SSPX_ELPG_CLAMP_EN_EARLY(index);
  1000. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  1001. usleep_range(100, 200);
  1002. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  1003. value &= ~SSPX_ELPG_CLAMP_EN(index);
  1004. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  1005. mutex_unlock(&padctl->lock);
  1006. return 0;
  1007. }
  1008. static int tegra186_usb3_phy_power_off(struct phy *phy)
  1009. {
  1010. struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
  1011. struct tegra_xusb_padctl *padctl = lane->pad->padctl;
  1012. struct tegra_xusb_usb3_port *port;
  1013. unsigned int index = lane->index;
  1014. struct device *dev = padctl->dev;
  1015. u32 value;
  1016. port = tegra_xusb_find_usb3_port(padctl, index);
  1017. if (!port) {
  1018. dev_err(dev, "no port found for USB3 lane %u\n", index);
  1019. return -ENODEV;
  1020. }
  1021. mutex_lock(&padctl->lock);
  1022. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  1023. value |= SSPX_ELPG_CLAMP_EN_EARLY(index);
  1024. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  1025. usleep_range(100, 200);
  1026. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  1027. value |= SSPX_ELPG_CLAMP_EN(index);
  1028. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  1029. usleep_range(250, 350);
  1030. value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
  1031. value |= SSPX_ELPG_VCORE_DOWN(index);
  1032. padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
  1033. mutex_unlock(&padctl->lock);
  1034. return 0;
  1035. }
  1036. static int tegra186_usb3_phy_init(struct phy *phy)
  1037. {
  1038. return 0;
  1039. }
  1040. static int tegra186_usb3_phy_exit(struct phy *phy)
  1041. {
  1042. return 0;
  1043. }
  1044. static const struct phy_ops usb3_phy_ops = {
  1045. .init = tegra186_usb3_phy_init,
  1046. .exit = tegra186_usb3_phy_exit,
  1047. .power_on = tegra186_usb3_phy_power_on,
  1048. .power_off = tegra186_usb3_phy_power_off,
  1049. .owner = THIS_MODULE,
  1050. };
  1051. static struct tegra_xusb_pad *
  1052. tegra186_usb3_pad_probe(struct tegra_xusb_padctl *padctl,
  1053. const struct tegra_xusb_pad_soc *soc,
  1054. struct device_node *np)
  1055. {
  1056. struct tegra_xusb_usb3_pad *usb3;
  1057. struct tegra_xusb_pad *pad;
  1058. int err;
  1059. usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
  1060. if (!usb3)
  1061. return ERR_PTR(-ENOMEM);
  1062. pad = &usb3->base;
  1063. pad->ops = &tegra186_usb3_lane_ops;
  1064. pad->soc = soc;
  1065. err = tegra_xusb_pad_init(pad, padctl, np);
  1066. if (err < 0) {
  1067. kfree(usb3);
  1068. goto out;
  1069. }
  1070. err = tegra_xusb_pad_register(pad, &usb3_phy_ops);
  1071. if (err < 0)
  1072. goto unregister;
  1073. dev_set_drvdata(&pad->dev, pad);
  1074. return pad;
  1075. unregister:
  1076. device_unregister(&pad->dev);
  1077. out:
  1078. return ERR_PTR(err);
  1079. }
  1080. static void tegra186_usb3_pad_remove(struct tegra_xusb_pad *pad)
  1081. {
  1082. struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
  1083. kfree(usb2);
  1084. }
  1085. static const struct tegra_xusb_pad_ops tegra186_usb3_pad_ops = {
  1086. .probe = tegra186_usb3_pad_probe,
  1087. .remove = tegra186_usb3_pad_remove,
  1088. };
  1089. static const char * const tegra186_usb3_functions[] = {
  1090. "xusb",
  1091. };
  1092. static int
  1093. tegra186_xusb_read_fuse_calibration(struct tegra186_xusb_padctl *padctl)
  1094. {
  1095. struct device *dev = padctl->base.dev;
  1096. unsigned int i, count;
  1097. u32 value, *level;
  1098. int err;
  1099. count = padctl->base.soc->ports.usb2.count;
  1100. level = devm_kcalloc(dev, count, sizeof(u32), GFP_KERNEL);
  1101. if (!level)
  1102. return -ENOMEM;
  1103. err = tegra_fuse_readl(TEGRA_FUSE_SKU_CALIB_0, &value);
  1104. if (err)
  1105. return dev_err_probe(dev, err,
  1106. "failed to read calibration fuse\n");
  1107. dev_dbg(dev, "FUSE_USB_CALIB_0 %#x\n", value);
  1108. for (i = 0; i < count; i++)
  1109. level[i] = (value >> HS_CURR_LEVEL_PADX_SHIFT(i)) &
  1110. HS_CURR_LEVEL_PAD_MASK;
  1111. padctl->calib.hs_curr_level = level;
  1112. padctl->calib.hs_squelch = (value >> HS_SQUELCH_SHIFT) &
  1113. HS_SQUELCH_MASK;
  1114. padctl->calib.hs_term_range_adj = (value >> HS_TERM_RANGE_ADJ_SHIFT) &
  1115. HS_TERM_RANGE_ADJ_MASK;
  1116. err = tegra_fuse_readl(TEGRA_FUSE_USB_CALIB_EXT_0, &value);
  1117. if (err) {
  1118. dev_err(dev, "failed to read calibration fuse: %d\n", err);
  1119. return err;
  1120. }
  1121. dev_dbg(dev, "FUSE_USB_CALIB_EXT_0 %#x\n", value);
  1122. padctl->calib.rpd_ctrl = (value >> RPD_CTRL_SHIFT) & RPD_CTRL_MASK;
  1123. return 0;
  1124. }
  1125. static struct tegra_xusb_padctl *
  1126. tegra186_xusb_padctl_probe(struct device *dev,
  1127. const struct tegra_xusb_padctl_soc *soc)
  1128. {
  1129. struct platform_device *pdev = to_platform_device(dev);
  1130. struct tegra186_xusb_padctl *priv;
  1131. struct resource *res;
  1132. int err;
  1133. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  1134. if (!priv)
  1135. return ERR_PTR(-ENOMEM);
  1136. priv->base.dev = dev;
  1137. priv->base.soc = soc;
  1138. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ao");
  1139. priv->ao_regs = devm_ioremap_resource(dev, res);
  1140. if (IS_ERR(priv->ao_regs))
  1141. return ERR_CAST(priv->ao_regs);
  1142. err = tegra186_xusb_read_fuse_calibration(priv);
  1143. if (err < 0)
  1144. return ERR_PTR(err);
  1145. return &priv->base;
  1146. }
  1147. static void tegra186_xusb_padctl_save(struct tegra_xusb_padctl *padctl)
  1148. {
  1149. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  1150. priv->context.vbus_id = padctl_readl(padctl, USB2_VBUS_ID);
  1151. priv->context.usb2_pad_mux = padctl_readl(padctl, XUSB_PADCTL_USB2_PAD_MUX);
  1152. priv->context.usb2_port_cap = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP);
  1153. priv->context.ss_port_cap = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CAP);
  1154. }
  1155. static void tegra186_xusb_padctl_restore(struct tegra_xusb_padctl *padctl)
  1156. {
  1157. struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
  1158. padctl_writel(padctl, priv->context.usb2_pad_mux, XUSB_PADCTL_USB2_PAD_MUX);
  1159. padctl_writel(padctl, priv->context.usb2_port_cap, XUSB_PADCTL_USB2_PORT_CAP);
  1160. padctl_writel(padctl, priv->context.ss_port_cap, XUSB_PADCTL_SS_PORT_CAP);
  1161. padctl_writel(padctl, priv->context.vbus_id, USB2_VBUS_ID);
  1162. }
  1163. static int tegra186_xusb_padctl_suspend_noirq(struct tegra_xusb_padctl *padctl)
  1164. {
  1165. tegra186_xusb_padctl_save(padctl);
  1166. return 0;
  1167. }
  1168. static int tegra186_xusb_padctl_resume_noirq(struct tegra_xusb_padctl *padctl)
  1169. {
  1170. tegra186_xusb_padctl_restore(padctl);
  1171. return 0;
  1172. }
  1173. static void tegra186_xusb_padctl_remove(struct tegra_xusb_padctl *padctl)
  1174. {
  1175. }
  1176. static const struct tegra_xusb_padctl_ops tegra186_xusb_padctl_ops = {
  1177. .probe = tegra186_xusb_padctl_probe,
  1178. .remove = tegra186_xusb_padctl_remove,
  1179. .suspend_noirq = tegra186_xusb_padctl_suspend_noirq,
  1180. .resume_noirq = tegra186_xusb_padctl_resume_noirq,
  1181. .vbus_override = tegra186_xusb_padctl_vbus_override,
  1182. .utmi_pad_power_on = tegra186_utmi_pad_power_on,
  1183. .utmi_pad_power_down = tegra186_utmi_pad_power_down,
  1184. };
  1185. #if IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC)
  1186. static const char * const tegra186_xusb_padctl_supply_names[] = {
  1187. "avdd-pll-erefeut",
  1188. "avdd-usb",
  1189. "vclamp-usb",
  1190. "vddio-hsic",
  1191. };
  1192. static const struct tegra_xusb_lane_soc tegra186_usb2_lanes[] = {
  1193. TEGRA186_LANE("usb2-0", 0, 0, 0, usb2),
  1194. TEGRA186_LANE("usb2-1", 0, 0, 0, usb2),
  1195. TEGRA186_LANE("usb2-2", 0, 0, 0, usb2),
  1196. };
  1197. static const struct tegra_xusb_pad_soc tegra186_usb2_pad = {
  1198. .name = "usb2",
  1199. .num_lanes = ARRAY_SIZE(tegra186_usb2_lanes),
  1200. .lanes = tegra186_usb2_lanes,
  1201. .ops = &tegra186_usb2_pad_ops,
  1202. };
  1203. static const struct tegra_xusb_lane_soc tegra186_usb3_lanes[] = {
  1204. TEGRA186_LANE("usb3-0", 0, 0, 0, usb3),
  1205. TEGRA186_LANE("usb3-1", 0, 0, 0, usb3),
  1206. TEGRA186_LANE("usb3-2", 0, 0, 0, usb3),
  1207. };
  1208. static const struct tegra_xusb_pad_soc tegra186_usb3_pad = {
  1209. .name = "usb3",
  1210. .num_lanes = ARRAY_SIZE(tegra186_usb3_lanes),
  1211. .lanes = tegra186_usb3_lanes,
  1212. .ops = &tegra186_usb3_pad_ops,
  1213. };
  1214. static const struct tegra_xusb_pad_soc * const tegra186_pads[] = {
  1215. &tegra186_usb2_pad,
  1216. &tegra186_usb3_pad,
  1217. #if 0 /* TODO implement */
  1218. &tegra186_hsic_pad,
  1219. #endif
  1220. };
  1221. const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc = {
  1222. .num_pads = ARRAY_SIZE(tegra186_pads),
  1223. .pads = tegra186_pads,
  1224. .ports = {
  1225. .usb2 = {
  1226. .ops = &tegra186_usb2_port_ops,
  1227. .count = 3,
  1228. },
  1229. #if 0 /* TODO implement */
  1230. .hsic = {
  1231. .ops = &tegra186_hsic_port_ops,
  1232. .count = 1,
  1233. },
  1234. #endif
  1235. .usb3 = {
  1236. .ops = &tegra186_usb3_port_ops,
  1237. .count = 3,
  1238. },
  1239. },
  1240. .ops = &tegra186_xusb_padctl_ops,
  1241. .supply_names = tegra186_xusb_padctl_supply_names,
  1242. .num_supplies = ARRAY_SIZE(tegra186_xusb_padctl_supply_names),
  1243. };
  1244. EXPORT_SYMBOL_GPL(tegra186_xusb_padctl_soc);
  1245. #endif
  1246. #if IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC)
  1247. static const char * const tegra194_xusb_padctl_supply_names[] = {
  1248. "avdd-usb",
  1249. "vclamp-usb",
  1250. };
  1251. static const struct tegra_xusb_lane_soc tegra194_usb2_lanes[] = {
  1252. TEGRA186_LANE("usb2-0", 0, 0, 0, usb2),
  1253. TEGRA186_LANE("usb2-1", 0, 0, 0, usb2),
  1254. TEGRA186_LANE("usb2-2", 0, 0, 0, usb2),
  1255. TEGRA186_LANE("usb2-3", 0, 0, 0, usb2),
  1256. };
  1257. static const struct tegra_xusb_pad_soc tegra194_usb2_pad = {
  1258. .name = "usb2",
  1259. .num_lanes = ARRAY_SIZE(tegra194_usb2_lanes),
  1260. .lanes = tegra194_usb2_lanes,
  1261. .ops = &tegra186_usb2_pad_ops,
  1262. };
  1263. static const struct tegra_xusb_lane_soc tegra194_usb3_lanes[] = {
  1264. TEGRA186_LANE("usb3-0", 0, 0, 0, usb3),
  1265. TEGRA186_LANE("usb3-1", 0, 0, 0, usb3),
  1266. TEGRA186_LANE("usb3-2", 0, 0, 0, usb3),
  1267. TEGRA186_LANE("usb3-3", 0, 0, 0, usb3),
  1268. };
  1269. static const struct tegra_xusb_pad_soc tegra194_usb3_pad = {
  1270. .name = "usb3",
  1271. .num_lanes = ARRAY_SIZE(tegra194_usb3_lanes),
  1272. .lanes = tegra194_usb3_lanes,
  1273. .ops = &tegra186_usb3_pad_ops,
  1274. };
  1275. static const struct tegra_xusb_pad_soc * const tegra194_pads[] = {
  1276. &tegra194_usb2_pad,
  1277. &tegra194_usb3_pad,
  1278. };
  1279. const struct tegra_xusb_padctl_soc tegra194_xusb_padctl_soc = {
  1280. .num_pads = ARRAY_SIZE(tegra194_pads),
  1281. .pads = tegra194_pads,
  1282. .ports = {
  1283. .usb2 = {
  1284. .ops = &tegra186_usb2_port_ops,
  1285. .count = 4,
  1286. },
  1287. .usb3 = {
  1288. .ops = &tegra186_usb3_port_ops,
  1289. .count = 4,
  1290. },
  1291. },
  1292. .ops = &tegra186_xusb_padctl_ops,
  1293. .supply_names = tegra194_xusb_padctl_supply_names,
  1294. .num_supplies = ARRAY_SIZE(tegra194_xusb_padctl_supply_names),
  1295. .supports_gen2 = true,
  1296. };
  1297. EXPORT_SYMBOL_GPL(tegra194_xusb_padctl_soc);
  1298. #endif
  1299. MODULE_AUTHOR("JC Kuo <[email protected]>");
  1300. MODULE_DESCRIPTION("NVIDIA Tegra186 XUSB Pad Controller driver");
  1301. MODULE_LICENSE("GPL v2");