diff mbox series

[3/6] board_r: Introduce CONFIG_PCI_INIT_R Kconfig option

Message ID 20200506173847.35635-3-ovidiu.panait@windriver.com
State Accepted
Commit 98bf46f7bd90b53ef9ed31b0b1dc8ddc4db15d61
Headers show
Series [1/6] env: Convert CONFIG_DELAY_ENVIRONMENT to Kconfig | expand

Commit Message

Ovidiu Panait May 6, 2020, 5:38 p.m. UTC
With CONFIG_DM_PCI enabled, PCI buses are not enumerated at boot, as they
are without that config option enabled. However, there are cases such as DM
PCI-based Ethernet devices that need the PCI bus enumerated so that they
can be discovered by their drivers.

Currently, to solve this, some boards enumerate the pci bus using
"pci enum" preboot command, while others do it manually in board files
(in board_init/board_late_init/etc. functions).

In order to possibly make the pci enumeration process uniform across all
boards, introduce CONFIG_PCI_INIT_R Kconfig option.

This change also preserves the current behavior in the !DM_PCI case
(pci_init is run unconditionally at boot).

Signed-off-by: Ovidiu Panait <ovidiu.panait at windriver.com>
---
 common/Kconfig   | 10 ++++++++++
 common/board_r.c |  5 ++---
 2 files changed, 12 insertions(+), 3 deletions(-)

Comments

Tom Rini May 16, 2020, 1:45 a.m. UTC | #1
On Wed, May 06, 2020 at 08:38:44PM +0300, Ovidiu Panait wrote:

> With CONFIG_DM_PCI enabled, PCI buses are not enumerated at boot, as they
> are without that config option enabled. However, there are cases such as DM
> PCI-based Ethernet devices that need the PCI bus enumerated so that they
> can be discovered by their drivers.
> 
> Currently, to solve this, some boards enumerate the pci bus using
> "pci enum" preboot command, while others do it manually in board files
> (in board_init/board_late_init/etc. functions).
> 
> In order to possibly make the pci enumeration process uniform across all
> boards, introduce CONFIG_PCI_INIT_R Kconfig option.
> 
> This change also preserves the current behavior in the !DM_PCI case
> (pci_init is run unconditionally at boot).
> 
> Signed-off-by: Ovidiu Panait <ovidiu.panait at windriver.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/Kconfig b/common/Kconfig
index 30cba15948..2d86dd7e63 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -932,6 +932,16 @@  config LAST_STAGE_INIT
 	  U-Boot calls last_stage_init() before the command-line interpreter is
 	  started.
 
+config PCI_INIT_R
+	bool "Enumerate PCI buses during init"
+	depends on PCI
+	default y if !DM_PCI
+	help
+	  With this option U-Boot will call pci_init() soon after relocation,
+	  which will enumerate PCI buses. This is needed, for instance, in the
+	  case of DM PCI-based Ethernet devices, which will not be detected
+	  without having the enumeration performed earlier.
+
 endmenu
 
 menu "Security support"
diff --git a/common/board_r.c b/common/board_r.c
index f6770f2300..96034b874e 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -232,9 +232,8 @@  static int initr_unlock_ram_in_cache(void)
 #ifdef CONFIG_PCI
 static int initr_pci(void)
 {
-#ifndef CONFIG_DM_PCI
-	pci_init();
-#endif
+	if (IS_ENABLED(CONFIG_PCI_INIT_R))
+		pci_init();
 
 	return 0;
 }