Skip to content

Commit f842d33

Browse files
PCI: j721e: Fix programming sequence of "strap" settings
The Cadence PCIe Controller integrated in the TI K3 SoCs supports both Root-Complex and Endpoint modes of operation. The Glue Layer allows "strapping" the Mode of operation of the Controller, the Link Speed and the Link Width. This is enabled by programming the "PCIEn_CTRL" register (n corresponds to the PCIe instance) within the CTRL_MMR memory-mapped register space. The "reset-values" of the registers are also different depending on the mode of operation. Since the PCIe Controller latches onto the "reset-values" immediately after being powered on, if the Glue Layer configuration is not done while the PCIe Controller is off, it will result in the PCIe Controller latching onto the wrong "reset-values". In practice, this will show up as a wrong representation of the PCIe Controller's capability structures in the PCIe Configuration Space. Some such capabilities which are supported by the PCIe Controller in the Root-Complex mode but are incorrectly latched onto as being unsupported are: - Link Bandwidth Notification - Alternate Routing ID (ARI) Forwarding Support - Next capability offset within Advanced Error Reporting (AER) capability Fix this by powering off the PCIe Controller before programming the "strap" settings and powering it on after that. The runtime PM APIs namely pm_runtime_put_sync() and pm_runtime_get_sync() will decrement and increment the usage counter respectively, causing GENPD to power off and power on the PCIe Controller. Fixes: f3e2591 ("PCI: j721e: Add TI J721E PCIe driver") Signed-off-by: Siddharth Vadapalli <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected]
1 parent 9a7f144 commit f842d33

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/pci/controller/cadence/pci-j721e.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,25 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
284284
if (!ret)
285285
offset = args.args[0];
286286

287+
/*
288+
* The PCIe Controller's registers have different "reset-values"
289+
* depending on the "strap" settings programmed into the PCIEn_CTRL
290+
* register within the CTRL_MMR memory-mapped register space.
291+
* The registers latch onto a "reset-value" based on the "strap"
292+
* settings sampled after the PCIe Controller is powered on.
293+
* To ensure that the "reset-values" are sampled accurately, power
294+
* off the PCIe Controller before programming the "strap" settings
295+
* and power it on after that. The runtime PM APIs namely
296+
* pm_runtime_put_sync() and pm_runtime_get_sync() will decrement and
297+
* increment the usage counter respectively, causing GENPD to power off
298+
* and power on the PCIe Controller.
299+
*/
300+
ret = pm_runtime_put_sync(dev);
301+
if (ret < 0) {
302+
dev_err(dev, "Failed to power off PCIe Controller\n");
303+
return ret;
304+
}
305+
287306
ret = j721e_pcie_set_mode(pcie, syscon, offset);
288307
if (ret < 0) {
289308
dev_err(dev, "Failed to set pci mode\n");
@@ -302,6 +321,12 @@ static int j721e_pcie_ctrl_init(struct j721e_pcie *pcie)
302321
return ret;
303322
}
304323

324+
ret = pm_runtime_get_sync(dev);
325+
if (ret < 0) {
326+
dev_err(dev, "Failed to power on PCIe Controller\n");
327+
return ret;
328+
}
329+
305330
/* Enable ACSPCIE refclk output if the optional property exists */
306331
syscon = syscon_regmap_lookup_by_phandle_optional(node,
307332
"ti,syscon-acspcie-proxy-ctrl");

0 commit comments

Comments
 (0)