All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 04/22] dm: Add livetree definitions
Date: Tue, 17 Jan 2017 22:50:33 -0700	[thread overview]
Message-ID: <20170118055058.6358-5-sjg@chromium.org> (raw)
In-Reply-To: <20170118055058.6358-1-sjg@chromium.org>

Add a Kconfig option to enable a live device tree, built at run time from
the flat tree. Also all structure definitions and a root node.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 dts/Kconfig                       | 11 ++++++++
 include/asm-generic/global_data.h |  3 +++
 include/dm/of.h                   | 53 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+)
 create mode 100644 include/dm/of.h

diff --git a/dts/Kconfig b/dts/Kconfig
index 4b7d8b15cc0..0fa1fb5c656 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -22,6 +22,17 @@ config SPL_OF_CONTROL
 	  which is not enough to support device tree. Enable this option to
 	  allow such boards to be supported by U-Boot SPL.
 
+config OF_LIVE
+	bool "Enable use of a live tree"
+	depends on OF_CONTROL
+	help
+	  Normally U-Boot uses a flat device tree which saves space and
+	  avoids the need to unpack the tree before use. However a flat
+	  tree does not support modifcation from within U-Boot since it
+	  can invalidate driver-model device tree offsets. This option
+	  enables a live tree which is available during relocation,
+	  and can be adjusted as needed.
+
 choice
 	prompt "Provider of DTB for DT control"
 	depends on OF_CONTROL
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h
index e02863dc031..c35f5d0c330 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -72,6 +72,9 @@ typedef struct global_data {
 	const void *fdt_blob;		/* Our device tree, NULL if none */
 	void *new_fdt;			/* Relocated FDT */
 	unsigned long fdt_size;		/* Space reserved for relocated FDT */
+#ifdef CONFIG_OF_LIVE
+	struct device_node *of_root;
+#endif
 	struct jt_funcs *jt;		/* jump table */
 	char env_buf[32];		/* buffer for getenv() before reloc. */
 #ifdef CONFIG_TRACE
diff --git a/include/dm/of.h b/include/dm/of.h
new file mode 100644
index 00000000000..716fd73ab38
--- /dev/null
+++ b/include/dm/of.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _DM_OF_H
+#define _DM_OF_H
+
+typedef u32 phandle;
+typedef u32 ihandle;
+
+struct property {
+	char	*name;
+	int	length;
+	void	*value;
+	struct property *next;
+};
+
+struct device_node {
+	const char *name;
+	phandle phandle;
+	const char *full_name;
+
+	struct	property *properties;
+	struct	device_node *parent;
+	struct	device_node *child;
+	struct	device_node *sibling;
+};
+
+#define OF_MAX_PHANDLE_ARGS 16
+struct of_phandle_args {
+	struct device_node *np;
+	int args_count;
+	uint32_t args[OF_MAX_PHANDLE_ARGS];
+};
+
+DECLARE_GLOBAL_DATA_PTR;
+
+#ifdef CONFIG_OF_LIVE
+static inline bool of_use_livetree(void)
+{
+	return gd->of_root != NULL;
+}
+#else
+static inline bool of_use_livetree(void)
+{
+	return false;
+}
+#endif
+
+#endif
-- 
2.11.0.483.g087da7b7c-goog

  parent reply	other threads:[~2017-01-18  5:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-18  5:50 [U-Boot] [PATCH 00/22] dm: Add support for a 'live' device tree Simon Glass
2017-01-18  5:50 ` [U-Boot] [PATCH 01/22] dm: core: Set return value first in lists_bind_fdt() Simon Glass
2017-01-18  5:50 ` [U-Boot] [PATCH 02/22] dm: core: atmel: Dont export dm_scan_fdt_node() Simon Glass
2017-01-18  5:50 ` [U-Boot] [PATCH 03/22] Update WARN_ON() to return a value Simon Glass
2017-01-18  5:50 ` Simon Glass [this message]
2017-02-05  3:34 ` [U-Boot] [PATCH 00/22] dm: Add support for a 'live' device tree Simon Glass
2017-02-05 23:38   ` Tom Rini
2017-03-21 14:07   ` Tom Rini
2017-04-01  4:21     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170118055058.6358-5-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.