From patchwork Tue Mar 5 03:25:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1051603 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="bOsk9hiy"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44D2bQ15Ntz9s4V for ; Tue, 5 Mar 2019 14:35:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CFF02C21DCA; Tue, 5 Mar 2019 03:35:28 +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, 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 D5B17C21DD3; Tue, 5 Mar 2019 03:26:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A8DA5C21DB6; Tue, 5 Mar 2019 03:26:20 +0000 (UTC) Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) by lists.denx.de (Postfix) with ESMTPS id A0460C21D74 for ; Tue, 5 Mar 2019 03:26:13 +0000 (UTC) Received: by mail-wr1-f52.google.com with SMTP id q1so7793690wrp.7 for ; Mon, 04 Mar 2019 19:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KgHVW+cXxLSrZd1UzZwp/Ukbl1CSVRXwolIKeqDBl5k=; b=bOsk9hiyU3GEdLTNpPF0uYu770pk4RDom8S+s0V0WlnHbxVdKaAFtyBzvUTm2UrWsf 6GmTOSXBDAAElrfcNR5wUnb2s4RpcjrV7WfRKjFVZ/eZ7pg77oXe1TndDr51/dMWODul MaNQcB65pgHgQPp9HdfRkbrpkCl1zfvqsKM2mvhQDynwFrReUkcmSNm98S0+yu/9Fh0p u7xQoCZ9aMUbvjAETYjvjKbVV7jkk6aF5u/jibDKjKktezqxsPMIE81L88Pwe7R6/dOY s23uqMXeQusNsdPB+H3dyVGTmj2zyn08YkPER2259DjjYD5K+LVqdpVbe3rToPnPbY5n 3C4Q== 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=KgHVW+cXxLSrZd1UzZwp/Ukbl1CSVRXwolIKeqDBl5k=; b=X0gKb/q3cr17UkNIzEHCRsJlQQXMQ38jV2VANARA7edQGEbDVdFYG7dl1Y0O3z+wmR KjeHfg079b0eOYsDZm71nFFH3qnNub2K+hGMM/slyNvr1AxUKkrXrm7RHO/NFwemY9Xk O7Fk9YQc2igZXuXhoo/czlsUiTqK/dRt65FzSfTAm9XFXOIhD78OfbI0IowTVc4c5BWN 1cBBwEbEPLV8PKmTa8U0LWNSHzgn4Hw+JxXRxBU0zQPtlzCHoMtX6uMo2sbUU5f9OLgC oiZIn3NN+cpYjeJD5D9nuwciVxyIFEV9s8Q5+BaF6+V3e5tV1/bD/xPrx03ng/cdYVO+ 2BEw== X-Gm-Message-State: APjAAAUZWIvdLo8zhUll7WyS+xBNqu1tluqM/Li+I3fyKelQXc/KBSgD QocKz7xx630w+XNNBGq4bpCUBigl X-Google-Smtp-Source: APXvYqwYnw+JNufcMwksD91NcMY6QEYhTvNGlh+9M2KyuFN1mYhD7LlQu5eeEid0Ife+UToFExw/pg== X-Received: by 2002:adf:9361:: with SMTP id 88mr7513935wro.152.1551756372934; Mon, 04 Mar 2019 19:26:12 -0800 (PST) Received: from kurokawa.lan (ip-86-49-110-70.net.upcbroadband.cz. [86.49.110.70]) by smtp.gmail.com with ESMTPSA id c18sm16841296wre.88.2019.03.04.19.26.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 19:26:12 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 5 Mar 2019 04:25:57 +0100 Message-Id: <20190305032557.19788-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190305032557.19788-1-marek.vasut+renesas@gmail.com> References: <20190305032557.19788-1-marek.vasut+renesas@gmail.com> MIME-Version: 1.0 Cc: Nobuhiro Iwamatsu , Marek Vasut Subject: [U-Boot] [PATCH 4/4] ARM: renesas: Configure DRAM size from ATF DT fragment 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" The ATF can pass additional information via the first four registers, x0...x3. The R-Car Gen3 with mainline ATF, register x1 contains pointer to a device tree with platform information. Parse this device tree and extract DRAM size information from it. This is useful on systems where the DRAM size can vary between configurations. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu --- board/renesas/ebisu/ebisu.c | 28 +++++++++++++++++++++++---- board/renesas/salvator-x/salvator-x.c | 28 +++++++++++++++++++++++---- board/renesas/ulcb/ulcb.c | 28 +++++++++++++++++++++++---- 3 files changed, 72 insertions(+), 12 deletions(-) diff --git a/board/renesas/ebisu/ebisu.c b/board/renesas/ebisu/ebisu.c index 5d8b79eee3..60429e4529 100644 --- a/board/renesas/ebisu/ebisu.c +++ b/board/renesas/ebisu/ebisu.c @@ -43,17 +43,37 @@ int board_init(void) return 0; } +/* + * If the firmware passed a device tree use it for U-Boot DRAM setup. + */ +extern u64 rcar_atf_boot_args[]; + int dram_init(void) { - if (fdtdec_setup_mem_size_base() != 0) - return -EINVAL; + const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]); + const void *blob; - return 0; + /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */ + if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) + blob = atf_fdt_blob; + else + blob = gd->fdt_blob; + + return fdtdec_setup_mem_size_base_fdt(blob); } int dram_init_banksize(void) { - fdtdec_setup_memory_banksize(); + const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]); + const void *blob; + + /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */ + if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) + blob = atf_fdt_blob; + else + blob = gd->fdt_blob; + + fdtdec_setup_memory_banksize_fdt(blob); return 0; } diff --git a/board/renesas/salvator-x/salvator-x.c b/board/renesas/salvator-x/salvator-x.c index 8f0247e046..1db08fce6a 100644 --- a/board/renesas/salvator-x/salvator-x.c +++ b/board/renesas/salvator-x/salvator-x.c @@ -69,17 +69,37 @@ int board_init(void) return 0; } +/* + * If the firmware passed a device tree use it for U-Boot DRAM setup. + */ +extern u64 rcar_atf_boot_args[]; + int dram_init(void) { - if (fdtdec_setup_mem_size_base() != 0) - return -EINVAL; + const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]); + const void *blob; - return 0; + /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */ + if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) + blob = atf_fdt_blob; + else + blob = gd->fdt_blob; + + return fdtdec_setup_mem_size_base_fdt(blob); } int dram_init_banksize(void) { - fdtdec_setup_memory_banksize(); + const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]); + const void *blob; + + /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */ + if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) + blob = atf_fdt_blob; + else + blob = gd->fdt_blob; + + fdtdec_setup_memory_banksize_fdt(blob); return 0; } diff --git a/board/renesas/ulcb/ulcb.c b/board/renesas/ulcb/ulcb.c index 81d6f8f6f2..3ed7bfaa88 100644 --- a/board/renesas/ulcb/ulcb.c +++ b/board/renesas/ulcb/ulcb.c @@ -68,17 +68,37 @@ int board_init(void) return 0; } +/* + * If the firmware passed a device tree use it for U-Boot DRAM setup. + */ +extern u64 rcar_atf_boot_args[]; + int dram_init(void) { - if (fdtdec_setup_mem_size_base() != 0) - return -EINVAL; + const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]); + const void *blob; - return 0; + /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */ + if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) + blob = atf_fdt_blob; + else + blob = gd->fdt_blob; + + return fdtdec_setup_mem_size_base_fdt(blob); } int dram_init_banksize(void) { - fdtdec_setup_memory_banksize(); + const void *atf_fdt_blob = (const void *)(rcar_atf_boot_args[1]); + const void *blob; + + /* Check if ATF passed us DTB. If not, fall back to builtin DTB. */ + if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) + blob = atf_fdt_blob; + else + blob = gd->fdt_blob; + + fdtdec_setup_memory_banksize_fdt(blob); return 0; }