mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] configure environment from devicetree
@ 2013-07-16 14:05 Sascha Hauer
  2013-07-16 14:05 ` [PATCH 01/10] of: partition: check for valid node Sascha Hauer
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:05 UTC (permalink / raw)
  To: barebox

This adds a driver which allows to configure the place where the
environment is stored from devicetree. The changes to the last
series I posted are:

- drop barebox specific partition driver and instead expect the
  partition nodes directly under the devicenode for the physical
  device.
- use /chosen instead of /chosen/barebox for barebox specific
  configuration drivers

Sascha

----------------------------------------------------------------
Sascha Hauer (10):
      of: partition: check for valid node
      of: Add convenience functions to en/disable devicenodes
      mtd: Add devicetree partition parsing
      mci: Add devicetree partition parsing
      Add configurability via devicetree
      ARM: i.MX Datamodul edmqx6: configure environment from devicetree
      ARM: i.MX51 babbage: configure environment from devicetree
      ARM: i.MX53 QSB: configure environment from devicetree
      ARM: i.MX51 efikasb: configure environment from devicetree
      ARM: i.MX6 tqma6x: configure environment from devicetree

 Documentation/devicetree/bindings/barebox.txt      |  10 ++
 .../bindings/barebox/barebox,environment.txt       |  25 ++++
 arch/arm/boards/dmo-mx6-realq7/board.c             |  26 ++--
 arch/arm/boards/efika-mx-smartbook/board.c         |  29 ++--
 arch/arm/boards/freescale-mx51-pdk/board.c         |   5 -
 arch/arm/boards/freescale-mx53-loco/board.c        |   4 -
 arch/arm/boards/tqma6x/board.c                     |   4 -
 arch/arm/configs/dmo-realq7_defconfig              |   1 +
 arch/arm/dts/imx51-babbage.dts                     |  12 ++
 arch/arm/dts/imx51-genesi-efika-sb.dts             |  26 ++++
 arch/arm/dts/imx53-qsb.dts                         |  12 ++
 arch/arm/dts/imx6dl-mba6x.dts                      |   5 +
 arch/arm/dts/imx6q-dmo-realq7.dts                  |  31 +++++
 arch/arm/dts/imx6q-mba6x.dts                       |   5 +
 drivers/mci/mci-core.c                             |   1 +
 drivers/mtd/core.c                                 |   1 +
 drivers/of/Kconfig                                 |   9 ++
 drivers/of/Makefile                                |   1 +
 drivers/of/barebox.c                               |  99 +++++++++++++
 drivers/of/base.c                                  |  65 +++++++++
 drivers/of/of_path.c                               | 155 +++++++++++++++++++++
 drivers/of/partition.c                             |   6 +
 include/of.h                                       |   7 +
 23 files changed, 491 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/barebox.txt
 create mode 100644 Documentation/devicetree/bindings/barebox/barebox,environment.txt
 create mode 100644 drivers/of/barebox.c
 create mode 100644 drivers/of/of_path.c

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

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

* [PATCH 01/10] of: partition: check for valid node
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
@ 2013-07-16 14:05 ` Sascha Hauer
  2013-07-16 14:05 ` [PATCH 02/10] of: Add convenience functions to en/disable devicenodes Sascha Hauer
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:05 UTC (permalink / raw)
  To: barebox

So that users can call the of partition parsers without checking
if they are probed from the devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/partition.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index d69251e..7199eff 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -34,6 +34,9 @@ struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node)
 	int len;
 	unsigned long flags = 0;
 
+	if (!node)
+		return NULL;
+
 	reg = of_get_property(node, "reg", &len);
 	if (!reg)
 		return NULL;
@@ -67,6 +70,9 @@ int of_parse_partitions(struct cdev *cdev, struct device_node *node)
 {
 	struct device_node *n;
 
+	if (!node)
+		return -EINVAL;
+
 	for_each_child_of_node(node, n) {
 		of_parse_partition(cdev, n);
 	}
-- 
1.8.3.2


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

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

* [PATCH 02/10] of: Add convenience functions to en/disable devicenodes
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
  2013-07-16 14:05 ` [PATCH 01/10] of: partition: check for valid node Sascha Hauer
@ 2013-07-16 14:05 ` Sascha Hauer
  2013-07-16 14:05 ` [PATCH 03/10] mtd: Add devicetree partition parsing Sascha Hauer
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:05 UTC (permalink / raw)
  To: barebox

These functions allow to manipulate the "status" property of
devicenodes effectively enabling/disabling devices.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/of/base.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/of.h      |  5 +++++
 2 files changed, 70 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7bee912..9559bff 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1752,3 +1752,68 @@ int of_add_initrd(struct device_node *root, resource_size_t start,
 
 	return 0;
 }
+
+/**
+ * of_device_enable - enable a devicenode device
+ * @node - the node to enable
+ *
+ * This deletes the status property of a devicenode effectively
+ * enabling the device.
+ */
+int of_device_enable(struct device_node *node)
+{
+	struct property *pp;
+
+	pp = of_find_property(node, "status", NULL);
+	if (!pp)
+		return 0;
+
+	of_delete_property(pp);
+
+	return 0;
+}
+
+/**
+ * of_device_enable_path - enable a devicenode
+ * @path - the nodepath to enable
+ *
+ * wrapper around of_device_enable taking the nodepath as argument
+ */
+int of_device_enable_path(const char *path)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path(path);
+	if (!node)
+		return -ENODEV;
+
+	return of_device_enable(node);
+}
+
+/**
+ * of_device_enable - disable a devicenode device
+ * @node - the node to disable
+ *
+ * This sets the status of a devicenode to "disabled"
+ */
+int of_device_disable(struct device_node *node)
+{
+	return of_set_property(node, "status", "disabled", sizeof("disabled"), 1);
+}
+
+/**
+ * of_device_disable_path - disable a devicenode
+ * @path - the nodepath to disable
+ *
+ * wrapper around of_device_disable taking the nodepath as argument
+ */
+int of_device_disable_path(const char *path)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path(path);
+	if (!node)
+		return -ENODEV;
+
+	return of_device_disable(node);
+}
diff --git a/include/of.h b/include/of.h
index 710383c..7b600f0 100644
--- a/include/of.h
+++ b/include/of.h
@@ -682,4 +682,9 @@ static inline int of_property_write_u64(struct device_node *np,
 
 extern const struct of_device_id of_default_bus_match_table[];
 
+int of_device_enable(struct device_node *node);
+int of_device_enable_path(const char *path);
+int of_device_disable(struct device_node *node);
+int of_device_disable_path(const char *path);
+
 #endif /* __OF_H */
-- 
1.8.3.2


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

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

* [PATCH 03/10] mtd: Add devicetree partition parsing
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
  2013-07-16 14:05 ` [PATCH 01/10] of: partition: check for valid node Sascha Hauer
  2013-07-16 14:05 ` [PATCH 02/10] of: Add convenience functions to en/disable devicenodes Sascha Hauer
@ 2013-07-16 14:05 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 04/10] mci: " Sascha Hauer
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:05 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mtd/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 37f4428..f46ab46 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -365,6 +365,7 @@ int add_mtd_device(struct mtd_info *mtd, char *devname)
 	}
 
 	devfs_create(&mtd->cdev);
+	of_parse_partitions(&mtd->cdev, mtd->parent->device_node);
 
 	list_for_each_entry(hook, &mtd_register_hooks, hook)
 		if (hook->add_mtd_device)
-- 
1.8.3.2


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

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

* [PATCH 04/10] mci: Add devicetree partition parsing
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (2 preceding siblings ...)
  2013-07-16 14:05 ` [PATCH 03/10] mtd: Add devicetree partition parsing Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 05/10] Add configurability via devicetree Sascha Hauer
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

MMC/SD cards normally have a DOS/GPT partition table, but sometimes
barebox uses the unpartitioned area to store its environment. Add
devicetree partition parsing also for SD/MMC cards so that we have
a way to describe the partition in the devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mci-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 02e6216..66ddb5b 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1558,6 +1558,7 @@ static int mci_card_probe(struct mci *mci)
 				dev_warn(&mci->dev, "No partition table found\n");
 				rc = 0; /* it's not a failure */
 			}
+			of_parse_partitions(&part->blk.cdev, host->hw_dev->device_node);
 		}
 
 		if (IS_ENABLED(CONFIG_MCI_MMC_BOOT_PARTITIONS) &&
-- 
1.8.3.2


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

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

* [PATCH 05/10] Add configurability via devicetree
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (3 preceding siblings ...)
  2013-07-16 14:06 ` [PATCH 04/10] mci: " Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 06/10] ARM: i.MX Datamodul edmqx6: configure environment from devicetree Sascha Hauer
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

This adds the possibility to configure the place for the environment
from the devicetree and to partition devices from the devicetree.

Configuration has the general form of devices with a regular compatible
property. This allows to later add additional drivers or drivers with
different behaviour (for example to add support for redundant environment).

The configuration is all in the /chosen/barebox/ hierarchy of the
devicetree. This separates the configuration from the hardware
description. Also it makes it possible to store the configuration
in a completely separate devicetree (or devicetree overlay). For
the same reason all configuration is done using nodepathes rather
than phandles.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/devicetree/bindings/barebox.txt      |  10 ++
 .../bindings/barebox/barebox,environment.txt       |  25 ++++
 drivers/of/Kconfig                                 |   9 ++
 drivers/of/Makefile                                |   1 +
 drivers/of/barebox.c                               |  99 +++++++++++++
 drivers/of/of_path.c                               | 155 +++++++++++++++++++++
 include/of.h                                       |   2 +
 7 files changed, 301 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/barebox.txt
 create mode 100644 Documentation/devicetree/bindings/barebox/barebox,environment.txt
 create mode 100644 drivers/of/barebox.c
 create mode 100644 drivers/of/of_path.c

diff --git a/Documentation/devicetree/bindings/barebox.txt b/Documentation/devicetree/bindings/barebox.txt
new file mode 100644
index 0000000..5e8d461
--- /dev/null
+++ b/Documentation/devicetree/bindings/barebox.txt
@@ -0,0 +1,10 @@
+barebox specific devicetree bindings
+====================================
+
+barebox uses some barebox specific devicetree bindings. All of these
+are under the /chosen/ hierarchy in the devicetree.
+
+The bindings have the form of a device with regular 'compatible' properties.
+drivers matching these devices do not handle physical devices but instead
+influence / configure certain behaviours of barebox like the place where to
+find the persistent environment.
diff --git a/Documentation/devicetree/bindings/barebox/barebox,environment.txt b/Documentation/devicetree/bindings/barebox/barebox,environment.txt
new file mode 100644
index 0000000..5a8bf9c
--- /dev/null
+++ b/Documentation/devicetree/bindings/barebox/barebox,environment.txt
@@ -0,0 +1,25 @@
+barebox environment
+===================
+
+This driver provides an environment for barebox from the devicetree.
+
+Required properties:
+- compatible: should be "barebox,environment"
+- device-path: path to the environment
+
+The device-path is a multistring property. The first string should be a
+nodepath to the node containing the physical device of the environment.
+The subsequent strings are of the form <type>:<options> to further describe
+the path to the environment. Supported values for <type>:
+
+partname:<partname>  This describes a partition on a device. <partname> can
+                     be the label for mtd partitions, the number for DOS
+		     partitions (beginning with 0) or the name for GPT
+		     partitions
+
+Example:
+
+environment@0 {
+	compatible = "barebox,environment";
+	device-path = &flash, "partname:barebox-environment";
+};
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 03ae599..ab5eac8 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -18,3 +18,12 @@ config OFDEVICE
 config OF_NET
 	depends on NET
 	def_bool y
+
+config OF_BAREBOX_DRIVERS
+	depends on OFDEVICE
+	bool "Enable barebox specific devicetree configuration drivers"
+	help
+	  barebox supports being configured from devicetree. This enables
+	  support for this feature. This currently allows to configure the
+	  environment path from devicetree and to partition devices. See
+	  Documentation/devicetree/bindings/barebox/ for more information.
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index e7d0733..97fea9d 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_OFTREE_MEM_GENERIC) += mem_generic.o
 obj-$(CONFIG_GPIOLIB) += of_gpio.o
 obj-y += partition.o
 obj-y += of_net.o
+obj-$(CONFIG_OF_BAREBOX_DRIVERS) += barebox.o of_path.o
diff --git a/drivers/of/barebox.c b/drivers/of/barebox.c
new file mode 100644
index 0000000..8977158
--- /dev/null
+++ b/drivers/of/barebox.c
@@ -0,0 +1,99 @@
+/*
+ * barebox.c
+ *
+ * Copyright (c) 2013 Sascha Hauer <s.hauer@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 <io.h>
+#include <of.h>
+#include <malloc.h>
+#include <partition.h>
+#include <envfs.h>
+
+struct of_partition {
+	struct list_head list;
+	char *nodepath;
+	struct device_d *dev;
+	struct device_node *of_partitions;
+};
+
+static LIST_HEAD(of_partition_list);
+
+struct device_d *of_find_device_by_node_path(const char *path)
+{
+	struct device_d *dev;
+
+	for_each_device(dev) {
+		if (!dev->device_node)
+			continue;
+		if (!strcmp(path, dev->device_node->full_name))
+			return dev;
+	}
+
+	return NULL;
+}
+
+static int environment_probe(struct device_d *dev)
+{
+	char *path;
+	int ret;
+
+	ret = of_find_path(dev->device_node, "device-path", &path);
+	if (ret)
+		return ret;
+
+	dev_info(dev, "setting default environment path to %s\n", path);
+
+	default_environment_path = path;
+
+	return 0;
+}
+
+static struct of_device_id environment_dt_ids[] = {
+	{
+		.compatible = "barebox,environment",
+	}, {
+		/* sentinel */
+	}
+};
+
+static struct driver_d environment_driver = {
+	.name		= "barebox-environment",
+	.probe		= environment_probe,
+	.of_compatible	= environment_dt_ids,
+};
+
+static int barebox_of_driver_init(void)
+{
+	struct device_node *node;
+
+	node = of_get_root_node();
+	if (!node)
+		return 0;
+
+	node = of_find_node_by_path("/chosen");
+	if (!node)
+		return 0;
+
+	of_platform_populate(node, of_default_bus_match_table, NULL);
+
+	platform_driver_register(&environment_driver);
+
+	return 0;
+}
+late_initcall(barebox_of_driver_init);
diff --git a/drivers/of/of_path.c b/drivers/of/of_path.c
new file mode 100644
index 0000000..ab8618e
--- /dev/null
+++ b/drivers/of/of_path.c
@@ -0,0 +1,155 @@
+/*
+ * of_path.c
+ *
+ * Copyright (c) 2013 Sascha Hauer <s.hauer@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 <malloc.h>
+#include <of.h>
+
+struct of_path {
+	struct cdev *cdev;
+	struct device_d *dev;
+};
+
+struct of_path_type {
+	const char *name;
+	int (*parse)(struct of_path *op, const char *str);
+};
+
+/**
+ * of_path_type_partname - find a partition based on physical device and
+ *                         partition name
+ * @op: of_path context
+ * @name: the partition name to find
+ */
+static int of_path_type_partname(struct of_path *op, const char *name)
+{
+	if (!op->dev)
+		return -EINVAL;
+
+	op->cdev = device_find_partition(op->dev, name);
+	if (op->cdev) {
+		pr_debug("%s: found part '%s'\n", __func__, name);
+		return 0;
+	} else {
+		pr_debug("%s: cannot find part '%s'\n", __func__, name);
+		return -ENODEV;
+	}
+}
+
+static struct of_path_type of_path_types[] = {
+	{
+		.name = "partname",
+		.parse = of_path_type_partname,
+	},
+};
+
+static int of_path_parse_one(struct of_path *op, const char *str)
+{
+	int i, ret;
+	char *name, *desc;
+
+	pr_debug("parsing: %s\n", str);
+
+	name = xstrdup(str);
+	desc = strchr(name, ':');
+	if (!desc) {
+		free(name);
+		return -EINVAL;
+	}
+
+	*desc = 0;
+	desc++;
+
+	for (i = 0; i < ARRAY_SIZE(of_path_types); i++) {
+		if (!strcmp(of_path_types[i].name, name)) {
+			ret = of_path_types[i].parse(op, desc);
+			goto out;
+		}
+	}
+
+	ret = -EINVAL;
+out:
+	free(name);
+
+	return ret;
+}
+
+/**
+ * of_find_path - translate a path description in the devicetree to a barebox
+ *                path
+ *
+ * @node: the node containing the property with the path description
+ * @propname: the property name of the path description
+ * @outpath: if this function returns 0 outpath will contain the path belonging
+ *           to the input path description. Must be freed with free().
+ *
+ * pathes in the devicetree have the form of a multistring property. The first
+ * string contains the full path to the physical device containing the path.
+ * The remaining strings have the form "<type>:<options>". Currently supported
+ * for <type> are:
+ *
+ * partname:<partname> - find a partition by its partition name. For mtd
+ *                       partitions this is the label. For DOS partitions
+ *                       this is the number beginning with 0.
+ *
+ * examples:
+ *
+ * device-path = &mmc0, "partname:0";
+ * device-path = &norflash, "partname:barebox-environment";
+ */
+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;
+
+	path = of_get_property(node, propname, &len);
+	if (!path)
+		return -EINVAL;
+
+	rnode = of_find_node_by_path(path);
+	if (!rnode)
+		return -ENODEV;
+
+	op.dev = of_find_device_by_node_path(rnode->full_name);
+	if (!op.dev)
+		return -ENODEV;
+
+	device_detect(op.dev);
+
+	i = 1;
+
+	while (1) {
+		ret = of_property_read_string_index(node, propname, i++, &str);
+		if (ret)
+			break;
+
+		ret = of_path_parse_one(&op, str);
+		if (ret)
+			return ret;
+	}
+
+	if (!op.cdev)
+		return -ENOENT;
+
+	*outpath = asprintf("/dev/%s", op.cdev->name);
+
+	return 0;
+}
diff --git a/include/of.h b/include/of.h
index 7b600f0..b99f0b2 100644
--- a/include/of.h
+++ b/include/of.h
@@ -229,6 +229,8 @@ void *of_flatten_dtb(struct device_node *node);
 int of_add_memory(struct device_node *node, bool dump);
 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);
 #else
 static inline int of_parse_partitions(struct cdev *cdev,
 					  struct device_node *node)
-- 
1.8.3.2


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

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

* [PATCH 06/10] ARM: i.MX Datamodul edmqx6: configure environment from devicetree
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (4 preceding siblings ...)
  2013-07-16 14:06 ` [PATCH 05/10] Add configurability via devicetree Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 07/10] ARM: i.MX51 babbage: " Sascha Hauer
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

This drops support for storing the environment in the eMMC,
but the standard bootsource is the SPI NOR flash.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/dmo-mx6-realq7/board.c | 26 ++++++++++----------------
 arch/arm/configs/dmo-realq7_defconfig  |  1 +
 arch/arm/dts/imx6q-dmo-realq7.dts      | 31 +++++++++++++++++++++++++++++++
 3 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/arch/arm/boards/dmo-mx6-realq7/board.c b/arch/arm/boards/dmo-mx6-realq7/board.c
index 9cf6c31..69d93f8 100644
--- a/arch/arm/boards/dmo-mx6-realq7/board.c
+++ b/arch/arm/boards/dmo-mx6-realq7/board.c
@@ -114,22 +114,6 @@ static int realq7_env_init(void)
 		BBU_HANDLER_FLAG_DEFAULT, NULL, 0, 0x00907000);
 	imx6_bbu_internal_mmc_register_handler("mmc", "/dev/mmc3.barebox",
 		0, NULL, 0, 0x00907000);
-
-	switch (bootsource_get()) {
-	case BOOTSOURCE_MMC:
-		device_detect_by_name("mmc3");
-		devfs_add_partition("mmc3", 0, SZ_1M, DEVFS_PARTITION_FIXED, "mmc3.barebox");
-		devfs_add_partition("mmc3", SZ_1M, SZ_1M, DEVFS_PARTITION_FIXED, "mmc3.bareboxenv");
-		default_environment_path = "/dev/mmc3.bareboxenv";
-		break;
-	default:
-	case BOOTSOURCE_SPI:
-		devfs_add_partition("m25p0", 0, SZ_256K, DEVFS_PARTITION_FIXED, "m25p0.barebox");
-		devfs_add_partition("m25p0", SZ_256K, SZ_256K, DEVFS_PARTITION_FIXED, "m25p0.bareboxenv");
-		default_environment_path = "/dev/m25p0.bareboxenv";
-		break;
-	}
-
 	return 0;
 }
 late_initcall(realq7_env_init);
@@ -141,6 +125,16 @@ static int realq7_console_init(void)
 
 	imx6_init_lowlevel();
 
+	switch (bootsource_get()) {
+	case BOOTSOURCE_MMC:
+		of_device_enable_path("/chosen/environment-emmc");
+		break;
+	default:
+	case BOOTSOURCE_SPI:
+		of_device_enable_path("/chosen/environment-spi");
+		break;
+	}
+
 	return 0;
 }
 postcore_initcall(realq7_console_init);
diff --git a/arch/arm/configs/dmo-realq7_defconfig b/arch/arm/configs/dmo-realq7_defconfig
index ab8aa43..501a182 100644
--- a/arch/arm/configs/dmo-realq7_defconfig
+++ b/arch/arm/configs/dmo-realq7_defconfig
@@ -71,6 +71,7 @@ CONFIG_NET_NFS=y
 CONFIG_NET_PING=y
 CONFIG_NET_RESOLV=y
 CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_NET_FEC_IMX=y
 CONFIG_DRIVER_SPI_IMX=y
 CONFIG_I2C=y
diff --git a/arch/arm/dts/imx6q-dmo-realq7.dts b/arch/arm/dts/imx6q-dmo-realq7.dts
index a33a700..672f15d 100644
--- a/arch/arm/dts/imx6q-dmo-realq7.dts
+++ b/arch/arm/dts/imx6q-dmo-realq7.dts
@@ -19,6 +19,18 @@
 
 	chosen {
 		linux,stdout-path = "/soc/aips-bus@02100000/serial@021e8000";
+
+		environment-emmc {
+			compatible = "barebox,environment";
+			device-path = &usdhc4, "partname:barebox-environment";
+			status = "disabled";
+		};
+
+		environment-spi {
+			compatible = "barebox,environment";
+			device-path = &flash, "partname:barebox-environment";
+			status = "disabled";
+		};
 	};
 
 	aliases {
@@ -87,6 +99,18 @@
 		compatible = "m25p80";
 		spi-max-frequency = <40000000>;
 		reg = <0>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "barebox";
+			reg = <0x0 0x80000>;
+		};
+
+		partition@1 {
+			label = "barebox-environment";
+			reg = <0x80000 0x20000>;
+		};
 	};
 };
 
@@ -351,4 +375,11 @@
 	non-removable;
 	bus-width = <8>;
 	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	partition@0 {
+		label = "barebox-environment";
+		reg = <0x0 0x80000>;
+	};
 };
-- 
1.8.3.2


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

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

* [PATCH 07/10] ARM: i.MX51 babbage: configure environment from devicetree
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (5 preceding siblings ...)
  2013-07-16 14:06 ` [PATCH 06/10] ARM: i.MX Datamodul edmqx6: configure environment from devicetree Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 08/10] ARM: i.MX53 QSB: " Sascha Hauer
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

While at it use offset 512k to allow bigger barebox binaries.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/freescale-mx51-pdk/board.c |  5 -----
 arch/arm/dts/imx51-babbage.dts             | 12 ++++++++++++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index 2e7be85..cafcf37 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -178,11 +178,6 @@ static int imx51_babbage_late_init(void)
 		BBU_HANDLER_FLAG_DEFAULT, (void *)flash_header_imx51_babbage_start,
 		flash_header_imx51_babbage_end - flash_header_imx51_babbage_start, 0);
 
-	device_detect_by_name("mmc0");
-
-	devfs_add_partition("mmc0", 0x00000, 0x40000, DEVFS_PARTITION_FIXED, "self0");
-	devfs_add_partition("mmc0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
-
 	return 0;
 }
 late_initcall(imx51_babbage_late_init);
diff --git a/arch/arm/dts/imx51-babbage.dts b/arch/arm/dts/imx51-babbage.dts
index 4950eef..4edbccb 100644
--- a/arch/arm/dts/imx51-babbage.dts
+++ b/arch/arm/dts/imx51-babbage.dts
@@ -19,6 +19,11 @@
 
 	chosen {
 		linux,stdout-path = "/soc/aips@70000000/serial@73fbc000";
+
+		environment@0 {
+			compatible = "barebox,environment";
+			device-path = &esdhc1, "partname:barebox-environment";
+		};
 	};
 
 	memory {
@@ -73,6 +78,13 @@
 	fsl,cd-controller;
 	fsl,wp-controller;
 	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	partition@0 {
+		label = "barebox-environment";
+		reg = <0x80000 0x20000>;
+	};
 };
 
 &esdhc2 {
-- 
1.8.3.2


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

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

* [PATCH 08/10] ARM: i.MX53 QSB: configure environment from devicetree
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (6 preceding siblings ...)
  2013-07-16 14:06 ` [PATCH 07/10] ARM: i.MX51 babbage: " Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 09/10] ARM: i.MX51 efikasb: " Sascha Hauer
  2013-07-16 14:06 ` [PATCH 10/10] ARM: i.MX6 tqma6x: " Sascha Hauer
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

While at it use offset 512k to allow bigger barebox binaries.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/freescale-mx53-loco/board.c |  4 ----
 arch/arm/dts/imx53-qsb.dts                  | 12 ++++++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boards/freescale-mx53-loco/board.c b/arch/arm/boards/freescale-mx53-loco/board.c
index 15dc591..7e8fc27 100644
--- a/arch/arm/boards/freescale-mx53-loco/board.c
+++ b/arch/arm/boards/freescale-mx53-loco/board.c
@@ -86,10 +86,6 @@ static int loco_late_init(void)
 	if (!of_machine_is_compatible("fsl,imx53-qsb"))
 		return 0;
 
-	device_detect_by_name("mmc0");
-
-	devfs_add_partition("mmc0", 0x40000, 0x20000, DEVFS_PARTITION_FIXED, "env0");
-
 	mc34708 = mc13xxx_get();
 	if (mc34708) {
 		/* get the board revision from fuse */
diff --git a/arch/arm/dts/imx53-qsb.dts b/arch/arm/dts/imx53-qsb.dts
index 1dfb48b..3be4ff2 100644
--- a/arch/arm/dts/imx53-qsb.dts
+++ b/arch/arm/dts/imx53-qsb.dts
@@ -19,6 +19,11 @@
 
 	chosen {
 		linux,stdout-path = "/soc/aips@50000000/serial@53fbc000";
+
+		environment@0 {
+			compatible = "barebox,environment";
+			device-path = &esdhc1, "partname:barebox-environment";
+		};
 	};
 
 	memory {
@@ -119,6 +124,13 @@
 	pinctrl-0 = <&pinctrl_esdhc1_1>;
 	cd-gpios = <&gpio3 13 0>;
 	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	partition@0 {
+		label = "barebox-environment";
+		reg = <0x80000 0x20000>;
+	};
 };
 
 &ssi2 {
-- 
1.8.3.2


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

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

* [PATCH 09/10] ARM: i.MX51 efikasb: configure environment from devicetree
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (7 preceding siblings ...)
  2013-07-16 14:06 ` [PATCH 08/10] ARM: i.MX53 QSB: " Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  2013-07-16 14:06 ` [PATCH 10/10] ARM: i.MX6 tqma6x: " Sascha Hauer
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/efika-mx-smartbook/board.c | 29 ++++++++++-------------------
 arch/arm/dts/imx51-genesi-efika-sb.dts     | 26 ++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 19 deletions(-)

diff --git a/arch/arm/boards/efika-mx-smartbook/board.c b/arch/arm/boards/efika-mx-smartbook/board.c
index 1735c3e..85ff466 100644
--- a/arch/arm/boards/efika-mx-smartbook/board.c
+++ b/arch/arm/boards/efika-mx-smartbook/board.c
@@ -210,6 +210,16 @@ static int efikamx_usb_init(void)
 		mxc_iomux_v3_setup_pad(MX51_PAD_EIM_A26__USBH2_STP);
 	}
 
+	switch (bootsource_get()) {
+	case BOOTSOURCE_MMC:
+		of_device_enable_path("/chosen/environment-sd");
+		break;
+	case BOOTSOURCE_SPI:
+	default:
+		of_device_enable_path("/chosen/environment-spi");
+		break;
+	}
+
 	return 0;
 }
 console_initcall(efikamx_usb_init);
@@ -230,7 +240,6 @@ extern char flash_header_imx51_genesi_efikasb_end[];
 
 static int efikamx_late_init(void)
 {
-	enum bootsource bootsource;
 	int i;
 
 	if (!of_machine_is_compatible("genesi,imx51-sb"))
@@ -255,24 +264,6 @@ static int efikamx_late_init(void)
 	armlinux_set_architecture(2370);
 	armlinux_set_revision(0x5100 | imx_silicon_revision());
 
-	bootsource = bootsource_get();
-
-	switch (bootsource) {
-	case BOOTSOURCE_MMC:
-		device_detect_by_name("mmc1");
-
-		devfs_add_partition("mmc1", 0x00000, 0x80000,
-				DEVFS_PARTITION_FIXED, "self0");
-		devfs_add_partition("mmc1", 0x80000, 0x80000,
-				DEVFS_PARTITION_FIXED, "env0");
-		break;
-	case BOOTSOURCE_SPI:
-	default:
-		devfs_add_partition("m25p0", 0x80000, 0x20000,
-				DEVFS_PARTITION_FIXED, "env0");
-		break;
-	}
-
 	return 0;
 }
 late_initcall(efikamx_late_init);
diff --git a/arch/arm/dts/imx51-genesi-efika-sb.dts b/arch/arm/dts/imx51-genesi-efika-sb.dts
index dc92b2a..21b7c7e 100644
--- a/arch/arm/dts/imx51-genesi-efika-sb.dts
+++ b/arch/arm/dts/imx51-genesi-efika-sb.dts
@@ -18,6 +18,18 @@
 
 	chosen {
 		linux,stdout-path = "/soc/aips@70000000/serial@73fbc000";
+
+		environment-sd {
+			compatible = "barebox,environment";
+			device-path = &esdhc2, "partname:barebox-environment";
+			status = "disabled";
+		};
+
+		environment-spi {
+			compatible = "barebox,environment";
+			device-path = &flash, "partname:barebox-environment";
+			status = "disabled";
+		};
 	};
 
 	memory {
@@ -178,6 +190,13 @@
 	cd-gpios = <&gpio1 8 0>;
 	wp-gpios = <&gpio1 7 0>;
 	status = "okay";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	partition@0 {
+		label = "barebox-environment";
+		reg = <0x80000 0x80000>;
+	};
 };
 
 &ecspi1 {
@@ -290,6 +309,13 @@
 		compatible = "sst,sst25vf032b", "m25p80";
 		spi-max-frequency = <15000000>;
 		reg = <1>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "barebox-environment";
+			reg = <0x80000 0x80000>;
+		};
 	};
 };
 
-- 
1.8.3.2


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

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

* [PATCH 10/10] ARM: i.MX6 tqma6x: configure environment from devicetree
  2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
                   ` (8 preceding siblings ...)
  2013-07-16 14:06 ` [PATCH 09/10] ARM: i.MX51 efikasb: " Sascha Hauer
@ 2013-07-16 14:06 ` Sascha Hauer
  9 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2013-07-16 14:06 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/tqma6x/board.c | 4 ----
 arch/arm/dts/imx6dl-mba6x.dts  | 5 +++++
 arch/arm/dts/imx6q-mba6x.dts   | 5 +++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boards/tqma6x/board.c b/arch/arm/boards/tqma6x/board.c
index 9e81a1d..7878cc6 100644
--- a/arch/arm/boards/tqma6x/board.c
+++ b/arch/arm/boards/tqma6x/board.c
@@ -134,10 +134,6 @@ static int tqma6x_env_init(void)
 	imx6_bbu_internal_mmc_register_handler("emmc", "/dev/mmc2.boot0",
 		0, (void *)flash_header_start, flash_header_end - flash_header_start, 0);
 
-	device_detect_by_name("mmc2");
-
-	default_environment_path = "/dev/mmc2.boot1";
-
 	return 0;
 }
 late_initcall(tqma6x_env_init);
diff --git a/arch/arm/dts/imx6dl-mba6x.dts b/arch/arm/dts/imx6dl-mba6x.dts
index 7840f06..9e4b95f 100644
--- a/arch/arm/dts/imx6dl-mba6x.dts
+++ b/arch/arm/dts/imx6dl-mba6x.dts
@@ -19,6 +19,11 @@
 
 	chosen {
 		linux,stdout-path = &uart2;
+
+		environment-emmc {
+			compatible = "barebox,environment";
+			device-path = &usdhc3, "partname:boot1";
+		};
 	};
 
 	memory {
diff --git a/arch/arm/dts/imx6q-mba6x.dts b/arch/arm/dts/imx6q-mba6x.dts
index f2ca177..5bf1405 100644
--- a/arch/arm/dts/imx6q-mba6x.dts
+++ b/arch/arm/dts/imx6q-mba6x.dts
@@ -19,6 +19,11 @@
 
 	chosen {
 		linux,stdout-path = &uart2;
+
+		environment-emmc {
+			compatible = "barebox,environment";
+			device-path = &usdhc3, "partname:boot1";
+		};
 	};
 
 	memory {
-- 
1.8.3.2


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

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

end of thread, other threads:[~2013-07-16 14:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-16 14:05 [PATCH] configure environment from devicetree Sascha Hauer
2013-07-16 14:05 ` [PATCH 01/10] of: partition: check for valid node Sascha Hauer
2013-07-16 14:05 ` [PATCH 02/10] of: Add convenience functions to en/disable devicenodes Sascha Hauer
2013-07-16 14:05 ` [PATCH 03/10] mtd: Add devicetree partition parsing Sascha Hauer
2013-07-16 14:06 ` [PATCH 04/10] mci: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 05/10] Add configurability via devicetree Sascha Hauer
2013-07-16 14:06 ` [PATCH 06/10] ARM: i.MX Datamodul edmqx6: configure environment from devicetree Sascha Hauer
2013-07-16 14:06 ` [PATCH 07/10] ARM: i.MX51 babbage: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 08/10] ARM: i.MX53 QSB: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 09/10] ARM: i.MX51 efikasb: " Sascha Hauer
2013-07-16 14:06 ` [PATCH 10/10] ARM: i.MX6 tqma6x: " Sascha Hauer

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