devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/8] Allow usage of independant devicetrees
@ 2016-03-11 15:56 Franck Jullien
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

This patch serie allow modules to register their own devicetree.

I started to work on this because I work on a PCIe board with
a FPGA. The FPGA acts as a bridge. Behind this bridge I use Xilinx
IPs. The problem is that Xilinx IPs support in the Kernel as been
made with Zynq or Microblaze in mind. They require devicetree
support.

The idea is that a pci module could be shipped with its own
devicetree describing whats behind the BARs.

Here is an example of what could be such a tree:
/dts-v1/;
/ {
	compatible = "pci,pci_dev";
	#address-cells = <1>;
	#size-cells = <1>;

	bar@0 {
		compatible = "pci,pci_bar";
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0 0>;
		/* Dynamically set by module */
		ranges = <0 0 0>;

		axi_vdma_0: axivdma@10000 {
			compatible = "xlnx,axi-vdma-1.00.a";
			#dma-cells = <1>;
			reg = <0x10000 0x10000>;
			xlnx,num-fstores = <0x8>;
			xlnx,flush-fsync = <0x1>;
			dma-channel@0x10000 {
				compatible = "xlnx,axi-vdma-s2mm-channel";
				/* New flag */
				irq_direct_mapping;
				/* Dynamically set by module */
				interrupts = <0>;
				xlnx,datawidth = <0x40>;
			} ;
		};
	};
};

Ranges an interrupts are dynamically set by the module at
probe time.

For interrupts, we could also think of a special interrupt
controller for this application. For now [7/8] looks like
a hack.

An example of module using this serie (and the associated dts) can 
be found on my Github account [1].

I my example you'll see that I use a Makefile rule to compile
the devicetree and then generates a C array from the blob.
The module should use the dtb target to generate the blob but
I couldn't find the good way to do that for a module on a x86
target. Help is welcome.

Patch [1/8] should no be part of this serie. However, it shows
that if we allow independant devicetree, every architecture should
be able to select USE_OF. The better would be to have of support
as a module.

Don't take this serie as a finished work. There is a lot of aspects
to improve. May be we should start to implement multi-root node
properly as a lot of functions assume of_root is the only devicetree
present in the system.

Franck Jullien (8):
  arch/x86: Add Kconfig USE_OF
  drivers/of: attach top level tree nodes to sysfs with their name
  drivers/of: export of_attach_node_sysfs
  drivers/of: export of_update_property
  drivers/of: rename __of_find_all_nodes and export it
  of.h: add for_each_compatible_node_from helper
  drivers/of: allow irq direct mapping
  drivers/of: parse_phandle_with_args to look in node's root

 arch/x86/Kconfig        |    7 ++++++
 drivers/of/base.c       |   49 +++++++++++++++++++++++++++++++++++++++++-----
 drivers/of/dynamic.c    |    4 +-
 drivers/of/irq.c        |    6 +++++
 drivers/of/of_private.h |    1 -
 drivers/of/platform.c   |    6 ++++-
 drivers/of/unittest.c   |    4 +-
 include/linux/of.h      |   15 ++++++++++++-
 8 files changed, 78 insertions(+), 14 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 1/8] arch/x86: Add Kconfig USE_OF
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 2/8] drivers/of: attach top level tree nodes to sysfs with their name Franck Jullien
                     ` (8 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 arch/x86/Kconfig |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index c46662f..6948691 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -292,6 +292,13 @@ config X86_32_LAZY_GS
 	def_bool y
 	depends on X86_32 && !CC_STACKPROTECTOR
 
+config USE_OF
+	bool "Support for device tree"
+	select OF
+	select OF_EARLY_FLATTREE
+	---help---
+	  Device tree support on X86.
+
 config ARCH_HWEIGHT_CFLAGS
 	string
 	default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 2/8] drivers/of: attach top level tree nodes to sysfs with their name
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
  2016-03-11 15:56   ` [RFC 1/8] arch/x86: Add Kconfig USE_OF Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 3/8] drivers/of: export of_attach_node_sysfs Franck Jullien
                     ` (7 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

Nodes without parents are new top level trees. If we want to attach
more than one tree, we need a different name for each top node.

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 drivers/of/base.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 017dd94..a7ff11f 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -172,7 +172,7 @@ int __of_attach_node_sysfs(struct device_node *np)
 	if (!np->parent) {
 		/* Nodes without parents are new top level trees */
 		rc = kobject_add(&np->kobj, NULL, "%s",
-				 safe_name(&of_kset->kobj, "base"));
+				 safe_name(&of_kset->kobj, np == of_root ? "base" : np->name));
 	} else {
 		name = safe_name(&np->parent->kobj, kbasename(np->full_name));
 		if (!name || !name[0])
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 3/8] drivers/of: export of_attach_node_sysfs
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
  2016-03-11 15:56   ` [RFC 1/8] arch/x86: Add Kconfig USE_OF Franck Jullien
  2016-03-11 15:56   ` [RFC 2/8] drivers/of: attach top level tree nodes to sysfs with their name Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 4/8] drivers/of: export of_update_property Franck Jullien
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 drivers/of/base.c       |    5 +++--
 drivers/of/dynamic.c    |    4 ++--
 drivers/of/of_private.h |    1 -
 drivers/of/unittest.c   |    4 ++--
 include/linux/of.h      |    2 ++
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index a7ff11f..faa108a 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -156,7 +156,7 @@ int __of_add_property_sysfs(struct device_node *np, struct property *pp)
 	return rc;
 }
 
-int __of_attach_node_sysfs(struct device_node *np)
+int of_attach_node_sysfs(struct device_node *np)
 {
 	const char *name;
 	struct property *pp;
@@ -188,6 +188,7 @@ int __of_attach_node_sysfs(struct device_node *np)
 
 	return 0;
 }
+EXPORT_SYMBOL(of_attach_node_sysfs);
 
 void __init of_core_init(void)
 {
@@ -202,7 +203,7 @@ void __init of_core_init(void)
 		return;
 	}
 	for_each_of_allnodes(np)
-		__of_attach_node_sysfs(np);
+		of_attach_node_sysfs(np);
 	mutex_unlock(&of_mutex);
 
 	/* Symlink in /proc as required by userspace ABI */
diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
index c647bd1..ff03c85 100644
--- a/drivers/of/dynamic.c
+++ b/drivers/of/dynamic.c
@@ -251,7 +251,7 @@ int of_attach_node(struct device_node *np)
 	__of_attach_node(np);
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
 
-	__of_attach_node_sysfs(np);
+	of_attach_node_sysfs(np);
 	mutex_unlock(&of_mutex);
 
 	of_reconfig_notify(OF_RECONFIG_ATTACH_NODE, &rd);
@@ -606,7 +606,7 @@ static int __of_changeset_entry_apply(struct of_changeset_entry *ce)
 
 	switch (ce->action) {
 	case OF_RECONFIG_ATTACH_NODE:
-		__of_attach_node_sysfs(ce->np);
+		of_attach_node_sysfs(ce->np);
 		break;
 	case OF_RECONFIG_DETACH_NODE:
 		__of_detach_node_sysfs(ce->np);
diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h
index 829469f..1bf7deb 100644
--- a/drivers/of/of_private.h
+++ b/drivers/of/of_private.h
@@ -79,7 +79,6 @@ extern void __of_update_property_sysfs(struct device_node *np,
 		struct property *newprop, struct property *oldprop);
 
 extern void __of_attach_node(struct device_node *np);
-extern int __of_attach_node_sysfs(struct device_node *np);
 extern void __of_detach_node(struct device_node *np);
 extern void __of_detach_node_sysfs(struct device_node *np);
 
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 979b6e4..5986b05 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -878,7 +878,7 @@ static int attach_node_and_children(struct device_node *np)
 	of_node_clear_flag(np, OF_DETACHED);
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
 
-	__of_attach_node_sysfs(np);
+	of_attach_node_sysfs(np);
 	mutex_unlock(&of_mutex);
 
 	while (child) {
@@ -936,7 +936,7 @@ static int __init unittest_data_add(void)
 	if (!of_root) {
 		of_root = unittest_data_node;
 		for_each_of_allnodes(np)
-			__of_attach_node_sysfs(np);
+			of_attach_node_sysfs(np);
 		of_aliases = of_find_node_by_path("/aliases");
 		of_chosen = of_find_node_by_path("/chosen");
 		return 0;
diff --git a/include/linux/of.h b/include/linux/of.h
index dc6e396..d6c31fd 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -344,6 +344,8 @@ extern int of_add_property(struct device_node *np, struct property *prop);
 extern int of_remove_property(struct device_node *np, struct property *prop);
 extern int of_update_property(struct device_node *np, struct property *newprop);
 
+extern int of_attach_node_sysfs(struct device_node *np);
+
 /* For updating the device tree at runtime */
 #define OF_RECONFIG_ATTACH_NODE		0x0001
 #define OF_RECONFIG_DETACH_NODE		0x0002
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 4/8] drivers/of: export of_update_property
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (2 preceding siblings ...)
  2016-03-11 15:56   ` [RFC 3/8] drivers/of: export of_attach_node_sysfs Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 5/8] drivers/of: rename __of_find_all_nodes and export it Franck Jullien
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 drivers/of/base.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index faa108a..fd75a45 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1869,6 +1869,7 @@ int of_update_property(struct device_node *np, struct property *newprop)
 
 	return rc;
 }
+EXPORT_SYMBOL(of_update_property);
 
 static void of_alias_add(struct alias_prop *ap, struct device_node *np,
 			 int id, const char *stem, int stem_len)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 5/8] drivers/of: rename __of_find_all_nodes and export it
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (3 preceding siblings ...)
  2016-03-11 15:56   ` [RFC 4/8] drivers/of: export of_update_property Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 6/8] of.h: add for_each_compatible_node_from helper Franck Jullien
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

In order to export __of_find_all_nodes, we need to rename it.
It is now of_walk_to_all_nodes.

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 drivers/of/base.c  |    5 +++--
 include/linux/of.h |    4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index fd75a45..331141b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -245,7 +245,7 @@ struct property *of_find_property(const struct device_node *np,
 }
 EXPORT_SYMBOL(of_find_property);
 
-struct device_node *__of_find_all_nodes(struct device_node *prev)
+struct device_node *of_walk_to_all_nodes(struct device_node *prev)
 {
 	struct device_node *np;
 	if (!prev) {
@@ -261,6 +261,7 @@ struct device_node *__of_find_all_nodes(struct device_node *prev)
 	}
 	return np;
 }
+EXPORT_SYMBOL(of_walk_to_all_nodes);
 
 /**
  * of_find_all_nodes - Get next node in global list
@@ -276,7 +277,7 @@ struct device_node *of_find_all_nodes(struct device_node *prev)
 	unsigned long flags;
 
 	raw_spin_lock_irqsave(&devtree_lock, flags);
-	np = __of_find_all_nodes(prev);
+	np = of_walk_to_all_nodes(prev);
 	of_node_get(np);
 	of_node_put(prev);
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
diff --git a/include/linux/of.h b/include/linux/of.h
index d6c31fd..883df55 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -188,7 +188,7 @@ static inline void of_property_clear_flag(struct property *p, unsigned long flag
 	clear_bit(flag, &p->_flags);
 }
 
-extern struct device_node *__of_find_all_nodes(struct device_node *prev);
+extern struct device_node *of_walk_to_all_nodes(struct device_node *prev);
 extern struct device_node *of_find_all_nodes(struct device_node *prev);
 
 /*
@@ -237,7 +237,7 @@ static inline const char *of_node_full_name(const struct device_node *np)
 }
 
 #define for_each_of_allnodes_from(from, dn) \
-	for (dn = __of_find_all_nodes(from); dn; dn = __of_find_all_nodes(dn))
+	for (dn = of_walk_to_all_nodes(from); dn; dn = of_walk_to_all_nodes(dn))
 #define for_each_of_allnodes(dn) for_each_of_allnodes_from(NULL, dn)
 extern struct device_node *of_find_node_by_name(struct device_node *from,
 	const char *name);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 6/8] of.h: add for_each_compatible_node_from helper
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (4 preceding siblings ...)
  2016-03-11 15:56   ` [RFC 5/8] drivers/of: rename __of_find_all_nodes and export it Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 7/8] drivers/of: allow irq direct mapping Franck Jullien
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

When working with independant trees, one need to find each
compatible node from something else than of_root.

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 include/linux/of.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/include/linux/of.h b/include/linux/of.h
index 883df55..37da652 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -891,6 +891,9 @@ static inline int of_property_read_s32(const struct device_node *np,
 #define for_each_compatible_node(dn, type, compatible) \
 	for (dn = of_find_compatible_node(NULL, type, compatible); dn; \
 	     dn = of_find_compatible_node(dn, type, compatible))
+#define for_each_compatible_node_from(from, dn, type, compatible) \
+	for (dn = of_find_compatible_node(from, type, compatible); dn; \
+	     dn = of_find_compatible_node(dn, type, compatible))
 #define for_each_matching_node(dn, matches) \
 	for (dn = of_find_matching_node(NULL, matches); dn; \
 	     dn = of_find_matching_node(dn, matches))
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 7/8] drivers/of: allow irq direct mapping
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (5 preceding siblings ...)
  2016-03-11 15:56   ` [RFC 6/8] of.h: add for_each_compatible_node_from helper Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 15:56   ` [RFC 8/8] drivers/of: parse_phandle_with_args to look in node's root Franck Jullien
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 drivers/of/irq.c      |    6 ++++++
 drivers/of/platform.c |    6 +++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index e7bfc17..afcbfc9 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -38,6 +38,12 @@
 unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
 {
 	struct of_phandle_args oirq;
+	int irq;
+
+	if (of_find_property(dev, "irq_direct_mapping", NULL)) {
+		of_property_read_u32(dev, "interrupts", &irq);
+		return irq;
+	}
 
 	if (of_irq_parse_one(dev, index, &oirq))
 		return 0;
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 8d103e4..d29f65d 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -118,7 +118,11 @@ struct platform_device *of_device_alloc(struct device_node *np,
 	/* count the io and irq resources */
 	while (of_address_to_resource(np, num_reg, &temp_res) == 0)
 		num_reg++;
-	num_irq = of_irq_count(np);
+	if (of_find_property(np, "irq_direct_mapping", NULL))
+		num_irq = 1;
+	else
+		num_irq = of_irq_count(np);
+
 
 	/* Populate the resource table */
 	if (num_irq || num_reg) {
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [RFC 8/8] drivers/of: parse_phandle_with_args to look in node's root
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (6 preceding siblings ...)
  2016-03-11 15:56   ` [RFC 7/8] drivers/of: allow irq direct mapping Franck Jullien
@ 2016-03-11 15:56   ` Franck Jullien
  2016-03-11 16:37   ` [RFC 0/8] Allow usage of independant devicetrees Franck Jullien
  2016-03-17 14:37   ` Rob Herring
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 15:56 UTC (permalink / raw)
  To: devicetree-u79uwXL29TY76Z2rM5mHXA
  Cc: lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf,
	laurent.pinchart-ryLnwIuWjnjg/C1BVhZhaw, Franck Jullien

Signed-off-by: Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
---
 drivers/of/base.c  |   36 +++++++++++++++++++++++++++++++++++-
 include/linux/of.h |    8 +++++++-
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 331141b..c0165cb 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1080,6 +1080,31 @@ struct device_node *of_find_node_by_phandle(phandle handle)
 EXPORT_SYMBOL(of_find_node_by_phandle);
 
 /**
+ * of_find_node_by_phandle_from - Find a node given a phandle in a given tree
+ * @handle:	phandle of the node to find
+ *
+ * Returns a node pointer with refcount incremented, use
+ * of_node_put() on it when done.
+ */
+struct device_node *of_find_node_by_phandle_from(struct device_node *root, phandle handle)
+{
+	struct device_node *np;
+	unsigned long flags;
+
+	if (!handle)
+		return NULL;
+
+	raw_spin_lock_irqsave(&devtree_lock, flags);
+	for_each_of_allnodes_from(root, np)
+		if (np->phandle == handle)
+			break;
+	of_node_get(np);
+	raw_spin_unlock_irqrestore(&devtree_lock, flags);
+	return np;
+}
+EXPORT_SYMBOL(of_find_node_by_phandle_from);
+
+/**
  * of_property_count_elems_of_size - Count the number of elements in a property
  *
  * @np:		device node from which the property value is to be read.
@@ -1441,6 +1466,15 @@ void of_print_phandle_args(const char *msg, const struct of_phandle_args *args)
 	printk("\n");
 }
 
+struct device_node *find_root_node(struct device_node *np)
+{
+	while (np->parent)
+		np = np->parent;
+
+	return np;
+}
+EXPORT_SYMBOL(find_root_node);
+
 static int __of_parse_phandle_with_args(const struct device_node *np,
 					const char *list_name,
 					const char *cells_name,
@@ -1480,7 +1514,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
 			 * below.
 			 */
 			if (cells_name || cur_index == index) {
-				node = of_find_node_by_phandle(phandle);
+				node = of_find_node_by_phandle_from(find_root_node(np), phandle);
 				if (!node) {
 					pr_err("%s: could not find phandle\n",
 						np->full_name);
diff --git a/include/linux/of.h b/include/linux/of.h
index 37da652..21e192f 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -258,6 +258,7 @@ static inline struct device_node *of_find_node_by_path(const char *path)
 }
 
 extern struct device_node *of_find_node_by_phandle(phandle handle);
+extern struct device_node *of_find_node_by_phandle_from(struct device_node *root, phandle handle);
 extern struct device_node *of_get_parent(const struct device_node *node);
 extern struct device_node *of_get_next_parent(struct device_node *node);
 extern struct device_node *of_get_next_child(const struct device_node *node,
@@ -343,7 +344,7 @@ extern int of_machine_is_compatible(const char *compat);
 extern int of_add_property(struct device_node *np, struct property *prop);
 extern int of_remove_property(struct device_node *np, struct property *prop);
 extern int of_update_property(struct device_node *np, struct property *newprop);
-
+extern struct device_node *find_root_node(struct device_node *np);
 extern int of_attach_node_sysfs(struct device_node *np);
 
 /* For updating the device tree at runtime */
@@ -436,6 +437,11 @@ static inline struct device_node *of_find_node_by_phandle(phandle handle)
 	return NULL;
 }
 
+static inline struct device_node *of_find_node_by_phandle_from(phandle handle)
+{
+	return NULL;
+}
+
 static inline struct device_node *of_get_parent(const struct device_node *node)
 {
 	return NULL;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC 0/8] Allow usage of independant devicetrees
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (7 preceding siblings ...)
  2016-03-11 15:56   ` [RFC 8/8] drivers/of: parse_phandle_with_args to look in node's root Franck Jullien
@ 2016-03-11 16:37   ` Franck Jullien
  2016-03-17 14:37   ` Rob Herring
  9 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-11 16:37 UTC (permalink / raw)
  To: Franck Jullien
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, lars-Qo5EllUWu/uELgA04lAiVw,
	panto-wVdstyuyKrO8r51toPun2/C9HSW9iNxf, Laurent Pinchart

2016-03-11 16:56 GMT+01:00 Franck Jullien <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>:
> This patch serie allow modules to register their own devicetree.
>
> I started to work on this because I work on a PCIe board with
> a FPGA. The FPGA acts as a bridge. Behind this bridge I use Xilinx
> IPs. The problem is that Xilinx IPs support in the Kernel as been
> made with Zynq or Microblaze in mind. They require devicetree
> support.
>
> The idea is that a pci module could be shipped with its own
> devicetree describing whats behind the BARs.
>
> Here is an example of what could be such a tree:
> /dts-v1/;
> / {
>         compatible = "pci,pci_dev";
>         #address-cells = <1>;
>         #size-cells = <1>;
>
>         bar@0 {
>                 compatible = "pci,pci_bar";
>                 #address-cells = <1>;
>                 #size-cells = <1>;
>                 reg = <0 0>;
>                 /* Dynamically set by module */
>                 ranges = <0 0 0>;
>
>                 axi_vdma_0: axivdma@10000 {
>                         compatible = "xlnx,axi-vdma-1.00.a";
>                         #dma-cells = <1>;
>                         reg = <0x10000 0x10000>;
>                         xlnx,num-fstores = <0x8>;
>                         xlnx,flush-fsync = <0x1>;
>                         dma-channel@0x10000 {
>                                 compatible = "xlnx,axi-vdma-s2mm-channel";
>                                 /* New flag */
>                                 irq_direct_mapping;
>                                 /* Dynamically set by module */
>                                 interrupts = <0>;
>                                 xlnx,datawidth = <0x40>;
>                         } ;
>                 };
>         };
> };
>
> Ranges an interrupts are dynamically set by the module at
> probe time.
>
> For interrupts, we could also think of a special interrupt
> controller for this application. For now [7/8] looks like
> a hack.
>
> An example of module using this serie (and the associated dts) can
> be found on my Github account [1].
>
> I my example you'll see that I use a Makefile rule to compile
> the devicetree and then generates a C array from the blob.
> The module should use the dtb target to generate the blob but
> I couldn't find the good way to do that for a module on a x86
> target. Help is welcome.
>
> Patch [1/8] should no be part of this serie. However, it shows
> that if we allow independant devicetree, every architecture should
> be able to select USE_OF. The better would be to have of support
> as a module.
>
> Don't take this serie as a finished work. There is a lot of aspects
> to improve. May be we should start to implement multi-root node
> properly as a lot of functions assume of_root is the only devicetree
> present in the system.
>
> Franck Jullien (8):
>   arch/x86: Add Kconfig USE_OF
>   drivers/of: attach top level tree nodes to sysfs with their name
>   drivers/of: export of_attach_node_sysfs
>   drivers/of: export of_update_property
>   drivers/of: rename __of_find_all_nodes and export it
>   of.h: add for_each_compatible_node_from helper
>   drivers/of: allow irq direct mapping
>   drivers/of: parse_phandle_with_args to look in node's root
>
>  arch/x86/Kconfig        |    7 ++++++
>  drivers/of/base.c       |   49 +++++++++++++++++++++++++++++++++++++++++-----
>  drivers/of/dynamic.c    |    4 +-
>  drivers/of/irq.c        |    6 +++++
>  drivers/of/of_private.h |    1 -
>  drivers/of/platform.c   |    6 ++++-
>  drivers/of/unittest.c   |    4 +-
>  include/linux/of.h      |   15 ++++++++++++-
>  8 files changed, 78 insertions(+), 14 deletions(-)
>
> --
> To unsubscribe from this list: send the line "unsubscribe devicetree" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Here is the missing link:

[1] https://github.com/fjullien/of_pci_module_example
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC 0/8] Allow usage of independant devicetrees
       [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
                     ` (8 preceding siblings ...)
  2016-03-11 16:37   ` [RFC 0/8] Allow usage of independant devicetrees Franck Jullien
@ 2016-03-17 14:37   ` Rob Herring
       [not found]     ` <CAL_JsqJ_JB=DXJAyzBfm3JvShq8U5+Jg1mOjY_0gM=zTbwFXVw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  9 siblings, 1 reply; 13+ messages in thread
From: Rob Herring @ 2016-03-17 14:37 UTC (permalink / raw)
  To: Franck Jullien
  Cc: devicetree-u79uwXL29TY76Z2rM5mHXA, Lars-Peter Clausen,
	Pantelis Antoniou, Laurent Pinchart

On Fri, Mar 11, 2016 at 9:56 AM, Franck Jullien
<franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org> wrote:
> This patch serie allow modules to register their own devicetree.

I've not looked at this thoroughly, but have some initial comments.
Some of what you are doing should already be possible. The DT unittest
essentially does this. I know we wanted it to work as a module, but it
does not currently. Fixing issues with building it as a module would
be a good first step and be contained to just one part of the problems
you face.

> I started to work on this because I work on a PCIe board with
> a FPGA. The FPGA acts as a bridge. Behind this bridge I use Xilinx
> IPs. The problem is that Xilinx IPs support in the Kernel as been
> made with Zynq or Microblaze in mind. They require devicetree
> support.
>
> The idea is that a pci module could be shipped with its own
> devicetree describing whats behind the BARs.
>
> Here is an example of what could be such a tree:
> /dts-v1/;
> / {

This should all be moved down a level rather than being at the root
level. The root is somewhat special and you need to deal with things
like having 2 or more cards.

>         compatible = "pci,pci_dev";

We already have defined way to do PCI device compatible strings[1].

>         #address-cells = <1>;
>         #size-cells = <1>;
>
>         bar@0 {
>                 compatible = "pci,pci_bar";

Describing this in terms of BARs seems strange to me. There are
examples of ISA buses downstream of PCI buses in some powerpc DTs. I
think we want to follow something similar here in terms of structure.

>                 #address-cells = <1>;
>                 #size-cells = <1>;
>                 reg = <0 0>;
>                 /* Dynamically set by module */
>                 ranges = <0 0 0>;
>
>                 axi_vdma_0: axivdma@10000 {
>                         compatible = "xlnx,axi-vdma-1.00.a";
>                         #dma-cells = <1>;
>                         reg = <0x10000 0x10000>;
>                         xlnx,num-fstores = <0x8>;
>                         xlnx,flush-fsync = <0x1>;
>                         dma-channel@0x10000 {
>                                 compatible = "xlnx,axi-vdma-s2mm-channel";
>                                 /* New flag */
>                                 irq_direct_mapping;
>                                 /* Dynamically set by module */
>                                 interrupts = <0>;
>                                 xlnx,datawidth = <0x40>;
>                         } ;
>                 };
>         };
> };
>
> Ranges an interrupts are dynamically set by the module at
> probe time.
>
> For interrupts, we could also think of a special interrupt
> controller for this application. For now [7/8] looks like
> a hack.
>
> An example of module using this serie (and the associated dts) can
> be found on my Github account [1].
>
> I my example you'll see that I use a Makefile rule to compile
> the devicetree and then generates a C array from the blob.
> The module should use the dtb target to generate the blob but
> I couldn't find the good way to do that for a module on a x86
> target. Help is welcome.

obj-y += your-dts-file.dtb

> Patch [1/8] should no be part of this serie. However, it shows
> that if we allow independant devicetree, every architecture should
> be able to select USE_OF. The better would be to have of support
> as a module.

CONFIG_OF is already user selectable.

> Don't take this serie as a finished work. There is a lot of aspects
> to improve. May be we should start to implement multi-root node
> properly as a lot of functions assume of_root is the only devicetree
> present in the system.

I think this should all be using overlays. I'm not sure that we
support applying overlays with no root DT ATM, but I know others are
certainly interested in doing just that and creating a default
skeleton DT root node should be trivial.

The big challenge here how to describe child devices which don't have
the parent described in DT. Perhaps we need some sort of virtual
parent(s) which have all the necessary providers like interrupts.

Rob

[1] http://www.o3one.org/hwdocs/openfirmware/pci_supplement_2_1.pdf
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC 0/8] Allow usage of independant devicetrees
       [not found]     ` <CAL_JsqJ_JB=DXJAyzBfm3JvShq8U5+Jg1mOjY_0gM=zTbwFXVw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-03-18 10:06       ` Franck Jullien
       [not found]         ` <CAJfOKByPe4O4uLHRmnrwVsP-=uPbgdKyW3=SAUJcz5hDiEK+fQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Franck Jullien @ 2016-03-18 10:06 UTC (permalink / raw)
  To: Rob Herring
  Cc: Franck Jullien, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Lars-Peter Clausen, Pantelis Antoniou, Laurent Pinchart

2016-03-17 15:37 GMT+01:00 Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>:
> On Fri, Mar 11, 2016 at 9:56 AM, Franck Jullien
> <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org> wrote:
>> This patch serie allow modules to register their own devicetree.
>
> I've not looked at this thoroughly, but have some initial comments.
> Some of what you are doing should already be possible. The DT unittest
> essentially does this. I know we wanted it to work as a module, but it
> does not currently. Fixing issues with building it as a module would
> be a good first step and be contained to just one part of the problems
> you face.
>

I was speaking about making OF base support as a module. But the more
I think about this, the more I realize this is not necessary.
Modularize the DT unittest is a good idea. I'll do that.

>> I started to work on this because I work on a PCIe board with
>> a FPGA. The FPGA acts as a bridge. Behind this bridge I use Xilinx
>> IPs. The problem is that Xilinx IPs support in the Kernel as been
>> made with Zynq or Microblaze in mind. They require devicetree
>> support.
>>
>> The idea is that a pci module could be shipped with its own
>> devicetree describing whats behind the BARs.
>>
>> Here is an example of what could be such a tree:
>> /dts-v1/;
>> / {
>
> This should all be moved down a level rather than being at the root
> level. The root is somewhat special and you need to deal with things
> like having 2 or more cards.
>

This does work with several cards. You'll just have as many trees as cards.

>>         compatible = "pci,pci_dev";
>
> We already have defined way to do PCI device compatible strings[1].
>
>>         #address-cells = <1>;
>>         #size-cells = <1>;
>>
>>         bar@0 {
>>                 compatible = "pci,pci_bar";
>
> Describing this in terms of BARs seems strange to me. There are
> examples of ISA buses downstream of PCI buses in some powerpc DTs. I
> think we want to follow something similar here in terms of structure.
>

You're right. If we go this direction I'd better try to follow this description.
Thanks for the link.

>>                 #address-cells = <1>;
>>                 #size-cells = <1>;
>>                 reg = <0 0>;
>>                 /* Dynamically set by module */
>>                 ranges = <0 0 0>;
>>
>>                 axi_vdma_0: axivdma@10000 {
>>                         compatible = "xlnx,axi-vdma-1.00.a";
>>                         #dma-cells = <1>;
>>                         reg = <0x10000 0x10000>;
>>                         xlnx,num-fstores = <0x8>;
>>                         xlnx,flush-fsync = <0x1>;
>>                         dma-channel@0x10000 {
>>                                 compatible = "xlnx,axi-vdma-s2mm-channel";
>>                                 /* New flag */
>>                                 irq_direct_mapping;
>>                                 /* Dynamically set by module */
>>                                 interrupts = <0>;
>>                                 xlnx,datawidth = <0x40>;
>>                         } ;
>>                 };
>>         };
>> };
>>
>> Ranges an interrupts are dynamically set by the module at
>> probe time.
>>
>> For interrupts, we could also think of a special interrupt
>> controller for this application. For now [7/8] looks like
>> a hack.
>>
>> An example of module using this serie (and the associated dts) can
>> be found on my Github account [1].
>>
>> I my example you'll see that I use a Makefile rule to compile
>> the devicetree and then generates a C array from the blob.
>> The module should use the dtb target to generate the blob but
>> I couldn't find the good way to do that for a module on a x86
>> target. Help is welcome.
>
> obj-y += your-dts-file.dtb
>

This doesn't work for out-of-tree module build.

>> Patch [1/8] should no be part of this serie. However, it shows
>> that if we allow independant devicetree, every architecture should
>> be able to select USE_OF. The better would be to have of support
>> as a module.
>
> CONFIG_OF is already user selectable.
>

You're right. My mistake.

>> Don't take this serie as a finished work. There is a lot of aspects
>> to improve. May be we should start to implement multi-root node
>> properly as a lot of functions assume of_root is the only devicetree
>> present in the system.
>
> I think this should all be using overlays. I'm not sure that we
> support applying overlays with no root DT ATM, but I know others are
> certainly interested in doing just that and creating a default
> skeleton DT root node should be trivial.
>

We could test if of_root == NULL && CONFIG_OF in of_core_init.
If it is NULL, unflatten a default devicetree. Then we can use overlays.
If you like the idea, I'll work on this.

> The big challenge here how to describe child devices which don't have
> the parent described in DT. Perhaps we need some sort of virtual
> parent(s) which have all the necessary providers like interrupts.
>

Indeed, that's the real question. However, I think we would only need a
special interrupt controller.

Franck.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC 0/8] Allow usage of independant devicetrees
       [not found]         ` <CAJfOKByPe4O4uLHRmnrwVsP-=uPbgdKyW3=SAUJcz5hDiEK+fQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2016-03-18 20:12           ` Franck Jullien
  0 siblings, 0 replies; 13+ messages in thread
From: Franck Jullien @ 2016-03-18 20:12 UTC (permalink / raw)
  To: Rob Herring
  Cc: Franck Jullien, devicetree-u79uwXL29TY76Z2rM5mHXA,
	Lars-Peter Clausen, Pantelis Antoniou, Laurent Pinchart

2016-03-18 11:06 GMT+01:00 Franck Jullien <franck.jullien-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> 2016-03-17 15:37 GMT+01:00 Rob Herring <robh-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>:
>> On Fri, Mar 11, 2016 at 9:56 AM, Franck Jullien
>> <franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org> wrote:
>>> This patch serie allow modules to register their own devicetree.
>>
>> I've not looked at this thoroughly, but have some initial comments.
>> Some of what you are doing should already be possible. The DT unittest
>> essentially does this. I know we wanted it to work as a module, but it
>> does not currently. Fixing issues with building it as a module would
>> be a good first step and be contained to just one part of the problems
>> you face.
>>
>
> I was speaking about making OF base support as a module. But the more
> I think about this, the more I realize this is not necessary.
> Modularize the DT unittest is a good idea. I'll do that.
>
>>> I started to work on this because I work on a PCIe board with
>>> a FPGA. The FPGA acts as a bridge. Behind this bridge I use Xilinx
>>> IPs. The problem is that Xilinx IPs support in the Kernel as been
>>> made with Zynq or Microblaze in mind. They require devicetree
>>> support.
>>>
>>> The idea is that a pci module could be shipped with its own
>>> devicetree describing whats behind the BARs.
>>>
>>> Here is an example of what could be such a tree:
>>> /dts-v1/;
>>> / {
>>
>> This should all be moved down a level rather than being at the root
>> level. The root is somewhat special and you need to deal with things
>> like having 2 or more cards.
>>
>
> This does work with several cards. You'll just have as many trees as cards.
>
>>>         compatible = "pci,pci_dev";
>>
>> We already have defined way to do PCI device compatible strings[1].
>>
>>>         #address-cells = <1>;
>>>         #size-cells = <1>;
>>>
>>>         bar@0 {
>>>                 compatible = "pci,pci_bar";
>>
>> Describing this in terms of BARs seems strange to me. There are
>> examples of ISA buses downstream of PCI buses in some powerpc DTs. I
>> think we want to follow something similar here in terms of structure.
>>
>
> You're right. If we go this direction I'd better try to follow this description.
> Thanks for the link.
>
>>>                 #address-cells = <1>;
>>>                 #size-cells = <1>;
>>>                 reg = <0 0>;
>>>                 /* Dynamically set by module */
>>>                 ranges = <0 0 0>;
>>>
>>>                 axi_vdma_0: axivdma@10000 {
>>>                         compatible = "xlnx,axi-vdma-1.00.a";
>>>                         #dma-cells = <1>;
>>>                         reg = <0x10000 0x10000>;
>>>                         xlnx,num-fstores = <0x8>;
>>>                         xlnx,flush-fsync = <0x1>;
>>>                         dma-channel@0x10000 {
>>>                                 compatible = "xlnx,axi-vdma-s2mm-channel";
>>>                                 /* New flag */
>>>                                 irq_direct_mapping;
>>>                                 /* Dynamically set by module */
>>>                                 interrupts = <0>;
>>>                                 xlnx,datawidth = <0x40>;
>>>                         } ;
>>>                 };
>>>         };
>>> };
>>>
>>> Ranges an interrupts are dynamically set by the module at
>>> probe time.
>>>
>>> For interrupts, we could also think of a special interrupt
>>> controller for this application. For now [7/8] looks like
>>> a hack.
>>>
>>> An example of module using this serie (and the associated dts) can
>>> be found on my Github account [1].
>>>
>>> I my example you'll see that I use a Makefile rule to compile
>>> the devicetree and then generates a C array from the blob.
>>> The module should use the dtb target to generate the blob but
>>> I couldn't find the good way to do that for a module on a x86
>>> target. Help is welcome.
>>
>> obj-y += your-dts-file.dtb
>>
>
> This doesn't work for out-of-tree module build.
>

Well, it does work. My mistake was to use 'make modules'.

>>> Patch [1/8] should no be part of this serie. However, it shows
>>> that if we allow independant devicetree, every architecture should
>>> be able to select USE_OF. The better would be to have of support
>>> as a module.
>>
>> CONFIG_OF is already user selectable.
>>
>
> You're right. My mistake.
>
>>> Don't take this serie as a finished work. There is a lot of aspects
>>> to improve. May be we should start to implement multi-root node
>>> properly as a lot of functions assume of_root is the only devicetree
>>> present in the system.
>>
>> I think this should all be using overlays. I'm not sure that we
>> support applying overlays with no root DT ATM, but I know others are
>> certainly interested in doing just that and creating a default
>> skeleton DT root node should be trivial.
>>
>
> We could test if of_root == NULL && CONFIG_OF in of_core_init.
> If it is NULL, unflatten a default devicetree. Then we can use overlays.
> If you like the idea, I'll work on this.
>
>> The big challenge here how to describe child devices which don't have
>> the parent described in DT. Perhaps we need some sort of virtual
>> parent(s) which have all the necessary providers like interrupts.
>>
>
> Indeed, that's the real question. However, I think we would only need a
> special interrupt controller.
>
> Franck.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-03-18 20:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11 15:56 [RFC 0/8] Allow usage of independant devicetrees Franck Jullien
     [not found] ` <1457711775-6326-1-git-send-email-franck.jullien-EduPiq9onwdphFt5fpzH3laPQRlvutdw@public.gmane.org>
2016-03-11 15:56   ` [RFC 1/8] arch/x86: Add Kconfig USE_OF Franck Jullien
2016-03-11 15:56   ` [RFC 2/8] drivers/of: attach top level tree nodes to sysfs with their name Franck Jullien
2016-03-11 15:56   ` [RFC 3/8] drivers/of: export of_attach_node_sysfs Franck Jullien
2016-03-11 15:56   ` [RFC 4/8] drivers/of: export of_update_property Franck Jullien
2016-03-11 15:56   ` [RFC 5/8] drivers/of: rename __of_find_all_nodes and export it Franck Jullien
2016-03-11 15:56   ` [RFC 6/8] of.h: add for_each_compatible_node_from helper Franck Jullien
2016-03-11 15:56   ` [RFC 7/8] drivers/of: allow irq direct mapping Franck Jullien
2016-03-11 15:56   ` [RFC 8/8] drivers/of: parse_phandle_with_args to look in node's root Franck Jullien
2016-03-11 16:37   ` [RFC 0/8] Allow usage of independant devicetrees Franck Jullien
2016-03-17 14:37   ` Rob Herring
     [not found]     ` <CAL_JsqJ_JB=DXJAyzBfm3JvShq8U5+Jg1mOjY_0gM=zTbwFXVw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-18 10:06       ` Franck Jullien
     [not found]         ` <CAJfOKByPe4O4uLHRmnrwVsP-=uPbgdKyW3=SAUJcz5hDiEK+fQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-03-18 20:12           ` Franck Jullien

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).