pci: brcmstb: Cleanup controller state before handover 55/267755/3 accepted/tizen/6.5/unified/20211213.212334 submit/tizen_6.5/20211213.042338
authorNicolas Saenz Julienne <nsaenzjulienne@suse.de>
Thu, 14 Jan 2021 15:49:01 +0000 (16:49 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 13 Dec 2021 02:01:49 +0000 (02:01 +0000)
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.

Change-Id: I1650975684d3c0315dac4dfe44f58f33e78ba0ad
Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/pci/pcie_brcmstb.c

index f6e8ad0d0a19ac75a96f64e5af5278658cbbabc5..d0b34ce25680a6751647021fae38d8a487bfe8c4 100644 (file)
@@ -577,7 +577,26 @@ static int brcm_pcie_probe(struct udevice *dev)
        return 0;
 }
 
-static int brcm_pcie_ofdata_to_platdata(struct udevice *dev)
+
+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_of_to_plat(struct udevice *dev)
 {
        struct brcm_pcie *pcie = dev_get_priv(dev);
        ofnode dn = dev_ofnode(dev);
@@ -616,6 +635,8 @@ U_BOOT_DRIVER(pcie_brcm_base) = {
        .ops                    = &brcm_pcie_ops,
        .of_match               = brcm_pcie_ids,
        .probe                  = brcm_pcie_probe,
-       .ofdata_to_platdata     = brcm_pcie_ofdata_to_platdata,
+       .remove                 = brcm_pcie_remove,
+       .ofdata_to_platdata     = brcm_pcie_of_to_plat,
        .priv_auto_alloc_size   = sizeof(struct brcm_pcie),
+       .flags          = DM_FLAG_OS_PREPARE,
 };