Skip to content

Commit 5364f3a

Browse files
FROMLIST: PCI: qcom: Add support for host_stop_link() & host_start_link()
Add support for host_stop_link() and host_start_link() for switches like TC956x, which require configuration before the PCIe link is established. Assert PERST# and disable LTSSM bit to prevent the PCIe controller from participating in link training during host_stop_link(). De-assert PERST# and enable LTSSM bit during host_start_link(). Introduce ltssm_disable function op to stop link training. For the switches like TC956x, which needs to configure it before the PCIe link is established. Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Krishna Chaitanya Chundru <[email protected]>
1 parent 0d3d0b4 commit 5364f3a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

drivers/pci/controller/dwc/pcie-qcom.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ struct qcom_pcie_ops {
250250
void (*host_post_init)(struct qcom_pcie *pcie);
251251
void (*deinit)(struct qcom_pcie *pcie);
252252
void (*ltssm_enable)(struct qcom_pcie *pcie);
253+
void (*ltssm_disable)(struct qcom_pcie *pcie);
253254
int (*config_sid)(struct qcom_pcie *pcie);
254255
};
255256

@@ -642,6 +643,37 @@ static int qcom_pcie_post_init_1_0_0(struct qcom_pcie *pcie)
642643
return 0;
643644
}
644645

646+
static int qcom_pcie_host_start_link(struct dw_pcie *pci)
647+
{
648+
struct qcom_pcie *pcie = to_qcom_pcie(pci);
649+
650+
qcom_ep_reset_deassert(pcie);
651+
652+
if (pcie->cfg->ops->ltssm_enable)
653+
pcie->cfg->ops->ltssm_enable(pcie);
654+
655+
return 0;
656+
}
657+
658+
static void qcom_pcie_host_stop_link(struct dw_pcie *pci)
659+
{
660+
struct qcom_pcie *pcie = to_qcom_pcie(pci);
661+
662+
qcom_ep_reset_assert(pcie);
663+
664+
if (pcie->cfg->ops->ltssm_disable)
665+
pcie->cfg->ops->ltssm_disable(pcie);
666+
}
667+
668+
static void qcom_pcie_2_3_2_ltssm_disable(struct qcom_pcie *pcie)
669+
{
670+
u32 val;
671+
672+
val = readl(pcie->parf + PARF_LTSSM);
673+
val &= ~LTSSM_EN;
674+
writel(val, pcie->parf + PARF_LTSSM);
675+
}
676+
645677
static void qcom_pcie_2_3_2_ltssm_enable(struct qcom_pcie *pcie)
646678
{
647679
u32 val;
@@ -1435,6 +1467,7 @@ static const struct qcom_pcie_ops ops_1_9_0 = {
14351467
.host_post_init = qcom_pcie_host_post_init_2_7_0,
14361468
.deinit = qcom_pcie_deinit_2_7_0,
14371469
.ltssm_enable = qcom_pcie_2_3_2_ltssm_enable,
1470+
.ltssm_disable = qcom_pcie_2_3_2_ltssm_disable,
14381471
.config_sid = qcom_pcie_config_sid_1_9_0,
14391472
};
14401473

@@ -1506,6 +1539,8 @@ static const struct qcom_pcie_cfg cfg_fw_managed = {
15061539
static const struct dw_pcie_ops dw_pcie_ops = {
15071540
.link_up = qcom_pcie_link_up,
15081541
.start_link = qcom_pcie_start_link,
1542+
.host_start_link = qcom_pcie_host_start_link,
1543+
.host_stop_link = qcom_pcie_host_stop_link,
15091544
};
15101545

15111546
static int qcom_pcie_icc_init(struct qcom_pcie *pcie)

0 commit comments

Comments
 (0)