u-boot/0031-pci-brcmstb-Cleanup-controller-stat.patch

56 lines
1.8 KiB
Diff

From 8566f4fb6d707b40121a02b081dadb558ae9ce66 Mon Sep 17 00:00:00 2001
From: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Date: Thu, 14 Jan 2021 16:49:01 +0100
Subject: [PATCH] pci: brcmstb: Cleanup controller state before handover
Make sure we handover the PCIe controller in a clean state. Some of the
devices hanging from the PCIe bus might need to be properly reset
through #PERST in order for Linux to be able to initialize them.
This is specially important in order to properly initialize Raspberry Pi
4 B and 400's USB chip.
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
drivers/pci/pcie_brcmstb.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/pci/pcie_brcmstb.c b/drivers/pci/pcie_brcmstb.c
index f6e8ad0d0a..c87a5dce4d 100644
--- a/drivers/pci/pcie_brcmstb.c
+++ b/drivers/pci/pcie_brcmstb.c
@@ -577,6 +577,24 @@ static int brcm_pcie_probe(struct udevice *dev)
return 0;
}
+static int brcm_pcie_remove(struct udevice *dev)
+{
+ struct brcm_pcie *pcie = dev_get_priv(dev);
+ void __iomem *base = pcie->base;
+
+ /* Assert fundamental reset */
+ setbits_le32(base + PCIE_RGR1_SW_INIT_1, RGR1_SW_INIT_1_PERST_MASK);
+
+ /* Turn off SerDes */
+ setbits_le32(base + PCIE_MISC_HARD_PCIE_HARD_DEBUG,
+ PCIE_HARD_DEBUG_SERDES_IDDQ_MASK);
+
+ /* Shutdown bridge */
+ setbits_le32(base + PCIE_RGR1_SW_INIT_1, RGR1_SW_INIT_1_INIT_MASK);
+
+ return 0;
+}
+
static int brcm_pcie_ofdata_to_platdata(struct udevice *dev)
{
struct brcm_pcie *pcie = dev_get_priv(dev);
@@ -616,6 +634,8 @@ U_BOOT_DRIVER(pcie_brcm_base) = {
.ops = &brcm_pcie_ops,
.of_match = brcm_pcie_ids,
.probe = brcm_pcie_probe,
+ .remove = brcm_pcie_remove,
.ofdata_to_platdata = brcm_pcie_ofdata_to_platdata,
.priv_auto_alloc_size = sizeof(struct brcm_pcie),
+ .flags = DM_FLAG_OS_PREPARE,
};