From patchwork Sun Sep 18 16:50:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9337969 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 BC4166077F for ; Sun, 18 Sep 2016 16:52:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA4BC28993 for ; Sun, 18 Sep 2016 16:52:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EACD28C63; Sun, 18 Sep 2016 16:52:14 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A7F728993 for ; Sun, 18 Sep 2016 16:52:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1blfIo-000656-Ib; Sun, 18 Sep 2016 16:50:50 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1blfIj-000630-Mv for linux-arm-kernel@lists.infradead.org; Sun, 18 Sep 2016 16:50:46 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C07DC05AA43; Sun, 18 Sep 2016 16:50:24 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-5-65.ams2.redhat.com [10.36.5.65]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8IGoKhF030272; Sun, 18 Sep 2016 12:50:21 -0400 From: Hans de Goede To: Bin Liu , Kishon Vijay Abraham I Subject: [PATCH 1/2] phy-sun4i-usb: Add sun4i_usb_phy_force_session_end() function Date: Sun, 18 Sep 2016 18:50:17 +0200 Message-Id: <20160918165018.24547-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 18 Sep 2016 16:50:24 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160918_095045_805301_1CF50C6F X-CRM114-Status: GOOD ( 11.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Hans de Goede , Chen-Yu Tsai , Maxime Ripard , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The sunxi musb has a bug where sometimes it will generate a babble error on device disconnect instead of a disconnect irq. When this happens the musb-controller switches from host mode to device mode (it clears MUSB_DEVCTL_SESSION and sets MUSB_DEVCTL_BDEVICE) and gets stuck in this state. Clearing this requires reporting Vbus low for 200 or more ms, but on some devices Vbus is simply always high (host-only mode, no Vbus control). The phy-sun4i-usb code already has code to force a session end for devices without Vbus control. This commit adds a sun4i_usb_phy_force_session_end() function exporting this functionality to the sunxi-musb glue, so that it can force a session end to fixup the stuck state after a babble error. Signed-off-by: Hans de Goede --- drivers/phy/phy-sun4i-usb.c | 11 +++++++++++ include/linux/phy/phy-sun4i-usb.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index 43c0d98..06f4e11a 100644 --- a/drivers/phy/phy-sun4i-usb.c +++ b/drivers/phy/phy-sun4i-usb.c @@ -470,6 +470,17 @@ void sun4i_usb_phy_set_squelch_detect(struct phy *_phy, bool enabled) } EXPORT_SYMBOL_GPL(sun4i_usb_phy_set_squelch_detect); +void sun4i_usb_phy_force_session_end(struct phy *_phy) +{ + struct sun4i_usb_phy *phy = phy_get_drvdata(_phy); + struct sun4i_usb_phy_data *data = to_sun4i_usb_phy_data(phy); + + data->id_det = -1; + data->force_session_end = true; + queue_delayed_work(system_wq, &data->detect, 0); +} +EXPORT_SYMBOL_GPL(sun4i_usb_phy_force_session_end); + static const struct phy_ops sun4i_usb_phy_ops = { .init = sun4i_usb_phy_init, .exit = sun4i_usb_phy_exit, diff --git a/include/linux/phy/phy-sun4i-usb.h b/include/linux/phy/phy-sun4i-usb.h index 50aed92..3bb773f 100644 --- a/include/linux/phy/phy-sun4i-usb.h +++ b/include/linux/phy/phy-sun4i-usb.h @@ -23,4 +23,11 @@ */ void sun4i_usb_phy_set_squelch_detect(struct phy *phy, bool enabled); +/** + * sun4i_usb_force_session_end() - Force the current session to end + * by reporting VBus low for 200+ ms + * @phy: reference to a sun4i usb phy + */ +void sun4i_usb_phy_force_session_end(struct phy *phy); + #endif