Skip to contentSkip to conversation

PCI: rockchip-host: Fix rockchip_pcie_host_init_port() PERST handling

PATCH Superseded Damien Le Moal 2 participants 2 messages Mar 29, 2024

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: rockchip-host: Fix rockchip_pcie_host_init_port() PERST handling

The PCI specifications mandate that PERST be asserted for at least 100ms. Make sure that is done in rockchip_pcie_host_init_port() by adding a 100ms sleep before bringing back PESRT signal to high using the ep_gpio GPIO. Comments are also added to clarify this behavior.

---
 drivers/pci/controller/pcie-rockchip-host.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/controller/pcie-rockchip-host.c +6 -0
index 300b9dc85ecc..d526b9d26c18 100644
@@ -294,6 +294,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
 	int err, i = MAX_LANE_NUM;
 	u32 status;
 
+	/* Assert PERST */
 	gpiod_set_value_cansleep(rockchip->ep_gpio, 0);
 
 	err = rockchip_pcie_init_port(rockchip);
@@ -322,6 +323,11 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
 	rockchip_pcie_write(rockchip, PCIE_CLIENT_LINK_TRAIN_ENABLE,
 			    PCIE_CLIENT_CONFIG);
 
+	/*
+	 * PCIe specifications mandate that PERST be asserted for at
+	 * least 100ms.
+	 */
+	msleep(100);
 	gpiod_set_value_cansleep(rockchip->ep_gpio, 1);
 
 	/* 500ms timeout value should be enough for Gen1/2 training */
Signature · 1 line
2.44.0
#1 lore raw

Observing the timing is the important thing here, if you can wedge that into the subject somehow.

Quoted 4 lines · Damien Le Moal

The PCI specifications mandate that PERST be asserted for at least 100ms. Make sure that is done in rockchip_pcie_host_init_port() by adding a 100ms sleep before bringing back PESRT signal to high using the ep_gpio GPIO. Comments are also added to clarify this behavior.

"PERST#" in spec, and to make the "assert" and "set value to 0" all match up.

s/PESRT/PERST#/

Quoted 18 lines
---
 drivers/pci/controller/pcie-rockchip-host.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/pci/controller/pcie-rockchip-host.c +1 -0
index 300b9dc85ecc..d526b9d26c18 100644
@@ -294,6 +294,7 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
 	int err, i = MAX_LANE_NUM;
 	u32 status;
 
+	/* Assert PERST */
 	gpiod_set_value_cansleep(rockchip->ep_gpio, 0);
 
 	err = rockchip_pcie_init_port(rockchip);

drivers/pci/controller/pcie-rockchip-host.c static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip) · line 330

Quoted 8 lines
drivers/pci/controller/pcie-rockchip-host.c +5 -0
@@ -322,6 +323,11 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip)
 	rockchip_pcie_write(rockchip, PCIE_CLIENT_LINK_TRAIN_ENABLE,
 			    PCIE_CLIENT_CONFIG);
 
+	/*
+	 * PCIe specifications mandate that PERST be asserted for at
+	 * least 100ms.
+	 */
+	msleep(100);

Specific rev, section citation? And a name for the parameter if there is one (T_PVPERL, etc). And hopefully a macro along the lines of PCIE_T_PVPERL_MS since this isn't rockchip-specific.

Quoted 6 lines
drivers/pci/controller/pcie-rockchip-host.c +0 -0
 	gpiod_set_value_cansleep(rockchip->ep_gpio, 1);
 
 	/* 500ms timeout value should be enough for Gen1/2 training */
Signature · 1 line
2.44.0