From f4f5fc8dabb91f95a7451aae2ddc6650596f36ac Mon Sep 17 00:00:00 2001 From: Li Jun Date: Wed, 11 Feb 2015 18:32:33 +0800 Subject: [PATCH] MLK-10243 usb: chipidea: udc: enable and disable BSV irq only for ID change Since BSV irq is only used for B-device, this patch correct the setting of BSVIE of otgsc only for case of ID change, that is: - In otg fsm mode, ID change from 0 to 1 means otg state from A_IDLE to B_IDLE; ID change from 1 to 0 means otg state from B_IDLE to A_IDLE, so only disable BSVIE if the current state is B_IDLE(to be update to A_IDLE), only enable BSVIE if the current state is A_IDLE(to be update to B_IDLE). - In non-otg-fsm mode, it's already correct. This fix the bug of MLK-10243. Signed-off-by: Li Jun Signed-off-by: Peter Chen (cherry picked from commit 8153cb550a007e1cd62dd4f043330c694cf62f23) --- drivers/usb/chipidea/udc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 0612baa65b95..b32d51cbc98e 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -2021,9 +2021,12 @@ static int udc_id_switch_for_device(struct ci_hdrc *ci) if (!ci->is_otg) return 0; - /* Clear and enable BSV irq for peripheral or OTG B-device */ + /* + * Clear and enable BSV irq for A-device switch to B-device + * (in otg fsm mode, means A_IDLE->B_DILE) due to ID change. + */ if (!ci_otg_is_fsm_mode(ci) || - ci->fsm.otg->state <= OTG_STATE_B_HOST) + ci->fsm.otg->state == OTG_STATE_A_IDLE) hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE, OTGSC_BSVIS | OTGSC_BSVIE); @@ -2034,12 +2037,13 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci) { if (!ci->is_otg) return; + /* - * Host or OTG A-device doesn't care B_SESSION_VALID event - * so clear and disbale BSV irq + * Clear and disbale BSV irq for B-device switch to A-device + * (in otg fsm mode, means B_IDLE->A_IDLE) due to ID change. */ if (!ci_otg_is_fsm_mode(ci) || - ci->fsm.otg->state > OTG_STATE_B_HOST) + ci->fsm.otg->state == OTG_STATE_B_IDLE) hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS); } -- 2.17.1