usb: xhci: Load Raspberry Pi 4 VL805's firmware
Subsystems (8)
v5 cover usb: xhci: Load Raspberry Pi 4 VL805's firmware
Newer revisions of the RPi4 need their xHCI chip, VL805, firmware to be loaded explicitly. Earlier versions didn't need that as they where using an EEPROM for that purpose. This series takes care of setting up the relevant infrastructure and run the firmware loading routine at the right moment.
Note that this builds on top of Sylwester Nawrocki's "USB host support for Raspberry Pi 4 board" series.
This also depends on a DT/bindings patch available on the linux-mailing lists:
https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg2205783.html
Here is the relevant bit for reference/discussion:
&pcie0 {
pci at 1,0 {
#address-cells = <3>;
#size-cells = <2>;
ranges;
reg = <0 0 0 0 0>;
usb at 1,0 {
reg = <0x10000 0 0 0 0>;
resets = <&reset RASPBERRYPI_FIRMWARE_RESET_ID_USB>;
};
};
};---
Changes since v4:
- Correct DT PCI topology, I separated the root bridge and controller DT nodes
- Get rid of PCI core patch as not needed with correct DT PCI topology
- Move reset support to xchi core
Changes since v3:
- Use reset controller
Changes since v2:
- Correct comment on patch #1
- Address Matthias' comments
Changes since v1:
- Rename function
- Use callback in xhci-pci.c
Nicolas Saenz Julienne (4):
arm: rpi: Add function to trigger VL805's firmware load
reset: Add Raspberry Pi 4 firmware reset controller
configs: Enable support for reset controllers on RPi4
usb: xhci: Add reset controller support
arch/arm/mach-bcm283x/include/mach/mbox.h | 13 ++++ arch/arm/mach-bcm283x/include/mach/msg.h | 7 +++ arch/arm/mach-bcm283x/msg.c | 46 ++++++++++++++ configs/rpi_4_32b_defconfig | 1 + configs/rpi_4_defconfig | 1 + configs/rpi_arm64_defconfig | 1 + drivers/reset/Kconfig | 10 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-raspberrypi.c | 60 +++++++++++++++++++ drivers/usb/host/xhci-mem.c | 2 + drivers/usb/host/xhci.c | 33 ++++++++++ .../reset/raspberrypi,firmware-reset.h | 13 ++++ include/usb/xhci.h | 2 + 13 files changed, 190 insertions(+) create mode 100644 drivers/reset/reset-raspberrypi.c create mode 100644 include/dt-bindings/reset/raspberrypi,firmware-reset.h
Signature · 1 line
2.27.0
PATCH v5 1/4 arm: rpi: Add function to trigger VL805's firmware load
On the Raspberry Pi 4, after a PCI reset, VL805's (a xHCI chip) firmware may either be loaded directly from an EEPROM or, if not present, by the SoC's VideCore (the SoC's co-processor). Introduce the function that informs VideCore that VL805 may need its firmware loaded.
---
Changes since v1:
- Rename function so it's not mistaken with regular firmware loading
arch/arm/mach-bcm283x/include/mach/mbox.h | 13 +++++++ arch/arm/mach-bcm283x/include/mach/msg.h | 7 ++++ arch/arm/mach-bcm283x/msg.c | 46 +++++++++++++++++++++++ 3 files changed, 66 insertions(+)
arch/arm/mach-bcm283x/include/mach/mbox.h +13 -0
@@ -491,6 +491,19 @@ struct bcm2835_mbox_tag_set_palette { } body; }; +#define BCM2835_MBOX_TAG_NOTIFY_XHCI_RESET 0x00030058 + +struct bcm2835_mbox_tag_pci_dev_addr { +struct bcm2835_mbox_tag_hdr tag_hdr; +union { +struct { +u32 dev_addr; + } req; +struct { + } resp; + } body; +}; +/* * Pass a raw u32 message to the VC, and receive a raw u32 back. *
arch/arm/mach-bcm283x/include/mach/msg.h +7 -0
@@ -48,4 +48,11 @@ int bcm2835_set_video_params(int *widthp, int *heightp, int depth_bpp, int pixel_order, int alpha_mode, ulong *fb_basep, ulong *fb_sizep, int *pitchp); +/** +* bcm2711_load_vl805_firmware() - get vl805's firmware loaded +* +* @return 0 if OK, -EIO on error +*/ +int bcm2711_notify_vl805_reset (void ); +#endif
arch/arm/mach-bcm283x/msg.c +46 -0
61 lines not on this page · raw message
Signature · 1 line
2.27.0
PATCH v5 2/4 reset: Add Raspberry Pi 4 firmware reset controller
In reply to Nicolas Saenz JulienneRaspberry Pi 4's co-processor controls some of the board's HW initialization process, but it's up to Linux to trigger it when relevant. Introduce a reset controller capable of interfacing with RPi4's co-processor that models these firmware initialization routines as reset lines.
--- drivers/reset/Kconfig | 10 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-raspberrypi.c | 60 +++++++++++++++++++ .../reset/raspberrypi,firmware-reset.h | 13 ++++ 4 files changed, 84 insertions(+) create mode 100644 drivers/reset/reset-raspberrypi.c create mode 100644 include/dt-bindings/reset/raspberrypi,firmware-reset.h
drivers/reset/Kconfig +10 -0
@@ -148,4 +148,14 @@ config RESET_IMX7 help Support for reset controller on i.MX7/8 SoCs. +config RESET_RASPBERRYPI + bool "Raspberry Pi 4 Firmware Reset Controller Driver" + depends on DM_RESET && ARCH_BCM283X + default USB_XHCI_PCI + help + Raspberry Pi 4's co-processor controls some of the board's HW + initialization process, but it's up to Linux to trigger it when + relevant. This driver provides a reset controller capable of + interfacing with RPi4's co-processor and model these firmware + initialization routines as reset lines. endmenu
drivers/reset/Makefile +1 -0
@@ -23,3 +23,4 @@ obj-$(CONFIG_RESET_MTMIPS) += reset-mtmips.o obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o obj-$(CONFIG_RESET_IMX7) += reset-imx7.o +obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
drivers/reset/reset-raspberrypi.c new file +60 -0
60 lines not on this page · raw message
include/dt-bindings/reset/raspberrypi,firmware-reset.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2020 Nicolas Saenz Julienne +* Author: Nicolas Saenz Julienne <[email protected]> +*/ + +#ifndef _DT_BINDINGS_RASPBERRYPI_FIRMWARE_RESET_H +#define _DT_BINDINGS_RASPBERRYPI_FIRMWARE_RESET_H + +#define RASPBERRYPI_FIRMWARE_RESET_ID_USB 0 +#define RASPBERRYPI_FIRMWARE_RESET_NUM_IDS 1 + +#endif
Signature · 1 line
2.27.0
PATCH v5 3/4 configs: Enable support for reset controllers on RPi4
In reply to Nicolas Saenz JulienneThis is required in order to access the reset controller used to initialize the board's xHCI chip.
--- configs/rpi_4_32b_defconfig | 1 + configs/rpi_4_defconfig | 1 + configs/rpi_arm64_defconfig | 1 + 3 files changed, 3 insertions(+)
configs/rpi_4_32b_defconfig +1 -0
@@ -35,6 +35,7 @@ CONFIG_DM_PCI=y CONFIG_PCI_BRCMSTB=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_GENERIC is not set +CONFIG_DM_RESET=y # CONFIG_REQUIRE_SERIAL_CONSOLE is not set CONFIG_USB=y CONFIG_DM_USB=y
configs/rpi_4_defconfig +1 -0
@@ -35,6 +35,7 @@ CONFIG_DM_PCI=y CONFIG_PCI_BRCMSTB=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_GENERIC is not set +CONFIG_DM_RESET=y # CONFIG_REQUIRE_SERIAL_CONSOLE is not set CONFIG_USB=y CONFIG_DM_USB=y
configs/rpi_arm64_defconfig +1 -0
@@ -32,6 +32,7 @@ CONFIG_DM_PCI=y CONFIG_PCI_BRCMSTB=y CONFIG_PINCTRL=y # CONFIG_PINCTRL_GENERIC is not set +CONFIG_DM_RESET=y # CONFIG_REQUIRE_SERIAL_CONSOLE is not set CONFIG_USB=y CONFIG_DM_USB=y
Signature · 1 line
2.27.0
PATCH v5 4/4 usb: xhci: Add reset controller support
In reply to Nicolas Saenz JulienneSome atypical users of xhci might need to manually reset their xHCI controller before starting the HCD setup. Check if a reset controller device is available to the PCI bus and trigger a reset.
---
Changes since v3:
- Move reset support to xchi core
drivers/usb/host/xhci-mem.c | 2 ++ drivers/usb/host/xhci.c | 33 +++++++++++++++++++++++++++++++++ include/usb/xhci.h | 2 ++ 3 files changed, 37 insertions(+)
drivers/usb/host/xhci-mem.c +2 -0
@@ -180,6 +180,8 @@ void xhci_cleanup(struct xhci_ctrl *ctrl)xhci_free_virt_devices (ctrl);free (ctrl->erst.entries);free (ctrl->dcbaa); +if (reset_valid (&ctrl->reset)) +reset_free (&ctrl->reset);memset (ctrl,'\0' ,sizeof (struct xhci_ctrl )); }
drivers/usb/host/xhci.c +33 -0
@@ -190,6 +190,35 @@ static int xhci_start(struct xhci_hcor *hcor)return ret; } +/** +* Resets XHCI Hardware +* +* @param ctrl pointer to host controller +* @return 0 if OK, or a negative error code. +*/ +static int xhci_reset_hw (struct xhci_ctrl *ctrl) +{ +int ret; + + ret =reset_get_by_index (ctrl->dev,0 , &ctrl->reset); +if (ret && ret != -ENOENT ) { +dev_err (ctrl->dev,"failed to get reset\n" ); +return ret; + } + +if (reset_valid (&ctrl->reset)) { + ret =reset_assert (&ctrl->reset); +if (ret) +return ret; + + ret =reset_deassert (&ctrl->reset); +if (ret) +return ret; + } + +return 0 ; +} +/** * Resets the XHCI Controller *
@@ -1508,6 +1537,10 @@ int xhci_register(struct udevice *dev, struct xhci_hccr *hccr, ctrl->dev = dev; + ret =xhci_reset_hw (ctrl); +if (ret) + goto err; +/* * XHCI needs to issue a Address device command to setup * proper device context structures, before it can interact
include/usb/xhci.h +2 -0
@@ -16,6 +16,7 @@#ifndef HOST_XHCI_H_ #define HOST_XHCI_H_ +#include <reset.h> #include <asm/types.h> #include <asm/cache.h> #include <asm/io.h>
@@ -1209,6 +1210,7 @@ struct xhci_ctrl {#if CONFIG_IS_ENABLED (DM_USB )struct udevice *dev;#endif +struct reset_ctl reset;struct xhci_hccr *hccr;/* R/O registers, not need for volatile */ struct xhci_hcor *hcor;struct xhci_doorbell_array *dba;
Signature · 1 line
2.27.0
PATCH v5 4/4 usb: xhci: Add reset controller support
On 6/22/20 5:30 PM, Nicolas Saenz Julienne wrote:
[...]
Quoted 13 lines
include/usb/xhci.h +1
-0@@ -16,6 +16,7 @@#ifndef HOST_XHCI_H_ #define HOST_XHCI_H_ +#include <reset.h> #include <asm/types.h> #include <asm/cache.h> #include <asm/io.h>
include/usb/xhci.h struct xhci_ctrl { · line 1213
Quoted 4 lines
include/usb/xhci.h +1
-0@@ -1209,6 +1210,7 @@ struct xhci_ctrl {#if CONFIG_IS_ENABLED (DM_USB )struct udevice *dev;#endif +struct reset_ctl reset;
Should all this reset logic be protected by if CONFIG_IS_ENABLED(DM_RESET) ?
Otherwise the series looks good to me, thanks.
PATCH v5 4/4 usb: xhci: Add reset controller support
Hi Marek,
Quoted 11 lines · Marek Vasut
On 6/22/20 5:30 PM, Nicolas Saenz Julienne wrote:
[...]Quoted 8 lines
include/usb/xhci.h +0
-0@@ -16,6 +16,7 @@#ifndef HOST_XHCI_H_ #define HOST_XHCI_H_
Quoted 11 lines
include/usb/xhci.h struct xhci_ctrl { · line 1213
Quoted 9 lines
include/usb/xhci.h +2
-0+#include <reset.h> #include <asm/types.h> #include <asm/cache.h> #include <asm/io.h> @@ -1209,6 +1210,7 @@ struct xhci_ctrl {#if CONFIG_IS_ENABLED (DM_USB )struct udevice *dev;#endif +struct reset_ctl reset;Should all this reset logic be protected by if
CONFIG_IS_ENABLED(DM_RESET)?
As far as building the code there shouldn't be any issues, function/structures are defined in either case.
That said I can see how there could be a runtime issue for the !CONFIG_IS_ENABLED(DM_RESET) case, as xhci_reset_hw() will return an error and make xchi_register() fail.
So I can either protect everything with preprocessor conditionals, both in the struct as in xhci_register(), or catch -ENOTSUPP in xhci_register() and continue the registration as usual. I prefer the later as it adds less preprocessor churn, but I'll go the other way if you prefer it.
Quoted 1 line
Otherwise the series looks good to me, thanks.
Thanks!
Regards,
Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200624/a72cb35a/attachment.sig>
PATCH v5 4/4 usb: xhci: Add reset controller support
Quoted 1 line · Nicolas Saenz Julienne
Hi Marek,
Hi,
Quoted 27 lines · Marek Vasut
Quoted 11 lines · Nicolas Saenz Julienne
[...]
Quoted 8 lines
include/usb/xhci.h +0
-0@@ -16,6 +16,7 @@#ifndef HOST_XHCI_H_ #define HOST_XHCI_H_ Quoted 11 lines
include/usb/xhci.h struct xhci_ctrl { · line 1213
Quoted 9 lines
include/usb/xhci.h +2
-0+#include <reset.h> #include <asm/types.h> #include <asm/cache.h> #include <asm/io.h> @@ -1209,6 +1210,7 @@ struct xhci_ctrl {#if CONFIG_IS_ENABLED (DM_USB )struct udevice *dev;#endif +struct reset_ctl reset;Should all this reset logic be protected by if
CONFIG_IS_ENABLED(DM_RESET)?As far as building the code there shouldn't be any issues, function/structures are defined in either case.
Quoted 8 lines
That said I can see how there could be a runtime issue for the !CONFIG_IS_ENABLED(DM_RESET) case, as
xhci_reset_hw()will return an error and makexchi_register()fail.So I can either protect everything with preprocessor conditionals, both in the struct as in
xhci_register(), or catch-ENOTSUPPinxhci_register()and continue the registration as usual. I prefer the later as it adds less preprocessor churn, but I'll go the other way if you prefer it.
I agree, lets go with the later, thanks.