From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S940328AbdAINnK (ORCPT ); Mon, 9 Jan 2017 08:43:10 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:60327 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753506AbdAINlb (ORCPT ); Mon, 9 Jan 2017 08:41:31 -0500 X-AuditID: b6c32a37-f79606d000005083-b8-587393089727 Subject: Re: [PATCH V2 4/5] PCI: exynos: support the using PHY generic framework To: Jaehoon Chung , linux-pci@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, bhelgaas@google.com, robh+dt@kernel.org, mark.rutland@arm.com, kgene@kernel.org, krzk@kernel.org, kishon@ti.com, jingoohan1@gmail.com, vivek.gautam@codeaurora.org, pankaj.dubey@samsung.com, cpgs@samsung.com From: Alim Akhtar Message-id: Date: Mon, 09 Jan 2017 19:09:18 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-version: 1.0 In-reply-to: <20170104123435.30740-5-jh80.chung@samsung.com> Content-type: text/plain; charset=windows-1252; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrPJsWRmVeSWpSXmKPExsWy7bCmri7H5OIIg9dL+S2WNGVYvDykaTH/ yDlWixu/2lgtVnyZyW7R//g1s8WFpz1sFufPb2C3uLxrDpvF2XnH2SxmnN/HZLH0+kUmi0Vb v7BbtO49wm5x4ucOZgd+jzXz1jB6XO7rZfLYOesuu8eCTaUem1Z1snn0bVnF6HH8xnYmj8+b 5AI4olJtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1DS0tzJUU8hJzU22VXHwCdN0yc4BO V1IoS8wpBQoFJBYXK+nb2RTll5akKmTkF5fYKkUbGhrpGRqY6xkZGemZGMVaGZk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FvMTcVFulCF3fkCAlhbLEnFIgz8gADTg4 B7gHK+nbJbhl/L17gKVgnlrFwxlLWRsYr8t3MXJySAiYSBw8u5MJwhaTuHBvPRuILSSwjlHi bacZiC0sECTx5eVV5i5GDg4RAVeJ6Ysiuhi5gEoOMkoc2POLFcRhFtjOJHHy21l2kAY2AW2J u9O3gA3lFbCTuHrlJjOIzSKgInHx6Rd2kEGiAhESDYfTIUoEJU7OfMICYnMK2EhcWfMczGYW sJW4M3c3M4QtL7H97RzmCYz8s5C0zEJSNgtJ2QJG5lWMYqkFxbnpucUFBoZ6xYm5xaV56XrJ +bmbGIHRuu2wktgOxrYVXocYBTgYlXh4N0wqjhBiTSwrrsw9xCjBwawkwqs2ASjEm5JYWZVa lB9fVJqTWnyI0RToi4nMUqLJ+cBEklcSb2hiamFhYWJpbGxsYaIkzhs7/Vm4kEB6Yklqdmpq QWoRTB8TB6dUAyNHt17lJzcHO8PTEeYpRtcST6V8ZU+4l/VhxjxxRbMGM/UK/y18Ydyh8pW6 J4RP7YkLfvBr+ePUjr0z78VNMQ/gZlglN3ut83cGJwn1Ow/Li6UFYo8J7uhVSowzeWv9irnL 0WDhgwalHc6iX7KXbFppMjH4jbzL3qzndkdrVJ6aONayyf/fqsRSnJFoqMVcVJwIAG19jifs AgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170109134127epcas1p49fa4763d3c02a0c9dfbbbce53f9c7c01 X-Msg-Generator: CA X-Sender-IP: 182.195.34.22 X-Local-Sender: =?UTF-8?B?7JWM66a8G1NTSVItVHVybiBLZXkgU29sdXRpb25zG+yCvA==?= =?UTF-8?B?7ISx7KCE7J6QGy4vU2VuaW9yIENoaWVmIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?QUxJTSBBS0hUQVIbU1NJUi1UdXJuIEtleSBTb2x1dGlvbnMb?= =?UTF-8?B?U2Ftc3VuZyBFbGVjdHJvbmljcxsuL1NlbmlvciBDaGllZiBFbmdpbmVlcg==?= X-Sender-Code: =?UTF-8?B?QzEwG1NXQUhRG0MxMElEMDdJRDAxMDk5Nw==?= CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20170104123436epcas1p1651443c5fe13f67006864aed2f70fa9d X-RootMTR: 20170104123436epcas1p1651443c5fe13f67006864aed2f70fa9d References: <20170104123435.30740-1-jh80.chung@samsung.com> <20170104123435.30740-5-jh80.chung@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jaehoon, On 01/04/2017 06:04 PM, Jaehoon Chung wrote: > This patch is for using PHY generic framework. > To maintain backward compatibility, check whether phy is supported or > not with 'using_phy'. > > And if someone use the old dt-file, display the "deprecated" message. > But it's still working fine with it. > > Signed-off-by: Jaehoon Chung > --- Reviewed-by: Alim Akhtar > 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 | 61 +++++++++++++++++++++++++++++++++++-------- > 1 file changed, 50 insertions(+), 11 deletions(-) > > diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c > index feed0fd..34f2eed 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 { > @@ -135,6 +140,10 @@ static int exynos5440_pcie_get_mem_resources(struct platform_device *pdev, > if (IS_ERR(ep->mem_res->elbi_base)) > return PTR_ERR(ep->mem_res->elbi_base); > > + /* If using the PHY framework, doesn't need to get other resource */ > + if (ep->using_phy) > + return 0; > + > res = platform_get_resource(pdev, IORESOURCE_MEM, 1); > ep->mem_res->phy_base = devm_ioremap_resource(dev, res); > if (IS_ERR(ep->mem_res->phy_base)) > @@ -396,17 +405,28 @@ static int exynos_pcie_establish_link(struct exynos_pcie *exynos_pcie) > } > > exynos_pcie_assert_core_reset(exynos_pcie); > - exynos_pcie_assert_phy_reset(exynos_pcie); > - exynos_pcie_deassert_phy_reset(exynos_pcie); > - exynos_pcie_power_on_phy(exynos_pcie); > - exynos_pcie_init_phy(exynos_pcie); > - > - /* pulse for common reset */ > - exynos_pcie_writel(exynos_pcie->mem_res->block_base, 1, > - PCIE_PHY_COMMON_RESET); > - udelay(500); > - exynos_pcie_writel(exynos_pcie->mem_res->block_base, 0, > - PCIE_PHY_COMMON_RESET); > + > + if (exynos_pcie->using_phy) { > + phy_reset(exynos_pcie->phy); > + > + exynos_pcie_writel(exynos_pcie->mem_res->elbi_base, 1, > + PCIE_PWR_RESET); > + > + phy_power_on(exynos_pcie->phy); > + phy_init(exynos_pcie->phy); > + } else { > + exynos_pcie_assert_phy_reset(exynos_pcie); > + exynos_pcie_deassert_phy_reset(exynos_pcie); > + exynos_pcie_power_on_phy(exynos_pcie); > + exynos_pcie_init_phy(exynos_pcie); > + > + /* pulse for common reset */ > + exynos_pcie_writel(exynos_pcie->mem_res->block_base, 1, > + PCIE_PHY_COMMON_RESET); > + udelay(500); > + exynos_pcie_writel(exynos_pcie->mem_res->block_base, 0, > + PCIE_PHY_COMMON_RESET); > + } > > exynos_pcie_deassert_core_reset(exynos_pcie); > dw_pcie_setup_rc(pp); > @@ -420,6 +440,11 @@ static int exynos_pcie_establish_link(struct exynos_pcie *exynos_pcie) > if (!dw_pcie_wait_for_link(pp)) > return 0; > > + if (exynos_pcie->using_phy) { > + phy_power_off(exynos_pcie->phy); > + return -ETIMEDOUT; > + } > + > while (exynos_pcie_readl(exynos_pcie->mem_res->phy_base, > PCIE_PHY_PLL_LOCKED) == 0) { > val = exynos_pcie_readl(exynos_pcie->mem_res->block_base, > @@ -633,6 +658,17 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) > > exynos_pcie->reset_gpio = of_get_named_gpio(np, "reset-gpio", 0); > > + /* Assume that controller doesn't use the PHY framework */ > + exynos_pcie->using_phy = false; > + > + exynos_pcie->phy = devm_of_phy_get(dev, np, NULL); > + if (IS_ERR(exynos_pcie->phy)) { > + if (PTR_ERR(exynos_pcie->phy) == -EPROBE_DEFER) > + return PTR_ERR(exynos_pcie->phy); > + dev_warn(dev, "Use the 'phy' property. Current DT of pci-exynos was deprecated!!\n"); > + } else > + exynos_pcie->using_phy = true; > + > if (exynos_pcie->ops && exynos_pcie->ops->get_mem_resources) { > ret = exynos_pcie->ops->get_mem_resources(pdev, exynos_pcie); > if (ret) > @@ -657,6 +693,9 @@ static int __init exynos_pcie_probe(struct platform_device *pdev) > return 0; > > fail_probe: > + if (exynos_pcie->using_phy) > + phy_exit(exynos_pcie->phy); > + > if (exynos_pcie->ops && exynos_pcie->ops->deinit_clk_resources) > exynos_pcie->ops->deinit_clk_resources(exynos_pcie); > return ret; >