Skip to content

Commit 27b3bcb

Browse files
nxpfrankliLorenzo Pieralisi
authored andcommitted
PCI: layerscape: Add suspend/resume for ls1043a
Add suspend/resume support for Layerscape LS1043a. In the suspend path, PME_Turn_Off message is sent to the endpoint to transition the link to L2/L3_Ready state. In this SoC, there is no way to check if the controller has received the PME_To_Ack from the endpoint or not. So to be on the safer side, the driver just waits for PCIE_PME_TO_L2_TIMEOUT_US before asserting the SoC specific PMXMTTURNOFF bit to complete the PME_Turn_Off handshake. Then the link would enter L2/L3 state depending on the VAUX supply. In the resume path, the link is brought back from L2 to L0 by doing a software reset. Link: https://lore.kernel.org/r/20231204160829.2498703-5-Frank.Li@nxp.com Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Acked-by: Roy Zang <Roy.Zang@nxp.com>
1 parent 762ef94 commit 27b3bcb

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

drivers/pci/controller/dwc/pci-layerscape.c

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
#define SCFG_PEXSFTRSTCR 0x190
4242
#define PEXSR(idx) BIT(idx)
4343

44+
/* LS1043A PEX PME control register */
45+
#define SCFG_PEXPMECR 0x144
46+
#define PEXPME(idx) BIT(31 - (idx) * 4)
47+
48+
/* LS1043A PEX LUT debug register */
49+
#define LS_PCIE_LDBG 0x7fc
50+
#define LDBG_SR BIT(30)
51+
#define LDBG_WE BIT(31)
52+
4453
#define PCIE_IATU_NUM 6
4554

4655
struct ls_pcie_drvdata {
@@ -224,6 +233,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp)
224233
return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index));
225234
}
226235

236+
static void ls1043a_pcie_send_turnoff_msg(struct dw_pcie_rp *pp)
237+
{
238+
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
239+
struct ls_pcie *pcie = to_ls_pcie(pci);
240+
241+
scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index));
242+
}
243+
244+
static int ls1043a_pcie_exit_from_l2(struct dw_pcie_rp *pp)
245+
{
246+
struct dw_pcie *pci = to_dw_pcie_from_pp(pp);
247+
struct ls_pcie *pcie = to_ls_pcie(pci);
248+
u32 val;
249+
250+
/*
251+
* Reset the PEX wrapper to bring the link out of L2.
252+
* LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and
253+
* clearing the soft reset on the PEX module.
254+
* LDBG_SR: When SR is set to 1, the PEX module enters soft reset.
255+
*/
256+
val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG);
257+
val |= LDBG_WE;
258+
ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val);
259+
260+
val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG);
261+
val |= LDBG_SR;
262+
ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val);
263+
264+
val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG);
265+
val &= ~LDBG_SR;
266+
ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val);
267+
268+
val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG);
269+
val &= ~LDBG_WE;
270+
ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val);
271+
272+
return 0;
273+
}
274+
227275
static const struct dw_pcie_host_ops ls_pcie_host_ops = {
228276
.host_init = ls_pcie_host_init,
229277
.pme_turn_off = ls_pcie_send_turnoff_msg,
@@ -241,6 +289,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = {
241289
.exit_from_l2 = ls1021a_pcie_exit_from_l2,
242290
};
243291

292+
static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = {
293+
.host_init = ls_pcie_host_init,
294+
.pme_turn_off = ls1043a_pcie_send_turnoff_msg,
295+
};
296+
297+
static const struct ls_pcie_drvdata ls1043a_drvdata = {
298+
.pf_lut_off = 0x10000,
299+
.pm_support = true,
300+
.scfg_support = true,
301+
.ops = &ls1043a_pcie_host_ops,
302+
.exit_from_l2 = ls1043a_pcie_exit_from_l2,
303+
};
304+
244305
static const struct ls_pcie_drvdata layerscape_drvdata = {
245306
.pf_lut_off = 0xc0000,
246307
.pm_support = true,
@@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = {
252313
{ .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata },
253314
{ .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata },
254315
{ .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata },
255-
{ .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata },
316+
{ .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata },
256317
{ .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata },
257318
{ .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata },
258319
{ .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata },

0 commit comments

Comments
 (0)