From patchwork Sun Jun 5 17:43:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ladislav Michl X-Patchwork-Id: 630456 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 3rN4tf4YNNz9t50 for ; Mon, 6 Jun 2016 03:43:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2794E4BA38; Sun, 5 Jun 2016 19:43:21 +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 1f5knJDoqHDM; Sun, 5 Jun 2016 19:43:20 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6ABFD4B979; Sun, 5 Jun 2016 19:43:20 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5DBBC4B979 for ; Sun, 5 Jun 2016 19:43:17 +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 ihpfj-z_Zteg for ; Sun, 5 Jun 2016 19:43:17 +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 cvs.linux-mips.org (eddie.linux-mips.org [148.251.95.138]) by theia.denx.de (Postfix) with ESMTP id 3076D4B93F for ; Sun, 5 Jun 2016 19:43:12 +0200 (CEST) Received: (from localhost user: 'ladis' uid#1021 fake: STDIN (ladis@eddie.linux-mips.org)) by eddie.linux-mips.org id S27042020AbcFERnM2RuwP (ORCPT ); Sun, 5 Jun 2016 19:43:12 +0200 Date: Sun, 5 Jun 2016 19:43:09 +0200 From: Ladislav Michl To: u-boot@lists.denx.de Message-ID: <20160605174309.GE26814@localhost.localdomain> References: <20160605173453.GA26656@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160605173453.GA26656@localhost.localdomain> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: Tom Rini , Stefan Roese , Harald Welte , Scott Wood Subject: [U-Boot] [PATCH 5/6] cmd: mtdparts: support runtime generated mtdparts 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Some CPUs contains boot ROM code capable reading first few blocks (where SPL resides) of NAND flash and executing it. It is wise to create separate partition here for SPL. As block size depends on NAND chip used, we could either use worst case (biggest) partition size or base its size on actual block size. This patch adds support for the latter option. Signed-off-by: Ladislav Michl --- cmd/mtdparts.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/cmd/mtdparts.c b/cmd/mtdparts.c index 53074a1..71c7acb 100644 --- a/cmd/mtdparts.c +++ b/cmd/mtdparts.c @@ -109,17 +109,20 @@ DECLARE_GLOBAL_DATA_PTR; #define MTD_WRITEABLE_CMD 1 /* default values for mtdids and mtdparts variables */ -#if defined(MTDIDS_DEFAULT) -static const char *const mtdids_default = MTDIDS_DEFAULT; -#else -static const char *const mtdids_default = NULL; +#if !defined(MTDIDS_DEFAULT) +#define MTDIDS_DEFAULT NULL #endif - -#if defined(MTDPARTS_DEFAULT) -static const char *const mtdparts_default = MTDPARTS_DEFAULT; +#if !defined(MTDPARTS_DEFAULT) +#define MTDPARTS_DEFAULT NULL +#endif +#if defined(CONFIG_SYS_MTDPARTS_DEFAULT_RUNTIME) +#define MTD_DEFAULTS_READONLY +extern void board_mtdparts_default(const char **mtdids, const char **mtdparts); #else -static const char *const mtdparts_default = NULL; +#define MTD_DEFAULTS_READONLY const #endif +static const char *MTD_DEFAULTS_READONLY mtdids_default = MTDIDS_DEFAULT; +static const char *MTD_DEFAULTS_READONLY mtdparts_default = MTDPARTS_DEFAULT; /* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */ #define MTDIDS_MAXLEN 128 @@ -1725,6 +1728,9 @@ int mtdparts_init(void) memset(last_ids, 0, MTDIDS_MAXLEN); memset(last_parts, 0, MTDPARTS_MAXLEN); memset(last_partition, 0, PARTITION_MAXLEN); +#if defined(CONFIG_SYS_MTDPARTS_DEFAULT_RUNTIME) + board_mtdparts_default(&mtdids_default, &mtdparts_default); +#endif use_defaults = 1; initialized = 1; }