diff mbox series

[U-Boot,068/126] x86: tpl: Add a fake PCI bus

Message ID 20190925145750.200592-69-sjg@chromium.org
State Superseded
Delegated to: Bin Meng
Headers show
Series x86: Add initial support for apollolake | expand

Commit Message

Simon Glass Sept. 25, 2019, 2:56 p.m. UTC
In TPL we try to minimise code size so do not include the PCI subsystem.
We can use fixed BARs and drivers can directly program the devices that
they need.

However we do need to bind the devices on the PCI bus and without PCI this
does not ordinarily happen. As a work-around, define a fake PCI bus which
does this binding, but no other PCI operations. This is a convenient way
to ensure that we can use the same device tree for TPL, SPL and U-Boot
proper:

   TPL    - CONFIG_TPL_PCI is not set (manual mode, fake PCI bus)
   SPL    - CONFIG_SPL_PCI is set (manual mode but with real PCI bus)
   U-Boot - CONFIG_PCI is set (full auto-config after relocation)

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/x86/lib/tpl.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

Comments

Bin Meng Oct. 9, 2019, 2:20 p.m. UTC | #1
Hi Simon,

On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote:
>
> In TPL we try to minimise code size so do not include the PCI subsystem.
> We can use fixed BARs and drivers can directly program the devices that
> they need.
>
> However we do need to bind the devices on the PCI bus and without PCI this
> does not ordinarily happen. As a work-around, define a fake PCI bus which
> does this binding, but no other PCI operations. This is a convenient way
> to ensure that we can use the same device tree for TPL, SPL and U-Boot
> proper:
>
>    TPL    - CONFIG_TPL_PCI is not set (manual mode, fake PCI bus)
>    SPL    - CONFIG_SPL_PCI is set (manual mode but with real PCI bus)

manual mode is confusing. Maybe (no auto-config, real PCI bus)?

>    U-Boot - CONFIG_PCI is set (full auto-config after relocation)
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  arch/x86/lib/tpl.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
>
> diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
> index d70f590541c..f8075568a2c 100644
> --- a/arch/x86/lib/tpl.c
> +++ b/arch/x86/lib/tpl.c
> @@ -5,6 +5,7 @@
>
>  #include <common.h>
>  #include <debug_uart.h>
> +#include <dm.h>
>  #include <spl.h>
>  #include <asm/cpu.h>
>  #include <asm/mtrr.h>
> @@ -115,3 +116,27 @@ void spl_board_init(void)
>  {
>         preloader_console_init();
>  }
> +
> +#if !CONFIG_IS_ENABLED(PCI)
> +/*
> + * This is a fake PCI bus for TPL when it doesn't have proper PCI. It is enough
> + * to bind the devices on the PCI bus, some of which have early-regs properties
> + * providing fixed BARs. Individual drivers program these BARs themselves so
> + * that they can access the devices. The BARs are allocated statically in the
> + * device tree.
> + *
> + * Once SPL is running it enables PCI properly, but does not auto-assign BARs
> + * for devices, so the TPL BARs continue to be used. Once U-Boot starts it does
> + * the autoallocation (after relocation).

missing space between "auto" and "allocation"

> + */
> +static const struct udevice_id tpl_fake_pci_ids[] = {
> +       { .compatible = "pci-x86" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(pci_x86) = {
> +       .name   = "pci_x86",
> +       .id     = UCLASS_SIMPLE_BUS,
> +       .of_match = tpl_fake_pci_ids,
> +};
> +#endif
> --

Regards,
Bin
diff mbox series

Patch

diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c
index d70f590541c..f8075568a2c 100644
--- a/arch/x86/lib/tpl.c
+++ b/arch/x86/lib/tpl.c
@@ -5,6 +5,7 @@ 
 
 #include <common.h>
 #include <debug_uart.h>
+#include <dm.h>
 #include <spl.h>
 #include <asm/cpu.h>
 #include <asm/mtrr.h>
@@ -115,3 +116,27 @@  void spl_board_init(void)
 {
 	preloader_console_init();
 }
+
+#if !CONFIG_IS_ENABLED(PCI)
+/*
+ * This is a fake PCI bus for TPL when it doesn't have proper PCI. It is enough
+ * to bind the devices on the PCI bus, some of which have early-regs properties
+ * providing fixed BARs. Individual drivers program these BARs themselves so
+ * that they can access the devices. The BARs are allocated statically in the
+ * device tree.
+ *
+ * Once SPL is running it enables PCI properly, but does not auto-assign BARs
+ * for devices, so the TPL BARs continue to be used. Once U-Boot starts it does
+ * the autoallocation (after relocation).
+ */
+static const struct udevice_id tpl_fake_pci_ids[] = {
+	{ .compatible = "pci-x86" },
+	{ }
+};
+
+U_BOOT_DRIVER(pci_x86) = {
+	.name	= "pci_x86",
+	.id	= UCLASS_SIMPLE_BUS,
+	.of_match = tpl_fake_pci_ids,
+};
+#endif