From patchwork Mon Sep 17 08:50:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 1466191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 501DADFFFF for ; Mon, 17 Sep 2012 08:53:11 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TDX1l-0000BM-TV; Mon, 17 Sep 2012 08:50:01 +0000 Received: from co1ehsobe006.messaging.microsoft.com ([216.32.180.189] helo=co1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TDX1g-0000Ae-Tt for linux-arm-kernel@lists.infradead.org; Mon, 17 Sep 2012 08:49:59 +0000 Received: from mail179-co1-R.bigfish.com (10.243.78.233) by CO1EHSOBE006.bigfish.com (10.243.66.69) with Microsoft SMTP Server id 14.1.225.23; Mon, 17 Sep 2012 08:49:53 +0000 Received: from mail179-co1 (localhost [127.0.0.1]) by mail179-co1-R.bigfish.com (Postfix) with ESMTP id E805E64014D; Mon, 17 Sep 2012 08:49:52 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1202h1d1ah1d2ahzz8275bhz2dh2a8h668h839hd24he5bhf0ah107ah1288h12a5h12a9h12bdh12e5h1155h) Received: from mail179-co1 (localhost.localdomain [127.0.0.1]) by mail179-co1 (MessageSwitch) id 1347871791778637_20084; Mon, 17 Sep 2012 08:49:51 +0000 (UTC) Received: from CO1EHSMHS029.bigfish.com (unknown [10.243.78.229]) by mail179-co1.bigfish.com (Postfix) with ESMTP id B0575580045; Mon, 17 Sep 2012 08:49:51 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS029.bigfish.com (10.243.66.39) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 17 Sep 2012 08:49:51 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-005.039d.mgd.msft.net (10.84.1.17) with Microsoft SMTP Server (TLS) id 14.2.309.3; Mon, 17 Sep 2012 03:49:49 -0500 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q8H8ndS5000542; Mon, 17 Sep 2012 01:49:42 -0700 From: Richard Zhao To: , Subject: [PATCH] USB: chipidea: use OTGSC_BSV to detect vbus valid Date: Mon, 17 Sep 2012 16:50:21 +0800 Message-ID: <1347871821-14643-1-git-send-email-richard.zhao@freescale.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.32.180.189 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: marex@denx.de, B20596@freescale.com, dong.aisheng@linaro.org, fabio.estevam@freescale.com, alexander.shishkin@linux.intel.com, B29397@freescale.com, balbi@ti.com, stern@rowland.harvard.edu, kernel@pengutronix.de, gregkh@linuxfoundation.org, richard.zhao@freescale.com, shawn.guo@linaro.org, mkl@pengutronix.de, linuxzsc@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org OTGSC_AVVIS cannot be set when vbus voltage goes valid or invalid on imx, so convert to use OTGSC_BSV. OTGSC_BSVIE and OTGSC_BSVIS is not cleared when hw_device_reset, so we don't need to call hw_enable_vbus_intr after hw_device_reset. Signed-off-by: Richard Zhao --- drivers/usb/chipidea/udc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 2f45bba..b158a04 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -307,14 +307,13 @@ static u32 hw_test_and_clear_intr_active(struct ci13xxx *ci) static void hw_enable_vbus_intr(struct ci13xxx *ci) { - hw_write(ci, OP_OTGSC, OTGSC_AVVIS, OTGSC_AVVIS); - hw_write(ci, OP_OTGSC, OTGSC_AVVIE, OTGSC_AVVIE); - queue_work(ci->wq, &ci->vbus_work); + hw_write(ci, OP_OTGSC, OTGSC_BSVIS, OTGSC_BSVIS); + hw_write(ci, OP_OTGSC, OTGSC_BSVIE, OTGSC_BSVIE); } static void hw_disable_vbus_intr(struct ci13xxx *ci) { - hw_write(ci, OP_OTGSC, OTGSC_AVVIE, 0); + hw_write(ci, OP_OTGSC, OTGSC_BSVIE, 0); } /** @@ -387,7 +386,7 @@ static void vbus_work(struct work_struct *work) { struct ci13xxx *ci = container_of(work, struct ci13xxx, vbus_work); - if (hw_read(ci, OP_OTGSC, OTGSC_AVV)) + if (hw_read(ci, OP_OTGSC, OTGSC_BSV)) usb_gadget_vbus_connect(&ci->gadget); else usb_gadget_vbus_disconnect(&ci->gadget); @@ -1392,7 +1391,6 @@ static int ci13xxx_vbus_session(struct usb_gadget *_gadget, int is_active) if (is_active) { pm_runtime_get_sync(&_gadget->dev); hw_device_reset(ci, USBMODE_CM_DC); - hw_enable_vbus_intr(ci); hw_device_state(ci, ci->ep0out->qh.dma); } else { hw_device_state(ci, 0); @@ -1569,7 +1567,6 @@ static int ci13xxx_start(struct usb_gadget *gadget, if (ci->vbus_active) { if (ci->platdata->flags & CI13XXX_REGS_SHARED) { hw_device_reset(ci, USBMODE_CM_DC); - hw_enable_vbus_intr(ci); } } else { pm_runtime_put_sync(&ci->gadget.dev); @@ -1680,7 +1677,7 @@ static irqreturn_t udc_irq(struct ci13xxx *ci) intr = hw_read(ci, OP_OTGSC, ~0); hw_write(ci, OP_OTGSC, ~0, intr); - if (intr & (OTGSC_AVVIE & OTGSC_AVVIS)) + if ((intr & OTGSC_BSVIE) && (intr & OTGSC_BSVIS)) queue_work(ci->wq, &ci->vbus_work); spin_unlock(&ci->lock); @@ -1758,7 +1755,6 @@ static int udc_start(struct ci13xxx *ci) retval = hw_device_reset(ci, USBMODE_CM_DC); if (retval) goto put_transceiver; - hw_enable_vbus_intr(ci); } retval = device_register(&ci->gadget.dev); @@ -1782,6 +1778,9 @@ static int udc_start(struct ci13xxx *ci) if (retval) goto remove_trans; + queue_work(ci->wq, &ci->vbus_work); + hw_enable_vbus_intr(ci); + pm_runtime_no_callbacks(&ci->gadget.dev); pm_runtime_enable(&ci->gadget.dev);