Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp243726rdg; Tue, 10 Oct 2023 09:03:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1w51CiklQQh/xGv0qrj5nQaVwNva7o+779vmMB14QkOsyA8iGVdKx/UPj5OEqW1AB8YH/ X-Received: by 2002:a05:6a00:988:b0:690:c887:8cd8 with SMTP id u8-20020a056a00098800b00690c8878cd8mr20622333pfg.32.1696953792634; Tue, 10 Oct 2023 09:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696953792; cv=none; d=google.com; s=arc-20160816; b=bUWUDRS4CG+yjyiBwLHb5gWMsdcFa/ht4zy4aOIVVAqbDj4TQ8Hz8Sdub9DULfpD35 kfmghiOSZqmLXovO1L8RcTQYooxs0o6iw8ucMAmq2Hh4+qesbjFUcqBRBpLc1iBxCgwI SryKuMvMCpGNN/JU0u/nPq/u7xhwasyH5YRkRiCFavhJgO+SE4xAizh13zhIWzmkZtnY lLPfZEvsgegOwfzkQLJvTbi6I+nxZR8m73GEyC8KPQi+gfVMGVNzhkMwjeDyIcWOaWjX XRMaXA7RoyfMojNDoEGF51c4OzC+oSdFL7K9Z+Eh74NIfM9cYKYls+uN180uo0WAeOdc 9wGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SaXFTispdBsfwi8LngYlAgss6T+NU4hzGaBrMB2s8HA=; fh=OozOmOOBpZMCEY4EIgGIyqBEgdh7VkjbLzQ1OxjXSb0=; b=YwiJmxh5rV4Q/W+topmfDyAKmHB6RTMmbkT7xGGrmA0S9w94qmxxWGLeXzDo0nIH1y KsEdAGgNl7TUWj0Jkhxmtwc3FcbL2bn5j5ZZgGJ5Kv/Pt7KY5lDD1vIfMfx9W5yoGKTd sJ66uyUt1NivZrZTi8DeUzA26VYe1ivZTMOzc2U30stPiwypLxY+gyYch3GgvhnDEUcf 3QhkqxODm9T8PRjre9YzXwQS59+WwXIJIrx6RcJAjsOD9M3/I+JMYmea6pFZW5PM3Wem ItUVTK48UF0Csu7dSMzumejNlvrGbLoFYHqpX4mRRxSZfuiQ37P5gRKM4n+gTdKXdFGj 2Ahg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DPfnQ4Mq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id cd10-20020a056a00420a00b00690208f6d56si9807818pfb.340.2023.10.10.09.03.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 09:03:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DPfnQ4Mq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7ACE5823F5CE; Tue, 10 Oct 2023 09:03:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233529AbjJJQCr (ORCPT + 99 others); Tue, 10 Oct 2023 12:02:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232966AbjJJQCq (ORCPT ); Tue, 10 Oct 2023 12:02:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15E58A7; Tue, 10 Oct 2023 09:02:43 -0700 (PDT) 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 10 Oct 2023 09:03:06 -0700 (PDT) X-Spam-Level: ** 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 > > >