summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Vasut <[email protected]>2025-09-18 18:36:00 +0200
committerMarek Vasut <[email protected]>2025-10-17 21:53:52 +0200
commit2b634a80b5ce92232f309fdd7d7864098ca7fb95 (patch)
tree47d85564966a97d0db08fbac8077bf280c141e2e
parentbf1d8c1fec863b7da2f0d1ed4bd5526275d70dc2 (diff)
pci: pcie-rcar-gen4: Shut down controller on link down and remove
In case the link is down, or the controller driver is removed before booting the next stage, shut down the PCIe link, put both the remote PCIe device and the controller into reset, and disable clock. This way, the hardware is not left active when not in use. Signed-off-by: Marek Vasut <[email protected]>
-rw-r--r--drivers/pci/pci-rcar-gen4.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/pci/pci-rcar-gen4.c b/drivers/pci/pci-rcar-gen4.c
index 1f41ce28b0b..e165271f58c 100644
--- a/drivers/pci/pci-rcar-gen4.c
+++ b/drivers/pci/pci-rcar-gen4.c
@@ -477,6 +477,10 @@ static int rcar_gen4_pcie_probe(struct udevice *dev)
if (!rcar_gen4_pcie_link_up(rcar)) {
printf("PCIE-%d: Link down\n", dev_seq(dev));
+ rcar_gen4_pcie_ltssm_control(rcar, false);
+ dm_gpio_set_value(&rcar->pe_rst, 1);
+ reset_assert(&rcar->pwr_rst);
+ clk_disable_unprepare(rcar->ref_clk);
return -ENODEV;
}
@@ -494,6 +498,26 @@ static int rcar_gen4_pcie_probe(struct udevice *dev)
}
/**
+ * rcar_gen4_pcie_remove() - Stop the PCIe bus active link
+ * @dev: A pointer to the device being operated on
+ *
+ * Stop an active link on the PCIe bus and deconfigure the controller.
+ *
+ * Return: 0 on success, else -ENODEV
+ */
+static int rcar_gen4_pcie_remove(struct udevice *dev)
+{
+ struct rcar_gen4_pcie *rcar = dev_get_priv(dev);
+
+ rcar_gen4_pcie_ltssm_control(rcar, false);
+ dm_gpio_set_value(&rcar->pe_rst, 1);
+ reset_assert(&rcar->pwr_rst);
+ clk_disable_unprepare(rcar->ref_clk);
+
+ return 0;
+}
+
+/**
* rcar_gen4_pcie_of_to_plat() - Translate from DT to device state
*
* @dev: A pointer to the device being operated on
@@ -566,5 +590,7 @@ U_BOOT_DRIVER(rcar_gen4_pcie) = {
.ops = &rcar_gen4_pcie_ops,
.of_to_plat = rcar_gen4_pcie_of_to_plat,
.probe = rcar_gen4_pcie_probe,
+ .remove = rcar_gen4_pcie_remove,
.priv_auto = sizeof(struct rcar_gen4_pcie),
+ .flags = DM_FLAG_ACTIVE_DMA,
};