From patchwork Mon Jul 11 22:43:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dima Zavin X-Patchwork-Id: 966722 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6BMiAte011819 for ; Mon, 11 Jul 2011 22:44:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758277Ab1GKWoG (ORCPT ); Mon, 11 Jul 2011 18:44:06 -0400 Received: from smtp-out.google.com ([74.125.121.67]:11625 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758177Ab1GKWoE (ORCPT ); Mon, 11 Jul 2011 18:44:04 -0400 Received: from hpaq1.eem.corp.google.com (hpaq1.eem.corp.google.com [172.25.149.1]) by smtp-out.google.com with ESMTP id p6BMi0Wc019786; Mon, 11 Jul 2011 15:44:00 -0700 Received: from dima.mtv.corp.google.com (dima.mtv.corp.google.com [172.18.102.73]) by hpaq1.eem.corp.google.com with ESMTP id p6BMhwEW013809; Mon, 11 Jul 2011 15:43:59 -0700 Received: by dima.mtv.corp.google.com (Postfix, from userid 17275) id 6CC02D1B12; Mon, 11 Jul 2011 15:43:58 -0700 (PDT) From: Dima Zavin To: Felipe Balbi Cc: linux-omap@vger.kernel.org, linux-usb@vger.kernel.org, Dima Zavin Subject: [PATCH] usb: musb: omap2430: handle charger OTG xceiver event Date: Mon, 11 Jul 2011 15:43:17 -0700 Message-Id: <1310424197-22909-1-git-send-email-dima@android.com> X-Mailer: git-send-email 1.7.3.1 X-System-Of-Record: true Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 11 Jul 2011 22:44:10 +0000 (UTC) Set a flag on OTG charger event and check it on cable remove event (i.e. USB_EVENT_NONE). This way we will not need to power up the PHY when an external charger is detected by the transceiver itself. Signed-off-by: Dima Zavin --- drivers/usb/musb/musb_core.h | 1 + drivers/usb/musb/omap2430.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 0e053b5..f65269d 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -497,6 +497,7 @@ struct musb { struct usb_gadget g; /* the gadget */ struct usb_gadget_driver *gadget_driver; /* its driver */ #endif + bool is_ac_charger:1; /* * FIXME: Remove this flag. diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index c5d4c44..ac4cfbc 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -257,6 +257,11 @@ static int musb_otg_notifications(struct notifier_block *nb, } break; + case USB_EVENT_CHARGER: + dev_dbg(musb->controller, "Dedicated charger connect\n"); + musb->is_ac_charger = true; + break; + case USB_EVENT_VBUS: dev_dbg(musb->controller, "VBUS Connect\n"); @@ -268,6 +273,13 @@ static int musb_otg_notifications(struct notifier_block *nb, break; case USB_EVENT_NONE: + if (musb->is_ac_charger) { + dev_dbg(musb->controller, + "Dedicated charger disconnect\n"); + musb->is_ac_charger = false; + break; + } + dev_dbg(musb->controller, "VBUS Disconnect\n"); #ifdef CONFIG_USB_GADGET_MUSB_HDRC