mbox series

[v2,0/9] Raspberry Pi 4 USB firmware initialization rework

Message ID 20200609175003.19793-1-nsaenzjulienne@suse.de (mailing list archive)
Headers show
Series Raspberry Pi 4 USB firmware initialization rework | expand

Message

Nicolas Saenz Julienne June 9, 2020, 5:49 p.m. UTC
On the Raspberry Pi 4, after a PCI reset, VL805's firmware may either be
loaded directly from an EEPROM or, if not present, by the SoC's
co-processor, VideoCore. This series reworks how we handle this.

The previous solution makes use of PCI quirks and exporting platform
specific functions. Albeit functional it feels pretty shoehorned. This
proposes an alternative way of handling the triggering of the xHCI chip
initialization trough means of a reset controller.

The benefits are pretty evident: less platform churn in core xHCI code,
and no explicit device dependency management in pcie-brcmstb.

Note that patch #1 depend on another series[1].

The series is based on next-20200605.

v1: https://lore.kernel.org/linux-usb/20200608192701.18355-1-nsaenzjulienne@suse.de/T/#t

[1] https://lwn.net/ml/linux-kernel/cover.662a8d401787ef33780d91252a352de91dc4be10.1590594293.git-series.maxime@cerno.tech/

---

Changes since v1:
 - Rework reset controller so it's less USB centric.
 - Use correct reset controller API in xhci-pci
 - Correct typos

Nicolas Saenz Julienne (9):
  dt-bindings: reset: Add a binding for the RPi Firmware reset
    controller
  reset: Add Raspberry Pi 4 firmware reset controller
  ARM: dts: bcm2711: Add firmware usb reset node
  ARM: dts: bcm2711: Add reset controller to xHCI node
  usb: xhci-pci: Add support for reset controllers
  Revert "USB: pci-quirks: Add Raspberry Pi 4 quirk"
  usb: host: pci-quirks: Bypass xHCI quirks for Raspberry Pi 4
  Revert "firmware: raspberrypi: Introduce vl805 init routine"
  Revert "PCI: brcmstb: Wait for Raspberry Pi's firmware when present"

 .../arm/bcm/raspberrypi,bcm2835-firmware.yaml |  21 +++
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts         |  12 ++
 drivers/firmware/Kconfig                      |   3 +-
 drivers/firmware/raspberrypi.c                |  61 ---------
 drivers/pci/controller/pcie-brcmstb.c         |  17 ---
 drivers/reset/Kconfig                         |  11 ++
 drivers/reset/Makefile                        |   1 +
 drivers/reset/reset-raspberrypi.c             | 126 ++++++++++++++++++
 drivers/usb/host/pci-quirks.c                 |  22 ++-
 drivers/usb/host/xhci-pci.c                   |   7 +
 include/soc/bcm2835/raspberrypi-firmware.h    |   7 -
 11 files changed, 188 insertions(+), 100 deletions(-)
 create mode 100644 drivers/reset/reset-raspberrypi.c

Comments

Florian Fainelli June 9, 2020, 6:07 p.m. UTC | #1
On 6/9/2020 10:49 AM, Nicolas Saenz Julienne wrote:
> The firmware running on the RPi VideoCore can be used to reset and
> initialize HW controlled by the firmware.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> 
> ---
> 
> Changes since v1:
>  - Correct cells binding as per Florian's comment
>  - Change compatible string to be more generic
> 
>  .../arm/bcm/raspberrypi,bcm2835-firmware.yaml | 21 +++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
> index b48ed875eb8e..23a885af3a28 100644
> --- a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
> +++ b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-firmware.yaml
> @@ -39,6 +39,22 @@ properties:
>        - compatible
>        - "#clock-cells"
>  
> +  reset:
> +    type: object
> +
> +    properties:
> +      compatible:
> +        const: raspberrypi,firmware-reset
> +
> +      "#reset-cells":
> +        const: 1
> +        description: >

Is this a stray '>' character? If so, with that fixed:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Florian Fainelli June 9, 2020, 6:14 p.m. UTC | #2
On 6/9/2020 10:49 AM, Nicolas Saenz Julienne wrote:
> 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. Introduce a reset controller capable of interfacing with
> RPi4's co-processor that models these firmware initialization routines as
> reset lines.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> 
> ---
> 
> Changes since v1:
>   - Make the whole driver less USB centric as per Florian's comments
> 
>  drivers/reset/Kconfig             |  11 +++
>  drivers/reset/Makefile            |   1 +
>  drivers/reset/reset-raspberrypi.c | 126 ++++++++++++++++++++++++++++++
>  3 files changed, 138 insertions(+)
>  create mode 100644 drivers/reset/reset-raspberrypi.c
> 
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> index d9efbfd29646..97e848740e13 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -140,6 +140,17 @@ config RESET_QCOM_PDC
>  	  to control reset signals provided by PDC for Modem, Compute,
>  	  Display, GPU, Debug, AOP, Sensors, Audio, SP and APPS.
>  
> +config RESET_RASPBERRYPI
> +	tristate "Raspberry Pi 4 Firmware Reset Driver"
> +	depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n && COMPILE_TEST)
> +	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.
> +
>  config RESET_SCMI
>  	tristate "Reset driver controlled via ARM SCMI interface"
>  	depends on ARM_SCMI_PROTOCOL || COMPILE_TEST
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> index 249ed357c997..16947610cc3b 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -21,6 +21,7 @@ obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
>  obj-$(CONFIG_RESET_PISTACHIO) += reset-pistachio.o
>  obj-$(CONFIG_RESET_QCOM_AOSS) += reset-qcom-aoss.o
>  obj-$(CONFIG_RESET_QCOM_PDC) += reset-qcom-pdc.o
> +obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
>  obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
>  obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
>  obj-$(CONFIG_RESET_STM32MP157) += reset-stm32mp1.o
> diff --git a/drivers/reset/reset-raspberrypi.c b/drivers/reset/reset-raspberrypi.c
> new file mode 100644
> index 000000000000..5fc8c6319a20
> --- /dev/null
> +++ b/drivers/reset/reset-raspberrypi.c
> @@ -0,0 +1,126 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Raspberry Pi 4 firmware reset driver
> + *
> + * Copyright (C) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> + */
> +#include <linux/delay.h>
> +#include <linux/device.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/reset-controller.h>
> +#include <soc/bcm2835/raspberrypi-firmware.h>
> +
> +struct rpi_reset {
> +	struct reset_controller_dev rcdev;
> +	struct rpi_firmware *fw;
> +};
> +
> +enum rpi_reset_ids {
> +	RASPBERRYPI_FIRMWARE_RESET_ID_USB,

You should probably move this to a header file under
include/dt-bindings/reset/ in order to ensure that what gets referenced
by the DTS is in sync with what the driver knows about.

With that:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Florian Fainelli June 9, 2020, 6:14 p.m. UTC | #3
On 6/9/2020 10:49 AM, Nicolas Saenz Julienne wrote:
> This reverts commit c65822fef4adc0ba40c37a47337376ce75f7a7bc.
> 
> The initialization of Raspberry Pi 4's USB chip is now handled through a
> reset controller. No need to directly call the firmware routine trough a
> pci quirk.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Florian Fainelli June 9, 2020, 6:16 p.m. UTC | #4
On 6/9/2020 10:49 AM, Nicolas Saenz Julienne wrote:
> Now that the reset driver exposing Raspberry Pi 4's firmware based USB
> reset routine is available, let's add the device tree node exposing it.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Nicolas Saenz Julienne June 10, 2020, 3:37 p.m. UTC | #5
Hi Florian, thanks for the review :)

On Tue, 2020-06-09 at 11:07 -0700, Florian Fainelli wrote:
> 
> On 6/9/2020 10:49 AM, Nicolas Saenz Julienne wrote:
> > The firmware running on the RPi VideoCore can be used to reset and
> > initialize HW controlled by the firmware.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > 
> > ---
> > 
> > Changes since v1:
> >  - Correct cells binding as per Florian's comment
> >  - Change compatible string to be more generic
> > 
> >  .../arm/bcm/raspberrypi,bcm2835-firmware.yaml | 21 +++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-
> > firmware.yaml
> > b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-
> > firmware.yaml
> > index b48ed875eb8e..23a885af3a28 100644
> > --- a/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-
> > firmware.yaml
> > +++ b/Documentation/devicetree/bindings/arm/bcm/raspberrypi,bcm2835-
> > firmware.yaml
> > @@ -39,6 +39,22 @@ properties:
> >        - compatible
> >        - "#clock-cells"
> >  
> > +  reset:
> > +    type: object
> > +
> > +    properties:
> > +      compatible:
> > +        const: raspberrypi,firmware-reset
> > +
> > +      "#reset-cells":
> > +        const: 1
> > +        description: >
> 
> Is this a stray '>' character? If so, with that fixed:

No, it marks the formatting of the text below. | will keep the formatting as
is, > will leave the formatting to whatever is going to use it.

Regards,
Nicolas
Nicolas Saenz Julienne June 10, 2020, 3:37 p.m. UTC | #6
On Tue, 2020-06-09 at 11:14 -0700, Florian Fainelli wrote:
> 
> On 6/9/2020 10:49 AM, Nicolas Saenz Julienne wrote:
> > 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. Introduce a reset controller capable of interfacing with
> > RPi4's co-processor that models these firmware initialization routines as
> > reset lines.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > 
> > ---
> > 
> > Changes since v1:
> >   - Make the whole driver less USB centric as per Florian's comments
> > 
> >  drivers/reset/Kconfig             |  11 +++
> >  drivers/reset/Makefile            |   1 +
> >  drivers/reset/reset-raspberrypi.c | 126 ++++++++++++++++++++++++++++++
> >  3 files changed, 138 insertions(+)
> >  create mode 100644 drivers/reset/reset-raspberrypi.c
> > 
> > diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
> > index d9efbfd29646..97e848740e13 100644
> > --- a/drivers/reset/Kconfig
> > +++ b/drivers/reset/Kconfig
> > @@ -140,6 +140,17 @@ config RESET_QCOM_PDC
> >  	  to control reset signals provided by PDC for Modem, Compute,
> >  	  Display, GPU, Debug, AOP, Sensors, Audio, SP and APPS.
> >  
> > +config RESET_RASPBERRYPI
> > +	tristate "Raspberry Pi 4 Firmware Reset Driver"
> > +	depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n &&
> > COMPILE_TEST)
> > +	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.
> > +
> >  config RESET_SCMI
> >  	tristate "Reset driver controlled via ARM SCMI interface"
> >  	depends on ARM_SCMI_PROTOCOL || COMPILE_TEST
> > diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
> > index 249ed357c997..16947610cc3b 100644
> > --- a/drivers/reset/Makefile
> > +++ b/drivers/reset/Makefile
> > @@ -21,6 +21,7 @@ obj-$(CONFIG_RESET_OXNAS) += reset-oxnas.o
> >  obj-$(CONFIG_RESET_PISTACHIO) += reset-pistachio.o
> >  obj-$(CONFIG_RESET_QCOM_AOSS) += reset-qcom-aoss.o
> >  obj-$(CONFIG_RESET_QCOM_PDC) += reset-qcom-pdc.o
> > +obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
> >  obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
> >  obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o
> >  obj-$(CONFIG_RESET_STM32MP157) += reset-stm32mp1.o
> > diff --git a/drivers/reset/reset-raspberrypi.c b/drivers/reset/reset-
> > raspberrypi.c
> > new file mode 100644
> > index 000000000000..5fc8c6319a20
> > --- /dev/null
> > +++ b/drivers/reset/reset-raspberrypi.c
> > @@ -0,0 +1,126 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Raspberry Pi 4 firmware reset driver
> > + *
> > + * Copyright (C) 2020 Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > + */
> > +#include <linux/delay.h>
> > +#include <linux/device.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/reset-controller.h>
> > +#include <soc/bcm2835/raspberrypi-firmware.h>
> > +
> > +struct rpi_reset {
> > +	struct reset_controller_dev rcdev;
> > +	struct rpi_firmware *fw;
> > +};
> > +
> > +enum rpi_reset_ids {
> > +	RASPBERRYPI_FIRMWARE_RESET_ID_USB,
> 
> You should probably move this to a header file under
> include/dt-bindings/reset/ in order to ensure that what gets referenced
> by the DTS is in sync with what the driver knows about.
> 
> With that:
> 
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

Thanks! Will fix that on v3.

Regards,
Nicolas