From patchwork Thu Mar 19 18:40:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fr=C3=A9d=C3=A9ric_Danis?= X-Patchwork-Id: 1258369 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48jwjf5Pxtz9sPF for ; Fri, 20 Mar 2020 05:41:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3119B81750; Thu, 19 Mar 2020 19:41:25 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 5E1AC81662; Thu, 19 Mar 2020 19:41:19 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 13FCE81552 for ; Thu, 19 Mar 2020 19:41:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=frederic.danis@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: fdanis) with ESMTPSA id 620EB2971FA From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_Danis?= To: u-boot@lists.denx.de Cc: trini@konsulko.com, xypron.glpk@gmx.de Subject: [PATCH v4 3/3] cmd: Fixup DT to pass PStore Ramoops parameters Date: Thu, 19 Mar 2020 19:40:24 +0100 Message-Id: <20200319184024.5023-4-frederic.danis@collabora.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200319184024.5023-1-frederic.danis@collabora.com> References: <20200319184024.5023-1-frederic.danis@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean To simplify configuration and keep synchronized the PStore/Ramoops between U-Boot and the Linux kernel, this commit dynamically adds the Ramoops parameters defined in the U-Boot session to the Device Tree. Signed-off-by: Frédéric Danis --- cmd/pstore.c | 38 ++++++++++++++++++++++++++++++++++++++ common/image-fdt.c | 4 ++++ doc/pstore.rst | 2 ++ include/fdt_support.h | 3 +++ 4 files changed, 47 insertions(+) diff --git a/cmd/pstore.c b/cmd/pstore.c index 4e4d70d604..6cad635620 100644 --- a/cmd/pstore.c +++ b/cmd/pstore.c @@ -479,6 +479,44 @@ static int do_pstore(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return c->cmd(cmdtp, flag, argc, argv); } +void fdt_fixup_pstore(void *blob) +{ + char node[32]; + int nodeoffset; /* node offset from libfdt */ + + nodeoffset = fdt_path_offset(blob, "/"); + if (nodeoffset < 0) { + /* Not found or something else bad happened. */ + log_debug("fdt_path_offset() returned %s\n", fdt_strerror(nodeoffset)); + return; + } + + nodeoffset = fdt_add_subnode(blob, nodeoffset, "reserved-memory"); + if (nodeoffset < 0) { + log_debug("Add 'reserved-memory' node failed: %s\n", + fdt_strerror(nodeoffset)); + return; + } + fdt_appendprop_u32(blob, nodeoffset, "#address-cells", 2); + fdt_appendprop_u32(blob, nodeoffset, "#size-cells", 2); + fdt_appendprop(blob, nodeoffset, "ranges", NULL, 0); + + sprintf(node, "ramoops@%llx", (unsigned long long)pstore_addr); + nodeoffset = fdt_add_subnode(blob, nodeoffset, node); + if (nodeoffset < 0) { + log_debug("Add '%s' node failed: %s\n", node, fdt_strerror(nodeoffset)); + return; + } + fdt_appendprop_string(blob, nodeoffset, "compatible", "ramoops"); + fdt_appendprop_u64(blob, nodeoffset, "reg", pstore_addr); + fdt_appendprop_u64(blob, nodeoffset, "reg", pstore_length); + fdt_appendprop_u32(blob, nodeoffset, "record-size", pstore_record_size); + fdt_appendprop_u32(blob, nodeoffset, "console-size", pstore_console_size); + fdt_appendprop_u32(blob, nodeoffset, "ftrace-size", pstore_ftrace_size); + fdt_appendprop_u32(blob, nodeoffset, "pmsg-size", pstore_pmsg_size); + fdt_appendprop_u32(blob, nodeoffset, "ecc-size", pstore_ecc_size); +} + U_BOOT_CMD(pstore, 10, 0, do_pstore, "Manage Linux Persistent Storage", "set [record-size] [console-size] [ftrace-size] [pmsg_size] [ecc-size]\n" diff --git a/common/image-fdt.c b/common/image-fdt.c index 3002948b6b..491d55ad1a 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -547,6 +547,10 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob, } /* Update ethernet nodes */ fdt_fixup_ethernet(blob); +#if CONFIG_IS_ENABLED(CMD_PSTORE) + /* Append PStore configuration */ + fdt_fixup_pstore(blob); +#endif if (IMAGE_OF_BOARD_SETUP) { fdt_ret = ft_board_setup(blob, gd->bd); if (fdt_ret) { diff --git a/doc/pstore.rst b/doc/pstore.rst index 90a8e1c2cb..0038249976 100644 --- a/doc/pstore.rst +++ b/doc/pstore.rst @@ -24,6 +24,8 @@ i.e.:: The same values should be set in U-Boot to be able to retrieve the records. This values can be set at build time in U-Boot configuration file, or at runtime. +U-Boot automatically patches the Device Tree to pass the Ramoops parameters to +the kernel. The PStore configuration parameters are: diff --git a/include/fdt_support.h b/include/fdt_support.h index ba14acd7f6..7afbdcfe37 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -350,4 +350,7 @@ int fdt_update_ethernet_dt(void *blob); #ifdef CONFIG_FSL_MC_ENET void fdt_fixup_board_enet(void *blob); #endif +#ifdef CONFIG_CMD_PSTORE +void fdt_fixup_pstore(void *blob); +#endif #endif /* ifndef __FDT_SUPPORT_H */