diff mbox

[U-Boot,v2,1/1] pci: move pcidelay code to new location just before PCI bus scan

Message ID 1318409070-11792-1-git-send-email-agust@denx.de
State Accepted
Commit 0da1fb03c588eebd6287b3fc7d06bf01b0588d89
Headers show

Commit Message

Anatolij Gustschin Oct. 12, 2011, 8:44 a.m. UTC
PCI cards might need some time after reset to respond. On some
boards (mpc5200 or mpc8260 based) the PCI bus reset is deasserted
at pci_init_board() time, so we currently can not use available
"pcidelay" option for waiting before PCI bus scan since this
waiting takes place before calling pci_init_board(). By moving
the pcidelay code to the new location using of the "pcidelay"
option is possible on mpc5200 or mpc8260 based boards, too.

Since pci_hose_scan() could be called multiple times, restrict
the function to wait only during its first call and to ignore
pcidelay for any further call (as pointed out by Matthias).

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Cc: Matthias Fuchs <matthias.fuchs@esd.eu>
---
Changes since first version:
 - extend to wait only during initial pci_hose_scan() call
   as pointed out by Matthias

 drivers/pci/pci.c |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

Comments

Stefan Roese Oct. 12, 2011, 9:42 a.m. UTC | #1
On Wednesday 12 October 2011 10:44:30 Anatolij Gustschin wrote:
> PCI cards might need some time after reset to respond. On some
> boards (mpc5200 or mpc8260 based) the PCI bus reset is deasserted
> at pci_init_board() time, so we currently can not use available
> "pcidelay" option for waiting before PCI bus scan since this
> waiting takes place before calling pci_init_board(). By moving
> the pcidelay code to the new location using of the "pcidelay"
> option is possible on mpc5200 or mpc8260 based boards, too.
> 
> Since pci_hose_scan() could be called multiple times, restrict
> the function to wait only during its first call and to ignore
> pcidelay for any further call (as pointed out by Matthias).
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Matthias Fuchs <matthias.fuchs@esd.eu>

Looks good, so:

Acked-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
Matthias Fuchs Oct. 13, 2011, 12:50 p.m. UTC | #2
On 12.10.2011 10:44, Anatolij Gustschin wrote:
> PCI cards might need some time after reset to respond. On some
> boards (mpc5200 or mpc8260 based) the PCI bus reset is deasserted
> at pci_init_board() time, so we currently can not use available
> "pcidelay" option for waiting before PCI bus scan since this
> waiting takes place before calling pci_init_board(). By moving
> the pcidelay code to the new location using of the "pcidelay"
> option is possible on mpc5200 or mpc8260 based boards, too.
> 
> Since pci_hose_scan() could be called multiple times, restrict
> the function to wait only during its first call and to ignore
> pcidelay for any further call (as pointed out by Matthias).
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Matthias Fuchs <matthias.fuchs@esd.eu>
> ---
> Changes since first version:
>  - extend to wait only during initial pci_hose_scan() call
>    as pointed out by Matthias

Tested on PMC440. Works fine.

Acked-by: Matthias Fuchs <matthias.fuchs@esd.eu>


Matthias
Stefan Roese Oct. 13, 2011, 1:03 p.m. UTC | #3
On Thursday 13 October 2011 14:50:02 Matthias Fuchs wrote:
> On 12.10.2011 10:44, Anatolij Gustschin wrote:
> > PCI cards might need some time after reset to respond. On some
> > boards (mpc5200 or mpc8260 based) the PCI bus reset is deasserted
> > at pci_init_board() time, so we currently can not use available
> > "pcidelay" option for waiting before PCI bus scan since this
> > waiting takes place before calling pci_init_board(). By moving
> > the pcidelay code to the new location using of the "pcidelay"
> > option is possible on mpc5200 or mpc8260 based boards, too.
> > 
> > Since pci_hose_scan() could be called multiple times, restrict
> > the function to wait only during its first call and to ignore
> > pcidelay for any further call (as pointed out by Matthias).
> > 
> > Signed-off-by: Anatolij Gustschin <agust@denx.de>
> > Cc: Matthias Fuchs <matthias.fuchs@esd.eu>
> > ---
> > 
> > Changes since first version:
> >  - extend to wait only during initial pci_hose_scan() call
> >  
> >    as pointed out by Matthias
> 
> Tested on PMC440. Works fine.
> 
> Acked-by: Matthias Fuchs <matthias.fuchs@esd.eu>

Thanks. In this case a:

Tested-by: ...

would be even better. :)

Thanks,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de
Matthias Fuchs Oct. 13, 2011, 1:08 p.m. UTC | #4
On 13.10.2011 15:03, Stefan Roese wrote:
>>
>> Tested on PMC440. Works fine.
>>
>> Acked-by: Matthias Fuchs <matthias.fuchs@esd.eu>
> 
> Thanks. In this case a:
> 
> Tested-by: ...
> 
> would be even better. :)
> 
Even both if you like :-)

Matthias
Wolfgang Denk Oct. 15, 2011, 8:16 p.m. UTC | #5
Dear Anatolij Gustschin,

In message <1318409070-11792-1-git-send-email-agust@denx.de> you wrote:
> PCI cards might need some time after reset to respond. On some
> boards (mpc5200 or mpc8260 based) the PCI bus reset is deasserted
> at pci_init_board() time, so we currently can not use available
> "pcidelay" option for waiting before PCI bus scan since this
> waiting takes place before calling pci_init_board(). By moving
> the pcidelay code to the new location using of the "pcidelay"
> option is possible on mpc5200 or mpc8260 based boards, too.
> 
> Since pci_hose_scan() could be called multiple times, restrict
> the function to wait only during its first call and to ignore
> pcidelay for any further call (as pointed out by Matthias).
> 
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> Cc: Matthias Fuchs <matthias.fuchs@esd.eu>
> ---
> Changes since first version:
>  - extend to wait only during initial pci_hose_scan() call
>    as pointed out by Matthias
> 
>  drivers/pci/pci.c |   30 +++++++++++++++++-------------
>  1 files changed, 17 insertions(+), 13 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 1a0b14c..5f1f128 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -695,6 +695,23 @@  int pci_hose_scan_bus(struct pci_controller *hose, int bus)
 
 int pci_hose_scan(struct pci_controller *hose)
 {
+#if defined(CONFIG_PCI_BOOTDELAY)
+	static int pcidelay_done;
+	char *s;
+	int i;
+
+	if (!pcidelay_done) {
+		/* wait "pcidelay" ms (if defined)... */
+		s = getenv("pcidelay");
+		if (s) {
+			int val = simple_strtoul(s, NULL, 10);
+			for (i = 0; i < val; i++)
+				udelay(1000);
+		}
+		pcidelay_done = 1;
+	}
+#endif /* CONFIG_PCI_BOOTDELAY */
+
 	/* Start scan at current_busno.
 	 * PCIe will start scan at first_busno+1.
 	 */
@@ -709,19 +726,6 @@  int pci_hose_scan(struct pci_controller *hose)
 
 void pci_init(void)
 {
-#if defined(CONFIG_PCI_BOOTDELAY)
-	char *s;
-	int i;
-
-	/* wait "pcidelay" ms (if defined)... */
-	s = getenv ("pcidelay");
-	if (s) {
-		int val = simple_strtoul (s, NULL, 10);
-		for (i=0; i<val; i++)
-			udelay (1000);
-	}
-#endif /* CONFIG_PCI_BOOTDELAY */
-
 	hose_head = NULL;
 
 	/* now call board specific pci_init()... */