Re: [PATCH 3/7] PCI: imx6: Rework PHY search and mapping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 10, 2021 at 04:15:05PM +0200, Lucas Stach wrote:
> We don't need to have a phandle of the PHY, as we know the compatible
> of the node we are looking for. This will make it easier to put add
> more PHY handling for new generations later on, where the
> "fsl,imx7d-pcie-phy" phandle would be a misnomer.
> 
> Also we can use a helper function to get the resource for us,
> simplifying out driver code a bit.

Better yes, but really all the phy handling should be split out to 
its own driver even in the older h/w with shared phy registers.

Soon as there's a chip with 2 PCI hosts, you're going to need the phy 
binding.

> Signed-off-by: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
> ---
>  .../devicetree/bindings/pci/fsl,imx6q-pcie.txt  |  5 ++---
>  drivers/pci/controller/dwc/pci-imx6.c           | 17 +++++------------
>  2 files changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
> index de4b2baf91e8..308540df99ef 100644
> --- a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
> +++ b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
> @@ -54,7 +54,6 @@ Additional required properties for imx7d-pcie and imx8mq-pcie:
>  	       - "pciephy"
>  	       - "apps"
>  	       - "turnoff"
> -- fsl,imx7d-pcie-phy: A phandle to an fsl,imx7d-pcie-phy node.
>  
>  Additional required properties for imx8mq-pcie:
>  - clock-names: Must include the following additional entries:
> @@ -88,8 +87,8 @@ Example:
>  
>  * Freescale i.MX7d PCIe PHY
>  
> -This is the PHY associated with the IMX7d PCIe controller.  It's used by the
> -PCI-e controller via the fsl,imx7d-pcie-phy phandle.
> +This is the PHY associated with the IMX7d PCIe controller.  It's looked up by
> +the PCI-e controller via the fsl,imx7d-pcie-phy compatible.
>  
>  Required properties:
>  - compatible:
> diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c
> index 922c14361cd3..5e13758222e8 100644
> --- a/drivers/pci/controller/dwc/pci-imx6.c
> +++ b/drivers/pci/controller/dwc/pci-imx6.c
> @@ -555,7 +555,7 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie)
>  			writel(PCIE_PHY_CMN_REG26_ATT_MODE,
>  			       imx6_pcie->phy_base + PCIE_PHY_CMN_REG26);
>  		} else {
> -			dev_warn(dev, "Unable to apply ERR010728 workaround. DT missing fsl,imx7d-pcie-phy phandle ?\n");
> +			dev_warn(dev, "Unable to apply ERR010728 workaround. DT missing fsl,imx7d-pcie-phy node?\n");
>  		}
>  
>  		imx7d_pcie_wait_for_phy_pll_lock(imx6_pcie);
> @@ -970,7 +970,7 @@ static int imx6_pcie_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct dw_pcie *pci;
>  	struct imx6_pcie *imx6_pcie;
> -	struct device_node *np;
> +	struct device_node *np = NULL;
>  	struct resource *dbi_base;
>  	struct device_node *node = dev->of_node;
>  	int ret;
> @@ -991,17 +991,10 @@ static int imx6_pcie_probe(struct platform_device *pdev)
>  	imx6_pcie->pci = pci;
>  	imx6_pcie->drvdata = of_device_get_match_data(dev);
>  
> -	/* Find the PHY if one is defined, only imx7d uses it */
> -	np = of_parse_phandle(node, "fsl,imx7d-pcie-phy", 0);
> +	/* Find the PHY if one is present in DT, only imx7d uses it */
> +	np = of_find_compatible_node(NULL, NULL, "fsl,imx7d-pcie-phy");
>  	if (np) {
> -		struct resource res;
> -
> -		ret = of_address_to_resource(np, 0, &res);
> -		if (ret) {
> -			dev_err(dev, "Unable to map PCIe PHY\n");
> -			return ret;
> -		}
> -		imx6_pcie->phy_base = devm_ioremap_resource(dev, &res);
> +		imx6_pcie->phy_base = devm_of_iomap(dev, np, 0, NULL);
>  		if (IS_ERR(imx6_pcie->phy_base)) {
>  			dev_err(dev, "Unable to map PCIe PHY\n");
>  			return PTR_ERR(imx6_pcie->phy_base);
> -- 
> 2.29.2
> 



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux