Skip to content

Commit 091022f

Browse files
damien-lemoalbjorn-helgaas
authored andcommitted
PCI: rockchip-ep: Refactor endpoint link training enable
The function rockchip_pcie_init_port() enables link training for a controller configured in EP mode. Enabling link training is again done in rockchip_pcie_ep_probe() after that function executed rockchip_pcie_init_port(). Enabling link training only needs to be done once, and doing so at the probe stage before the controller is actually started by the user serves no purpose. Refactor this by removing the link training enablement from both rockchip_pcie_init_port() and rockchip_pcie_ep_probe() and moving it to the endpoint start operation defined with rockchip_pcie_ep_start(). Enabling the controller configuration using the PCIE_CLIENT_CONF_ENABLE bit in the same PCIE_CLIENT_CONFIG register is also moved to rockchip_pcie_ep_start() and both the controller configuration and link training enable bits are set with a single call to rockchip_pcie_write(). Link: https://lore.kernel.org/r/20241017015849.190271-11-dlemoal@kernel.org Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 8efda8a commit 091022f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

drivers/pci/controller/pcie-rockchip-ep.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ static int rockchip_pcie_ep_start(struct pci_epc *epc)
467467

468468
rockchip_pcie_write(rockchip, cfg, PCIE_CORE_PHY_FUNC_CFG);
469469

470+
/* Enable configuration and start link training */
471+
rockchip_pcie_write(rockchip,
472+
PCIE_CLIENT_LINK_TRAIN_ENABLE |
473+
PCIE_CLIENT_CONF_ENABLE,
474+
PCIE_CLIENT_CONFIG);
475+
470476
return 0;
471477
}
472478

@@ -656,16 +662,9 @@ static int rockchip_pcie_ep_probe(struct platform_device *pdev)
656662

657663
rockchip_pcie_ep_hide_broken_msix_cap(rockchip);
658664

659-
/* Establish the link automatically */
660-
rockchip_pcie_write(rockchip, PCIE_CLIENT_LINK_TRAIN_ENABLE,
661-
PCIE_CLIENT_CONFIG);
662-
663665
/* Only enable function 0 by default */
664666
rockchip_pcie_write(rockchip, BIT(0), PCIE_CORE_PHY_FUNC_CFG);
665667

666-
rockchip_pcie_write(rockchip, PCIE_CLIENT_CONF_ENABLE,
667-
PCIE_CLIENT_CONFIG);
668-
669668
pci_epc_init_notify(epc);
670669

671670
return 0;

drivers/pci/controller/pcie-rockchip.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip)
244244
rockchip_pcie_write(rockchip, PCIE_CLIENT_GEN_SEL_1,
245245
PCIE_CLIENT_CONFIG);
246246

247-
regs = PCIE_CLIENT_LINK_TRAIN_ENABLE | PCIE_CLIENT_ARI_ENABLE |
247+
regs = PCIE_CLIENT_ARI_ENABLE |
248248
PCIE_CLIENT_CONF_LANE_NUM(rockchip->lanes);
249249

250250
if (rockchip->is_rc)
251-
regs |= PCIE_CLIENT_CONF_ENABLE | PCIE_CLIENT_MODE_RC;
251+
regs |= PCIE_CLIENT_LINK_TRAIN_ENABLE |
252+
PCIE_CLIENT_CONF_ENABLE | PCIE_CLIENT_MODE_RC;
252253
else
253254
regs |= PCIE_CLIENT_CONF_DISABLE | PCIE_CLIENT_MODE_EP;
254255

0 commit comments

Comments
 (0)