* [PATCH 0/5] dt: Device creation infrastructure
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Benjamin Herrenschmidt, Russell King, Arnd Bergmann
This series adds infrastructure for generating platform and amba
devices based on device tree data. I intend to queue up this series
for the v3.1 merge window. I had already posted these patches earlier
in the "Full device tree support for ARM Versatile" RFC series. They
haven't changed since I posted that.
Unless I hear otherwise, I'll put the first 4 patches into
devicetree/next later this week. The fifth patch can either go via
devicetree/next or benh's powerpc tree (your choice Ben).
g.
---
Grant Likely (5):
dt: Add default match table for bus ids
dt: add of_platform_populate() for creating device from the device tree
drivers/amba: create devices from device tree
dt/platform: allow device name to be overridden
powerpc/5200: convert mpc5200 to use of_platform_populate()
.../devicetree/bindings/arm/primecell.txt | 21 ++
arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 -
drivers/of/platform.c | 196 +++++++++++++++++++-
include/linux/of_platform.h | 40 ++++
4 files changed, 252 insertions(+), 15 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 0/5] dt: Device creation infrastructure
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Russell King, Arnd Bergmann
This series adds infrastructure for generating platform and amba
devices based on device tree data. I intend to queue up this series
for the v3.1 merge window. I had already posted these patches earlier
in the "Full device tree support for ARM Versatile" RFC series. They
haven't changed since I posted that.
Unless I hear otherwise, I'll put the first 4 patches into
devicetree/next later this week. The fifth patch can either go via
devicetree/next or benh's powerpc tree (your choice Ben).
g.
---
Grant Likely (5):
dt: Add default match table for bus ids
dt: add of_platform_populate() for creating device from the device tree
drivers/amba: create devices from device tree
dt/platform: allow device name to be overridden
powerpc/5200: convert mpc5200 to use of_platform_populate()
.../devicetree/bindings/arm/primecell.txt | 21 ++
arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 -
drivers/of/platform.c | 196 +++++++++++++++++++-
include/linux/of_platform.h | 40 ++++
4 files changed, 252 insertions(+), 15 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 0/5] dt: Device creation infrastructure
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: linux-arm-kernel
This series adds infrastructure for generating platform and amba
devices based on device tree data. I intend to queue up this series
for the v3.1 merge window. I had already posted these patches earlier
in the "Full device tree support for ARM Versatile" RFC series. They
haven't changed since I posted that.
Unless I hear otherwise, I'll put the first 4 patches into
devicetree/next later this week. The fifth patch can either go via
devicetree/next or benh's powerpc tree (your choice Ben).
g.
---
Grant Likely (5):
dt: Add default match table for bus ids
dt: add of_platform_populate() for creating device from the device tree
drivers/amba: create devices from device tree
dt/platform: allow device name to be overridden
powerpc/5200: convert mpc5200 to use of_platform_populate()
.../devicetree/bindings/arm/primecell.txt | 21 ++
arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 -
drivers/of/platform.c | 196 +++++++++++++++++++-
include/linux/of_platform.h | 40 ++++
4 files changed, 252 insertions(+), 15 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 1/5] dt: Add default match table for bus ids
2011-06-21 18:44 ` Grant Likely
(?)
@ 2011-06-21 18:44 ` Grant Likely
-1 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Benjamin Herrenschmidt, Russell King, Arnd Bergmann
No need for most platforms to define their own bus table when calling
of_platform_populate(). Supply a stock one.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 8 ++++++++
include/linux/of_platform.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 63d3cb7..bb483ef 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -22,6 +22,14 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+const struct of_device_id of_default_bus_match_table[] = {
+ { .compatible = "simple-bus", },
+#ifdef CONFIG_ARM_AMBA
+ { .compatible = "arm,amba-bus", },
+#endif /* CONFIG_ARM_AMBA */
+ {} /* Empty terminated list */
+};
+
static int of_dev_node_match(struct device *dev, void *data)
{
return dev->of_node == data;
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index fb51ae3..8f023f8 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -40,6 +40,8 @@ struct of_platform_driver
#define to_of_platform_driver(drv) \
container_of(drv,struct of_platform_driver, driver)
+extern const struct of_device_id of_default_bus_match_table[];
+
/* Platform drivers register/unregister */
extern struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 1/5] dt: Add default match table for bus ids
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Russell King, Arnd Bergmann
No need for most platforms to define their own bus table when calling
of_platform_populate(). Supply a stock one.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 8 ++++++++
include/linux/of_platform.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 63d3cb7..bb483ef 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -22,6 +22,14 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+const struct of_device_id of_default_bus_match_table[] = {
+ { .compatible = "simple-bus", },
+#ifdef CONFIG_ARM_AMBA
+ { .compatible = "arm,amba-bus", },
+#endif /* CONFIG_ARM_AMBA */
+ {} /* Empty terminated list */
+};
+
static int of_dev_node_match(struct device *dev, void *data)
{
return dev->of_node == data;
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index fb51ae3..8f023f8 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -40,6 +40,8 @@ struct of_platform_driver
#define to_of_platform_driver(drv) \
container_of(drv,struct of_platform_driver, driver)
+extern const struct of_device_id of_default_bus_match_table[];
+
/* Platform drivers register/unregister */
extern struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 1/5] dt: Add default match table for bus ids
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: linux-arm-kernel
No need for most platforms to define their own bus table when calling
of_platform_populate(). Supply a stock one.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 8 ++++++++
include/linux/of_platform.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 63d3cb7..bb483ef 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -22,6 +22,14 @@
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+const struct of_device_id of_default_bus_match_table[] = {
+ { .compatible = "simple-bus", },
+#ifdef CONFIG_ARM_AMBA
+ { .compatible = "arm,amba-bus", },
+#endif /* CONFIG_ARM_AMBA */
+ {} /* Empty terminated list */
+};
+
static int of_dev_node_match(struct device *dev, void *data)
{
return dev->of_node == data;
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index fb51ae3..8f023f8 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -40,6 +40,8 @@ struct of_platform_driver
#define to_of_platform_driver(drv) \
container_of(drv,struct of_platform_driver, driver)
+extern const struct of_device_id of_default_bus_match_table[];
+
/* Platform drivers register/unregister */
extern struct platform_device *of_device_alloc(struct device_node *np,
const char *bus_id,
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 2/5] dt: add of_platform_populate() for creating device from the device tree
2011-06-21 18:44 ` Grant Likely
(?)
@ 2011-06-21 18:44 ` Grant Likely
-1 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Benjamin Herrenschmidt, Russell King, Arnd Bergmann
of_platform_populate() is similar to of_platform_bus_probe() except
that it strictly enforces that all device nodes must have a compatible
property, and it can be used to register devices (not buses) which are
children of the root node.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 54 ++++++++++++++++++++++++++++++++++++++++---
include/linux/of_platform.h | 3 ++
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index bb483ef..1f4a5d3 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -229,19 +229,26 @@ EXPORT_SYMBOL(of_platform_device_create);
*/
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
- struct device *parent)
+ struct device *parent, bool strict)
{
struct device_node *child;
struct platform_device *dev;
int rc = 0;
+ /* Make sure it has a compatible property */
+ if (strict && (!of_get_property(bus, "compatible", NULL))) {
+ pr_debug("%s() - skipping %s, no compatible prop\n",
+ __func__, bus->full_name);
+ return 0;
+ }
+
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
- rc = of_platform_bus_create(child, matches, &dev->dev);
+ rc = of_platform_bus_create(child, matches, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
@@ -275,11 +282,11 @@ int of_platform_bus_probe(struct device_node *root,
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
- rc = of_platform_bus_create(root, matches, parent);
+ rc = of_platform_bus_create(root, matches, parent, false);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
- rc = of_platform_bus_create(child, matches, parent);
+ rc = of_platform_bus_create(child, matches, parent, false);
if (rc)
break;
}
@@ -288,4 +295,43 @@ int of_platform_bus_probe(struct device_node *root,
return rc;
}
EXPORT_SYMBOL(of_platform_bus_probe);
+
+/**
+ * of_platform_populate() - Populate platform_devices from device tree data
+ * @root: parent of the first level to probe or NULL for the root of the tree
+ * @matches: match table, NULL to use the default
+ * @parent: parent to hook devices from, NULL for toplevel
+ *
+ * Similar to of_platform_bus_probe(), this function walks the device tree
+ * and creates devices from nodes. It differs in that it follows the modern
+ * convention of requiring all device nodes to have a 'compatible' property,
+ * and it is suitable for creating devices which are children of the root
+ * node (of_platform_bus_probe will only create children of the root which
+ * are selected by the @matches argument).
+ *
+ * New board support should be using this function instead of
+ * of_platform_bus_probe().
+ *
+ * Returns 0 on success, < 0 on failure.
+ */
+int of_platform_populate(struct device_node *root,
+ const struct of_device_id *matches,
+ struct device *parent)
+{
+ struct device_node *child;
+ int rc = 0;
+
+ root = root ? of_node_get(root) : of_find_node_by_path("/");
+ if (!root)
+ return -EINVAL;
+
+ for_each_child_of_node(root, child) {
+ rc = of_platform_bus_create(child, matches, parent, true);
+ if (rc)
+ break;
+ }
+
+ of_node_put(root);
+ return rc;
+}
#endif /* !CONFIG_SPARC */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 8f023f8..8390233 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -57,6 +57,9 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
extern int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches,
struct device *parent);
+extern int of_platform_populate(struct device_node *root,
+ const struct of_device_id *matches,
+ struct device *parent);
#endif /* !CONFIG_SPARC */
#endif /* CONFIG_OF_DEVICE */
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 2/5] dt: add of_platform_populate() for creating device from the device tree
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Russell King, Arnd Bergmann
of_platform_populate() is similar to of_platform_bus_probe() except
that it strictly enforces that all device nodes must have a compatible
property, and it can be used to register devices (not buses) which are
children of the root node.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 54 ++++++++++++++++++++++++++++++++++++++++---
include/linux/of_platform.h | 3 ++
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index bb483ef..1f4a5d3 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -229,19 +229,26 @@ EXPORT_SYMBOL(of_platform_device_create);
*/
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
- struct device *parent)
+ struct device *parent, bool strict)
{
struct device_node *child;
struct platform_device *dev;
int rc = 0;
+ /* Make sure it has a compatible property */
+ if (strict && (!of_get_property(bus, "compatible", NULL))) {
+ pr_debug("%s() - skipping %s, no compatible prop\n",
+ __func__, bus->full_name);
+ return 0;
+ }
+
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
- rc = of_platform_bus_create(child, matches, &dev->dev);
+ rc = of_platform_bus_create(child, matches, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
@@ -275,11 +282,11 @@ int of_platform_bus_probe(struct device_node *root,
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
- rc = of_platform_bus_create(root, matches, parent);
+ rc = of_platform_bus_create(root, matches, parent, false);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
- rc = of_platform_bus_create(child, matches, parent);
+ rc = of_platform_bus_create(child, matches, parent, false);
if (rc)
break;
}
@@ -288,4 +295,43 @@ int of_platform_bus_probe(struct device_node *root,
return rc;
}
EXPORT_SYMBOL(of_platform_bus_probe);
+
+/**
+ * of_platform_populate() - Populate platform_devices from device tree data
+ * @root: parent of the first level to probe or NULL for the root of the tree
+ * @matches: match table, NULL to use the default
+ * @parent: parent to hook devices from, NULL for toplevel
+ *
+ * Similar to of_platform_bus_probe(), this function walks the device tree
+ * and creates devices from nodes. It differs in that it follows the modern
+ * convention of requiring all device nodes to have a 'compatible' property,
+ * and it is suitable for creating devices which are children of the root
+ * node (of_platform_bus_probe will only create children of the root which
+ * are selected by the @matches argument).
+ *
+ * New board support should be using this function instead of
+ * of_platform_bus_probe().
+ *
+ * Returns 0 on success, < 0 on failure.
+ */
+int of_platform_populate(struct device_node *root,
+ const struct of_device_id *matches,
+ struct device *parent)
+{
+ struct device_node *child;
+ int rc = 0;
+
+ root = root ? of_node_get(root) : of_find_node_by_path("/");
+ if (!root)
+ return -EINVAL;
+
+ for_each_child_of_node(root, child) {
+ rc = of_platform_bus_create(child, matches, parent, true);
+ if (rc)
+ break;
+ }
+
+ of_node_put(root);
+ return rc;
+}
#endif /* !CONFIG_SPARC */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 8f023f8..8390233 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -57,6 +57,9 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
extern int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches,
struct device *parent);
+extern int of_platform_populate(struct device_node *root,
+ const struct of_device_id *matches,
+ struct device *parent);
#endif /* !CONFIG_SPARC */
#endif /* CONFIG_OF_DEVICE */
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 2/5] dt: add of_platform_populate() for creating device from the device tree
@ 2011-06-21 18:44 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:44 UTC (permalink / raw)
To: linux-arm-kernel
of_platform_populate() is similar to of_platform_bus_probe() except
that it strictly enforces that all device nodes must have a compatible
property, and it can be used to register devices (not buses) which are
children of the root node.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 54 ++++++++++++++++++++++++++++++++++++++++---
include/linux/of_platform.h | 3 ++
2 files changed, 53 insertions(+), 4 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index bb483ef..1f4a5d3 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -229,19 +229,26 @@ EXPORT_SYMBOL(of_platform_device_create);
*/
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
- struct device *parent)
+ struct device *parent, bool strict)
{
struct device_node *child;
struct platform_device *dev;
int rc = 0;
+ /* Make sure it has a compatible property */
+ if (strict && (!of_get_property(bus, "compatible", NULL))) {
+ pr_debug("%s() - skipping %s, no compatible prop\n",
+ __func__, bus->full_name);
+ return 0;
+ }
+
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
- rc = of_platform_bus_create(child, matches, &dev->dev);
+ rc = of_platform_bus_create(child, matches, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
@@ -275,11 +282,11 @@ int of_platform_bus_probe(struct device_node *root,
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
- rc = of_platform_bus_create(root, matches, parent);
+ rc = of_platform_bus_create(root, matches, parent, false);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
- rc = of_platform_bus_create(child, matches, parent);
+ rc = of_platform_bus_create(child, matches, parent, false);
if (rc)
break;
}
@@ -288,4 +295,43 @@ int of_platform_bus_probe(struct device_node *root,
return rc;
}
EXPORT_SYMBOL(of_platform_bus_probe);
+
+/**
+ * of_platform_populate() - Populate platform_devices from device tree data
+ * @root: parent of the first level to probe or NULL for the root of the tree
+ * @matches: match table, NULL to use the default
+ * @parent: parent to hook devices from, NULL for toplevel
+ *
+ * Similar to of_platform_bus_probe(), this function walks the device tree
+ * and creates devices from nodes. It differs in that it follows the modern
+ * convention of requiring all device nodes to have a 'compatible' property,
+ * and it is suitable for creating devices which are children of the root
+ * node (of_platform_bus_probe will only create children of the root which
+ * are selected by the @matches argument).
+ *
+ * New board support should be using this function instead of
+ * of_platform_bus_probe().
+ *
+ * Returns 0 on success, < 0 on failure.
+ */
+int of_platform_populate(struct device_node *root,
+ const struct of_device_id *matches,
+ struct device *parent)
+{
+ struct device_node *child;
+ int rc = 0;
+
+ root = root ? of_node_get(root) : of_find_node_by_path("/");
+ if (!root)
+ return -EINVAL;
+
+ for_each_child_of_node(root, child) {
+ rc = of_platform_bus_create(child, matches, parent, true);
+ if (rc)
+ break;
+ }
+
+ of_node_put(root);
+ return rc;
+}
#endif /* !CONFIG_SPARC */
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 8f023f8..8390233 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -57,6 +57,9 @@ extern struct platform_device *of_platform_device_create(struct device_node *np,
extern int of_platform_bus_probe(struct device_node *root,
const struct of_device_id *matches,
struct device *parent);
+extern int of_platform_populate(struct device_node *root,
+ const struct of_device_id *matches,
+ struct device *parent);
#endif /* !CONFIG_SPARC */
#endif /* CONFIG_OF_DEVICE */
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 3/5] drivers/amba: create devices from device tree
2011-06-21 18:44 ` Grant Likely
(?)
@ 2011-06-21 18:45 ` Grant Likely
-1 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Benjamin Herrenschmidt, Russell King, Arnd Bergmann
Add a function to create amba_devices (i.e. primecell peripherals)
from device tree nodes. The device tree scanning is done by the
of_platform_populate() function which can call of_amba_device_create
based on a match table entry.
Nodes with a "arm,primecell-periphid" property can override the h/w
peripheral id value.
Based on the original work by Jeremy Kerr.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
[grant.likely: add Jeremy's original s-o-b line, changes from review
comments, and moved all code to drivers/of/platform.c]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
.../devicetree/bindings/arm/primecell.txt | 21 ++++++
drivers/of/platform.c | 71 ++++++++++++++++++++
2 files changed, 92 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
new file mode 100644
index 0000000..1d5d7a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/primecell.txt
@@ -0,0 +1,21 @@
+* ARM Primecell Peripherals
+
+ARM, Ltd. Primecell peripherals have a standard id register that can be used to
+identify the peripheral type, vendor, and revision. This value can be used for
+driver matching.
+
+Required properties:
+
+- compatible : should be a specific value for peripheral and "arm,primecell"
+
+Optional properties:
+
+- arm,primecell-periphid : Value to override the h/w value with
+
+Example:
+
+serial@fff36000 {
+ compatible = "arm,pl011", "arm,primecell";
+ arm,primecell-periphid = <0x00341011>;
+};
+
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 1f4a5d3..4192ddc 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -13,6 +13,7 @@
*/
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/amba/bus.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
@@ -217,6 +218,71 @@ struct platform_device *of_platform_device_create(struct device_node *np,
}
EXPORT_SYMBOL(of_platform_device_create);
+#ifdef CONFIG_ARM_AMBA
+static struct amba_device *of_amba_device_create(struct device_node *node,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
+{
+ struct amba_device *dev;
+ const void *prop;
+ int i, ret;
+
+ pr_debug("Creating amba device %s\n", node->full_name);
+
+ if (!of_device_is_available(node))
+ return NULL;
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return NULL;
+
+ /* setup generic device info */
+ dev->dev.coherent_dma_mask = ~0;
+ dev->dev.of_node = of_node_get(node);
+ dev->dev.parent = parent;
+ dev->dev.platform_data = platform_data;
+ if (bus_id)
+ dev_set_name(&dev->dev, "%s", bus_id);
+ else
+ of_device_make_bus_id(&dev->dev);
+
+ /* setup amba-specific device info */
+ dev->dma_mask = ~0;
+
+ /* Allow the HW Peripheral ID to be overridden */
+ prop = of_get_property(node, "arm,primecell-periphid", NULL);
+ if (prop)
+ dev->periphid = of_read_ulong(prop, 1);
+
+ /* Decode the IRQs and address ranges */
+ for (i = 0; i < AMBA_NR_IRQS; i++)
+ dev->irq[i] = irq_of_parse_and_map(node, i);
+
+ ret = of_address_to_resource(node, 0, &dev->res);
+ if (ret)
+ goto err_free;
+
+ ret = amba_device_register(dev, &iomem_resource);
+ if (ret)
+ goto err_free;
+
+ return dev;
+
+err_free:
+ kfree(dev);
+ return NULL;
+}
+#else /* CONFIG_ARM_AMBA */
+static struct amba_device *of_amba_device_create(struct device_node *node,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
+{
+ return NULL;
+}
+#endif /* CONFIG_ARM_AMBA */
+
/**
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
@@ -242,6 +308,11 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
+ if (of_device_is_compatible(bus, "arm,primecell")) {
+ of_amba_device_create(bus, NULL, NULL, parent);
+ return 0;
+ }
+
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-21 18:45 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Russell King, Arnd Bergmann
Add a function to create amba_devices (i.e. primecell peripherals)
from device tree nodes. The device tree scanning is done by the
of_platform_populate() function which can call of_amba_device_create
based on a match table entry.
Nodes with a "arm,primecell-periphid" property can override the h/w
peripheral id value.
Based on the original work by Jeremy Kerr.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
[grant.likely: add Jeremy's original s-o-b line, changes from review
comments, and moved all code to drivers/of/platform.c]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
.../devicetree/bindings/arm/primecell.txt | 21 ++++++
drivers/of/platform.c | 71 ++++++++++++++++++++
2 files changed, 92 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
new file mode 100644
index 0000000..1d5d7a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/primecell.txt
@@ -0,0 +1,21 @@
+* ARM Primecell Peripherals
+
+ARM, Ltd. Primecell peripherals have a standard id register that can be used to
+identify the peripheral type, vendor, and revision. This value can be used for
+driver matching.
+
+Required properties:
+
+- compatible : should be a specific value for peripheral and "arm,primecell"
+
+Optional properties:
+
+- arm,primecell-periphid : Value to override the h/w value with
+
+Example:
+
+serial@fff36000 {
+ compatible = "arm,pl011", "arm,primecell";
+ arm,primecell-periphid = <0x00341011>;
+};
+
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 1f4a5d3..4192ddc 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -13,6 +13,7 @@
*/
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/amba/bus.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
@@ -217,6 +218,71 @@ struct platform_device *of_platform_device_create(struct device_node *np,
}
EXPORT_SYMBOL(of_platform_device_create);
+#ifdef CONFIG_ARM_AMBA
+static struct amba_device *of_amba_device_create(struct device_node *node,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
+{
+ struct amba_device *dev;
+ const void *prop;
+ int i, ret;
+
+ pr_debug("Creating amba device %s\n", node->full_name);
+
+ if (!of_device_is_available(node))
+ return NULL;
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return NULL;
+
+ /* setup generic device info */
+ dev->dev.coherent_dma_mask = ~0;
+ dev->dev.of_node = of_node_get(node);
+ dev->dev.parent = parent;
+ dev->dev.platform_data = platform_data;
+ if (bus_id)
+ dev_set_name(&dev->dev, "%s", bus_id);
+ else
+ of_device_make_bus_id(&dev->dev);
+
+ /* setup amba-specific device info */
+ dev->dma_mask = ~0;
+
+ /* Allow the HW Peripheral ID to be overridden */
+ prop = of_get_property(node, "arm,primecell-periphid", NULL);
+ if (prop)
+ dev->periphid = of_read_ulong(prop, 1);
+
+ /* Decode the IRQs and address ranges */
+ for (i = 0; i < AMBA_NR_IRQS; i++)
+ dev->irq[i] = irq_of_parse_and_map(node, i);
+
+ ret = of_address_to_resource(node, 0, &dev->res);
+ if (ret)
+ goto err_free;
+
+ ret = amba_device_register(dev, &iomem_resource);
+ if (ret)
+ goto err_free;
+
+ return dev;
+
+err_free:
+ kfree(dev);
+ return NULL;
+}
+#else /* CONFIG_ARM_AMBA */
+static struct amba_device *of_amba_device_create(struct device_node *node,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
+{
+ return NULL;
+}
+#endif /* CONFIG_ARM_AMBA */
+
/**
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
@@ -242,6 +308,11 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
+ if (of_device_is_compatible(bus, "arm,primecell")) {
+ of_amba_device_create(bus, NULL, NULL, parent);
+ return 0;
+ }
+
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-21 18:45 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: linux-arm-kernel
Add a function to create amba_devices (i.e. primecell peripherals)
from device tree nodes. The device tree scanning is done by the
of_platform_populate() function which can call of_amba_device_create
based on a match table entry.
Nodes with a "arm,primecell-periphid" property can override the h/w
peripheral id value.
Based on the original work by Jeremy Kerr.
Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
[grant.likely: add Jeremy's original s-o-b line, changes from review
comments, and moved all code to drivers/of/platform.c]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
.../devicetree/bindings/arm/primecell.txt | 21 ++++++
drivers/of/platform.c | 71 ++++++++++++++++++++
2 files changed, 92 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
new file mode 100644
index 0000000..1d5d7a8
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/primecell.txt
@@ -0,0 +1,21 @@
+* ARM Primecell Peripherals
+
+ARM, Ltd. Primecell peripherals have a standard id register that can be used to
+identify the peripheral type, vendor, and revision. This value can be used for
+driver matching.
+
+Required properties:
+
+- compatible : should be a specific value for peripheral and "arm,primecell"
+
+Optional properties:
+
+- arm,primecell-periphid : Value to override the h/w value with
+
+Example:
+
+serial at fff36000 {
+ compatible = "arm,pl011", "arm,primecell";
+ arm,primecell-periphid = <0x00341011>;
+};
+
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 1f4a5d3..4192ddc 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -13,6 +13,7 @@
*/
#include <linux/errno.h>
#include <linux/module.h>
+#include <linux/amba/bus.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
@@ -217,6 +218,71 @@ struct platform_device *of_platform_device_create(struct device_node *np,
}
EXPORT_SYMBOL(of_platform_device_create);
+#ifdef CONFIG_ARM_AMBA
+static struct amba_device *of_amba_device_create(struct device_node *node,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
+{
+ struct amba_device *dev;
+ const void *prop;
+ int i, ret;
+
+ pr_debug("Creating amba device %s\n", node->full_name);
+
+ if (!of_device_is_available(node))
+ return NULL;
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return NULL;
+
+ /* setup generic device info */
+ dev->dev.coherent_dma_mask = ~0;
+ dev->dev.of_node = of_node_get(node);
+ dev->dev.parent = parent;
+ dev->dev.platform_data = platform_data;
+ if (bus_id)
+ dev_set_name(&dev->dev, "%s", bus_id);
+ else
+ of_device_make_bus_id(&dev->dev);
+
+ /* setup amba-specific device info */
+ dev->dma_mask = ~0;
+
+ /* Allow the HW Peripheral ID to be overridden */
+ prop = of_get_property(node, "arm,primecell-periphid", NULL);
+ if (prop)
+ dev->periphid = of_read_ulong(prop, 1);
+
+ /* Decode the IRQs and address ranges */
+ for (i = 0; i < AMBA_NR_IRQS; i++)
+ dev->irq[i] = irq_of_parse_and_map(node, i);
+
+ ret = of_address_to_resource(node, 0, &dev->res);
+ if (ret)
+ goto err_free;
+
+ ret = amba_device_register(dev, &iomem_resource);
+ if (ret)
+ goto err_free;
+
+ return dev;
+
+err_free:
+ kfree(dev);
+ return NULL;
+}
+#else /* CONFIG_ARM_AMBA */
+static struct amba_device *of_amba_device_create(struct device_node *node,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
+{
+ return NULL;
+}
+#endif /* CONFIG_ARM_AMBA */
+
/**
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
@@ -242,6 +308,11 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
+ if (of_device_is_compatible(bus, "arm,primecell")) {
+ of_amba_device_create(bus, NULL, NULL, parent);
+ return 0;
+ }
+
dev = of_platform_device_create(bus, NULL, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 4/5] dt/platform: allow device name to be overridden
2011-06-21 18:44 ` Grant Likely
(?)
@ 2011-06-21 18:45 ` Grant Likely
-1 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Benjamin Herrenschmidt, Russell King, Arnd Bergmann
Some platform code has specific requirements on the naming of devices.
This patch allows callers of of_platform_populate() to provide a
device name lookup table.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 73 +++++++++++++++++++++++++++++++++++++------
include/linux/of_platform.h | 35 +++++++++++++++++++++
2 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 4192ddc..e75af39 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -177,17 +177,20 @@ struct platform_device *of_device_alloc(struct device_node *np,
EXPORT_SYMBOL(of_device_alloc);
/**
- * of_platform_device_create - Alloc, initialize and register an of_device
+ * of_platform_device_create_pdata - Alloc, initialize and register an of_device
* @np: pointer to node to create device for
* @bus_id: name to assign device
+ * @platform_data: pointer to populate platform_data pointer with
* @parent: Linux device model parent device.
*
* Returns pointer to created platform device, or NULL if a device was not
* registered. Unavailable devices will not get registered.
*/
-struct platform_device *of_platform_device_create(struct device_node *np,
- const char *bus_id,
- struct device *parent)
+struct platform_device *of_platform_device_create_pdata(
+ struct device_node *np,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
{
struct platform_device *dev;
@@ -203,6 +206,7 @@ struct platform_device *of_platform_device_create(struct device_node *np,
#endif
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
dev->dev.bus = &platform_bus_type;
+ dev->dev.platform_data = platform_data;
/* We do not fill the DMA ops for platform devices by default.
* This is currently the responsibility of the platform code
@@ -216,6 +220,22 @@ struct platform_device *of_platform_device_create(struct device_node *np,
return dev;
}
+
+/**
+ * of_platform_device_create - Alloc, initialize and register an of_device
+ * @np: pointer to node to create device for
+ * @bus_id: name to assign device
+ * @parent: Linux device model parent device.
+ *
+ * Returns pointer to created platform device, or NULL if a device was not
+ * registered. Unavailable devices will not get registered.
+ */
+struct platform_device *of_platform_device_create(struct device_node *np,
+ const char *bus_id,
+ struct device *parent)
+{
+ return of_platform_device_create_pdata(np, bus_id, NULL, parent);
+}
EXPORT_SYMBOL(of_platform_device_create);
#ifdef CONFIG_ARM_AMBA
@@ -284,6 +304,28 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
#endif /* CONFIG_ARM_AMBA */
/**
+ * of_devname_lookup() - Given a device node, lookup the preferred Linux name
+ */
+static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *lookup,
+ struct device_node *np)
+{
+ struct resource res;
+ if (lookup) {
+ for(; lookup->name != NULL; lookup++) {
+ if (!of_device_is_compatible(np, lookup->compatible))
+ continue;
+ if (of_address_to_resource(np, 0, &res))
+ continue;
+ if (res.start != lookup->phys_addr)
+ continue;
+ pr_debug("%s: devname=%s\n", np->full_name, lookup->name);
+ return lookup;
+ }
+ }
+ return NULL;
+}
+
+/**
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
* @matches: match table for bus nodes
@@ -295,10 +337,14 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
*/
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent, bool strict)
{
+ const struct of_dev_auxdata *auxdata;
struct device_node *child;
struct platform_device *dev;
+ const char *bus_id = NULL;
+ void *platform_data = NULL;
int rc = 0;
/* Make sure it has a compatible property */
@@ -308,18 +354,24 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
+ auxdata = of_dev_lookup(lookup, bus);
+ if (auxdata) {
+ bus_id = auxdata->name;
+ platform_data = auxdata->platform_data;
+ }
+
if (of_device_is_compatible(bus, "arm,primecell")) {
- of_amba_device_create(bus, NULL, NULL, parent);
+ of_amba_device_create(bus, bus_id, platform_data, parent);
return 0;
}
- dev = of_platform_device_create(bus, NULL, parent);
+ dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
- rc = of_platform_bus_create(child, matches, &dev->dev, strict);
+ rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
@@ -353,11 +405,11 @@ int of_platform_bus_probe(struct device_node *root,
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
- rc = of_platform_bus_create(root, matches, parent, false);
+ rc = of_platform_bus_create(root, matches, NULL, parent, false);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
- rc = of_platform_bus_create(child, matches, parent, false);
+ rc = of_platform_bus_create(child, matches, NULL, parent, false);
if (rc)
break;
}
@@ -387,6 +439,7 @@ EXPORT_SYMBOL(of_platform_bus_probe);
*/
int of_platform_populate(struct device_node *root,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent)
{
struct device_node *child;
@@ -397,7 +450,7 @@ int of_platform_populate(struct device_node *root,
return -EINVAL;
for_each_child_of_node(root, child) {
- rc = of_platform_bus_create(child, matches, parent, true);
+ rc = of_platform_bus_create(child, matches, lookup, parent, true);
if (rc)
break;
}
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 8390233..5a6f458 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -20,6 +20,40 @@
#include <linux/platform_device.h>
/**
+ * struct of_dev_auxdata - lookup table entry for device names & platform_data
+ * @compatible: compatible value of node to match against node
+ * @phys_addr: Start address of registers to match against node
+ * @name: Name to assign for matching nodes
+ * @platform_data: platform_data to assign for matching nodes
+ *
+ * This lookup table allows the caller of of_platform_populate() to override
+ * the names of devices when creating devices from the device tree. The table
+ * should be terminated with an empty entry. It also allows the platform_data
+ * pointer to be set.
+ *
+ * The reason for this functionality is that some Linux infrastructure uses
+ * the device name to look up a specific device, but the Linux-specific names
+ * are not encoded into the device tree, so the kernel needs to provide specific
+ * values.
+ *
+ * Note: Using an auxdata lookup table should be considered a last resort when
+ * converting a platform to use the DT. Normally the automatically generated
+ * device name will not matter, and drivers should obtain data from the device
+ * node instead of from an anonymouns platform_data pointer.
+ */
+struct of_dev_auxdata {
+ char *compatible;
+ resource_size_t phys_addr;
+ char *name;
+ void *platform_data;
+};
+
+/* Macro to simplify populating a lookup table */
+#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \
+ { .compatible = _compat, .phys_addr = _phys, .name = _name, \
+ .platform_data = _pdata }
+
+/**
* of_platform_driver - Legacy of-aware driver for platform devices.
*
* An of_platform_driver driver is attached to a basic platform_device on
@@ -59,6 +93,7 @@ extern int of_platform_bus_probe(struct device_node *root,
struct device *parent);
extern int of_platform_populate(struct device_node *root,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent);
#endif /* !CONFIG_SPARC */
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 4/5] dt/platform: allow device name to be overridden
@ 2011-06-21 18:45 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Russell King, Arnd Bergmann
Some platform code has specific requirements on the naming of devices.
This patch allows callers of of_platform_populate() to provide a
device name lookup table.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 73 +++++++++++++++++++++++++++++++++++++------
include/linux/of_platform.h | 35 +++++++++++++++++++++
2 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 4192ddc..e75af39 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -177,17 +177,20 @@ struct platform_device *of_device_alloc(struct device_node *np,
EXPORT_SYMBOL(of_device_alloc);
/**
- * of_platform_device_create - Alloc, initialize and register an of_device
+ * of_platform_device_create_pdata - Alloc, initialize and register an of_device
* @np: pointer to node to create device for
* @bus_id: name to assign device
+ * @platform_data: pointer to populate platform_data pointer with
* @parent: Linux device model parent device.
*
* Returns pointer to created platform device, or NULL if a device was not
* registered. Unavailable devices will not get registered.
*/
-struct platform_device *of_platform_device_create(struct device_node *np,
- const char *bus_id,
- struct device *parent)
+struct platform_device *of_platform_device_create_pdata(
+ struct device_node *np,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
{
struct platform_device *dev;
@@ -203,6 +206,7 @@ struct platform_device *of_platform_device_create(struct device_node *np,
#endif
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
dev->dev.bus = &platform_bus_type;
+ dev->dev.platform_data = platform_data;
/* We do not fill the DMA ops for platform devices by default.
* This is currently the responsibility of the platform code
@@ -216,6 +220,22 @@ struct platform_device *of_platform_device_create(struct device_node *np,
return dev;
}
+
+/**
+ * of_platform_device_create - Alloc, initialize and register an of_device
+ * @np: pointer to node to create device for
+ * @bus_id: name to assign device
+ * @parent: Linux device model parent device.
+ *
+ * Returns pointer to created platform device, or NULL if a device was not
+ * registered. Unavailable devices will not get registered.
+ */
+struct platform_device *of_platform_device_create(struct device_node *np,
+ const char *bus_id,
+ struct device *parent)
+{
+ return of_platform_device_create_pdata(np, bus_id, NULL, parent);
+}
EXPORT_SYMBOL(of_platform_device_create);
#ifdef CONFIG_ARM_AMBA
@@ -284,6 +304,28 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
#endif /* CONFIG_ARM_AMBA */
/**
+ * of_devname_lookup() - Given a device node, lookup the preferred Linux name
+ */
+static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *lookup,
+ struct device_node *np)
+{
+ struct resource res;
+ if (lookup) {
+ for(; lookup->name != NULL; lookup++) {
+ if (!of_device_is_compatible(np, lookup->compatible))
+ continue;
+ if (of_address_to_resource(np, 0, &res))
+ continue;
+ if (res.start != lookup->phys_addr)
+ continue;
+ pr_debug("%s: devname=%s\n", np->full_name, lookup->name);
+ return lookup;
+ }
+ }
+ return NULL;
+}
+
+/**
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
* @matches: match table for bus nodes
@@ -295,10 +337,14 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
*/
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent, bool strict)
{
+ const struct of_dev_auxdata *auxdata;
struct device_node *child;
struct platform_device *dev;
+ const char *bus_id = NULL;
+ void *platform_data = NULL;
int rc = 0;
/* Make sure it has a compatible property */
@@ -308,18 +354,24 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
+ auxdata = of_dev_lookup(lookup, bus);
+ if (auxdata) {
+ bus_id = auxdata->name;
+ platform_data = auxdata->platform_data;
+ }
+
if (of_device_is_compatible(bus, "arm,primecell")) {
- of_amba_device_create(bus, NULL, NULL, parent);
+ of_amba_device_create(bus, bus_id, platform_data, parent);
return 0;
}
- dev = of_platform_device_create(bus, NULL, parent);
+ dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
- rc = of_platform_bus_create(child, matches, &dev->dev, strict);
+ rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
@@ -353,11 +405,11 @@ int of_platform_bus_probe(struct device_node *root,
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
- rc = of_platform_bus_create(root, matches, parent, false);
+ rc = of_platform_bus_create(root, matches, NULL, parent, false);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
- rc = of_platform_bus_create(child, matches, parent, false);
+ rc = of_platform_bus_create(child, matches, NULL, parent, false);
if (rc)
break;
}
@@ -387,6 +439,7 @@ EXPORT_SYMBOL(of_platform_bus_probe);
*/
int of_platform_populate(struct device_node *root,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent)
{
struct device_node *child;
@@ -397,7 +450,7 @@ int of_platform_populate(struct device_node *root,
return -EINVAL;
for_each_child_of_node(root, child) {
- rc = of_platform_bus_create(child, matches, parent, true);
+ rc = of_platform_bus_create(child, matches, lookup, parent, true);
if (rc)
break;
}
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 8390233..5a6f458 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -20,6 +20,40 @@
#include <linux/platform_device.h>
/**
+ * struct of_dev_auxdata - lookup table entry for device names & platform_data
+ * @compatible: compatible value of node to match against node
+ * @phys_addr: Start address of registers to match against node
+ * @name: Name to assign for matching nodes
+ * @platform_data: platform_data to assign for matching nodes
+ *
+ * This lookup table allows the caller of of_platform_populate() to override
+ * the names of devices when creating devices from the device tree. The table
+ * should be terminated with an empty entry. It also allows the platform_data
+ * pointer to be set.
+ *
+ * The reason for this functionality is that some Linux infrastructure uses
+ * the device name to look up a specific device, but the Linux-specific names
+ * are not encoded into the device tree, so the kernel needs to provide specific
+ * values.
+ *
+ * Note: Using an auxdata lookup table should be considered a last resort when
+ * converting a platform to use the DT. Normally the automatically generated
+ * device name will not matter, and drivers should obtain data from the device
+ * node instead of from an anonymouns platform_data pointer.
+ */
+struct of_dev_auxdata {
+ char *compatible;
+ resource_size_t phys_addr;
+ char *name;
+ void *platform_data;
+};
+
+/* Macro to simplify populating a lookup table */
+#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \
+ { .compatible = _compat, .phys_addr = _phys, .name = _name, \
+ .platform_data = _pdata }
+
+/**
* of_platform_driver - Legacy of-aware driver for platform devices.
*
* An of_platform_driver driver is attached to a basic platform_device on
@@ -59,6 +93,7 @@ extern int of_platform_bus_probe(struct device_node *root,
struct device *parent);
extern int of_platform_populate(struct device_node *root,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent);
#endif /* !CONFIG_SPARC */
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 4/5] dt/platform: allow device name to be overridden
@ 2011-06-21 18:45 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: linux-arm-kernel
Some platform code has specific requirements on the naming of devices.
This patch allows callers of of_platform_populate() to provide a
device name lookup table.
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
drivers/of/platform.c | 73 +++++++++++++++++++++++++++++++++++++------
include/linux/of_platform.h | 35 +++++++++++++++++++++
2 files changed, 98 insertions(+), 10 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 4192ddc..e75af39 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -177,17 +177,20 @@ struct platform_device *of_device_alloc(struct device_node *np,
EXPORT_SYMBOL(of_device_alloc);
/**
- * of_platform_device_create - Alloc, initialize and register an of_device
+ * of_platform_device_create_pdata - Alloc, initialize and register an of_device
* @np: pointer to node to create device for
* @bus_id: name to assign device
+ * @platform_data: pointer to populate platform_data pointer with
* @parent: Linux device model parent device.
*
* Returns pointer to created platform device, or NULL if a device was not
* registered. Unavailable devices will not get registered.
*/
-struct platform_device *of_platform_device_create(struct device_node *np,
- const char *bus_id,
- struct device *parent)
+struct platform_device *of_platform_device_create_pdata(
+ struct device_node *np,
+ const char *bus_id,
+ void *platform_data,
+ struct device *parent)
{
struct platform_device *dev;
@@ -203,6 +206,7 @@ struct platform_device *of_platform_device_create(struct device_node *np,
#endif
dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
dev->dev.bus = &platform_bus_type;
+ dev->dev.platform_data = platform_data;
/* We do not fill the DMA ops for platform devices by default.
* This is currently the responsibility of the platform code
@@ -216,6 +220,22 @@ struct platform_device *of_platform_device_create(struct device_node *np,
return dev;
}
+
+/**
+ * of_platform_device_create - Alloc, initialize and register an of_device
+ * @np: pointer to node to create device for
+ * @bus_id: name to assign device
+ * @parent: Linux device model parent device.
+ *
+ * Returns pointer to created platform device, or NULL if a device was not
+ * registered. Unavailable devices will not get registered.
+ */
+struct platform_device *of_platform_device_create(struct device_node *np,
+ const char *bus_id,
+ struct device *parent)
+{
+ return of_platform_device_create_pdata(np, bus_id, NULL, parent);
+}
EXPORT_SYMBOL(of_platform_device_create);
#ifdef CONFIG_ARM_AMBA
@@ -284,6 +304,28 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
#endif /* CONFIG_ARM_AMBA */
/**
+ * of_devname_lookup() - Given a device node, lookup the preferred Linux name
+ */
+static const struct of_dev_auxdata *of_dev_lookup(const struct of_dev_auxdata *lookup,
+ struct device_node *np)
+{
+ struct resource res;
+ if (lookup) {
+ for(; lookup->name != NULL; lookup++) {
+ if (!of_device_is_compatible(np, lookup->compatible))
+ continue;
+ if (of_address_to_resource(np, 0, &res))
+ continue;
+ if (res.start != lookup->phys_addr)
+ continue;
+ pr_debug("%s: devname=%s\n", np->full_name, lookup->name);
+ return lookup;
+ }
+ }
+ return NULL;
+}
+
+/**
* of_platform_bus_create() - Create a device for a node and its children.
* @bus: device node of the bus to instantiate
* @matches: match table for bus nodes
@@ -295,10 +337,14 @@ static struct amba_device *of_amba_device_create(struct device_node *node,
*/
static int of_platform_bus_create(struct device_node *bus,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent, bool strict)
{
+ const struct of_dev_auxdata *auxdata;
struct device_node *child;
struct platform_device *dev;
+ const char *bus_id = NULL;
+ void *platform_data = NULL;
int rc = 0;
/* Make sure it has a compatible property */
@@ -308,18 +354,24 @@ static int of_platform_bus_create(struct device_node *bus,
return 0;
}
+ auxdata = of_dev_lookup(lookup, bus);
+ if (auxdata) {
+ bus_id = auxdata->name;
+ platform_data = auxdata->platform_data;
+ }
+
if (of_device_is_compatible(bus, "arm,primecell")) {
- of_amba_device_create(bus, NULL, NULL, parent);
+ of_amba_device_create(bus, bus_id, platform_data, parent);
return 0;
}
- dev = of_platform_device_create(bus, NULL, parent);
+ dev = of_platform_device_create_pdata(bus, bus_id, platform_data, parent);
if (!dev || !of_match_node(matches, bus))
return 0;
for_each_child_of_node(bus, child) {
pr_debug(" create child: %s\n", child->full_name);
- rc = of_platform_bus_create(child, matches, &dev->dev, strict);
+ rc = of_platform_bus_create(child, matches, lookup, &dev->dev, strict);
if (rc) {
of_node_put(child);
break;
@@ -353,11 +405,11 @@ int of_platform_bus_probe(struct device_node *root,
/* Do a self check of bus type, if there's a match, create children */
if (of_match_node(matches, root)) {
- rc = of_platform_bus_create(root, matches, parent, false);
+ rc = of_platform_bus_create(root, matches, NULL, parent, false);
} else for_each_child_of_node(root, child) {
if (!of_match_node(matches, child))
continue;
- rc = of_platform_bus_create(child, matches, parent, false);
+ rc = of_platform_bus_create(child, matches, NULL, parent, false);
if (rc)
break;
}
@@ -387,6 +439,7 @@ EXPORT_SYMBOL(of_platform_bus_probe);
*/
int of_platform_populate(struct device_node *root,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent)
{
struct device_node *child;
@@ -397,7 +450,7 @@ int of_platform_populate(struct device_node *root,
return -EINVAL;
for_each_child_of_node(root, child) {
- rc = of_platform_bus_create(child, matches, parent, true);
+ rc = of_platform_bus_create(child, matches, lookup, parent, true);
if (rc)
break;
}
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 8390233..5a6f458 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -20,6 +20,40 @@
#include <linux/platform_device.h>
/**
+ * struct of_dev_auxdata - lookup table entry for device names & platform_data
+ * @compatible: compatible value of node to match against node
+ * @phys_addr: Start address of registers to match against node
+ * @name: Name to assign for matching nodes
+ * @platform_data: platform_data to assign for matching nodes
+ *
+ * This lookup table allows the caller of of_platform_populate() to override
+ * the names of devices when creating devices from the device tree. The table
+ * should be terminated with an empty entry. It also allows the platform_data
+ * pointer to be set.
+ *
+ * The reason for this functionality is that some Linux infrastructure uses
+ * the device name to look up a specific device, but the Linux-specific names
+ * are not encoded into the device tree, so the kernel needs to provide specific
+ * values.
+ *
+ * Note: Using an auxdata lookup table should be considered a last resort when
+ * converting a platform to use the DT. Normally the automatically generated
+ * device name will not matter, and drivers should obtain data from the device
+ * node instead of from an anonymouns platform_data pointer.
+ */
+struct of_dev_auxdata {
+ char *compatible;
+ resource_size_t phys_addr;
+ char *name;
+ void *platform_data;
+};
+
+/* Macro to simplify populating a lookup table */
+#define OF_DEV_AUXDATA(_compat,_phys,_name,_pdata) \
+ { .compatible = _compat, .phys_addr = _phys, .name = _name, \
+ .platform_data = _pdata }
+
+/**
* of_platform_driver - Legacy of-aware driver for platform devices.
*
* An of_platform_driver driver is attached to a basic platform_device on
@@ -59,6 +93,7 @@ extern int of_platform_bus_probe(struct device_node *root,
struct device *parent);
extern int of_platform_populate(struct device_node *root,
const struct of_device_id *matches,
+ const struct of_dev_auxdata *lookup,
struct device *parent);
#endif /* !CONFIG_SPARC */
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 5/5] powerpc/5200: convert mpc5200 to use of_platform_populate()
2011-06-21 18:44 ` Grant Likely
(?)
@ 2011-06-21 18:45 ` Grant Likely
-1 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Benjamin Herrenschmidt, Russell King, Arnd Bergmann
of_platform_populate() also handles nodes at the root of the tree,
which is wanted for things like describing the sound complex. This
patch converts mpc5200 support to use of_platform_populate() instead
of of_platform_bus_probe().
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index 41f3a7e..6a2fde2 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -97,13 +97,11 @@ struct mpc52xx_gpio_wkup __iomem *wkup_gpio;
* of the localplus bus to the of_platform
* bus.
*/
-void __init
-mpc52xx_declare_of_platform_devices(void)
+void __init mpc52xx_declare_of_platform_devices(void)
{
- /* Find every child of the SOC node and add it to of_platform */
- if (of_platform_bus_probe(NULL, mpc52xx_bus_ids, NULL))
- printk(KERN_ERR __FILE__ ": "
- "Error while probing of_platform bus\n");
+ /* Find all the 'platform' devices and register them. */
+ if (of_platform_populate(NULL, mpc52xx_bus_ids, NULL, NULL))
+ pr_err(__FILE__ ": Error while populating devices from DT\n");
}
/*
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 5/5] powerpc/5200: convert mpc5200 to use of_platform_populate()
@ 2011-06-21 18:45 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel
Cc: Russell King, Arnd Bergmann
of_platform_populate() also handles nodes at the root of the tree,
which is wanted for things like describing the sound complex. This
patch converts mpc5200 support to use of_platform_populate() instead
of of_platform_bus_probe().
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index 41f3a7e..6a2fde2 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -97,13 +97,11 @@ struct mpc52xx_gpio_wkup __iomem *wkup_gpio;
* of the localplus bus to the of_platform
* bus.
*/
-void __init
-mpc52xx_declare_of_platform_devices(void)
+void __init mpc52xx_declare_of_platform_devices(void)
{
- /* Find every child of the SOC node and add it to of_platform */
- if (of_platform_bus_probe(NULL, mpc52xx_bus_ids, NULL))
- printk(KERN_ERR __FILE__ ": "
- "Error while probing of_platform bus\n");
+ /* Find all the 'platform' devices and register them. */
+ if (of_platform_populate(NULL, mpc52xx_bus_ids, NULL, NULL))
+ pr_err(__FILE__ ": Error while populating devices from DT\n");
}
/*
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH 5/5] powerpc/5200: convert mpc5200 to use of_platform_populate()
@ 2011-06-21 18:45 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-21 18:45 UTC (permalink / raw)
To: linux-arm-kernel
of_platform_populate() also handles nodes at the root of the tree,
which is wanted for things like describing the sound complex. This
patch converts mpc5200 support to use of_platform_populate() instead
of of_platform_bus_probe().
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_common.c b/arch/powerpc/platforms/52xx/mpc52xx_common.c
index 41f3a7e..6a2fde2 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_common.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_common.c
@@ -97,13 +97,11 @@ struct mpc52xx_gpio_wkup __iomem *wkup_gpio;
* of the localplus bus to the of_platform
* bus.
*/
-void __init
-mpc52xx_declare_of_platform_devices(void)
+void __init mpc52xx_declare_of_platform_devices(void)
{
- /* Find every child of the SOC node and add it to of_platform */
- if (of_platform_bus_probe(NULL, mpc52xx_bus_ids, NULL))
- printk(KERN_ERR __FILE__ ": "
- "Error while probing of_platform bus\n");
+ /* Find all the 'platform' devices and register them. */
+ if (of_platform_populate(NULL, mpc52xx_bus_ids, NULL, NULL))
+ pr_err(__FILE__ ": Error while populating devices from DT\n");
}
/*
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH 3/5] drivers/amba: create devices from device tree
2011-06-21 18:45 ` Grant Likely
(?)
(?)
@ 2011-06-21 20:07 ` Rob Herring
-1 siblings, 0 replies; 27+ messages in thread
From: Rob Herring @ 2011-06-21 20:07 UTC (permalink / raw)
To: Grant Likely
Cc: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel, Benjamin Herrenschmidt, Russell King,
Arnd Bergmann
Grant,
On 06/21/2011 01:45 PM, Grant Likely wrote:
> Add a function to create amba_devices (i.e. primecell peripherals)
> from device tree nodes. The device tree scanning is done by the
> of_platform_populate() function which can call of_amba_device_create
> based on a match table entry.
>
> Nodes with a "arm,primecell-periphid" property can override the h/w
> peripheral id value.
>
> Based on the original work by Jeremy Kerr.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> [grant.likely: add Jeremy's original s-o-b line, changes from review
> comments, and moved all code to drivers/of/platform.c]
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> .../devicetree/bindings/arm/primecell.txt | 21 ++++++
> drivers/of/platform.c | 71 ++++++++++++++++++++
> 2 files changed, 92 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
>
> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
> new file mode 100644
> index 0000000..1d5d7a8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
> @@ -0,0 +1,21 @@
> +* ARM Primecell Peripherals
> +
> +ARM, Ltd. Primecell peripherals have a standard id register that can be used to
> +identify the peripheral type, vendor, and revision. This value can be used for
> +driver matching.
> +
> +Required properties:
> +
> +- compatible : should be a specific value for peripheral and "arm,primecell"
Can I review what I wrote... Perhaps we should put strings in for all
existing drivers in the kernel. This should be a complete list:
arm,pl010
arm,pl011
st,pl011
arm,pl022
st,pl022
st,pl023
arm,pl030
arm,pl031
st,pl031
arm,pl061
arm,pl050
arm,pl080
arm,pl081
st,pl080
arm,pl110
arm,pl180
arm,pl330
arm,sp804
arm,sp805
Otherwise, they may never get added.
Rob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-21 20:07 ` Rob Herring
0 siblings, 0 replies; 27+ messages in thread
From: Rob Herring @ 2011-06-21 20:07 UTC (permalink / raw)
To: Grant Likely
Cc: Nicolas Pitre, Russell King, Arnd Bergmann,
Benjamin Herrenschmidt, devicetree-discuss, linux-kernel,
linuxppc-dev, linux-arm-kernel
Grant,
On 06/21/2011 01:45 PM, Grant Likely wrote:
> Add a function to create amba_devices (i.e. primecell peripherals)
> from device tree nodes. The device tree scanning is done by the
> of_platform_populate() function which can call of_amba_device_create
> based on a match table entry.
>
> Nodes with a "arm,primecell-periphid" property can override the h/w
> peripheral id value.
>
> Based on the original work by Jeremy Kerr.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> [grant.likely: add Jeremy's original s-o-b line, changes from review
> comments, and moved all code to drivers/of/platform.c]
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> .../devicetree/bindings/arm/primecell.txt | 21 ++++++
> drivers/of/platform.c | 71 ++++++++++++++++++++
> 2 files changed, 92 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
>
> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
> new file mode 100644
> index 0000000..1d5d7a8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
> @@ -0,0 +1,21 @@
> +* ARM Primecell Peripherals
> +
> +ARM, Ltd. Primecell peripherals have a standard id register that can be used to
> +identify the peripheral type, vendor, and revision. This value can be used for
> +driver matching.
> +
> +Required properties:
> +
> +- compatible : should be a specific value for peripheral and "arm,primecell"
Can I review what I wrote... Perhaps we should put strings in for all
existing drivers in the kernel. This should be a complete list:
arm,pl010
arm,pl011
st,pl011
arm,pl022
st,pl022
st,pl023
arm,pl030
arm,pl031
st,pl031
arm,pl061
arm,pl050
arm,pl080
arm,pl081
st,pl080
arm,pl110
arm,pl180
arm,pl330
arm,sp804
arm,sp805
Otherwise, they may never get added.
Rob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-21 20:07 ` Rob Herring
0 siblings, 0 replies; 27+ messages in thread
From: Rob Herring @ 2011-06-21 20:07 UTC (permalink / raw)
To: Grant Likely
Cc: Nicolas Pitre, Russell King, Arnd Bergmann, devicetree-discuss,
linux-kernel, linuxppc-dev, linux-arm-kernel
Grant,
On 06/21/2011 01:45 PM, Grant Likely wrote:
> Add a function to create amba_devices (i.e. primecell peripherals)
> from device tree nodes. The device tree scanning is done by the
> of_platform_populate() function which can call of_amba_device_create
> based on a match table entry.
>
> Nodes with a "arm,primecell-periphid" property can override the h/w
> peripheral id value.
>
> Based on the original work by Jeremy Kerr.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> [grant.likely: add Jeremy's original s-o-b line, changes from review
> comments, and moved all code to drivers/of/platform.c]
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> .../devicetree/bindings/arm/primecell.txt | 21 ++++++
> drivers/of/platform.c | 71 ++++++++++++++++++++
> 2 files changed, 92 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
>
> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
> new file mode 100644
> index 0000000..1d5d7a8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
> @@ -0,0 +1,21 @@
> +* ARM Primecell Peripherals
> +
> +ARM, Ltd. Primecell peripherals have a standard id register that can be used to
> +identify the peripheral type, vendor, and revision. This value can be used for
> +driver matching.
> +
> +Required properties:
> +
> +- compatible : should be a specific value for peripheral and "arm,primecell"
Can I review what I wrote... Perhaps we should put strings in for all
existing drivers in the kernel. This should be a complete list:
arm,pl010
arm,pl011
st,pl011
arm,pl022
st,pl022
st,pl023
arm,pl030
arm,pl031
st,pl031
arm,pl061
arm,pl050
arm,pl080
arm,pl081
st,pl080
arm,pl110
arm,pl180
arm,pl330
arm,sp804
arm,sp805
Otherwise, they may never get added.
Rob
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-21 20:07 ` Rob Herring
0 siblings, 0 replies; 27+ messages in thread
From: Rob Herring @ 2011-06-21 20:07 UTC (permalink / raw)
To: linux-arm-kernel
Grant,
On 06/21/2011 01:45 PM, Grant Likely wrote:
> Add a function to create amba_devices (i.e. primecell peripherals)
> from device tree nodes. The device tree scanning is done by the
> of_platform_populate() function which can call of_amba_device_create
> based on a match table entry.
>
> Nodes with a "arm,primecell-periphid" property can override the h/w
> peripheral id value.
>
> Based on the original work by Jeremy Kerr.
>
> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> [grant.likely: add Jeremy's original s-o-b line, changes from review
> comments, and moved all code to drivers/of/platform.c]
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> .../devicetree/bindings/arm/primecell.txt | 21 ++++++
> drivers/of/platform.c | 71 ++++++++++++++++++++
> 2 files changed, 92 insertions(+), 0 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
>
> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
> new file mode 100644
> index 0000000..1d5d7a8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
> @@ -0,0 +1,21 @@
> +* ARM Primecell Peripherals
> +
> +ARM, Ltd. Primecell peripherals have a standard id register that can be used to
> +identify the peripheral type, vendor, and revision. This value can be used for
> +driver matching.
> +
> +Required properties:
> +
> +- compatible : should be a specific value for peripheral and "arm,primecell"
Can I review what I wrote... Perhaps we should put strings in for all
existing drivers in the kernel. This should be a complete list:
arm,pl010
arm,pl011
st,pl011
arm,pl022
st,pl022
st,pl023
arm,pl030
arm,pl031
st,pl031
arm,pl061
arm,pl050
arm,pl080
arm,pl081
st,pl080
arm,pl110
arm,pl180
arm,pl330
arm,sp804
arm,sp805
Otherwise, they may never get added.
Rob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/5] drivers/amba: create devices from device tree
2011-06-21 20:07 ` Rob Herring
(?)
@ 2011-06-23 20:55 ` Grant Likely
-1 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-23 20:55 UTC (permalink / raw)
To: Rob Herring
Cc: Nicolas Pitre, devicetree-discuss, linuxppc-dev, linux-kernel,
linux-arm-kernel, Benjamin Herrenschmidt, Russell King,
Arnd Bergmann
On Tue, Jun 21, 2011 at 2:07 PM, Rob Herring <robherring2@gmail.com> wrote:
> Grant,
>
> On 06/21/2011 01:45 PM, Grant Likely wrote:
>> Add a function to create amba_devices (i.e. primecell peripherals)
>> from device tree nodes. The device tree scanning is done by the
>> of_platform_populate() function which can call of_amba_device_create
>> based on a match table entry.
>>
>> Nodes with a "arm,primecell-periphid" property can override the h/w
>> peripheral id value.
>>
>> Based on the original work by Jeremy Kerr.
>>
>> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
>> [grant.likely: add Jeremy's original s-o-b line, changes from review
>> comments, and moved all code to drivers/of/platform.c]
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> ---
>> .../devicetree/bindings/arm/primecell.txt | 21 ++++++
>> drivers/of/platform.c | 71 ++++++++++++++++++++
>> 2 files changed, 92 insertions(+), 0 deletions(-)
>> create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
>>
>> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
>> new file mode 100644
>> index 0000000..1d5d7a8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
>> @@ -0,0 +1,21 @@
>> +* ARM Primecell Peripherals
>> +
>> +ARM, Ltd. Primecell peripherals have a standard id register that can be used to
>> +identify the peripheral type, vendor, and revision. This value can be used for
>> +driver matching.
>> +
>> +Required properties:
>> +
>> +- compatible : should be a specific value for peripheral and "arm,primecell"
>
> Can I review what I wrote... Perhaps we should put strings in for all
> existing drivers in the kernel. This should be a complete list:
>
> arm,pl010
> arm,pl011
> st,pl011
> arm,pl022
> st,pl022
> st,pl023
> arm,pl030
> arm,pl031
> st,pl031
> arm,pl061
> arm,pl050
> arm,pl080
> arm,pl081
> st,pl080
> arm,pl110
> arm,pl180
> arm,pl330
> arm,sp804
> arm,sp805
Yes, this whole list should be added.
g.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-23 20:55 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-23 20:55 UTC (permalink / raw)
To: Rob Herring
Cc: Nicolas Pitre, Russell King, Arnd Bergmann, devicetree-discuss,
linux-kernel, linuxppc-dev, linux-arm-kernel
On Tue, Jun 21, 2011 at 2:07 PM, Rob Herring <robherring2@gmail.com> wrote:
> Grant,
>
> On 06/21/2011 01:45 PM, Grant Likely wrote:
>> Add a function to create amba_devices (i.e. primecell peripherals)
>> from device tree nodes. The device tree scanning is done by the
>> of_platform_populate() function which can call of_amba_device_create
>> based on a match table entry.
>>
>> Nodes with a "arm,primecell-periphid" property can override the h/w
>> peripheral id value.
>>
>> Based on the original work by Jeremy Kerr.
>>
>> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
>> [grant.likely: add Jeremy's original s-o-b line, changes from review
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0comments, and moved all code to drivers/o=
f/platform.c]
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> ---
>> =A0.../devicetree/bindings/arm/primecell.txt =A0 =A0 =A0 =A0 =A0| =A0 21=
++++++
>> =A0drivers/of/platform.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0| =A0 71 ++++++++++++++++++++
>> =A02 files changed, 92 insertions(+), 0 deletions(-)
>> =A0create mode 100644 Documentation/devicetree/bindings/arm/primecell.tx=
t
>>
>> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Docum=
entation/devicetree/bindings/arm/primecell.txt
>> new file mode 100644
>> index 0000000..1d5d7a8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
>> @@ -0,0 +1,21 @@
>> +* ARM Primecell Peripherals
>> +
>> +ARM, Ltd. Primecell peripherals have a standard id register that can be=
used to
>> +identify the peripheral type, vendor, and revision. This value can be u=
sed for
>> +driver matching.
>> +
>> +Required properties:
>> +
>> +- compatible : should be a specific value for peripheral and "arm,prime=
cell"
>
> Can I review what I wrote... Perhaps we should put strings in for all
> existing drivers in the kernel. This should be a complete list:
>
> arm,pl010
> arm,pl011
> st,pl011
> arm,pl022
> st,pl022
> st,pl023
> arm,pl030
> arm,pl031
> st,pl031
> arm,pl061
> arm,pl050
> arm,pl080
> arm,pl081
> st,pl080
> arm,pl110
> arm,pl180
> arm,pl330
> arm,sp804
> arm,sp805
Yes, this whole list should be added.
g.
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH 3/5] drivers/amba: create devices from device tree
@ 2011-06-23 20:55 ` Grant Likely
0 siblings, 0 replies; 27+ messages in thread
From: Grant Likely @ 2011-06-23 20:55 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Jun 21, 2011 at 2:07 PM, Rob Herring <robherring2@gmail.com> wrote:
> Grant,
>
> On 06/21/2011 01:45 PM, Grant Likely wrote:
>> Add a function to create amba_devices (i.e. primecell peripherals)
>> from device tree nodes. The device tree scanning is done by the
>> of_platform_populate() function which can call of_amba_device_create
>> based on a match table entry.
>>
>> Nodes with a "arm,primecell-periphid" property can override the h/w
>> peripheral id value.
>>
>> Based on the original work by Jeremy Kerr.
>>
>> Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
>> Acked-by: Linus Walleij <linus.walleij@linaro.org>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
>> [grant.likely: add Jeremy's original s-o-b line, changes from review
>> ? ? ? ? ? ? ? ?comments, and moved all code to drivers/of/platform.c]
>> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
>> ---
>> ?.../devicetree/bindings/arm/primecell.txt ? ? ? ? ?| ? 21 ++++++
>> ?drivers/of/platform.c ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?| ? 71 ++++++++++++++++++++
>> ?2 files changed, 92 insertions(+), 0 deletions(-)
>> ?create mode 100644 Documentation/devicetree/bindings/arm/primecell.txt
>>
>> diff --git a/Documentation/devicetree/bindings/arm/primecell.txt b/Documentation/devicetree/bindings/arm/primecell.txt
>> new file mode 100644
>> index 0000000..1d5d7a8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/arm/primecell.txt
>> @@ -0,0 +1,21 @@
>> +* ARM Primecell Peripherals
>> +
>> +ARM, Ltd. Primecell peripherals have a standard id register that can be used to
>> +identify the peripheral type, vendor, and revision. This value can be used for
>> +driver matching.
>> +
>> +Required properties:
>> +
>> +- compatible : should be a specific value for peripheral and "arm,primecell"
>
> Can I review what I wrote... Perhaps we should put strings in for all
> existing drivers in the kernel. This should be a complete list:
>
> arm,pl010
> arm,pl011
> st,pl011
> arm,pl022
> st,pl022
> st,pl023
> arm,pl030
> arm,pl031
> st,pl031
> arm,pl061
> arm,pl050
> arm,pl080
> arm,pl081
> st,pl080
> arm,pl110
> arm,pl180
> arm,pl330
> arm,sp804
> arm,sp805
Yes, this whole list should be added.
g.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 5/5] powerpc/5200: convert mpc5200 to use of_platform_populate()
2011-06-21 18:45 ` Grant Likely
@ 2012-03-20 16:20 ` Anatolij Gustschin
-1 siblings, 0 replies; 27+ messages in thread
From: Anatolij Gustschin @ 2012-03-20 16:20 UTC (permalink / raw)
To: Grant Likely
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ
On Tue, 21 Jun 2011 12:45:13 -0600
Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> wrote:
> of_platform_populate() also handles nodes at the root of the tree,
> which is wanted for things like describing the sound complex. This
> patch converts mpc5200 support to use of_platform_populate() instead
> of of_platform_bus_probe().
>
> Signed-off-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> ---
> arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
Applied for mpc5xxx next, thanks.
Anatolij
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH 5/5] powerpc/5200: convert mpc5200 to use of_platform_populate()
@ 2012-03-20 16:20 ` Anatolij Gustschin
0 siblings, 0 replies; 27+ messages in thread
From: Anatolij Gustschin @ 2012-03-20 16:20 UTC (permalink / raw)
To: Grant Likely; +Cc: devicetree-discuss, linuxppc-dev
On Tue, 21 Jun 2011 12:45:13 -0600
Grant Likely <grant.likely@secretlab.ca> wrote:
> of_platform_populate() also handles nodes at the root of the tree,
> which is wanted for things like describing the sound complex. This
> patch converts mpc5200 support to use of_platform_populate() instead
> of of_platform_bus_probe().
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> ---
> arch/powerpc/platforms/52xx/mpc52xx_common.c | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
Applied for mpc5xxx next, thanks.
Anatolij
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2012-03-20 16:20 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-21 18:44 [PATCH 0/5] dt: Device creation infrastructure Grant Likely
2011-06-21 18:44 ` Grant Likely
2011-06-21 18:44 ` Grant Likely
2011-06-21 18:44 ` [PATCH 1/5] dt: Add default match table for bus ids Grant Likely
2011-06-21 18:44 ` Grant Likely
2011-06-21 18:44 ` Grant Likely
2011-06-21 18:44 ` [PATCH 2/5] dt: add of_platform_populate() for creating device from the device tree Grant Likely
2011-06-21 18:44 ` Grant Likely
2011-06-21 18:44 ` Grant Likely
2011-06-21 18:45 ` [PATCH 3/5] drivers/amba: create devices from " Grant Likely
2011-06-21 18:45 ` Grant Likely
2011-06-21 18:45 ` Grant Likely
2011-06-21 20:07 ` Rob Herring
2011-06-21 20:07 ` Rob Herring
2011-06-21 20:07 ` Rob Herring
2011-06-21 20:07 ` Rob Herring
2011-06-23 20:55 ` Grant Likely
2011-06-23 20:55 ` Grant Likely
2011-06-23 20:55 ` Grant Likely
2011-06-21 18:45 ` [PATCH 4/5] dt/platform: allow device name to be overridden Grant Likely
2011-06-21 18:45 ` Grant Likely
2011-06-21 18:45 ` Grant Likely
2011-06-21 18:45 ` [PATCH 5/5] powerpc/5200: convert mpc5200 to use of_platform_populate() Grant Likely
2011-06-21 18:45 ` Grant Likely
2011-06-21 18:45 ` Grant Likely
2012-03-20 16:20 ` Anatolij Gustschin
2012-03-20 16:20 ` Anatolij Gustschin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.