Skip to content

Commit 36b447a

Browse files
timg236popcornmix
authored andcommitted
usb: xhci: Raspberry Pi FW loader for VIA VL805
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@raspberrypi.org>
1 parent 04b8b28 commit 36b447a

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎drivers/usb/host/pci-quirks.c‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <linux/dmi.h>
1919
#include "pci-quirks.h"
2020
#include "xhci-ext-caps.h"
21-
21+
#include <soc/bcm2835/raspberrypi-firmware.h>
2222

2323
#define UHCI_USBLEGSUP 0xc0 /* legacy support */
2424
#define UHCI_USBCMD 0 /* command register */
@@ -630,6 +630,32 @@ bool usb_amd_pt_check_port(struct device *device, int port)
630630
}
631631
EXPORT_SYMBOL_GPL(usb_amd_pt_check_port);
632632

633+
/* The VL805 firmware may either be loaded from an EEPROM or by the BIOS into
634+
* memory. If run from memory it must be reloaded after a PCI fundmental reset.
635+
* The Raspberry Pi firmware acts as the BIOS in this case.
636+
*/
637+
static void usb_vl805_init(struct pci_dev *pdev)
638+
{
639+
#if IS_ENABLED(CONFIG_RASPBERRYPI_FIRMWARE)
640+
struct rpi_firmware *fw;
641+
struct {
642+
u32 dev_addr;
643+
} packet;
644+
int ret;
645+
646+
fw = rpi_firmware_get(NULL);
647+
if (!fw)
648+
return;
649+
650+
packet.dev_addr = (pdev->bus->number << 20) |
651+
(PCI_SLOT(pdev->devfn) << 15) | (PCI_FUNC(pdev->devfn) << 12);
652+
653+
dev_dbg(&pdev->dev, "RPI_FIRMWARE_NOTIFY_XHCI_RESET %x", packet.dev_addr);
654+
ret = rpi_firmware_property(fw, RPI_FIRMWARE_NOTIFY_XHCI_RESET,
655+
&packet, sizeof(packet));
656+
#endif
657+
}
658+
633659
/*
634660
* Make sure the controller is completely inactive, unable to
635661
* generate interrupts or do DMA.
@@ -1207,6 +1233,9 @@ static void quirk_usb_handoff_xhci(struct pci_dev *pdev)
12071233
if (pdev->vendor == PCI_VENDOR_ID_INTEL)
12081234
usb_enable_intel_xhci_ports(pdev);
12091235

1236+
if (pdev->vendor == PCI_VENDOR_ID_VIA && pdev->device == 0x3483)
1237+
usb_vl805_init(pdev);
1238+
12101239
op_reg_base = base + XHCI_HC_LENGTH(readl(base));
12111240

12121241
/* Wait for the host controller to be ready before writing any

‎include/soc/bcm2835/raspberrypi-firmware.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ enum rpi_firmware_property_tag {
9595
RPI_FIRMWARE_SET_PERIPH_REG = 0x00038045,
9696
RPI_FIRMWARE_GET_POE_HAT_VAL = 0x00030049,
9797
RPI_FIRMWARE_SET_POE_HAT_VAL = 0x00030050,
98-
98+
RPI_FIRMWARE_NOTIFY_XHCI_RESET = 0x00030058,
9999

100100
/* Dispmanx TAGS */
101101
RPI_FIRMWARE_FRAMEBUFFER_ALLOCATE = 0x00040001,

0 commit comments

Comments
 (0)