Skip to content

Commit f55df11

Browse files
Chunfeng Yungregkh
authored andcommitted
usb: mtu3: reinitialize CSR registers
The CSR registers will be reset as default value if the ports are disabled, so reinitialize them when the ports are enabled again. Signed-off-by: Chunfeng Yun <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c0a8d95 commit f55df11

File tree

1 file changed

+32
-29
lines changed

1 file changed

+32
-29
lines changed

drivers/usb/mtu3/mtu3_core.c

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,36 @@ static void mtu3_intr_enable(struct mtu3 *mtu)
202202
mtu3_writel(mbase, U3D_DEV_LINK_INTR_ENABLE, SSUSB_DEV_SPEED_CHG_INTR);
203203
}
204204

205+
static void mtu3_set_speed(struct mtu3 *mtu);
206+
207+
/* CSR registers will be reset to default value if port is disabled */
208+
static void mtu3_csr_init(struct mtu3 *mtu)
209+
{
210+
void __iomem *mbase = mtu->mac_base;
211+
212+
if (mtu->is_u3_ip) {
213+
/* disable LGO_U1/U2 by default */
214+
mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL,
215+
SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE);
216+
/* enable accept LGO_U1/U2 link command from host */
217+
mtu3_setbits(mbase, U3D_LINK_POWER_CONTROL,
218+
SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE);
219+
/* device responses to u3_exit from host automatically */
220+
mtu3_clrbits(mbase, U3D_LTSSM_CTRL, SOFT_U3_EXIT_EN);
221+
/* automatically build U2 link when U3 detect fail */
222+
mtu3_setbits(mbase, U3D_USB2_TEST_MODE, U2U3_AUTO_SWITCH);
223+
/* auto clear SOFT_CONN when clear USB3_EN if work as HS */
224+
mtu3_setbits(mbase, U3D_U3U2_SWITCH_CTRL, SOFTCON_CLR_AUTO_EN);
225+
}
226+
227+
mtu3_set_speed(mtu);
228+
229+
/* delay about 0.1us from detecting reset to send chirp-K */
230+
mtu3_clrbits(mbase, U3D_LINK_RESET_INFO, WTCHRP_MSK);
231+
/* enable automatical HWRW from L1 */
232+
mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, LPM_HRWE);
233+
}
234+
205235
/* reset: u2 - data toggle, u3 - SeqN, flow control status etc */
206236
static void mtu3_ep_reset(struct mtu3_ep *mep)
207237
{
@@ -267,13 +297,7 @@ void mtu3_start(struct mtu3 *mtu)
267297

268298
mtu3_clrbits(mtu->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
269299

270-
/*
271-
* When disable U2 port, USB2_CSR's register will be reset to
272-
* default value after re-enable it again(HS is enabled by default).
273-
* So if force mac to work as FS, disable HS function.
274-
*/
275-
if (mtu->max_speed == USB_SPEED_FULL)
276-
mtu3_clrbits(mbase, U3D_POWER_MANAGEMENT, HS_ENABLE);
300+
mtu3_csr_init(mtu);
277301

278302
/* Initialize the default interrupts */
279303
mtu3_intr_enable(mtu);
@@ -572,39 +596,18 @@ static void mtu3_set_speed(struct mtu3 *mtu)
572596

573597
static void mtu3_regs_init(struct mtu3 *mtu)
574598
{
575-
576599
void __iomem *mbase = mtu->mac_base;
577600

578601
/* be sure interrupts are disabled before registration of ISR */
579602
mtu3_intr_disable(mtu);
580603
mtu3_intr_status_clear(mtu);
581604

582-
if (mtu->is_u3_ip) {
583-
/* disable LGO_U1/U2 by default */
584-
mtu3_clrbits(mbase, U3D_LINK_POWER_CONTROL,
585-
SW_U1_REQUEST_ENABLE | SW_U2_REQUEST_ENABLE);
586-
/* enable accept LGO_U1/U2 link command from host */
587-
mtu3_setbits(mbase, U3D_LINK_POWER_CONTROL,
588-
SW_U1_ACCEPT_ENABLE | SW_U2_ACCEPT_ENABLE);
589-
/* device responses to u3_exit from host automatically */
590-
mtu3_clrbits(mbase, U3D_LTSSM_CTRL, SOFT_U3_EXIT_EN);
591-
/* automatically build U2 link when U3 detect fail */
592-
mtu3_setbits(mbase, U3D_USB2_TEST_MODE, U2U3_AUTO_SWITCH);
593-
/* auto clear SOFT_CONN when clear USB3_EN if work as HS */
594-
mtu3_setbits(mbase, U3D_U3U2_SWITCH_CTRL, SOFTCON_CLR_AUTO_EN);
595-
}
596-
597-
mtu3_set_speed(mtu);
605+
mtu3_csr_init(mtu);
598606

599-
/* delay about 0.1us from detecting reset to send chirp-K */
600-
mtu3_clrbits(mbase, U3D_LINK_RESET_INFO, WTCHRP_MSK);
601607
/* U2/U3 detected by HW */
602608
mtu3_writel(mbase, U3D_DEVICE_CONF, 0);
603609
/* vbus detected by HW */
604610
mtu3_clrbits(mbase, U3D_MISC_CTRL, VBUS_FRC_EN | VBUS_ON);
605-
/* enable automatical HWRW from L1 */
606-
mtu3_setbits(mbase, U3D_POWER_MANAGEMENT, LPM_HRWE);
607-
608611
/* use new QMU format when HW version >= 0x1003 */
609612
if (mtu->gen2cp)
610613
mtu3_writel(mbase, U3D_QFCR, ~0x0);

0 commit comments

Comments
 (0)