From patchwork Fri Jun 24 14:27:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 640239 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rbgj14CBvz9sDC for ; Sat, 25 Jun 2016 00:30:13 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5D8E7A7548; Fri, 24 Jun 2016 16:29:34 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LelO4YHbpxVR; Fri, 24 Jun 2016 16:29:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E7FE9A7514; Fri, 24 Jun 2016 16:28:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 19EAC4B853 for ; Fri, 24 Jun 2016 16:28:32 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 28yppyHYCgtQ for ; Fri, 24 Jun 2016 16:28:32 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.free-electrons.com (down.free-electrons.com [37.187.137.238]) by theia.denx.de (Postfix) with ESMTP id 477034BA35 for ; Fri, 24 Jun 2016 16:28:21 +0200 (CEST) Received: by mail.free-electrons.com (Postfix, from userid 110) id B0785182C; Fri, 24 Jun 2016 16:28:20 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 02D681830; Fri, 24 Jun 2016 16:28:02 +0200 (CEST) From: Maxime Ripard To: Pantelis Antoniou , Simon Glass Date: Fri, 24 Jun 2016 16:27:56 +0200 Message-Id: <20160624142757.32735-12-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160624142757.32735-1-maxime.ripard@free-electrons.com> References: <20160624142757.32735-1-maxime.ripard@free-electrons.com> Cc: Thomas Petazzoni , Tom Rini , u-boot@lists.denx.de, Alexander Kaplan , devicetree-compiler@vger.kernel.org Subject: [U-Boot] [PATCH v3 11/12] cmd: fdt: add fdt overlay application subcommand X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The device tree overlays are a good way to deal with user-modifyable boards or boards with some kind of an expansion mechanism where we can easily plug new board in (like the BBB or the raspberry pi). However, so far, the usual mechanism to deal with it was to have in Linux some driver detecting the expansion boards plugged in and then request these overlays using the firmware interface. That works in most cases, but in some cases, you might want to have the overlays applied before the userspace comes in. Either because the new board requires some kind of an early initialization, or because your root filesystem is accessed through that expansion board. The easiest solution in such a case is to simply have the component before Linux applying that overlay, removing all these drawbacks. Reviewed-by: Stefan Agner Acked-by: Pantelis Antoniou Acked-by: Simon Glass Signed-off-by: Maxime Ripard --- cmd/fdt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cmd/fdt.c b/cmd/fdt.c index 0f5923e75a41..58af7727ba08 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -639,6 +639,27 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif } +#ifdef CONFIG_OF_LIBFDT_OVERLAY + /* apply an overlay */ + else if (strncmp(argv[1], "ap", 2) == 0) { + unsigned long addr; + struct fdt_header *blob; + + if (argc != 3) + return CMD_RET_USAGE; + + if (!working_fdt) + return CMD_RET_FAILURE; + + addr = simple_strtoul(argv[2], NULL, 16); + blob = map_sysmem(addr, 0); + if (!fdt_valid(&blob)) + return CMD_RET_FAILURE; + + if (fdt_overlay_apply(working_fdt, blob)) + return CMD_RET_FAILURE; + } +#endif /* resize the fdt */ else if (strncmp(argv[1], "re", 2) == 0) { fdt_shrink_to_minimum(working_fdt); @@ -1025,6 +1046,9 @@ static int fdt_print(const char *pathp, char *prop, int depth) #ifdef CONFIG_SYS_LONGHELP static char fdt_help_text[] = "addr [-c] [] - Set the [control] fdt location to \n" +#ifdef CONFIG_OF_LIBFDT_OVERLAY + "fdt apply - Apply overlay to the DT\n" +#endif #ifdef CONFIG_OF_BOARD_SETUP "fdt boardsetup - Do board-specific set up\n" #endif