From patchwork Sun Jun 26 07:28:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9199205 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 6DD8A60754 for ; Sun, 26 Jun 2016 07:33:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60C232853F for ; Sun, 26 Jun 2016 07:33:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5568728542; Sun, 26 Jun 2016 07:33:47 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 CD4312853F for ; Sun, 26 Jun 2016 07:33:46 +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 1bH4WF-0002wV-Fc; Sun, 26 Jun 2016 07:30:15 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bH4VC-0000zh-FS for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2016 07:29:12 +0000 Received: by mail-pa0-x22a.google.com with SMTP id b13so49585332pat.0 for ; Sun, 26 Jun 2016 00:28:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wkalcJ3AZZ4lqOKMwqfJk8TldloGuiijSg9UR2MFBbM=; b=GTNsUbNTJ0sT1+6pmDqIno8My1eml7R7ANrEbFf6X20uKxwr1R+/vRDs9yv7Yd3pr/ LQAf2kohGwFoc8CEb6FblFLVhJtT8SeOq8QKWGgnYonKJ0xzC/AP9I49nlZ1O6FwfGZq j0fO8tyeEDxe2nv8UwJ1rezHpS9My7HwumV0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wkalcJ3AZZ4lqOKMwqfJk8TldloGuiijSg9UR2MFBbM=; b=QIQqOjLeDk9RFTrrR4SUM9m12Dd2cNBjOenxtVKE5/mA9msJ35hIU6VSk/BDTcNfeq RcmZcrDI2DieDtFAuxeilgL7tGqn9A8ruUi0js2CURpZVg4FHjKGFS5yWLCdj/TLGr8L EtXHvIAe/UmkZf7qaxUc5OZejsJDUBLuE2/aDIn4Pxvi9CCEi4NX8S6WVzPf13Yu+b8/ D9taVLfpMgl95jprmusa/AmTMWHlNXWHYe2y7fdHClx8jsVrtuEc0WPMQbYoqvdNS3Dn Fr4zalVKos5plxf8iQoIyR+jU5mGrtYAWIkLqSvi8kYQOcsuFGcbgtx7ksaTegJC9JQo MzBw== X-Gm-Message-State: ALyK8tJ+DuJGF0hpnpNOpdZ8KvmrMyAVY72jnvSCcLh4fAM41w5/xwIuxaXOXfzjv0AYC0Sk X-Received: by 10.66.62.196 with SMTP id a4mr22687718pas.25.1466926129700; Sun, 26 Jun 2016 00:28:49 -0700 (PDT) Received: from localhost.localdomain (ip68-101-172-78.sd.sd.cox.net. [68.101.172.78]) by smtp.gmail.com with ESMTPSA id f138sm3790495pfa.17.2016.06.26.00.28.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jun 2016 00:28:49 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Subject: [PATCH 06/21] usb: chipidea: Initialize and reinitialize phy later Date: Sun, 26 Jun 2016 00:28:23 -0700 Message-Id: <20160626072838.28082-7-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d In-Reply-To: <20160626072838.28082-1-stephen.boyd@linaro.org> References: <20160626072838.28082-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160626_002910_629083_ECBB3EDA X-CRM114-Status: GOOD ( 15.11 ) 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: Felipe Balbi , Arnd Bergmann , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Bjorn Andersson , Peter Chen , Greg Kroah-Hartman , Andy Gross , 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 ULPI phy on qcom platforms needs to be initialized and powered on after a USB reset and before we toggle the run/stop bit. Otherwise, the phy locks up and doesn't work properly. Move the phy initialization to a later point, and shut it down outside of driver remove so that the phy state is properly managed across role switches. Cc: Peter Chen Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/ci.h | 3 ++- drivers/usb/chipidea/core.c | 23 ++++++++++------------- drivers/usb/chipidea/host.c | 5 ++--- drivers/usb/chipidea/udc.c | 2 ++ 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/usb/chipidea/ci.h b/drivers/usb/chipidea/ci.h index cd414559040f..f87805235caa 100644 --- a/drivers/usb/chipidea/ci.h +++ b/drivers/usb/chipidea/ci.h @@ -431,7 +431,8 @@ u8 hw_port_test_get(struct ci_hdrc *ci); int hw_wait_reg(struct ci_hdrc *ci, enum ci_hw_regs reg, u32 mask, u32 value, unsigned int timeout_ms); -void ci_platform_configure(struct ci_hdrc *ci); +void ci_usb_phy_exit(struct ci_hdrc *ci); +int ci_platform_configure(struct ci_hdrc *ci); int dbg_create_files(struct ci_hdrc *ci); diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index 01390e02ee53..a01611c7f815 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c @@ -359,7 +359,7 @@ static int _ci_usb_phy_init(struct ci_hdrc *ci) * interfaces * @ci: the controller */ -static void ci_usb_phy_exit(struct ci_hdrc *ci) +void ci_usb_phy_exit(struct ci_hdrc *ci) { if (ci->phy) { phy_power_off(ci->phy); @@ -412,9 +412,14 @@ static int ci_usb_phy_init(struct ci_hdrc *ci) * @ci: the controller * */ -void ci_platform_configure(struct ci_hdrc *ci) +int ci_platform_configure(struct ci_hdrc *ci) { bool is_device_mode, is_host_mode; + int ret; + + ret = ci_usb_phy_init(ci); + if (ret) + return ret; is_device_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_DC; is_host_mode = hw_read(ci, OP_USBMODE, USBMODE_CM) == USBMODE_CM_HC; @@ -453,6 +458,8 @@ void ci_platform_configure(struct ci_hdrc *ci) hw_write(ci, OP_BURSTSIZE, RX_BURST_MASK, ci->platdata->rx_burst_size); } + + return 0; } /** @@ -511,9 +518,7 @@ int hw_device_reset(struct ci_hdrc *ci) return -ENODEV; } - ci_platform_configure(ci); - - return 0; + return ci_platform_configure(ci); } static irqreturn_t ci_irq(int irq, void *data) @@ -917,12 +922,6 @@ static int ci_hdrc_probe(struct platform_device *pdev) ci->usb_phy = NULL; } - ret = ci_usb_phy_init(ci); - if (ret) { - dev_err(dev, "unable to init phy: %d\n", ret); - return ret; - } - ci->hw_bank.phys = res->start; ci->irq = platform_get_irq(pdev, 0); @@ -1025,7 +1024,6 @@ static int ci_hdrc_probe(struct platform_device *pdev) stop: ci_role_destroy(ci); deinit_phy: - ci_usb_phy_exit(ci); return ret; } @@ -1044,7 +1042,6 @@ static int ci_hdrc_remove(struct platform_device *pdev) ci_extcon_unregister(ci); ci_role_destroy(ci); ci_hdrc_enter_lpm(ci, true); - ci_usb_phy_exit(ci); return 0; } diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 053bac9d983c..523c155daea8 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c @@ -87,9 +87,7 @@ static int ehci_ci_reset(struct usb_hcd *hcd) if (ret) return ret; - ci_platform_configure(ci); - - return ret; + return ci_platform_configure(ci); } static const struct ehci_driver_overrides ehci_ci_overrides = { @@ -186,6 +184,7 @@ static void host_stop(struct ci_hdrc *ci) if (hcd) { usb_remove_hcd(hcd); usb_put_hcd(hcd); + ci_usb_phy_exit(ci); if (ci->platdata->reg_vbus && !ci_otg_is_fsm_mode(ci) && (ci->platdata->flags & CI_HDRC_TURN_VBUS_EARLY_ON)) regulator_disable(ci->platdata->reg_vbus); diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 065f5d97aa67..8f44e2d1e0c0 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1534,6 +1534,7 @@ static int ci_udc_vbus_session(struct usb_gadget *_gadget, int is_active) if (ci->driver) ci->driver->disconnect(&ci->gadget); hw_device_state(ci, 0); + ci_usb_phy_exit(ci); if (ci->platdata->notify_event) ci->platdata->notify_event(ci, CI_HDRC_CONTROLLER_STOPPED_EVENT); @@ -1794,6 +1795,7 @@ static int ci_udc_stop(struct usb_gadget *gadget) ci->platdata->notify_event(ci, CI_HDRC_CONTROLLER_STOPPED_EVENT); spin_unlock_irqrestore(&ci->lock, flags); + ci_usb_phy_exit(ci); _gadget_stop_activity(&ci->gadget); spin_lock_irqsave(&ci->lock, flags); pm_runtime_put(&ci->gadget.dev);