Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2016-2020, NVIDIA CORPORATION.  All rights reserved.
0004  */
0005 
0006 #include <linux/delay.h>
0007 #include <linux/io.h>
0008 #include <linux/module.h>
0009 #include <linux/of.h>
0010 #include <linux/phy/phy.h>
0011 #include <linux/regulator/consumer.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/clk.h>
0014 #include <linux/slab.h>
0015 
0016 #include <soc/tegra/fuse.h>
0017 
0018 #include "xusb.h"
0019 
0020 /* FUSE USB_CALIB registers */
0021 #define HS_CURR_LEVEL_PADX_SHIFT(x) ((x) ? (11 + (x - 1) * 6) : 0)
0022 #define HS_CURR_LEVEL_PAD_MASK      0x3f
0023 #define HS_TERM_RANGE_ADJ_SHIFT     7
0024 #define HS_TERM_RANGE_ADJ_MASK      0xf
0025 #define HS_SQUELCH_SHIFT        29
0026 #define HS_SQUELCH_MASK         0x7
0027 
0028 #define RPD_CTRL_SHIFT          0
0029 #define RPD_CTRL_MASK           0x1f
0030 
0031 /* XUSB PADCTL registers */
0032 #define XUSB_PADCTL_USB2_PAD_MUX    0x4
0033 #define  USB2_PORT_SHIFT(x)     ((x) * 2)
0034 #define  USB2_PORT_MASK         0x3
0035 #define   PORT_XUSB         1
0036 #define  HSIC_PORT_SHIFT(x)     ((x) + 20)
0037 #define  HSIC_PORT_MASK         0x1
0038 #define   PORT_HSIC         0
0039 
0040 #define XUSB_PADCTL_USB2_PORT_CAP   0x8
0041 #define XUSB_PADCTL_SS_PORT_CAP     0xc
0042 #define  PORTX_CAP_SHIFT(x)     ((x) * 4)
0043 #define  PORT_CAP_MASK          0x3
0044 #define   PORT_CAP_DISABLED     0x0
0045 #define   PORT_CAP_HOST         0x1
0046 #define   PORT_CAP_DEVICE       0x2
0047 #define   PORT_CAP_OTG          0x3
0048 
0049 #define XUSB_PADCTL_ELPG_PROGRAM        0x20
0050 #define  USB2_PORT_WAKE_INTERRUPT_ENABLE(x)     BIT(x)
0051 #define  USB2_PORT_WAKEUP_EVENT(x)          BIT((x) +  7)
0052 #define  SS_PORT_WAKE_INTERRUPT_ENABLE(x)       BIT((x) + 14)
0053 #define  SS_PORT_WAKEUP_EVENT(x)            BIT((x) + 21)
0054 #define  USB2_HSIC_PORT_WAKE_INTERRUPT_ENABLE(x)    BIT((x) + 28)
0055 #define  USB2_HSIC_PORT_WAKEUP_EVENT(x)         BIT((x) + 30)
0056 #define  ALL_WAKE_EVENTS                        \
0057     (USB2_PORT_WAKEUP_EVENT(0) | USB2_PORT_WAKEUP_EVENT(1) |    \
0058     USB2_PORT_WAKEUP_EVENT(2) | SS_PORT_WAKEUP_EVENT(0) |       \
0059     SS_PORT_WAKEUP_EVENT(1) | SS_PORT_WAKEUP_EVENT(2) |     \
0060     USB2_HSIC_PORT_WAKEUP_EVENT(0))
0061 
0062 #define XUSB_PADCTL_ELPG_PROGRAM_1      0x24
0063 #define  SSPX_ELPG_CLAMP_EN(x)          BIT(0 + (x) * 3)
0064 #define  SSPX_ELPG_CLAMP_EN_EARLY(x)        BIT(1 + (x) * 3)
0065 #define  SSPX_ELPG_VCORE_DOWN(x)        BIT(2 + (x) * 3)
0066 #define XUSB_PADCTL_SS_PORT_CFG         0x2c
0067 #define   PORTX_SPEED_SUPPORT_SHIFT(x)      ((x) * 4)
0068 #define   PORTX_SPEED_SUPPORT_MASK      (0x3)
0069 #define     PORT_SPEED_SUPPORT_GEN1     (0x0)
0070 
0071 #define XUSB_PADCTL_USB2_OTG_PADX_CTL0(x)   (0x88 + (x) * 0x40)
0072 #define  HS_CURR_LEVEL(x)           ((x) & 0x3f)
0073 #define  TERM_SEL               BIT(25)
0074 #define  USB2_OTG_PD                BIT(26)
0075 #define  USB2_OTG_PD2               BIT(27)
0076 #define  USB2_OTG_PD2_OVRD_EN           BIT(28)
0077 #define  USB2_OTG_PD_ZI             BIT(29)
0078 
0079 #define XUSB_PADCTL_USB2_OTG_PADX_CTL1(x)   (0x8c + (x) * 0x40)
0080 #define  USB2_OTG_PD_DR             BIT(2)
0081 #define  TERM_RANGE_ADJ(x)          (((x) & 0xf) << 3)
0082 #define  RPD_CTRL(x)                (((x) & 0x1f) << 26)
0083 
0084 #define XUSB_PADCTL_USB2_BIAS_PAD_CTL0      0x284
0085 #define  BIAS_PAD_PD                BIT(11)
0086 #define  HS_SQUELCH_LEVEL(x)            (((x) & 0x7) << 0)
0087 
0088 #define XUSB_PADCTL_USB2_BIAS_PAD_CTL1      0x288
0089 #define  USB2_TRK_START_TIMER(x)        (((x) & 0x7f) << 12)
0090 #define  USB2_TRK_DONE_RESET_TIMER(x)       (((x) & 0x7f) << 19)
0091 #define  USB2_PD_TRK                BIT(26)
0092 
0093 #define XUSB_PADCTL_HSIC_PADX_CTL0(x)       (0x300 + (x) * 0x20)
0094 #define  HSIC_PD_TX_DATA0           BIT(1)
0095 #define  HSIC_PD_TX_STROBE          BIT(3)
0096 #define  HSIC_PD_RX_DATA0           BIT(4)
0097 #define  HSIC_PD_RX_STROBE          BIT(6)
0098 #define  HSIC_PD_ZI_DATA0           BIT(7)
0099 #define  HSIC_PD_ZI_STROBE          BIT(9)
0100 #define  HSIC_RPD_DATA0             BIT(13)
0101 #define  HSIC_RPD_STROBE            BIT(15)
0102 #define  HSIC_RPU_DATA0             BIT(16)
0103 #define  HSIC_RPU_STROBE            BIT(18)
0104 
0105 #define XUSB_PADCTL_HSIC_PAD_TRK_CTL0       0x340
0106 #define  HSIC_TRK_START_TIMER(x)        (((x) & 0x7f) << 5)
0107 #define  HSIC_TRK_DONE_RESET_TIMER(x)       (((x) & 0x7f) << 12)
0108 #define  HSIC_PD_TRK                BIT(19)
0109 
0110 #define USB2_VBUS_ID                0x360
0111 #define  VBUS_OVERRIDE              BIT(14)
0112 #define  ID_OVERRIDE(x)             (((x) & 0xf) << 18)
0113 #define  ID_OVERRIDE_FLOATING           ID_OVERRIDE(8)
0114 #define  ID_OVERRIDE_GROUNDED           ID_OVERRIDE(0)
0115 
0116 /* XUSB AO registers */
0117 #define XUSB_AO_USB_DEBOUNCE_DEL        (0x4)
0118 #define   UHSIC_LINE_DEB_CNT(x)         (((x) & 0xf) << 4)
0119 #define   UTMIP_LINE_DEB_CNT(x)         ((x) & 0xf)
0120 
0121 #define XUSB_AO_UTMIP_TRIGGERS(x)       (0x40 + (x) * 4)
0122 #define   CLR_WALK_PTR              BIT(0)
0123 #define   CAP_CFG               BIT(1)
0124 #define   CLR_WAKE_ALARM            BIT(3)
0125 
0126 #define XUSB_AO_UHSIC_TRIGGERS(x)       (0x60 + (x) * 4)
0127 #define   HSIC_CLR_WALK_PTR         BIT(0)
0128 #define   HSIC_CLR_WAKE_ALARM           BIT(3)
0129 #define   HSIC_CAP_CFG              BIT(4)
0130 
0131 #define XUSB_AO_UTMIP_SAVED_STATE(x)        (0x70 + (x) * 4)
0132 #define   SPEED(x)              ((x) & 0x3)
0133 #define     UTMI_HS             SPEED(0)
0134 #define     UTMI_FS             SPEED(1)
0135 #define     UTMI_LS             SPEED(2)
0136 #define     UTMI_RST                SPEED(3)
0137 
0138 #define XUSB_AO_UHSIC_SAVED_STATE(x)        (0x90 + (x) * 4)
0139 #define   MODE(x)               ((x) & 0x1)
0140 #define   MODE_HS               MODE(0)
0141 #define   MODE_RST              MODE(1)
0142 
0143 #define XUSB_AO_UTMIP_SLEEPWALK_CFG(x)      (0xd0 + (x) * 4)
0144 #define XUSB_AO_UHSIC_SLEEPWALK_CFG(x)      (0xf0 + (x) * 4)
0145 #define   FAKE_USBOP_VAL            BIT(0)
0146 #define   FAKE_USBON_VAL            BIT(1)
0147 #define   FAKE_USBOP_EN             BIT(2)
0148 #define   FAKE_USBON_EN             BIT(3)
0149 #define   FAKE_STROBE_VAL           BIT(0)
0150 #define   FAKE_DATA_VAL             BIT(1)
0151 #define   FAKE_STROBE_EN            BIT(2)
0152 #define   FAKE_DATA_EN              BIT(3)
0153 #define   WAKE_WALK_EN              BIT(14)
0154 #define   MASTER_ENABLE             BIT(15)
0155 #define   LINEVAL_WALK_EN           BIT(16)
0156 #define   WAKE_VAL(x)               (((x) & 0xf) << 17)
0157 #define     WAKE_VAL_NONE           WAKE_VAL(12)
0158 #define     WAKE_VAL_ANY            WAKE_VAL(15)
0159 #define     WAKE_VAL_DS10           WAKE_VAL(2)
0160 #define   LINE_WAKEUP_EN            BIT(21)
0161 #define   MASTER_CFG_SEL            BIT(22)
0162 
0163 #define XUSB_AO_UTMIP_SLEEPWALK(x)      (0x100 + (x) * 4)
0164 /* phase A */
0165 #define   USBOP_RPD_A               BIT(0)
0166 #define   USBON_RPD_A               BIT(1)
0167 #define   AP_A                  BIT(4)
0168 #define   AN_A                  BIT(5)
0169 #define   HIGHZ_A               BIT(6)
0170 /* phase B */
0171 #define   USBOP_RPD_B               BIT(8)
0172 #define   USBON_RPD_B               BIT(9)
0173 #define   AP_B                  BIT(12)
0174 #define   AN_B                  BIT(13)
0175 #define   HIGHZ_B               BIT(14)
0176 /* phase C */
0177 #define   USBOP_RPD_C               BIT(16)
0178 #define   USBON_RPD_C               BIT(17)
0179 #define   AP_C                  BIT(20)
0180 #define   AN_C                  BIT(21)
0181 #define   HIGHZ_C               BIT(22)
0182 /* phase D */
0183 #define   USBOP_RPD_D               BIT(24)
0184 #define   USBON_RPD_D               BIT(25)
0185 #define   AP_D                  BIT(28)
0186 #define   AN_D                  BIT(29)
0187 #define   HIGHZ_D               BIT(30)
0188 
0189 #define XUSB_AO_UHSIC_SLEEPWALK(x)      (0x120 + (x) * 4)
0190 /* phase A */
0191 #define   RPD_STROBE_A              BIT(0)
0192 #define   RPD_DATA0_A               BIT(1)
0193 #define   RPU_STROBE_A              BIT(2)
0194 #define   RPU_DATA0_A               BIT(3)
0195 /* phase B */
0196 #define   RPD_STROBE_B              BIT(8)
0197 #define   RPD_DATA0_B               BIT(9)
0198 #define   RPU_STROBE_B              BIT(10)
0199 #define   RPU_DATA0_B               BIT(11)
0200 /* phase C */
0201 #define   RPD_STROBE_C              BIT(16)
0202 #define   RPD_DATA0_C               BIT(17)
0203 #define   RPU_STROBE_C              BIT(18)
0204 #define   RPU_DATA0_C               BIT(19)
0205 /* phase D */
0206 #define   RPD_STROBE_D              BIT(24)
0207 #define   RPD_DATA0_D               BIT(25)
0208 #define   RPU_STROBE_D              BIT(26)
0209 #define   RPU_DATA0_D               BIT(27)
0210 
0211 #define XUSB_AO_UTMIP_PAD_CFG(x)        (0x130 + (x) * 4)
0212 #define   FSLS_USE_XUSB_AO          BIT(3)
0213 #define   TRK_CTRL_USE_XUSB_AO          BIT(4)
0214 #define   RPD_CTRL_USE_XUSB_AO          BIT(5)
0215 #define   RPU_USE_XUSB_AO           BIT(6)
0216 #define   VREG_USE_XUSB_AO          BIT(7)
0217 #define   USBOP_VAL_PD              BIT(8)
0218 #define   USBON_VAL_PD              BIT(9)
0219 #define   E_DPD_OVRD_EN             BIT(10)
0220 #define   E_DPD_OVRD_VAL            BIT(11)
0221 
0222 #define XUSB_AO_UHSIC_PAD_CFG(x)        (0x150 + (x) * 4)
0223 #define   STROBE_VAL_PD             BIT(0)
0224 #define   DATA0_VAL_PD              BIT(1)
0225 #define   USE_XUSB_AO               BIT(4)
0226 
0227 #define TEGRA186_LANE(_name, _offset, _shift, _mask, _type)     \
0228     {                               \
0229         .name = _name,                      \
0230         .offset = _offset,                  \
0231         .shift = _shift,                    \
0232         .mask = _mask,                      \
0233         .num_funcs = ARRAY_SIZE(tegra186_##_type##_functions),  \
0234         .funcs = tegra186_##_type##_functions,          \
0235     }
0236 
0237 struct tegra_xusb_fuse_calibration {
0238     u32 *hs_curr_level;
0239     u32 hs_squelch;
0240     u32 hs_term_range_adj;
0241     u32 rpd_ctrl;
0242 };
0243 
0244 struct tegra186_xusb_padctl_context {
0245     u32 vbus_id;
0246     u32 usb2_pad_mux;
0247     u32 usb2_port_cap;
0248     u32 ss_port_cap;
0249 };
0250 
0251 struct tegra186_xusb_padctl {
0252     struct tegra_xusb_padctl base;
0253     void __iomem *ao_regs;
0254 
0255     struct tegra_xusb_fuse_calibration calib;
0256 
0257     /* UTMI bias and tracking */
0258     struct clk *usb2_trk_clk;
0259     unsigned int bias_pad_enable;
0260 
0261     /* padctl context */
0262     struct tegra186_xusb_padctl_context context;
0263 };
0264 
0265 static inline void ao_writel(struct tegra186_xusb_padctl *priv, u32 value, unsigned int offset)
0266 {
0267     writel(value, priv->ao_regs + offset);
0268 }
0269 
0270 static inline u32 ao_readl(struct tegra186_xusb_padctl *priv, unsigned int offset)
0271 {
0272     return readl(priv->ao_regs + offset);
0273 }
0274 
0275 static inline struct tegra186_xusb_padctl *
0276 to_tegra186_xusb_padctl(struct tegra_xusb_padctl *padctl)
0277 {
0278     return container_of(padctl, struct tegra186_xusb_padctl, base);
0279 }
0280 
0281 /* USB 2.0 UTMI PHY support */
0282 static struct tegra_xusb_lane *
0283 tegra186_usb2_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
0284              unsigned int index)
0285 {
0286     struct tegra_xusb_usb2_lane *usb2;
0287     int err;
0288 
0289     usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
0290     if (!usb2)
0291         return ERR_PTR(-ENOMEM);
0292 
0293     INIT_LIST_HEAD(&usb2->base.list);
0294     usb2->base.soc = &pad->soc->lanes[index];
0295     usb2->base.index = index;
0296     usb2->base.pad = pad;
0297     usb2->base.np = np;
0298 
0299     err = tegra_xusb_lane_parse_dt(&usb2->base, np);
0300     if (err < 0) {
0301         kfree(usb2);
0302         return ERR_PTR(err);
0303     }
0304 
0305     return &usb2->base;
0306 }
0307 
0308 static void tegra186_usb2_lane_remove(struct tegra_xusb_lane *lane)
0309 {
0310     struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
0311 
0312     kfree(usb2);
0313 }
0314 
0315 static int tegra186_utmi_enable_phy_sleepwalk(struct tegra_xusb_lane *lane,
0316                           enum usb_device_speed speed)
0317 {
0318     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0319     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
0320     unsigned int index = lane->index;
0321     u32 value;
0322 
0323     mutex_lock(&padctl->lock);
0324 
0325     /* ensure sleepwalk logic is disabled */
0326     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0327     value &= ~MASTER_ENABLE;
0328     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0329 
0330     /* ensure sleepwalk logics are in low power mode */
0331     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0332     value |= MASTER_CFG_SEL;
0333     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0334 
0335     /* set debounce time */
0336     value = ao_readl(priv, XUSB_AO_USB_DEBOUNCE_DEL);
0337     value &= ~UTMIP_LINE_DEB_CNT(~0);
0338     value |= UTMIP_LINE_DEB_CNT(1);
0339     ao_writel(priv, value, XUSB_AO_USB_DEBOUNCE_DEL);
0340 
0341     /* ensure fake events of sleepwalk logic are desiabled */
0342     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0343     value &= ~(FAKE_USBOP_VAL | FAKE_USBON_VAL |
0344         FAKE_USBOP_EN | FAKE_USBON_EN);
0345     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0346 
0347     /* ensure wake events of sleepwalk logic are not latched */
0348     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0349     value &= ~LINE_WAKEUP_EN;
0350     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0351 
0352     /* disable wake event triggers of sleepwalk logic */
0353     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0354     value &= ~WAKE_VAL(~0);
0355     value |= WAKE_VAL_NONE;
0356     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0357 
0358     /* power down the line state detectors of the pad */
0359     value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
0360     value |= (USBOP_VAL_PD | USBON_VAL_PD);
0361     ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
0362 
0363     /* save state per speed */
0364     value = ao_readl(priv, XUSB_AO_UTMIP_SAVED_STATE(index));
0365     value &= ~SPEED(~0);
0366 
0367     switch (speed) {
0368     case USB_SPEED_HIGH:
0369         value |= UTMI_HS;
0370         break;
0371 
0372     case USB_SPEED_FULL:
0373         value |= UTMI_FS;
0374         break;
0375 
0376     case USB_SPEED_LOW:
0377         value |= UTMI_LS;
0378         break;
0379 
0380     default:
0381         value |= UTMI_RST;
0382         break;
0383     }
0384 
0385     ao_writel(priv, value, XUSB_AO_UTMIP_SAVED_STATE(index));
0386 
0387     /* enable the trigger of the sleepwalk logic */
0388     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0389     value |= LINEVAL_WALK_EN;
0390     value &= ~WAKE_WALK_EN;
0391     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0392 
0393     /* reset the walk pointer and clear the alarm of the sleepwalk logic,
0394      * as well as capture the configuration of the USB2.0 pad
0395      */
0396     value = ao_readl(priv, XUSB_AO_UTMIP_TRIGGERS(index));
0397     value |= (CLR_WALK_PTR | CLR_WAKE_ALARM | CAP_CFG);
0398     ao_writel(priv, value, XUSB_AO_UTMIP_TRIGGERS(index));
0399 
0400     /* setup the pull-ups and pull-downs of the signals during the four
0401      * stages of sleepwalk.
0402      * if device is connected, program sleepwalk logic to maintain a J and
0403      * keep driving K upon seeing remote wake.
0404      */
0405     value = USBOP_RPD_A | USBOP_RPD_B | USBOP_RPD_C | USBOP_RPD_D;
0406     value |= USBON_RPD_A | USBON_RPD_B | USBON_RPD_C | USBON_RPD_D;
0407 
0408     switch (speed) {
0409     case USB_SPEED_HIGH:
0410     case USB_SPEED_FULL:
0411         /* J state: D+/D- = high/low, K state: D+/D- = low/high */
0412         value |= HIGHZ_A;
0413         value |= AP_A;
0414         value |= AN_B | AN_C | AN_D;
0415         break;
0416 
0417     case USB_SPEED_LOW:
0418         /* J state: D+/D- = low/high, K state: D+/D- = high/low */
0419         value |= HIGHZ_A;
0420         value |= AN_A;
0421         value |= AP_B | AP_C | AP_D;
0422         break;
0423 
0424     default:
0425         value |= HIGHZ_A | HIGHZ_B | HIGHZ_C | HIGHZ_D;
0426         break;
0427     }
0428 
0429     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK(index));
0430 
0431     /* power up the line state detectors of the pad */
0432     value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
0433     value &= ~(USBOP_VAL_PD | USBON_VAL_PD);
0434     ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
0435 
0436     usleep_range(150, 200);
0437 
0438     /* switch the electric control of the USB2.0 pad to XUSB_AO */
0439     value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
0440     value |= FSLS_USE_XUSB_AO | TRK_CTRL_USE_XUSB_AO | RPD_CTRL_USE_XUSB_AO |
0441          RPU_USE_XUSB_AO | VREG_USE_XUSB_AO;
0442     ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
0443 
0444     /* set the wake signaling trigger events */
0445     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0446     value &= ~WAKE_VAL(~0);
0447     value |= WAKE_VAL_ANY;
0448     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0449 
0450     /* enable the wake detection */
0451     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0452     value |= MASTER_ENABLE | LINE_WAKEUP_EN;
0453     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0454 
0455     mutex_unlock(&padctl->lock);
0456 
0457     return 0;
0458 }
0459 
0460 static int tegra186_utmi_disable_phy_sleepwalk(struct tegra_xusb_lane *lane)
0461 {
0462     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0463     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
0464     unsigned int index = lane->index;
0465     u32 value;
0466 
0467     mutex_lock(&padctl->lock);
0468 
0469     /* disable the wake detection */
0470     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0471     value &= ~(MASTER_ENABLE | LINE_WAKEUP_EN);
0472     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0473 
0474     /* switch the electric control of the USB2.0 pad to XUSB vcore logic */
0475     value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
0476     value &= ~(FSLS_USE_XUSB_AO | TRK_CTRL_USE_XUSB_AO | RPD_CTRL_USE_XUSB_AO |
0477            RPU_USE_XUSB_AO | VREG_USE_XUSB_AO);
0478     ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
0479 
0480     /* disable wake event triggers of sleepwalk logic */
0481     value = ao_readl(priv, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0482     value &= ~WAKE_VAL(~0);
0483     value |= WAKE_VAL_NONE;
0484     ao_writel(priv, value, XUSB_AO_UTMIP_SLEEPWALK_CFG(index));
0485 
0486     /* power down the line state detectors of the port */
0487     value = ao_readl(priv, XUSB_AO_UTMIP_PAD_CFG(index));
0488     value |= USBOP_VAL_PD | USBON_VAL_PD;
0489     ao_writel(priv, value, XUSB_AO_UTMIP_PAD_CFG(index));
0490 
0491     /* clear alarm of the sleepwalk logic */
0492     value = ao_readl(priv, XUSB_AO_UTMIP_TRIGGERS(index));
0493     value |= CLR_WAKE_ALARM;
0494     ao_writel(priv, value, XUSB_AO_UTMIP_TRIGGERS(index));
0495 
0496     mutex_unlock(&padctl->lock);
0497 
0498     return 0;
0499 }
0500 
0501 static int tegra186_utmi_enable_phy_wake(struct tegra_xusb_lane *lane)
0502 {
0503     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0504     unsigned int index = lane->index;
0505     u32 value;
0506 
0507     mutex_lock(&padctl->lock);
0508 
0509     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
0510     value &= ~ALL_WAKE_EVENTS;
0511     value |= USB2_PORT_WAKEUP_EVENT(index);
0512     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
0513 
0514     usleep_range(10, 20);
0515 
0516     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
0517     value &= ~ALL_WAKE_EVENTS;
0518     value |= USB2_PORT_WAKE_INTERRUPT_ENABLE(index);
0519     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
0520 
0521     mutex_unlock(&padctl->lock);
0522 
0523     return 0;
0524 }
0525 
0526 static int tegra186_utmi_disable_phy_wake(struct tegra_xusb_lane *lane)
0527 {
0528     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0529     unsigned int index = lane->index;
0530     u32 value;
0531 
0532     mutex_lock(&padctl->lock);
0533 
0534     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
0535     value &= ~ALL_WAKE_EVENTS;
0536     value &= ~USB2_PORT_WAKE_INTERRUPT_ENABLE(index);
0537     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
0538 
0539     usleep_range(10, 20);
0540 
0541     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
0542     value &= ~ALL_WAKE_EVENTS;
0543     value |= USB2_PORT_WAKEUP_EVENT(index);
0544     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
0545 
0546     mutex_unlock(&padctl->lock);
0547 
0548     return 0;
0549 }
0550 
0551 static bool tegra186_utmi_phy_remote_wake_detected(struct tegra_xusb_lane *lane)
0552 {
0553     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0554     unsigned int index = lane->index;
0555     u32 value;
0556 
0557     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
0558     if ((value & USB2_PORT_WAKE_INTERRUPT_ENABLE(index)) &&
0559         (value & USB2_PORT_WAKEUP_EVENT(index)))
0560         return true;
0561 
0562     return false;
0563 }
0564 
0565 static const struct tegra_xusb_lane_ops tegra186_usb2_lane_ops = {
0566     .probe = tegra186_usb2_lane_probe,
0567     .remove = tegra186_usb2_lane_remove,
0568     .enable_phy_sleepwalk = tegra186_utmi_enable_phy_sleepwalk,
0569     .disable_phy_sleepwalk = tegra186_utmi_disable_phy_sleepwalk,
0570     .enable_phy_wake = tegra186_utmi_enable_phy_wake,
0571     .disable_phy_wake = tegra186_utmi_disable_phy_wake,
0572     .remote_wake_detected = tegra186_utmi_phy_remote_wake_detected,
0573 };
0574 
0575 static void tegra186_utmi_bias_pad_power_on(struct tegra_xusb_padctl *padctl)
0576 {
0577     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
0578     struct device *dev = padctl->dev;
0579     u32 value;
0580     int err;
0581 
0582     mutex_lock(&padctl->lock);
0583 
0584     if (priv->bias_pad_enable++ > 0) {
0585         mutex_unlock(&padctl->lock);
0586         return;
0587     }
0588 
0589     err = clk_prepare_enable(priv->usb2_trk_clk);
0590     if (err < 0)
0591         dev_warn(dev, "failed to enable USB2 trk clock: %d\n", err);
0592 
0593     value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
0594     value &= ~USB2_TRK_START_TIMER(~0);
0595     value |= USB2_TRK_START_TIMER(0x1e);
0596     value &= ~USB2_TRK_DONE_RESET_TIMER(~0);
0597     value |= USB2_TRK_DONE_RESET_TIMER(0xa);
0598     padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
0599 
0600     value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
0601     value &= ~BIAS_PAD_PD;
0602     value &= ~HS_SQUELCH_LEVEL(~0);
0603     value |= HS_SQUELCH_LEVEL(priv->calib.hs_squelch);
0604     padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL0);
0605 
0606     udelay(1);
0607 
0608     value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
0609     value &= ~USB2_PD_TRK;
0610     padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
0611 
0612     mutex_unlock(&padctl->lock);
0613 }
0614 
0615 static void tegra186_utmi_bias_pad_power_off(struct tegra_xusb_padctl *padctl)
0616 {
0617     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
0618     u32 value;
0619 
0620     mutex_lock(&padctl->lock);
0621 
0622     if (WARN_ON(priv->bias_pad_enable == 0)) {
0623         mutex_unlock(&padctl->lock);
0624         return;
0625     }
0626 
0627     if (--priv->bias_pad_enable > 0) {
0628         mutex_unlock(&padctl->lock);
0629         return;
0630     }
0631 
0632     value = padctl_readl(padctl, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
0633     value |= USB2_PD_TRK;
0634     padctl_writel(padctl, value, XUSB_PADCTL_USB2_BIAS_PAD_CTL1);
0635 
0636     clk_disable_unprepare(priv->usb2_trk_clk);
0637 
0638     mutex_unlock(&padctl->lock);
0639 }
0640 
0641 static void tegra_phy_xusb_utmi_pad_power_on(struct phy *phy)
0642 {
0643     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
0644     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0645     struct tegra_xusb_usb2_port *port;
0646     struct device *dev = padctl->dev;
0647     unsigned int index = lane->index;
0648     u32 value;
0649 
0650     if (!phy)
0651         return;
0652 
0653     port = tegra_xusb_find_usb2_port(padctl, index);
0654     if (!port) {
0655         dev_err(dev, "no port found for USB2 lane %u\n", index);
0656         return;
0657     }
0658 
0659     tegra186_utmi_bias_pad_power_on(padctl);
0660 
0661     udelay(2);
0662 
0663     value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
0664     value &= ~USB2_OTG_PD;
0665     padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
0666 
0667     value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
0668     value &= ~USB2_OTG_PD_DR;
0669     padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
0670 }
0671 
0672 static void tegra_phy_xusb_utmi_pad_power_down(struct phy *phy)
0673 {
0674     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
0675     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0676     unsigned int index = lane->index;
0677     u32 value;
0678 
0679     if (!phy)
0680         return;
0681 
0682     value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
0683     value |= USB2_OTG_PD;
0684     padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
0685 
0686     value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
0687     value |= USB2_OTG_PD_DR;
0688     padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
0689 
0690     udelay(2);
0691 
0692     tegra186_utmi_bias_pad_power_off(padctl);
0693 }
0694 
0695 static int tegra186_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
0696                            bool status)
0697 {
0698     u32 value;
0699 
0700     dev_dbg(padctl->dev, "%s vbus override\n", status ? "set" : "clear");
0701 
0702     value = padctl_readl(padctl, USB2_VBUS_ID);
0703 
0704     if (status) {
0705         value |= VBUS_OVERRIDE;
0706         value &= ~ID_OVERRIDE(~0);
0707         value |= ID_OVERRIDE_FLOATING;
0708     } else {
0709         value &= ~VBUS_OVERRIDE;
0710     }
0711 
0712     padctl_writel(padctl, value, USB2_VBUS_ID);
0713 
0714     return 0;
0715 }
0716 
0717 static int tegra186_xusb_padctl_id_override(struct tegra_xusb_padctl *padctl,
0718                         bool status)
0719 {
0720     u32 value;
0721 
0722     dev_dbg(padctl->dev, "%s id override\n", status ? "set" : "clear");
0723 
0724     value = padctl_readl(padctl, USB2_VBUS_ID);
0725 
0726     if (status) {
0727         if (value & VBUS_OVERRIDE) {
0728             value &= ~VBUS_OVERRIDE;
0729             padctl_writel(padctl, value, USB2_VBUS_ID);
0730             usleep_range(1000, 2000);
0731 
0732             value = padctl_readl(padctl, USB2_VBUS_ID);
0733         }
0734 
0735         value &= ~ID_OVERRIDE(~0);
0736         value |= ID_OVERRIDE_GROUNDED;
0737     } else {
0738         value &= ~ID_OVERRIDE(~0);
0739         value |= ID_OVERRIDE_FLOATING;
0740     }
0741 
0742     padctl_writel(padctl, value, USB2_VBUS_ID);
0743 
0744     return 0;
0745 }
0746 
0747 static int tegra186_utmi_phy_set_mode(struct phy *phy, enum phy_mode mode,
0748                       int submode)
0749 {
0750     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
0751     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0752     struct tegra_xusb_usb2_port *port = tegra_xusb_find_usb2_port(padctl,
0753                                 lane->index);
0754     int err = 0;
0755 
0756     mutex_lock(&padctl->lock);
0757 
0758     dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode);
0759 
0760     if (mode == PHY_MODE_USB_OTG) {
0761         if (submode == USB_ROLE_HOST) {
0762             tegra186_xusb_padctl_id_override(padctl, true);
0763 
0764             err = regulator_enable(port->supply);
0765         } else if (submode == USB_ROLE_DEVICE) {
0766             tegra186_xusb_padctl_vbus_override(padctl, true);
0767         } else if (submode == USB_ROLE_NONE) {
0768             /*
0769              * When port is peripheral only or role transitions to
0770              * USB_ROLE_NONE from USB_ROLE_DEVICE, regulator is not
0771              * enabled.
0772              */
0773             if (regulator_is_enabled(port->supply))
0774                 regulator_disable(port->supply);
0775 
0776             tegra186_xusb_padctl_id_override(padctl, false);
0777             tegra186_xusb_padctl_vbus_override(padctl, false);
0778         }
0779     }
0780 
0781     mutex_unlock(&padctl->lock);
0782 
0783     return err;
0784 }
0785 
0786 static int tegra186_utmi_phy_power_on(struct phy *phy)
0787 {
0788     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
0789     struct tegra_xusb_usb2_lane *usb2 = to_usb2_lane(lane);
0790     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0791     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
0792     struct tegra_xusb_usb2_port *port;
0793     unsigned int index = lane->index;
0794     struct device *dev = padctl->dev;
0795     u32 value;
0796 
0797     port = tegra_xusb_find_usb2_port(padctl, index);
0798     if (!port) {
0799         dev_err(dev, "no port found for USB2 lane %u\n", index);
0800         return -ENODEV;
0801     }
0802 
0803     value = padctl_readl(padctl, XUSB_PADCTL_USB2_PAD_MUX);
0804     value &= ~(USB2_PORT_MASK << USB2_PORT_SHIFT(index));
0805     value |= (PORT_XUSB << USB2_PORT_SHIFT(index));
0806     padctl_writel(padctl, value, XUSB_PADCTL_USB2_PAD_MUX);
0807 
0808     value = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP);
0809     value &= ~(PORT_CAP_MASK << PORTX_CAP_SHIFT(index));
0810 
0811     if (port->mode == USB_DR_MODE_UNKNOWN)
0812         value |= (PORT_CAP_DISABLED << PORTX_CAP_SHIFT(index));
0813     else if (port->mode == USB_DR_MODE_PERIPHERAL)
0814         value |= (PORT_CAP_DEVICE << PORTX_CAP_SHIFT(index));
0815     else if (port->mode == USB_DR_MODE_HOST)
0816         value |= (PORT_CAP_HOST << PORTX_CAP_SHIFT(index));
0817     else if (port->mode == USB_DR_MODE_OTG)
0818         value |= (PORT_CAP_OTG << PORTX_CAP_SHIFT(index));
0819 
0820     padctl_writel(padctl, value, XUSB_PADCTL_USB2_PORT_CAP);
0821 
0822     value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
0823     value &= ~USB2_OTG_PD_ZI;
0824     value |= TERM_SEL;
0825     value &= ~HS_CURR_LEVEL(~0);
0826 
0827     if (usb2->hs_curr_level_offset) {
0828         int hs_current_level;
0829 
0830         hs_current_level = (int)priv->calib.hs_curr_level[index] +
0831                         usb2->hs_curr_level_offset;
0832 
0833         if (hs_current_level < 0)
0834             hs_current_level = 0;
0835         if (hs_current_level > 0x3f)
0836             hs_current_level = 0x3f;
0837 
0838         value |= HS_CURR_LEVEL(hs_current_level);
0839     } else {
0840         value |= HS_CURR_LEVEL(priv->calib.hs_curr_level[index]);
0841     }
0842 
0843     padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL0(index));
0844 
0845     value = padctl_readl(padctl, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
0846     value &= ~TERM_RANGE_ADJ(~0);
0847     value |= TERM_RANGE_ADJ(priv->calib.hs_term_range_adj);
0848     value &= ~RPD_CTRL(~0);
0849     value |= RPD_CTRL(priv->calib.rpd_ctrl);
0850     padctl_writel(padctl, value, XUSB_PADCTL_USB2_OTG_PADX_CTL1(index));
0851 
0852     /* TODO: pad power saving */
0853     tegra_phy_xusb_utmi_pad_power_on(phy);
0854     return 0;
0855 }
0856 
0857 static int tegra186_utmi_phy_power_off(struct phy *phy)
0858 {
0859     /* TODO: pad power saving */
0860     tegra_phy_xusb_utmi_pad_power_down(phy);
0861 
0862     return 0;
0863 }
0864 
0865 static int tegra186_utmi_phy_init(struct phy *phy)
0866 {
0867     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
0868     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0869     struct tegra_xusb_usb2_port *port;
0870     unsigned int index = lane->index;
0871     struct device *dev = padctl->dev;
0872     int err;
0873 
0874     port = tegra_xusb_find_usb2_port(padctl, index);
0875     if (!port) {
0876         dev_err(dev, "no port found for USB2 lane %u\n", index);
0877         return -ENODEV;
0878     }
0879 
0880     if (port->supply && port->mode == USB_DR_MODE_HOST) {
0881         err = regulator_enable(port->supply);
0882         if (err) {
0883             dev_err(dev, "failed to enable port %u VBUS: %d\n",
0884                 index, err);
0885             return err;
0886         }
0887     }
0888 
0889     return 0;
0890 }
0891 
0892 static int tegra186_utmi_phy_exit(struct phy *phy)
0893 {
0894     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
0895     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
0896     struct tegra_xusb_usb2_port *port;
0897     unsigned int index = lane->index;
0898     struct device *dev = padctl->dev;
0899     int err;
0900 
0901     port = tegra_xusb_find_usb2_port(padctl, index);
0902     if (!port) {
0903         dev_err(dev, "no port found for USB2 lane %u\n", index);
0904         return -ENODEV;
0905     }
0906 
0907     if (port->supply && port->mode == USB_DR_MODE_HOST) {
0908         err = regulator_disable(port->supply);
0909         if (err) {
0910             dev_err(dev, "failed to disable port %u VBUS: %d\n",
0911                 index, err);
0912             return err;
0913         }
0914     }
0915 
0916     return 0;
0917 }
0918 
0919 static const struct phy_ops utmi_phy_ops = {
0920     .init = tegra186_utmi_phy_init,
0921     .exit = tegra186_utmi_phy_exit,
0922     .power_on = tegra186_utmi_phy_power_on,
0923     .power_off = tegra186_utmi_phy_power_off,
0924     .set_mode = tegra186_utmi_phy_set_mode,
0925     .owner = THIS_MODULE,
0926 };
0927 
0928 static struct tegra_xusb_pad *
0929 tegra186_usb2_pad_probe(struct tegra_xusb_padctl *padctl,
0930             const struct tegra_xusb_pad_soc *soc,
0931             struct device_node *np)
0932 {
0933     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
0934     struct tegra_xusb_usb2_pad *usb2;
0935     struct tegra_xusb_pad *pad;
0936     int err;
0937 
0938     usb2 = kzalloc(sizeof(*usb2), GFP_KERNEL);
0939     if (!usb2)
0940         return ERR_PTR(-ENOMEM);
0941 
0942     pad = &usb2->base;
0943     pad->ops = &tegra186_usb2_lane_ops;
0944     pad->soc = soc;
0945 
0946     err = tegra_xusb_pad_init(pad, padctl, np);
0947     if (err < 0) {
0948         kfree(usb2);
0949         goto out;
0950     }
0951 
0952     priv->usb2_trk_clk = devm_clk_get(&pad->dev, "trk");
0953     if (IS_ERR(priv->usb2_trk_clk)) {
0954         err = PTR_ERR(priv->usb2_trk_clk);
0955         dev_dbg(&pad->dev, "failed to get usb2 trk clock: %d\n", err);
0956         goto unregister;
0957     }
0958 
0959     err = tegra_xusb_pad_register(pad, &utmi_phy_ops);
0960     if (err < 0)
0961         goto unregister;
0962 
0963     dev_set_drvdata(&pad->dev, pad);
0964 
0965     return pad;
0966 
0967 unregister:
0968     device_unregister(&pad->dev);
0969 out:
0970     return ERR_PTR(err);
0971 }
0972 
0973 static void tegra186_usb2_pad_remove(struct tegra_xusb_pad *pad)
0974 {
0975     struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
0976 
0977     kfree(usb2);
0978 }
0979 
0980 static const struct tegra_xusb_pad_ops tegra186_usb2_pad_ops = {
0981     .probe = tegra186_usb2_pad_probe,
0982     .remove = tegra186_usb2_pad_remove,
0983 };
0984 
0985 static const char * const tegra186_usb2_functions[] = {
0986     "xusb",
0987 };
0988 
0989 static int tegra186_usb2_port_enable(struct tegra_xusb_port *port)
0990 {
0991     return 0;
0992 }
0993 
0994 static void tegra186_usb2_port_disable(struct tegra_xusb_port *port)
0995 {
0996 }
0997 
0998 static struct tegra_xusb_lane *
0999 tegra186_usb2_port_map(struct tegra_xusb_port *port)
1000 {
1001     return tegra_xusb_find_lane(port->padctl, "usb2", port->index);
1002 }
1003 
1004 static const struct tegra_xusb_port_ops tegra186_usb2_port_ops = {
1005     .release = tegra_xusb_usb2_port_release,
1006     .remove = tegra_xusb_usb2_port_remove,
1007     .enable = tegra186_usb2_port_enable,
1008     .disable = tegra186_usb2_port_disable,
1009     .map = tegra186_usb2_port_map,
1010 };
1011 
1012 /* SuperSpeed PHY support */
1013 static struct tegra_xusb_lane *
1014 tegra186_usb3_lane_probe(struct tegra_xusb_pad *pad, struct device_node *np,
1015              unsigned int index)
1016 {
1017     struct tegra_xusb_usb3_lane *usb3;
1018     int err;
1019 
1020     usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
1021     if (!usb3)
1022         return ERR_PTR(-ENOMEM);
1023 
1024     INIT_LIST_HEAD(&usb3->base.list);
1025     usb3->base.soc = &pad->soc->lanes[index];
1026     usb3->base.index = index;
1027     usb3->base.pad = pad;
1028     usb3->base.np = np;
1029 
1030     err = tegra_xusb_lane_parse_dt(&usb3->base, np);
1031     if (err < 0) {
1032         kfree(usb3);
1033         return ERR_PTR(err);
1034     }
1035 
1036     return &usb3->base;
1037 }
1038 
1039 static void tegra186_usb3_lane_remove(struct tegra_xusb_lane *lane)
1040 {
1041     struct tegra_xusb_usb3_lane *usb3 = to_usb3_lane(lane);
1042 
1043     kfree(usb3);
1044 }
1045 
1046 static int tegra186_usb3_enable_phy_sleepwalk(struct tegra_xusb_lane *lane,
1047                           enum usb_device_speed speed)
1048 {
1049     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1050     unsigned int index = lane->index;
1051     u32 value;
1052 
1053     mutex_lock(&padctl->lock);
1054 
1055     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1056     value |= SSPX_ELPG_CLAMP_EN_EARLY(index);
1057     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1058 
1059     usleep_range(100, 200);
1060 
1061     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1062     value |= SSPX_ELPG_CLAMP_EN(index);
1063     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1064 
1065     usleep_range(250, 350);
1066 
1067     mutex_unlock(&padctl->lock);
1068 
1069     return 0;
1070 }
1071 
1072 static int tegra186_usb3_disable_phy_sleepwalk(struct tegra_xusb_lane *lane)
1073 {
1074     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1075     unsigned int index = lane->index;
1076     u32 value;
1077 
1078     mutex_lock(&padctl->lock);
1079 
1080     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1081     value &= ~SSPX_ELPG_CLAMP_EN_EARLY(index);
1082     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1083 
1084     usleep_range(100, 200);
1085 
1086     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1087     value &= ~SSPX_ELPG_CLAMP_EN(index);
1088     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1089 
1090     mutex_unlock(&padctl->lock);
1091 
1092     return 0;
1093 }
1094 
1095 static int tegra186_usb3_enable_phy_wake(struct tegra_xusb_lane *lane)
1096 {
1097     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1098     unsigned int index = lane->index;
1099     u32 value;
1100 
1101     mutex_lock(&padctl->lock);
1102 
1103     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
1104     value &= ~ALL_WAKE_EVENTS;
1105     value |= SS_PORT_WAKEUP_EVENT(index);
1106     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
1107 
1108     usleep_range(10, 20);
1109 
1110     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
1111     value &= ~ALL_WAKE_EVENTS;
1112     value |= SS_PORT_WAKE_INTERRUPT_ENABLE(index);
1113     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
1114 
1115     mutex_unlock(&padctl->lock);
1116 
1117     return 0;
1118 }
1119 
1120 static int tegra186_usb3_disable_phy_wake(struct tegra_xusb_lane *lane)
1121 {
1122     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1123     unsigned int index = lane->index;
1124     u32 value;
1125 
1126     mutex_lock(&padctl->lock);
1127 
1128     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
1129     value &= ~ALL_WAKE_EVENTS;
1130     value &= ~SS_PORT_WAKE_INTERRUPT_ENABLE(index);
1131     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
1132 
1133     usleep_range(10, 20);
1134 
1135     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
1136     value &= ~ALL_WAKE_EVENTS;
1137     value |= SS_PORT_WAKEUP_EVENT(index);
1138     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM);
1139 
1140     mutex_unlock(&padctl->lock);
1141 
1142     return 0;
1143 }
1144 
1145 static bool tegra186_usb3_phy_remote_wake_detected(struct tegra_xusb_lane *lane)
1146 {
1147     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1148     unsigned int index = lane->index;
1149     u32 value;
1150 
1151     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM);
1152     if ((value & SS_PORT_WAKE_INTERRUPT_ENABLE(index)) && (value & SS_PORT_WAKEUP_EVENT(index)))
1153         return true;
1154 
1155     return false;
1156 }
1157 
1158 static const struct tegra_xusb_lane_ops tegra186_usb3_lane_ops = {
1159     .probe = tegra186_usb3_lane_probe,
1160     .remove = tegra186_usb3_lane_remove,
1161     .enable_phy_sleepwalk = tegra186_usb3_enable_phy_sleepwalk,
1162     .disable_phy_sleepwalk = tegra186_usb3_disable_phy_sleepwalk,
1163     .enable_phy_wake = tegra186_usb3_enable_phy_wake,
1164     .disable_phy_wake = tegra186_usb3_disable_phy_wake,
1165     .remote_wake_detected = tegra186_usb3_phy_remote_wake_detected,
1166 };
1167 
1168 static int tegra186_usb3_port_enable(struct tegra_xusb_port *port)
1169 {
1170     return 0;
1171 }
1172 
1173 static void tegra186_usb3_port_disable(struct tegra_xusb_port *port)
1174 {
1175 }
1176 
1177 static struct tegra_xusb_lane *
1178 tegra186_usb3_port_map(struct tegra_xusb_port *port)
1179 {
1180     return tegra_xusb_find_lane(port->padctl, "usb3", port->index);
1181 }
1182 
1183 static const struct tegra_xusb_port_ops tegra186_usb3_port_ops = {
1184     .release = tegra_xusb_usb3_port_release,
1185     .remove = tegra_xusb_usb3_port_remove,
1186     .enable = tegra186_usb3_port_enable,
1187     .disable = tegra186_usb3_port_disable,
1188     .map = tegra186_usb3_port_map,
1189 };
1190 
1191 static int tegra186_usb3_phy_power_on(struct phy *phy)
1192 {
1193     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
1194     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1195     struct tegra_xusb_usb3_port *port;
1196     struct tegra_xusb_usb2_port *usb2;
1197     unsigned int index = lane->index;
1198     struct device *dev = padctl->dev;
1199     u32 value;
1200 
1201     port = tegra_xusb_find_usb3_port(padctl, index);
1202     if (!port) {
1203         dev_err(dev, "no port found for USB3 lane %u\n", index);
1204         return -ENODEV;
1205     }
1206 
1207     usb2 = tegra_xusb_find_usb2_port(padctl, port->port);
1208     if (!usb2) {
1209         dev_err(dev, "no companion port found for USB3 lane %u\n",
1210             index);
1211         return -ENODEV;
1212     }
1213 
1214     mutex_lock(&padctl->lock);
1215 
1216     value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CAP);
1217     value &= ~(PORT_CAP_MASK << PORTX_CAP_SHIFT(index));
1218 
1219     if (usb2->mode == USB_DR_MODE_UNKNOWN)
1220         value |= (PORT_CAP_DISABLED << PORTX_CAP_SHIFT(index));
1221     else if (usb2->mode == USB_DR_MODE_PERIPHERAL)
1222         value |= (PORT_CAP_DEVICE << PORTX_CAP_SHIFT(index));
1223     else if (usb2->mode == USB_DR_MODE_HOST)
1224         value |= (PORT_CAP_HOST << PORTX_CAP_SHIFT(index));
1225     else if (usb2->mode == USB_DR_MODE_OTG)
1226         value |= (PORT_CAP_OTG << PORTX_CAP_SHIFT(index));
1227 
1228     padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_CAP);
1229 
1230     if (padctl->soc->supports_gen2 && port->disable_gen2) {
1231         value = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CFG);
1232         value &= ~(PORTX_SPEED_SUPPORT_MASK <<
1233             PORTX_SPEED_SUPPORT_SHIFT(index));
1234         value |= (PORT_SPEED_SUPPORT_GEN1 <<
1235             PORTX_SPEED_SUPPORT_SHIFT(index));
1236         padctl_writel(padctl, value, XUSB_PADCTL_SS_PORT_CFG);
1237     }
1238 
1239     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1240     value &= ~SSPX_ELPG_VCORE_DOWN(index);
1241     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1242 
1243     usleep_range(100, 200);
1244 
1245     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1246     value &= ~SSPX_ELPG_CLAMP_EN_EARLY(index);
1247     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1248 
1249     usleep_range(100, 200);
1250 
1251     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1252     value &= ~SSPX_ELPG_CLAMP_EN(index);
1253     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1254 
1255     mutex_unlock(&padctl->lock);
1256 
1257     return 0;
1258 }
1259 
1260 static int tegra186_usb3_phy_power_off(struct phy *phy)
1261 {
1262     struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
1263     struct tegra_xusb_padctl *padctl = lane->pad->padctl;
1264     struct tegra_xusb_usb3_port *port;
1265     unsigned int index = lane->index;
1266     struct device *dev = padctl->dev;
1267     u32 value;
1268 
1269     port = tegra_xusb_find_usb3_port(padctl, index);
1270     if (!port) {
1271         dev_err(dev, "no port found for USB3 lane %u\n", index);
1272         return -ENODEV;
1273     }
1274 
1275     mutex_lock(&padctl->lock);
1276 
1277     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1278     value |= SSPX_ELPG_CLAMP_EN_EARLY(index);
1279     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1280 
1281     usleep_range(100, 200);
1282 
1283     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1284     value |= SSPX_ELPG_CLAMP_EN(index);
1285     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1286 
1287     usleep_range(250, 350);
1288 
1289     value = padctl_readl(padctl, XUSB_PADCTL_ELPG_PROGRAM_1);
1290     value |= SSPX_ELPG_VCORE_DOWN(index);
1291     padctl_writel(padctl, value, XUSB_PADCTL_ELPG_PROGRAM_1);
1292 
1293     mutex_unlock(&padctl->lock);
1294 
1295     return 0;
1296 }
1297 
1298 static int tegra186_usb3_phy_init(struct phy *phy)
1299 {
1300     return 0;
1301 }
1302 
1303 static int tegra186_usb3_phy_exit(struct phy *phy)
1304 {
1305     return 0;
1306 }
1307 
1308 static const struct phy_ops usb3_phy_ops = {
1309     .init = tegra186_usb3_phy_init,
1310     .exit = tegra186_usb3_phy_exit,
1311     .power_on = tegra186_usb3_phy_power_on,
1312     .power_off = tegra186_usb3_phy_power_off,
1313     .owner = THIS_MODULE,
1314 };
1315 
1316 static struct tegra_xusb_pad *
1317 tegra186_usb3_pad_probe(struct tegra_xusb_padctl *padctl,
1318             const struct tegra_xusb_pad_soc *soc,
1319             struct device_node *np)
1320 {
1321     struct tegra_xusb_usb3_pad *usb3;
1322     struct tegra_xusb_pad *pad;
1323     int err;
1324 
1325     usb3 = kzalloc(sizeof(*usb3), GFP_KERNEL);
1326     if (!usb3)
1327         return ERR_PTR(-ENOMEM);
1328 
1329     pad = &usb3->base;
1330     pad->ops = &tegra186_usb3_lane_ops;
1331     pad->soc = soc;
1332 
1333     err = tegra_xusb_pad_init(pad, padctl, np);
1334     if (err < 0) {
1335         kfree(usb3);
1336         goto out;
1337     }
1338 
1339     err = tegra_xusb_pad_register(pad, &usb3_phy_ops);
1340     if (err < 0)
1341         goto unregister;
1342 
1343     dev_set_drvdata(&pad->dev, pad);
1344 
1345     return pad;
1346 
1347 unregister:
1348     device_unregister(&pad->dev);
1349 out:
1350     return ERR_PTR(err);
1351 }
1352 
1353 static void tegra186_usb3_pad_remove(struct tegra_xusb_pad *pad)
1354 {
1355     struct tegra_xusb_usb2_pad *usb2 = to_usb2_pad(pad);
1356 
1357     kfree(usb2);
1358 }
1359 
1360 static const struct tegra_xusb_pad_ops tegra186_usb3_pad_ops = {
1361     .probe = tegra186_usb3_pad_probe,
1362     .remove = tegra186_usb3_pad_remove,
1363 };
1364 
1365 static const char * const tegra186_usb3_functions[] = {
1366     "xusb",
1367 };
1368 
1369 static int
1370 tegra186_xusb_read_fuse_calibration(struct tegra186_xusb_padctl *padctl)
1371 {
1372     struct device *dev = padctl->base.dev;
1373     unsigned int i, count;
1374     u32 value, *level;
1375     int err;
1376 
1377     count = padctl->base.soc->ports.usb2.count;
1378 
1379     level = devm_kcalloc(dev, count, sizeof(u32), GFP_KERNEL);
1380     if (!level)
1381         return -ENOMEM;
1382 
1383     err = tegra_fuse_readl(TEGRA_FUSE_SKU_CALIB_0, &value);
1384     if (err) {
1385         if (err != -EPROBE_DEFER)
1386             dev_err(dev, "failed to read calibration fuse: %d\n",
1387                 err);
1388         return err;
1389     }
1390 
1391     dev_dbg(dev, "FUSE_USB_CALIB_0 %#x\n", value);
1392 
1393     for (i = 0; i < count; i++)
1394         level[i] = (value >> HS_CURR_LEVEL_PADX_SHIFT(i)) &
1395                 HS_CURR_LEVEL_PAD_MASK;
1396 
1397     padctl->calib.hs_curr_level = level;
1398 
1399     padctl->calib.hs_squelch = (value >> HS_SQUELCH_SHIFT) &
1400                     HS_SQUELCH_MASK;
1401     padctl->calib.hs_term_range_adj = (value >> HS_TERM_RANGE_ADJ_SHIFT) &
1402                         HS_TERM_RANGE_ADJ_MASK;
1403 
1404     err = tegra_fuse_readl(TEGRA_FUSE_USB_CALIB_EXT_0, &value);
1405     if (err) {
1406         dev_err(dev, "failed to read calibration fuse: %d\n", err);
1407         return err;
1408     }
1409 
1410     dev_dbg(dev, "FUSE_USB_CALIB_EXT_0 %#x\n", value);
1411 
1412     padctl->calib.rpd_ctrl = (value >> RPD_CTRL_SHIFT) & RPD_CTRL_MASK;
1413 
1414     return 0;
1415 }
1416 
1417 static struct tegra_xusb_padctl *
1418 tegra186_xusb_padctl_probe(struct device *dev,
1419                const struct tegra_xusb_padctl_soc *soc)
1420 {
1421     struct platform_device *pdev = to_platform_device(dev);
1422     struct tegra186_xusb_padctl *priv;
1423     struct resource *res;
1424     int err;
1425 
1426     priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
1427     if (!priv)
1428         return ERR_PTR(-ENOMEM);
1429 
1430     priv->base.dev = dev;
1431     priv->base.soc = soc;
1432 
1433     res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ao");
1434     priv->ao_regs = devm_ioremap_resource(dev, res);
1435     if (IS_ERR(priv->ao_regs))
1436         return ERR_CAST(priv->ao_regs);
1437 
1438     err = tegra186_xusb_read_fuse_calibration(priv);
1439     if (err < 0)
1440         return ERR_PTR(err);
1441 
1442     return &priv->base;
1443 }
1444 
1445 static void tegra186_xusb_padctl_save(struct tegra_xusb_padctl *padctl)
1446 {
1447     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
1448 
1449     priv->context.vbus_id = padctl_readl(padctl, USB2_VBUS_ID);
1450     priv->context.usb2_pad_mux = padctl_readl(padctl, XUSB_PADCTL_USB2_PAD_MUX);
1451     priv->context.usb2_port_cap = padctl_readl(padctl, XUSB_PADCTL_USB2_PORT_CAP);
1452     priv->context.ss_port_cap = padctl_readl(padctl, XUSB_PADCTL_SS_PORT_CAP);
1453 }
1454 
1455 static void tegra186_xusb_padctl_restore(struct tegra_xusb_padctl *padctl)
1456 {
1457     struct tegra186_xusb_padctl *priv = to_tegra186_xusb_padctl(padctl);
1458 
1459     padctl_writel(padctl, priv->context.usb2_pad_mux, XUSB_PADCTL_USB2_PAD_MUX);
1460     padctl_writel(padctl, priv->context.usb2_port_cap, XUSB_PADCTL_USB2_PORT_CAP);
1461     padctl_writel(padctl, priv->context.ss_port_cap, XUSB_PADCTL_SS_PORT_CAP);
1462     padctl_writel(padctl, priv->context.vbus_id, USB2_VBUS_ID);
1463 }
1464 
1465 static int tegra186_xusb_padctl_suspend_noirq(struct tegra_xusb_padctl *padctl)
1466 {
1467     tegra186_xusb_padctl_save(padctl);
1468 
1469     return 0;
1470 }
1471 
1472 static int tegra186_xusb_padctl_resume_noirq(struct tegra_xusb_padctl *padctl)
1473 {
1474     tegra186_xusb_padctl_restore(padctl);
1475 
1476     return 0;
1477 }
1478 
1479 static void tegra186_xusb_padctl_remove(struct tegra_xusb_padctl *padctl)
1480 {
1481 }
1482 
1483 static const struct tegra_xusb_padctl_ops tegra186_xusb_padctl_ops = {
1484     .probe = tegra186_xusb_padctl_probe,
1485     .remove = tegra186_xusb_padctl_remove,
1486     .suspend_noirq = tegra186_xusb_padctl_suspend_noirq,
1487     .resume_noirq = tegra186_xusb_padctl_resume_noirq,
1488     .vbus_override = tegra186_xusb_padctl_vbus_override,
1489 };
1490 
1491 #if IS_ENABLED(CONFIG_ARCH_TEGRA_186_SOC)
1492 static const char * const tegra186_xusb_padctl_supply_names[] = {
1493     "avdd-pll-erefeut",
1494     "avdd-usb",
1495     "vclamp-usb",
1496     "vddio-hsic",
1497 };
1498 
1499 static const struct tegra_xusb_lane_soc tegra186_usb2_lanes[] = {
1500     TEGRA186_LANE("usb2-0", 0,  0, 0, usb2),
1501     TEGRA186_LANE("usb2-1", 0,  0, 0, usb2),
1502     TEGRA186_LANE("usb2-2", 0,  0, 0, usb2),
1503 };
1504 
1505 static const struct tegra_xusb_pad_soc tegra186_usb2_pad = {
1506     .name = "usb2",
1507     .num_lanes = ARRAY_SIZE(tegra186_usb2_lanes),
1508     .lanes = tegra186_usb2_lanes,
1509     .ops = &tegra186_usb2_pad_ops,
1510 };
1511 
1512 static const struct tegra_xusb_lane_soc tegra186_usb3_lanes[] = {
1513     TEGRA186_LANE("usb3-0", 0,  0, 0, usb3),
1514     TEGRA186_LANE("usb3-1", 0,  0, 0, usb3),
1515     TEGRA186_LANE("usb3-2", 0,  0, 0, usb3),
1516 };
1517 
1518 static const struct tegra_xusb_pad_soc tegra186_usb3_pad = {
1519     .name = "usb3",
1520     .num_lanes = ARRAY_SIZE(tegra186_usb3_lanes),
1521     .lanes = tegra186_usb3_lanes,
1522     .ops = &tegra186_usb3_pad_ops,
1523 };
1524 
1525 static const struct tegra_xusb_pad_soc * const tegra186_pads[] = {
1526     &tegra186_usb2_pad,
1527     &tegra186_usb3_pad,
1528 #if 0 /* TODO implement */
1529     &tegra186_hsic_pad,
1530 #endif
1531 };
1532 
1533 const struct tegra_xusb_padctl_soc tegra186_xusb_padctl_soc = {
1534     .num_pads = ARRAY_SIZE(tegra186_pads),
1535     .pads = tegra186_pads,
1536     .ports = {
1537         .usb2 = {
1538             .ops = &tegra186_usb2_port_ops,
1539             .count = 3,
1540         },
1541 #if 0 /* TODO implement */
1542         .hsic = {
1543             .ops = &tegra186_hsic_port_ops,
1544             .count = 1,
1545         },
1546 #endif
1547         .usb3 = {
1548             .ops = &tegra186_usb3_port_ops,
1549             .count = 3,
1550         },
1551     },
1552     .ops = &tegra186_xusb_padctl_ops,
1553     .supply_names = tegra186_xusb_padctl_supply_names,
1554     .num_supplies = ARRAY_SIZE(tegra186_xusb_padctl_supply_names),
1555 };
1556 EXPORT_SYMBOL_GPL(tegra186_xusb_padctl_soc);
1557 #endif
1558 
1559 #if IS_ENABLED(CONFIG_ARCH_TEGRA_194_SOC)
1560 static const char * const tegra194_xusb_padctl_supply_names[] = {
1561     "avdd-usb",
1562     "vclamp-usb",
1563 };
1564 
1565 static const struct tegra_xusb_lane_soc tegra194_usb2_lanes[] = {
1566     TEGRA186_LANE("usb2-0", 0,  0, 0, usb2),
1567     TEGRA186_LANE("usb2-1", 0,  0, 0, usb2),
1568     TEGRA186_LANE("usb2-2", 0,  0, 0, usb2),
1569     TEGRA186_LANE("usb2-3", 0,  0, 0, usb2),
1570 };
1571 
1572 static const struct tegra_xusb_pad_soc tegra194_usb2_pad = {
1573     .name = "usb2",
1574     .num_lanes = ARRAY_SIZE(tegra194_usb2_lanes),
1575     .lanes = tegra194_usb2_lanes,
1576     .ops = &tegra186_usb2_pad_ops,
1577 };
1578 
1579 static const struct tegra_xusb_lane_soc tegra194_usb3_lanes[] = {
1580     TEGRA186_LANE("usb3-0", 0,  0, 0, usb3),
1581     TEGRA186_LANE("usb3-1", 0,  0, 0, usb3),
1582     TEGRA186_LANE("usb3-2", 0,  0, 0, usb3),
1583     TEGRA186_LANE("usb3-3", 0,  0, 0, usb3),
1584 };
1585 
1586 static const struct tegra_xusb_pad_soc tegra194_usb3_pad = {
1587     .name = "usb3",
1588     .num_lanes = ARRAY_SIZE(tegra194_usb3_lanes),
1589     .lanes = tegra194_usb3_lanes,
1590     .ops = &tegra186_usb3_pad_ops,
1591 };
1592 
1593 static const struct tegra_xusb_pad_soc * const tegra194_pads[] = {
1594     &tegra194_usb2_pad,
1595     &tegra194_usb3_pad,
1596 };
1597 
1598 const struct tegra_xusb_padctl_soc tegra194_xusb_padctl_soc = {
1599     .num_pads = ARRAY_SIZE(tegra194_pads),
1600     .pads = tegra194_pads,
1601     .ports = {
1602         .usb2 = {
1603             .ops = &tegra186_usb2_port_ops,
1604             .count = 4,
1605         },
1606         .usb3 = {
1607             .ops = &tegra186_usb3_port_ops,
1608             .count = 4,
1609         },
1610     },
1611     .ops = &tegra186_xusb_padctl_ops,
1612     .supply_names = tegra194_xusb_padctl_supply_names,
1613     .num_supplies = ARRAY_SIZE(tegra194_xusb_padctl_supply_names),
1614     .supports_gen2 = true,
1615 };
1616 EXPORT_SYMBOL_GPL(tegra194_xusb_padctl_soc);
1617 #endif
1618 
1619 MODULE_AUTHOR("JC Kuo <jckuo@nvidia.com>");
1620 MODULE_DESCRIPTION("NVIDIA Tegra186 XUSB Pad Controller driver");
1621 MODULE_LICENSE("GPL v2");