Message ID | 20230915184306.2374670-2-Frank.Li@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1280322vqi; Fri, 15 Sep 2023 12:44:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFCWLsGQ6gMtNdHpsd7qiSzhGc8RVjcfy7G4mfme/l4kwNm9G9uJ5n/epSo6rdLwipy+14t X-Received: by 2002:a17:903:245:b0:1c3:fa9a:1e41 with SMTP id j5-20020a170903024500b001c3fa9a1e41mr2877705plh.45.1694807070665; Fri, 15 Sep 2023 12:44:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1694807070; cv=pass; d=google.com; s=arc-20160816; b=d+FaCCCoASWQpOqHi1jb9/MT0yLoz06MiDa98FKiO1ei/dZP6C1schgako0CFE4Ikv 6u5vtauTo++MnG+/0JpUEXiVPRXaUlkIeyCEJCrX/jvx3tcHe2TlI/uofb6AelJmol9e H6i9S8G95dKdxjCKAOLL4K7CAicN12LGoORevEajiN27/KvHVsxXJFrrI5XShvQQJ/7q e6MG8E35mRJGyryW1dfQ6E7TpA9i9EJUMVXwKZu39q7PI7XECGABzAt6HbrYAvdNwTs9 QL8eMY0dOLiL3zfEzTQC0C17QUWHFH+wVTazdOHWFZS367deIn7rThWif4OQxkKcNDXc Msqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QumOeoWtlkpcZNKxeTPO0UIw55ZdtSB9pWNTJIivito=; fh=oooHTiAXK44aMf+XQcyrMApjhhRxQuk8M9D/ohRv+pM=; b=SNK8dXJIhUiz9s3XHa9O+mBEwxo6879vKF6gPVW7UetQnaryCzWZPu3B0TJTvQF3Uv 5vV/F8YaR1YQShGOuj49hOIVRbssyIZNqDbevdOJKPE/dpnQlIueAwyiixb6zNvAzcyz s3NtBSDa/VBDFyQVfMo9dGfX+0p85NgQeRA1yO+pIbGkptXhZEoyrpn2YpnN+wv9ChPh uKzWCH/kTO4nOzFAfbKGvfgYecroZmPWUQCFDi66EG7nVcUz7L63K+Mzp+MoBN4aLssy xqa1qZnMOoBvav9cix3BlXav0IA5+CYM3IfRB3LBpWJqBR7+1XaRPMwfEe4hd4dZ/rY0 JdCQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ALrIEt9K; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=nxp.com Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ky6-20020a170902f98600b001c08a358683si3627003plb.217.2023.09.15.12.44.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 12:44:30 -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=@nxp.com header.s=selector2 header.b=ALrIEt9K; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); 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=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6346F846B687; Fri, 15 Sep 2023 11:48:44 -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 S236699AbjIOSsE (ORCPT <rfc822;ruipengqi7@gmail.com> + 30 others); Fri, 15 Sep 2023 14:48:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236745AbjIOSrm (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 14:47:42 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2088.outbound.protection.outlook.com [40.107.21.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 722E72D42; Fri, 15 Sep 2023 11:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W3d1O0IDAWUNQJ2OQPySRbbZoNnVu4WSD/jUYqbiDT2/ZtO6fMRCv1WbYY/8VSo0jtCv89kwh27Q+cS/+bMgZDd11C/1bgakheZqeunJkWB/JF8EZ9vssgRSYgbN8SRxscupHr6V3cb7BRITAFDnBo/GEX+AGshxUQSoT3rhdWSeUQDKBiAeh9Xv08/faVO5uBQcU1NpDTdcMl6wspBjcJgymNJjcWBw9W+0/zubfamRcLjB8ENytsR6KrehUfLo89leBuPAkL3yxadIY7IXCvZtPdwwLcNNr0ul/8GhQTTWHSntHLLNu8GmMnLAsdIHVHe32fbHImSsPD/wYSZmkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QumOeoWtlkpcZNKxeTPO0UIw55ZdtSB9pWNTJIivito=; b=kgS3vsJM6pLd28hpoJSV7PwpDRs/7WBYNq/hAhJr7uRWgJrlpQsXbmatt8i5UPd//nLg7R0Bq/EVQ2qavShb5lvX4AnISZbxDFD8RBsuugQki8cMo8OGGdtK4MqPSmTmLHPEqgoOTHBnvp/iXoxRJMHqhH/xWaoGCIiRCurQZVj+5X3tRDjChcOPKyEYuxaawq9zJxVgzU0Z1J0Vby3U4YUbc7kgbxoqcnlzomnT7CEuqPH9FdGqtZh+OQSyBhe03glGc76TgvbJuNn1+DU/mCx3ZKtIVZMEwOLA7IyXtwFaVk1NeH8ySWCAF0kUMSsAW8cNgTVj1mqr6g55zl/7ew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QumOeoWtlkpcZNKxeTPO0UIw55ZdtSB9pWNTJIivito=; b=ALrIEt9KSRnXqd2Y1Zi+/7H7SFZbqnYiJWIdEu25FLtczfCX3h8K4hnYvAm07wP/Tvins63LZLjh3wWkTAnvNkJnadKil248RC8pP9zq2CSFA3iIYa9XrxJvkrhyu7ZAyg9/SKtOsFYyTyKrAIpVwoXDYyRbVpH7cW3ct91lKdQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by GV1PR04MB9184.eurprd04.prod.outlook.com (2603:10a6:150:28::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 15 Sep 2023 18:43:31 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::aa90:117d:c1d0:346a]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::aa90:117d:c1d0:346a%3]) with mapi id 15.20.6792.020; Fri, 15 Sep 2023 18:43:31 +0000 From: Frank Li <Frank.Li@nxp.com> To: Minghuan Lian <minghuan.Lian@nxp.com>, Mingkai Hu <mingkai.hu@nxp.com>, Roy Zang <roy.zang@nxp.com>, Lorenzo Pieralisi <lpieralisi@kernel.org>, =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= <kw@linux.com>, Rob Herring <robh@kernel.org>, Bjorn Helgaas <bhelgaas@google.com>, linuxppc-dev@lists.ozlabs.org (open list:PCI DRIVER FOR FREESCALE LAYERSCAPE), linux-pci@vger.kernel.org (open list:PCI DRIVER FOR FREESCALE LAYERSCAPE), linux-arm-kernel@lists.infradead.org (moderated list:PCI DRIVER FOR FREESCALE LAYERSCAPE), linux-kernel@vger.kernel.org (open list) Cc: imx@lists.linux.dev Subject: [PATCH 2/3] PCI: layerscape: add suspend/resume for ls1021a Date: Fri, 15 Sep 2023 14:43:05 -0400 Message-Id: <20230915184306.2374670-2-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230915184306.2374670-1-Frank.Li@nxp.com> References: <20230915184306.2374670-1-Frank.Li@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR03CA0186.namprd03.prod.outlook.com (2603:10b6:a03:2ef::11) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|GV1PR04MB9184:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c5d930a-77dd-49d9-536e-08dbb61ba858 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rCK2+podRajhIiRYJTdg4kmq0lGIbMEtqx8Uf7LWqRXch9GO4EPvmz9LF9bXVSdaYuk2YjApTjSuxHYDnx8QTFTgiBrAPflgfrdZv17H9MkpsitRw/C5f2nZHsEdBIF5qxwpCA9dlhgiK3kgvjBXUjXDnsNxI8q+F63FFR4OAhHjG0XDkgEQBfCZXprfyqyXI7l/1AUZQUagdrLQM/5wu/UURDCXDra2wQ4f9qoWx5zi1BA9f3uuUY9S6vAglQRTBik4W3O/r3Wov6K1sCFzeb5wad87aLDQ2e+jfuK/WKNB8W1Ansf5In3tiM1zWwrwBJMHz/Di/K/D0+AdkxNRlsuYUQ4QI0hDWFFzMQSptzZae9xCLfpjCkJh5guD3CeVZwPOSO5pPVDcNjTq8B9YpsKm/RdqeEogWcd4bG+xz3TCsB0Sq2vE2h7QyrnTacbxaBcrV13lqmSngNNYOmhGclpU8elpXRk02Yq+GYJlqKyZCdEYV3kWbwDO7QHAmXJH0S6sAm6VDNYFEWBSYGLZBlPixl6s7rtdFxPXs0/NuBXnkemD5I/e4KQqFsTDsFGDMlnm1u9suNXLT4xcYEhqqhAz0eyQkBqeq1VXK7CRWMQbt3toTzlwcHSzptkrRJhPQA0dtGivmWheNck+F8+Q1w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(39860400002)(136003)(376002)(366004)(396003)(451199024)(1800799009)(186009)(15650500001)(478600001)(6512007)(6506007)(6486002)(6666004)(52116002)(2906002)(4326008)(86362001)(8676002)(5660300002)(8936002)(41300700001)(316002)(110136005)(66476007)(66946007)(66556008)(38350700002)(1076003)(2616005)(26005)(921005)(36756003)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d5T25l3cmeODg2lNlVqkQXnmQTEWajP6BO9fGNnHG0a5Wi6UKzPcuXKDIXm1LTrid8mLK3oIlsHFZCESaEyClz0ApOu8UGLENllVMkuanMSe6r3/vw6eIjJK7y40AhIS5TBLj3M9vHgJbrE2sisUfZi7q+Dqt4+UhqCCJSfj+p90iiFjsaA9oFoYAlk5/x46En1sJfWdup65pAbKD/UsznJzgibS8O47bFFpeD6STjpep/iRgvWc7a7/rmavtieRNYzjZWCBaIKfzlfEPTFC08vW2PvXwfYPgMKZOET/1KmNOpTP6Evc+e0+9Ac3Xtj5uPXd0e7KR6yXTJo0LLWDc8H/pOT1DZ5Itzw/0yAIb8EzfcyAntIid246h/49LsmeUcFzjD/7gaiWT+wKhC9/vSf4iPdEZ4k+y1EGfBgAixEQjtKTalXDVtZ0coxp0cJgnOZaDZ011Opi10/NqC1vYM587bPKeXxDCBXNUzm5KVuOAFLYLpoepsuhzOIZC1wbJcgbvBW++30uues/YZmnS03ZKApBLaWx+chKgIPYm2d7xvdwH6ZQbw3DH8zQfi1PB0TT9fFgLFfBWS6QYR+aa20c4kxQoysyuvNGtLXqZUudF3CgjRe+Fo30EzQx8zs494zespQRtLFZ2hz6vs+/NzLP21AJD7NyfKNEZh9myL3nRHdbzQ70B1T0ScDA9tjGlniPxJ0bzKRyc+5OSSYChewb7Q9SfGS9ftKdednbXmUad8yG3mTeUGXIYu9rfLKdlTXHxM6YQMPBT76COXQadiaaajkZxvODNBVNEWGKK7DuIrRhQjR69vCB4bbqjJqeYM9iF0zKhKPAW+cDNM6sD0aVk3ro6ChAffLjbvMJqB+HohpfZeneGqdQbvFBtY7lP7hhhLpQ1wbo1VRYycOfKjY0NJWOvq79zfrgrTDqH6MQDMDyrro1tCO7NLUhzB+7nrfbpLm3pgk4tY88Im/KMSM1DGEjkOURjLOQjWpSWbwM39ECokRiNW8YsV+Po5NaKPNCWO1nm6vfKApjR6leKm+dW1ZUHes6yiCRaOxeqPjCkgJmPRJjLR5ZaBG7B/9TMI0VPpaQsvxP4g9rdgVAfgenK8Ox/LHMNFkW/mPzO7dyeX7rHxSq+0JoGtyDcbzTpUMn4KYCLSm1OQEQAudkKkCOxfF21QWUV6fpvK/mzgdnvR9QSNaKmuJUU6JO7hXeGFOfVsgdvbD35AjRqrBzygnLeuLWd6cyVZSpYL1Fap+Zm6sAvilCfEw3cGr5KL/0pNz1INI/qlGfn7GYnUL3AuWlaXwXDZ9FuF3lRGlFS11HTVV3gCoj8D8Y+3l1kwo42wiHUYE593inOfgc2j2TxY8EJFMSk34ai6TtWG0LE8HAUk6lPTz2KXommA1OE6bJXnRNZNswQW9nwf/5j25Wgv4QBWRqECrcMR4m2k/klAuG306hlb9vxhOuxY+J1r24NTJL8o1QsLyxla2p4stFP5IoClZL2GehgLTako9vy7iTgc71zvdrFsbgdTc1WAySR9EbRTITaYOwpkFGiBWUw/0KRmkFHmJzo0juttDIphelhmMFoEYVvdW65sYxybTI X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c5d930a-77dd-49d9-536e-08dbb61ba858 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 18:43:30.9410 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qDx5pDnr2ez4W/2qaphZj1s47pcAYcIq8PsZFdzxQvxcsET9jOK6nUJubrYzVozaWqeizdIxrXv7OWkZHUP3hQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR04MB9184 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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: <linux-kernel.vger.kernel.org> 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]); Fri, 15 Sep 2023 11:48:44 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777134018558748423 X-GMAIL-MSGID: 1777134018558748423 |
Series |
[1/3] PCI: layerscape: add function pointer for exit_from_l2()
|
|
Commit Message
Frank Li
Sept. 15, 2023, 6:43 p.m. UTC
ls1021a add suspend/resume support.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
drivers/pci/controller/dwc/pci-layerscape.c | 88 ++++++++++++++++++++-
1 file changed, 87 insertions(+), 1 deletion(-)
Comments
On Fri, Sep 15, 2023 at 02:43:05PM -0400, Frank Li wrote: > ls1021a add suspend/resume support. > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > --- ping 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 >
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 <Frank.Li@nxp.com> > > --- > > ping > > Frank Ping 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 > >
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 <Frank.Li@nxp.com> > > > --- > > > > 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 > > >
On Tue, Oct 10, 2023 at 06:02:36PM +0200, Lorenzo Pieralisi wrote: > 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 <Frank.Li@nxp.com> > > > > --- > > > > > > 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 Could you please help point which specic one was not follow aboved guide? Then I can update my code. I think that's efficial communication method. I think I have read it serial times. But not sure which one violate the guide? @Bjorn Helgaas. How do you think so? best regards Frank Li > > > 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 > > > >
On Mon, Oct 16, 2023 at 10:45:25AM -0400, Frank Li wrote: > On Tue, Oct 10, 2023 at 06:02:36PM +0200, Lorenzo Pieralisi wrote: > > On Tue, Oct 10, 2023 at 10:20:12AM -0400, Frank Li wrote: > > > Ping > > > > Read and follow please (and then ping us): > > https://lore.kernel.org/linux-pci/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com > > Could you please help point which specic one was not follow aboved guide? > Then I can update my code. I think that's efficial communication method. I > think I have read it serial times. But not sure which one violate the > guide? > > @Bjorn Helgaas. How do you think so? Since Lorenzo didn't point out anything specific in the patch itself, I think he was probably referring to the subject line and this advice: - Follow the existing convention, i.e., run "git log --oneline <file>" and make yours match in format, capitalization, and sentence structure. For example, native host bridge driver patch titles look like this: PCI: altera: Fix platform_get_irq() error handling PCI: vmd: Remove IRQ affinity so we can allocate more IRQs PCI: mediatek: Add MSI support for MT2712 and MT7622 PCI: rockchip: Remove IRQ domain if probe fails In this case, your subject line was: PCI: layerscape: add suspend/resume for ls1021a The advice was to run this: $ git log --oneline drivers/pci/controller/dwc/pci-layerscape.c 83c088148c8e PCI: Use PCI_HEADER_TYPE_* instead of literals 9fda4d09905d PCI: layerscape: Add power management support for ls1028a 277004d7a4a3 PCI: Remove unnecessary <linux/of_irq.h> includes 60b3c27fb9b9 PCI: dwc: Rename struct pcie_port to dw_pcie_rp d23f0c11aca2 PCI: layerscape: Change to use the DWC common link-up check function 7007b745a508 PCI: layerscape: Convert to builtin_platform_driver() 60f5b73fa0f2 PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init() b9ac0f9dc8ea PCI: dwc: Move dw_pcie_setup_rc() to DWC common code f78f02638af5 PCI: dwc: Rework MSI initialization Note that these summaries are all complete sentences that start with a capital letter: Use PCI_HEADER_TYPE_* instead of literals Add power management support for ls1028a Remove unnecessary <linux/of_irq.h> includes ... So yours could be this: PCI: layerscape: Add suspend/resume for ls1021a ^ This is trivial, obviously. But the uppercase/lowercase distinction carries information, and it's an unnecessary distraction to notice that "oh, this is different from the rest; is the difference important or should I ignore it?" Obviously Lorenzo *could* edit all your subject lines on your behalf, but it makes everybody's life easier if people look at the existing code and follow the style when making changes. E.g., write subject lines that are similar in style to previous ones, name local variables similarly to other functions, use line lengths consistent with the rest of the file, etc. After applying a change, the file should look like a coherent whole; we should not be able to tell that this hunk was added later by somebody else. This all helps make the code (and the git history) more readable and maintainable. Bjorn
On Mon, Oct 16, 2023 at 10:22:11AM -0500, Bjorn Helgaas wrote: > On Mon, Oct 16, 2023 at 10:45:25AM -0400, Frank Li wrote: > > On Tue, Oct 10, 2023 at 06:02:36PM +0200, Lorenzo Pieralisi wrote: > > > On Tue, Oct 10, 2023 at 10:20:12AM -0400, Frank Li wrote: > > > > > Ping > > > > > > Read and follow please (and then ping us): > > > https://lore.kernel.org/linux-pci/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com > > > > Could you please help point which specic one was not follow aboved guide? > > Then I can update my code. I think that's efficial communication method. I > > think I have read it serial times. But not sure which one violate the > > guide? > > > > @Bjorn Helgaas. How do you think so? > > Since Lorenzo didn't point out anything specific in the patch itself, > I think he was probably referring to the subject line and this advice: > > - Follow the existing convention, i.e., run "git log --oneline > <file>" and make yours match in format, capitalization, and > sentence structure. For example, native host bridge driver patch > titles look like this: > > PCI: altera: Fix platform_get_irq() error handling > PCI: vmd: Remove IRQ affinity so we can allocate more IRQs > PCI: mediatek: Add MSI support for MT2712 and MT7622 > PCI: rockchip: Remove IRQ domain if probe fails > > In this case, your subject line was: > > PCI: layerscape: add suspend/resume for ls1021a > > The advice was to run this: > > $ git log --oneline drivers/pci/controller/dwc/pci-layerscape.c > 83c088148c8e PCI: Use PCI_HEADER_TYPE_* instead of literals > 9fda4d09905d PCI: layerscape: Add power management support for ls1028a > 277004d7a4a3 PCI: Remove unnecessary <linux/of_irq.h> includes > 60b3c27fb9b9 PCI: dwc: Rename struct pcie_port to dw_pcie_rp > d23f0c11aca2 PCI: layerscape: Change to use the DWC common link-up check function > 7007b745a508 PCI: layerscape: Convert to builtin_platform_driver() > 60f5b73fa0f2 PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init() > b9ac0f9dc8ea PCI: dwc: Move dw_pcie_setup_rc() to DWC common code > f78f02638af5 PCI: dwc: Rework MSI initialization > > Note that these summaries are all complete sentences that start with a > capital letter: > > Use PCI_HEADER_TYPE_* instead of literals > Add power management support for ls1028a > Remove unnecessary <linux/of_irq.h> includes > ... > > So yours could be this: > > PCI: layerscape: Add suspend/resume for ls1021a > ^ > > This is trivial, obviously. But the uppercase/lowercase distinction > carries information, and it's an unnecessary distraction to notice > that "oh, this is different from the rest; is the difference > important or should I ignore it?" Thanks. Not everyone think it is trivial. Especially for the one, who English are not native language. > > Obviously Lorenzo *could* edit all your subject lines on your behalf, > but it makes everybody's life easier if people look at the existing > code and follow the style when making changes. Understand, but simple mark 'a' and 'A' to me. I will update patches and take care for next time instead search whole docuemnt to guess which one violated. I know I make some mistakes at here. But I am working on many difference kernel subsystems, some require upper case, some require low case, someone doesn't care. I respected all reviewer's and maintaner's time, but I hope respected the contributor's time also. Just simple words like , 'a' to 'A' or run git log --oneline to check subject. I will know what exact means. Do you think it will better than below words "Read and follow please (and then ping us): https://lore.kernel.org/linux-pci/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com" Frank > > E.g., write subject lines that are similar in style to previous ones, > name local variables similarly to other functions, use line lengths > consistent with the rest of the file, etc. After applying a change, > the file should look like a coherent whole; we should not be able to > tell that this hunk was added later by somebody else. This all helps > make the code (and the git history) more readable and maintainable. > > Bjorn
On Mon, Oct 16, 2023 at 10:22:11AM -0500, Bjorn Helgaas wrote: > On Mon, Oct 16, 2023 at 10:45:25AM -0400, Frank Li wrote: > > On Tue, Oct 10, 2023 at 06:02:36PM +0200, Lorenzo Pieralisi wrote: > > > On Tue, Oct 10, 2023 at 10:20:12AM -0400, Frank Li wrote: > > > > > Ping > > > > > > Read and follow please (and then ping us): > > > https://lore.kernel.org/linux-pci/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com > > > > Could you please help point which specic one was not follow aboved guide? > > Then I can update my code. I think that's efficial communication method. I > > think I have read it serial times. But not sure which one violate the > > guide? > > > > @Bjorn Helgaas. How do you think so? > > Since Lorenzo didn't point out anything specific in the patch itself, > I think he was probably referring to the subject line and this advice: > > - Follow the existing convention, i.e., run "git log --oneline > <file>" and make yours match in format, capitalization, and > sentence structure. For example, native host bridge driver patch > titles look like this: > > PCI: altera: Fix platform_get_irq() error handling > PCI: vmd: Remove IRQ affinity so we can allocate more IRQs > PCI: mediatek: Add MSI support for MT2712 and MT7622 > PCI: rockchip: Remove IRQ domain if probe fails > > In this case, your subject line was: > > PCI: layerscape: add suspend/resume for ls1021a > > The advice was to run this: > > $ git log --oneline drivers/pci/controller/dwc/pci-layerscape.c > 83c088148c8e PCI: Use PCI_HEADER_TYPE_* instead of literals > 9fda4d09905d PCI: layerscape: Add power management support for ls1028a > 277004d7a4a3 PCI: Remove unnecessary <linux/of_irq.h> includes > 60b3c27fb9b9 PCI: dwc: Rename struct pcie_port to dw_pcie_rp > d23f0c11aca2 PCI: layerscape: Change to use the DWC common link-up check function > 7007b745a508 PCI: layerscape: Convert to builtin_platform_driver() > 60f5b73fa0f2 PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init() > b9ac0f9dc8ea PCI: dwc: Move dw_pcie_setup_rc() to DWC common code > f78f02638af5 PCI: dwc: Rework MSI initialization > > Note that these summaries are all complete sentences that start with a > capital letter: > > Use PCI_HEADER_TYPE_* instead of literals > Add power management support for ls1028a > Remove unnecessary <linux/of_irq.h> includes > ... > > So yours could be this: > > PCI: layerscape: Add suspend/resume for ls1021a > ^ > > This is trivial, obviously. But the uppercase/lowercase distinction > carries information, and it's an unnecessary distraction to notice > that "oh, this is different from the rest; is the difference > important or should I ignore it?" > > Obviously Lorenzo *could* edit all your subject lines on your behalf, > but it makes everybody's life easier if people look at the existing > code and follow the style when making changes. > > E.g., write subject lines that are similar in style to previous ones, > name local variables similarly to other functions, use line lengths > consistent with the rest of the file, etc. After applying a change, > the file should look like a coherent whole; we should not be able to > tell that this hunk was added later by somebody else. This all helps > make the code (and the git history) more readable and maintainable. Thank you very much Bjorn. Frank, now please resend your patches and make sure that you follow these guidelines, they must be clear by now. Lorenzo
On Mon, Oct 16, 2023 at 12:11:04PM -0400, Frank Li wrote: > On Mon, Oct 16, 2023 at 10:22:11AM -0500, Bjorn Helgaas wrote: > > Obviously Lorenzo *could* edit all your subject lines on your behalf, > > but it makes everybody's life easier if people look at the existing > > code and follow the style when making changes. > > Understand, but simple mark 'a' and 'A' to me. I will update patches and > take care for next time instead search whole docuemnt to guess which one > violated. I know I make some mistakes at here. But I am working on many > difference kernel subsystems, some require upper case, some require low > case, someone doesn't care. Right, that's why I always suggest following the example of the surrounding code and history. English is the only language I know, but I speculate that this typographical detail probably doesn't make sense in languages that don't have a similar upper/lowercase distinction. Thanks for persevering; we'd be having a lot more trouble if I tried to send emails in your native language ;) Bjorn
On Mon, Oct 16, 2023 at 12:11:04PM -0400, Frank Li wrote: > On Mon, Oct 16, 2023 at 10:22:11AM -0500, Bjorn Helgaas wrote: > > On Mon, Oct 16, 2023 at 10:45:25AM -0400, Frank Li wrote: > > > On Tue, Oct 10, 2023 at 06:02:36PM +0200, Lorenzo Pieralisi wrote: > > > > On Tue, Oct 10, 2023 at 10:20:12AM -0400, Frank Li wrote: > > > > > > > Ping > > > > > > > > Read and follow please (and then ping us): > > > > https://lore.kernel.org/linux-pci/20171026223701.GA25649@bhelgaas-glaptop.roam.corp.google.com > > > > > > Could you please help point which specic one was not follow aboved guide? > > > Then I can update my code. I think that's efficial communication method. I > > > think I have read it serial times. But not sure which one violate the > > > guide? > > > > > > @Bjorn Helgaas. How do you think so? > > > > Since Lorenzo didn't point out anything specific in the patch itself, > > I think he was probably referring to the subject line and this advice: > > > > - Follow the existing convention, i.e., run "git log --oneline > > <file>" and make yours match in format, capitalization, and > > sentence structure. For example, native host bridge driver patch > > titles look like this: > > > > PCI: altera: Fix platform_get_irq() error handling > > PCI: vmd: Remove IRQ affinity so we can allocate more IRQs > > PCI: mediatek: Add MSI support for MT2712 and MT7622 > > PCI: rockchip: Remove IRQ domain if probe fails > > > > In this case, your subject line was: > > > > PCI: layerscape: add suspend/resume for ls1021a > > > > The advice was to run this: > > > > $ git log --oneline drivers/pci/controller/dwc/pci-layerscape.c > > 83c088148c8e PCI: Use PCI_HEADER_TYPE_* instead of literals > > 9fda4d09905d PCI: layerscape: Add power management support for ls1028a > > 277004d7a4a3 PCI: Remove unnecessary <linux/of_irq.h> includes > > 60b3c27fb9b9 PCI: dwc: Rename struct pcie_port to dw_pcie_rp > > d23f0c11aca2 PCI: layerscape: Change to use the DWC common link-up check function > > 7007b745a508 PCI: layerscape: Convert to builtin_platform_driver() > > 60f5b73fa0f2 PCI: dwc: Remove unnecessary wrappers around dw_pcie_host_init() > > b9ac0f9dc8ea PCI: dwc: Move dw_pcie_setup_rc() to DWC common code > > f78f02638af5 PCI: dwc: Rework MSI initialization > > > > Note that these summaries are all complete sentences that start with a > > capital letter: > > > > Use PCI_HEADER_TYPE_* instead of literals > > Add power management support for ls1028a > > Remove unnecessary <linux/of_irq.h> includes > > ... > > > > So yours could be this: > > > > PCI: layerscape: Add suspend/resume for ls1021a > > ^ > > > > This is trivial, obviously. But the uppercase/lowercase distinction > > carries information, and it's an unnecessary distraction to notice > > that "oh, this is different from the rest; is the difference > > important or should I ignore it?" > > Thanks. Not everyone think it is trivial. Especially for the one, who > English are not native language. > > > > > Obviously Lorenzo *could* edit all your subject lines on your behalf, > > but it makes everybody's life easier if people look at the existing > > code and follow the style when making changes. > > Understand, but simple mark 'a' and 'A' to me. I will update patches and > take care for next time instead search whole docuemnt to guess which one > violated. I know I make some mistakes at here. But I am working on many > difference kernel subsystems, some require upper case, some require low > case, someone doesn't care. > > I respected all reviewer's and maintaner's time, but I hope respected > the contributor's time also. I do respect your time, please respect ours by following the guidelines I provided you with multiple times already. Thank you for resending the series. Lorenzo
On Fri, Sep 15, 2023 at 02:43:05PM -0400, Frank Li wrote: > ls1021a add suspend/resume support. > Please add what the driver is doing during suspend/resume. > Signed-off-by: Frank Li <Frank.Li@nxp.com> > --- > 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) { Can this ever happen? > + dev_dbg(pcie->pci->dev, "SYSCFG is NULL\n"); > + return; > + } > + > + /* Send Turn_off message */ "Send PME_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 */ "There is no specific register to check for PME_To_Ack from endpoint. So on the safe side, wait for PCIE_PME_TO_L2_TIMEOUT_US." > + mdelay(PCIE_PME_TO_L2_TIMEOUT_US/1000); > + > + /* Clear Turn_off message */ "PME_Turn_off". But I'm not sure if this is really required. Are you doing it because the layerspace hw implements the PME_Turn_Off bit as "level triggered"? > + 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; > + A comment here would be good. > + 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]; > + The above syscon parsing could be done conditionally during probe itself. There is no need to do it during host_init() time. - Mani > + 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 >
On Mon, Oct 16, 2023 at 11:25:12AM -0500, Bjorn Helgaas wrote: > On Mon, Oct 16, 2023 at 12:11:04PM -0400, Frank Li wrote: > > On Mon, Oct 16, 2023 at 10:22:11AM -0500, Bjorn Helgaas wrote: > > > > Obviously Lorenzo *could* edit all your subject lines on your behalf, > > > but it makes everybody's life easier if people look at the existing > > > code and follow the style when making changes. > > > > Understand, but simple mark 'a' and 'A' to me. I will update patches and > > take care for next time instead search whole docuemnt to guess which one > > violated. I know I make some mistakes at here. But I am working on many > > difference kernel subsystems, some require upper case, some require low > > case, someone doesn't care. > > Right, that's why I always suggest following the example of the > surrounding code and history. English is the only language I know, > but I speculate that this typographical detail probably doesn't make > sense in languages that don't have a similar upper/lowercase > distinction. If everyone thinks it is important. I suggest put it in checkpatch.pl script. The only script check can prevent to human make mistakes. I asked the same question at: https://lore.kernel.org/imx/ZSV1sINV%2F2GrAYFr@lizhi-Precision-Tower-5810/T/#t It lets teach kid mulitplication, kid did 20 questions. only 1 failure. The good teacher should tell which one is wrong and grade as 19/20 instead of just grade 19/20 without any comments. We are using email communication instead of face to face. The efficient of communication is important. We have differece background, difference native languadge, live on difference area in world and do the same jobs to make linux kernel better. The simple and straight forward's feedback can save both our time and efforts. Frank Li > > Thanks for persevering; we'd be having a lot more trouble if I tried > to send emails in your native language ;) > > Bjorn
On Mon, Oct 16, 2023 at 10:28:24PM +0530, Manivannan Sadhasivam wrote: > On Fri, Sep 15, 2023 at 02:43:05PM -0400, Frank Li wrote: > > ls1021a add suspend/resume support. > > > > Please add what the driver is doing during suspend/resume. > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > --- > > 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) { > > Can this ever happen? > > > + dev_dbg(pcie->pci->dev, "SYSCFG is NULL\n"); > > + return; > > + } > > + > > + /* Send Turn_off message */ > > "Send PME_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 */ > > "There is no specific register to check for PME_To_Ack from endpoint. So on the > safe side, wait for PCIE_PME_TO_L2_TIMEOUT_US." > > > + mdelay(PCIE_PME_TO_L2_TIMEOUT_US/1000); > > + > > + /* Clear Turn_off message */ > > "PME_Turn_off". But I'm not sure if this is really required. Are you doing it > because the layerspace hw implements the PME_Turn_Off bit as "level triggered"? I am not sure how hardware implement this. But reference manual said: PMXMTTURNOFF: Generate PM turnoff message for power management of PCI Express controllers. This bit should be cleared by software. 0 Clear PM turnoff (default) 1 Trigger PM turnoff Frank > > > + 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; > > + > > A comment here would be good. > > > + 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]; > > + > > The above syscon parsing could be done conditionally during probe itself. There > is no need to do it during host_init() time. > > - Mani > > > + 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 > > > > -- > மணிவண்ணன் சதாசிவம்
On Mon, Oct 16, 2023 at 04:18:36PM -0400, Frank Li wrote: > On Mon, Oct 16, 2023 at 10:28:24PM +0530, Manivannan Sadhasivam wrote: > > On Fri, Sep 15, 2023 at 02:43:05PM -0400, Frank Li wrote: > > > ls1021a add suspend/resume support. > > > > > > > Please add what the driver is doing during suspend/resume. > > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > > --- > > > 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) { > > > > Can this ever happen? > > > > > + dev_dbg(pcie->pci->dev, "SYSCFG is NULL\n"); > > > + return; > > > + } > > > + > > > + /* Send Turn_off message */ > > > > "Send PME_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 */ > > > > "There is no specific register to check for PME_To_Ack from endpoint. So on the > > safe side, wait for PCIE_PME_TO_L2_TIMEOUT_US." > > > > > + mdelay(PCIE_PME_TO_L2_TIMEOUT_US/1000); > > > + > > > + /* Clear Turn_off message */ > > > > "PME_Turn_off". But I'm not sure if this is really required. Are you doing it > > because the layerspace hw implements the PME_Turn_Off bit as "level triggered"? > > I am not sure how hardware implement this. But reference manual said: > > PMXMTTURNOFF: > Generate PM turnoff message for power management of PCI Express controllers. > This bit should be cleared by software. > 0 Clear PM turnoff (default) > 1 Trigger PM turnoff > Hmm, okay. Atleast add the below comment to make it understandable in the future: "Layerscape hardware reference manual recommends clearing the PMXMTTURNOFF bit to complete the PME_Turn_Off handshake." - Mani > Frank > > > > > > + 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; > > > + > > > > A comment here would be good. > > > > > + 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]; > > > + > > > > The above syscon parsing could be done conditionally during probe itself. There > > is no need to do it during host_init() time. > > > > - Mani > > > > > + 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 > > > > > > > -- > > மணிவண்ணன் சதாசிவம்
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 = {