Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp650599rdb; Fri, 26 Jan 2024 06:52:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFMaLySVxENWVAq55hJBccfq8tdf8lHcyEzUpeVhTXLXG7LmAVnF5RMxG00dzPAfcwpOtQ X-Received: by 2002:a05:6402:148b:b0:55d:333c:1ae with SMTP id e11-20020a056402148b00b0055d333c01aemr657728edv.15.1706280761804; Fri, 26 Jan 2024 06:52:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706280761; cv=pass; d=google.com; s=arc-20160816; b=PHO845vrRHV1me6HBQEsXqliK1FOuY2Dj20ou8LdGjDdk73KuTNt16AS+g4mhs29QX frJ86j17AjScjDky8I6xwzbNeib3YfRREO3Eh4sgoK1V3oVy5H4/V8Tj1VDRN1OBkL+Z nBuN/g2tsxjELnLRdI3Ef1QHzAFNykCh6mQXDxSOwdCf/Sk5GbPZ+RHIC2HD50TmNFr/ TrAO8PMtcAk5Sf8G9jCnHOKN39/BWSByMqLq+V8FA0NPZYe8d2sirdbfAGYaxasFR8VM fvZ5zUDB+rtg8RS5Kfbg9GhybmXUvvhNTnDjZBRa1wu/w+IGZD+hTGfkQKbITpN9LyoN 6/kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=lcccQt60PbgXpfFYlxstnMtRY1ZKZ/mBq6e6WJEE79I=; fh=ihwxVJW8DyodhmdJo1IfhLUDNDWeXh+49SpWXYbpL2Y=; b=S/LImDTGKjyfjRXlxGKfoIFqUHzgkcS+U+unj07Js8/C5sAWLmrg3UdTuVypQJ9Zju 9/BAnTmIGVrqBw2MvQGcnLkS8Gjax6KcVC+rwgagngbvShtXOTFIkJ3PaVo4ksRTj//i CTa98SNvQDBcp4z6W2Xs033Qu5wLWkjOQvwKzO21s4rVBq3AMJYmbiFkDU9TZOKQYWdA UXOdyxeuTn0J09rV7iVRPMFcnW8Oz8vk+g7w/I0uVefTOnf4hTWsKj8TgM0uQ3yCWBwu hmXdaao18apPNCX9A8G5zx10bCOUX6SyxnGAXzPt0H7QYybYwtURyMW4TGR/bVBwlBHj tq0Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="NLM/H13H"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-40212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40212-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id dn2-20020a05640222e200b0055a8321f767si678726edb.258.2024.01.26.06.52.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 06:52:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="NLM/H13H"; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-40212-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40212-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 69C081F2A258 for ; Fri, 26 Jan 2024 14:42:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D1F82111D; Fri, 26 Jan 2024 14:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="NLM/H13H" Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 E6BB420DCF; Fri, 26 Jan 2024 14:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706279892; cv=none; b=WG3WODMBHb7ifkh6PnYK//6B0Vewhw0x+jbAkeJr+spW+/dCoP6heq1vHhEcpwYkZYxgW/qHElmLytkvWfY2QiHYaLz1cNVzRmTr+SiZTJSNtsxttqkO969Owm5spLNhHxmH7/IKfnPO53VS1iZsa0LoifhB009snluECozwgmI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706279892; c=relaxed/simple; bh=EpowN3MVwFfCca/NjDDLYiLhwhML2WXMPwNVeRQX9Mg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iGaXKcaI9oeCUp1ZMjnietK2XaQ9NBuwROVTOieMq0ScB1S7XItwAaElOFiI0exXdc4nn8aT6Po5LmSP+BtEejIKOL03P0rPbUQXBm9eABA4/7ErRk4eOnDRayJ9BTwRbfTyu4viUMP1IIQnBvAYTV0GzlPy8N+uJunxhlxxC1I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=NLM/H13H; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id ECC734000C; Fri, 26 Jan 2024 14:38:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1706279888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lcccQt60PbgXpfFYlxstnMtRY1ZKZ/mBq6e6WJEE79I=; b=NLM/H13Hw/PkB6gbvbxB84bToMata8sGd+8fNgBMPoCQyJBCFw7ww/kaf4etU5S8sBoSba qEXCwG03S1uvdeiaBigfX6iJ5K+LnYAemVXCIpZXWPF+Re9gI+xG5sjsYMPLHSNthiO8Mv Ox1r1V7G4eJL7pNLmSx7Ew6p21yyF9d12y0Fx+OJmSD8HUvazkJY8K6ZbI15tLVr4qtajv Rpim2RT9MllbJPXO9Bi9DugU+P79Qr0qvkKh1IjKFprTSYdMIbQoch6YWVhDADzwN3iNyM zdxtkji3XSDQCuK1XLF9te52H/2uQq2JGQAsYthPAoyMm5PVOTufu34ERyKZZg== From: Thomas Richard Date: Fri, 26 Jan 2024 15:36:55 +0100 Subject: [PATCH v2 13/15] PCI: cadence: add resume support to cdns_pcie_host_setup() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240102-j7200-pcie-s2r-v2-13-8e4f7d228ec2@bootlin.com> References: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> In-Reply-To: <20240102-j7200-pcie-s2r-v2-0-8e4f7d228ec2@bootlin.com> To: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , Tony Lindgren , Haojian Zhuang , Vignesh R , Aaro Koskinen , Janusz Krzysztofik , Andi Shyti , Peter Rosin , Vinod Koul , Kishon Vijay Abraham I , Philipp Zabel , Tom Joseph , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-i2c@vger.kernel.org, linux-phy@lists.infradead.org, linux-pci@vger.kernel.org, gregory.clement@bootlin.com, theo.lebrun@bootlin.com, thomas.petazzoni@bootlin.com, u-kumar1@ti.com, Thomas Richard X-Mailer: b4 0.12.0 X-GND-Sasl: thomas.richard@bootlin.com From: Théo Lebrun That function mixes probe structure init and hardware config. The whole hardware config part must be done at resume after a suspend to ram. We therefore pass it a boolean flag determining if we are at probe or at resume. Signed-off-by: Théo Lebrun Signed-off-by: Thomas Richard --- drivers/pci/controller/cadence/pci-j721e.c | 2 +- drivers/pci/controller/cadence/pcie-cadence-host.c | 49 ++++++++++++---------- drivers/pci/controller/cadence/pcie-cadence-plat.c | 2 +- drivers/pci/controller/cadence/pcie-cadence.h | 4 +- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 2c87e7728a65..9b343a46da11 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -509,7 +509,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) gpiod_set_value_cansleep(gpiod, 1); } - ret = cdns_pcie_host_setup(rc); + ret = cdns_pcie_host_setup(rc, true); if (ret < 0) { clk_disable_unprepare(pcie->refclk); goto err_pcie_setup; diff --git a/drivers/pci/controller/cadence/pcie-cadence-host.c b/drivers/pci/controller/cadence/pcie-cadence-host.c index 5b14f7ee3c79..dd4d876a9138 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-host.c +++ b/drivers/pci/controller/cadence/pcie-cadence-host.c @@ -497,14 +497,14 @@ static int cdns_pcie_host_init(struct device *dev, return cdns_pcie_host_init_address_translation(rc); } -int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) +int cdns_pcie_host_setup(struct cdns_pcie_rc *rc, bool probe) { struct device *dev = rc->pcie.dev; struct platform_device *pdev = to_platform_device(dev); struct device_node *np = dev->of_node; struct pci_host_bridge *bridge; enum cdns_pcie_rp_bar bar; - struct cdns_pcie *pcie; + struct cdns_pcie *pcie = &rc->pcie; struct resource *res; int ret; @@ -512,26 +512,27 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) if (!bridge) return -ENOMEM; - pcie = &rc->pcie; - pcie->is_rc = true; + if (probe) { + pcie->is_rc = true; - rc->vendor_id = 0xffff; - of_property_read_u32(np, "vendor-id", &rc->vendor_id); + rc->vendor_id = 0xffff; + of_property_read_u32(np, "vendor-id", &rc->vendor_id); - rc->device_id = 0xffff; - of_property_read_u32(np, "device-id", &rc->device_id); + rc->device_id = 0xffff; + of_property_read_u32(np, "device-id", &rc->device_id); - pcie->reg_base = devm_platform_ioremap_resource_byname(pdev, "reg"); - if (IS_ERR(pcie->reg_base)) { - dev_err(dev, "missing \"reg\"\n"); - return PTR_ERR(pcie->reg_base); - } + pcie->reg_base = devm_platform_ioremap_resource_byname(pdev, "reg"); + if (IS_ERR(pcie->reg_base)) { + dev_err(dev, "missing \"reg\"\n"); + return PTR_ERR(pcie->reg_base); + } - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); - rc->cfg_base = devm_pci_remap_cfg_resource(dev, res); - if (IS_ERR(rc->cfg_base)) - return PTR_ERR(rc->cfg_base); - rc->cfg_res = res; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cfg"); + rc->cfg_base = devm_pci_remap_cfg_resource(dev, res); + if (IS_ERR(rc->cfg_base)) + return PTR_ERR(rc->cfg_base); + rc->cfg_res = res; + } if (rc->quirk_detect_quiet_flag) cdns_pcie_detect_quiet_min_delay_set(&rc->pcie); @@ -555,12 +556,14 @@ int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) if (ret) return ret; - if (!bridge->ops) - bridge->ops = &cdns_pcie_host_ops; + if (probe) { + if (!bridge->ops) + bridge->ops = &cdns_pcie_host_ops; - ret = pci_host_probe(bridge); - if (ret < 0) - goto err_init; + ret = pci_host_probe(bridge); + if (ret < 0) + goto err_init; + } return 0; diff --git a/drivers/pci/controller/cadence/pcie-cadence-plat.c b/drivers/pci/controller/cadence/pcie-cadence-plat.c index 0456845dabb9..071423091668 100644 --- a/drivers/pci/controller/cadence/pcie-cadence-plat.c +++ b/drivers/pci/controller/cadence/pcie-cadence-plat.c @@ -86,7 +86,7 @@ static int cdns_plat_pcie_probe(struct platform_device *pdev) goto err_get_sync; } - ret = cdns_pcie_host_setup(rc); + ret = cdns_pcie_host_setup(rc, true); if (ret) goto err_init; } else { diff --git a/drivers/pci/controller/cadence/pcie-cadence.h b/drivers/pci/controller/cadence/pcie-cadence.h index 373cb50fcd15..3b0da889ed64 100644 --- a/drivers/pci/controller/cadence/pcie-cadence.h +++ b/drivers/pci/controller/cadence/pcie-cadence.h @@ -515,11 +515,11 @@ static inline bool cdns_pcie_link_up(struct cdns_pcie *pcie) } #ifdef CONFIG_PCIE_CADENCE_HOST -int cdns_pcie_host_setup(struct cdns_pcie_rc *rc); +int cdns_pcie_host_setup(struct cdns_pcie_rc *rc, bool probe); void __iomem *cdns_pci_map_bus(struct pci_bus *bus, unsigned int devfn, int where); #else -static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc) +static inline int cdns_pcie_host_setup(struct cdns_pcie_rc *rc, bool probe) { return 0; } -- 2.39.2