mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* general cleanups and sandbox OF integration
@ 2015-02-28 21:40 Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 01/16] drivers: remove unused function dev_protect() Marc Kleine-Budde
                   ` (15 more replies)
  0 siblings, 16 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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


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

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

* [PATCH 01/16] drivers: remove unused function dev_protect()
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 02/16] fs: make "offset" parameter of erase() and protect() 64 bit safe Marc Kleine-Budde
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 02/16] fs: make "offset" parameter of erase() and protect() 64 bit safe
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 01/16] drivers: remove unused function dev_protect() Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 03/16] of_path: of_find_path(): remove unused variable len Marc Kleine-Budde
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 03/16] of_path: of_find_path(): remove unused variable len
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 01/16] drivers: remove unused function dev_protect() Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 02/16] fs: make "offset" parameter of erase() and protect() 64 bit safe Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 04/16] of: make first argument of several of_property_*_string functions const Marc Kleine-Budde
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 04/16] of: make first argument of several of_property_*_string functions const
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (2 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 03/16] of_path: of_find_path(): remove unused variable len Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-03-01  7:27   ` Sascha Hauer
  2015-02-28 21:40 ` [PATCH 05/16] of/base: fix sparse warning, don't use interger 0 as NULL pointer Marc Kleine-Budde
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 UTC (permalink / raw)
  To: barebox

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

diff --git a/drivers/of/base.c b/drivers/of/base.c
index af10fd1da32c..4b5d4d75f19c 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -799,7 +799,7 @@ EXPORT_SYMBOL_GPL(of_property_read_u64);
  *
  * The out_string pointer is modified only if a valid string can be decoded.
  */
-int of_property_read_string(struct device_node *np, const char *propname,
+int of_property_read_string(const struct device_node *np, const char *propname,
 				const char **out_string)
 {
 	struct property *prop = of_find_property(np, propname, NULL);
@@ -832,7 +832,7 @@ EXPORT_SYMBOL_GPL(of_property_read_string);
  *
  * The out_string pointer is modified only if a valid string can be decoded.
  */
-int of_property_read_string_index(struct device_node *np, const char *propname,
+int of_property_read_string_index(const struct device_node *np, const char *propname,
 				  int index, const char **output)
 {
 	struct property *prop = of_find_property(np, propname, NULL);
@@ -869,7 +869,7 @@ EXPORT_SYMBOL_GPL(of_property_read_string_index);
  * This function searches a string list property and returns the index
  * of a specific string value.
  */
-int of_property_match_string(struct device_node *np, const char *propname,
+int of_property_match_string(const struct device_node *np, const char *propname,
 			     const char *string)
 {
 	struct property *prop = of_find_property(np, propname, NULL);
@@ -909,7 +909,7 @@ EXPORT_SYMBOL_GPL(of_property_match_string);
  * does not have a value, and -EILSEQ if the string is not null-terminated
  * within the length of the property data.
  */
-int of_property_count_strings(struct device_node *np, const char *propname)
+int of_property_count_strings(const struct device_node *np, const char *propname)
 {
 	struct property *prop = of_find_property(np, propname, NULL);
 	int i = 0;
diff --git a/include/of.h b/include/of.h
index 2ad941864f5d..4019b927aa98 100644
--- a/include/of.h
+++ b/include/of.h
@@ -171,16 +171,16 @@ extern int of_property_read_u32_array(const struct device_node *np,
 extern int of_property_read_u64(const struct device_node *np,
 				const char *propname, u64 *out_value);
 
-extern int of_property_read_string(struct device_node *np,
+extern int of_property_read_string(const struct device_node *np,
 				   const char *propname,
 				   const char **out_string);
-extern int of_property_read_string_index(struct device_node *np,
+extern int of_property_read_string_index(const struct device_node *np,
 					 const char *propname,
 					 int index, const char **output);
-extern int of_property_match_string(struct device_node *np,
+extern int of_property_match_string(const struct device_node *np,
 				    const char *propname,
 				    const char *string);
-extern int of_property_count_strings(struct device_node *np,
+extern int of_property_count_strings(const struct device_node *np,
 				     const char *propname);
 
 extern const __be32 *of_prop_next_u32(struct property *prop,
@@ -373,25 +373,25 @@ static inline int of_property_read_u64(const struct device_node *np,
 	return -ENOSYS;
 }
 
-static inline int of_property_read_string(struct device_node *np,
+static inline int of_property_read_string(const struct device_node *np,
 				const char *propname, const char **out_string)
 {
 	return -ENOSYS;
 }
 
-static inline int of_property_read_string_index(struct device_node *np,
+static inline int of_property_read_string_index(const struct device_node *np,
 			 const char *propname, int index, const char **output)
 {
 	return -ENOSYS;
 }
 
-static inline int of_property_match_string(struct device_node *np,
+static inline int of_property_match_string(const struct device_node *np,
 				const char *propname, const char *string)
 {
 	return -ENOSYS;
 }
 
-static inline int of_property_count_strings(struct device_node *np,
+static inline int of_property_count_strings(const struct device_node *np,
 					const char *propname)
 {
 	return -ENOSYS;
-- 
2.1.4


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

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

* [PATCH 05/16] of/base: fix sparse warning, don't use interger 0 as NULL pointer
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (3 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 04/16] of: make first argument of several of_property_*_string functions const Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 06/16] sandbox: fix indention in help text Marc Kleine-Budde
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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 4b5d4d75f19c..0cffb962e637 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] 21+ messages in thread

* [PATCH 06/16] sandbox: fix indention in help text
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (4 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 05/16] of/base: fix sparse warning, don't use interger 0 as NULL pointer Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 07/16] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 07/16] sandbox: add support to pass dtb to barebox
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (5 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 06/16] sandbox: fix indention in help text Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-03-01  7:33   ` Sascha Hauer
  2015-02-28 21:40 ` [PATCH 08/16] sandbox: hostfile: clarify variable names Marc Kleine-Budde
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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 |  1 +
 arch/sandbox/os/common.c                       | 47 ++++++++++++++++++++-
 4 files changed, 105 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..460116332df9 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-y += 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..28d5017a4e4b 100644
--- a/arch/sandbox/mach-sandbox/include/mach/linux.h
+++ b/arch/sandbox/mach-sandbox/include/mach/linux.h
@@ -19,6 +19,7 @@ int linux_tstc(int fd);
 int linux_execve(const char * filename, char *const argv[], char *const envp[]);
 
 int barebox_register_console(char *name_template, int stdinfd, int stdoutfd);
+int barebox_register_dtb(const void *dtb);
 
 struct linux_console_data {
 	int stdinfd;
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] 21+ messages in thread

* [PATCH 08/16] sandbox: hostfile: clarify variable names
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (6 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 07/16] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 09/16] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev Marc Kleine-Budde
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 09/16] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (7 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 08/16] sandbox: hostfile: clarify variable names Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 10/16] sandbox: hostfile: remove struct hf_platform_data from hf_priv Marc Kleine-Budde
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 10/16] sandbox: hostfile: remove struct hf_platform_data from hf_priv
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (8 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 09/16] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 11/16] sandbox: hostfile: move fd from platform data to priv Marc Kleine-Budde
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 11/16] sandbox: hostfile: move fd from platform data to priv
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (9 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 10/16] sandbox: hostfile: remove struct hf_platform_data from hf_priv Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 12/16] sandbox: hostfile: probe driver earlier Marc Kleine-Budde
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 12/16] sandbox: hostfile: probe driver earlier
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (10 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 11/16] sandbox: hostfile: move fd from platform data to priv Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 13/16] sandbox: hostfile: use the memory resource to determine the size not the platform_data Marc Kleine-Budde
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 13/16] sandbox: hostfile: use the memory resource to determine the size not the platform_data
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (11 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 12/16] sandbox: hostfile: probe driver earlier Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 14/16] sandbox: hostfile: add support for OF Marc Kleine-Budde
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 14/16] sandbox: hostfile: add support for OF
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (12 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 13/16] sandbox: hostfile: use the memory resource to determine the size not the platform_data Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 15/16] sandbox: add sample dts Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 16/16] sandbox: activate OF support in defconfig Marc Kleine-Budde
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 15/16] sandbox: add sample dts
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (13 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 14/16] sandbox: hostfile: add support for OF Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  2015-02-28 21:40 ` [PATCH 16/16] sandbox: activate OF support in defconfig Marc Kleine-Budde
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* [PATCH 16/16] sandbox: activate OF support in defconfig
  2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
                   ` (14 preceding siblings ...)
  2015-02-28 21:40 ` [PATCH 15/16] sandbox: add sample dts Marc Kleine-Budde
@ 2015-02-28 21:40 ` Marc Kleine-Budde
  15 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-02-28 21:40 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] 21+ messages in thread

* Re: [PATCH 04/16] of: make first argument of several of_property_*_string functions const
  2015-02-28 21:40 ` [PATCH 04/16] of: make first argument of several of_property_*_string functions const Marc Kleine-Budde
@ 2015-03-01  7:27   ` Sascha Hauer
  2015-03-01 10:47     ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Sascha Hauer @ 2015-03-01  7:27 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On Sat, Feb 28, 2015 at 10:40:09PM +0100, Marc Kleine-Budde wrote:
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/of/base.c |  8 ++++----
>  include/of.h      | 16 ++++++++--------
>  2 files changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index af10fd1da32c..4b5d4d75f19c 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -799,7 +799,7 @@ EXPORT_SYMBOL_GPL(of_property_read_u64);
>   *
>   * The out_string pointer is modified only if a valid string can be decoded.
>   */
> -int of_property_read_string(struct device_node *np, const char *propname,
> +int of_property_read_string(const struct device_node *np, const char *propname,
>  				const char **out_string)

Is this necessary for something or just a nice to have? The functions
are takes from the kernel and the device_node arguments cannot be const
there because the functions take a reference on the node.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 07/16] sandbox: add support to pass dtb to barebox
  2015-02-28 21:40 ` [PATCH 07/16] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
@ 2015-03-01  7:33   ` Sascha Hauer
  2015-03-01 10:46     ` Marc Kleine-Budde
  0 siblings, 1 reply; 21+ messages in thread
From: Sascha Hauer @ 2015-03-01  7:33 UTC (permalink / raw)
  To: Marc Kleine-Budde; +Cc: barebox

On Sat, Feb 28, 2015 at 10:40:12PM +0100, Marc Kleine-Budde wrote:
> 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 |  1 +
>  arch/sandbox/os/common.c                       | 47 ++++++++++++++++++++-
>  4 files changed, 105 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..460116332df9 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-y += 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);

of_unflatten_dtb is only defined when CONFIG_OFTREE is enabled. I see
nothing in this patch selectin this option or depending on this option.
Does this compile with device tree support disabled?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

* Re: [PATCH 07/16] sandbox: add support to pass dtb to barebox
  2015-03-01  7:33   ` Sascha Hauer
@ 2015-03-01 10:46     ` Marc Kleine-Budde
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 10:46 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 851 bytes --]

On 03/01/2015 08:33 AM, Sascha Hauer wrote:
[...]
>> +	root = of_unflatten_dtb(dtb);
> 
> of_unflatten_dtb is only defined when CONFIG_OFTREE is enabled. I see
> nothing in this patch selectin this option or depending on this option.
> Does this compile with device tree support disabled?

Doh! - Now it does.

I'm left with:

> undefined reference to `of_find_node_by_alias'
> undefined reference to `of_register_fixup'

because they have no NOOPs in case if !CONFIG_OFTREE. I'll add them in a
separate patch, to avoid having ifdefs in the C code.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

* Re: [PATCH 04/16] of: make first argument of several of_property_*_string functions const
  2015-03-01  7:27   ` Sascha Hauer
@ 2015-03-01 10:47     ` Marc Kleine-Budde
  0 siblings, 0 replies; 21+ messages in thread
From: Marc Kleine-Budde @ 2015-03-01 10:47 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 790 bytes --]

On 03/01/2015 08:27 AM, Sascha Hauer wrote:
>> -int of_property_read_string(struct device_node *np, const char *propname,
>> +int of_property_read_string(const struct device_node *np, const char *propname,
>>  				const char **out_string)
> 
> Is this necessary for something or just a nice to have? The functions
> are takes from the kernel and the device_node arguments cannot be const
> there because the functions take a reference on the node.

I see, I'll remove the patch and adopt my code.

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

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

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

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

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-28 21:40 general cleanups and sandbox OF integration Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 01/16] drivers: remove unused function dev_protect() Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 02/16] fs: make "offset" parameter of erase() and protect() 64 bit safe Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 03/16] of_path: of_find_path(): remove unused variable len Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 04/16] of: make first argument of several of_property_*_string functions const Marc Kleine-Budde
2015-03-01  7:27   ` Sascha Hauer
2015-03-01 10:47     ` Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 05/16] of/base: fix sparse warning, don't use interger 0 as NULL pointer Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 06/16] sandbox: fix indention in help text Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 07/16] sandbox: add support to pass dtb to barebox Marc Kleine-Budde
2015-03-01  7:33   ` Sascha Hauer
2015-03-01 10:46     ` Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 08/16] sandbox: hostfile: clarify variable names Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 09/16] sandbox: hostfile: probe(): add missing pointer from cdev.dev to dev Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 10/16] sandbox: hostfile: remove struct hf_platform_data from hf_priv Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 11/16] sandbox: hostfile: move fd from platform data to priv Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 12/16] sandbox: hostfile: probe driver earlier Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 13/16] sandbox: hostfile: use the memory resource to determine the size not the platform_data Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 14/16] sandbox: hostfile: add support for OF Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 15/16] sandbox: add sample dts Marc Kleine-Budde
2015-02-28 21:40 ` [PATCH 16/16] 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