Commit 5af94053 authored by Luca Ceresoli's avatar Luca Ceresoli Committed by Lorenzo Pieralisi

PCI: dra7xx: Get an optional clock

If the clock is provided externally we need to make sure it is enabled
before starting PCI scan.

Link: https://lore.kernel.org/r/20210531085934.2662457-5-luca@lucaceresoli.netSigned-off-by: default avatarLuca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent b9a6943d
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* Authors: Kishon Vijay Abraham I <kishon@ti.com> * Authors: Kishon Vijay Abraham I <kishon@ti.com>
*/ */
#include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -90,6 +91,7 @@ struct dra7xx_pcie { ...@@ -90,6 +91,7 @@ struct dra7xx_pcie {
int phy_count; /* DT phy-names count */ int phy_count; /* DT phy-names count */
struct phy **phy; struct phy **phy;
struct irq_domain *irq_domain; struct irq_domain *irq_domain;
struct clk *clk;
enum dw_pcie_device_mode mode; enum dw_pcie_device_mode mode;
}; };
...@@ -741,6 +743,15 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) ...@@ -741,6 +743,15 @@ static int dra7xx_pcie_probe(struct platform_device *pdev)
if (!link) if (!link)
return -ENOMEM; return -ENOMEM;
dra7xx->clk = devm_clk_get_optional(dev, NULL);
if (IS_ERR(dra7xx->clk))
return dev_err_probe(dev, PTR_ERR(dra7xx->clk),
"clock request failed");
ret = clk_prepare_enable(dra7xx->clk);
if (ret)
return ret;
for (i = 0; i < phy_count; i++) { for (i = 0; i < phy_count; i++) {
snprintf(name, sizeof(name), "pcie-phy%d", i); snprintf(name, sizeof(name), "pcie-phy%d", i);
phy[i] = devm_phy_get(dev, name); phy[i] = devm_phy_get(dev, name);
...@@ -926,6 +937,8 @@ static void dra7xx_pcie_shutdown(struct platform_device *pdev) ...@@ -926,6 +937,8 @@ static void dra7xx_pcie_shutdown(struct platform_device *pdev)
pm_runtime_disable(dev); pm_runtime_disable(dev);
dra7xx_pcie_disable_phy(dra7xx); dra7xx_pcie_disable_phy(dra7xx);
clk_disable_unprepare(dra7xx->clk);
} }
static const struct dev_pm_ops dra7xx_pcie_pm_ops = { static const struct dev_pm_ops dra7xx_pcie_pm_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment