From patchwork Tue Jul 18 07:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Karlman X-Patchwork-Id: 1809020 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kwiboo.se header.i=@kwiboo.se header.a=rsa-sha256 header.s=s1 header.b=ZBk5WDyf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R4rqW6WLRz20FX for ; Tue, 18 Jul 2023 17:56:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7E331866F5; Tue, 18 Jul 2023 09:55:46 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kwiboo.se header.i=@kwiboo.se header.b="ZBk5WDyf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6450C866CE; Tue, 18 Jul 2023 09:55:42 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 Received: from s.wrqvwxzv.outbound-mail.sendgrid.net (s.wrqvwxzv.outbound-mail.sendgrid.net [149.72.154.232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EDBD4866B4 for ; Tue, 18 Jul 2023 09:55:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kwiboo.se Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bounces+31435339-7456-u-boot=lists.denx.de@em2124.kwiboo.se DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kwiboo.se; h=from:subject:in-reply-to:references:mime-version:to:cc: content-transfer-encoding:content-type:cc:content-type:from:subject:to; s=s1; bh=l0Rq2uiDcs6M15hOY/7mSiNo4nPJZnTPnKK7du7acK8=; b=ZBk5WDyfKv0/UVzEaPmevPEH8YTeKSdTzRPm/GO0cgWgS0LsQ840TfHQmKpYqW2gEjoW EIaI9kRVKYQnVl7b101GB6txW//m9iupX5AYziMptt9ycUvbeLoK+qtXxWpjRc1txZHBvb ZGwxGDxoWCa40BkSNbySgKwWQSBCdFFi9WiSd2emWMEQq5fzHZRE9xJ3vJKNrCLvAh+Kex lt5d1Sq8i98RonkwoRI4HxStBuTdkLpzoCQqzUBZnsIG4m3tkHkDEzkSAHRoFVcrR9dL7I zphdyiruijr8z9fxCAAYQE3nV4nQuA+NZe9lhNExeT89dyEo65tWQegFRZmcH/UA== Received: by filterdrecv-77869f68cc-gch4b with SMTP id filterdrecv-77869f68cc-gch4b-1-64B64579-F 2023-07-18 07:55:37.506814322 +0000 UTC m=+5905176.667297673 Received: from bionic.localdomain (unknown) by geopod-ismtpd-7 (SG) with ESMTP id VumnTHV0QHiEKUh3mT4fpQ Tue, 18 Jul 2023 07:55:37.314 +0000 (UTC) From: Jonas Karlman Subject: [PATCH v3 2/9] pci: pcie_dw_rockchip: Get config region from reg prop Date: Tue, 18 Jul 2023 07:55:37 +0000 (UTC) Message-ID: <20230718075529.78776-3-jonas@kwiboo.se> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230718075529.78776-1-jonas@kwiboo.se> References: <20230718075529.78776-1-jonas@kwiboo.se> MIME-Version: 1.0 X-SG-EID: TdbjyGynYnRZWhH+7lKUQJL+ZxmxpowvO2O9SQF5CwCVrYgcwUXgU5DKUU3QxAfZekEeQsTe+RrMu3cja6a0h+bQtSmFPYOYgeN2bSIgTr5Oxqd2wJVuCxQXd2MauNLIsLiF3WzYUzqfj/HiFywdz84eS4c+nMXyi9ONxd1iuJM70Flc5+PSvXISzm2Lj0533xADPb1CaMHZML/8vqbZqjxHzk7iVWG/S55hD966rYDcX97F5rFPy4BXEGvkkl2E To: Kever Yang , Simon Glass , Philipp Tomsich Cc: Eugen Hristev , Shawn Lin , u-boot@lists.denx.de, Jonas Karlman X-Entity-ID: P7KYpSJvGCELWjBME/J5tg== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Get the config region to use from the reg prop. Also update the referenced region index used in comment. Signed-off-by: Jonas Karlman Reviewed-by: Kever Yang --- v3: - No change v2: - Use dev_read_addr_size_index_ptr - Collect r-b tag drivers/pci/pcie_dw_common.c | 10 ++++++---- drivers/pci/pcie_dw_rockchip.c | 7 +++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pcie_dw_common.c b/drivers/pci/pcie_dw_common.c index 9f8b016d1149..74fb6df412c7 100644 --- a/drivers/pci/pcie_dw_common.c +++ b/drivers/pci/pcie_dw_common.c @@ -141,9 +141,9 @@ static uintptr_t set_cfg_address(struct pcie_dw *pcie, /* * Not accessing root port configuration space? - * Region #0 is used for Outbound CFG space access. + * Region #1 is used for Outbound CFG space access. * Direction = Outbound - * Region Index = 0 + * Region Index = 1 */ d = PCI_MASK_BUS(d); d = PCI_ADD_BUS(bus, d); @@ -328,8 +328,10 @@ void pcie_dw_setup_host(struct pcie_dw *pci) pci->prefetch.bus_start = hose->regions[ret].bus_start; /* PREFETCH_bus_addr */ pci->prefetch.size = hose->regions[ret].size; /* PREFETCH size */ } else if (hose->regions[ret].flags == PCI_REGION_SYS_MEMORY) { - pci->cfg_base = (void *)(pci->io.phys_start - pci->io.size); - pci->cfg_size = pci->io.size; + if (!pci->cfg_base) { + pci->cfg_base = (void *)(pci->io.phys_start - pci->io.size); + pci->cfg_size = pci->io.size; + } } else { dev_err(pci->dev, "invalid flags type!\n"); } diff --git a/drivers/pci/pcie_dw_rockchip.c b/drivers/pci/pcie_dw_rockchip.c index 6da618055cbe..83737e62bc6a 100644 --- a/drivers/pci/pcie_dw_rockchip.c +++ b/drivers/pci/pcie_dw_rockchip.c @@ -366,6 +366,13 @@ static int rockchip_pcie_parse_dt(struct udevice *dev) dev_dbg(dev, "APB address is 0x%p\n", priv->apb_base); + priv->dw.cfg_base = dev_read_addr_size_index_ptr(dev, 2, + &priv->dw.cfg_size); + if (!priv->dw.cfg_base) + return -EINVAL; + + dev_dbg(dev, "CFG address is 0x%p\n", priv->dw.cfg_base); + ret = gpio_request_by_name(dev, "reset-gpios", 0, &priv->rst_gpio, GPIOD_IS_OUT); if (ret) {