mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 00/17] general cleanups and sandbox OF integration
@ 2015-03-01 12:32 Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 01/17] drivers: remove unused function dev_protect() Marc Kleine-Budde
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Hello Sascha,

the first five patches are several cleanups in barebox, I've found while
working on a new feautre. The remaining ones bring OF support to the sandbox so
that enables testing of framworks which need the device tree.

regards,
Marc

changes since v1:
- remove 04/16 "of: make first argument of several of_property_*_string functions const"
- add 05/17, 06/17: to provide no-ops for of_register_fixup, of_find_node_by_alias
- fix 08/17: "sandbox: add support to pass dtb to barebox"
  fix compilation for !CONFIG_OFTREE


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 01/17] drivers: remove unused function dev_protect()
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 02/17] fs: make "offset" parameter of erase() and protect() 64 bit safe Marc Kleine-Budde
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/base/driver.c | 6 ------
 include/driver.h      | 2 --
 2 files changed, 8 deletions(-)

diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 81b35031a111..3363b56675ee 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -350,12 +350,6 @@ void __iomem *dev_request_mem_region(struct device_d *dev, int num)
 }
 EXPORT_SYMBOL(dev_request_mem_region);
 
-int dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot)
-{
-	printf("%s: currently broken\n", __func__);
-	return -EINVAL;
-}
-
 int generic_memmap_ro(struct cdev *cdev, void **map, int flags)
 {
 	if (!cdev->dev)
diff --git a/include/driver.h b/include/driver.h
index 76fd4b1720b2..0ee3b4554f98 100644
--- a/include/driver.h
+++ b/include/driver.h
@@ -331,8 +331,6 @@ struct driver_d *get_driver_by_name(const char *name);
 
 struct cdev;
 
-int     dev_protect(struct device_d *dev, size_t count, unsigned long offset, int prot);
-
 /* These are used by drivers which work with direct memory accesses */
 ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags);
 ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 02/17] fs: make "offset" parameter of erase() and protect() 64 bit safe
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 01/17] drivers: remove unused function dev_protect() Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 03/17] of_path: of_find_path(): remove unused variable len Marc Kleine-Budde
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 fs/fs.c      | 4 ++--
 include/fs.h | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index ffdfa2c0ff39..779f2641b200 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -923,7 +923,7 @@ out:
 }
 EXPORT_SYMBOL(lseek);
 
-int erase(int fd, size_t count, unsigned long offset)
+int erase(int fd, size_t count, loff_t offset)
 {
 	struct fs_driver_d *fsdrv;
 	FILE *f;
@@ -950,7 +950,7 @@ int erase(int fd, size_t count, unsigned long offset)
 }
 EXPORT_SYMBOL(erase);
 
-int protect(int fd, size_t count, unsigned long offset, int prot)
+int protect(int fd, size_t count, loff_t offset, int prot)
 {
 	struct fs_driver_d *fsdrv;
 	FILE *f;
diff --git a/include/fs.h b/include/fs.h
index 63e35ca815f5..b8a95a20a793 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -147,8 +147,8 @@ int mount (const char *device, const char *fsname, const char *path,
 int umount(const char *pathname);
 
 /* not-so-standard functions */
-int erase(int fd, size_t count, unsigned long offset);
-int protect(int fd, size_t count, unsigned long offset, int prot);
+int erase(int fd, size_t count, loff_t offset);
+int protect(int fd, size_t count, loff_t offset, int prot);
 int protect_file(const char *file, int prot);
 void *memmap(int fd, int flags);
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 03/17] of_path: of_find_path(): remove unused variable len
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 01/17] drivers: remove unused function dev_protect() Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 02/17] fs: make "offset" parameter of erase() and protect() 64 bit safe Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 04/17] of/base: fix sparse warning, don't use interger 0 as NULL pointer Marc Kleine-Budde
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/of/of_path.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
index f0fd917ada56..df63c5782a02 100644
--- a/drivers/of/of_path.c
+++ b/drivers/of/of_path.c
@@ -132,9 +132,9 @@ int of_find_path(struct device_node *node, const char *propname, char **outpath)
 	struct of_path op = {};
 	struct device_node *rnode;
 	const char *path, *str;
-	int i, len, ret;
+	int i, ret;
 
-	path = of_get_property(node, propname, &len);
+	path = of_get_property(node, propname, NULL);
 	if (!path)
 		return -EINVAL;
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 04/17] of/base: fix sparse warning, don't use interger 0 as NULL pointer
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 03/17] of_path: of_find_path(): remove unused variable len Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 05/17] of: add no-op function for of_register_fixup() Marc Kleine-Budde
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/of/base.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index af10fd1da32c..d45d3941b88d 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -184,7 +184,7 @@ void of_alias_scan(void)
 			end--;
 		len = end - start;
 
-		id = simple_strtol(end, 0, 10);
+		id = simple_strtol(end, NULL, 10);
 		if (id < 0)
 			continue;
 
@@ -280,7 +280,7 @@ struct device_node *of_find_node_by_phandle_from(phandle phandle,
 		root = root_node;
 
 	if (!root)
-		return 0;
+		return NULL;
 
 	of_tree_for_each_node_from(node, root)
 		if (node->phandle == phandle)
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 05/17] of: add no-op function for of_register_fixup()
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 04/17] of/base: fix sparse warning, don't use interger 0 as NULL pointer Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 06/17] of: add no-op functions for of_find_node_by_alias() and of_find_node_by_path_or_alias() Marc Kleine-Budde
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 include/of.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/include/of.h b/include/of.h
index 2ad941864f5d..46eecee70035 100644
--- a/include/of.h
+++ b/include/of.h
@@ -61,7 +61,6 @@ struct device_d;
 struct driver_d;
 
 int of_fix_tree(struct device_node *);
-int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context);
 
 int of_match(struct device_d *dev, struct driver_d *drv);
 
@@ -240,6 +239,7 @@ void of_add_memory_bank(struct device_node *node, bool dump, int r,
 		u64 base, u64 size);
 struct device_d *of_find_device_by_node_path(const char *path);
 int of_find_path(struct device_node *node, const char *propname, char **outpath);
+int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context);
 #else
 static inline int of_parse_partitions(struct cdev *cdev,
 					  struct device_node *node)
@@ -596,6 +596,12 @@ static inline struct device_d *of_device_enable_and_register_by_name(
 {
 	return NULL;
 }
+
+static inline int of_register_fixup(int (*fixup)(struct device_node *, void *),
+				void *context)
+{
+	return -ENOSYS;
+}
 #endif
 
 #define for_each_node_by_name(dn, name) \
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 06/17] of: add no-op functions for of_find_node_by_alias() and of_find_node_by_path_or_alias()
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 05/17] of: add no-op function for of_register_fixup() Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 07/17] sandbox: fix indention in help text Marc Kleine-Budde
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 include/of.h | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/include/of.h b/include/of.h
index 46eecee70035..764a2e5939b7 100644
--- a/include/of.h
+++ b/include/of.h
@@ -240,6 +240,10 @@ void of_add_memory_bank(struct device_node *node, bool dump, int r,
 struct device_d *of_find_device_by_node_path(const char *path);
 int of_find_path(struct device_node *node, const char *propname, char **outpath);
 int of_register_fixup(int (*fixup)(struct device_node *, void *), void *context);
+struct device_node *of_find_node_by_alias(struct device_node *root,
+		const char *alias);
+struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
+		const char *str);
 #else
 static inline int of_parse_partitions(struct cdev *cdev,
 					  struct device_node *node)
@@ -602,6 +606,18 @@ static inline int of_register_fixup(int (*fixup)(struct device_node *, void *),
 {
 	return -ENOSYS;
 }
+
+static inline struct device_node *of_find_node_by_alias(
+				struct device_node *root, const char *alias)
+{
+	return NULL;
+}
+
+static inline struct device_node *of_find_node_by_path_or_alias(
+				struct device_node *root, const char *str)
+{
+	return NULL;
+}
 #endif
 
 #define for_each_node_by_name(dn, name) \
@@ -737,10 +753,6 @@ int of_device_disable_path(const char *path);
 phandle of_get_tree_max_phandle(struct device_node *root);
 phandle of_node_create_phandle(struct device_node *node);
 int of_set_property_to_child_phandle(struct device_node *node, char *prop_name);
-struct device_node *of_find_node_by_alias(struct device_node *root,
-		const char *alias);
-struct device_node *of_find_node_by_path_or_alias(struct device_node *root,
-		const char *str);
 
 static inline struct device_node *of_find_root_node(struct device_node *node)
 {
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 07/17] sandbox: fix indention in help text
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 06/17] of: add no-op functions for of_find_node_by_alias() and of_find_node_by_path_or_alias() Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 08/17] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 0854fb5d802d..65dc4a1ab75c 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -399,7 +399,7 @@ static void print_usage(const char *prgname)
 "Usage: %s [OPTIONS]\n"
 "Start barebox.\n\n"
 "Options:\n\n"
-"  -m, --malloc=<size>	Start sandbox with a specified malloc-space size in bytes.\n"
+"  -m, --malloc=<size>  Start sandbox with a specified malloc-space size in bytes.\n"
 "  -i, --image=<file>   Map an image file to barebox. This option can be given\n"
 "                       multiple times. The files will show up as\n"
 "                       /dev/fd0 ... /dev/fdx under barebox.\n"
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 08/17] sandbox: add support to pass dtb to barebox
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 07/17] sandbox: fix indention in help text Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 09/17] sandbox: hostfile: clarify variable names Marc Kleine-Budde
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/Makefile                    |  1 +
 arch/sandbox/board/dtb.c                       | 57 ++++++++++++++++++++++++++
 arch/sandbox/mach-sandbox/include/mach/linux.h | 10 +++++
 arch/sandbox/os/Makefile                       |  3 ++
 arch/sandbox/os/common.c                       | 47 ++++++++++++++++++++-
 5 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 arch/sandbox/board/dtb.c

diff --git a/arch/sandbox/board/Makefile b/arch/sandbox/board/Makefile
index 5104f5cb2679..5061d658e500 100644
--- a/arch/sandbox/board/Makefile
+++ b/arch/sandbox/board/Makefile
@@ -3,5 +3,6 @@ obj-y += clock.o
 obj-y += hostfile.o
 obj-y += console.o
 obj-y += devices.o
+obj-$(CONFIG_OFTREE) += dtb.o
 
 extra-y += barebox.lds
diff --git a/arch/sandbox/board/dtb.c b/arch/sandbox/board/dtb.c
new file mode 100644
index 000000000000..9d4210164e01
--- /dev/null
+++ b/arch/sandbox/board/dtb.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2013 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
+ * Copyright (c) 2015 Marc Kleine-Budde <mkl@pengutronix.de>, Pengutronix
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <of.h>
+
+#include <mach/linux.h>
+#include <linux/err.h>
+
+static const void *dtb;
+
+int barebox_register_dtb(const void *new_dtb)
+{
+	if (dtb)
+		return -EBUSY;
+
+	dtb = new_dtb;
+
+	return 0;
+}
+
+static int of_sandbox_init(void)
+{
+	struct device_node *root;
+
+	if (!dtb)
+		return 0;
+
+	root = of_unflatten_dtb(dtb);
+	if (IS_ERR(root)) {
+		return PTR_ERR(root);
+	}
+
+	of_set_root_node(root);
+	of_fix_tree(root);
+	if (IS_ENABLED(CONFIG_OFDEVICE))
+		of_probe();
+
+	return 0;
+}
+core_initcall(of_sandbox_init);
diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h
index 98f9067046c3..037153d7f873 100644
--- a/arch/sandbox/mach-sandbox/include/mach/linux.h
+++ b/arch/sandbox/mach-sandbox/include/mach/linux.h
@@ -20,6 +20,16 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[]);
 
 int barebox_register_console(char *name_template, int stdinfd, int stdoutfd);
 
+#ifdef CONFIG_OFTREE
+int barebox_register_dtb(const void *dtb);
+#else
+static inline int barebox_register_dtb(const void *dtb)
+{
+	fprintf(stderr, "OF support not enabled - aborting\n");
+	return -ENOSYS;
+}
+#endif
+
 struct linux_console_data {
 	int stdinfd;
 	int stdoutfd;
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index 537f848e06f5..eaf9375c0ee8 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -9,6 +9,9 @@ CPPFLAGS = $(patsubst %,-I$(srctree)/%include,$(machdirs))
 endif
 
 CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
+ifdef CONFIG_OFTREE
+CPPFLAGS += -DCONFIG_OFTREE=$(CONFIG_OFTREE)
+endif
 
 CFLAGS := -Wall
 NOSTDINC_FLAGS :=
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 65dc4a1ab75c..cfb261acf2b5 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -265,6 +265,42 @@ err_out:
 	return -1;
 }
 
+static int add_dtb(const char *file)
+{
+	struct stat s;
+	void *dtb = NULL;
+	int fd;
+
+	fd = open(file, O_RDONLY);
+	if (fd < 0) {
+		perror("open");
+		goto err_out;
+	}
+
+	if (fstat(fd, &s)) {
+		perror("fstat");
+		goto err_out;
+	}
+
+	dtb = mmap(NULL, s.st_size, PROT_READ, MAP_SHARED, fd, 0);
+	if (dtb == MAP_FAILED) {
+		perror("mmap");
+		goto err_out;
+	}
+
+	if (barebox_register_dtb(dtb))
+		goto err_out;
+
+	return 0;
+
+ err_out:
+	if (dtb)
+		munmap(dtb, s.st_size);
+	if (fd > 0)
+		close(fd);
+	return -1;
+}
+
 static void print_usage(const char*);
 
 static struct option long_options[] = {
@@ -272,6 +308,7 @@ static struct option long_options[] = {
 	{"malloc", 1, 0, 'm'},
 	{"image",  1, 0, 'i'},
 	{"env",    1, 0, 'e'},
+	{"dtb",    1, 0, 'd'},
 	{"stdout", 1, 0, 'O'},
 	{"stdin",  1, 0, 'I'},
 	{"xres",  1, 0, 'x'},
@@ -279,7 +316,7 @@ static struct option long_options[] = {
 	{0, 0, 0, 0},
 };
 
-static const char optstring[] = "hm:i:e:O:I:x:y:";
+static const char optstring[] = "hm:i:e:d:O:I:x:y:";
 
 int main(int argc, char *argv[])
 {
@@ -308,6 +345,13 @@ int main(int argc, char *argv[])
 			break;
 		case 'e':
 			break;
+		case 'd':
+			ret = add_dtb(optarg);
+			if (ret) {
+				printf("Failed to load dtb: '%s'\n", optarg);
+				exit(1);
+			}
+			break;
 		case 'O':
 			fd = open(optarg, O_WRONLY);
 			if (fd < 0) {
@@ -408,6 +452,7 @@ static void print_usage(const char *prgname)
 "                       and thus are used as the default environment.\n"
 "                       An empty file generated with dd will do to get started\n"
 "                       with an empty environment.\n"
+"  -d, --dtb=<file>     Map a device tree binary blob (dtb) into barebox.\n"
 "  -O, --stdout=<file>  Register a file as a console capable of doing stdout.\n"
 "                       <file> can be a regular file or a FIFO.\n"
 "  -I, --stdin=<file>   Register a file as a console capable of doing stdin.\n"
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 09/17] sandbox: hostfile: clarify variable names
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 08/17] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 10/17] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev Marc Kleine-Budde
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Use "filename" for the name of the file in the host system, while "devname" for
the device in the sandbox.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c                     |  2 +-
 arch/sandbox/mach-sandbox/include/mach/hostfile.h |  2 +-
 arch/sandbox/os/common.c                          | 16 ++++++++--------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index ac29cfa47a7d..5324da6f4802 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -73,7 +73,7 @@ static int hf_probe(struct device_d *dev)
 
 	priv->pdata = hf;
 
-	priv->cdev.name = hf->name;
+	priv->cdev.name = hf->devname;
 	priv->cdev.size = hf->size;
 	priv->cdev.ops = &hf_fops;
 	priv->cdev.priv = hf;
diff --git a/arch/sandbox/mach-sandbox/include/mach/hostfile.h b/arch/sandbox/mach-sandbox/include/mach/hostfile.h
index 7c4e67cf6847..747063182cf3 100644
--- a/arch/sandbox/mach-sandbox/include/mach/hostfile.h
+++ b/arch/sandbox/mach-sandbox/include/mach/hostfile.h
@@ -6,7 +6,7 @@ struct hf_platform_data {
 	size_t size;
 	unsigned long base;
 	char *filename;
-	char *name;
+	char *devname;
 };
 
 int barebox_register_filedev(struct hf_platform_data *hf);
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index cfb261acf2b5..e2023165d542 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -206,9 +206,9 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[])
 extern void start_barebox(void);
 extern void mem_malloc_init(void *start, void *end);
 
-static int add_image(char *str, char *name)
+static int add_image(char *str, char *devname)
 {
-	char *file;
+	char *filename;
 	int readonly = 0, map = 1;
 	struct stat s;
 	char *opt;
@@ -218,7 +218,7 @@ static int add_image(char *str, char *name)
 	if (!hf)
 		return -1;
 
-	file = strtok(str, ",");
+	filename = strtok(str, ",");
 	while ((opt = strtok(NULL, ","))) {
 		if (!strcmp(opt, "ro"))
 			readonly = 1;
@@ -226,11 +226,11 @@ static int add_image(char *str, char *name)
 			map = 1;
 	}
 
-	printf("add file %s(%s)\n", file, readonly ? "ro" : "");
+	printf("add file %s(%s)\n", filename, readonly ? "ro" : "");
 
-	fd = open(file, readonly ? O_RDONLY : O_RDWR);
+	fd = open(filename, readonly ? O_RDONLY : O_RDWR);
 	hf->fd = fd;
-	hf->filename = file;
+	hf->filename = filename;
 
 	if (fd < 0) {
 		perror("open");
@@ -243,14 +243,14 @@ static int add_image(char *str, char *name)
 	}
 
 	hf->size = s.st_size;
-	hf->name = strdup(name);
+	hf->devname = strdup(devname);
 
 	if (map) {
 		hf->base = (unsigned long)mmap(NULL, hf->size,
 				PROT_READ | (readonly ? 0 : PROT_WRITE),
 				MAP_SHARED, fd, 0);
 		if ((void *)hf->base == MAP_FAILED)
-			printf("warning: mmapping %s failed\n", file);
+			printf("warning: mmapping %s failed\n", filename);
 	}
 
 	ret = barebox_register_filedev(hf);
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 10/17] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 09/17] sandbox: hostfile: clarify variable names Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 11/17] sandbox: hostfile: remove struct hf_platform_data from hf_priv Marc Kleine-Budde
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Without this pointer the cdev will not be associated with the dev,
of_find_path() relies on this.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 5324da6f4802..6ec3b87efa86 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -75,6 +75,7 @@ static int hf_probe(struct device_d *dev)
 
 	priv->cdev.name = hf->devname;
 	priv->cdev.size = hf->size;
+	priv->cdev.dev = dev;
 	priv->cdev.ops = &hf_fops;
 	priv->cdev.priv = hf;
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 11/17] sandbox: hostfile: remove struct hf_platform_data from hf_priv
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (9 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 10/17] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 12/17] sandbox: hostfile: move fd from platform data to priv Marc Kleine-Budde
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 6ec3b87efa86..fef9f5cffa89 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -28,7 +28,6 @@
 
 struct hf_priv {
 	struct cdev cdev;
-	struct hf_platform_data *pdata;
 };
 
 static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
@@ -71,8 +70,6 @@ static int hf_probe(struct device_d *dev)
 	struct hf_platform_data *hf = dev->platform_data;
 	struct hf_priv *priv = xzalloc(sizeof(*priv));
 
-	priv->pdata = hf;
-
 	priv->cdev.name = hf->devname;
 	priv->cdev.size = hf->size;
 	priv->cdev.dev = dev;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 12/17] sandbox: hostfile: move fd from platform data to priv
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (10 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 11/17] sandbox: hostfile: remove struct hf_platform_data from hf_priv Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 13/17] sandbox: hostfile: probe driver earlier Marc Kleine-Budde
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index fef9f5cffa89..103bcd9badc7 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -28,12 +28,13 @@
 
 struct hf_priv {
 	struct cdev cdev;
+	int fd;
 };
 
 static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulong flags)
 {
-	struct hf_platform_data *hf = cdev->priv;
-	int fd = hf->fd;
+	struct hf_priv *priv= cdev->priv;
+	int fd = priv->fd;
 
 	if (linux_lseek(fd, offset) != offset)
 		return -EINVAL;
@@ -43,8 +44,8 @@ static ssize_t hf_read(struct cdev *cdev, void *buf, size_t count, loff_t offset
 
 static ssize_t hf_write(struct cdev *cdev, const void *buf, size_t count, loff_t offset, ulong flags)
 {
-	struct hf_platform_data *hf = cdev->priv;
-	int fd = hf->fd;
+	struct hf_priv *priv = cdev->priv;
+	int fd = priv->fd;
 
 	if (linux_lseek(fd, offset) != offset)
 		return -EINVAL;
@@ -70,11 +71,12 @@ static int hf_probe(struct device_d *dev)
 	struct hf_platform_data *hf = dev->platform_data;
 	struct hf_priv *priv = xzalloc(sizeof(*priv));
 
+	priv->fd = hf->fd;
 	priv->cdev.name = hf->devname;
 	priv->cdev.size = hf->size;
 	priv->cdev.dev = dev;
 	priv->cdev.ops = &hf_fops;
-	priv->cdev.priv = hf;
+	priv->cdev.priv = priv;
 
 	dev->info = hf_info;
 
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 13/17] sandbox: hostfile: probe driver earlier
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (11 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 12/17] sandbox: hostfile: move fd from platform data to priv Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 14/17] sandbox: hostfile: use the memory resource to determine the size not the platform_data Marc Kleine-Budde
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

This patch convert from device_platform_driver to coredevice_platform_driver,
so that the driver is initialzied before the state framework is probed.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 103bcd9badc7..42ade6bec8a4 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -91,7 +91,7 @@ static struct driver_d hf_drv = {
 	.name  = "hostfile",
 	.probe = hf_probe,
 };
-device_platform_driver(hf_drv);
+coredevice_platform_driver(hf_drv);
 
 int barebox_register_filedev(struct hf_platform_data *hf)
 {
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 14/17] sandbox: hostfile: use the memory resource to determine the size not the platform_data
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (12 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 13/17] sandbox: hostfile: probe driver earlier Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 15/17] sandbox: hostfile: add support for OF Marc Kleine-Budde
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index 42ade6bec8a4..d9ca1a423acf 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -70,10 +70,15 @@ static int hf_probe(struct device_d *dev)
 {
 	struct hf_platform_data *hf = dev->platform_data;
 	struct hf_priv *priv = xzalloc(sizeof(*priv));
+	struct resource *res;
+
+	res = dev_get_resource(dev, IORESOURCE_MEM, 0);
+	if (IS_ERR(res))
+		return PTR_ERR(res);
 
 	priv->fd = hf->fd;
 	priv->cdev.name = hf->devname;
-	priv->cdev.size = hf->size;
+	priv->cdev.size = resource_size(res);
 	priv->cdev.dev = dev;
 	priv->cdev.ops = &hf_fops;
 	priv->cdev.priv = priv;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 15/17] sandbox: hostfile: add support for OF
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (13 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 14/17] sandbox: hostfile: use the memory resource to determine the size not the platform_data Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 16/17] sandbox: add sample dts Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 17/17] sandbox: activate OF support in defconfig Marc Kleine-Budde
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/board/hostfile.c                     | 59 +++++++++++++++++++++--
 arch/sandbox/mach-sandbox/include/mach/hostfile.h |  1 +
 arch/sandbox/os/common.c                          | 31 +++++++++---
 3 files changed, 82 insertions(+), 9 deletions(-)

diff --git a/arch/sandbox/board/hostfile.c b/arch/sandbox/board/hostfile.c
index d9ca1a423acf..7576b22ca01f 100644
--- a/arch/sandbox/board/hostfile.c
+++ b/arch/sandbox/board/hostfile.c
@@ -26,6 +26,8 @@
 #include <mach/hostfile.h>
 #include <xfuncs.h>
 
+#include <linux/err.h>
+
 struct hf_priv {
 	struct cdev cdev;
 	int fd;
@@ -57,7 +59,8 @@ static void hf_info(struct device_d *dev)
 {
 	struct hf_platform_data *hf = dev->platform_data;
 
-	printf("file: %s\n", hf->filename);
+	if (hf)
+		printf("file: %s\n", hf->filename);
 }
 
 static struct file_operations hf_fops = {
@@ -71,14 +74,31 @@ static int hf_probe(struct device_d *dev)
 	struct hf_platform_data *hf = dev->platform_data;
 	struct hf_priv *priv = xzalloc(sizeof(*priv));
 	struct resource *res;
+	int err;
 
 	res = dev_get_resource(dev, IORESOURCE_MEM, 0);
 	if (IS_ERR(res))
 		return PTR_ERR(res);
 
-	priv->fd = hf->fd;
-	priv->cdev.name = hf->devname;
 	priv->cdev.size = resource_size(res);
+
+	if (dev->device_node) {
+		const char *alias;
+		err = of_property_read_u32(dev->device_node, "fd", &priv->fd);
+		if (err)
+			return err;
+
+		alias = of_alias_get(dev->device_node);
+		if (!alias)
+			alias = dev->device_node->name;
+
+		priv->cdev.name = xstrdup(alias);
+	} else if (hf) {
+		priv->fd = hf->fd;
+		priv->cdev.name = hf->devname;
+	} else {
+		return -ENODEV;
+	}
 	priv->cdev.dev = dev;
 	priv->cdev.ops = &hf_fops;
 	priv->cdev.priv = priv;
@@ -92,8 +112,17 @@ static int hf_probe(struct device_d *dev)
 	return 0;
 }
 
+static __maybe_unused struct of_device_id hostfile_dt_ids[] = {
+	{
+		.compatible = "barebox,hostfile",
+	}, {
+		/* sentinel */
+	}
+};
+
 static struct driver_d hf_drv = {
 	.name  = "hostfile",
+	.of_compatible = DRV_OF_COMPAT(hostfile_dt_ids),
 	.probe = hf_probe,
 };
 coredevice_platform_driver(hf_drv);
@@ -118,3 +147,27 @@ int barebox_register_filedev(struct hf_platform_data *hf)
 
 	return sandbox_add_device(dev);
 }
+
+static int of_hostfile_fixup(struct device_node *node, void *ctx)
+{
+	struct hf_platform_data *hf = ctx;
+	uint32_t reg[] = {
+		hf->base >> 32,
+		hf->base,
+		hf->size
+	};
+
+	node = of_find_node_by_alias(NULL, hf->devname);
+	if (!node)
+		return -ENODEV;
+
+	of_property_write_u32(node, "fd", hf->fd);
+	of_property_write_u32_array(node, "reg", reg, ARRAY_SIZE(reg));
+
+	return 0;
+}
+
+int barebox_register_filedev_dt(struct hf_platform_data *hf)
+{
+	return of_register_fixup(of_hostfile_fixup, hf);
+}
diff --git a/arch/sandbox/mach-sandbox/include/mach/hostfile.h b/arch/sandbox/mach-sandbox/include/mach/hostfile.h
index 747063182cf3..ef985bcbd790 100644
--- a/arch/sandbox/mach-sandbox/include/mach/hostfile.h
+++ b/arch/sandbox/mach-sandbox/include/mach/hostfile.h
@@ -10,6 +10,7 @@ struct hf_platform_data {
 };
 
 int barebox_register_filedev(struct hf_platform_data *hf);
+int barebox_register_filedev_dt(struct hf_platform_data *hf);
 
 #endif /* __ASM_ARCH_HOSTFILE_H */
 
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e2023165d542..c4155714ba28 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -25,6 +25,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <termios.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -34,6 +35,7 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <libgen.h>
+#include <limits.h>
 #include <sys/mman.h>
 #include <errno.h>
 #include <signal.h>
@@ -206,7 +208,7 @@ int linux_execve(const char * filename, char *const argv[], char *const envp[])
 extern void start_barebox(void);
 extern void mem_malloc_init(void *start, void *end);
 
-static int add_image(char *str, char *devname)
+static int add_image(char *str, char *devname, bool dt)
 {
 	char *filename;
 	int readonly = 0, map = 1;
@@ -253,7 +255,11 @@ static int add_image(char *str, char *devname)
 			printf("warning: mmapping %s failed\n", filename);
 	}
 
-	ret = barebox_register_filedev(hf);
+	if (dt)
+		ret = barebox_register_filedev_dt(hf);
+	else
+		ret = barebox_register_filedev(hf);
+
 	if (ret)
 		goto err_out;
 	return 0;
@@ -303,11 +309,16 @@ static int add_dtb(const char *file)
 
 static void print_usage(const char*);
 
+#define OPT_DTIMAGE	(UCHAR_MAX + 1)
+#define OPT_DTENV	(UCHAR_MAX + 2)
+
 static struct option long_options[] = {
 	{"help",   0, 0, 'h'},
 	{"malloc", 1, 0, 'm'},
 	{"image",  1, 0, 'i'},
 	{"env",    1, 0, 'e'},
+	{"dtimage",1, 0, OPT_DTIMAGE},
+	{"dtenv",  1, 0, OPT_DTENV},
 	{"dtb",    1, 0, 'd'},
 	{"stdout", 1, 0, 'O'},
 	{"stdin",  1, 0, 'I'},
@@ -345,6 +356,10 @@ int main(int argc, char *argv[])
 			break;
 		case 'e':
 			break;
+		case OPT_DTIMAGE:
+			break;
+		case OPT_DTENV:
+			break;
 		case 'd':
 			ret = add_dtb(optarg);
 			if (ret) {
@@ -405,15 +420,17 @@ int main(int argc, char *argv[])
 
 		switch (opt) {
 		case 'i':
-			sprintf(str, "fd%d", fdno);
-			ret = add_image(optarg, str);
+		case OPT_DTIMAGE:
+			snprintf(str, sizeof(str),"fd%d", fdno);
+			ret = add_image(optarg, str, opt == OPT_DTIMAGE);
 			if (ret)
 				exit(1);
 			fdno++;
 			break;
 		case 'e':
-			sprintf(str, "env%d", envno);
-			ret = add_image(optarg, str);
+		case OPT_DTENV:
+			snprintf(str, sizeof(str), "env%d", envno);
+			ret = add_image(optarg, str, opt == OPT_DTENV);
 			if (ret)
 				exit(1);
 			envno++;
@@ -447,11 +464,13 @@ static void print_usage(const char *prgname)
 "  -i, --image=<file>   Map an image file to barebox. This option can be given\n"
 "                       multiple times. The files will show up as\n"
 "                       /dev/fd0 ... /dev/fdx under barebox.\n"
+"  --dtimage=<file>     Same as '--image', but add file via device tree\n"
 "  -e, --env=<file>     Map a file with an environment to barebox. With this \n"
 "                       option, files are mapped as /dev/env0 ... /dev/envx\n"
 "                       and thus are used as the default environment.\n"
 "                       An empty file generated with dd will do to get started\n"
 "                       with an empty environment.\n"
+"  --dtenv=<file>       Same as '--env', but add file via device tree\n"
 "  -d, --dtb=<file>     Map a device tree binary blob (dtb) into barebox.\n"
 "  -O, --stdout=<file>  Register a file as a console capable of doing stdout.\n"
 "                       <file> can be a regular file or a FIFO.\n"
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 16/17] sandbox: add sample dts
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (14 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 15/17] sandbox: hostfile: add support for OF Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  2015-03-01 12:32 ` [PATCH v2 17/17] sandbox: activate OF support in defconfig Marc Kleine-Budde
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/Makefile          |  2 ++
 arch/sandbox/dts/.gitignore    |  1 +
 arch/sandbox/dts/Makefile      | 11 +++++++++++
 arch/sandbox/dts/sandbox.dts   | 13 +++++++++++++
 arch/sandbox/dts/skeleton.dtsi | 13 +++++++++++++
 5 files changed, 40 insertions(+)
 create mode 100644 arch/sandbox/dts/.gitignore
 create mode 100644 arch/sandbox/dts/Makefile
 create mode 100644 arch/sandbox/dts/sandbox.dts
 create mode 100644 arch/sandbox/dts/skeleton.dtsi

diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index e3fb03955407..a539a901fc8d 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -50,4 +50,6 @@ cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(barebox-lds) \
 
 common-y += $(BOARD) arch/sandbox/os/
 
+common-$(CONFIG_OFTREE) += arch/sandbox/dts/
+
 CLEAN_FILES += $(BOARD)/barebox.lds
diff --git a/arch/sandbox/dts/.gitignore b/arch/sandbox/dts/.gitignore
new file mode 100644
index 000000000000..077903c50a26
--- /dev/null
+++ b/arch/sandbox/dts/.gitignore
@@ -0,0 +1 @@
+*dtb*
diff --git a/arch/sandbox/dts/Makefile b/arch/sandbox/dts/Makefile
new file mode 100644
index 000000000000..6f6838857849
--- /dev/null
+++ b/arch/sandbox/dts/Makefile
@@ -0,0 +1,11 @@
+ifeq ($(CONFIG_OFTREE),y)
+dtb-y += \
+	sandbox.dtb
+endif
+
+# just to build a built-in.o. Otherwise compilation fails when no devicetree is
+# created.
+obj- += dummy.o
+
+always := $(dtb-y)
+clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts
diff --git a/arch/sandbox/dts/sandbox.dts b/arch/sandbox/dts/sandbox.dts
new file mode 100644
index 000000000000..b4cb1d1dfc4d
--- /dev/null
+++ b/arch/sandbox/dts/sandbox.dts
@@ -0,0 +1,13 @@
+/dts-v1/;
+
+#include "skeleton.dtsi"
+
+/ {
+	aliases {
+		fd0 = &fd0;
+	};
+
+	fd0: fd@0 {
+		compatible = "barebox,hostfile";
+	};
+};
diff --git a/arch/sandbox/dts/skeleton.dtsi b/arch/sandbox/dts/skeleton.dtsi
new file mode 100644
index 000000000000..38ead821bb42
--- /dev/null
+++ b/arch/sandbox/dts/skeleton.dtsi
@@ -0,0 +1,13 @@
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
+ * add a compatible value.  The bootloader will typically populate the memory
+ * node.
+ */
+
+/ {
+	#address-cells = <2>;
+	#size-cells = <1>;
+	chosen { };
+	aliases { };
+	memory { device_type = "memory"; reg = <0 0 0>; };
+};
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 17/17] sandbox: activate OF support in defconfig
  2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (15 preceding siblings ...)
  2015-03-01 12:32 ` [PATCH v2 16/17] sandbox: add sample dts Marc Kleine-Budde
@ 2015-03-01 12:32 ` Marc Kleine-Budde
  16 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 12:32 UTC (permalink / raw)
  To: barebox

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 arch/sandbox/configs/sandbox_defconfig | 35 ++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/arch/sandbox/configs/sandbox_defconfig b/arch/sandbox/configs/sandbox_defconfig
index 7ce256950192..ec045f7c0b51 100644
--- a/arch/sandbox/configs/sandbox_defconfig
+++ b/arch/sandbox/configs/sandbox_defconfig
@@ -5,25 +5,36 @@ CONFIG_PARTITION=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
 CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/sandbox/board/env"
 CONFIG_DEBUG_INFO=y
-CONFIG_CMD_EDIT=y
-CONFIG_CMD_SLEEP=y
-CONFIG_CMD_SAVEENV=y
-CONFIG_CMD_EXPORT=y
-CONFIG_CMD_PRINTENV=y
-CONFIG_CMD_READLINE=y
-CONFIG_CMD_TFTP=y
+CONFIG_LONGHELP=y
 CONFIG_CMD_MEMINFO=y
-CONFIG_CMD_CRC=y
-CONFIG_CMD_FLASH=y
 # CONFIG_CMD_BOOTM is not set
-CONFIG_CMD_RESET=y
 CONFIG_CMD_GO=y
-CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_RESET=y
 CONFIG_CMD_PARTITION=y
-CONFIG_NET=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_SLEEP=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_2048=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_DISPLAY_TIMINGS=y
+CONFIG_CMD_OFTREE=y
+CONFIG_NET=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_NET_TAP=y
 # CONFIG_SPI is not set
+# CONFIG_PINCTRL is not set
 CONFIG_FS_CRAMFS=y
 CONFIG_FS_TFTP=y
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2015-03-01 12:33 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-01 12:32 [PATCH v2 00/17] general cleanups and sandbox OF integration Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 01/17] drivers: remove unused function dev_protect() Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 02/17] fs: make "offset" parameter of erase() and protect() 64 bit safe Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 03/17] of_path: of_find_path(): remove unused variable len Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 04/17] of/base: fix sparse warning, don't use interger 0 as NULL pointer Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 05/17] of: add no-op function for of_register_fixup() Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 06/17] of: add no-op functions for of_find_node_by_alias() and of_find_node_by_path_or_alias() Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 07/17] sandbox: fix indention in help text Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 08/17] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 09/17] sandbox: hostfile: clarify variable names Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 10/17] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 11/17] sandbox: hostfile: remove struct hf_platform_data from hf_priv Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 12/17] sandbox: hostfile: move fd from platform data to priv Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 13/17] sandbox: hostfile: probe driver earlier Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 14/17] sandbox: hostfile: use the memory resource to determine the size not the platform_data Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 15/17] sandbox: hostfile: add support for OF Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 16/17] sandbox: add sample dts Marc Kleine-Budde
2015-03-01 12:32 ` [PATCH v2 17/17] sandbox: activate OF support in defconfig Marc Kleine-Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox