usb: xhci: Load Raspberry Pi 4 VL805's firmware
Subsystems (9)
v4 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 works hand in hand with a series of device tree changes on the Linux device tree that are still being reviewed:
https://patchwork.kernel.org/patch/11596403/
https://patchwork.kernel.org/patch/11596409/
---
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 (5):
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
dm: pci: Assign controller device node to root bridge
usb: xhci-pci: 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/pci/pci-uclass.c | 15 ++++- drivers/reset/Kconfig | 10 ++++ drivers/reset/Makefile | 1 + drivers/reset/reset-raspberrypi.c | 60 +++++++++++++++++++ drivers/usb/host/xhci-pci.c | 38 +++++++++++- .../reset/raspberrypi,firmware-reset.h | 13 ++++ 12 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 drivers/reset/reset-raspberrypi.c create mode 100644 include/dt-bindings/reset/raspberrypi,firmware-reset.h
Signature · 1 line
2.26.2
PATCH v4 1/5 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.26.2
PATCH v4 2/5 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.26.2
PATCH v4 3/5 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.26.2
PATCH v4 4/5 dm: pci: Assign controller device node to root bridge
In reply to Nicolas Saenz JulienneThere is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node.
This permits setups like this to work correctly:
pcie {
compatible = "...";
...
dev {
reg = <0 0 0 0 0>;
...
};
};Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected.
--- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/pci/pci-uclass.c +14 -1
@@ -762,7 +762,20 @@ static int pci_find_and_bind_driver(struct udevice *parent, str =strdup (name);if (!str)return -ENOMEM ; - drv = bridge ?"pci_bridge_drv" :"pci_generic_drv" ; + +if (bridge) { + drv ="pci_bridge_drv" ; + +/* +* If we're dealing with the root bridge pass the parent device +* node, as there isn't a distinction in device tree between +* that and the actual controller platform device. +*/ +if (!PCI_MASK_BUS (bdf)) + node = parent->node; + }else { + drv ="pci_generic_drv" ; + } ret =device_bind_driver_to_node (parent, drv, str, node, devp);if (ret) {
Signature · 1 line
2.26.2
Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge
Hi Nicolas,
Quoted 17 lines · Nicolas Saenz Julienne
There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node.
This permits setups like this to work correctly:
pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; };
Quoted 7 lines
Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected.
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Can you update the tests to handle this case please?
Regards,
Simon
Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge
Quoted 23 lines · Simon Glass
Hi Nicolas,
Quoted 19 lines · Nicolas Saenz Julienne
There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node.
This permits setups like this to work correctly:
pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; };Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected.
Quoted 6 lines
Quoted 4 lines
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)Can you update the tests to handle this case please?
I'd be glad to, but I'm not familiar with the test FW in u-booy, coud give me some pointers on where/how to test this?
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/20200616/e0b6022e/attachment.sig>
Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge
Hi Nicolas,
Quoted 30 lines · Nicolas Saenz Julienne
Quoted 28 lines · Simon Glass
Hi Nicolas,
Quoted 23 lines · Nicolas Saenz Julienne
There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node.
This permits setups like this to work correctly:
pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; };Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected.
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line
Can you update the tests to handle this case please?
I'd be glad to, but I'm not familiar with the test FW in u-booy, coud give me some pointers on where/how to test this?
Yes it is at test/dm/pci.c and the device tree is test.dts
'make qcheck' to run all tests. To run one test, build for sandbox and then something like
u-boot -T -c "ut dm pci_swapcase"
for example.
You can perhaps use an existing PCI controller in test.dts but feel free to add one more if you need it for your test. Make sure that you don't break other tests.
Regards,
Simon
Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge
Quoted 45 lines · Simon Glass
Hi Nicolas,
Quoted 29 lines · Nicolas Saenz Julienne
Quoted 28 lines · Simon Glass
Hi Nicolas,
Quoted 23 lines · Nicolas Saenz Julienne
There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node.
This permits setups like this to work correctly:
pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; };Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected.
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)Quoted 6 lines
Quoted 1 line
Can you update the tests to handle this case please?
I'd be glad to, but I'm not familiar with the test FW in u-booy, coud give me
some pointers on where/how to test this?Yes it is at
test/dm/pci.cand the device tree istest.dts'make qcheck' to run all tests. To run one test, build for sandbox and then something like
Quoted 7 lines
u-boot -T -c "ut dm
pci_swapcase"for example.
You can perhaps use an existing PCI controller in
test.dtsbut feel free to add one more if you need it for your test. Make sure that you don't break other tests.
Thanks for the info.
Actually adding the tests made me doubleguess myself, and now I'm pretty sure that what I shoudl've done in DT is the following:
&pcie0 {
pci at 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>;
};
};
};(with "lspci -tv": [0000:00]---00.0-[01]----00.0 VIA Technologies, Inc. VL805 USB 3.0 Host Controller)
With this the patch above isn't needed, which is great.
I'll send this to upstream Linux just to get a confirmation this is correct, although if you have any comments it'll be appreciated.
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/20200617/bd5cc8c3/attachment.sig>
Re: [PATCH v4 4/5] dm: pci: Assign controller device node to root bridge
Hi Nicolas,
Quoted 76 lines · Nicolas Saenz Julienne
Quoted 45 lines · Simon Glass
Hi Nicolas,
Quoted 29 lines · Nicolas Saenz Julienne
Quoted 28 lines · Simon Glass
Hi Nicolas,
Quoted 23 lines · Nicolas Saenz Julienne
There is no distinction in DT between the PCI controller device and the root bridge, whereas such distinction exists from dm's perspective. Make sure the root bridge ofnode is assigned to the controller's platform device node.
This permits setups like this to work correctly:
pcie { compatible = "..."; ... dev { reg = <0 0 0 0 0>; ... }; };Without this the dev node is assigned to the root bridge and the actual device search starts one level lower than expected.
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/pci/pci-uclass.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)Quoted 6 lines
Quoted 1 line
Can you update the tests to handle this case please?
I'd be glad to, but I'm not familiar with the test FW in u-booy, coud give me
some pointers on where/how to test this?Yes it is at
test/dm/pci.cand the device tree istest.dts'make qcheck' to run all tests. To run one test, build for sandbox and then something like
Quoted 7 lines
u-boot -T -c "ut dm
pci_swapcase"for example.
You can perhaps use an existing PCI controller in
test.dtsbut feel free to add one more if you need it for your test. Make sure that you don't break other tests.Thanks for the info.
Actually adding the tests made me doubleguess myself, and now I'm pretty sure that what I shoudl've done in DT is the following:
&pcie0 { pci at 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>; }; }; };
Quoted 6 lines
(with "lspci -tv": [0000:00]---00.0-[01]----00.0 VIA Technologies, Inc. VL805 USB 3.0 Host Controller)
With this the patch above isn't needed, which is great.
I'll send this to upstream Linux just to get a confirmation this is correct, although if you have any comments it'll be appreciated.
Yes it looks OK to me. U-Boot allows PCI and USB devices to be represented in the device tree.
Regards,
Simon
PATCH v4 5/5 usb: xhci-pci: Add reset controller support
In reply to Nicolas Saenz JulienneSome atypical users of xhci-pci 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.
--- drivers/usb/host/xhci-pci.c | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
drivers/usb/host/xhci-pci.c +36 -2
@@ -10,9 +10,14 @@#include <init.h> #include <log.h> #include <pci.h> +#include <reset.h> #include <usb.h> #include <usb/xhci.h> +struct xhci_pci_platdata { +struct reset_ctl reset; +}; +static void xhci_pci_init (struct udevice *dev,struct xhci_hccr **ret_hccr,struct xhci_hcor **ret_hcor) {
@@ -39,14 +44,43 @@ static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,static int xhci_pci_probe (struct udevice *dev) { +struct xhci_pci_platdata *plat =dev_get_platdata (dev);struct xhci_hccr *hccr;struct xhci_hcor *hcor; +int ret; + + ret =reset_get_by_index (dev,0 , &plat->reset); +if (ret && ret != -ENOENT ) { +dev_err (dev,"failed to get reset\n" ); +return ret; + } + +if (reset_valid (&plat->reset)) { + ret =reset_assert (&plat->reset); +if (ret) +return ret; + + ret =reset_deassert (&plat->reset); +if (ret) +return ret; + }xhci_pci_init (dev, &hccr, &hcor);return xhci_register (dev, hccr, hcor); } +static int xhci_pci_remove (struct udevice *dev) +{ +struct xhci_pci_platdata *plat =dev_get_platdata (dev); + +xhci_deregister (dev); +if (reset_valid (&plat->reset)) +reset_free (&plat->reset); + +return 0 ; +} +static const struct udevice_id xhci_pci_ids[] = { { .compatible ="xhci-pci" }, { }
@@ -56,10 +90,10 @@ U_BOOT_DRIVER(xhci_pci) = { .name = "xhci_pci", .id = UCLASS_USB, .probe = xhci_pci_probe, - .remove = xhci_deregister, + .remove = xhci_pci_remove, .of_match = xhci_pci_ids, .ops = &xhci_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .platdata_auto_alloc_size = sizeof(struct xhci_pci_platdata), .priv_auto_alloc_size = sizeof(struct xhci_ctrl), .flags = DM_FLAG_ALLOC_PRIV_DMA, };
Signature · 1 line
2.26.2
Re: [PATCH v4 5/5] usb: xhci-pci: Add reset controller support
Quoted 8 lines · Nicolas Saenz Julienne
Some atypical users of xhci-pci 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.
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/usb/host/xhci-pci.c | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
Can the XHCI core code do the reset management instead ? Then everyone benefits from it.
The rest of the series is nice, thanks.
Re: [PATCH v4 5/5] usb: xhci-pci: Add reset controller support
Quoted 5 lines · Marek Vasut
Quoted 4 lines · Nicolas Saenz Julienne
Some atypical users of xhci-pci 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.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Nicolas Saenz Julienne <[email protected]>--- drivers/usb/host/xhci-pci.c | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)Can the XHCI core code do the reset management instead ? Then everyone benefits from it.
I'll look into it.
Quoted 1 line
The rest of the series is nice, 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/20200615/dcbff58c/attachment.sig>