Skip to content

Commit c0b9375

Browse files
twilfredobjorn-helgaas
authored andcommitted
PCI: dw-rockchip: Delay link training after hot reset in EP mode
RK3588 TRM, section "11.6.1.3.3 Hot Reset and Link-Down Reset" states that: If you want to delay link re-establishment (after reset) so that you can reprogram some registers through DBI, you must set app_ltssm_enable =0 immediately after core_rst_n as shown in above. This can be achieved by enable the app_dly2_en, and end-up the delay by assert app_dly2_done. I.e. setting app_dly2_en will automatically deassert app_ltssm_enable on a hot reset, and setting app_dly2_done will re-assert app_ltssm_enable, re-enabling link training. When receiving a hot reset/link-down IRQ when running in EP mode, we will call dw_pcie_ep_linkdown(), which may update registers through DBI. Unless link training is inhibited, these register updates race with the link training. To avoid the race, set PCIE_LTSSM_APP_DLY2_EN so the controller never automatically trains the link after a link-down or hot reset interrupt. That way any DBI updates done in the dw_pcie_ep_linkdown() path will happen while the link is still down. Then allow link training by setting PCIE_LTSSM_APP_DLY2_DONE Co-developed-by: Niklas Cassel <[email protected]> Signed-off-by: Wilfred Mallawa <[email protected]> Signed-off-by: Niklas Cassel <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 19272b3 commit c0b9375

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/pci/controller/dwc/pcie-dw-rockchip.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858

5959
/* Hot Reset Control Register */
6060
#define PCIE_CLIENT_HOT_RESET_CTRL 0x180
61+
#define PCIE_LTSSM_APP_DLY2_EN BIT(1)
62+
#define PCIE_LTSSM_APP_DLY2_DONE BIT(3)
6163
#define PCIE_LTSSM_ENABLE_ENHANCE BIT(4)
6264

6365
/* LTSSM Status Register */
@@ -474,7 +476,7 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
474476
struct rockchip_pcie *rockchip = arg;
475477
struct dw_pcie *pci = &rockchip->pci;
476478
struct device *dev = pci->dev;
477-
u32 reg;
479+
u32 reg, val;
478480

479481
reg = rockchip_pcie_readl_apb(rockchip, PCIE_CLIENT_INTR_STATUS_MISC);
480482
rockchip_pcie_writel_apb(rockchip, reg, PCIE_CLIENT_INTR_STATUS_MISC);
@@ -485,6 +487,10 @@ static irqreturn_t rockchip_pcie_ep_sys_irq_thread(int irq, void *arg)
485487
if (reg & PCIE_LINK_REQ_RST_NOT_INT) {
486488
dev_dbg(dev, "hot reset or link-down reset\n");
487489
dw_pcie_ep_linkdown(&pci->ep);
490+
/* Stop delaying link training. */
491+
val = HIWORD_UPDATE_BIT(PCIE_LTSSM_APP_DLY2_DONE);
492+
rockchip_pcie_writel_apb(rockchip, val,
493+
PCIE_CLIENT_HOT_RESET_CTRL);
488494
}
489495

490496
if (reg & PCIE_RDLH_LINK_UP_CHGED) {
@@ -566,8 +572,11 @@ static int rockchip_pcie_configure_ep(struct platform_device *pdev,
566572
return ret;
567573
}
568574

569-
/* LTSSM enable control mode */
570-
val = HIWORD_UPDATE_BIT(PCIE_LTSSM_ENABLE_ENHANCE);
575+
/*
576+
* LTSSM enable control mode, and automatically delay link training on
577+
* hot reset/link-down reset.
578+
*/
579+
val = HIWORD_UPDATE_BIT(PCIE_LTSSM_ENABLE_ENHANCE | PCIE_LTSSM_APP_DLY2_EN);
571580
rockchip_pcie_writel_apb(rockchip, val, PCIE_CLIENT_HOT_RESET_CTRL);
572581

573582
rockchip_pcie_writel_apb(rockchip, PCIE_CLIENT_EP_MODE,

0 commit comments

Comments
 (0)