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)