From patchwork Thu Aug 18 22:46:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 9289173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D658C607FD for ; Fri, 19 Aug 2016 02:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE97F2916A for ; Fri, 19 Aug 2016 02:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B314229175; Fri, 19 Aug 2016 02:24:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26FBA2916A for ; Fri, 19 Aug 2016 02:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754016AbcHSCXm (ORCPT ); Thu, 18 Aug 2016 22:23:42 -0400 Received: from muru.com ([72.249.23.125]:45917 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753911AbcHSCXW (ORCPT ); Thu, 18 Aug 2016 22:23:22 -0400 Received: from sampyla.monkeybrains.net (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 469CC85D8; Thu, 18 Aug 2016 22:47:32 +0000 (UTC) From: Tony Lindgren To: Bin Liu Cc: Andreas Kemnade , Felipe Balbi , George Cherian , Kishon Vijay Abraham I , Ivaylo Dimitrov , Ladislav Michl , Sergei Shtylyov , linux-usb@vger.kernel.org, linux-omap@vger.kernel.org Subject: [PATCH 2/4] usb: musb: Prepare dsps glue layer for PM runtime support Date: Thu, 18 Aug 2016 15:46:48 -0700 Message-Id: <1471560410-6428-3-git-send-email-tony@atomide.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1471560410-6428-1-git-send-email-tony@atomide.com> References: <1471560410-6428-1-git-send-email-tony@atomide.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We want to be polling the state when nothing is connected. Let's change the polling logic in preparation for PM runtime support. Signed-off-by: Tony Lindgren --- drivers/usb/musb/musb_dsps.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 2537179..ec0369b 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -247,6 +247,10 @@ static void otg_timer(unsigned long _musb) spin_lock_irqsave(&musb->lock, flags); switch (musb->xceiv->otg->state) { + case OTG_STATE_A_WAIT_VRISE: + mod_timer(&glue->timer, jiffies + + msecs_to_jiffies(wrp->poll_timeout)); + break; case OTG_STATE_A_WAIT_BCON: musb_writeb(musb->mregs, MUSB_DEVCTL, 0); skip_session = 1; @@ -338,7 +342,8 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) MUSB_HST_MODE(musb); musb->xceiv->otg->default_a = 1; musb->xceiv->otg->state = OTG_STATE_A_WAIT_VRISE; - del_timer(&glue->timer); + mod_timer(&glue->timer, jiffies + + msecs_to_jiffies(wrp->poll_timeout)); } else { musb->is_active = 0; MUSB_DEV_MODE(musb); @@ -358,11 +363,17 @@ static irqreturn_t dsps_interrupt(int irq, void *hci) if (musb->int_tx || musb->int_rx || musb->int_usb) ret |= musb_interrupt(musb); - /* Poll for ID change in OTG port mode */ - if (musb->xceiv->otg->state == OTG_STATE_B_IDLE && - musb->port_mode == MUSB_PORT_MODE_DUAL_ROLE) + /* Poll for ID change and connect */ + switch (musb->xceiv->otg->state) { + case OTG_STATE_B_IDLE: + case OTG_STATE_A_WAIT_BCON: mod_timer(&glue->timer, jiffies + - msecs_to_jiffies(wrp->poll_timeout)); + msecs_to_jiffies(wrp->poll_timeout)); + break; + default: + break; + } + out: spin_unlock_irqrestore(&musb->lock, flags); @@ -461,6 +472,9 @@ static int dsps_musb_init(struct musb *musb) musb_writeb(musb->mregs, MUSB_BABBLE_CTL, val); } + mod_timer(&glue->timer, jiffies + + msecs_to_jiffies(glue->wrp->poll_timeout)); + return dsps_musb_dbg_init(musb, glue); }