All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Raspberry Pi 4 VL805 firmware load
@ 2020-04-28 17:44 Nicolas Saenz Julienne
  2020-04-28 17:44 ` [PATCH 1/2] arm: rpi: Add function to trigger VL805's " Nicolas Saenz Julienne
  2020-04-28 17:44 ` [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware Nicolas Saenz Julienne
  0 siblings, 2 replies; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-28 17:44 UTC (permalink / raw)
  To: u-boot

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.

Patch 2 is a little invasive, but I couldn't find a mechanism in u-boot
similar to Linux's PCI quirks.

Nicolas Saenz Julienne (2):
  arm: rpi: Add function to trigger VL805's firmware load
  usb: xhci: Load Raspberry Pi 4 VL805's firmware

 arch/arm/mach-bcm283x/include/mach/mbox.h | 13 +++++++
 arch/arm/mach-bcm283x/include/mach/msg.h  |  7 ++++
 arch/arm/mach-bcm283x/msg.c               | 41 +++++++++++++++++++++++
 drivers/usb/host/xhci-pci.c               |  6 ++++
 4 files changed, 67 insertions(+)

-- 
2.26.2

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/2] arm: rpi: Add function to trigger VL805's firmware load
  2020-04-28 17:44 [PATCH 0/2] Raspberry Pi 4 VL805 firmware load Nicolas Saenz Julienne
@ 2020-04-28 17:44 ` Nicolas Saenz Julienne
  2020-04-28 17:44 ` [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware Nicolas Saenz Julienne
  1 sibling, 0 replies; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-28 17:44 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 arch/arm/mach-bcm283x/include/mach/mbox.h | 13 +++++++
 arch/arm/mach-bcm283x/include/mach/msg.h  |  7 ++++
 arch/arm/mach-bcm283x/msg.c               | 41 +++++++++++++++++++++++
 3 files changed, 61 insertions(+)

diff --git a/arch/arm/mach-bcm283x/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index 60e226ce1d..2ae2d3d97c 100644
--- a/arch/arm/mach-bcm283x/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -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.
  *
diff --git a/arch/arm/mach-bcm283x/include/mach/msg.h b/arch/arm/mach-bcm283x/include/mach/msg.h
index 4afb08631b..c63fa4f6ee 100644
--- a/arch/arm/mach-bcm283x/include/mach/msg.h
+++ b/arch/arm/mach-bcm283x/include/mach/msg.h
@@ -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, -ve on error
+ */
+int bcm2711_load_vl805_firmware(void);
+
 #endif
diff --git a/arch/arm/mach-bcm283x/msg.c b/arch/arm/mach-bcm283x/msg.c
index 94b75283f8..861438899f 100644
--- a/arch/arm/mach-bcm283x/msg.c
+++ b/arch/arm/mach-bcm283x/msg.c
@@ -40,6 +40,12 @@ struct msg_setup {
 	u32 end_tag;
 };
 
+struct msg_load_vl805_fw {
+	struct bcm2835_mbox_hdr hdr;
+	struct bcm2835_mbox_tag_pci_dev_addr dev_addr;
+	u32 end_tag;
+};
+
 int bcm2835_power_on_module(u32 module)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1);
@@ -151,3 +157,38 @@ int bcm2835_set_video_params(int *widthp, int *heightp, int depth_bpp,
 
 	return 0;
 }
+
+/*
+ * On the Raspberry Pi 4, after a PCI reset, VL805's (the xHCI chip) firmware
+ * may either be loaded directly from an EEPROM or, if not present, by the
+ * SoC's VideCore. This informs VideoCore that VL805 needs its firmware loaded.
+ */
+int bcm2711_load_vl805_firmware(void)
+{
+	ALLOC_CACHE_ALIGN_BUFFER(struct msg_load_vl805_fw,
+				 msg_load_vl805_fw, 1);
+	int ret;
+
+	BCM2835_MBOX_INIT_HDR(msg_load_vl805_fw);
+	BCM2835_MBOX_INIT_TAG(&msg_load_vl805_fw->dev_addr, NOTIFY_XHCI_RESET);
+
+	/*
+	 * The pci device address is expected like this:
+	 *
+	 *   PCI_BUS << 20 | PCI_SLOT << 15 | PCI_FUNC << 12
+	 *
+	 * But since RPi4's PCIe setup is hardwired, we know the address in
+	 * advance.
+	 */
+	msg_load_vl805_fw->dev_addr.body.req.dev_addr = 0x100000;
+
+	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
+				     &msg_load_vl805_fw->hdr);
+	if (ret) {
+		printf("bcm2711: Faild to load vl805's firmware, %d\n", ret);
+		return -EIO;
+	}
+
+	return 0;
+}
+
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-28 17:44 [PATCH 0/2] Raspberry Pi 4 VL805 firmware load Nicolas Saenz Julienne
  2020-04-28 17:44 ` [PATCH 1/2] arm: rpi: Add function to trigger VL805's " Nicolas Saenz Julienne
@ 2020-04-28 17:44 ` Nicolas Saenz Julienne
  2020-04-28 17:59   ` Marek Vasut
                     ` (2 more replies)
  1 sibling, 3 replies; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-28 17:44 UTC (permalink / raw)
  To: u-boot

When needed, RPi4's co-processor (called VideoCore) has to be instructed
to load VL805's firmware (the chip providing xHCI support). VideCore's
firmware expects the board's PCIe bus to be already configured in order
for it to load the xHCI chip firmware. So we have to make sure this
happens in between the PCIe configuration and xHCI startup.

Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
---
 drivers/usb/host/xhci-pci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
index c1f60da541..5c17ea6932 100644
--- a/drivers/usb/host/xhci-pci.c
+++ b/drivers/usb/host/xhci-pci.c
@@ -11,6 +11,8 @@
 #include <usb.h>
 #include <usb/xhci.h>
 
+#include <asm/arch/msg.h>
+
 static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
 			  struct xhci_hcor **ret_hcor)
 {
@@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
 	struct xhci_hcor *hcor;
 	u32 cmd;
 
+#ifdef CONFIG_BCM2711
+	bcm2711_load_vl805_firmware();
+#endif
+
 	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
 			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
 	hcor = (struct xhci_hcor *)((uintptr_t) hccr +
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-28 17:44 ` [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware Nicolas Saenz Julienne
@ 2020-04-28 17:59   ` Marek Vasut
  2020-04-29 10:10     ` Nicolas Saenz Julienne
  2020-04-29  6:18   ` Marek Szyprowski
  2020-04-29  6:51   ` Bin Meng
  2 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2020-04-28 17:59 UTC (permalink / raw)
  To: u-boot

On 4/28/20 7:44 PM, Nicolas Saenz Julienne wrote:
> When needed, RPi4's co-processor (called VideoCore) has to be instructed
> to load VL805's firmware (the chip providing xHCI support). VideCore's
> firmware expects the board's PCIe bus to be already configured in order
> for it to load the xHCI chip firmware. So we have to make sure this
> happens in between the PCIe configuration and xHCI startup.
> 
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>  drivers/usb/host/xhci-pci.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index c1f60da541..5c17ea6932 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -11,6 +11,8 @@
>  #include <usb.h>
>  #include <usb/xhci.h>
>  
> +#include <asm/arch/msg.h>
> +
>  static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
>  			  struct xhci_hcor **ret_hcor)
>  {
> @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
>  	struct xhci_hcor *hcor;
>  	u32 cmd;
>  
> +#ifdef CONFIG_BCM2711
> +	bcm2711_load_vl805_firmware();
> +#endif
> +
>  	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
>  			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
>  	hcor = (struct xhci_hcor *)((uintptr_t) hccr +

I think socfpga arria10 has some firmware loader implementation that is
generic, so can't we use that ?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-28 17:44 ` [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware Nicolas Saenz Julienne
  2020-04-28 17:59   ` Marek Vasut
@ 2020-04-29  6:18   ` Marek Szyprowski
  2020-04-29 11:19     ` Nicolas Saenz Julienne
  2020-04-29  6:51   ` Bin Meng
  2 siblings, 1 reply; 13+ messages in thread
From: Marek Szyprowski @ 2020-04-29  6:18 UTC (permalink / raw)
  To: u-boot

Hi Nicolas,

On 28.04.2020 19:44, Nicolas Saenz Julienne wrote:
> When needed, RPi4's co-processor (called VideoCore) has to be instructed
> to load VL805's firmware (the chip providing xHCI support). VideCore's
> firmware expects the board's PCIe bus to be already configured in order
> for it to load the xHCI chip firmware. So we have to make sure this
> happens in between the PCIe configuration and xHCI startup.
>
> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>   drivers/usb/host/xhci-pci.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> index c1f60da541..5c17ea6932 100644
> --- a/drivers/usb/host/xhci-pci.c
> +++ b/drivers/usb/host/xhci-pci.c
> @@ -11,6 +11,8 @@
>   #include <usb.h>
>   #include <usb/xhci.h>
>   
> +#include <asm/arch/msg.h>
> +

Does the above include works on the other archs?

>   static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
>   			  struct xhci_hcor **ret_hcor)
>   {
> @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
>   	struct xhci_hcor *hcor;
>   	u32 cmd;
>   
> +#ifdef CONFIG_BCM2711
> +	bcm2711_load_vl805_firmware();
> +#endif
> +
>   	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
>   			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
>   	hcor = (struct xhci_hcor *)((uintptr_t) hccr +

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-28 17:44 ` [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware Nicolas Saenz Julienne
  2020-04-28 17:59   ` Marek Vasut
  2020-04-29  6:18   ` Marek Szyprowski
@ 2020-04-29  6:51   ` Bin Meng
  2020-04-29 10:53     ` Nicolas Saenz Julienne
  2 siblings, 1 reply; 13+ messages in thread
From: Bin Meng @ 2020-04-29  6:51 UTC (permalink / raw)
  To: u-boot

Hi Nicolas,

On Wed, Apr 29, 2020 at 1:45 AM Nicolas Saenz Julienne
<nsaenzjulienne@suse.de> wrote:
>
> When needed, RPi4's co-processor (called VideoCore) has to be instructed
> to load VL805's firmware (the chip providing xHCI support). VideCore's
> firmware expects the board's PCIe bus to be already configured in order
> for it to load the xHCI chip firmware. So we have to make sure this
> happens in between the PCIe configuration and xHCI startup.
>

I am a little bit confused. I thought we already solved the xHCI
driver issuw on RPi4. What's this firmware used for?

> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> ---
>  drivers/usb/host/xhci-pci.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>

Regards,
Bin

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-28 17:59   ` Marek Vasut
@ 2020-04-29 10:10     ` Nicolas Saenz Julienne
  2020-04-29 12:05       ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-29 10:10 UTC (permalink / raw)
  To: u-boot

On Tue, 2020-04-28 at 19:59 +0200, Marek Vasut wrote:
> On 4/28/20 7:44 PM, Nicolas Saenz Julienne wrote:
> > When needed, RPi4's co-processor (called VideoCore) has to be instructed
> > to load VL805's firmware (the chip providing xHCI support). VideCore's
> > firmware expects the board's PCIe bus to be already configured in order
> > for it to load the xHCI chip firmware. So we have to make sure this
> > happens in between the PCIe configuration and xHCI startup.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > ---
> >  drivers/usb/host/xhci-pci.c | 6 ++++++
> >  1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> > index c1f60da541..5c17ea6932 100644
> > --- a/drivers/usb/host/xhci-pci.c
> > +++ b/drivers/usb/host/xhci-pci.c
> > @@ -11,6 +11,8 @@
> >  #include <usb.h>
> >  #include <usb/xhci.h>
> >  
> > +#include <asm/arch/msg.h>
> > +
> >  static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
> >  			  struct xhci_hcor **ret_hcor)
> >  {
> > @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct
> > xhci_hccr **ret_hccr,
> >  	struct xhci_hcor *hcor;
> >  	u32 cmd;
> >  
> > +#ifdef CONFIG_BCM2711
> > +	bcm2711_load_vl805_firmware();
> > +#endif
> > +
> >  	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
> >  			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
> >  	hcor = (struct xhci_hcor *)((uintptr_t) hccr +
> 
> I think socfpga arria10 has some firmware loader implementation that is
> generic, so can't we use that ?

I don't think so. I've been told the firmware upgrade protocol is private and
specific to the VL80X family of devices. The Raspberry Pi foundation decided to
implement it in their closed source VideoCore firmware. All we have access to
from arm is this mailbox interface where we just trigger the process.

Then there's an extra potential issue as it's the RPi4 co-processor firmware
image that contains VL805's firmware. We'd had to somehow extract it from
there every time they update it.

As a recap of what's happening here:
 - arm configures PCI
 - arm triggers VL805 firmware reload
 - VideoCore somehow transfers firmware (trough PCI) into VL805 if no EEPROM
   present
 - VL805 is up and running
 - arm can carry on with xHCI init

Note that all this is only relevant if you have newer revision of the board. So
most people will not need it right now. But as it becomes more widespread we'll
start seeing complaints.

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/20200429/a05a0776/attachment.sig>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-29  6:51   ` Bin Meng
@ 2020-04-29 10:53     ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-29 10:53 UTC (permalink / raw)
  To: u-boot

Hi Bin,

On Wed, 2020-04-29 at 14:51 +0800, Bin Meng wrote:
> Hi Nicolas,
> 
> On Wed, Apr 29, 2020 at 1:45 AM Nicolas Saenz Julienne
> <nsaenzjulienne@suse.de> wrote:
> > When needed, RPi4's co-processor (called VideoCore) has to be instructed
> > to load VL805's firmware (the chip providing xHCI support). VideCore's
> > firmware expects the board's PCIe bus to be already configured in order
> > for it to load the xHCI chip firmware. So we have to make sure this
> > happens in between the PCIe configuration and xHCI startup.
> > 
> 
> I am a little bit confused. I thought we already solved the xHCI
> driver issuw on RPi4. What's this firmware used for?

This is not related to the issues Sylwester fixed. It builds on it (I should
have been more explicit in that regard). It relates to a design change the RPi
foundation did on newer revisions of boards. VL805, the xHCI chip, needs its
firmware loaded. On older revisions of the board -- the one most people have
right now -- this is achieved using an EEPROM that is rooted directly into
VL805. Newer board revisions removed the EEPROM and now let VideoCore (the
board co-processor) take care of loading the firmware into the VL805 chip.

All we have left from arm's perspective is a mailbox interface to VideoCore,
where we can trigger the VL805 firmware load. Which can only happen as long as
we've have properly configured the PCI bus.

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/20200429/f6282a23/attachment.sig>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-29  6:18   ` Marek Szyprowski
@ 2020-04-29 11:19     ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-29 11:19 UTC (permalink / raw)
  To: u-boot

On Wed, 2020-04-29 at 08:18 +0200, Marek Szyprowski wrote:
> Hi Nicolas,
> 
> On 28.04.2020 19:44, Nicolas Saenz Julienne wrote:
> > When needed, RPi4's co-processor (called VideoCore) has to be instructed
> > to load VL805's firmware (the chip providing xHCI support). VideCore's
> > firmware expects the board's PCIe bus to be already configured in order
> > for it to load the xHCI chip firmware. So we have to make sure this
> > happens in between the PCIe configuration and xHCI startup.
> > 
> > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > ---
> >   drivers/usb/host/xhci-pci.c | 6 ++++++
> >   1 file changed, 6 insertions(+)
> > 
> > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> > index c1f60da541..5c17ea6932 100644
> > --- a/drivers/usb/host/xhci-pci.c
> > +++ b/drivers/usb/host/xhci-pci.c
> > @@ -11,6 +11,8 @@
> >   #include <usb.h>
> >   #include <usb/xhci.h>
> >   
> > +#include <asm/arch/msg.h>
> > +
> 
> Does the above include works on the other archs?

It doesn't I should have enclosed it with '#ifdef CONFIG_BCM2711' as well.

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/20200429/0a596b50/attachment.sig>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-29 10:10     ` Nicolas Saenz Julienne
@ 2020-04-29 12:05       ` Marek Vasut
  2020-04-29 12:36         ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2020-04-29 12:05 UTC (permalink / raw)
  To: u-boot

On 4/29/20 12:10 PM, Nicolas Saenz Julienne wrote:
> On Tue, 2020-04-28 at 19:59 +0200, Marek Vasut wrote:
>> On 4/28/20 7:44 PM, Nicolas Saenz Julienne wrote:
>>> When needed, RPi4's co-processor (called VideoCore) has to be instructed
>>> to load VL805's firmware (the chip providing xHCI support). VideCore's
>>> firmware expects the board's PCIe bus to be already configured in order
>>> for it to load the xHCI chip firmware. So we have to make sure this
>>> happens in between the PCIe configuration and xHCI startup.
>>>
>>> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>>> ---
>>>  drivers/usb/host/xhci-pci.c | 6 ++++++
>>>  1 file changed, 6 insertions(+)
>>>
>>> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
>>> index c1f60da541..5c17ea6932 100644
>>> --- a/drivers/usb/host/xhci-pci.c
>>> +++ b/drivers/usb/host/xhci-pci.c
>>> @@ -11,6 +11,8 @@
>>>  #include <usb.h>
>>>  #include <usb/xhci.h>
>>>  
>>> +#include <asm/arch/msg.h>
>>> +
>>>  static void xhci_pci_init(struct udevice *dev, struct xhci_hccr **ret_hccr,
>>>  			  struct xhci_hcor **ret_hcor)
>>>  {
>>> @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct
>>> xhci_hccr **ret_hccr,
>>>  	struct xhci_hcor *hcor;
>>>  	u32 cmd;
>>>  
>>> +#ifdef CONFIG_BCM2711
>>> +	bcm2711_load_vl805_firmware();
>>> +#endif
>>> +
>>>  	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
>>>  			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
>>>  	hcor = (struct xhci_hcor *)((uintptr_t) hccr +
>>
>> I think socfpga arria10 has some firmware loader implementation that is
>> generic, so can't we use that ?
> 
> I don't think so. I've been told the firmware upgrade protocol is private and
> specific to the VL80X family of devices. The Raspberry Pi foundation decided to
> implement it in their closed source VideoCore firmware.

What I meant was that U-Boot has a way to load files from various
storage roughly the same way Linux firmware loader API does.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-29 12:05       ` Marek Vasut
@ 2020-04-29 12:36         ` Nicolas Saenz Julienne
  2020-04-29 12:37           ` Marek Vasut
  0 siblings, 1 reply; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-29 12:36 UTC (permalink / raw)
  To: u-boot

On Wed, 2020-04-29 at 14:05 +0200, Marek Vasut wrote:
> On 4/29/20 12:10 PM, Nicolas Saenz Julienne wrote:
> > On Tue, 2020-04-28 at 19:59 +0200, Marek Vasut wrote:
> > > On 4/28/20 7:44 PM, Nicolas Saenz Julienne wrote:
> > > > When needed, RPi4's co-processor (called VideoCore) has to be instructed
> > > > to load VL805's firmware (the chip providing xHCI support). VideCore's
> > > > firmware expects the board's PCIe bus to be already configured in order
> > > > for it to load the xHCI chip firmware. So we have to make sure this
> > > > happens in between the PCIe configuration and xHCI startup.
> > > > 
> > > > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > > > ---
> > > >  drivers/usb/host/xhci-pci.c | 6 ++++++
> > > >  1 file changed, 6 insertions(+)
> > > > 
> > > > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
> > > > index c1f60da541..5c17ea6932 100644
> > > > --- a/drivers/usb/host/xhci-pci.c
> > > > +++ b/drivers/usb/host/xhci-pci.c
> > > > @@ -11,6 +11,8 @@
> > > >  #include <usb.h>
> > > >  #include <usb/xhci.h>
> > > >  
> > > > +#include <asm/arch/msg.h>
> > > > +
> > > >  static void xhci_pci_init(struct udevice *dev, struct xhci_hccr
> > > > **ret_hccr,
> > > >  			  struct xhci_hcor **ret_hcor)
> > > >  {
> > > > @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct
> > > > xhci_hccr **ret_hccr,
> > > >  	struct xhci_hcor *hcor;
> > > >  	u32 cmd;
> > > >  
> > > > +#ifdef CONFIG_BCM2711
> > > > +	bcm2711_load_vl805_firmware();
> > > > +#endif
> > > > +
> > > >  	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
> > > >  			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
> > > >  	hcor = (struct xhci_hcor *)((uintptr_t) hccr +
> > > 
> > > I think socfpga arria10 has some firmware loader implementation that is
> > > generic, so can't we use that ?
> > 
> > I don't think so. I've been told the firmware upgrade protocol is private
> > and
> > specific to the VL80X family of devices. The Raspberry Pi foundation decided
> > to
> > implement it in their closed source VideoCore firmware.
> 
> What I meant was that U-Boot has a way to load files from various
> storage roughly the same way Linux firmware loader API does.

As far as generic APIs are concerned I've had a look at
request_firmware_into_buf() which socfpga uses in its spl_board_init(). But
sadly it doesn't help here.

What bcm2711_load_vl805_firmware() does here is just informing the co-processor
that it's free to start the VL805 firmware load operation. I'm by no means
providing anything, think of it as a doorbell if you will. I'll try to find an
alternative to 'load' in the function name so the distinction with regular
firmware loading is more explicit.

Also bare in mind we have to time this operation in between PCIe configuration
and xHCI init. Which, IIUC, blocks us from using board_init() and the likes of
it (which would be way nicer IMO).

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/20200429/cdd7e892/attachment.sig>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-29 12:36         ` Nicolas Saenz Julienne
@ 2020-04-29 12:37           ` Marek Vasut
  2020-04-29 13:04             ` Nicolas Saenz Julienne
  0 siblings, 1 reply; 13+ messages in thread
From: Marek Vasut @ 2020-04-29 12:37 UTC (permalink / raw)
  To: u-boot

On 4/29/20 2:36 PM, Nicolas Saenz Julienne wrote:
> On Wed, 2020-04-29 at 14:05 +0200, Marek Vasut wrote:
>> On 4/29/20 12:10 PM, Nicolas Saenz Julienne wrote:
>>> On Tue, 2020-04-28 at 19:59 +0200, Marek Vasut wrote:
>>>> On 4/28/20 7:44 PM, Nicolas Saenz Julienne wrote:
>>>>> When needed, RPi4's co-processor (called VideoCore) has to be instructed
>>>>> to load VL805's firmware (the chip providing xHCI support). VideCore's
>>>>> firmware expects the board's PCIe bus to be already configured in order
>>>>> for it to load the xHCI chip firmware. So we have to make sure this
>>>>> happens in between the PCIe configuration and xHCI startup.
>>>>>
>>>>> Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
>>>>> ---
>>>>>  drivers/usb/host/xhci-pci.c | 6 ++++++
>>>>>  1 file changed, 6 insertions(+)
>>>>>
>>>>> diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c
>>>>> index c1f60da541..5c17ea6932 100644
>>>>> --- a/drivers/usb/host/xhci-pci.c
>>>>> +++ b/drivers/usb/host/xhci-pci.c
>>>>> @@ -11,6 +11,8 @@
>>>>>  #include <usb.h>
>>>>>  #include <usb/xhci.h>
>>>>>  
>>>>> +#include <asm/arch/msg.h>
>>>>> +
>>>>>  static void xhci_pci_init(struct udevice *dev, struct xhci_hccr
>>>>> **ret_hccr,
>>>>>  			  struct xhci_hcor **ret_hcor)
>>>>>  {
>>>>> @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev, struct
>>>>> xhci_hccr **ret_hccr,
>>>>>  	struct xhci_hcor *hcor;
>>>>>  	u32 cmd;
>>>>>  
>>>>> +#ifdef CONFIG_BCM2711
>>>>> +	bcm2711_load_vl805_firmware();
>>>>> +#endif
>>>>> +
>>>>>  	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
>>>>>  			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
>>>>>  	hcor = (struct xhci_hcor *)((uintptr_t) hccr +
>>>>
>>>> I think socfpga arria10 has some firmware loader implementation that is
>>>> generic, so can't we use that ?
>>>
>>> I don't think so. I've been told the firmware upgrade protocol is private
>>> and
>>> specific to the VL80X family of devices. The Raspberry Pi foundation decided
>>> to
>>> implement it in their closed source VideoCore firmware.
>>
>> What I meant was that U-Boot has a way to load files from various
>> storage roughly the same way Linux firmware loader API does.
> 
> As far as generic APIs are concerned I've had a look at
> request_firmware_into_buf() which socfpga uses in its spl_board_init(). But
> sadly it doesn't help here.
> 
> What bcm2711_load_vl805_firmware() does here is just informing the co-processor
> that it's free to start the VL805 firmware load operation. I'm by no means
> providing anything, think of it as a doorbell if you will. I'll try to find an
> alternative to 'load' in the function name so the distinction with regular
> firmware loading is more explicit.

Oh, that's how it is, I see.

> Also bare in mind we have to time this operation in between PCIe configuration
> and xHCI init. Which, IIUC, blocks us from using board_init() and the likes of
> it (which would be way nicer IMO).

Maybe you need some callback there ?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware
  2020-04-29 12:37           ` Marek Vasut
@ 2020-04-29 13:04             ` Nicolas Saenz Julienne
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas Saenz Julienne @ 2020-04-29 13:04 UTC (permalink / raw)
  To: u-boot

On Wed, 2020-04-29 at 14:37 +0200, Marek Vasut wrote:
> On 4/29/20 2:36 PM, Nicolas Saenz Julienne wrote:
> > On Wed, 2020-04-29 at 14:05 +0200, Marek Vasut wrote:
> > > On 4/29/20 12:10 PM, Nicolas Saenz Julienne wrote:
> > > > On Tue, 2020-04-28 at 19:59 +0200, Marek Vasut wrote:
> > > > > On 4/28/20 7:44 PM, Nicolas Saenz Julienne wrote:
> > > > > > When needed, RPi4's co-processor (called VideoCore) has to be
> > > > > > instructed
> > > > > > to load VL805's firmware (the chip providing xHCI support).
> > > > > > VideCore's
> > > > > > firmware expects the board's PCIe bus to be already configured in
> > > > > > order
> > > > > > for it to load the xHCI chip firmware. So we have to make sure this
> > > > > > happens in between the PCIe configuration and xHCI startup.
> > > > > > 
> > > > > > Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
> > > > > > ---
> > > > > >  drivers/usb/host/xhci-pci.c | 6 ++++++
> > > > > >  1 file changed, 6 insertions(+)
> > > > > > 
> > > > > > diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-
> > > > > > pci.c
> > > > > > index c1f60da541..5c17ea6932 100644
> > > > > > --- a/drivers/usb/host/xhci-pci.c
> > > > > > +++ b/drivers/usb/host/xhci-pci.c
> > > > > > @@ -11,6 +11,8 @@
> > > > > >  #include <usb.h>
> > > > > >  #include <usb/xhci.h>
> > > > > >  
> > > > > > +#include <asm/arch/msg.h>
> > > > > > +
> > > > > >  static void xhci_pci_init(struct udevice *dev, struct xhci_hccr
> > > > > > **ret_hccr,
> > > > > >  			  struct xhci_hcor **ret_hcor)
> > > > > >  {
> > > > > > @@ -18,6 +20,10 @@ static void xhci_pci_init(struct udevice *dev,
> > > > > > struct
> > > > > > xhci_hccr **ret_hccr,
> > > > > >  	struct xhci_hcor *hcor;
> > > > > >  	u32 cmd;
> > > > > >  
> > > > > > +#ifdef CONFIG_BCM2711
> > > > > > +	bcm2711_load_vl805_firmware();
> > > > > > +#endif
> > > > > > +
> > > > > >  	hccr = (struct xhci_hccr *)dm_pci_map_bar(dev,
> > > > > >  			PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
> > > > > >  	hcor = (struct xhci_hcor *)((uintptr_t) hccr +
> > > > > 
> > > > > I think socfpga arria10 has some firmware loader implementation that
> > > > > is
> > > > > generic, so can't we use that ?
> > > > 
> > > > I don't think so. I've been told the firmware upgrade protocol is
> > > > private
> > > > and
> > > > specific to the VL80X family of devices. The Raspberry Pi foundation
> > > > decided
> > > > to
> > > > implement it in their closed source VideoCore firmware.
> > > 
> > > What I meant was that U-Boot has a way to load files from various
> > > storage roughly the same way Linux firmware loader API does.
> > 
> > As far as generic APIs are concerned I've had a look at
> > request_firmware_into_buf() which socfpga uses in its spl_board_init(). But
> > sadly it doesn't help here.
> > 
> > What bcm2711_load_vl805_firmware() does here is just informing the co-
> > processor
> > that it's free to start the VL805 firmware load operation. I'm by no means
> > providing anything, think of it as a doorbell if you will. I'll try to find
> > an
> > alternative to 'load' in the function name so the distinction with regular
> > firmware loading is more explicit.
> 
> Oh, that's how it is, I see.
> 
> > Also bare in mind we have to time this operation in between PCIe
> > configuration
> > and xHCI init. Which, IIUC, blocks us from using board_init() and the likes
> > of
> > it (which would be way nicer IMO).
> 
> Maybe you need some callback there ?

Indeed, in Linux I'm using PCI fixups. I guess I could create a similar
concept, albeit simpler, that calls board specific code for fixups after
scanning and detecting PCI devices. Or even simpler if we do it after PCI bus
probes.

I'll look into it.

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/20200429/0c87afbe/attachment.sig>

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-04-29 13:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 17:44 [PATCH 0/2] Raspberry Pi 4 VL805 firmware load Nicolas Saenz Julienne
2020-04-28 17:44 ` [PATCH 1/2] arm: rpi: Add function to trigger VL805's " Nicolas Saenz Julienne
2020-04-28 17:44 ` [PATCH 2/2] usb: xhci: Load Raspberry Pi 4 VL805's firmware Nicolas Saenz Julienne
2020-04-28 17:59   ` Marek Vasut
2020-04-29 10:10     ` Nicolas Saenz Julienne
2020-04-29 12:05       ` Marek Vasut
2020-04-29 12:36         ` Nicolas Saenz Julienne
2020-04-29 12:37           ` Marek Vasut
2020-04-29 13:04             ` Nicolas Saenz Julienne
2020-04-29  6:18   ` Marek Szyprowski
2020-04-29 11:19     ` Nicolas Saenz Julienne
2020-04-29  6:51   ` Bin Meng
2020-04-29 10:53     ` Nicolas Saenz Julienne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.