From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 947D6CD8CA8 for ; Tue, 10 Oct 2023 16:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=t42xqA8THYLMqie2oMXxPa5fMPkiAxEmbwbuKC2sHKM=; b=UVb1xChL9tqtYa 7NKZdxr3fi5Tbqqc63AEKSi4Z+deXeZWCJItZtEjCfrsC+UYiNCzmkjMyn3ZWCwbV+DUFrhymkZ2z x5tTCoT0qAfp+MOtabxcZm5Hcju1T8NRs/aQP7u00VOU3XCWWV9YfN7UKfJWkuYXWw5Ry3Qb1nu+K 2fXElden1OP88mNKeBC21HuC+rvHqn5xRNcqALKv5stVgf8bHb2ADR6eixloDvXS6bn9PE3cgcCPc 9OVMVb43rokmsct+SeF2ZLa00xjfbmQv/zvhPghaAulByDdhVl5T39Sm2PZgR61zKWUrSzyM0GdLd z4taNYRMyd04VVxK+EIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qqFC3-00Djgg-1F; Tue, 10 Oct 2023 16:02:47 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qqFBz-00DjgL-13 for linux-arm-kernel@lists.infradead.org; Tue, 10 Oct 2023 16:02:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BF21061714; Tue, 10 Oct 2023 16:02:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84E2FC433C7; Tue, 10 Oct 2023 16:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696953762; bh=8zTGRYTY1WUSPexJBZKSYXIXebpfzjhtEAwIpwHKrgk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DPfnQ4Mqq/LwUfreTwFh2h7CpeWm1aEetozjYfx9hep8O3FN5ECtreNqLxdO38h4D y2M4N0vbTDKEqB0hqR5Gj4wp//6BhUIyeyzarNel8VnlHeGz7zSnawtIJZYoXg0mIB X1kxcEPxUxbVc6CJN4yLmqP9IsVviwIgAl3dk/XdYU2p2AP1HyHTYct6nl7aJAI1Na y1Q73d4THK7/xQV198rpNqDqOIYAxFwUmCYguOeBkMJGCQlLvwH+lSoSSrDxHObl5o FWQmFW0v8FHC/s0zHtU7iOk7N1XpVaO97nOxNcG2mDEAW1GtvKhWjB6l63p7vX3J8t tOM7bgskk4kmA== Date: Tue, 10 Oct 2023 18:02:36 +0200 From: Lorenzo Pieralisi To: Frank Li Cc: Minghuan Lian , Mingkai Hu , Roy Zang , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , "open list:PCI DRIVER FOR FREESCALE LAYERSCAPE" , "open list:PCI DRIVER FOR FREESCALE LAYERSCAPE" , "moderated list:PCI DRIVER FOR FREESCALE LAYERSCAPE" , open list , imx@lists.linux.dev Subject: Re: [PATCH 2/3] PCI: layerscape: add suspend/resume for ls1021a Message-ID: References: <20230915184306.2374670-1-Frank.Li@nxp.com> <20230915184306.2374670-2-Frank.Li@nxp.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231010_090243_444453_CCB91DF6 X-CRM114-Status: GOOD ( 24.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Oct 10, 2023 at 10:20:12AM -0400, Frank Li wrote: > On Wed, Oct 04, 2023 at 10:23:51AM -0400, Frank Li wrote: > > On Fri, Sep 15, 2023 at 02:43:05PM -0400, Frank Li wrote: > > > ls1021a add suspend/resume support. > > > > > > Signed-off-by: Frank Li > > > --- > > > > ping > > > > Frank > > Ping Read and follow please (and then ping us): https://lore.kernel.org/linux-pci/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com > Frank > > > > > > drivers/pci/controller/dwc/pci-layerscape.c | 88 ++++++++++++++++++++- > > > 1 file changed, 87 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c > > > index 20c48c06e2248..bc5a8ff1a26ce 100644 > > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > > @@ -35,6 +35,12 @@ > > > #define PF_MCR_PTOMR BIT(0) > > > #define PF_MCR_EXL2S BIT(1) > > > > > > +/* LS1021A PEXn PM Write Control Register */ > > > +#define SCFG_PEXPMWRCR(idx) (0x5c + (idx) * 0x64) > > > +#define PMXMTTURNOFF BIT(31) > > > +#define SCFG_PEXSFTRSTCR 0x190 > > > +#define PEXSR(idx) BIT(idx) > > > + > > > #define PCIE_IATU_NUM 6 > > > > > > struct ls_pcie_drvdata { > > > @@ -48,6 +54,8 @@ struct ls_pcie { > > > struct dw_pcie *pci; > > > const struct ls_pcie_drvdata *drvdata; > > > void __iomem *pf_base; > > > + struct regmap *scfg; > > > + int index; > > > bool big_endian; > > > }; > > > > > > @@ -170,13 +178,91 @@ static int ls_pcie_host_init(struct dw_pcie_rp *pp) > > > return 0; > > > } > > > > > > +static void ls1021a_pcie_send_turnoff_msg(struct dw_pcie_rp *pp) > > > +{ > > > + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); > > > + struct ls_pcie *pcie = to_ls_pcie(pci); > > > + u32 val; > > > + > > > + if (!pcie->scfg) { > > > + dev_dbg(pcie->pci->dev, "SYSCFG is NULL\n"); > > > + return; > > > + } > > > + > > > + /* Send Turn_off message */ > > > + regmap_read(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), &val); > > > + val |= PMXMTTURNOFF; > > > + regmap_write(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), val); > > > + > > > + /* There are not register to check ACK, so wait PCIE_PME_TO_L2_TIMEOUT_US */ > > > + mdelay(PCIE_PME_TO_L2_TIMEOUT_US/1000); > > > + > > > + /* Clear Turn_off message */ > > > + regmap_read(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), &val); > > > + val &= ~PMXMTTURNOFF; > > > + regmap_write(pcie->scfg, SCFG_PEXPMWRCR(pcie->index), val); > > > +} > > > + > > > +static void ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) > > > +{ > > > + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); > > > + struct ls_pcie *pcie = to_ls_pcie(pci); > > > + u32 val; > > > + > > > + regmap_read(pcie->scfg, SCFG_PEXSFTRSTCR, &val); > > > + val |= PEXSR(pcie->index); > > > + regmap_write(pcie->scfg, SCFG_PEXSFTRSTCR, val); > > > + > > > + regmap_read(pcie->scfg, SCFG_PEXSFTRSTCR, &val); > > > + val &= ~PEXSR(pcie->index); > > > + regmap_write(pcie->scfg, SCFG_PEXSFTRSTCR, val); > > > +} > > > + > > > +static int ls1021a_pcie_host_init(struct dw_pcie_rp *pp) > > > +{ > > > + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); > > > + struct ls_pcie *pcie = to_ls_pcie(pci); > > > + struct device *dev = pcie->pci->dev; > > > + u32 index[2]; > > > + int ret; > > > + > > > + ret = ls_pcie_host_init(pp); > > > + if (ret) > > > + return ret; > > > + > > > + pcie->scfg = syscon_regmap_lookup_by_phandle(dev->of_node, "fsl,pcie-scfg"); > > > + if (IS_ERR(pcie->scfg)) { > > > + ret = PTR_ERR(pcie->scfg); > > > + dev_err(dev, "No syscfg phandle specified\n"); > > > + pcie->scfg = NULL; > > > + return ret; > > > + } > > > + > > > + ret = of_property_read_u32_array(dev->of_node, "fsl,pcie-scfg", index, 2); > > > + if (ret) { > > > + pcie->scfg = NULL; > > > + return ret; > > > + } > > > + > > > + pcie->index = index[1]; > > > + > > > + return ret; > > > +} > > > + > > > static const struct dw_pcie_host_ops ls_pcie_host_ops = { > > > .host_init = ls_pcie_host_init, > > > .pme_turn_off = ls_pcie_send_turnoff_msg, > > > }; > > > > > > +static const struct dw_pcie_host_ops ls1021a_pcie_host_ops = { > > > + .host_init = ls1021a_pcie_host_init, > > > + .pme_turn_off = ls1021a_pcie_send_turnoff_msg, > > > +}; > > > + > > > static const struct ls_pcie_drvdata ls1021a_drvdata = { > > > - .pm_support = false, > > > + .pm_support = true, > > > + .ops = &ls1021a_pcie_host_ops, > > > + .exit_from_l2 = ls1021a_pcie_exit_from_l2, > > > }; > > > > > > static const struct ls_pcie_drvdata layerscape_drvdata = { > > > -- > > > 2.34.1 > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel