From patchwork Sat Oct 15 15:48:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 119978 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 909DBB70C5 for ; Sun, 16 Oct 2011 03:07:08 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4FABE28B0C; Sat, 15 Oct 2011 18:07:04 +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 7f4fyES8HlWs; Sat, 15 Oct 2011 18:07:04 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6ACBF286C5; Sat, 15 Oct 2011 18:06:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D9D472867F for ; Sat, 15 Oct 2011 17:50:14 +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 JgCbKpoOJegW for ; Sat, 15 Oct 2011 17:50:13 +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 smtp-out.google.com (smtp-out.google.com [216.239.44.51]) by theia.denx.de (Postfix) with ESMTPS id 9F69F2866C for ; Sat, 15 Oct 2011 17:50:13 +0200 (CEST) Received: from wpaz29.hot.corp.google.com (wpaz29.hot.corp.google.com [172.24.198.93]) by smtp-out.google.com with ESMTP id p9FFo0eh028391; Sat, 15 Oct 2011 08:50:00 -0700 Received: from sglass.mtv.corp.google.com (sglass.mtv.corp.google.com [172.22.72.144]) by wpaz29.hot.corp.google.com with ESMTP id p9FFnuCA013174; Sat, 15 Oct 2011 08:49:56 -0700 Received: by sglass.mtv.corp.google.com (Postfix, from userid 121222) id 8AE9A140B9B; Sat, 15 Oct 2011 08:49:56 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 15 Oct 2011 08:48:24 -0700 Message-Id: <1318693706-3381-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1318693706-3381-1-git-send-email-sjg@chromium.org> References: <1318693706-3381-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true X-Mailman-Approved-At: Sat, 15 Oct 2011 18:06:52 +0200 Cc: Kumar Gala , Grant Likely , Tom Warren , Aaron Williams Subject: [U-Boot] [PATCH v4 5/6] fdt: ARM: Add fdtcontroladdr to set device tree address in environment X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 This adds support for a new environment variable called 'fdtcontroladdr'. If defined, the hex address is used as the address of the control fdt for U-Boot. Note: I have not changed CONFIG_PRAM section as I already have an outstanding patch on that. Signed-off-by: Simon Glass --- Changes in v3: - Add fdtcontroladdr environment variable README | 4 ++++ arch/arm/lib/board.c | 30 +++++++++++++++++++++++------- doc/README.fdt-control | 12 ++++++++++++ 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/README b/README index fc1cd00..3b1faf9 100644 --- a/README +++ b/README @@ -3493,6 +3493,10 @@ List of environment variables (most likely not complete): add the information it needs into it, and the memory must be accessible by the kernel. + fdtcontroladdr- if set this is the address of the control flattened + device tree used by U-Boot when CONFIG_OF_CONTROL is + defined. + i2cfast - (PPC405GP|PPC405EP only) if set to 'y' configures Linux I2C driver for fast mode (400kHZ). This environment variable is used in diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index b0f3162..f26d77a 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -116,18 +116,31 @@ void blue_led_off(void) __attribute__((weak, alias("__blue_led_off"))); * but let's get it working (again) first... */ +/** + * Decode the value of an environment variable and return it. + * + * @param name Name of environemnt variable + * @param base Number base to use (normally 10, or 16 for hex) + * @param default_val Default value to return if the variable is not + * found + * @return the decoded value, or default_val if not found + */ +static int getenv_int(const char *name, int base, int default_val) +{ + char tmp[64]; /* long enough for environment variables */ + int i = getenv_f(name, tmp, sizeof(tmp)); + + return (i > 0) + ? (int) simple_strtoul(tmp, NULL, base) + : default_val; +} + #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE) #define CONFIG_BAUDRATE 115200 #endif static int init_baudrate(void) { - char tmp[64]; /* long enough for environment variables */ - int i = getenv_f("baudrate", tmp, sizeof(tmp)); - - gd->baudrate = (i > 0) - ? (int) simple_strtoul(tmp, NULL, 10) - : CONFIG_BAUDRATE; - + gd->baudrate = getenv_int("baudrate", 10, CONFIG_BAUDRATE); return (0); } @@ -298,6 +311,9 @@ void board_init_f(ulong bootflag) /* FDT is at end of image */ gd->fdt_blob = (void *)(_end_ofs + _TEXT_BASE); #endif + /* Allow the early environment to override the fdt address */ + gd->fdt_blob = (void *)getenv_int("fdtcontroladdr", 16, + (uintptr_t)gd->fdt_blob); for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { if ((*init_fnc_ptr)() != 0) { diff --git a/doc/README.fdt-control b/doc/README.fdt-control index 3f8bb5a..85bda03 100644 --- a/doc/README.fdt-control +++ b/doc/README.fdt-control @@ -144,6 +144,18 @@ and then flash image.bin onto your board. You cannot use both of these options at the same time. +If you wish to put the fdt at a different address in memory, you can +define the "fdtcontroladdr" environment variable. This is the hex +address of the fdt binary blob, and will override either of the options. +Be aware that this environment variable is checked prior to relocation, +when only the compiled-in environment is available. Therefore it is not +possible to define this variable in the saved SPI/NAND flash +environment, for example (it will be ignored). + +To use this, put something like this in your board header file: + +#define CONFIG_EXTRA_ENV_SETTINGS "fdtcontroladdr=10000\0" + Limitations -----------