From patchwork Tue Mar 5 03:25:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1051601 X-Patchwork-Delegate: sjg@chromium.org 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="dEH/D/Wn"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44D2Pd061Mz9sB3 for ; Tue, 5 Mar 2019 14:26:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9C0FDC21D74; Tue, 5 Mar 2019 03:26:55 +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 40441C21C3F; Tue, 5 Mar 2019 03:26:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7540EC21D83; Tue, 5 Mar 2019 03:26:15 +0000 (UTC) Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by lists.denx.de (Postfix) with ESMTPS id 571C2C21D56 for ; Tue, 5 Mar 2019 03:26:11 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id q1so7793642wrp.7 for ; Mon, 04 Mar 2019 19:26:11 -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:mime-version :content-transfer-encoding; bh=lh5RepVR3/Y+hEmzhuxTZCNUN6WuP5g9jaz5oP2TSAU=; b=dEH/D/WnxB/cHJSKU8hGSmDjxvX9UCX9WGQQtmXm17LAEh1h1c+++hX8DsAa67cyt2 uAu/U5PkmD5v4pu4Fgr2GEjCPaw084IiWWbOublgBMUxUpXxlsr6xhvanZxiIGUB/Z3Y +Hdka1x0zy5g3MRKbo9bsby8Wb2ICxhIn9jPc4DiGDIEEplL88gXJCGUBpm1TBKFBIzr SryxuWjdAeX8riMo3cwWDqIVXWfNR0cEJjphyUw1hf5egE4qXMbJmfwGJcLj3Jwqivd2 5LatyF5dKtDRRjaR0Mjb9++deLi/GZC96eHaiVx3yIIs2BOzOnKvX5nU48yLJsmAM8IH x2KA== 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=lh5RepVR3/Y+hEmzhuxTZCNUN6WuP5g9jaz5oP2TSAU=; b=Qulr4YUDjLhtbpPzNocUgZH5+n6eYlv6/phGGt1DTS+dCWP0fHqC6Fjmt6GRHWH5rs iJREhU9IokMgqZwF4GphaXkwhd+0jucXDrXnM36+1xyig72LEJ4aR6ytwhiaQM2oa1Wx buy/TZIu5t5mVZ1Ks9Gyk7OEthmPm4WTtZA+ckcNi24CWb0KcSpqCuH+WfeFeA41H2NH J3KW07GcWSeyVnBgyfcO103XH+JM/aue5VHb/XsFl1a2m5WdL6o0MwPRivKaev/0Bhzq SDLjKODXiJpFc+fEjj/KMtvqjr5UQ0GITZIsrtfU2qtfBUE0lzdA/XKLGFmyZzNg4e3a iDOw== X-Gm-Message-State: APjAAAVlMbZ6li4hRbB8ozD5x4lz2qB8S1zNhlJVxIp5nW4PKTUTBhm5 +uJBjTVmMaapkvHoicE8AKnY3O6R X-Google-Smtp-Source: APXvYqyMS6301+6ovSHrtgafSSiQg/EL4j/metqxNrwDHeEWHz47tuRNCRnWGt1gne+FPpxGL8J3zA== X-Received: by 2002:adf:e8c7:: with SMTP id k7mr15115062wrn.298.1551756369657; Mon, 04 Mar 2019 19:26:09 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 19:26:08 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 5 Mar 2019 04:25:54 +0100 Message-Id: <20190305032557.19788-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Cc: Tom Rini , Nobuhiro Iwamatsu , Marek Vasut Subject: [U-Boot] [PATCH 1/4] lib: fdt: Split fdtdec_setup_mem_size_base() 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" Split fdtdec_setup_mem_size_base() into fdtdec_setup_mem_size_base_fdt(), which allows the caller to pass custom blob into the function and the original fdtdec_setup_mem_size_base(), which uses the gd->fdt_blob. This is useful when configuring the DRAM properties from a FDT blob fragment passed in by the firmware. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu Cc: Simon Glass Cc: Tom Rini Reviewed-by: Simon Glass --- include/fdtdec.h | 20 ++++++++++++++++++++ lib/fdtdec.c | 11 ++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index b7e35cd87c..3e681099a8 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -917,6 +917,26 @@ struct display_timing { int fdtdec_decode_display_timing(const void *blob, int node, int index, struct display_timing *config); +/** + * fdtdec_setup_mem_size_base_fdt() - decode and setup gd->ram_size and + * gd->ram_start + * + * Decode the /memory 'reg' property to determine the size and start of the + * first memory bank, populate the global data with the size and start of the + * first bank of memory. + * + * This function should be called from a boards dram_init(). This helper + * function allows for boards to query the device tree for DRAM size and start + * address instead of hard coding the value in the case where the memory size + * and start address cannot be detected automatically. + * + * @param blob FDT blob + * + * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or + * invalid + */ +int fdtdec_setup_mem_size_base_fdt(const void *blob); + /** * fdtdec_setup_mem_size_base() - decode and setup gd->ram_size and * gd->ram_start diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 09a7e133a5..3f29e9d647 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1088,18 +1088,18 @@ int fdtdec_decode_display_timing(const void *blob, int parent, int index, return ret; } -int fdtdec_setup_mem_size_base(void) +int fdtdec_setup_mem_size_base_fdt(const void *blob) { int ret, mem; struct fdt_resource res; - mem = fdt_path_offset(gd->fdt_blob, "/memory"); + mem = fdt_path_offset(blob, "/memory"); if (mem < 0) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", 0, &res); + ret = fdt_get_resource(blob, mem, "reg", 0, &res); if (ret != 0) { debug("%s: Unable to decode first memory bank\n", __func__); return -EINVAL; @@ -1113,6 +1113,11 @@ int fdtdec_setup_mem_size_base(void) return 0; } +int fdtdec_setup_mem_size_base(void) +{ + return fdtdec_setup_mem_size_base_fdt(gd->fdt_blob); +} + #if defined(CONFIG_NR_DRAM_BANKS) static int get_next_memory_node(const void *blob, int mem) From patchwork Tue Mar 5 03:25:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1051602 X-Patchwork-Delegate: sjg@chromium.org 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="p9JgeY0+"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44D2VV3rpHz9sB3 for ; Tue, 5 Mar 2019 14:31:14 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3573FC21E0D; Tue, 5 Mar 2019 03:31:12 +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 8B77DC21D8E; Tue, 5 Mar 2019 03:26:16 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7F83EC21C3F; Tue, 5 Mar 2019 03:26:15 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id 60346C21C3F for ; Tue, 5 Mar 2019 03:26:11 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id w2so7764043wrt.11 for ; Mon, 04 Mar 2019 19:26:11 -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=rxHnHA3ZEiZKPM4Us3JqA1cvxcVG7jBR9Q2eTlLxy3A=; b=p9JgeY0+oQseYu7h94ZDXZI0uvNMQYUAz+MLeiJUAM1Wok1hLDyUo2OILHJsyd1WXR Ce/GWF3hZc0pOYL4Qu+sQnGyDsfGbNk9kFlUPgXKZ5DVEyBfDOGM6ero9rXglFkwVyAy JhnbIqv5FfPw0DDJmhBsEZeX6NXKhSawC3w1tYsRg/2uXmdL2VF/5digm0LWJtqKpq0K ZMNWLrYguO9/9qeyvh8xi4gO3FtdcOjG2U502x4LANAJoYn/xlKdVJtWIQCrJUzvy3oO NiNGltnLwZbJAaoB39dEuhyT2G7SzPe16uRchFxUajU8ao/uxHkN3qmkXLtN3abXo9Af jfMg== 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=rxHnHA3ZEiZKPM4Us3JqA1cvxcVG7jBR9Q2eTlLxy3A=; b=rKjblaE9TvLFnX0TUCB2i9Pzlw6yGUSPzgExNl9vWJOiY6WeN+EkDHAcijG5ZXPn0e wU93f5DitLCd1PlFr8TW8/i25InNKSebrJdSEMdDWvwbHuqJkqtwx5OR8pdKbtCOmStF okwnN9mnO0YKEqNCPZJHHqE90g29i5m1Yynt+B1OOTX+0ThfjY9Uv6tytnoKDhowZ5if l367K1JRilJcSFh0ni2abHZspaxvA/jmhI96Rz0QB/CKL7Vo7eKuX8Z8s5PLh+K+naTi swFuKCHBh1Ghd+ziKyHymiBkbXsq8MAzac6aosXMhsMvqdcMeevhef1yE+h+V3zilupA sVqQ== X-Gm-Message-State: APjAAAV5WbfmYMQDLeU7eDzbVqQEQgNLndhIDhCLDqDLLEuqo+HXTrVI mkJOx/CsbsygvzhEcxy909Om+TmR X-Google-Smtp-Source: APXvYqznvWDs/0hCtOFw36+ShuityWQmcyJXNkazoHqqkSrqF45TplYA/bnQuEkCflAqFQa1g2979w== X-Received: by 2002:adf:cc83:: with SMTP id p3mr14456908wrj.292.1551756370704; Mon, 04 Mar 2019 19:26:10 -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.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 19:26:10 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 5 Mar 2019 04:25:55 +0100 Message-Id: <20190305032557.19788-2-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: Tom Rini , Nobuhiro Iwamatsu , Marek Vasut Subject: [U-Boot] [PATCH 2/4] lib: fdt: Split fdtdec_setup_memory_banksize() 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" Split fdtdec_setup_memory_banksize() into fdtdec_setup_memory_banksize_fdt(), which allows the caller to pass custom blob into the function and the original fdtdec_setup_memory_banksize(), which uses the gd->fdt_blob. This is useful when configuring the DRAM properties from a FDT blob fragment passed in by the firmware. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu Cc: Simon Glass Cc: Tom Rini Reviewed-by: Simon Glass --- include/fdtdec.h | 19 +++++++++++++++++++ lib/fdtdec.c | 18 ++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 3e681099a8..ad00f79f20 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -955,6 +955,25 @@ int fdtdec_setup_mem_size_base_fdt(const void *blob); */ int fdtdec_setup_mem_size_base(void); +/** + * fdtdec_setup_memory_banksize_fdt() - decode and populate gd->bd->bi_dram + * + * Decode the /memory 'reg' property to determine the address and size of the + * memory banks. Use this data to populate the global data board info with the + * phys address and size of memory banks. + * + * This function should be called from a boards dram_init_banksize(). This + * helper function allows for boards to query the device tree for memory bank + * information instead of hard coding the information in cases where it cannot + * be detected automatically. + * + * @param blob FDT blob + * + * @return 0 if OK, -EINVAL if the /memory node or reg property is missing or + * invalid + */ +int fdtdec_setup_memory_banksize_fdt(const void *blob); + /** * fdtdec_setup_memory_banksize() - decode and populate gd->bd->bi_dram * diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 3f29e9d647..79915b59bd 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1123,33 +1123,33 @@ int fdtdec_setup_mem_size_base(void) static int get_next_memory_node(const void *blob, int mem) { do { - mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem, + mem = fdt_node_offset_by_prop_value(blob, mem, "device_type", "memory", 7); } while (!fdtdec_get_is_enabled(blob, mem)); return mem; } -int fdtdec_setup_memory_banksize(void) +int fdtdec_setup_memory_banksize_fdt(const void *blob) { int bank, ret, mem, reg = 0; struct fdt_resource res; - mem = get_next_memory_node(gd->fdt_blob, -1); + mem = get_next_memory_node(blob, -1); if (mem < 0) { debug("%s: Missing /memory node\n", __func__); return -EINVAL; } for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) { - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); + ret = fdt_get_resource(blob, mem, "reg", reg++, &res); if (ret == -FDT_ERR_NOTFOUND) { reg = 0; - mem = get_next_memory_node(gd->fdt_blob, mem); + mem = get_next_memory_node(blob, mem); if (mem == -FDT_ERR_NOTFOUND) break; - ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res); + ret = fdt_get_resource(blob, mem, "reg", reg++, &res); if (ret == -FDT_ERR_NOTFOUND) break; } @@ -1169,6 +1169,12 @@ int fdtdec_setup_memory_banksize(void) return 0; } + +int fdtdec_setup_memory_banksize(void) +{ + return fdtdec_setup_memory_banksize_fdt(gd->fdt_blob); + +} #endif #if CONFIG_IS_ENABLED(MULTI_DTB_FIT) From patchwork Tue Mar 5 03:25:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1051604 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="h3GqTCRc"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 44D2hM1dwNz9s6w for ; Tue, 5 Mar 2019 14:39:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 7B0FDC21E1E; Tue, 5 Mar 2019 03:39:45 +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 217EBC21DDC; Tue, 5 Mar 2019 03:26:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BD4D9C21D4A; Tue, 5 Mar 2019 03:26:20 +0000 (UTC) Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by lists.denx.de (Postfix) with ESMTPS id 7A580C21D4A for ; Tue, 5 Mar 2019 03:26:12 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id o17so7788468wrw.3 for ; Mon, 04 Mar 2019 19:26:12 -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=73GTARQiSs/YKXPPWL7C0Z2IsWcx+h30OZhteaQFJPc=; b=h3GqTCRcOlc37ImthVm6C8Pxq4SImJcjwL7f63L9OZOcl/qowAu2rBMgXS2ckc1HOa y4NG5xnx1fOXe7D5AaPSxcbfjJ4QomEmTj/fC8ewwCW53aag4Ap8BtOXWDZ0MqtBuaQg Z+0ECLHRod85MnHRVkcTXjVRGPd4/1A2X9IWEO+M3VbrPHhYHTcF3t4oXyKuxTvyBL/O olxlja/pP1J5hplEYI7ag2GDFdQ3UHDkl+YwmgWiI9aDY6IwIHaNdoMbtt58qDvMuUx+ SbNmBE6qCBgNdfBkWtQocyvziGofsEiONdOwXSU70ykX4fenFnR4h17URQyQYV6WtZN9 G8tQ== 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=73GTARQiSs/YKXPPWL7C0Z2IsWcx+h30OZhteaQFJPc=; b=dZBoPCQhXp0QqqJ8OqbcNqaf5GC9OFROVdpstIajA7TTfe7XhoSY3Md9FNW96GKXiC fszEXAaEww9j2jF2c/pnxt2cO3vX/kOGpVLrQcIXJeTmRl68LNuESzYioIljXSpLx5em 2g35xSacfB7VfmqoS5RQC21g3z8mmUx9unyQUGtsuT/UvwYR3ZumLAWJCRCDbfYWZL47 TozctPxKVZl52tO6ZYRjTy8KLrTz+UpND2wugPqevAs2JHYSiziegiDojLHkPsu0YIAZ qmSihaQKBrLkrZ2a9Vop/Y1rUgXY+ln2FpRFBBlttj9I1D8w9d8uE9XFN3Y/Y6ayA8xo 8wlw== X-Gm-Message-State: APjAAAX4dJKUvli6nI2BMCjSGi1t4JQeg3HvFELDZzZ5GCBALEi4pU17 3UlQkXH6727uijqUWQzJG+hFBO17 X-Google-Smtp-Source: APXvYqwT6g8CWQtu2XdA8Ot/MQv/lsnLR4gyYp0WSg/j8eTuoG3mbgWCvNQMma4/0jAwAT1Ig+FWOw== X-Received: by 2002:adf:f391:: with SMTP id m17mr13792320wro.137.1551756371797; Mon, 04 Mar 2019 19:26:11 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 19:26:11 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: u-boot@lists.denx.de Date: Tue, 5 Mar 2019 04:25:56 +0100 Message-Id: <20190305032557.19788-3-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 3/4] ARM: renesas: Save boot parameters passed in by ATF 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. Save these registers for future use. Signed-off-by: Marek Vasut Cc: Nobuhiro Iwamatsu --- arch/arm/mach-rmobile/lowlevel_init_gen3.S | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm/mach-rmobile/lowlevel_init_gen3.S b/arch/arm/mach-rmobile/lowlevel_init_gen3.S index f42b53fd88..213ec143e2 100644 --- a/arch/arm/mach-rmobile/lowlevel_init_gen3.S +++ b/arch/arm/mach-rmobile/lowlevel_init_gen3.S @@ -16,6 +16,21 @@ #include #include +.align 8 +.globl rcar_atf_boot_args +rcar_atf_boot_args: + .dword 0 + .dword 0 + .dword 0 + .dword 0 + +ENTRY(save_boot_params) + adr x8, rcar_atf_boot_args + stp x0, x1, [x8], #16 + stp x2, x3, [x8], #16 + b save_boot_params_ret +ENDPROC(save_boot_params) + ENTRY(lowlevel_init) mov x29, lr /* Save LR */ 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; }