From patchwork Mon Oct 1 20:56:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonard Crestez X-Patchwork-Id: 10623061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A917614BD for ; Tue, 2 Oct 2018 06:52:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80D2828734 for ; Tue, 2 Oct 2018 06:52:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7538028737; Tue, 2 Oct 2018 06:52:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1026628734 for ; Tue, 2 Oct 2018 06:52:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6425C6E28A; Tue, 2 Oct 2018 06:51:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40053.outbound.protection.outlook.com [40.107.4.53]) by gabe.freedesktop.org (Postfix) with ESMTPS id 25A596E058 for ; Mon, 1 Oct 2018 20:56:42 +0000 (UTC) Received: from localhost.localdomain (95.76.156.53) by VI1PR04MB4303.eurprd04.prod.outlook.com (2603:10a6:803:3f::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.25; Mon, 1 Oct 2018 20:56:37 +0000 From: Leonard Crestez To: Lucas Stach , Lorenzo Pieralisi , Shawn Guo Subject: [PATCH 2/3] PCI: imx: Add multi-pd support Date: Mon, 1 Oct 2018 23:56:17 +0300 Message-Id: <5832128f3b1822839a0f0bbd1cf8313cf586f15f.1538426534.git.leonard.crestez@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [95.76.156.53] X-ClientProxiedBy: HE1P190CA0058.EURP190.PROD.OUTLOOK.COM (2603:10a6:7:52::47) To VI1PR04MB4303.eurprd04.prod.outlook.com (2603:10a6:803:3f::30) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a93b8d0-e616-4c42-d2df-08d627e06260 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR04MB4303; X-Microsoft-Exchange-Diagnostics: 1; VI1PR04MB4303; 3:tyXX+EsrMnJ0ahPAr7D69lhlvSDXVmfSMunP3XpTnAQkPVRWhMSyDb3/27QPC57bwM+mSo9i4zQBsUCafbA5lWmqb4yrFYsywlmIrVeuSUvUOS58/54U3qDgj490Ob4HTJzjAQ7XzRtM9tBxCI+wTOa4TPkrIBzRCJasWtAUF4mLID0f/Jb+RP+np9l35+ZCrJXzx97ldvPDGRI/t1aR18QROfaU4TUmPU2H5zOklPBMOgwK2aYtsOwVEc2ADETA; 25:uGAnbwIlxDCsuRnTv/DT8dxq7gzM8M5CdLX54ORt3/IXToLklaqKZ6tx+jvEBeH7gm7ATO8Mb3L5pbclup5T2WhzX1onvsz1/4AuDfl/9lmqttOh/1lWk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gDx4Uk6wrSnkXZ5IHjuwujI5b6OfQvG8jPJ4Nrgzebhx28L/WqSehkl4YAZ5Ga8XyfD1LWdk8rd8oCCJYfVXYDWgDt8Y9JiW3vLbsg26NnRY2Noy/4hF34WvP1tZ0Wo8mypyqImiN/wNzVS756U9yCi9ben/5RfszGbHrhW86tl+BO4vsEeDVHyQ2BDNaP8nobMHV+VJeISB8akeNGZNpNdGB0kTAr7Bvbh0A/N582gO5f5uyhmVXirq7XJTMk5q1IWMCVpHhN/a/Rc8VbMNOWVpltQ4iInEgPAOgiM4v18j/aJ8soAIE0Ii99UHZOJKgWp/z9nKU2xBnZ4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(269456686620040)(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699051); SRVR:VI1PR04MB4303; BCL:0; PCL:0; RULEID:; SRVR:VI1PR04MB4303; X-Forefront-PRVS: 0812095267 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(39860400002)(136003)(366004)(376002)(346002)(396003)(199004)(189003)(5660300001)(6506007)(386003)(316002)(3846002)(16586007)(6512007)(36756003)(6116002)(53936002)(54906003)(110136005)(86362001)(52116002)(51416003)(76176011)(6486002)(44832011)(11346002)(476003)(118296001)(2616005)(6666003)(956004)(2906002)(50226002)(68736007)(8936002)(81156014)(446003)(81166006)(8676002)(486006)(97736004)(105586002)(106356001)(478600001)(25786009)(966005)(48376002)(4326008)(16526019)(186003)(69590400006)(26005)(7416002)(305945005)(6306002)(14444005)(7736002)(47776003)(50466002)(5024004)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR04MB4303; H:localhost.localdomain; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR04MB4303; 23:w6apis3duD/20pJX84fjlpO5ybFTd56Lijp/Wz7uC?= vUex+K6hwaqTAg3XGGhfeqo97ukKafLcaixHdgqvPM0kFm4sEPcWRsBc41Ev41fEeIiGsIwtEAjdQtLxahCpWLZ7nE/wZCpt5asKawuuF235f5QI9IxuFxAJNnMQ+ARxviPLWV3W97seThn253KqKI1PgJo2dQpZrUt0jub93BzLYpFLCctFhMaXZe4XNx25dDFo5d+mDLeh6w9b5+CCwqqUBc6dVg4xKl7MjiSoS2k4I4/bMBGbwBYuZ70OK8ilgg5R/6zOn/lRPzZX+/skU0HQ1VTTS1XAbueSW7VNi5K1RbwcSYmLNc4Mo38lav/uXfxOTCla3qtYkU8sFfKU0Pq1W6k4Yt2+/8aCIG2W03ooFFbrfSUj2sTnQOVnubwZ/Y29mLQKwG8f0GWVw7QubLmMC/k3vgB94J1hdlAY8nwpSQUT4RApqeJULzQNoSOY3fnZSb80Ye3ADX3dJWBw0J5oGqAEyjzbLtw3vJURtbvyAabbZX6cAc81d7K64RPGP94dc4ZXJzIqqoq2VmNAClIkHCXZjniEHRsaa+objPNma7KJ2e0qQUeDbGqCvw131eubbTMk9FDDOir/L1ShbuAMIHReIM2xymLmJ0Ts9Z6YFz7/xdCPTxfUYZSvJPfOuFK69wWrTwxm3gMcKycHojWgSFLBxo04vS7J3RJRYxRwJHTT//hn5wWYaHoP8+ztLk15c3dWtn6ExN7kKGmF5O5JRdiHRL5z7IOjRXqye92B6JJhaJZ0JvhDtlOh3FJnwGChaGdYkMDgcr4C39ucEPd1bi9HTLPyRrsNWiH6hn4ypKmnZrziD8jOMb/UK3bRDvQurWk8EVZlstnjCZIgSlv9gwXcV39Z4CkLkXFvsIPlR0tBANhf5H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jfpZOW8Qdzl8G/DYE/y7MxwJZstYChkzMpNtAMTnQx4pSlLcXbO86Q+P1applbi8zEXKQTq8eUkSBNZBG6PLmWyPsb639jpEDkK5nAHkyPB9NkWoBD9YFwemBCju3Px6kwDxcqeuoBObNy4DNUGWj69F6wKPFEB+1FaFkbVhDyZ3ihvDrfZTK87feSGdZKUewItEDgwNyRARYEy8qIuPOF0tQmBWh+3mvov3oXtjqr/vd2V6N5ogtyd35gilOHjasBr+K4RLgy2RA==; 5:0NMVEFoizBhVOeGmXks00GQieKpiR6JkDcHgaH0ivThjKx3EBDMDmGUn+7NcOjANMZAJdI1bmGTYm0hoRyLv2qicxe1gYx5T6V4sBIVXzl3ylVdG67boOrb9gRJ8Em0j/sNas+bEPASMc9hlOf2yAvizbgp/j84qXbtiWFlKwWI=; 7:OzCcenY90gUkR64Qe1IwedMyecSzSyG3tXwKajce6ESNDH6e174nxCIzy02iQOODZDpqLCxh7GftBwgq9nkzuzYEjGEY1VZJRkJR1mP8oSlVZbLLC0eBERxE5BF6OaxT9hcjZ/E9w89QmtBvS6vz6E3QY/bQysZLFzaBKIL4th+F2l+4MrgZAVVfigxLeyaLb4fp24qaDgreUo0mtyuPLWSPYVB2K2f3FSB8ALj6SZzuNG9ty9vA4sxpz1A5/d+8 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2018 20:56:37.9298 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a93b8d0-e616-4c42-d2df-08d627e06260 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4303 X-Mailman-Approved-At: Tue, 02 Oct 2018 06:51:51 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut , Ulf Hansson , linux-pm@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, kernel@pengutronix.de, Fabio Estevam , linux-imx@nxp.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On some chips the PCIE and PCIE_PHY blocks are in separate power domains which can be power-gated independently. The driver needs to handle this by keeping both domain active. This is intended for imx6sx where PCIE is in DISPMIX and PCIE_PHY in it's own domain. Defining the DISPMIX domain requires a way for pcie to keep it active or it will break when displays are off. The power-domains on imx6sx are meant to look like this: power-domains = <&pd_disp>, <&pd_pci>; power-domain-names = "pcie", "pcie_phy"; Signed-off-by: Leonard Crestez Reviewed-by: Ulf Hansson --- drivers/pci/controller/dwc/pci-imx6.c | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) Previously sent as RFC: https://lkml.org/lkml/2018/7/24/849 diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index d13dae50dc99..6ba16fd1373c 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -25,10 +25,12 @@ #include #include #include #include #include +#include +#include #include "pcie-designware.h" #define to_imx6_pcie(x) dev_get_drvdata((x)->dev) @@ -56,10 +58,15 @@ struct imx6_pcie { u32 tx_deemph_gen2_6db; u32 tx_swing_full; u32 tx_swing_low; int link_gen; struct regulator *vpcie; + + /* power domain for pcie itself (dispmix) */ + struct device *pd_pcie; + /* power domain for pcie phy */ + struct device *pd_pcie_phy; }; /* Parameters for the waiting for PCIe PHY PLL to lock on i.MX7 */ #define PHY_PLL_LOCK_WAIT_MAX_RETRIES 2000 #define PHY_PLL_LOCK_WAIT_USLEEP_MIN 50 @@ -289,10 +296,47 @@ static int imx6q_pcie_abort_handler(unsigned long addr, } return 1; } +static int imx6_pcie_attach_pd(struct device *dev) +{ + struct imx6_pcie *imx6_pcie = dev_get_drvdata(dev); + struct device_link *link; + + /* Do nothing when in a single power domain */ + if (dev->pm_domain) + return 0; + + imx6_pcie->pd_pcie = dev_pm_domain_attach_by_name(dev, "pcie"); + if (IS_ERR(imx6_pcie->pd_pcie)) + return PTR_ERR(imx6_pcie->pd_pcie); + link = device_link_add(dev, imx6_pcie->pd_pcie, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (IS_ERR(link)) { + dev_err(dev, "Failed to add device_link to pcie pd: %ld\n", PTR_ERR(link)); + return PTR_ERR(link); + } + + imx6_pcie->pd_pcie_phy = dev_pm_domain_attach_by_name(dev, "pcie_phy"); + if (IS_ERR(imx6_pcie->pd_pcie_phy)) + return PTR_ERR(imx6_pcie->pd_pcie_phy); + + device_link_add(dev, imx6_pcie->pd_pcie_phy, + DL_FLAG_STATELESS | + DL_FLAG_PM_RUNTIME | + DL_FLAG_RPM_ACTIVE); + if (IS_ERR(link)) { + dev_err(dev, "Failed to add device_link to pcie_phy pd: %ld\n", PTR_ERR(link)); + return PTR_ERR(link); + } + + return 0; +} + static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) { struct device *dev = imx6_pcie->pci->dev; switch (imx6_pcie->variant) { @@ -959,10 +1003,14 @@ static int imx6_pcie_probe(struct platform_device *pdev) imx6_pcie->vpcie = NULL; } platform_set_drvdata(pdev, imx6_pcie); + ret = imx6_pcie_attach_pd(dev); + if (ret) + return ret; + ret = imx6_add_pcie_port(imx6_pcie, pdev); if (ret < 0) return ret; return 0;