From patchwork Tue Jul 9 00:02:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1129432 X-Patchwork-Delegate: marek.vasut@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="AU1PQDG+"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45jMyd3D1Rz9sN4 for ; Tue, 9 Jul 2019 10:05:13 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 28E92C21DF8; Tue, 9 Jul 2019 00:05:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 79776C21C3F; Tue, 9 Jul 2019 00:05:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4F2E5C21C4A; Tue, 9 Jul 2019 00:05:04 +0000 (UTC) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by lists.denx.de (Postfix) with ESMTPS id 8B714C21C3F for ; Tue, 9 Jul 2019 00:05:03 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id a10so17884424wrp.9 for ; Mon, 08 Jul 2019 17:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5TWNAlFjWGbKxJyHTeDol1Hbblf9MnvQer7zr2/f17Y=; b=AU1PQDG+gBG9hgC+hWyq1S9F8o7M2A1+8GZuE9hKZPJ9oEhqo+AHlVbWi55FFf+IBO fkMuUmFZXfVG/NsZbPLnBtGWTWDmihbgzqaILQpGp50AcpSkodLMP3T5RKL3BKuBe6Jg PhkZjFfwRsuNSDNnQc+64vyKg/kR1iUdJAv9IS7vOiqLt2QSoE6QujN9g0WWLcRNeafx h9F5H4aLuJOaegidjbY78palqJsli4OuHEfyrzfhAZBjrHc/Z2B+owpNsV8qTEEQWCce xQp2JzVPRBky1lAjrqKz+ahc7C1I9wypGrJjNFM/9tyBdo5LqPUDHsUTyKVIxS5Xi28y ojFA== 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:mime-version :content-transfer-encoding; bh=5TWNAlFjWGbKxJyHTeDol1Hbblf9MnvQer7zr2/f17Y=; b=MPgrpWVKH6nFG4zP9VYr6xe+UEpJCT9sKl65lA2HUDJ+2OgkFDhWm3KTAOfx0kEOCj xpYMwvhOtIb5j0faden12ZtTLOQHidUV03Q0nFgiX9Ihs1HCKhLVISofiVXxQFKdmTRM vIQDk/vmKCnj4cc+r5To0enG7zpy3Ew2OPnq6UnVkTCtliZ4b591mZu20BrptPbV2Ys+ uP8pbhwaqRpIQ6rpbeV7a72xqwk91iu6KFq4cPH+4sz05anIsNenpoxij24S6EtMD5sx ojjarfUlGAmA9UO3L4fk0Kb0bDcYGd09XhPDM8wWJfSEoTWGdyFg/hsUStcFGxD3ClvE /3ww== X-Gm-Message-State: APjAAAWI4bUaClW7bcMkYOPncoOPV2/wKfxxP5nM/waxVDpQWVrSVneF wBUrbMKu0GV1bpyh0E7fN/N/Q1DB X-Google-Smtp-Source: APXvYqwvqkvkrbfvCn+DBmT4KPZ/gBWHof1gneRDXC6QWggFVT6KvDc4NTyQUQBIF/JzFILC8XbSPQ== X-Received: by 2002:a5d:4e8a:: with SMTP id e10mr2314663wru.26.1562630702796; Mon, 08 Jul 2019 17:05:02 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id p3sm869107wmg.15.2019.07.08.17.05.01 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 17:05:01 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 9 Jul 2019 02:02:45 +0200 Message-Id: <20190709000245.10802-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: Nobuhiro Iwamatsu , Marek Vasut Subject: [U-Boot] [PATCH] ARM: renesas: Update Gen3 PCIe dma-ranges before boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" Update "dma-ranges" DT property of all PCIe controllers in the system with the up-to-date DRAM layout. This allows the PCIe controller take full advantage of all the available DRAM, at least in theory. This patch only populates up to two dma-ranges entry though, this is because older versions of Linux kernel would fail to probe the PCIe driver if there are more regions in the DT than the PCIe IP can use. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu --- arch/arm/mach-rmobile/Kconfig | 1 + board/renesas/rcar-common/common.c | 53 ++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/arch/arm/mach-rmobile/Kconfig b/arch/arm/mach-rmobile/Kconfig index aafeb355ef..52ab891425 100644 --- a/arch/arm/mach-rmobile/Kconfig +++ b/arch/arm/mach-rmobile/Kconfig @@ -21,6 +21,7 @@ config RCAR_GEN3 imply CMD_GPT imply CMD_UUID imply CMD_MMC_SWRITE if MMC + imply OF_BOARD_SETUP if PCI imply SUPPORT_EMMC_RPMB if MMC imply SPL imply SPL_BOARD_INIT diff --git a/board/renesas/rcar-common/common.c b/board/renesas/rcar-common/common.c index 292867e496..17127d4124 100644 --- a/board/renesas/rcar-common/common.c +++ b/board/renesas/rcar-common/common.c @@ -8,6 +8,8 @@ */ #include +#include +#include #include #ifdef CONFIG_RCAR_GEN3 @@ -46,4 +48,55 @@ int dram_init_banksize(void) return 0; } + +#if CONFIG_IS_ENABLED(OF_BOARD_SETUP) && CONFIG_IS_ENABLED(PCI) +int ft_board_setup(void *blob, bd_t *bd) +{ + struct udevice *dev; + struct uclass *uc; + fdt_addr_t regs_addr; + int i, off, ret; + + ret = uclass_get(UCLASS_PCI, &uc); + if (ret) + return ret; + + uclass_foreach_dev(dev, uc) { + struct pci_controller hose = { 0 }; + + /* + * Limit the number of memory regions to 2, which is the + * maximum that older Linux kernel versions can handle + * without aborting. + */ + for (i = 0; i < min(CONFIG_NR_DRAM_BANKS, 2); i++) { + if (hose.region_count == MAX_PCI_REGIONS) { + printf("maximum number of regions parsed, aborting\n"); + break; + } + + if (bd->bi_dram[i].size) { + pci_set_region(&hose.regions[hose.region_count++], + bd->bi_dram[i].start, + bd->bi_dram[i].start, + bd->bi_dram[i].size, + PCI_REGION_MEM | + PCI_REGION_SYS_MEMORY); + } + } + + regs_addr = devfdt_get_addr_index(dev, 0); + off = fdt_node_offset_by_compat_reg(blob, + "renesas,pcie-rcar-gen3", regs_addr); + if (off < 0) { + printf("Failed to find PCIe node@%llx\n", regs_addr); + return off; + } + + fdt_pci_dma_ranges(blob, off, &hose); + } + + return 0; +} +#endif #endif