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: 70858 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp554700qgy; Sun, 26 Jun 2016 00:29:21 -0700 (PDT) X-Received: by 10.98.57.12 with SMTP id g12mr22339493pfa.119.1466926161879; Sun, 26 Jun 2016 00:29:21 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si18076330paj.218.2016.06.26.00.29.21; Sun, 26 Jun 2016 00:29:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbcFZH3I (ORCPT + 8 others); Sun, 26 Jun 2016 03:29:08 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:33054 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752092AbcFZH2u (ORCPT ); Sun, 26 Jun 2016 03:28:50 -0400 Received: by mail-pa0-f49.google.com with SMTP id b13so49585334pat.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=BamaiXLdnjKehwdyGtZz2tNSXQWi8ou+mv9OmXc1Hni1kq86rFkhFhjBGH9LMlgXze sh+M9mjMOr0LSNO/FaQ+ToNBO4tgOK6fz4pBUpANTmJMhdzQMEoN/4FUH9qks3ecml2F 2sj6+nO8zwkgJAww93yEXMRB/fsuV0zWgCcL8JJqojVcZs307Z/a7c9d5UdhM9g/RlKi rf9lJTvRpvBabg1M+QfTxuLNvjl66cO4pLlv0TtDjG+d/rv5SHkgL09VYSV00zl2vgkk x7KHFhDUPLjRmopPwsNTQdh0bMdEjjMboEWAzqK6uLl3+SQ8C8QQuHn/oXZbKuWUaGF4 LudA== X-Gm-Message-State: ALyK8tKC6OFpNY7OdE5r+3Z3DpMY/tjKkneRlDZEOJbldFH1C2b/RVt09d+bW7SFIqIJCE4l 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Andy Gross , Bjorn Andersson , Neil Armstrong , Arnd Bergmann , Felipe Balbi , Peter Chen , Greg Kroah-Hartman 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> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org 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(-) -- 2.9.0.rc2.8.ga28705d -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" 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/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);