devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 2/9] fdt: Add function to allow aliases to refer to multiple nodes
       [not found] ` <1328318041-10943-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2012-02-04  1:13   ` Simon Glass
  2012-02-04  1:13   ` [PATCH v3 4/9] tegra: fdt: i2c: Add extra I2C bindings for U-Boot Simon Glass
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2012-02-04  1:13 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Warren, Stephen Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Simon Glass, Jerry Van Baren, Devicetree Discuss

Some devices can deal with multiple compatible properties. The devices
need to know which nodes to bind to which features. For example an
I2C driver which supports two different controller types will want to
know which type it is dealing with in each case.

The new fdtdec_add_aliases_for_id() function deals with this by allowing
the driver to search for additional compatible nodes for a different ID.
It can then detect the new ones and perform appropriate processing.

Another option considered was to return a tuple (node offset, compat id)
and have the function be passed a list of compatible IDs. This is more
overhead for the common case though. We may add such a function later if
more drivers in U-Boot require it.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v3:
- Add comments and warning for mixed alias use in fdtdec

 include/fdtdec.h |   23 +++++++++++++++++++++++
 lib/fdtdec.c     |   22 ++++++++++++++++++----
 2 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index bd2222c..b028bfb 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -200,6 +200,29 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
 			enum fdt_compat_id id, int *node_list, int maxcount);
 
 /*
+ * This function is similar to fdtdec_find_aliases_for_id() except that it
+ * adds to the node_list that is passed in. Any 0 elements are considered
+ * available for allocation - others are considered already used and are
+ * skipped.
+ *
+ * You can use this by calling fdtdec_find_aliases_for_id() with an
+ * uninitialised array, then setting the elements that are returned to -1,
+ * say, then calling this function, perhaps with a different compat id.
+ * Any elements you get back that are >0 are new nodes added by the call
+ * to this function.
+ *
+ * Note that if you have some nodes with aliases and some without, you are
+ * sailing close to the wind. The call to fdtdec_find_aliases_for_id() with
+ * one compat_id may fill in positions for which you have aliases defined
+ * for another compat_id. When you later call *this* function with the second
+ * compat_id, the alias positions may already be used. A debug warning may
+ * be generated in this case, but it is safest to define aliases for all
+ * nodes when you care about the ordering.
+ */
+int fdtdec_add_aliases_for_id(const void *blob, const char *name,
+			enum fdt_compat_id id, int *node_list, int maxcount);
+
+/*
  * Get the name for a compatible ID
  *
  * @param id		Compatible ID to look for
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 7260c73..35361d1 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -151,10 +151,18 @@ int fdtdec_next_alias(const void *blob, const char *name,
 	return node;
 }
 
-/* TODO: Can we tighten this code up a little? */
 int fdtdec_find_aliases_for_id(const void *blob, const char *name,
 			enum fdt_compat_id id, int *node_list, int maxcount)
 {
+	memset(node_list, '\0', sizeof(*node_list) * maxcount);
+
+	return fdtdec_add_aliases_for_id(blob, name, id, node_list, maxcount);
+}
+
+/* TODO: Can we tighten this code up a little? */
+int fdtdec_add_aliases_for_id(const void *blob, const char *name,
+			enum fdt_compat_id id, int *node_list, int maxcount)
+{
 	int name_len = strlen(name);
 	int nodes[maxcount];
 	int num_found = 0;
@@ -184,8 +192,6 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
 		       __func__, name);
 
 	/* Now find all the aliases */
-	memset(node_list, '\0', sizeof(*node_list) * maxcount);
-
 	for (offset = fdt_first_property_offset(blob, alias_node);
 			offset > 0;
 			offset = fdt_next_property_offset(blob, offset)) {
@@ -232,11 +238,19 @@ int fdtdec_find_aliases_for_id(const void *blob, const char *name,
 		 * it as done.
 		 */
 		if (fdtdec_get_is_enabled(blob, node)) {
+			if (node_list[number]) {
+				debug("%s: warning: alias '%s' requires that "
+				      "a node be placed in the list in a "
+				      "position which is already filled by "
+				      "node '%s'\n", __func__, path,
+				      fdt_get_name(blob, node, NULL));
+				continue;
+			}
 			node_list[number] = node;
 			if (number >= num_found)
 				num_found = number + 1;
 		}
-		nodes[j] = 0;
+		nodes[found] = 0;
 	}
 
 	/* Add any nodes not mentioned by an alias */
-- 
1.7.7.3

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

* [PATCH v3 4/9] tegra: fdt: i2c: Add extra I2C bindings for U-Boot
       [not found] ` <1328318041-10943-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2012-02-04  1:13   ` [PATCH v3 2/9] fdt: Add function to allow aliases to refer to multiple nodes Simon Glass
@ 2012-02-04  1:13   ` Simon Glass
       [not found]     ` <1328318041-10943-5-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  1 sibling, 1 reply; 3+ messages in thread
From: Simon Glass @ 2012-02-04  1:13 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Tom Warren, Stephen Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	Simon Glass, Jerry Van Baren, Devicetree Discuss, Heiko Schocher

Add U-Boot's peripheral clock information to the Tegra20 device tree file.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v2:
- Adjust definitions to fit new peripheral clock bindings
- Change 'speed' to 'clock-frequency'
- Remove u-boot,pinmux binding (sadly)

Changes in v3:
- Move speed setting from tegra20.dtsi to board .dts file

 arch/arm/dts/tegra20.dtsi |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index df1eda4..e7536f7 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -45,6 +45,7 @@
 		compatible = "nvidia,tegra20-i2c";
 		reg = <0x7000C000 0x100>;
 		interrupts = < 70 >;
+		clocks = <&periph_clk 12>;	/* PERIPH_ID_I2C1 */
 	};
 
 	i2c@7000c400 {
@@ -53,6 +54,7 @@
 		compatible = "nvidia,tegra20-i2c";
 		reg = <0x7000C400 0x100>;
 		interrupts = < 116 >;
+		clocks = <&periph_clk 54>;	/* PERIPH_ID_I2C2 */
 	};
 
 	i2c@7000c500 {
@@ -61,14 +63,16 @@
 		compatible = "nvidia,tegra20-i2c";
 		reg = <0x7000C500 0x100>;
 		interrupts = < 124 >;
+		clocks = <&periph_clk 67>;	/* PERIPH_ID_I2C3 */
 	};
 
 	i2c@7000d000 {
 		#address-cells = <1>;
 		#size-cells = <0>;
-		compatible = "nvidia,tegra20-i2c";
+		compatible = "nvidia,tegra20-i2c-dvc";
 		reg = <0x7000D000 0x200>;
 		interrupts = < 85 >;
+		clocks = <&periph_clk 47>;	/* PERIPH_ID_DVC_I2C */
 	};
 
 	i2s@70002800 {
-- 
1.7.7.3

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

* Re: [U-Boot] [PATCH v3 4/9] tegra: fdt: i2c: Add extra I2C bindings for U-Boot
       [not found]     ` <1328318041-10943-5-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2012-02-10  6:29       ` Heiko Schocher
  0 siblings, 0 replies; 3+ messages in thread
From: Heiko Schocher @ 2012-02-10  6:29 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Devicetree Discuss, Jerry Van Baren,
	Tom Warren, linux-tegra-u79uwXL29TY76Z2rM5mHXA

Hello Simon,

Simon Glass wrote:
> Add U-Boot's peripheral clock information to the Tegra20 device tree file.
> 
> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> ---
> Changes in v2:
> - Adjust definitions to fit new peripheral clock bindings
> - Change 'speed' to 'clock-frequency'
> - Remove u-boot,pinmux binding (sadly)
> 
> Changes in v3:
> - Move speed setting from tegra20.dtsi to board .dts file
> 
>  arch/arm/dts/tegra20.dtsi |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)

Acked-by: Heiko Schocher <hs-ynQEQJNshbs@public.gmane.org>

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

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

end of thread, other threads:[~2012-02-10  6:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1328318041-10943-1-git-send-email-sjg@chromium.org>
     [not found] ` <1328318041-10943-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-02-04  1:13   ` [PATCH v3 2/9] fdt: Add function to allow aliases to refer to multiple nodes Simon Glass
2012-02-04  1:13   ` [PATCH v3 4/9] tegra: fdt: i2c: Add extra I2C bindings for U-Boot Simon Glass
     [not found]     ` <1328318041-10943-5-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-02-10  6:29       ` [U-Boot] " Heiko Schocher

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).