From patchwork Sat Jan 5 01:51:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 209617 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 8A46C2C008D for ; Sat, 5 Jan 2013 13:00:22 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AB1294A0FC; Sat, 5 Jan 2013 02:59:42 +0100 (CET) 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 Qyi47Be4PcVr; Sat, 5 Jan 2013 02:59:42 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 92AC24A119; Sat, 5 Jan 2013 02:57:16 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A6C804A0F6 for ; Sat, 5 Jan 2013 02:56:59 +0100 (CET) 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 yZ1-DfFZP-ub for ; Sat, 5 Jan 2013 02:56:58 +0100 (CET) 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-ee0-f73.google.com (mail-ee0-f73.google.com [74.125.83.73]) by theia.denx.de (Postfix) with ESMTPS id 774CA4A030 for ; Sat, 5 Jan 2013 02:56:38 +0100 (CET) Received: by mail-ee0-f73.google.com with SMTP id c50so1065273eek.4 for ; Fri, 04 Jan 2013 17:56:38 -0800 (PST) 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=opwhVVZrUmNiF5jhB4+I/20O3feQM4dmvlAAUY8BUeM=; b=gbrrDQUC07k55AlKLTfmrFDcHzhqR5RQFLnpUM39h1gIUVNPvPRDXsNQcXAibPGJp1 0ScZru4C27N5YDACsAninnJzy5Ze2VaqvqN4F8bHp6USTmrF5xPvr/wDsYf1p8IaAXCt ncZRPlIbP5sppNXC5LcXU+vjGvb2nCsDdw242lnKnPDAJ6qCeN59nU5KBKjpxCYCZEsx 1rLjAALt7Pjd0MZBNu9A6r1sgssObsR5Yj0mMF2bpORPUGCO3EFYKUrrNDdYLhz2xrfg OfRhsFWltFLGL7rl+ADVFoprI0kNEvtIUHREOZhiu63KsDXF9L4Jyy/FareU7hBVkE0O 26Kg== X-Received: by 10.14.205.194 with SMTP id j42mr69203342eeo.2.1357350998030; Fri, 04 Jan 2013 17:56:38 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id z44si19167123een.0.2013.01.04.17.56.37 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 04 Jan 2013 17:56:38 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 8A87F200059; Fri, 4 Jan 2013 17:56:37 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 48EF0160DA0; Fri, 4 Jan 2013 17:56:37 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Fri, 4 Jan 2013 17:51:49 -0800 Message-Id: <1357350734-13737-21-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1357350734-13737-1-git-send-email-sjg@chromium.org> References: <1357350734-13737-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQmttfjWAUH5wUk24+YwD4B+frnUoh9Qdb3a6H8yA6sqgPlZzllWtG6zfYUMaPHxF73OPWCQ4UbaEni/BjgkwS56V7T1q8J/mXB9BSJ4Cx1fg7/99CDbuaVUZ+0IlewUUsDQsmU/4tHIq2As/HPQmK9hcjltZNQQ1vTlFt4J9BmyfYT5GLg80cAnmC3hbDjmvDUmiIN0 Cc: Joel A Fernandes , Jerry Van Baren , Tom Rini , Vadim Bendebury , =?UTF-8?q?Andreas=20B=C3=A4ck?= Subject: [U-Boot] [RFC PATCH 20/44] 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). Some nasty #ifdefs are added here - they are required until we move to generic board and every arch has an fdt_blob. Signed-off-by: Simon Glass --- common/cmd_fdt.c | 58 ++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 41 insertions(+), 17 deletions(-) diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 0adebf1..a193cc3 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -101,42 +101,66 @@ 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; + void *blob; /* * Set the address [and length] of the fdt. */ - if (argc == 2) { - if (!fdt_valid(working_fdt)) { - working_fdt = NULL; + 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) { +#ifdef CONFIG_OF_CONTROL + if (control) + blob = (void *)gd->fdt_blob; + else +#endif + 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)) { - working_fdt = NULL; - return 1; + addr = simple_strtoul(argv[0], NULL, 16); + blob = (void *)addr; + if (control) { +#ifdef CONFIG_OF_CONTROL + if (!fdt_valid(gd->fdt_blob)) + return 1; + gd->fdt_blob = blob; +#endif + } else { + if (!fdt_valid(blob)) + return 1; + 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 +984,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