All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Raspberry Pi 4 PCIe handover
@ 2021-01-14 15:48 Nicolas Saenz Julienne
  2021-01-14 15:49 ` [PATCH 1/2] usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag Nicolas Saenz Julienne
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-01-14 15:48 UTC (permalink / raw)
  To: u-boot

It's important for u-boot to properly reset RPi4's PCIe controller in
order for Linux to run the board's USB firmware load rountines.

---

Nicolas Saenz Julienne (2):
  usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag
  pci: brcmstb: Cleanup controller state before handover

 drivers/pci/pcie_brcmstb.c  | 20 ++++++++++++++++++++
 drivers/usb/host/xhci-pci.c |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

-- 
2.29.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag
  2021-01-14 15:48 [PATCH 0/2] Raspberry Pi 4 PCIe handover Nicolas Saenz Julienne
@ 2021-01-14 15:49 ` Nicolas Saenz Julienne
  2021-01-14 15:49 ` [PATCH 2/2] pci: brcmstb: Cleanup controller state before handover Nicolas Saenz Julienne
  2021-01-19 16:35 ` [PATCH 0/2] Raspberry Pi 4 PCIe handover Peter Robinson
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-01-14 15:49 UTC (permalink / raw)
  To: u-boot

The PCIe bus the controller is connected to might need to be removed
prior the handover. Make sure xhci-pci is also removed so as to avoid
unexpected timeouts or hangs.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/usb/host/xhci-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index 2b445f21b5..d626929953 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -61,7 +61,7 @@ U_BOOT_DRIVER(xhci_pci) = {
 	.ops	= &xhci_usb_ops,
 	.plat_auto	= sizeof(struct usb_plat),
 	.priv_auto	= sizeof(struct xhci_ctrl),
-	.flags	= DM_FLAG_ALLOC_PRIV_DMA,
+	.flags	= DM_FLAG_OS_PREPARE | DM_FLAG_ALLOC_PRIV_DMA,
 };
 
 static struct pci_device_id xhci_pci_supported[] = {
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] pci: brcmstb: Cleanup controller state before handover
  2021-01-14 15:48 [PATCH 0/2] Raspberry Pi 4 PCIe handover Nicolas Saenz Julienne
  2021-01-14 15:49 ` [PATCH 1/2] usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag Nicolas Saenz Julienne
@ 2021-01-14 15:49 ` Nicolas Saenz Julienne
  2021-01-19 16:35 ` [PATCH 0/2] Raspberry Pi 4 PCIe handover Peter Robinson
  2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Saenz Julienne @ 2021-01-14 15:49 UTC (permalink / raw)
  To: u-boot

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 bd645d7896..90225f6779 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_of_to_plat(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,
 	.of_to_plat	= brcm_pcie_of_to_plat,
 	.priv_auto	= sizeof(struct brcm_pcie),
+	.flags		= DM_FLAG_OS_PREPARE,
 };
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 0/2] Raspberry Pi 4 PCIe handover
  2021-01-14 15:48 [PATCH 0/2] Raspberry Pi 4 PCIe handover Nicolas Saenz Julienne
  2021-01-14 15:49 ` [PATCH 1/2] usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag Nicolas Saenz Julienne
  2021-01-14 15:49 ` [PATCH 2/2] pci: brcmstb: Cleanup controller state before handover Nicolas Saenz Julienne
@ 2021-01-19 16:35 ` Peter Robinson
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Robinson @ 2021-01-19 16:35 UTC (permalink / raw)
  To: u-boot

On Thu, Jan 14, 2021 at 3:49 PM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> It's important for u-boot to properly reset RPi4's PCIe controller in
> order for Linux to run the board's USB firmware load rountines.

For the series:
Tested-by: Peter Robinson <pbrobinson@gmail.com>

> ---
>
> Nicolas Saenz Julienne (2):
>   usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag
>   pci: brcmstb: Cleanup controller state before handover
>
>  drivers/pci/pcie_brcmstb.c  | 20 ++++++++++++++++++++
>  drivers/usb/host/xhci-pci.c |  2 +-
>  2 files changed, 21 insertions(+), 1 deletion(-)
>
> --
> 2.29.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-19 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-14 15:48 [PATCH 0/2] Raspberry Pi 4 PCIe handover Nicolas Saenz Julienne
2021-01-14 15:49 ` [PATCH 1/2] usb: xhci-pci: Add DM_FLAG_OS_PREPARE flag Nicolas Saenz Julienne
2021-01-14 15:49 ` [PATCH 2/2] pci: brcmstb: Cleanup controller state before handover Nicolas Saenz Julienne
2021-01-19 16:35 ` [PATCH 0/2] Raspberry Pi 4 PCIe handover Peter Robinson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.