summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Chen <peter.chen@freescale.com>2011-01-21 17:22:44 +0800
committerPeter Chen <peter.chen@freescale.com>2011-01-24 09:14:17 +0800
commitb8900d6c6fd434d9bdb525e00d8f2506e1262636 (patch)
tree5514c9922b528bf55b7b01fd4a3c4becb4057c4e
parentf674af9c672238ea58dab97f0406c70d23c6f810 (diff)
ENGR00138371 usb-otg: some variables should be updated at otg irq
otg->host->is_b_host and otg->gadget->is_a_peripheral should be updated at otg irq, as the host and device driver may use these two variables. enable clk before request_irq Signed-off-by: Peter Chen <peter.chen@freescale.com>
-rw-r--r--drivers/usb/otg/fsl_otg.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/usb/otg/fsl_otg.c b/drivers/usb/otg/fsl_otg.c
index 85fac13012a4..9fe5eb7ae8ed 100644
--- a/drivers/usb/otg/fsl_otg.c
+++ b/drivers/usb/otg/fsl_otg.c
@@ -700,11 +700,6 @@ static void fsl_otg_event(struct work_struct *work)
else
fsm->a_conn = 0;
- if (otg->host)
- otg->host->is_b_host = fsm->id;
- if (otg->gadget)
- otg->gadget->is_a_peripheral = !fsm->id;
-
if (fsm->id) { /* switch to gadget */
fsl_otg_start_host(fsm, 0);
otg_drv_vbus(fsm, 0);
@@ -813,6 +808,14 @@ irqreturn_t fsl_otg_isr(int irq, void *dev_id)
fotg->fsm.id = (otg_sc & OTGSC_STS_USB_ID) ? 1 : 0;
otg->default_a = (fotg->fsm.id == 0);
+ /* is_b_host, is_a_peripheral may be used at host/gadget driver
+ * so, assign them at irq, the otg event is scheduled too late
+ */
+ if (otg->host)
+ otg->host->is_b_host = fotg->fsm.id;
+ if (otg->gadget)
+ otg->gadget->is_a_peripheral = !(fotg->fsm.id);
+
/* process OTG interrupts */
if (otg_int_src) {
if (otg_int_src & OTGSC_INTSTS_USB_ID) {
@@ -951,6 +954,9 @@ int usb_otg_start(struct platform_device *pdev)
p_otg->dr_mem_map = (struct usb_dr_mmap *)usb_dr_regs;
pdata->regs = (void *)usb_dr_regs;
+ if (pdata->platform_init && pdata->platform_init(pdev) != 0)
+ return -EINVAL;
+
gpio_id = pdata->id_gpio;
/* request irq */
if (pdata->id_gpio == 0) {
@@ -970,9 +976,6 @@ int usb_otg_start(struct platform_device *pdev)
return status;
}
- if (pdata->platform_init && pdata->platform_init(pdev) != 0)
- return -EINVAL;
-
clk_stopped = false; /* platform_init will open the otg clk */
/* stop the controller */