[SRU][E/linux-raspi2][PATCH] usb: xhci: Raspberry Pi FW loader for VIA VL805
Juerg Haefliger
juerg.haefliger at canonical.com
Sat Jul 11 06:00:49 UTC 2020
From: Tim Gover <990920+timg236 at users.noreply.github.com>
BugLink: https://bugs.launchpad.net/bugs/1887156
The VL805 FW may either be loaded from an SPI EEPROM or alternatively
loaded directly by the VideoCore firmware. A PCI reset will reset
the VL805 XHCI controller on the Raspberry Pi4 requiring the firmware
to be reloaded if an SPI EEPROM is not present.
Use a VideoCore mailbox to trigger the loading of the VL805
firmware (if necessary) after a PCI reset.
Signed-off-by: Tim Gover <tim.gover at raspberrypi.org>
(cherry picked from commit 1e875bad827797253f1c0308fe384bbf48966ba1 rpi-5.4.y)
Signed-off-by: Juerg Haefliger <juergh at canonical.com>
---
drivers/usb/host/pci-quirks.c | 31 +++++++++++++++++++++-
include/soc/bcm2835/raspberrypi-firmware.h | 2 +-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index f6d04491df60..702d7015dfd1 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -18,7 +18,7 @@
#include <linux/dmi.h>
#include "pci-quirks.h"
#include "xhci-ext-caps.h"
-
+#include <soc/bcm2835/raspberrypi-firmware.h>
#define UHCI_USBLEGSUP 0xc0 /* legacy support */
#define UHCI_USBCMD 0 /* command register */
@@ -630,6 +630,32 @@ bool usb_amd_pt_check_port(struct device *device, int port)
}
EXPORT_SYMBOL_GPL(usb_amd_pt_check_port);
+/* The VL805 firmware may either be loaded from an EEPROM or by the BIOS into
+ * memory. If run from memory it must be reloaded after a PCI fundmental reset.
+ * The Raspberry Pi firmware acts as the BIOS in this case.
+ */
+static void usb_vl805_init(struct pci_dev *pdev)
+{
+#if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE)
+ struct rpi_firmware *fw;
+ struct {
+ u32 dev_addr;
+ } packet;
+ int ret;
+
+ fw = rpi_firmware_get(NULL);
+ if (!fw)
+ return;
+
+ packet.dev_addr = (pdev->bus->number << 20) |
+ (PCI_SLOT(pdev->devfn) << 15) | (PCI_FUNC(pdev->devfn) << 12);
+
+ dev_dbg(&pdev->dev, "RPI_FIRMWARE_NOTIFY_XHCI_RESET %x", packet.dev_addr);
+ ret = rpi_firmware_property(fw, RPI_FIRMWARE_NOTIFY_XHCI_RESET,
+ &packet, sizeof(packet));
+#endif
+}
+
/*
* Make sure the controller is completely inactive, unable to
* generate interrupts or do DMA.
@@ -1207,6 +1233,9 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
if (pdev->vendor == PCI_VENDOR_ID_INTEL)
usb_enable_intel_xhci_ports(pdev);
+ if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)
+ usb_vl805_init(pdev);
+
op_reg_base = base + XHCI_HC_LENGTH(readl(base));
/* Wait for the host controller to be ready before writing any
diff --git a/include/soc/bcm2835/raspberrypi-firmware.h b/include/soc/bcm2835/raspberrypi-firmware.h
index ae71820af8e5..05c6989ec4c6 100644
--- a/include/soc/bcm2835/raspberrypi-firmware.h
+++ b/include/soc/bcm2835/raspberrypi-firmware.h
@@ -95,7 +95,7 @@ enum rpi_firmware_property_tag {
RPI_FIRMWARE_SET_PERIPH_REG = 0x00038045,
RPI_FIRMWARE_GET_POE_HAT_VAL = 0x00030049,
RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00030050,
-
+ RPI_FIRMWARE_NOTIFY_XHCI_RESET = 0x00030058,
/* Dispmanx TAGS */
RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001,
--
2.20.1
More information about the kernel-team
mailing list