From patchwork Fri May 12 13:40:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Liu X-Patchwork-Id: 9724205 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 322C160382 for ; Fri, 12 May 2017 13:40:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D85B286B6 for ; Fri, 12 May 2017 13:40:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 202A228776; Fri, 12 May 2017 13:40:59 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 10B1A286B6 for ; Fri, 12 May 2017 13:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755662AbdELNk4 (ORCPT ); Fri, 12 May 2017 09:40:56 -0400 Received: from fllnx210.ext.ti.com ([198.47.19.17]:20608 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755480AbdELNkz (ORCPT ); Fri, 12 May 2017 09:40:55 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id v4CDei94030264; Fri, 12 May 2017 08:40:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1494596444; bh=aQzgyQFdIPVoH/kEHuup0yYwQTBTDQft3QWq6hOhb98=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=bczogU80Js2+s0UcdxG9YhEczO7tmiIYmvk434aTs1yfOEEk5AKGmU6dCIa633zT4 EOVTkSzF5FaUf6D1f04iuZ/2nkHRq7V8JXeqA4ik5qBKCGdf1/qgtzkVs1Smmmlibl SgyuYppWep5Istw0h8uO5QmV2xcm7RncLRsmNoJ4= Received: from DFLE73.ent.ti.com (dfle73.ent.ti.com [128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4CDegM2013867; Fri, 12 May 2017 08:40:43 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.3.294.0; Fri, 12 May 2017 08:40:42 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v4CDeg0o008972; Fri, 12 May 2017 08:40:42 -0500 Date: Fri, 12 May 2017 08:40:42 -0500 From: Bin Liu To: Tony Lindgren CC: Moreno Bartalucci , Lars Melin , "linux-omap@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Alessio Igor Bogani Subject: Re: [PATCH] usb-musb: keep VBUS on when device is disconnected Message-ID: <20170512134042.GK7154@uda0271908> Mail-Followup-To: Bin Liu , Tony Lindgren , Moreno Bartalucci , Lars Melin , "linux-omap@vger.kernel.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Alessio Igor Bogani References: <20170511185038.GE7154@uda0271908> <20170511185528.GW3489@atomide.com> <20170511190100.GF7154@uda0271908> <20170511191005.GG7154@uda0271908> <20170511192013.GA4459@uda0271908> <20170511193810.GX3489@atomide.com> <20170511200220.GH7154@uda0271908> <20170511202306.GY3489@atomide.com> <20170511204406.GI7154@uda0271908> <20170511210628.GA3489@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170511210628.GA3489@atomide.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Thu, May 11, 2017 at 02:06:28PM -0700, Tony Lindgren wrote: > > Well maybe the minimal fix for now is just pretty much back to > square one of this thread. This should keep VBUS always on. > Then we can figure out some logic to cut VBUS later on. > > And yeah, the state machine is really hard to follow so some kind > of clean up would be nice. Okay, figured out why clearing session in OTG_STATE_A_WAIT_BCON, it is not for error condition handling (which is done in musb-core), but for going back to b_idle state from a_host for dual-role mode. otg_timer() (now is dsps_check_status()) was only called for otg port originally, so it wasn't an issue, until started calling it for host mode as well when runtime PM was added. > > Regards, > > Tony > > 8< ------------------- > --- a/drivers/usb/musb/musb_dsps.c > +++ b/drivers/usb/musb/musb_dsps.c > @@ -245,7 +245,6 @@ static int dsps_check_status(struct musb *musb, void *unused) > dsps_mod_timer_optional(glue); > break; > case OTG_STATE_A_WAIT_BCON: > - musb_writeb(musb->mregs, MUSB_DEVCTL, 0); > skip_session = 1; > /* fall */ > So the above patch breaks otg port when switching from host to device mode. The following change should solve it. But Tony do you see any way to improve it with glue->vbus_irq? Regards, -Bin. 8< -------------------- Acked-by: Tony Lindgren --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 9c7ee26ef388..465281244596 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -245,9 +245,14 @@ static int dsps_check_status(struct musb *musb, void *unused) dsps_mod_timer_optional(glue); break; case OTG_STATE_A_WAIT_BCON: + /* keep VBUS on for host-only mode */ + if (musb->port_mode == MUSB_PORT_MODE_HOST) { + dsps_mod_timer_optional(glue); + break; + } musb_writeb(musb->mregs, MUSB_DEVCTL, 0); skip_session = 1; - /* fall */ + /* fall through */ case OTG_STATE_A_IDLE: case OTG_STATE_B_IDLE: