Skip to content

Commit 69d8388

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 df237d9 commit 69d8388

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
@@ -247,6 +247,7 @@ struct qcom_pcie_ops {
247247
void (*host_post_init)(struct qcom_pcie *pcie);
248248
void (*deinit)(struct qcom_pcie *pcie);
249249
void (*ltssm_enable)(struct qcom_pcie *pcie);
250+
void (*ltssm_disable)(struct qcom_pcie *pcie);
250251
int (*config_sid)(struct qcom_pcie *pcie);
251252
};
252253

@@ -618,6 +619,37 @@ static int qcom_pcie_post_init_1_0_0(struct qcom_pcie *pcie)
618619
return 0;
619620
}
620621

622+
static int qcom_pcie_host_start_link(struct dw_pcie *pci)
623+
{
624+
struct qcom_pcie *pcie = to_qcom_pcie(pci);
625+
626+
qcom_ep_reset_deassert(pcie);
627+
628+
if (pcie->cfg->ops->ltssm_enable)
629+
pcie->cfg->ops->ltssm_enable(pcie);
630+
631+
return 0;
632+
}
633+
634+
static void qcom_pcie_host_stop_link(struct dw_pcie *pci)
635+
{
636+
struct qcom_pcie *pcie = to_qcom_pcie(pci);
637+
638+
qcom_ep_reset_assert(pcie);
639+
640+
if (pcie->cfg->ops->ltssm_disable)
641+
pcie->cfg->ops->ltssm_disable(pcie);
642+
}
643+
644+
static void qcom_pcie_2_3_2_ltssm_disable(struct qcom_pcie *pcie)
645+
{
646+
u32 val;
647+
648+
val = readl(pcie->parf + PARF_LTSSM);
649+
val &= ~LTSSM_EN;
650+
writel(val, pcie->parf + PARF_LTSSM);
651+
}
652+
621653
static void qcom_pcie_2_3_2_ltssm_enable(struct qcom_pcie *pcie)
622654
{
623655
u32 val;
@@ -1362,6 +1394,7 @@ static const struct qcom_pcie_ops ops_1_9_0 = {
13621394
.host_post_init = qcom_pcie_host_post_init_2_7_0,
13631395
.deinit = qcom_pcie_deinit_2_7_0,
13641396
.ltssm_enable = qcom_pcie_2_3_2_ltssm_enable,
1397+
.ltssm_disable = qcom_pcie_2_3_2_ltssm_disable,
13651398
.config_sid = qcom_pcie_config_sid_1_9_0,
13661399
};
13671400

@@ -1429,6 +1462,8 @@ static const struct qcom_pcie_cfg cfg_sc8280xp = {
14291462
static const struct dw_pcie_ops dw_pcie_ops = {
14301463
.link_up = qcom_pcie_link_up,
14311464
.start_link = qcom_pcie_start_link,
1465+
.host_start_link = qcom_pcie_host_start_link,
1466+
.host_stop_link = qcom_pcie_host_stop_link,
14321467
};
14331468

14341469
static int qcom_pcie_icc_init(struct qcom_pcie *pcie)

0 commit comments

Comments
 (0)