Skip to content

Commit a86ca86

Browse files
Vidya Sagarbjorn-helgaas
authored andcommitted
PCI: tegra194: Add core monitor clock support
Add support for Tegra PCIe core clock monitoring. Monitoring tracks rate changes that may occur due to link speed changes and is useful for detecting core clock changes not initiated by software. Parse the monitor clock from device tree and enable it when present. Signed-off-by: Vidya Sagar <vidyas@nvidia.com> Signed-off-by: Manikanta Maddireddy <mmaddireddy@nvidia.com> Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Link: https://patch.msgid.link/20260324191000.1095768-8-mmaddireddy@nvidia.com
1 parent 5aed9ab commit a86ca86

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

drivers/pci/controller/dwc/pcie-tegra194.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct tegra_pcie_dw {
249249
struct resource *atu_dma_res;
250250
void __iomem *appl_base;
251251
struct clk *core_clk;
252+
struct clk *core_clk_m;
252253
struct reset_control *core_apb_rst;
253254
struct reset_control *core_rst;
254255
struct dw_pcie pci;
@@ -950,6 +951,8 @@ static int tegra_pcie_dw_host_init(struct dw_pcie_rp *pp)
950951
}
951952

952953
clk_set_rate(pcie->core_clk, GEN4_CORE_CLK_FREQ);
954+
if (clk_prepare_enable(pcie->core_clk_m))
955+
dev_err(pci->dev, "Failed to enable core monitor clock\n");
953956

954957
return 0;
955958
}
@@ -1022,6 +1025,12 @@ static int tegra_pcie_dw_start_link(struct dw_pcie *pci)
10221025
val &= ~PCI_DLF_EXCHANGE_ENABLE;
10231026
dw_pcie_writel_dbi(pci, offset + PCI_DLF_CAP, val);
10241027

1028+
/*
1029+
* core_clk_m is enabled as part of host_init callback in
1030+
* dw_pcie_host_init(). Disable the clock since below
1031+
* tegra_pcie_dw_host_init() will enable it again.
1032+
*/
1033+
clk_disable_unprepare(pcie->core_clk_m);
10251034
tegra_pcie_dw_host_init(pp);
10261035
dw_pcie_setup_rc(pp);
10271036

@@ -1615,6 +1624,7 @@ static void tegra_pcie_dw_pme_turnoff(struct tegra_pcie_dw *pcie)
16151624

16161625
static void tegra_pcie_deinit_controller(struct tegra_pcie_dw *pcie)
16171626
{
1627+
clk_disable_unprepare(pcie->core_clk_m);
16181628
dw_pcie_host_deinit(&pcie->pci.pp);
16191629
tegra_pcie_dw_pme_turnoff(pcie);
16201630
tegra_pcie_unconfig_controller(pcie);
@@ -2166,6 +2176,11 @@ static int tegra_pcie_dw_probe(struct platform_device *pdev)
21662176
return PTR_ERR(pcie->core_clk);
21672177
}
21682178

2179+
pcie->core_clk_m = devm_clk_get_optional(dev, "core_m");
2180+
if (IS_ERR(pcie->core_clk_m))
2181+
return dev_err_probe(dev, PTR_ERR(pcie->core_clk_m),
2182+
"Failed to get monitor clock\n");
2183+
21692184
pcie->appl_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
21702185
"appl");
21712186
if (!pcie->appl_res) {
@@ -2362,6 +2377,7 @@ static int tegra_pcie_dw_suspend_noirq(struct device *dev)
23622377
if (!pcie->link_state)
23632378
return 0;
23642379

2380+
clk_disable_unprepare(pcie->core_clk_m);
23652381
tegra_pcie_dw_pme_turnoff(pcie);
23662382
tegra_pcie_unconfig_controller(pcie);
23672383

0 commit comments

Comments
 (0)