diff mbox

[v2,2/5] PCI: imx6: wait the clocks to stabilize after ref_en

Message ID 1411445498-20250-3-git-send-email-r65037@freescale.com
State Changes Requested
Headers show

Commit Message

Zhu Richard-R65037 Sept. 23, 2014, 4:11 a.m. UTC
- a while delay is mandatory required after pcie_ref_clk_en
is set. Otherwise, the system would be hang on imx6qdl ard
boards, because that imx6qdl boards don't have the reset_gpio.
- the clocks should be stable already after the
"clk_prepare_enable" is return. So I think it's ok to move the
usleep delay after the pcie_ref_en is set.

Signed-off-by: Richard Zhu <r65037@freescale.com>
---
 drivers/pci/host/pci-imx6.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Lucas Stach Sept. 23, 2014, 9:56 a.m. UTC | #1
Am Dienstag, den 23.09.2014, 12:11 +0800 schrieb Richard Zhu:
> - a while delay is mandatory required after pcie_ref_clk_en
> is set. Otherwise, the system would be hang on imx6qdl ard
> boards, because that imx6qdl boards don't have the reset_gpio.
> - the clocks should be stable already after the
> "clk_prepare_enable" is return. So I think it's ok to move the
> usleep delay after the pcie_ref_en is set.
> 

You are describing a lot of the conditions around the issue, but not the
issue itself, which makes it hard to follow your commit message. After
looking at the code I think the problem is this (and should be described
accordingly):

For boards without a reset gpio we skip the delay between enabling the
pcie_ref_clk and touching the RC registers for configuration. Apparently
this hangs when the clocks are not yet settled in the DW PCIe core. So
we need to make sure that there is always an appropriate delay between
those two actions.

I have not found this constraint anywhere in the i.MX6 Reference Manual,
nor in the DW PCIe documents I have access to, which makes me a bit feel
a bit unhappy about this. Richard, do you have better info on why this
delay is needed and how long it needs to be? Or is this just empirical?

In general I'm ok with this patch, but still want a confirmation from
Tim that this doesn't break anything.

> Signed-off-by: Richard Zhu <r65037@freescale.com>
> ---
>  drivers/pci/host/pci-imx6.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
> index 233fe8a..bc4222b 100644
> --- a/drivers/pci/host/pci-imx6.c
> +++ b/drivers/pci/host/pci-imx6.c
> @@ -275,15 +275,15 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
>  		goto err_pcie;
>  	}
>  
> -	/* allow the clocks to stabilize */
> -	usleep_range(200, 500);
> -
>  	/* power up core phy and enable ref clock */
>  	regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>  			IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
>  	regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>  			IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
>  
> +	/* allow the clocks to stabilize */
> +	usleep_range(200, 500);
> +
>  	/* Some boards don't have PCIe reset GPIO. */
>  	if (gpio_is_valid(imx6_pcie->reset_gpio)) {
>  		gpio_set_value(imx6_pcie->reset_gpio, 0);
Tim Harvey Sept. 23, 2014, 12:28 p.m. UTC | #2
On Tue, Sep 23, 2014 at 2:56 AM, Lucas Stach <l.stach@pengutronix.de> wrote:
> Am Dienstag, den 23.09.2014, 12:11 +0800 schrieb Richard Zhu:
>> - a while delay is mandatory required after pcie_ref_clk_en
>> is set. Otherwise, the system would be hang on imx6qdl ard
>> boards, because that imx6qdl boards don't have the reset_gpio.
>> - the clocks should be stable already after the
>> "clk_prepare_enable" is return. So I think it's ok to move the
>> usleep delay after the pcie_ref_en is set.
>>
>
> You are describing a lot of the conditions around the issue, but not the
> issue itself, which makes it hard to follow your commit message. After
> looking at the code I think the problem is this (and should be described
> accordingly):
>
> For boards without a reset gpio we skip the delay between enabling the
> pcie_ref_clk and touching the RC registers for configuration. Apparently
> this hangs when the clocks are not yet settled in the DW PCIe core. So
> we need to make sure that there is always an appropriate delay between
> those two actions.
>
> I have not found this constraint anywhere in the i.MX6 Reference Manual,
> nor in the DW PCIe documents I have access to, which makes me a bit feel
> a bit unhappy about this. Richard, do you have better info on why this
> delay is needed and how long it needs to be? Or is this just empirical?
>
> In general I'm ok with this patch, but still want a confirmation from
> Tim that this doesn't break anything.

I agree with Lucas' comments and also agree that this can use some
testing. Based on my previous findings PCI link is very fragile. It
will take me a few days to get a proper test setup in a thermal
chamber with a host of boards but I will report back when I have
findings.

Tim

>
>> Signed-off-by: Richard Zhu <r65037@freescale.com>
>> ---
>>  drivers/pci/host/pci-imx6.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
>> index 233fe8a..bc4222b 100644
>> --- a/drivers/pci/host/pci-imx6.c
>> +++ b/drivers/pci/host/pci-imx6.c
>> @@ -275,15 +275,15 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
>>               goto err_pcie;
>>       }
>>
>> -     /* allow the clocks to stabilize */
>> -     usleep_range(200, 500);
>> -
>>       /* power up core phy and enable ref clock */
>>       regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>>                       IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
>>       regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>>                       IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
>>
>> +     /* allow the clocks to stabilize */
>> +     usleep_range(200, 500);
>> +
>>       /* Some boards don't have PCIe reset GPIO. */
>>       if (gpio_is_valid(imx6_pcie->reset_gpio)) {
>>               gpio_set_value(imx6_pcie->reset_gpio, 0);
>
> --
> Pengutronix e.K.             | Lucas Stach                 |
> Industrial Linux Solutions   | http://www.pengutronix.de/  |
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fabio Estevam Sept. 23, 2014, 12:45 p.m. UTC | #3
On Tue, Sep 23, 2014 at 1:11 AM, Richard Zhu <r65037@freescale.com> wrote:
> - a while delay is mandatory required after pcie_ref_clk_en
> is set. Otherwise, the system would be hang on imx6qdl ard
> boards, because that imx6qdl boards don't have the reset_gpio.

The mx6qdl sabreauto boards do have PCI reset pins. They come from the
I2C MAX7310 expander.

Yes, there are boards that do not have PCI reset GPIO, but this commit
log need to be rewritten.
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Zhu Sept. 25, 2014, 5:21 a.m. UTC | #4
DQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IFRpbSBIYXJ2ZXkgW21haWx0
bzp0aGFydmV5QGdhdGV3b3Jrcy5jb21dDQo+IFNlbnQ6IFR1ZXNkYXksIFNlcHRlbWJlciAyMywg
MjAxNCA4OjI5IFBNDQo+IFRvOiBMdWNhcyBTdGFjaDsgWmh1IFJpY2hhcmQtUjY1MDM3DQo+IENj
OiBsaW51eC1wY2ktb3duZXJAdmdlci5rZXJuZWwub3JnOyBsaW51eC1wY2lAdmdlci5rZXJuZWwu
b3JnOyBHdW8gU2hhd24tDQo+IFI2NTA3MzsgRmFiaW8gRXN0ZXZhbQ0KPiBTdWJqZWN0OiBSZTog
W1BBVENIIHYyIDIvNV0gUENJOiBpbXg2OiB3YWl0IHRoZSBjbG9ja3MgdG8gc3RhYmlsaXplIGFm
dGVyDQo+IHJlZl9lbg0KPiANCj4gT24gVHVlLCBTZXAgMjMsIDIwMTQgYXQgMjo1NiBBTSwgTHVj
YXMgU3RhY2ggPGwuc3RhY2hAcGVuZ3V0cm9uaXguZGU+IHdyb3RlOg0KPiA+IEFtIERpZW5zdGFn
LCBkZW4gMjMuMDkuMjAxNCwgMTI6MTEgKzA4MDAgc2NocmllYiBSaWNoYXJkIFpodToNCj4gPj4g
LSBhIHdoaWxlIGRlbGF5IGlzIG1hbmRhdG9yeSByZXF1aXJlZCBhZnRlciBwY2llX3JlZl9jbGtf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BDSUVfUkVGX0NMS19F
TiwgMSA8PCAxNik7DQo+ID4+DQo+ID4+ICsgICAgIC8qIGFsbG93IHRoZSBjbG9ja3MgdG8gc3Rh
YmlsaXplICovDQo+ID4+ICsgICAgIHVzbGVlcF9yYW5nZSgyMDAsIDUwMCk7DQo+ID4+ICsNCj4g
Pj4gICAgICAgLyogU29tZSBib2FyZHMgZG9uJ3QgaGF2ZSBQQ0llIHJlc2V0IEdQSU8uICovDQo+
ID4+ICAgICAgIGlmIChncGlvX2lzX3ZhbGlkKGlteDZfcGNpZS0+cmVzZXRfZ3BpbykpIHsNCj4g
Pj4gICAgICAgICAgICAgICBncGlvX3NldF92YWx1ZShpbXg2X3BjaWUtPnJlc2V0X2dwaW8sIDAp
Ow0KPiA+DQo+ID4gLS0NCj4gPiBQZW5ndXRyb25peCBlLksuICAgICAgICAgICAgIHwgTHVjYXMg
U3RhY2ggICAgICAgICAgICAgICAgIHwNCj4gPiBJbmR1c3RyaWFsIExpbnV4IFNvbHV0aW9ucyAg
IHwgaHR0cDovL3d3dy5wZW5ndXRyb25peC5kZS8gIHwNCj4gPg0KPiA+IC0tDQo+ID4gVG8gdW5z
dWJzY3JpYmUgZnJvbSB0aGlzIGxpc3Q6IHNlbmQgdGhlIGxpbmUgInVuc3Vic2NyaWJlIGxpbnV4
LXBjaSINCj4gPiBpbiB0aGUgYm9keSBvZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIua2Vy
bmVsLm9yZyBNb3JlIG1ham9yZG9tbw0KPiA+IGluZm8gYXQgIGh0dHA6Ly92Z2VyLmtlcm5lbC5v
cmcvbWFqb3Jkb21vLWluZm8uaHRtbA0K
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tim Harvey Oct. 1, 2014, 6 p.m. UTC | #5
On Tue, Sep 23, 2014 at 5:28 AM, Tim Harvey <tharvey@gateworks.com> wrote:
> On Tue, Sep 23, 2014 at 2:56 AM, Lucas Stach <l.stach@pengutronix.de> wrote:
>> Am Dienstag, den 23.09.2014, 12:11 +0800 schrieb Richard Zhu:
>>> - a while delay is mandatory required after pcie_ref_clk_en
>>> is set. Otherwise, the system would be hang on imx6qdl ard
>>> boards, because that imx6qdl boards don't have the reset_gpio.
>>> - the clocks should be stable already after the
>>> "clk_prepare_enable" is return. So I think it's ok to move the
>>> usleep delay after the pcie_ref_en is set.
>>>
>>
>> You are describing a lot of the conditions around the issue, but not the
>> issue itself, which makes it hard to follow your commit message. After
>> looking at the code I think the problem is this (and should be described
>> accordingly):
>>
>> For boards without a reset gpio we skip the delay between enabling the
>> pcie_ref_clk and touching the RC registers for configuration. Apparently
>> this hangs when the clocks are not yet settled in the DW PCIe core. So
>> we need to make sure that there is always an appropriate delay between
>> those two actions.
>>
>> I have not found this constraint anywhere in the i.MX6 Reference Manual,
>> nor in the DW PCIe documents I have access to, which makes me a bit feel
>> a bit unhappy about this. Richard, do you have better info on why this
>> delay is needed and how long it needs to be? Or is this just empirical?
>>
>> In general I'm ok with this patch, but still want a confirmation from
>> Tim that this doesn't break anything.
>
> I agree with Lucas' comments and also agree that this can use some
> testing. Based on my previous findings PCI link is very fragile. It
> will take me a few days to get a proper test setup in a thermal
> chamber with a host of boards but I will report back when I have
> findings.
>
> Tim
>
>>
>>> Signed-off-by: Richard Zhu <r65037@freescale.com>
>>> ---
>>>  drivers/pci/host/pci-imx6.c | 6 +++---
>>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
>>> index 233fe8a..bc4222b 100644
>>> --- a/drivers/pci/host/pci-imx6.c
>>> +++ b/drivers/pci/host/pci-imx6.c
>>> @@ -275,15 +275,15 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
>>>               goto err_pcie;
>>>       }
>>>
>>> -     /* allow the clocks to stabilize */
>>> -     usleep_range(200, 500);
>>> -
>>>       /* power up core phy and enable ref clock */
>>>       regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>>>                       IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
>>>       regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
>>>                       IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
>>>
>>> +     /* allow the clocks to stabilize */
>>> +     usleep_range(200, 500);
>>> +
>>>       /* Some boards don't have PCIe reset GPIO. */
>>>       if (gpio_is_valid(imx6_pcie->reset_gpio)) {
>>>               gpio_set_value(imx6_pcie->reset_gpio, 0);
>>

I tested this across temperature over 300+ boots each on several IMX6
based boards with switches and did not encounter any link failures.

Tested-by: Tim Harvey <tharvey@gateworks.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Zhu Oct. 2, 2014, 2:26 a.m. UTC | #6
Thanks Tim.

Best regards
Richard

> 在 2014年10月2日,上午2:00,"Tim Harvey" <tharvey@gateworks.com> 写道:

> 

>> On Tue, Sep 23, 2014 at 5:28 AM, Tim Harvey <tharvey@gateworks.com> wrote:

>>> On Tue, Sep 23, 2014 at 2:56 AM, Lucas Stach <l.stach@pengutronix.de> wrote:

>>> Am Dienstag, den 23.09.2014, 12:11 +0800 schrieb Richard Zhu:

>>>> - a while delay is mandatory required after pcie_ref_clk_en

>>>> is set. Otherwise, the system would be hang on imx6qdl ard

>>>> boards, because that imx6qdl boards don't have the reset_gpio.

>>>> - the clocks should be stable already after the

>>>> "clk_prepare_enable" is return. So I think it's ok to move the

>>>> usleep delay after the pcie_ref_en is set.

>>> 

>>> You are describing a lot of the conditions around the issue, but not the

>>> issue itself, which makes it hard to follow your commit message. After

>>> looking at the code I think the problem is this (and should be described

>>> accordingly):

>>> 

>>> For boards without a reset gpio we skip the delay between enabling the

>>> pcie_ref_clk and touching the RC registers for configuration. Apparently

>>> this hangs when the clocks are not yet settled in the DW PCIe core. So

>>> we need to make sure that there is always an appropriate delay between

>>> those two actions.

>>> 

>>> I have not found this constraint anywhere in the i.MX6 Reference Manual,

>>> nor in the DW PCIe documents I have access to, which makes me a bit feel

>>> a bit unhappy about this. Richard, do you have better info on why this

>>> delay is needed and how long it needs to be? Or is this just empirical?

>>> 

>>> In general I'm ok with this patch, but still want a confirmation from

>>> Tim that this doesn't break anything.

>> 

>> I agree with Lucas' comments and also agree that this can use some

>> testing. Based on my previous findings PCI link is very fragile. It

>> will take me a few days to get a proper test setup in a thermal

>> chamber with a host of boards but I will report back when I have

>> findings.

>> 

>> Tim

>> 

>>> 

>>>> Signed-off-by: Richard Zhu <r65037@freescale.com>

>>>> ---

>>>> drivers/pci/host/pci-imx6.c | 6 +++---

>>>> 1 file changed, 3 insertions(+), 3 deletions(-)

>>>> 

>>>> diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c

>>>> index 233fe8a..bc4222b 100644

>>>> --- a/drivers/pci/host/pci-imx6.c

>>>> +++ b/drivers/pci/host/pci-imx6.c

>>>> @@ -275,15 +275,15 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)

>>>>              goto err_pcie;

>>>>      }

>>>> 

>>>> -     /* allow the clocks to stabilize */

>>>> -     usleep_range(200, 500);

>>>> -

>>>>      /* power up core phy and enable ref clock */

>>>>      regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,

>>>>                      IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);

>>>>      regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,

>>>>                      IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);

>>>> 

>>>> +     /* allow the clocks to stabilize */

>>>> +     usleep_range(200, 500);

>>>> +

>>>>      /* Some boards don't have PCIe reset GPIO. */

>>>>      if (gpio_is_valid(imx6_pcie->reset_gpio)) {

>>>>              gpio_set_value(imx6_pcie->reset_gpio, 0);

> 

> I tested this across temperature over 300+ boots each on several IMX6

> based boards with switches and did not encounter any link failures.

> 

> Tested-by: Tim Harvey <tharvey@gateworks.com>
Fabio Estevam Oct. 24, 2014, 1:51 a.m. UTC | #7
Hi Richard,

On Tue, Sep 23, 2014 at 1:11 AM, Richard Zhu <r65037@freescale.com> wrote:
> - a while delay is mandatory required after pcie_ref_clk_en
> is set. Otherwise, the system would be hang on imx6qdl ard
> boards, because that imx6qdl boards don't have the reset_gpio.
> - the clocks should be stable already after the
> "clk_prepare_enable" is return. So I think it's ok to move the
> usleep delay after the pcie_ref_en is set.
>
> Signed-off-by: Richard Zhu <r65037@freescale.com>

Tested-by: Fabio Estevam <fabio.estevam@freescale.com>

Without this patch we notice that the kernel does not boot anymore
since commit  3fce0e882f61 (PCI: imx6: Delay enabling reference clock
for SS until it stabilizes) on a system that does not pass the PCI
gpio reset in the dtb. This causes a regression on mx6 nitrogen
boards.

I would suggest that you resend this patch only so that it could be
applied into 3.18 as a bug fix.
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Richard Zhu Oct. 24, 2014, 2:46 a.m. UTC | #8
DQo+IC0tLS0tT3JpZ2luYWwgTWVzc2FnZS0tLS0tDQo+IEZyb206IEZhYmlvIEVzdGV2YW0gW21h
aWx0bzpmZXN0ZXZhbUBnbWFpbC5jb21dDQo+IFNlbnQ6IEZyaWRheSwgT2N0b2JlciAyNCwgMjAx
NCA5OjUxIEFNDQo+IFRvOiBaaHUgUmljaGFyZC1SNjUwMzcNCj4gQ2M6IGxpbnV4LXBjaS1vd25l
ckB2Z2VyLmtlcm5lbC5vcmc7IGxpbnV4LXBjaUB2Z2VyLmtlcm5lbC5vcmc7IEd1byBTaGF3bi0N
Cj4gUjY1MDczOyBMdWNhcyBTdGFjaDsgVGltIEhhcnZleTsgQmpvcm4gSGVsZ2Fhcw0KPiBTdWJq
ZWN0OiBSZTogW1BBVENIIHYyIDIvN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BlbmFibGlu
ZyByZWZlcmVuY2UgY2xvY2sgZm9yIFNTIHVudGlsDQo+IGl0IHN0YWJpbGl6ZXMpIG9uIGEgc3lz
dGVtIHRoYXQgZG9lcyBub3QgcGFzcyB0aGUgUENJIGdwaW8gcmVzZXQgaW4gdGhlIGR0Yi4NCj4g
VGhpcyBjYXVzZXMgYSByZWdyZXNzaW9uIG9uIG14NiBuaXRyb2dlbiBib2FyZHMuDQo+IA0KPiBJ
IHdvdWxkIHN1Z2dlc3QgdGhhdCB5b3UgcmVzZW5kIHRoaXMgcGF0Y2ggb25seSBzbyB0aGF0IGl0
IGNvdWxkIGJlIGFwcGxpZWQNCj4gaW50byAzLjE4IGFzIGEgYnVnIGZpeC4NCg0KDQpPa2F5LCBJ
IHdvdWxkIHNlbmQgb3V0IHRoZSBwYXRjaCB0b2RheS4NCg0KQmVzdCBSZWdhcmRzDQpSaWNoYXJk
IFpodQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c
index 233fe8a..bc4222b 100644
--- a/drivers/pci/host/pci-imx6.c
+++ b/drivers/pci/host/pci-imx6.c
@@ -275,15 +275,15 @@  static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
 		goto err_pcie;
 	}
 
-	/* allow the clocks to stabilize */
-	usleep_range(200, 500);
-
 	/* power up core phy and enable ref clock */
 	regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
 			IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
 	regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
 			IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
 
+	/* allow the clocks to stabilize */
+	usleep_range(200, 500);
+
 	/* Some boards don't have PCIe reset GPIO. */
 	if (gpio_is_valid(imx6_pcie->reset_gpio)) {
 		gpio_set_value(imx6_pcie->reset_gpio, 0);