public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] pci: restore initialization for DM_PCI
@ 2016-01-21 23:35 Stephen Warren
  2016-01-22  0:30 ` Tom Rini
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Stephen Warren @ 2016-01-21 23:35 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

PCI controllers should be enumerated at startup so that PCI devices
such as Ethernet controllers are available at startup. Fix board_init_r()
not to skip calling pci_init() when CONFIG_DM_PCI is defined, and provide
an implementation of pci_init() for the DM case.

Fixes: 96350f729c42 ("dm: tegra: net: Convert tegra boards to driver model
for Ethernet")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
I'm not sure if relying on the side-effects of calling
uclass_{first,ext}_device is the correct approach; is there a more explicit
way to probe all PCI controllers?

Arguably, perhaps we should introduce a "pci start" command instead of
this change to be consistent with e.g. USB. However, that would be a
regression relative to earlier versions of U-Boot.
---
 common/board_r.c         |  2 --
 drivers/pci/pci-uclass.c | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index 75ee43e2d76e..e5029aff1e96 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -249,9 +249,7 @@ static int initr_unlock_ram_in_cache(void)
 #ifdef CONFIG_PCI
 static int initr_pci(void)
 {
-#ifndef CONFIG_DM_PCI
 	pci_init();
-#endif
 
 	return 0;
 }
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 685df9d274e4..f51f08289d66 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -1247,3 +1247,18 @@ U_BOOT_DRIVER(pci_generic_drv) = {
 	.id		= UCLASS_PCI_GENERIC,
 	.of_match	= pci_generic_ids,
 };
+
+void pci_init(void)
+{
+	struct udevice *bus;
+
+	/*
+	 * Enumerate all known controller devices. Enumeration has the side-
+	 * effect of probing them, so PCIe devices will be enumerated too.
+	 */
+	for (uclass_first_device(UCLASS_PCI, &bus);
+	     bus;
+	     uclass_next_device(&bus)) {
+		;
+	}
+}
-- 
2.7.0

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

end of thread, other threads:[~2016-01-26  0:57 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-21 23:35 [U-Boot] [PATCH] pci: restore initialization for DM_PCI Stephen Warren
2016-01-22  0:30 ` Tom Rini
2016-01-22  1:39 ` Bin Meng
2016-01-22  3:36   ` Simon Glass
2016-01-22  3:53     ` Bin Meng
2016-01-22  4:03       ` Simon Glass
2016-01-22  4:06         ` Bin Meng
2016-01-22  4:17           ` Simon Glass
2016-01-22 19:38         ` Stephen Warren
2016-01-22 20:32           ` Simon Glass
2016-01-22 21:48             ` Stephen Warren
2016-01-22 21:50               ` Simon Glass
2016-01-22 21:58                 ` Stephen Warren
2016-01-22 22:00                   ` Simon Glass
2016-01-25 17:11                     ` Stephen Warren
2016-01-26  0:57                       ` Simon Glass
2016-01-24 12:23               ` Bin Meng
2016-01-22 19:35   ` Stephen Warren
2016-01-22 15:49 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox