rockchip rk3399 port initialization fixes
v3 cover rockchip rk3399 port initialization fixes
A couple of patches to have the rockchip rk3399 host controller port initialization follow the PCI specifications around PERST# signal timing handling.
Changes from v2:
- Use PCIE_T_PVPERL_MS macro in patch 1 (and remove useless comments).
- Split second msleep() addition into patch 2 as suggested by Bjorn.
Changes from v1:
- Add more specification details to the commit message.
- Add missing msleep(100) after PERST# is deasserted.
Damien Le Moal (2):
PCI: rockchip-host: Fix rockchip_pcie_host_init_port() PERST# handling
PCI: rockchip-host: Wait 100ms after reset before starting configuration
drivers/pci/controller/pcie-rockchip-host.c | 3 +++ drivers/pci/pci.h | 7 +++++++ 2 files changed, 10 insertions(+)
Signature · 1 line
2.44.0
PATCH v3 1/2 PCI: rockchip-host: Fix rockchip_pcie_host_init_port() PERST# handling
The PCIe specifications (PCI Express Electromechanical Specification rev 2.0, section 2.6.2) mandate that the PERST# signal must remain asserted for at least 100 usec (Tperst-clk) after the PCIe reference clock becomes stable (if a reference clock is supplied), and for at least 100 msec after the power is stable (Tpvperl, defined by the macro PCIE_T_PVPERL_MS).
Modify rockchip_pcie_host_init_port() to satisfy these constraints by adding a sleep period before bringing back PESRT# signal to high using the ep_gpio GPIO. Since Tperst-clk is the shorter wait time, add an msleep() call for the longer PCIE_T_PVPERL_MS milliseconds to handle both timing requirements.
--- drivers/pci/controller/pcie-rockchip-host.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/pcie-rockchip-host.c +1 -0
@@ -322,6 +322,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)rockchip_pcie_write (rockchip,PCIE_CLIENT_LINK_TRAIN_ENABLE ,PCIE_CLIENT_CONFIG ); +msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (rockchip->ep_gpio,1 );/* 500ms timeout value should be enough for Gen1/2 training */
Signature · 1 line
2.44.0
Re: [PATCH v3 1/2] PCI: rockchip-host: Fix rockchip_pcie_host_init_port() PERST# handling
Quoted 2 lines · Damien Le Moal
The PCIe specifications (PCI Express Electromechanical Specification rev 2.0, section 2.6.2) mandate that the PERST# signal must remain asserted
"PCIe CEM r5.1, sec 2.9.2"
Quoted 7 lines
for at least 100 usec (Tperst-clk) after the PCIe reference clock becomes stable (if a reference clock is supplied), and for at least 100 msec after the power is stable (Tpvperl, defined by the macro
PCIE_T_PVPERL_MS).Modify
rockchip_pcie_host_init_port()to satisfy these constraints by adding a sleep period before bringing back PESRT# signal to high using
s/PESRT#/PERST#/
s/bringing back PERST# to high/deasserting PERST#/
Whoever applies this can probably fix these up for you.
Quoted 14 lines
the
ep_gpioGPIO. Since Tperst-clk is the shorter wait time, add anmsleep()call for the longerPCIE_T_PVPERL_MSmilliseconds to handle both timing requirements.Signed-off-by Damien Le Moal <[email protected]>--- drivers/pci/controller/pcie-rockchip-host.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/controller/pcie-rockchip-host.c +0
-0
drivers/pci/controller/pcie-rockchip-host.c static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip) · line 325
Quoted 4 lines
drivers/pci/controller/pcie-rockchip-host.c +1
-0@@ -322,6 +322,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)rockchip_pcie_write (rockchip,PCIE_CLIENT_LINK_TRAIN_ENABLE ,PCIE_CLIENT_CONFIG ); +msleep (PCIE_T_PVPERL_MS );
Looks good, thanks!
Quoted 6 lines
drivers/pci/controller/pcie-rockchip-host.c +0
-0gpiod_set_value_cansleep (rockchip->ep_gpio,1 );/* 500ms timeout value should be enough for Gen1/2 training */ Signature · 1 line
2.44.0
Re: [PATCH v3 1/2] PCI: rockchip-host: Fix rockchip_pcie_host_init_port() PERST# handling
In reply to Damien Le MoalQuoted 7 lines · Damien Le Moal
The PCIe specifications (PCI Express Electromechanical Specification rev 2.0, section 2.6.2) mandate that the PERST# signal must remain asserted for at least 100 usec (Tperst-clk) after the PCIe reference clock becomes stable (if a reference clock is supplied), and for at least 100 msec after the power is stable (Tpvperl, defined by the macro
PCIE_T_PVPERL_MS).
Quoted 7 lines
Modify
rockchip_pcie_host_init_port()to satisfy these constraints by adding a sleep period before bringing back PESRT# signal to high using theep_gpioGPIO. Since Tperst-clk is the shorter wait time, add anmsleep()call for the longerPCIE_T_PVPERL_MSmilliseconds to handle both timing requirements.Signed-off-by Damien Le Moal <[email protected]>
- Mani
Quoted 20 lines
--- drivers/pci/controller/pcie-rockchip-host.c | 1 + 1 file changed, 1 insertion(+)drivers/pci/controller/pcie-rockchip-host.c +1
-0@@ -322,6 +322,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)rockchip_pcie_write (rockchip,PCIE_CLIENT_LINK_TRAIN_ENABLE ,PCIE_CLIENT_CONFIG ); +msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (rockchip->ep_gpio,1 );/* 500ms timeout value should be enough for Gen1/2 training */ Signature · 1 line
2.44.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
PATCH v3 2/2 PCI: rockchip-host: Wait 100ms after reset before starting configuration
In reply to Damien Le MoalThe PCI Express Base Specification r6.0, section 6.6.1, states that the host should wait for at least 100 msec from the end of a conventional reset (PERST# is de-asserted) before sending a configuration request to ensure that the device is able to respond with a "Request Retry Status" completion.
Add the PCIE_T_RRS_READY_MS macro to define this wait time and modify rockchip_pcie_host_init_port() to add this 100ms sleep after bringing back PESRT# signal to high using the ep_gpio GPIO.
--- drivers/pci/controller/pcie-rockchip-host.c | 2 ++ drivers/pci/pci.h | 7 +++++++ 2 files changed, 9 insertions(+)
drivers/pci/controller/pcie-rockchip-host.c +2 -0
@@ -325,6 +325,8 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (rockchip->ep_gpio,1 ); +msleep (PCIE_T_RRS_READY_MS ); +/* 500ms timeout value should be enough for Gen1/2 training */ err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1, status, PCIE_LINK_UP(status), 20,
drivers/pci/pci.h +7 -0
@@ -16,6 +16,13 @@/* Power stable to PERST# inactive from PCIe card Electromechanical Spec */ #define PCIE_T_PVPERL_MS 100 +/* +* End of conventional reset (PERST# de-asserted) to first configuration +* request (device able to respond with a "Request Retry Status" completion), +* from PCI Express Base Specification r6.0, section 6.6.1. +*/ +#define PCIE_T_RRS_READY_MS 100 +/* * PCIe r6.0, sec 5.3.3.2.1 <PME Synchronization> * Recommends 1ms to 10ms timeout to check L2 ready.
Signature · 1 line
2.44.0
Re: [PATCH v3 2/2] PCI: rockchip-host: Wait 100ms after reset before starting configuration
Quoted 9 lines · Damien Le Moal
The PCI Express Base Specification r6.0, section 6.6.1, states that the host should wait for at least 100 msec from the end of a conventional reset (PERST# is de-asserted) before sending a configuration request to ensure that the device is able to respond with a "Request Retry Status" completion.
Add the
PCIE_T_RRS_READY_MSmacro to define this wait time and modifyrockchip_pcie_host_init_port()to add this 100ms sleep after bringing back PESRT# signal to high using theep_gpioGPIO.
s/PESRT#/PERST#/
s/bringing back PERST# signal to high/deasserting PERST#/
Quoted 25 lines
Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Damien Le Moal <[email protected]>--- drivers/pci/controller/pcie-rockchip-host.c | 2 ++ drivers/pci/pci.h | 7 +++++++ 2 files changed, 9 insertions(+)drivers/pci/controller/pcie-rockchip-host.c +2
-0@@ -325,6 +325,8 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (rockchip->ep_gpio,1 ); +msleep (PCIE_T_RRS_READY_MS ); +/* 500ms timeout value should be enough for Gen1/2 training */ err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1, status, PCIE_LINK_UP(status), 20,drivers/pci/pci.h +0
-0
drivers/pci/pci.h line 22
Quoted 7 lines
drivers/pci/pci.h +4
-0@@ -16,6 +16,13 @@/* Power stable to PERST# inactive from PCIe card Electromechanical Spec */ #define PCIE_T_PVPERL_MS 100 +/* +* End of conventional reset (PERST# de-asserted) to first configuration +* request (device able to respond with a "Request Retry Status" completion), +* from PCI Express Base Specification r6.0, section 6.6.1.
"PCIe r6.0, sec 6.6.1" to match typical style, e.g., the reference just below.
Whoever applies this can take care of this.
drivers/pci/pci.h line 24
Quoted 1 line
drivers/pci/pci.h +1
-0+#define PCIE_T_RRS_READY_MS 100
Thanks a lot for doing this; there are many similar places we can update to use this #define.
Quoted 6 lines
drivers/pci/pci.h +0
-0/* * PCIe r6.0, sec 5.3.3.2.1 <PME Synchronization> * Recommends 1ms to 10ms timeout to check L2 ready. Signature · 1 line
2.44.0
Re: [PATCH v3 2/2] PCI: rockchip-host: Wait 100ms after reset before starting configuration
Quoted 50 lines · Bjorn Helgaas
Quoted 9 lines · Damien Le Moal
The PCI Express Base Specification r6.0, section 6.6.1, states that the host should wait for at least 100 msec from the end of a conventional reset (PERST# is de-asserted) before sending a configuration request to ensure that the device is able to respond with a "Request Retry Status" completion.
Add the
PCIE_T_RRS_READY_MSmacro to define this wait time and modifyrockchip_pcie_host_init_port()to add this 100ms sleep after bringing back PESRT# signal to high using theep_gpioGPIO.s/PESRT#/PERST#/
s/bringing back PERST# signal to high/deasserting PERST#/Quoted 25 lines
Suggested-by Bjorn Helgaas <[email protected]>Signed-off-by Damien Le Moal <[email protected]>--- drivers/pci/controller/pcie-rockchip-host.c | 2 ++ drivers/pci/pci.h | 7 +++++++ 2 files changed, 9 insertions(+)drivers/pci/controller/pcie-rockchip-host.c +2
-0@@ -325,6 +325,8 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)msleep (PCIE_T_PVPERL_MS );gpiod_set_value_cansleep (rockchip->ep_gpio,1 ); +msleep (PCIE_T_RRS_READY_MS ); +/* 500ms timeout value should be enough for Gen1/2 training */ err = readl_poll_timeout(rockchip->apb_base + PCIE_CLIENT_BASIC_STATUS1, status, PCIE_LINK_UP(status), 20,drivers/pci/pci.h +0
-0drivers/pci/pci.h line 22
Quoted 7 lines
drivers/pci/pci.h +4
-0@@ -16,6 +16,13 @@/* Power stable to PERST# inactive from PCIe card Electromechanical Spec */ #define PCIE_T_PVPERL_MS 100 +/* +* End of conventional reset (PERST# de-asserted) to first configuration +* request (device able to respond with a "Request Retry Status" completion), +* from PCI Express Base Specification r6.0, section 6.6.1. "PCIe r6.0, sec 6.6.1" to match typical style, e.g., the reference just below.
Quoted 1 line
Whoever applies this can take care of this.
To make it easier to apply, I sent v4 with the corrections. Thanks.
Quoted 12 lines
drivers/pci/pci.h line 24
Quoted 2 lines
drivers/pci/pci.h +1
-0+#define PCIE_T_RRS_READY_MS 100Thanks a lot for doing this; there are many similar places we can update to use this #define.
Quoted 6 lines
drivers/pci/pci.h +0
-0/* * PCIe r6.0, sec 5.3.3.2.1 <PME Synchronization> * Recommends 1ms to 10ms timeout to check L2 ready. Signature · 1 line
2.44.0
Signature · 2 lines
Damien Le Moal Western Digital Research