From patchwork Wed Oct 16 20:06:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 11194243 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A2AE14DB for ; Wed, 16 Oct 2019 20:07:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F054421A49 for ; Wed, 16 Oct 2019 20:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571256449; bh=TPw9FVqSp2vCme6iGlQkoO8qY0OGK4pipx59v6MmggM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tyLhZ/IkMHWL8mJ48RgRgbKfVuS2zVbes9KCofNTVFF7hXrR8Y0eMPnhQiqKx9b48 CfSo+Eue/91ppWxijfsqmD4uMw3LPqW0MRy1vWrJnUoeb5bCO6JNpvxApnT6M368ct tbbnENFtZ/eG/oeOuoVtimzn3JSANLOWyOeZYrHQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387507AbfJPUH2 (ORCPT ); Wed, 16 Oct 2019 16:07:28 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:37391 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733109AbfJPUH2 (ORCPT ); Wed, 16 Oct 2019 16:07:28 -0400 Received: by mail-ot1-f66.google.com with SMTP id k32so21293222otc.4; Wed, 16 Oct 2019 13:07:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XzKyx3hGWss5OyYjnaux42GwkpReDhw7ttXIKJ3XApk=; b=gTxQi2P+y09QAqXQxD5bZysoBpJdSshVmQLS4HIBgEVMDRNpi/kTRZ1iVDmtBe8rEY 5XHiGhGfYnVjOZl8aKhyK7Aj1wjJOJZE+pQ4nIRbeFhsr/vVxeLWDggWpykxm6AaYCQh 7JQPfaQfLMwzbmtRHS1vafn/EqNgPk/swT6j9iHFgz2seztJ5Fs0Jpc1BJ1Gfj7bMd6J 6/WTogsNdQeqCqPkKoy//O2/o4EilLozeRAF+DbUlQE7x9zC2U6Ar8oO+9SoLZte74b8 1nvWvE8PIYXEDypIu/46sTLz/42+ZjvLTbgYrrbKmLNeVE9GmnEQNBrDSSFPyWpInFzY UIQg== X-Gm-Message-State: APjAAAVq9RowHnLZ58/nTBJ0MIQV9fTahRIfjOp/PHgaT3f18RNmm9Mp DlcbLSWD+u6U0izBlosfXw== X-Google-Smtp-Source: APXvYqzuOOI5O9nPE4chqz7q1M50UXLGHgUlkPl19eYyojabF8hEv3WJogI/0IUIWHhrDxD1NedNKw== X-Received: by 2002:a05:6830:1e59:: with SMTP id e25mr36910otj.342.1571256447566; Wed, 16 Oct 2019 13:07:27 -0700 (PDT) Received: from xps15.herring.priv (24-155-109-49.dyn.grandenetworks.net. [24.155.109.49]) by smtp.googlemail.com with ESMTPSA id a9sm7412463oie.7.2019.10.16.13.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 13:07:26 -0700 (PDT) From: Rob Herring To: Andrew Murray , Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Gustavo Pimentel , Heiko Stuebner , Hou Zhiqiang , Jingoo Han , Karthikeyan Mitran , Ley Foon Tan , Linus Walleij , linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, Matthias Brugger , Michal Simek , Ray Jui , rfi@lists.rocketboards.org, Ryder Lee , Scott Branden , Shawn Lin , Simon Horman , Srinath Mannam , Thomas Petazzoni , Toan Le , Tom Joseph , Will Deacon Subject: [PATCH v2 20/25] PCI: ftpci100: Use inbound resources for setup Date: Wed, 16 Oct 2019 15:06:42 -0500 Message-Id: <20191016200647.32050-21-robh@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191016200647.32050-1-robh@kernel.org> References: <20191016200647.32050-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Now that the helpers provide the inbound resources in the host bridge 'dma_ranges' resource list, convert Faraday ftpci100 host bridge to use the resource list to setup the inbound addresses. Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Reviewed-by: Andrew Murray Signed-off-by: Rob Herring Acked-by: Linus Walleij --- drivers/pci/controller/pci-ftpci100.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/drivers/pci/controller/pci-ftpci100.c b/drivers/pci/controller/pci-ftpci100.c index 5824913e311b..e6b498de35e1 100644 --- a/drivers/pci/controller/pci-ftpci100.c +++ b/drivers/pci/controller/pci-ftpci100.c @@ -375,12 +375,11 @@ static int faraday_pci_setup_cascaded_irq(struct faraday_pci *p) return 0; } -static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, - struct device_node *np) +static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p) { - struct of_pci_range range; - struct of_pci_range_parser parser; struct device *dev = p->dev; + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(p); + struct resource_entry *entry; u32 confreg[3] = { FARADAY_PCI_MEM1_BASE_SIZE, FARADAY_PCI_MEM2_BASE_SIZE, @@ -389,19 +388,12 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, int i = 0; u32 val; - if (of_pci_dma_range_parser_init(&parser, np)) { - dev_err(dev, "missing dma-ranges property\n"); - return -EINVAL; - } - - /* - * Get the dma-ranges from the device tree - */ - for_each_of_pci_range(&parser, &range) { - u64 end = range.pci_addr + range.size - 1; + resource_list_for_each_entry(entry, &bridge->dma_ranges) { + u64 pci_addr = entry->res->start - entry->offset; + u64 end = entry->res->end - entry->offset; int ret; - ret = faraday_res_to_memcfg(range.pci_addr, range.size, &val); + ret = faraday_res_to_memcfg(pci_addr, resource_size(entry->res), &val); if (ret) { dev_err(dev, "DMA range %d: illegal MEM resource size\n", i); @@ -409,7 +401,7 @@ static int faraday_pci_parse_map_dma_ranges(struct faraday_pci *p, } dev_info(dev, "DMA MEM%d BASE: 0x%016llx -> 0x%016llx config %08x\n", - i + 1, range.pci_addr, end, val); + i + 1, pci_addr, end, val); if (i <= 2) { faraday_raw_pci_write_config(p, 0, 0, confreg[i], 4, val); @@ -539,7 +531,7 @@ static int faraday_pci_probe(struct platform_device *pdev) cur_bus_speed = PCI_SPEED_66MHz; } - ret = faraday_pci_parse_map_dma_ranges(p, dev->of_node); + ret = faraday_pci_parse_map_dma_ranges(p); if (ret) return ret;