Message ID | 20231129214412.327633-5-Frank.Li@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9199:0:b0:435:d73e:8a63 with SMTP id s25csp644592vqg; Wed, 29 Nov 2023 13:45:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSKMaWl/CunpKe9fBzTz45Zpcrq69yiHmUoxIfv3n8fgQ1ulBhJhzM4XEQsDkG7TgB8aRJ X-Received: by 2002:a17:902:e804:b0:1d0:1f49:160 with SMTP id u4-20020a170902e80400b001d01f490160mr2676088plg.36.1701294322476; Wed, 29 Nov 2023 13:45:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701294322; cv=pass; d=google.com; s=arc-20160816; b=HRIqmJjEMz5qFVsxSW9/FuT+zLBJlqsznmFJ5W8ym8gDpbWncHHmmKZDbB8xH7myG4 YCCyv81ms55uOz4eCaBbmqZ2XSgnEn4/85y8kKc/feYY2WrD9Z6F3mgIKrwvAfuzG1OA P57UDzqfvooclIs1XAUsZ/aSI0L1a0EsR8EEw2MSXrnCSnLF93zTJVU6MpdS35+fIKu+ KJ1neO4Kl3wu+x9vIVYgqTJOkqqnbvIEUHFeTr5I5NPtVgQi8nLBvhH/k8ITt5Ry9F8G ZQaGWFsLLZ5ywhEdIh81PZvICEsLRDjJN8CvJtT2eq/4WXm0H3Sl7fvf2WGhjDIkxRPr 7mSg== 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=ENi4BObm6hUCle7hG/sI3aKr4l0G5+aghdecNzdpGvo=; fh=G2Za2XEd7lFHZ2j3w8Am2dhf4mDmMexXUuvn1GAozXQ=; b=oWPrdWgmiVprUQBQYnL8noDGmhYNoSzO5OMXFP/+fQ6q0twYsPBJvetshJbqcBCMV5 1l/9tqEDTOqept7V79ifdiyxhoUMi/nyA5+6s6gweMIiXq3DlvHwNCPwL/S5JHoVFcq0 fbTVk7uhAFYkP+nqcfFRaY/kmA4Td1RgumDVxHh2y/jK7XV9qxPCURiWhCykG8Mc6O1q 0pmwM+UEB7StyXD0Pt1CYOwZHchc1x2mtTpMRGB8JsQTkVboCTJbxiWLt9g9vsbNWW1Q D9Yl+b769yxMmJdivqaGRHy8dp73gQmVIVKEM6MpPfeBO8X/QvbdHjzXyB7A+sZpDORo oRRA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hbTT5bX7; 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.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lv13-20020a1709032a8d00b001cc644a2131si16647495plb.74.2023.11.29.13.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 13:45:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=hbTT5bX7; 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.34 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 howler.vger.email (Postfix) with ESMTP id A2766801B4A4; Wed, 29 Nov 2023 13:45:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234721AbjK2Voy (ORCPT <rfc822;realc9580@gmail.com> + 99 others); Wed, 29 Nov 2023 16:44:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234712AbjK2Vos (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 29 Nov 2023 16:44:48 -0500 Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2082.outbound.protection.outlook.com [40.107.247.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A0091709; Wed, 29 Nov 2023 13:44:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aUUHLCV5PuaKAt1oXAfC1Wss9pmZ9l+VCIHLovmTN7ECCZkaYbh+stcq2ABY9sAZ+RUwXxyccVzodfMFDcFkTsn09XWNoopepd4kakmx4Qms1I/IMJZYC9D6N/AvRPm/p/nPYP1gteO2TupUsFdz7r7yvx1wWP5UrY/bPmvyChLnsTSVWp4c128XXh7ZONgocwwv8gIHtDVlO1YEsmWyY589wC6wZsiRXeG0fZUwxmUYyZqJW8KRVE5SoJrYv6voZibd/nUcKCVejxeb0Qi8a5PnbhfSTNGR1wlixfMQmdv5VKrN3eWL4UbCkkUSLhqVDZvqG3xdOo38LEFTyROXyw== 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=ENi4BObm6hUCle7hG/sI3aKr4l0G5+aghdecNzdpGvo=; b=PFmuJHF3hTHwvkBOgywxkwvOcyTVAf0lS5MHFA3KOCCyFZ6Uhx1enBzkZzzdbSpVlgHNdQ07W3oC0vF9FD3+1cIFJPxQZWGUJUxONVgW6sVRt1Fy+nnXBFMzvi1mCDp50skJ8qomYUllTmu93CSU5rV2xbH1jt9FQJ4BaQfgBwv4X8KYYIBAkiSASAEU6DXni1V6h3t51yhGWl2cuKAYAAxi/vlKSegSdznbYh2LCIcfXjmhMWGGFoGhuv+fppdunYWHrYEmW7CghWGnNjCvHLmGkDWX1uw4+Ud81aBArj3bF1eSLp4y7pydPRpSjZIk9tRjfOlmDFxGhz3jjM7pew== 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=ENi4BObm6hUCle7hG/sI3aKr4l0G5+aghdecNzdpGvo=; b=hbTT5bX7nkzs1wAy1C43UBLOjw3jbThwpiD5C+1YmWC/JNlCCGXkWJu9a4hSwqyOR3HijoeC5CdsqqhhPNQxIwKs/0cjwnR+nmKDNOYA6YAQO36M1i6f8C2IjZzqvv/K852Uesa5caA4Ax9J6O6tt2ev96+TWUjqRN+Ng6CNyb4= 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 DBAPR04MB7416.eurprd04.prod.outlook.com (2603:10a6:10:1b3::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.11; Wed, 29 Nov 2023 21:44:44 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40%6]) with mapi id 15.20.7046.015; Wed, 29 Nov 2023 21:44:44 +0000 From: Frank Li <Frank.Li@nxp.com> To: manivannan.sadhasivam@linaro.org Cc: Frank.Li@nxp.com, bhelgaas@google.com, imx@lists.linux.dev, kw@linux.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, lpieralisi@kernel.org, minghuan.Lian@nxp.com, mingkai.hu@nxp.com, robh@kernel.org, roy.zang@nxp.com Subject: [PATCH v4 4/4] PCI: layerscape: Add suspend/resume for ls1043a Date: Wed, 29 Nov 2023 16:44:12 -0500 Message-Id: <20231129214412.327633-5-Frank.Li@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231129214412.327633-1-Frank.Li@nxp.com> References: <20231129214412.327633-1-Frank.Li@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SJ0PR13CA0136.namprd13.prod.outlook.com (2603:10b6:a03:2c6::21) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|DBAPR04MB7416:EE_ X-MS-Office365-Filtering-Correlation-Id: 120f70b8-0948-486f-8230-08dbf1246699 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l0qj56seLC49at42ZaRsH+bXm2MFtjulInLki67JV5yK6jYH0lMmOt+K0OoMXXbqlUBtiJVBy2Z2406CjsGt5cn06gSxqGbb8TZoc1TOmekkutucN83NBxBIAKWyiuwJ1wSzqAOeIhFT9NDZOXw4jluDWIz/jNTto6lCSrZDgWE1ShJKvItA+0DLND+92ss9z32GlhC+163YZ9EQd3ICTBv9ba8484zz2xyaUFGVUT1woa1DuSvZz7DMDwfzgHKWPo/Yqj3X4C1ljyQ1bltHesYobz/Mau9fhLxdgND6trC1io79Xu6iUnx2Z207sK04Uzrkk0al3pOFEFe4I8z51+XPdPOSVizsHYOVFKmd0Q1jj9deWBi5aEvTtVRU+9Gx9/naPydKXl9kPho2qi9pzWK6oWHVjS9bm4BwZ8xJ3/dVdgesPHXbJlW9r5HRq2HAq/K43Ac1EMKNMyeTkfjysme9z4y7l4mM1CtBZRNyjHHd5IdnGcyYwWpI1XKj+OQXaluCyoQaLJhOP2RGsPAVN36OEDmlS+Bn/PPyFtI0s04p0+oN6f+SFAi1geJAo7L6gQxXdKW7fhB1eIRKvMlSXtttVfdB7qlHUvktzqH5mxi58AlNdkSRSZc2lvsTtBfdV6H9HcEwWLF0fM8wHCozaw== 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)(366004)(39860400002)(376002)(136003)(396003)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(83380400001)(26005)(41300700001)(8936002)(8676002)(36756003)(478600001)(6486002)(316002)(86362001)(4326008)(6666004)(38350700005)(38100700002)(202311291699003)(1076003)(2616005)(6512007)(15650500001)(52116002)(66476007)(6916009)(66556008)(66946007)(2906002)(5660300002)(7416002)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kNZvkY6D0WUb3GEAGFwtxIMo5lWLFN/XWWmeXHR4ce+FPq8n7jgKxFLODjiOHO7XgpSSgBiuIkuCT/0V6gdHqroQ53Dn423odSpF/4S+gRRUtmHg916rWloTpRYcnb/iT59+xko5E0yE/apAPPYhZDRPk6zQt3ALomrA4sl8jLjq33K7/cufg8k4sq1MCa76qiJJrSTemzERCIeEeAg7fuWj5a80nqFJC23ohFNJ5LM8V/3hL9j52JMN6VwrbQnUTqeaWZpXnop5gFM4DOIkD9wvPsk6+0+mGzcQQQm1F7NYElExAolhOvsbPXm6niRS0uy7dzUOhzlzTzvG7wl4Y/dv0kgUT8SPyWJ/VXoFl0UwSxExiDAWhdaxFNsst8m0dcQlNifMiuPW8cNlHuTXUTiz7doMcMIIuGzJtQBY4X4DrgUuEF5uDnknPUznAOtF6q1FjlXiQs/Sfp7ZVXb20sY8LgD51p1bXIjVs3t3vm1480LQcim0v/Y/ba/wIAKP/jZZj11+ZX+63v0rvJnfxAuRCZmzLq73oUFgKfVb0dNzRAop//2VD8iG9MVbvwiogHWXj89rdaIYk4c39GpFxO+JRgZ/ZPKS6dCQL8VG5EQYqBUXf/EKc0GJpWAiW/h6dm7L1Xpzcpqed6blbLroQWIybsmL6+JjaYL9Q23/cNkacCsEv5RKkM9FgUjTRM6TJykYxF6WtJlfjdW8rNOw9yAtAJGVr5Oe9T+J4vq4W6mOmeLTjs4XXuZ+1111K7oXZgaGZIpIYivjwU8rR61TNZ4w0qJNTib5jUwG9ec9ljoqzFWT54ejnCxjy6A4VJMGghU4Z64V9gNIro6SR9MinedCMTkFtv8U/YwqotEiPaoqEwgY4ZUaNcGcPdtpnwM+L2N0eWnf5Sx/TFkd3HmLswOH+wR3sjn5y4Di3dncWc76VwFMW0N8gseVZwISCJA+jdQvBhbEUlFWxd38Qd/9WxlG3SqwLVpIGvRM97XCPJnL5AQj0AsYu3E5EDBG3/3MAd0pjkRkExluWWctSWV9fuHI4hM9TqjN7XaAkq2dydwt4alrfOtrLZfB2L05nAHcCrBh7uE01NgkwC/xFf0bhPp85/ZFYE8jKwvBGxWkACuEcTCG1HdDcOnMSnnc+IHoyiQoNKdTgAsclNLL1xfDrr5fVXP882wOlcW2TPnD0GOOgq4xBjDfY5BjgbFMiYFbfyLl2I+dnPaytGQbR7rs4rLAU1YuqW2mly4CeYlyb/C3DYGrz6GAVcCog4WnMAoAmzl1B7TdyNHPhU21EliQOzdBOWjdmcEID+74lLmf/F3VOq/cKQg7aEaWtsDmVpb0X5p+cmWk9ZzuZ9+x/FqNHquGXHxx8A0n+Fpn79ym9DKpE06G7J1CxlvutuqmkRKQPXVG0NfpTZQU3bvIaX+Ryq/GGAr+G7dEDrEdC9OvZHGi3kRxJaSfwEzQwLvuDSSujZ5iHKmXBGehrcjxqGAfPNbaEMESGPK8bACBgJe3CXLtRtzXnLuq/6zm5/GY3+8ezWDsjqim/kysLbcYx4pAs2mEG+hXmc2/+PBf5gnDidU= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 120f70b8-0948-486f-8230-08dbf1246699 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2023 21:44:44.7864 (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: voDQ3O9v9pgZu8BNm+qpB0oJNKiiE3jMn//dnOK7nPpiUkhU9I6Bb9y7C/ybrMkL1s/gvD0LXI0HqUf9Om6wqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7416 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Wed, 29 Nov 2023 13:45:03 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783936395359716450 X-GMAIL-MSGID: 1783936395359716450 |
Series |
dwc general suspend/resume functionality
|
|
Commit Message
Frank Li
Nov. 29, 2023, 9:44 p.m. UTC
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. This link would then 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.
Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
Notes:
Change from v3 to v4
- Call scfg_pcie_send_turnoff_msg() shared with ls1021a
- update commit message
Change from v2 to v3
- Remove ls_pcie_lut_readl(writel) function
Change from v1 to v2
- Update subject 'a' to 'A'
drivers/pci/controller/dwc/pci-layerscape.c | 63 ++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
Comments
On Wed, Nov 29, 2023 at 04:44:12PM -0500, Frank Li wrote: > 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. This link would then 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. > Same comment on the patch description as on patch 2/4. > Signed-off-by: Frank Li <Frank.Li@nxp.com> > --- > > Notes: > Change from v3 to v4 > - Call scfg_pcie_send_turnoff_msg() shared with ls1021a > - update commit message > > Change from v2 to v3 > - Remove ls_pcie_lut_readl(writel) function > > Change from v1 to v2 > - Update subject 'a' to 'A' > > drivers/pci/controller/dwc/pci-layerscape.c | 63 ++++++++++++++++++++- > 1 file changed, 62 insertions(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c > index 590e07bb27002..d39700b3afaaa 100644 > --- a/drivers/pci/controller/dwc/pci-layerscape.c > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > @@ -41,6 +41,15 @@ > #define SCFG_PEXSFTRSTCR 0x190 > #define PEXSR(idx) BIT(idx) > > +/* LS1043A PEX PME control register */ > +#define SCFG_PEXPMECR 0x144 > +#define PEXPME(idx) BIT(31 - (idx) * 4) > + > +/* LS1043A PEX LUT debug register */ > +#define LS_PCIE_LDBG 0x7fc > +#define LDBG_SR BIT(30) > +#define LDBG_WE BIT(31) > + > #define PCIE_IATU_NUM 6 > > struct ls_pcie_drvdata { > @@ -225,6 +234,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) > return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index)); > } > > +static void ls1043a_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); > + > + scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index)); > +} > + > +static int ls1043a_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; > + > + /* > + * Only way let PEX module exit L2 is do a software reset. Can you expand PEX? What is it used for? Also if the reset is only for the PEX module, please use the same comment in both patches 2 and 4. Patch 2 doesn't mention PEX in the comment. - Mani > + * LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and > + * clearing the soft reset on the PEX module. > + * LDBG_SR: When SR is set to 1, the PEX module enters soft reset. > + */ > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > + val |= LDBG_WE; > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > + > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > + val |= LDBG_SR; > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > + > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > + val &= ~LDBG_SR; > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > + > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > + val &= ~LDBG_WE; > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > + > + return 0; > +} > + > 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, > @@ -242,6 +290,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = { > .exit_from_l2 = ls1021a_pcie_exit_from_l2, > }; > > +static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = { > + .host_init = ls_pcie_host_init, > + .pme_turn_off = ls1043a_pcie_send_turnoff_msg, > +}; > + > +static const struct ls_pcie_drvdata ls1043a_drvdata = { > + .pf_lut_off = 0x10000, > + .pm_support = true, > + .scfg_support = true, > + .ops = &ls1043a_pcie_host_ops, > + .exit_from_l2 = ls1043a_pcie_exit_from_l2, > +}; > + > static const struct ls_pcie_drvdata layerscape_drvdata = { > .pf_lut_off = 0xc0000, > .pm_support = true, > @@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = { > { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, > { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, > { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, > - { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, > + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata }, > { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, > { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, > { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata }, > -- > 2.34.1 >
On Thu, Nov 30, 2023 at 10:21:00PM +0530, Manivannan Sadhasivam wrote: > On Wed, Nov 29, 2023 at 04:44:12PM -0500, Frank Li wrote: > > 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. This link would then 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. > > > > Same comment on the patch description as on patch 2/4. > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > --- > > > > Notes: > > Change from v3 to v4 > > - Call scfg_pcie_send_turnoff_msg() shared with ls1021a > > - update commit message > > > > Change from v2 to v3 > > - Remove ls_pcie_lut_readl(writel) function > > > > Change from v1 to v2 > > - Update subject 'a' to 'A' > > > > drivers/pci/controller/dwc/pci-layerscape.c | 63 ++++++++++++++++++++- > > 1 file changed, 62 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c > > index 590e07bb27002..d39700b3afaaa 100644 > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > @@ -41,6 +41,15 @@ > > #define SCFG_PEXSFTRSTCR 0x190 > > #define PEXSR(idx) BIT(idx) > > > > +/* LS1043A PEX PME control register */ > > +#define SCFG_PEXPMECR 0x144 > > +#define PEXPME(idx) BIT(31 - (idx) * 4) > > + > > +/* LS1043A PEX LUT debug register */ > > +#define LS_PCIE_LDBG 0x7fc > > +#define LDBG_SR BIT(30) > > +#define LDBG_WE BIT(31) > > + > > #define PCIE_IATU_NUM 6 > > > > struct ls_pcie_drvdata { > > @@ -225,6 +234,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) > > return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index)); > > } > > > > +static void ls1043a_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); > > + > > + scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index)); > > +} > > + > > +static int ls1043a_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; > > + > > + /* > > + * Only way let PEX module exit L2 is do a software reset. > > Can you expand PEX? What is it used for? > > Also if the reset is only for the PEX module, please use the same comment in > both patches 2 and 4. Patch 2 doesn't mention PEX in the comment. After read spec again, I think PEX is pci express. So it should software reset controller. I don't know what exactly did in the chip. But without below code, PCIe can't exit L2/L3. Any harmful if dwc controller reset? Anyway these code works well with intel network card. Frank > > - Mani > > > + * LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and > > + * clearing the soft reset on the PEX module. > > + * LDBG_SR: When SR is set to 1, the PEX module enters soft reset. > > + */ > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > + val |= LDBG_WE; > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > + > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > + val |= LDBG_SR; > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > + > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > + val &= ~LDBG_SR; > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > + > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > + val &= ~LDBG_WE; > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > + > > + return 0; > > +} > > + > > 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, > > @@ -242,6 +290,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = { > > .exit_from_l2 = ls1021a_pcie_exit_from_l2, > > }; > > > > +static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = { > > + .host_init = ls_pcie_host_init, > > + .pme_turn_off = ls1043a_pcie_send_turnoff_msg, > > +}; > > + > > +static const struct ls_pcie_drvdata ls1043a_drvdata = { > > + .pf_lut_off = 0x10000, > > + .pm_support = true, > > + .scfg_support = true, > > + .ops = &ls1043a_pcie_host_ops, > > + .exit_from_l2 = ls1043a_pcie_exit_from_l2, > > +}; > > + > > static const struct ls_pcie_drvdata layerscape_drvdata = { > > .pf_lut_off = 0xc0000, > > .pm_support = true, > > @@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = { > > { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, > > { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, > > { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, > > - { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, > > + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata }, > > { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, > > { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, > > { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata }, > > -- > > 2.34.1 > > > > -- > மணிவண்ணன் சதாசிவம்
On Thu, Nov 30, 2023 at 03:17:39PM -0500, Frank Li wrote: > On Thu, Nov 30, 2023 at 10:21:00PM +0530, Manivannan Sadhasivam wrote: > > On Wed, Nov 29, 2023 at 04:44:12PM -0500, Frank Li wrote: > > > 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. This link would then 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. > > > > > > > Same comment on the patch description as on patch 2/4. > > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > > --- > > > > > > Notes: > > > Change from v3 to v4 > > > - Call scfg_pcie_send_turnoff_msg() shared with ls1021a > > > - update commit message > > > > > > Change from v2 to v3 > > > - Remove ls_pcie_lut_readl(writel) function > > > > > > Change from v1 to v2 > > > - Update subject 'a' to 'A' > > > > > > drivers/pci/controller/dwc/pci-layerscape.c | 63 ++++++++++++++++++++- > > > 1 file changed, 62 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c > > > index 590e07bb27002..d39700b3afaaa 100644 > > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > > @@ -41,6 +41,15 @@ > > > #define SCFG_PEXSFTRSTCR 0x190 > > > #define PEXSR(idx) BIT(idx) > > > > > > +/* LS1043A PEX PME control register */ > > > +#define SCFG_PEXPMECR 0x144 > > > +#define PEXPME(idx) BIT(31 - (idx) * 4) > > > + > > > +/* LS1043A PEX LUT debug register */ > > > +#define LS_PCIE_LDBG 0x7fc > > > +#define LDBG_SR BIT(30) > > > +#define LDBG_WE BIT(31) > > > + > > > #define PCIE_IATU_NUM 6 > > > > > > struct ls_pcie_drvdata { > > > @@ -225,6 +234,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) > > > return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index)); > > > } > > > > > > +static void ls1043a_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); > > > + > > > + scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index)); > > > +} > > > + > > > +static int ls1043a_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; > > > + > > > + /* > > > + * Only way let PEX module exit L2 is do a software reset. > > > > Can you expand PEX? What is it used for? > > > > Also if the reset is only for the PEX module, please use the same comment in > > both patches 2 and 4. Patch 2 doesn't mention PEX in the comment. > > After read spec again, I think PEX is pci express. So it should software > reset controller. I don't know what exactly did in the chip. But without > below code, PCIe can't exit L2/L3. > > Any harmful if dwc controller reset? Anyway these code works well with > intel network card. Sorry, sent too quick. It is PCIe express wrapper Copy from spec: "PEXLDBG[SR]. Once set the PEXLDBG[SR] will enable the soft reset to the PEX wrapper." Frank > > Frank > > > > > - Mani > > > > > + * LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and > > > + * clearing the soft reset on the PEX module. > > > + * LDBG_SR: When SR is set to 1, the PEX module enters soft reset. > > > + */ > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val |= LDBG_WE; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val |= LDBG_SR; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val &= ~LDBG_SR; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val &= ~LDBG_WE; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + return 0; > > > +} > > > + > > > 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, > > > @@ -242,6 +290,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = { > > > .exit_from_l2 = ls1021a_pcie_exit_from_l2, > > > }; > > > > > > +static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = { > > > + .host_init = ls_pcie_host_init, > > > + .pme_turn_off = ls1043a_pcie_send_turnoff_msg, > > > +}; > > > + > > > +static const struct ls_pcie_drvdata ls1043a_drvdata = { > > > + .pf_lut_off = 0x10000, > > > + .pm_support = true, > > > + .scfg_support = true, > > > + .ops = &ls1043a_pcie_host_ops, > > > + .exit_from_l2 = ls1043a_pcie_exit_from_l2, > > > +}; > > > + > > > static const struct ls_pcie_drvdata layerscape_drvdata = { > > > .pf_lut_off = 0xc0000, > > > .pm_support = true, > > > @@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = { > > > { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, > > > { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, > > > { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, > > > - { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, > > > + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata }, > > > { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, > > > { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, > > > { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata }, > > > -- > > > 2.34.1 > > > > > > > -- > > மணிவண்ணன் சதாசிவம்
On Thu, Nov 30, 2023 at 03:17:39PM -0500, Frank Li wrote: > On Thu, Nov 30, 2023 at 10:21:00PM +0530, Manivannan Sadhasivam wrote: > > On Wed, Nov 29, 2023 at 04:44:12PM -0500, Frank Li wrote: > > > 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. This link would then 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. > > > > > > > Same comment on the patch description as on patch 2/4. > > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > > --- > > > > > > Notes: > > > Change from v3 to v4 > > > - Call scfg_pcie_send_turnoff_msg() shared with ls1021a > > > - update commit message > > > > > > Change from v2 to v3 > > > - Remove ls_pcie_lut_readl(writel) function > > > > > > Change from v1 to v2 > > > - Update subject 'a' to 'A' > > > > > > drivers/pci/controller/dwc/pci-layerscape.c | 63 ++++++++++++++++++++- > > > 1 file changed, 62 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c > > > index 590e07bb27002..d39700b3afaaa 100644 > > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > > @@ -41,6 +41,15 @@ > > > #define SCFG_PEXSFTRSTCR 0x190 > > > #define PEXSR(idx) BIT(idx) > > > > > > +/* LS1043A PEX PME control register */ > > > +#define SCFG_PEXPMECR 0x144 > > > +#define PEXPME(idx) BIT(31 - (idx) * 4) > > > + > > > +/* LS1043A PEX LUT debug register */ > > > +#define LS_PCIE_LDBG 0x7fc > > > +#define LDBG_SR BIT(30) > > > +#define LDBG_WE BIT(31) > > > + > > > #define PCIE_IATU_NUM 6 > > > > > > struct ls_pcie_drvdata { > > > @@ -225,6 +234,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) > > > return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index)); > > > } > > > > > > +static void ls1043a_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); > > > + > > > + scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index)); > > > +} > > > + > > > +static int ls1043a_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; > > > + > > > + /* > > > + * Only way let PEX module exit L2 is do a software reset. > > > > Can you expand PEX? What is it used for? > > > > Also if the reset is only for the PEX module, please use the same comment in > > both patches 2 and 4. Patch 2 doesn't mention PEX in the comment. > > After read spec again, I think PEX is pci express. So it should software > reset controller. I don't know what exactly did in the chip. But without > below code, PCIe can't exit L2/L3. > > Any harmful if dwc controller reset? Anyway these code works well with > intel network card. If it is a DWC controller reset, then we need to program all CSRs like DBI etc... But from your reply it seems like the reset is limited to some module, so it is fine. - Mani > > Frank > > > > > - Mani > > > > > + * LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and > > > + * clearing the soft reset on the PEX module. > > > + * LDBG_SR: When SR is set to 1, the PEX module enters soft reset. > > > + */ > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val |= LDBG_WE; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val |= LDBG_SR; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val &= ~LDBG_SR; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > + val &= ~LDBG_WE; > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > + > > > + return 0; > > > +} > > > + > > > 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, > > > @@ -242,6 +290,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = { > > > .exit_from_l2 = ls1021a_pcie_exit_from_l2, > > > }; > > > > > > +static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = { > > > + .host_init = ls_pcie_host_init, > > > + .pme_turn_off = ls1043a_pcie_send_turnoff_msg, > > > +}; > > > + > > > +static const struct ls_pcie_drvdata ls1043a_drvdata = { > > > + .pf_lut_off = 0x10000, > > > + .pm_support = true, > > > + .scfg_support = true, > > > + .ops = &ls1043a_pcie_host_ops, > > > + .exit_from_l2 = ls1043a_pcie_exit_from_l2, > > > +}; > > > + > > > static const struct ls_pcie_drvdata layerscape_drvdata = { > > > .pf_lut_off = 0xc0000, > > > .pm_support = true, > > > @@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = { > > > { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, > > > { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, > > > { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, > > > - { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, > > > + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata }, > > > { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, > > > { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, > > > { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata }, > > > -- > > > 2.34.1 > > > > > > > -- > > மணிவண்ணன் சதாசிவம்
On Thu, Nov 30, 2023 at 03:22:14PM -0500, Frank Li wrote: > On Thu, Nov 30, 2023 at 03:17:39PM -0500, Frank Li wrote: > > On Thu, Nov 30, 2023 at 10:21:00PM +0530, Manivannan Sadhasivam wrote: > > > On Wed, Nov 29, 2023 at 04:44:12PM -0500, Frank Li wrote: > > > > 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. This link would then 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. > > > > > > > > > > Same comment on the patch description as on patch 2/4. > > > > > > > Signed-off-by: Frank Li <Frank.Li@nxp.com> > > > > --- > > > > > > > > Notes: > > > > Change from v3 to v4 > > > > - Call scfg_pcie_send_turnoff_msg() shared with ls1021a > > > > - update commit message > > > > > > > > Change from v2 to v3 > > > > - Remove ls_pcie_lut_readl(writel) function > > > > > > > > Change from v1 to v2 > > > > - Update subject 'a' to 'A' > > > > > > > > drivers/pci/controller/dwc/pci-layerscape.c | 63 ++++++++++++++++++++- > > > > 1 file changed, 62 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c > > > > index 590e07bb27002..d39700b3afaaa 100644 > > > > --- a/drivers/pci/controller/dwc/pci-layerscape.c > > > > +++ b/drivers/pci/controller/dwc/pci-layerscape.c > > > > @@ -41,6 +41,15 @@ > > > > #define SCFG_PEXSFTRSTCR 0x190 > > > > #define PEXSR(idx) BIT(idx) > > > > > > > > +/* LS1043A PEX PME control register */ > > > > +#define SCFG_PEXPMECR 0x144 > > > > +#define PEXPME(idx) BIT(31 - (idx) * 4) > > > > + > > > > +/* LS1043A PEX LUT debug register */ > > > > +#define LS_PCIE_LDBG 0x7fc > > > > +#define LDBG_SR BIT(30) > > > > +#define LDBG_WE BIT(31) > > > > + > > > > #define PCIE_IATU_NUM 6 > > > > > > > > struct ls_pcie_drvdata { > > > > @@ -225,6 +234,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) > > > > return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index)); > > > > } > > > > > > > > +static void ls1043a_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); > > > > + > > > > + scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index)); > > > > +} > > > > + > > > > +static int ls1043a_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; > > > > + > > > > + /* > > > > + * Only way let PEX module exit L2 is do a software reset. > > > > > > Can you expand PEX? What is it used for? > > > > > > Also if the reset is only for the PEX module, please use the same comment in > > > both patches 2 and 4. Patch 2 doesn't mention PEX in the comment. > > > > After read spec again, I think PEX is pci express. So it should software > > reset controller. I don't know what exactly did in the chip. But without > > below code, PCIe can't exit L2/L3. > > > > Any harmful if dwc controller reset? Anyway these code works well with > > intel network card. > > Sorry, sent too quick. It is PCIe express wrapper > > Copy from spec: > > "PEXLDBG[SR]. Once set the > PEXLDBG[SR] will enable the soft reset to the PEX wrapper." > Okay. Please use the below comment in both patches 2 and 4: /* Reset the PEX wrapper to bring the link out of L2 */ - Mani > Frank > > > > > Frank > > > > > > > > - Mani > > > > > > > + * LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and > > > > + * clearing the soft reset on the PEX module. > > > > + * LDBG_SR: When SR is set to 1, the PEX module enters soft reset. > > > > + */ > > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > > + val |= LDBG_WE; > > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > > + > > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > > + val |= LDBG_SR; > > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > > + > > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > > + val &= ~LDBG_SR; > > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > > + > > > > + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); > > > > + val &= ~LDBG_WE; > > > > + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); > > > > + > > > > + return 0; > > > > +} > > > > + > > > > 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, > > > > @@ -242,6 +290,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = { > > > > .exit_from_l2 = ls1021a_pcie_exit_from_l2, > > > > }; > > > > > > > > +static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = { > > > > + .host_init = ls_pcie_host_init, > > > > + .pme_turn_off = ls1043a_pcie_send_turnoff_msg, > > > > +}; > > > > + > > > > +static const struct ls_pcie_drvdata ls1043a_drvdata = { > > > > + .pf_lut_off = 0x10000, > > > > + .pm_support = true, > > > > + .scfg_support = true, > > > > + .ops = &ls1043a_pcie_host_ops, > > > > + .exit_from_l2 = ls1043a_pcie_exit_from_l2, > > > > +}; > > > > + > > > > static const struct ls_pcie_drvdata layerscape_drvdata = { > > > > .pf_lut_off = 0xc0000, > > > > .pm_support = true, > > > > @@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = { > > > > { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, > > > > { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, > > > > { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, > > > > - { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, > > > > + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata }, > > > > { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, > > > > { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, > > > > { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata }, > > > > -- > > > > 2.34.1 > > > > > > > > > > -- > > > மணிவண்ணன் சதாசிவம்
diff --git a/drivers/pci/controller/dwc/pci-layerscape.c b/drivers/pci/controller/dwc/pci-layerscape.c index 590e07bb27002..d39700b3afaaa 100644 --- a/drivers/pci/controller/dwc/pci-layerscape.c +++ b/drivers/pci/controller/dwc/pci-layerscape.c @@ -41,6 +41,15 @@ #define SCFG_PEXSFTRSTCR 0x190 #define PEXSR(idx) BIT(idx) +/* LS1043A PEX PME control register */ +#define SCFG_PEXPMECR 0x144 +#define PEXPME(idx) BIT(31 - (idx) * 4) + +/* LS1043A PEX LUT debug register */ +#define LS_PCIE_LDBG 0x7fc +#define LDBG_SR BIT(30) +#define LDBG_WE BIT(31) + #define PCIE_IATU_NUM 6 struct ls_pcie_drvdata { @@ -225,6 +234,45 @@ static int ls1021a_pcie_exit_from_l2(struct dw_pcie_rp *pp) return scfg_pcie_exit_from_l2(pcie->scfg, SCFG_PEXSFTRSTCR, PEXSR(pcie->index)); } +static void ls1043a_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); + + scfg_pcie_send_turnoff_msg(pcie->scfg, SCFG_PEXPMECR, PEXPME(pcie->index)); +} + +static int ls1043a_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; + + /* + * Only way let PEX module exit L2 is do a software reset. + * LDBG_WE: allows the user to have write access to the PEXDBG[SR] for both setting and + * clearing the soft reset on the PEX module. + * LDBG_SR: When SR is set to 1, the PEX module enters soft reset. + */ + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); + val |= LDBG_WE; + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); + + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); + val |= LDBG_SR; + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); + + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); + val &= ~LDBG_SR; + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); + + val = ls_pcie_pf_lut_readl(pcie, LS_PCIE_LDBG); + val &= ~LDBG_WE; + ls_pcie_pf_lut_writel(pcie, LS_PCIE_LDBG, val); + + return 0; +} + 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, @@ -242,6 +290,19 @@ static const struct ls_pcie_drvdata ls1021a_drvdata = { .exit_from_l2 = ls1021a_pcie_exit_from_l2, }; +static const struct dw_pcie_host_ops ls1043a_pcie_host_ops = { + .host_init = ls_pcie_host_init, + .pme_turn_off = ls1043a_pcie_send_turnoff_msg, +}; + +static const struct ls_pcie_drvdata ls1043a_drvdata = { + .pf_lut_off = 0x10000, + .pm_support = true, + .scfg_support = true, + .ops = &ls1043a_pcie_host_ops, + .exit_from_l2 = ls1043a_pcie_exit_from_l2, +}; + static const struct ls_pcie_drvdata layerscape_drvdata = { .pf_lut_off = 0xc0000, .pm_support = true, @@ -252,7 +313,7 @@ static const struct of_device_id ls_pcie_of_match[] = { { .compatible = "fsl,ls1012a-pcie", .data = &layerscape_drvdata }, { .compatible = "fsl,ls1021a-pcie", .data = &ls1021a_drvdata }, { .compatible = "fsl,ls1028a-pcie", .data = &layerscape_drvdata }, - { .compatible = "fsl,ls1043a-pcie", .data = &ls1021a_drvdata }, + { .compatible = "fsl,ls1043a-pcie", .data = &ls1043a_drvdata }, { .compatible = "fsl,ls1046a-pcie", .data = &layerscape_drvdata }, { .compatible = "fsl,ls2080a-pcie", .data = &layerscape_drvdata }, { .compatible = "fsl,ls2085a-pcie", .data = &layerscape_drvdata },