From patchwork Sun Jun 26 07:28:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9199239 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 9635B60754 for ; Sun, 26 Jun 2016 07:35:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8714528544 for ; Sun, 26 Jun 2016 07:35:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7848E28530; Sun, 26 Jun 2016 07:35:18 +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 7BD7C28530 for ; Sun, 26 Jun 2016 07:35:17 +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 1bH4YC-0005aC-Nl; Sun, 26 Jun 2016 07:32:16 +0000 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bH4VQ-0001AV-0k for linux-arm-kernel@lists.infradead.org; Sun, 26 Jun 2016 07:29:25 +0000 Received: by mail-pf0-x22d.google.com with SMTP id h14so51896713pfe.1 for ; Sun, 26 Jun 2016 00:29:02 -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=TGqOiRd/uOdC5FZrHwX5ELr8t9DLnS+iQ4VZku05hbI=; b=KIaFPv/KtKuMvV/IzmQ0eeMq1gV6ZEFZ7s1u76t47tj9YfkSksf8a4vBTPuRXKKJHo js/egdvSLnM4i3Ki1DvXIGwdeUSCNZLy2MbN3YN5KjoQmOpuUvr/xTs4gSL0IBcxCW+A 3uD9xiLJeidSz3RZJ379RIMY9Oa15cEQR9snI= 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=TGqOiRd/uOdC5FZrHwX5ELr8t9DLnS+iQ4VZku05hbI=; b=Az3//pJzoxNYwLbotBLMYsT12ELXnDVpyyj/EyiGW6+Q9hMXGkUQS+nGtygywZOBNg hMVROSKeqVAyFuffb7PiCcEmzRcaNYSEbDA8A2nQcyemBudeq47yy50hMCD27oUDLNQJ 9PgzS+QXqaFto7seDiFHc2mE7c5f7vVP6e1lBoC1NQw1ZnSDfy9TbtKT3VVEWwguf1f3 8+RmIi2EZeF+M9ciEG0U7cOw/IIcmt05pvjbHNG9e7FhCNMhNLUOApEkK44qdSIg06Ur HYVvlTpJMOSjNwsNRRgPFTZPFRYfgWmptgppFS97KJ5kgmyn+CxIct8YyUtNve2L8efN 6Taw== X-Gm-Message-State: ALyK8tIB+AxwBTM8ugDr7zCTmj0lUxmFyd25TCgoB9kBJPmAzWMyDRV76t6pBhpNnA5lYBD5 X-Received: by 10.98.205.79 with SMTP id o76mr22027110pfg.37.1466926142417; Sun, 26 Jun 2016 00:29:02 -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.29.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 Jun 2016 00:29:02 -0700 (PDT) From: Stephen Boyd To: linux-usb@vger.kernel.org Subject: [PATCH 16/21] usb: chipidea: msm: Restore wrapper settings after reset Date: Sun, 26 Jun 2016 00:28:33 -0700 Message-Id: <20160626072838.28082-17-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_002924_231145_E41456DA X-CRM114-Status: GOOD ( 14.74 ) 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 When the RESET bit is set in the USBCMD register it resets quite a few of the wrapper's registers to their reset state. This includes the GENCONFIG and GENCONFIG2 registers. Currently this is done by the usb phy and ehci-msm drivers writing into the controller wrapper's MMIO address space. Let's consolidate the register writes into the wrapper driver instead so that we clearly split the wrapper from the phys. Cc: Peter Chen Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/ci_hdrc_msm.c | 46 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index df0f8b31db4f..cc6f9b0df9d5 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include "ci.h" @@ -21,11 +23,22 @@ #define HS_PHY_SEC_CTRL 0x0278 # define HS_PHY_DIG_CLAMP_N BIT(16) +#define HS_PHY_GENCONFIG 0x009c +# define HS_PHY_TXFIFO_IDLE_FORCE_DIS BIT(4) + +#define HS_PHY_GENCONFIG_2 0x00a0 +# define HS_PHY_SESS_VLD_CTRL_EN BIT(7) +# define HS_PHY_ULPI_TX_PKT_EN_CLR_FIX BIT(19) + +#define HSPHY_SESS_VLD_CTRL BIT(25) + struct ci_hdrc_msm { struct platform_device *ci; struct clk *core_clk; struct clk *iface_clk; + struct extcon_dev *vbus_edev; bool secondary_phy; + bool hsic; void __iomem *base; }; @@ -39,9 +52,26 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) dev_dbg(dev, "CI_HDRC_CONTROLLER_RESET_EVENT received\n"); /* use AHB transactor, allow posted data writes */ hw_write_id_reg(ci, HS_PHY_AHB_MODE, 0xffffffff, 0x8); + /* workaround for rx buffer collision issue */ + hw_write_id_reg(ci, HS_PHY_GENCONFIG, + HS_PHY_TXFIFO_IDLE_FORCE_DIS, 0); + if (msm_ci->secondary_phy) hw_write_id_reg(ci, HS_PHY_SEC_CTRL, HS_PHY_DIG_CLAMP_N, HS_PHY_DIG_CLAMP_N); + + if (!msm_ci->hsic) + hw_write_id_reg(ci, HS_PHY_GENCONFIG_2, + HS_PHY_ULPI_TX_PKT_EN_CLR_FIX, 0); + + if (msm_ci->vbus_edev) { + hw_write_id_reg(ci, HS_PHY_GENCONFIG_2, + HS_PHY_SESS_VLD_CTRL_EN, + HS_PHY_SESS_VLD_CTRL_EN); + hw_write(ci, OP_USBCMD, HSPHY_SESS_VLD_CTRL, + HSPHY_SESS_VLD_CTRL); + + } break; default: dev_dbg(dev, "unknown ci_hdrc event\n"); @@ -112,6 +142,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) void __iomem *base; resource_size_t size; int ret; + struct device_node *ulpi_node, *phy_node; dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n"); @@ -141,6 +172,13 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) if (!base) return -ENOMEM; + ci->vbus_edev = extcon_get_edev_by_phandle(&pdev->dev, 0); + if (IS_ERR(ci->vbus_edev)) { + if (PTR_ERR(ci->vbus_edev) != -ENODEV) + return PTR_ERR(ci->vbus_edev); + ci->vbus_edev = NULL; + } + reset_control_assert(reset); usleep_range(10000, 12000); reset_control_deassert(reset); @@ -157,6 +195,14 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) if (ret) goto err_mux; + ulpi_node = of_find_node_by_name(pdev->dev.of_node, "ulpi"); + if (ulpi_node) { + phy_node = of_get_next_available_child(ulpi_node, NULL); + ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy"); + of_node_put(phy_node); + } + of_node_put(ulpi_node); + plat_ci = ci_hdrc_add_device(&pdev->dev, pdev->resource, pdev->num_resources, &ci_hdrc_msm_platdata); if (IS_ERR(plat_ci)) {