From patchwork Mon Feb 13 08:26:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 9569005 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 4E5C260572 for ; Mon, 13 Feb 2017 08:26:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C95A2624A for ; Mon, 13 Feb 2017 08:26:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FA9727F8C; Mon, 13 Feb 2017 08:26:59 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23D482624A for ; Mon, 13 Feb 2017 08:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752528AbdBMI02 (ORCPT ); Mon, 13 Feb 2017 03:26:28 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:49374 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbdBMI0U (ORCPT ); Mon, 13 Feb 2017 03:26:20 -0500 Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OLB021XW0RT8I20@mailout2.samsung.com>; Mon, 13 Feb 2017 17:26:17 +0900 (KST) Received: from epsmges5p4.samsung.com (unknown [182.195.40.69]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20170213082616epcas1p2139973f5a0792a3f17fa182bc4e603cf~iy1E3cw4I0414604146epcas1p2c; Mon, 13 Feb 2017 08:26:16 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p4.samsung.com (EPCPMTA) with SMTP id 33.15.04777.8AD61A85; Mon, 13 Feb 2017 17:26:16 +0900 (KST) Received: from epcpsbgm2new.samsung.com (u27.gpu120.samsung.co.kr [203.254.230.27]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20170213082616epcas5p2a20cca498e9ddde7c5d3f7664fb8606e~iy1EP-uZ-1264912649epcas5p2X; Mon, 13 Feb 2017 08:26:16 +0000 (GMT) X-AuditID: b6c32a58-f79746d0000012a9-8b-58a16da84cd2 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 7C.E2.06428.7AD61A85; Mon, 13 Feb 2017 17:26:15 +0900 (KST) Received: from localhost.localdomain ([10.113.62.216]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OLB000LO0RQDO60@mmp1.samsung.com>; Mon, 13 Feb 2017 17:26:15 +0900 (KST) From: Jaehoon Chung To: linux-pci@vger.kernel.org Cc: bhelgaas@google.com, krzk@kernel.org, linux-kernel@vger.kernel.org, jingoohan1@gmail.com, javier@osg.samsung.com, kgene@kernel.org, linux-samsung-soc@vger.kernel.org, cpgs@samsung.com, niyas.ahmed@samsung.com, alim.akhtar@samsung.com, pankaj.dubey@samsung.com, kishon@ti.com, devicetree@vger.kernel.org, mark.rutland@arm.com, vivek.gautam@codeaurora.org, robh+dt@kernel.org, Jaehoon Chung Subject: [PATCH V3 4/4] PCI: exynos: support the using PHY generic framework Date: Mon, 13 Feb 2017 17:26:13 +0900 Message-id: <20170213082613.19628-5-jh80.chung@samsung.com> X-Mailer: git-send-email 2.10.2 In-reply-to: <20170213082613.19628-1-jh80.chung@samsung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170213082616epcas5p2a20cca498e9ddde7c5d3f7664fb8606e X-Msg-Generator: CA X-Sender-IP: 203.254.230.27 X-Local-Sender: =?UTF-8?B?7KCV7J6s7ZuIG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbUzUo7LGF7J6EKS/ssYXsnoQ=?= X-Global-Sender: =?UTF-8?B?SmFlaG9vbiBDaHVuZxtUaXplbiBQbGF0Zm9ybSBMYWIuG1Nh?= =?UTF-8?B?bXN1bmcgRWxlY3Ryb25pY3MbUzUvU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG1NUQUYbQzEwVjgxMTE=?= CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20170213082616epcas5p2a20cca498e9ddde7c5d3f7664fb8606e X-RootMTR: 20170213082616epcas5p2a20cca498e9ddde7c5d3f7664fb8606e References: <20170213082613.19628-1-jh80.chung@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Switch the pci-exynos driver to generic PHY framework. At the same time backward compatibility is preserved: Warning will be printed for old DTB. Refer to the binding file: - Documentation/devictree/bindings/pci/samsung,exynos5440-pcie.txt Signed-off-by: Jaehoon Chung Acked-by: Krzysztof Kozlowski Acked-by: Jingoo Han Reviewed-by: Pankaj Dubey Reviewed-by: Alim Akhtar Acked-by: Bjorn Helgaas --- Changelog on V3: - Changes the commit-message - Fixes the merge conflict Changelog on V2: - This patch is split from previous PATCH[1/4] - Maintain the backward compatibility - Adds 'using_phy' for cheching whether phy framework is used or not - Adds 'DEPRECATED' message for old dt-binding way drivers/pci/host/pci-exynos.c | 54 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c index 758906b..f6a8b6e 100644 --- a/drivers/pci/host/pci-exynos.c +++ b/drivers/pci/host/pci-exynos.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -110,6 +111,10 @@ struct exynos_pcie { struct exynos_pcie_clk_res *clk_res; const struct exynos_pcie_ops *ops; int reset_gpio; + + /* For Generic PHY Framework */ + bool using_phy; + struct phy *phy; }; struct exynos_pcie_ops { @@ -126,6 +131,10 @@ static int exynos5440_pcie_get_mem_resources(struct platform_device *pdev, struct resource *res; struct device *dev = ep->pp.dev; + /* If using the PHY framework, doesn't need to get other resource */ + if (ep->using_phy) + return 0; + ep->mem_res = devm_kzalloc(dev, sizeof(*ep->mem_res), GFP_KERNEL); if (!ep->mem_res) return -ENOMEM; @@ -396,10 +405,28 @@ static int exynos_pcie_establish_link(struct exynos_pcie *ep) } exynos_pcie_assert_core_reset(ep); - exynos_pcie_assert_phy_reset(ep); - exynos_pcie_deassert_phy_reset(ep); - exynos_pcie_power_on_phy(ep); - exynos_pcie_init_phy(ep); + + if (ep->using_phy) { + phy_reset(ep->phy); + + exynos_pcie_writel(ep->mem_res->elbi_base, 1, + PCIE_PWR_RESET); + + phy_power_on(ep->phy); + phy_init(ep->phy); + } else { + exynos_pcie_assert_phy_reset(ep); + exynos_pcie_deassert_phy_reset(ep); + exynos_pcie_power_on_phy(ep); + exynos_pcie_init_phy(ep); + + /* pulse for common reset */ + exynos_pcie_writel(ep->mem_res->block_base, 1, + PCIE_PHY_COMMON_RESET); + udelay(500); + exynos_pcie_writel(ep->mem_res->block_base, 0, + PCIE_PHY_COMMON_RESET); + } /* pulse for common reset */ exynos_pcie_writel(ep->mem_res->block_base, 1, PCIE_PHY_COMMON_RESET); @@ -418,6 +445,11 @@ static int exynos_pcie_establish_link(struct exynos_pcie *ep) if (!dw_pcie_wait_for_link(pp)) return 0; + if (ep->using_phy) { + phy_power_off(ep->phy); + return -ETIMEDOUT; + } + while (exynos_pcie_readl(ep->mem_res->phy_base, PCIE_PHY_PLL_LOCKED) == 0) { val = exynos_pcie_readl(ep->mem_res->block_base, @@ -624,6 +656,17 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) ep->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); + /* Assume that controller doesn't use the PHY framework */ + ep->using_phy = false; + + ep->phy = devm_of_phy_get(dev, np, NULL); + if (IS_ERR(ep->phy)) { + if (PTR_ERR(ep->phy) == -EPROBE_DEFER) + return PTR_ERR(ep->phy); + dev_warn(dev, "Use the 'phy' property. Current DT of pci-exynos was deprecated!!\n"); + } else + ep->using_phy = true; + if (ep->ops && ep->ops->get_mem_resources) { ret = ep->ops->get_mem_resources(pdev, ep); if (ret) @@ -647,6 +690,9 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) return 0; fail_probe: + if (ep->using_phy) + phy_exit(ep->phy); + if (ep->ops && ep->ops->deinit_clk_resources) ep->ops->deinit_clk_resources(ep); return ret;