From cac6e02a68ce8e08d7a4e4682012befcaa388af4 Mon Sep 17 00:00:00 2001 From: Li Jun Date: Tue, 27 Jan 2015 15:01:57 +0800 Subject: [PATCH] MLK-10101-3 usb: chipidea: otg: enable BSV irq when OTG B-device in host mode When B-device in host mode, if Vbus is off by A-device or A-device is removed, B-device should update charger status correctly. This patch enables BSV irq for B-device in all states, so the charger connection and removal can be early handled by BSV change irq. Signed-off-by: Li Jun (cherry picked from commit eb7c192ce6ce077471dfdcdc4eb6cc9da4a7c01a) --- drivers/usb/chipidea/udc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index a5f1d03d2e64..0612baa65b95 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -2018,8 +2018,12 @@ void ci_hdrc_gadget_connect(struct usb_gadget *gadget, int is_active) static int udc_id_switch_for_device(struct ci_hdrc *ci) { - if (ci->is_otg) - /* Clear and enable BSV irq */ + if (!ci->is_otg) + return 0; + + /* Clear and enable BSV irq for peripheral or OTG B-device */ + if (!ci_otg_is_fsm_mode(ci) || + ci->fsm.otg->state <= OTG_STATE_B_HOST) hw_write_otgsc(ci, OTGSC_BSVIS | OTGSC_BSVIE, OTGSC_BSVIS | OTGSC_BSVIE); @@ -2028,11 +2032,14 @@ static int udc_id_switch_for_device(struct ci_hdrc *ci) static void udc_id_switch_for_host(struct ci_hdrc *ci) { + if (!ci->is_otg) + return; /* - * host doesn't care B_SESSION_VALID event + * Host or OTG A-device doesn't care B_SESSION_VALID event * so clear and disbale BSV irq */ - if (ci->is_otg) + if (!ci_otg_is_fsm_mode(ci) || + ci->fsm.otg->state > OTG_STATE_B_HOST) hw_write_otgsc(ci, OTGSC_BSVIE | OTGSC_BSVIS, OTGSC_BSVIS); } -- 2.17.1