From patchwork Wed Dec 28 22:57:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9490801 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 88E3462AB0 for ; Wed, 28 Dec 2016 23:05:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FEBA26242 for ; Wed, 28 Dec 2016 23:05:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 610F926419; Wed, 28 Dec 2016 23:05:09 +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 852A926242 for ; Wed, 28 Dec 2016 23:05:05 +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 1cMNG5-0005fl-Fe; Wed, 28 Dec 2016 23:03:45 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cMNAT-0001Bg-Dj for linux-arm-kernel@bombadil.infradead.org; Wed, 28 Dec 2016 22:57:57 +0000 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]) by merlin.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cMNAR-0003l1-7m for linux-arm-kernel@lists.infradead.org; Wed, 28 Dec 2016 22:57:56 +0000 Received: by mail-pg0-x234.google.com with SMTP id i5so94981801pgh.2 for ; Wed, 28 Dec 2016 14:57:34 -0800 (PST) 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=uiPCap9vw0qopln027Q7P21/gL7YNr2TplyJKVbjDFI=; b=afaW7uFSZ+XqesHpEaXZrggUHrGXWBTRvzY1vs7o1WLfPBxKnn61J7uJBJ1DklUaFs puLPIplJQx645soDHMOOXYefwSsNUb6vXsSFSGDRyRYhZrYQdC30NCzXZuVRQnuE44dW opa3FHwZwDyVNDxQ9ktNZSFgSANaUhUnIwPgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uiPCap9vw0qopln027Q7P21/gL7YNr2TplyJKVbjDFI=; b=G+tzZnkExUrpaBLc92qetmyNAZ28Zk4tku3al9W3ekz5vHbqvjcc1t3vpfB6au1UJT 2KgQTp5nSHOq5FyJtfWVb144FoHWoZb7kY4/EAc3bpEginUCN9ma7M5ggxo6yRu+o2nj XGV4CN4fuhFFOLtlhndrpiyx37wN1byI1RQIpCzkYNMFOyNCkhY4dqDAI1pIuxDCuvfL 9mObdY9zTUI0TaRhl7+VXC1xTpwcNiD8W2QvGuit/lmYAoFEREF3PvJJ2ItTKolG3/a4 unkKzctyfzAfvRAd5hMmuAXAH7LyIBNJFLU9qSYtisRBiEuAdrxbO5sUJAm8hN41BZew NNAg== X-Gm-Message-State: AIkVDXIJ+7qdi3ngDfrZycFCFDm4N4gw/WxQnF9Tp45YQto47eDpXCuEH7wfYBn4s3PT/bgT X-Received: by 10.98.75.75 with SMTP id y72mr31867458pfa.23.1482965853163; Wed, 28 Dec 2016 14:57:33 -0800 (PST) Received: from localhost.localdomain (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id x4sm100355741pgc.14.2016.12.28.14.57.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Dec 2016 14:57:32 -0800 (PST) From: Stephen Boyd To: linux-usb@vger.kernel.org Subject: [PATCH v6 17/25] usb: chipidea: msm: Restore wrapper settings after reset Date: Wed, 28 Dec 2016 14:57:03 -0800 Message-Id: <20161228225711.698-18-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.10.0.297.gf6727b0 In-Reply-To: <20161228225711.698-1-stephen.boyd@linaro.org> References: <20161228225711.698-1-stephen.boyd@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161228_175755_365441_F2188A99 X-CRM114-Status: GOOD ( 14.13 ) 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. Acked-by: Peter Chen Cc: Greg Kroah-Hartman Signed-off-by: Stephen Boyd --- drivers/usb/chipidea/ci_hdrc_msm.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 4b0aadc2be2f..333817291798 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c @@ -14,11 +14,22 @@ #include #include #include +#include +#include #include "ci.h" #define HS_PHY_AHB_MODE 0x0098 +#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) + /* Vendor base starts at 0x200 beyond CI base */ #define HS_PHY_SEC_CTRL 0x0078 #define HS_PHY_DIG_CLAMP_N BIT(16) @@ -29,6 +40,7 @@ struct ci_hdrc_msm { struct clk *iface_clk; struct clk *fs_clk; bool secondary_phy; + bool hsic; void __iomem *base; }; @@ -48,6 +60,24 @@ static void ci_hdrc_msm_notify_event(struct ci_hdrc *ci, unsigned event) /* 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->hsic) + hw_write_id_reg(ci, HS_PHY_GENCONFIG_2, + HS_PHY_ULPI_TX_PKT_EN_CLR_FIX, 0); + + if (!IS_ERR(ci->platdata->vbus_extcon.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); + + } + usb_phy_init(ci->usb_phy); break; case CI_HDRC_CONTROLLER_STOPPED_EVENT: @@ -116,6 +146,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) struct reset_control *reset; struct resource *res; int ret; + struct device_node *ulpi_node, *phy_node; dev_dbg(&pdev->dev, "ci_hdrc_msm_probe\n"); @@ -181,6 +212,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);