From patchwork Sat Apr 20 18:42:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 238161 X-Patchwork-Delegate: sjg@chromium.org 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 DAB2C2C014C for ; Sun, 21 Apr 2013 04:44:53 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AFB9E4A468; Sat, 20 Apr 2013 20:44:26 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 e8qP053Yv2KU; Sat, 20 Apr 2013 20:44:26 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9A1F54A431; Sat, 20 Apr 2013 20:43:52 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C40734A365 for ; Sat, 20 Apr 2013 20:43:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 ViVf-8dIvl+y for ; Sat, 20 Apr 2013 20:43:36 +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-gh0-f201.google.com (mail-gh0-f201.google.com [209.85.160.201]) by theia.denx.de (Postfix) with ESMTPS id 6EB884A3B4 for ; Sat, 20 Apr 2013 20:43:18 +0200 (CEST) Received: by mail-gh0-f201.google.com with SMTP id r13so437211ghr.0 for ; Sat, 20 Apr 2013 11:43:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=XBOxp9UzpheupcDE3n1GisOM9rGp8y3C6BLhQXFC/ao=; b=K9NytrTYMPy/5kc/tnPXS6H9W1xG4vPzqAMLoxU4bdb8rzECi6+RkVRClj7ZGLQK6b bqQCxYwGPgmahOxrdX6ckhK8GY9kJbqrkduOVyiYkDXi0nKVrdzQlh4ZIrV+97yHC9VK hg3NIcnuAikQKFpM7eQI5sqfsijmZKQB8ScaM6K1MviXHEo2OB1+JMTKbFIYPNG9pi4D 7CYSipB75tS9gHhc3nKFAiaD54Ue44gLFtPk9ZbafYEldqEax2Vsw51m9ZO24qKYRRra FpBFpYAaqCOQfBWPGU6pPiv2Wl9ionxvBnyoN3AS0rkWBi0y9TQQe5Eqj6exH0LPJ0uk rkyg== X-Received: by 10.236.41.137 with SMTP id h9mr4846281yhb.43.1366483395515; Sat, 20 Apr 2013 11:43:15 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id s80si4201396yhe.6.2013.04.20.11.43.15 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sat, 20 Apr 2013 11:43:15 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 5B03C31C27C; Sat, 20 Apr 2013 11:43:15 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 3A1761605A1; Sat, 20 Apr 2013 11:43:15 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 20 Apr 2013 11:42:44 -0700 Message-Id: <1366483372-16523-10-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1366483372-16523-1-git-send-email-sjg@chromium.org> References: <1366483372-16523-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQm6KyhCMBZsbp5aoYJoW/nfxHpvg035QwI9NK0GjbKJ4y5nK5S5idWZhSm15P0oRbxL/WYcRHS72E07yHc6nr6RGXRAxzZ2G6scfm71Y5KOyu1fk3V0ETVKmPjwkvX//0MKBGGp8usadioVp9wk/biR8oJxCrS2YAcirtiJhARH0EgXnbzRvZjhmCHzfCJs9YAsws8B Cc: Tom Rini , u-boot-review@google.com, Jerry Van Baren Subject: [U-Boot] [PATCH v3 09/17] fdt: Allow fdt command to check and update control FDT X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de There is an existing fdt command to deal with the working FDT. Enhance this to support the control FDT also (CONFIG_OF_CONTROL). Signed-off-by: Simon Glass Acked-by: Gerald Van Baren --- Changes in v3: - Remove #ifdefs which are not needed now that we have generic global_data Changes in v2: - Correct bug in setting control FDT - Fix checkpatch checks about parenthesis alignment common/cmd_fdt.c | 47 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 07072f3..e582961 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -100,38 +100,59 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) */ if (argv[1][0] == 'a') { unsigned long addr; + int control = 0; + struct fdt_header *blob; /* * Set the address [and length] of the fdt. */ - if (argc == 2) { - if (!fdt_valid(&working_fdt)) + argc -= 2; + argv += 2; +/* Temporary #ifdef - some archs don't have fdt_blob yet */ +#ifdef CONFIG_OF_CONTROL + if (argc && !strcmp(*argv, "-c")) { + control = 1; + argc--; + argv++; + } +#endif + if (argc == 0) { + if (control) + blob = (struct fdt_header *)gd->fdt_blob; + else + blob = working_fdt; + if (!blob || !fdt_valid(&blob)) return 1; - printf("The address of the fdt is %p\n", working_fdt); + printf("The address of the fdt is %#08lx\n", + control ? (ulong)blob : + getenv_hex("fdtaddr", 0)); return 0; } - addr = simple_strtoul(argv[2], NULL, 16); - set_working_fdt_addr((void *)addr); - - if (!fdt_valid(&working_fdt)) + addr = simple_strtoul(argv[0], NULL, 16); + blob = (struct fdt_header *)addr; + if (!fdt_valid(&blob)) return 1; + if (control) + gd->fdt_blob = blob; + else + set_working_fdt_addr((void *)addr); - if (argc >= 4) { + if (argc >= 2) { int len; int err; /* * Optional new length */ - len = simple_strtoul(argv[3], NULL, 16); - if (len < fdt_totalsize(working_fdt)) { + len = simple_strtoul(argv[1], NULL, 16); + if (len < fdt_totalsize(blob)) { printf ("New length %d < existing length %d, " "ignoring.\n", - len, fdt_totalsize(working_fdt)); + len, fdt_totalsize(blob)); } else { /* * Open in place with a new length. */ - err = fdt_open_into(working_fdt, working_fdt, len); + err = fdt_open_into(blob, blob, len); if (err != 0) { printf ("libfdt fdt_open_into(): %s\n", fdt_strerror(err)); @@ -960,7 +981,7 @@ static int fdt_print(const char *pathp, char *prop, int depth) /********************************************************************/ #ifdef CONFIG_SYS_LONGHELP static char fdt_help_text[] = - "addr [] - Set the fdt location to \n" + "addr [-c] [] - Set the [control] fdt location to \n" #ifdef CONFIG_OF_BOARD_SETUP "fdt boardsetup - Do board-specific set up\n" #endif