From patchwork Fri Feb 3 16:09:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 723811 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 3vFMpG6p6Gz9s7D for ; Sat, 4 Feb 2017 03:32:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 086A8A7705; Fri, 3 Feb 2017 17:31:14 +0100 (CET) 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 NTekyJjwW0vu; Fri, 3 Feb 2017 17:31:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 268A1B38CE; Fri, 3 Feb 2017 17:30:49 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A6F8B38A5 for ; Fri, 3 Feb 2017 17:30:40 +0100 (CET) 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 qY7eUlhaVZbk for ; Fri, 3 Feb 2017 17:30:40 +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 gloria.sntech.de (gloria.sntech.de [95.129.55.99]) by theia.denx.de (Postfix) with ESMTPS id BC34CA7708 for ; Fri, 3 Feb 2017 17:30:33 +0100 (CET) Received: from host-78-129-33-179.dynamic.voo.be ([78.129.33.179] helo=phil.sntech) by gloria.sntech.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1cZgRL-0002I2-PF; Fri, 03 Feb 2017 17:10:23 +0100 From: Heiko Stuebner To: sjg@chromium.org Date: Fri, 3 Feb 2017 17:09:24 +0100 Message-Id: <20170203160939.27594-2-heiko@sntech.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170203160939.27594-1-heiko@sntech.de> References: <20170203160939.27594-1-heiko@sntech.de> Cc: romain.perier@collabora.com, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v3 01/16] dm: allow limiting pre-reloc markings to spl or tpl 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" Right now the u-boot,dm-pre-reloc flag will make each marked node always appear in both spl and tpl. But systems needing an additional tpl might have special constraints for each, like the spl needing to be very tiny. So introduce two additional flags to mark nodes for only spl or tpl environments and introduce a function dm_fdt_pre_reloc to automate the necessary checks in code instances checking for pre-relocation flags. The behaviour of the original flag stays untouched and still marks a node for both spl and tpl. Signed-off-by: Heiko Stuebner Reviewed-by: Simon Glass --- doc/driver-model/README.txt | 4 ++++ drivers/clk/at91/pmc.c | 3 ++- drivers/core/root.c | 2 +- drivers/core/util.c | 29 +++++++++++++++++++++++++++++ drivers/pinctrl/pinctrl-uclass.c | 3 ++- include/dm/util.h | 2 ++ scripts/Makefile.spl | 7 ++++++- tools/dtoc/dtoc.py | 2 ++ 8 files changed, 48 insertions(+), 4 deletions(-) diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt index 1b5ccec4b2..af28b43c7b 100644 --- a/doc/driver-model/README.txt +++ b/doc/driver-model/README.txt @@ -825,6 +825,10 @@ drivers marked with DM_FLAG_PRE_RELOC or the device tree 'u-boot,dm-pre-reloc' flag are initialised prior to relocation. This helps to reduce the driver model overhead. +It is possible to limit this to specific relocation steps, by using +the more specialized 'u-boot,dm-spl' and 'u-boot,dm-tpl' flags +in the devicetree. + Then post relocation we throw that away and re-init driver model again. For drivers which require some sort of continuity between pre- and post-relocation devices, we can provide access to the pre-relocation diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c index 76ba91af81..c098efc9f7 100644 --- a/drivers/clk/at91/pmc.c +++ b/drivers/clk/at91/pmc.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "pmc.h" DECLARE_GLOBAL_DATA_PTR; @@ -56,7 +57,7 @@ int at91_clk_sub_device_bind(struct udevice *dev, const char *drv_name) offset > 0; offset = fdt_next_subnode(fdt, offset)) { if (pre_reloc_only && - !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL)) + !dm_fdt_pre_reloc(fdt, offset)) continue; /* * If this node has "compatible" property, this is not diff --git a/drivers/core/root.c b/drivers/core/root.c index 9edfc1efb6..45f990ba9e 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -205,7 +205,7 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, offset > 0; offset = fdt_next_subnode(blob, offset)) { if (pre_reloc_only && - !fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) + !dm_fdt_pre_reloc(blob, offset)) continue; if (!fdtdec_get_is_enabled(blob, offset)) { dm_dbg(" - ignoring disabled device\n"); diff --git a/drivers/core/util.c b/drivers/core/util.c index e01dd06d28..a67434b80d 100644 --- a/drivers/core/util.c +++ b/drivers/core/util.c @@ -5,6 +5,7 @@ */ #include +#include #include void dm_warn(const char *fmt, ...) @@ -35,3 +36,31 @@ int list_count_items(struct list_head *head) return count; } + +int dm_fdt_pre_reloc(const void *blob, int offset) +{ + bool dm_spl, dm_tpl; + + if (fdt_getprop(blob, offset, "u-boot,dm-pre-reloc", NULL)) + return 1; + + dm_spl = fdt_getprop(blob, offset, "u-boot,dm-spl", NULL); + dm_tpl = fdt_getprop(blob, offset, "u-boot,dm-tpl", NULL); + +#ifdef CONFIG_TPL_BUILD + if (dm_tpl) + return 1; +#elif defined(CONFIG_SPL_BUILD) + if (dm_spl) + return 1; +#else + /* + * In regular builds individual spl and tpl handling both + * count as handled pre-relocation for later second init. + */ + if (dm_spl || dm_tpl) + return 1; +#endif + + return 0; +} diff --git a/drivers/pinctrl/pinctrl-uclass.c b/drivers/pinctrl/pinctrl-uclass.c index 02ab9b4afd..9e0122906c 100644 --- a/drivers/pinctrl/pinctrl-uclass.c +++ b/drivers/pinctrl/pinctrl-uclass.c @@ -12,6 +12,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -131,7 +132,7 @@ static int pinconfig_post_bind(struct udevice *dev) offset > 0; offset = fdt_next_subnode(fdt, offset)) { if (pre_reloc_only && - !fdt_getprop(fdt, offset, "u-boot,dm-pre-reloc", NULL)) + !dm_fdt_pre_reloc(fdt, offset)) continue; /* * If this node has "compatible" property, this is not diff --git a/include/dm/util.h b/include/dm/util.h index 15daa3d19f..38c023ce66 100644 --- a/include/dm/util.h +++ b/include/dm/util.h @@ -48,4 +48,6 @@ static inline void dm_dump_devres(void) } #endif +int dm_fdt_pre_reloc(const void *blob, int offset); + #endif diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl index c962bbca2c..60bd844e48 100644 --- a/scripts/Makefile.spl +++ b/scripts/Makefile.spl @@ -206,8 +206,13 @@ $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN) # 'u-boot,dm-pre-reloc' property and thus are not needed by SPL. The second # pass removes various unused properties from the remaining nodes. # The output is typically a much smaller device tree file. +ifeq ($(CONFIG_TPL_BUILD),y) +fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-tpl +else +fdtgrep_props := -b u-boot,dm-pre-reloc -b u-boot,dm-spl +endif quiet_cmd_fdtgrep = FDTGREP $@ - cmd_fdtgrep = $(objtree)/tools/fdtgrep -b u-boot,dm-pre-reloc -RT $< \ + cmd_fdtgrep = $(objtree)/tools/fdtgrep $(fdtgrep_props) -RT $< \ -n /chosen -O dtb | \ $(objtree)/tools/fdtgrep -r -O dtb - -o $@ \ $(addprefix -P ,$(subst $\",,$(CONFIG_OF_SPL_REMOVE_PROPS))) diff --git a/tools/dtoc/dtoc.py b/tools/dtoc/dtoc.py index 11050b66f7..232f8ff739 100755 --- a/tools/dtoc/dtoc.py +++ b/tools/dtoc/dtoc.py @@ -30,6 +30,8 @@ PROP_IGNORE_LIST = [ "status", 'phandle', 'u-boot,dm-pre-reloc', + 'u-boot,dm-tpl', + 'u-boot,dm-spl', ] # C type declarations for the tyues we support