Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp995651rdb; Sat, 6 Jan 2024 21:32:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQkV8yW02hudaepy1Sj8CbodOpN3baz7g7qqCgcnPnxjgsz9UZt2mVzz+VSqsLxSuLmhRE X-Received: by 2002:a05:600c:20c1:b0:40d:60f6:909 with SMTP id y1-20020a05600c20c100b0040d60f60909mr599557wmm.216.1704605561896; Sat, 06 Jan 2024 21:32:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704605561; cv=pass; d=google.com; s=arc-20160816; b=PLzhaAFLNl8SY2L2iIT0JWLUSNOU7it+qmCopC2ywJRGgO+qD+HwcdbCAAwhB9xOPF gxW83xXEV/bdAG+++g69SfcqxModYvLtRJfsLv3sXI6JtYBX6zLN/gRMbV1G67ujzrIL jMqF/xIBuDVhI/as4F6aOit2zMpk3ZNhKkfFPHxT7xYD2vuBH+0dR+UxipWHx4P6kW3g XIfKWMnjzat96+eeZ+5fE5kBwvK8aEeacjYT6+5lmqHCQUZA/KfoXbsRRWg8r5zNV47c ImamZRG6S5u8RoxReJKZ7eXERwC9voHCNOeW1zpzhenqpHdQYfdf4YkCH0AB0v2MsIs4 ZbwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :in-reply-to:content-transfer-encoding:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bMYTIQhEZ2iYwCsvfgly0+ACk3hldCB/5SXFMR/fbYE=; fh=+dfAMguWBMzi7KHaRKzrQHOoLDFcscEEushruXbLIe0=; b=jLJGxVE5DyHjY68IcwU/AqrURLsYLdGLmv37T/KWABQeLZypQbAFgPeUP6DazltcV6 Ptia01ZXZT/W+DcQihXmFCdyxQ03jjl/7mJYXMvsyZbbygWnY0otnuQ5lsjUJ0gCgno2 Q4yxIN9VBz/fGCNeHYhv1L9DXx8i+c46k5UT3K8Lq29kAbs3YlBIWkUPCeHAQxbpTvA/ KWY+bIcLViHmQB1doDnH2KuBFhikpLpJjns2Gb3ElkSv46HzZ+C2vf7JG5r6NcD+CAL/ Lq8LRg52aAd/qouyoVGAeXUVE8OMuINeGs2xuTHkFFtVs2vlvgRJvUhld7WVKy5HBanI F2Dg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="aFg/uuIq"; 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+bounces-18782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h21-20020a1709062dd500b00a233b305069si2052919eji.812.2024.01.06.21.32.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Jan 2024 21:32:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b="aFg/uuIq"; 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+bounces-18782-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18782-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 603A61F21CE6 for ; Sun, 7 Jan 2024 05:32:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AB6C125B4; Sun, 7 Jan 2024 05:32:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="aFg/uuIq" X-Original-To: linux-kernel@vger.kernel.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2070.outbound.protection.outlook.com [40.107.15.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91A50125A4; Sun, 7 Jan 2024 05:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Euv5h1wQ2weDPQTN502qOmWHsnWAkb+LrzQhpNehMZ5kSX0KJhBMiJoHylG3EnZeyqCybGdxB6lqv6QB2ctK0lWg3pQuE+mQDDL+LumKJdmdo1IU5T1THkqPQcHwbhWV/TZYoNvBBeFcacjrB1yItwlQjeAHp7Lp6d5trchTUami5JDcP6vlOe/Zg0uR+LBQjpu5CR2FDEns4ray7FG+55WNwBLIlPy8TTNjXOorF3oxysnwSZJAKcW5nyr39gh0dQOpZMd3Bodsz6WpWUe2MPKEfBftnVMypis15awAZugvZc3ZZTd2B597TRUUm4OGOLZgAZWJ2NyILLXUbYeHJw== 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=bMYTIQhEZ2iYwCsvfgly0+ACk3hldCB/5SXFMR/fbYE=; b=hL7wafB8iV1o9UPK4Cj2zc6AZVmnXjKnJFaFL7zJKbJXWcXxM8tZad2Utj15/Go0wp++Y4M43HtQEyQw7vojAFIoHNAN8cAe2sCO3Ba+PSfbBMfA3HjWwKX+27Gx/VYqjrSuvpP1Uk5jOUNAlTpqlXX1QLo7zL9ktITd4AKfJcUx+q+RV6Pul9ZytPRmAKiq1rE06CfUH411tuCUK4wM2LOyFuR3FPdtEM9LfmYgzWo1zlaxhAX7jFst2v9mxPA5gBkhk3HQ8HLlN742lmvgOruDzyUCs1xL3AxkL6HI7EGJs5+oKFPPBkLIJt49Xb/OASWr/2YnRdKeGCjWaykpaQ== 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=bMYTIQhEZ2iYwCsvfgly0+ACk3hldCB/5SXFMR/fbYE=; b=aFg/uuIqqsPY+dE2IL/a2fRQWV73ZUWw0bOvLgpE2P258htStTvQwZC6PQcIOpFvV0eEud3W04U9z9jcnE3noh5U30DXKbGNJ4+DXJSTUH0lVZ2nYZh00lbLTGsfSnJYhiTKfdbhx7S8cbGpgtN26xTNbZHPLg++zs2i6283Izs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB7511.eurprd04.prod.outlook.com (2603:10a6:20b:23f::5) by DB9PR04MB9283.eurprd04.prod.outlook.com (2603:10a6:10:36d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7159.20; Sun, 7 Jan 2024 05:32:23 +0000 Received: from AS8PR04MB7511.eurprd04.prod.outlook.com ([fe80::8ee3:bac5:a2da:d469]) by AS8PR04MB7511.eurprd04.prod.outlook.com ([fe80::8ee3:bac5:a2da:d469%4]) with mapi id 15.20.7159.020; Sun, 7 Jan 2024 05:32:23 +0000 Date: Sun, 7 Jan 2024 00:32:14 -0500 From: Frank Li To: Manivannan Sadhasivam Cc: krzysztof.kozlowski@linaro.org, bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, robh@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: Re: [PATCH v7 07/16] PCI: imx6: Simplify configure_type() by using mode_off and mode_mask Message-ID: References: <20231227182727.1747435-1-Frank.Li@nxp.com> <20231227182727.1747435-8-Frank.Li@nxp.com> <20240107051655.GF3416@thinkpad> Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240107051655.GF3416@thinkpad> X-ClientProxiedBy: BY5PR13CA0034.namprd13.prod.outlook.com (2603:10b6:a03:180::47) To AS8PR04MB7511.eurprd04.prod.outlook.com (2603:10a6:20b:23f::5) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB7511:EE_|DB9PR04MB9283:EE_ X-MS-Office365-Filtering-Correlation-Id: f595db06-be02-4e56-bda0-08dc0f4206a5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0RVzagaeVyqD6Qn4jpJlEJtXFIm9dNEmhpPmdrHSAMEF1t0Gv6X+kOczn1gEEluaqrzmtPES4YVnQoJ4onA7kfWXPfzVLwSjn0o4UqWtU4VzV9/I5OreOqPFdEwGe1n2owxQHeAZtiR0+mc9gAun86W/+lKhR+ugAt3gvLzlvrYnSvQ+tDGjtfn6oNcUcIEXisIjKPFRZjzbFDqspU1CLKVd7nggKtl8Wn9Q6/dguplHF9Z/F+NYMY7Ru1nwLqzJYsNjxAq4wiWQVE5okyq73xJAMMBK/OMfKn4705sJk5BY/NGjlRLUkQ80jk9wlu1uxoGvvxf6BcM8SunS2Ytb8eDcaq2TlXO2uNKd5qhhHqfI+5wGa5UtZSgKG/AgJ0VTItJAGCbwgoG2m7UDDoeaNKFt00H3nWEdRZavg6pnjrJNikezXPk5pnybT4ipQnfx0al5WQVKSmL2XTniI0OQvrK1cyH0GPjc87mXaPvr0gRzf9zOhawrEa68Gfirpk1s28ElcoXMw4dT9p39ZJSXK/djxTr0qCZfVLjapDGuzMJxzAeXqe5GTKhjrrsrlha6VkWjuIrjj7j/fxqt/V+tHqr2sHyn7RAPMW5Qo9tqzbXukwaeqfmPBOCmpkceUwAQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB7511.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(366004)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(6666004)(478600001)(26005)(6512007)(6506007)(9686003)(83380400001)(52116002)(38350700005)(66946007)(66556008)(66476007)(6916009)(41300700001)(38100700002)(2906002)(5660300002)(7416002)(8936002)(8676002)(316002)(4326008)(6486002)(33716001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-Anti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khVQXloWFBDendwTGRQcnJn?= =?utf-8?B?K2V1YVByU3Z2dEJsbHR6WGZmVEZOZzBLN3M0bUswRmN6T0NUcmJDb0poeHdI?= =?utf-8?B?b2h1ZE5rZHdSM2dIOW1CK3RLbTZUR3VLVEVMQTJRNXVtZzAraFJlaTZaQXQ5?= =?utf-8?B?d1dlUnlZNGtlQ3crMm02NzJ3aFVJZDBLc2QrYk9YUmJBazV3ME1RcmRJT1RX?= =?utf-8?B?U0txSjVNVEhRMjFScWhaQmkyYTVNVTV0Z1liSkozRk9qb0IvYk9teUM5RktK?= =?utf-8?B?dXNBZEQrN252dnNhams4eTI0eEZYM0tEcWZUSnVMWkw3Zm5xdEVTQkpWcXkw?= =?utf-8?Q?hJhM=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f595db06-be02-4e56-bda0-08dc0f4206a5 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB7511.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2024 05:32:23.5017 (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: FrlR+/ef9HYq/kfBivvIQqs1bWYdGFJ2YyxkqRwpifaHYGBw6M5ksqh9C5DWc5e/LDy04npvEWZewcKFyii0vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB9283 On Sun, Jan 07, 2024 at 10:46:55AM +0530, Manivannan Sadhasivam wrote: > On Wed, Dec 27, 2023 at 01:27:18PM -0500, Frank Li wrote: > > Add drvdata::mode_off and drvdata::mode_mask to simple > > simplify > > > imx6_pcie_configure_type() logic. > > > > Signed-off-by: Frank Li > > Couple of comments below. > > > --- > > > > Notes: > > Change from v2 to v3 > > - none > > Change from v1 to v2 > > - use ffs() to fixe build error. > > > > drivers/pci/controller/dwc/pci-imx6.c | 60 ++++++++++++++++++--------- > > 1 file changed, 40 insertions(+), 20 deletions(-) > > > > diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c > > index 588bfb616260e..717e8fa030deb 100644 > > --- a/drivers/pci/controller/dwc/pci-imx6.c > > +++ b/drivers/pci/controller/dwc/pci-imx6.c > > @@ -68,6 +68,7 @@ enum imx6_pcie_variants { > > > > #define IMX6_PCIE_MAX_CLKS 6 > > > > +#define IMX6_PCIE_MAX_INSTANCES 2 > > struct imx6_pcie_drvdata { > > enum imx6_pcie_variants variant; > > enum dw_pcie_device_mode mode; > > @@ -77,6 +78,8 @@ struct imx6_pcie_drvdata { > > const char *clk_names[IMX6_PCIE_MAX_CLKS]; > > const u32 ltssm_off; > > const u32 ltssm_mask; > > + const u32 mode_off[IMX6_PCIE_MAX_INSTANCES]; > > + const u32 mode_mask[IMX6_PCIE_MAX_INSTANCES]; > > }; > > > > struct imx6_pcie { > > @@ -174,32 +177,25 @@ static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) > > > > static void imx6_pcie_configure_type(struct imx6_pcie *imx6_pcie) > > { > > - unsigned int mask, val, mode; > > + const struct imx6_pcie_drvdata *drvdata = imx6_pcie->drvdata; > > + unsigned int mask, val, mode, id; > > > > - if (imx6_pcie->drvdata->mode == DW_PCIE_EP_TYPE) > > + if (drvdata->mode == DW_PCIE_EP_TYPE) > > mode = PCI_EXP_TYPE_ENDPOINT; > > else > > mode = PCI_EXP_TYPE_ROOT_PORT; > > > > - switch (imx6_pcie->drvdata->variant) { > > - case IMX8MQ: > > - case IMX8MQ_EP: > > - if (imx6_pcie->controller_id == 1) { > > - mask = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE; > > - val = FIELD_PREP(IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, > > - mode); > > - } else { > > - mask = IMX6Q_GPR12_DEVICE_TYPE; > > - val = FIELD_PREP(IMX6Q_GPR12_DEVICE_TYPE, mode); > > - } > > - break; > > - default: > > - mask = IMX6Q_GPR12_DEVICE_TYPE; > > - val = FIELD_PREP(IMX6Q_GPR12_DEVICE_TYPE, mode); > > - break; > > - } > > + id = imx6_pcie->controller_id; > > + > > + /* If mode_mask[id] is zero, means each controller have its individual gpr */ > > + if (!drvdata->mode_mask[id]) > > + id = 0; > > + > > + mask = drvdata->mode_mask[id]; > > + /* FIELD_PREP mask have been constant */ > > No need of this comment. > > > + val = mode << (ffs(mask) - 1); > > > > - regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, mask, val); > > + regmap_update_bits(imx6_pcie->iomuxc_gpr, drvdata->mode_off[id], mask, val); > > } > > > > static int pcie_phy_poll_ack(struct imx6_pcie *imx6_pcie, bool exp_val) > > @@ -1376,6 +1372,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > .clk_names = {"pcie_bus", "pcie", "pcie_phy"}, > > .ltssm_off = IOMUXC_GPR12, > > .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX6SX] = { > > .variant = IMX6SX, > > @@ -1386,6 +1384,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > .clk_names = {"pcie_bus", "pcie", "pcie_phy", "pcie_inbound_axi"}, > > .ltssm_off = IOMUXC_GPR12, > > .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX6QP] = { > > .variant = IMX6QP, > > @@ -1397,6 +1397,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > .clk_names = {"pcie_bus", "pcie", "pcie_phy"}, > > .ltssm_off = IOMUXC_GPR12, > > .ltssm_mask = IMX6Q_GPR12_PCIE_CTL_2, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX7D] = { > > .variant = IMX7D, > > @@ -1405,6 +1407,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > IMX6_PCIE_FLAG_HAS_PHY_RESET, > > .gpr = "fsl,imx7d-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_phy"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX8MQ] = { > > .variant = IMX8MQ, > > @@ -1412,6 +1416,10 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > IMX6_PCIE_FLAG_HAS_PHY_RESET, > > .gpr = "fsl,imx8mq-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > + .mode_off[1] = IOMUXC_GPR12, > > + .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, > > Is the mode_mask differ between SoCs or fixed based on instances? I mean, if > there is a guarantee that it is going to be IMX6Q_GPR12_DEVICE_TYPE for instance > 1 and IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE for instance 2 etc... > > Then we can avoid these SoC specific config and simplify the code further. No, iMX95 will change it. Frank > > - Mani > > > }, > > [IMX8MM] = { > > .variant = IMX8MM, > > @@ -1420,6 +1428,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > IMX6_PCIE_FLAG_HAS_APP_RESET, > > .gpr = "fsl,imx8mm-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX8MP] = { > > .variant = IMX8MP, > > @@ -1428,6 +1438,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > IMX6_PCIE_FLAG_HAS_APP_RESET, > > .gpr = "fsl,imx8mp-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX8MQ_EP] = { > > .variant = IMX8MQ_EP, > > @@ -1436,6 +1448,10 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > .mode = DW_PCIE_EP_TYPE, > > .gpr = "fsl,imx8mq-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_phy", "pcie_aux"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > + .mode_off[1] = IOMUXC_GPR12, > > + .mode_mask[1] = IMX8MQ_GPR12_PCIE2_CTRL_DEVICE_TYPE, > > }, > > [IMX8MM_EP] = { > > .variant = IMX8MM_EP, > > @@ -1443,6 +1459,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > .mode = DW_PCIE_EP_TYPE, > > .gpr = "fsl,imx8mm-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > [IMX8MP_EP] = { > > .variant = IMX8MP_EP, > > @@ -1450,6 +1468,8 @@ static const struct imx6_pcie_drvdata drvdata[] = { > > .mode = DW_PCIE_EP_TYPE, > > .gpr = "fsl,imx8mp-iomuxc-gpr", > > .clk_names = {"pcie_bus", "pcie", "pcie_aux"}, > > + .mode_off[0] = IOMUXC_GPR12, > > + .mode_mask[0] = IMX6Q_GPR12_DEVICE_TYPE, > > }, > > }; > > > > -- > > 2.34.1 > > > > -- > மணிவண்ணன் சதாசிவம்