Commit 521a7f7a authored by make shi's avatar make shi Committed by Jason Liu

ENGR00234722 USB: fix Kernel dump issue after USB driver loadable

- It is better to disable otgsc and wake up interrupt to avoid an
  abnormal interrupt happen during USB driver being removed.
- If the USB host is already at low power mode, only need turn on
  the clock, no need turn off the clock.
- Need discharge dp and dm during USB driver being removed ,in order
  to avoid a wakeup interrupt happen. And if the USB otg is in host
  mode, we should clear discharge dp and dm in fsl_otg_set_host()
  during system boot up.
Signed-off-by: default avatarmake shi <>
parent 57ade285
......@@ -3248,7 +3248,7 @@ err1a:
static int fsl_udc_remove(struct platform_device *pdev)
struct fsl_usb2_platform_data *pdata = pdev->dev.platform_data;
u32 temp;
if (!udc_controller)
......@@ -3258,6 +3258,13 @@ static int fsl_udc_remove(struct platform_device *pdev)
if (udc_controller->stopped)
/* disable wake up and otgsc interrupt for safely remove udc driver*/
temp = fsl_readl(&dr_regs->otgsc);
temp &= ~(0x7f << 24);
fsl_writel(temp, &dr_regs->otgsc);
dr_wake_up_enable(udc_controller, false);
dr_discharge_line(pdata, true);
/* DR has been stopped in usb_gadget_unregister_driver() */
......@@ -339,14 +339,14 @@ static void usb_hcd_fsl_remove(struct usb_hcd *hcd,
if (pdata->usb_clock_for_pm)
/*disable the wakeup to avoid an abnormal wakeup interrupt*/
usb_host_set_wakeup(hcd->self.controller, false);
tmp = ehci_readl(ehci, &ehci->regs->port_status[0]);
if (tmp & PORT_PTS_PHCD) {
tmp &= ~PORT_PTS_PHCD;
ehci_writel(ehci, tmp, &ehci->regs->port_status[0]);
if (pdata->usb_clock_for_pm)
......@@ -607,6 +607,9 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
struct fsl_otg *otg_dev = container_of(otg_p, struct fsl_otg, otg);
struct fsl_usb2_platform_data *pdata;
pdata = otg_dev->>platform_data;
if (!otg_p || otg_dev != fsl_otg_dev)
return -ENODEV;
......@@ -633,6 +636,8 @@ static int fsl_otg_set_host(struct otg_transceiver *otg_p, struct usb_bus *host)
else {
/* if the device is already at the port */
otg_drv_vbus(&otg_dev->fsm, 1);
if (pdata->dr_discharge_line)
fsl_otg_start_host(&otg_dev->fsm, 1);
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment