devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/14] fdt: Tidy up a few fdtdec problems
@ 2011-11-24  3:54 Simon Glass
  2011-11-24  3:54 ` [PATCH 03/14] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
                   ` (3 more replies)
  0 siblings, 4 replies; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

This fixes three trivial issues in fdtdec.c:
1. fdtdec_get_is_enabled() doesn't really need a default value
2. The fdt must be word-aligned, since otherwise it will fail on ARM
3. The compat_names[] array is missing its first element

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 include/fdtdec.h |    8 ++++----
 lib/fdtdec.c     |    7 ++++---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index d871cdd..9018181 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -112,14 +112,14 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
  * Checks whether a node is enabled.
  * This looks for a 'status' property. If this exists, then returns 1 if
  * the status is 'ok' and 0 otherwise. If there is no status property,
- * it returns the default value.
+ * it returns 1 on the assumption that anything mentioned should be enabled
+ * by default.
  *
  * @param blob	FDT blob
  * @param node	node to examine
- * @param default_val	default value to return if no 'status' property exists
- * @return integer value 0/1, if found, or default_val if not
+ * @return integer value 0 (not enabled) or 1 (enabled)
  */
-int fdtdec_get_is_enabled(const void *blob, int node, int default_val);
+int fdtdec_get_is_enabled(const void *blob, int node);
 
 /**
  * Checks whether we have a valid fdt available to control U-Boot, and panic
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 0f87163..d1321a8 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -33,6 +33,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 #define COMPAT(id, name) name
 static const char * const compat_names[COMPAT_COUNT] = {
+	COMPAT(UNKNOWN, "<none>"),
 };
 
 /**
@@ -84,14 +85,14 @@ s32 fdtdec_get_int(const void *blob, int node, const char *prop_name,
 	return default_val;
 }
 
-int fdtdec_get_is_enabled(const void *blob, int node, int default_val)
+int fdtdec_get_is_enabled(const void *blob, int node)
 {
 	const char *cell;
 
 	cell = fdt_getprop(blob, node, "status", NULL);
 	if (cell)
 		return 0 == strcmp(cell, "ok");
-	return default_val;
+	return 1;
 }
 
 enum fdt_compat_id fd_dec_lookup(const void *blob, int node)
@@ -140,7 +141,7 @@ int fdtdec_next_alias(const void *blob, const char *name,
 int fdtdec_check_fdt(void)
 {
 	/* We must have an fdt */
-	if (fdt_check_header(gd->fdt_blob))
+	if (((uintptr_t)gd->fdt_blob & 3) || fdt_check_header(gd->fdt_blob))
 		panic("No valid fdt found - please append one to U-Boot\n"
 			"binary or define CONFIG_OF_EMBED\n");
 	return 0;
-- 
1.7.3.1

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

* [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2011-11-24  3:54   ` Simon Glass
       [not found]     ` <1322106896-23054-3-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2011-11-24  3:54   ` [PATCH 04/14] arm: fdt: Add skeleton device tree file Simon Glass
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

Add a function to lookup a property which is a phandle in a node, and
another to read a fixed-length integer array from an fdt property.
Also add a function to read boolean properties.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/fdtdec.h |   40 ++++++++++++++++++++++++++
 lib/fdtdec.c     |   82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 122 insertions(+), 0 deletions(-)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index 9018181..9ecb6ab 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -126,3 +126,43 @@ int fdtdec_get_is_enabled(const void *blob, int node);
  * if not.
  */
 int fdtdec_check_fdt(void);
+
+/**
+ * Look up a phandle and follow it to its node. Then return the offset
+ * of that node.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @return node offset if found, -ve error code on error
+ */
+int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name);
+
+/**
+ * Look up a property in a node and return its contents in an integer
+ * array of given length. The property must have at least enough data for
+ * the array (4*count bytes). It may have more, but this will be ignored.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param array		array to fill with data
+ * @param count		number of array elements
+ * @return 0 if ok, or -FDT_ERR_NOTFOUND if the property is not found,
+ *		or -FDT_ERR_BADLAYOUT if not enough data
+ */
+int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
+		int *array, int count);
+
+/**
+ * Look up a boolean property in a node and return it.
+ *
+ * A boolean properly is true if present in the device tree and false if not
+ * present, or present with a 0 value.
+ *
+ * @param blob	FDT blob
+ * @param node	node to examine
+ * @param prop_name	name of property to find
+ * @return 1 if the properly is present; 0 if it isn't present or is 0
+ */
+int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d1321a8..613547a 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -146,3 +146,85 @@ int fdtdec_check_fdt(void)
 			"binary or define CONFIG_OF_EMBED\n");
 	return 0;
 }
+
+int fdtdec_lookup_phandle(const void *blob, int node, const char *prop_name)
+{
+	const u32 *phandle;
+	int lookup;
+
+	phandle = fdt_getprop(blob, node, prop_name, NULL);
+	if (!phandle)
+		return -FDT_ERR_NOTFOUND;
+
+	lookup = fdt_node_offset_by_phandle(blob, fdt32_to_cpu(*phandle));
+	return lookup;
+}
+
+/**
+ * Look up a property in a node and check that it has a minimum length.
+ *
+ * @param blob		FDT blob
+ * @param node		node to examine
+ * @param prop_name	name of property to find
+ * @param min_len	minimum property length in bytes
+ * @param err		0 if ok, or -FDT_ERR_NOTFOUND if the property is not
+			found, or -FDT_ERR_BADLAYOUT if not enough data
+ * @return pointer to cell, which is only valid if err == 0
+ */
+static const void *get_prop_len(const void *blob, int node,
+		const char *prop_name, int min_len, int *err)
+{
+	const void *cell;
+	int len;
+
+	debug("%s: %s\n", __func__, prop_name);
+	cell = fdt_getprop(blob, node, prop_name, &len);
+	if (!cell)
+		*err = -FDT_ERR_NOTFOUND;
+	else if (len < min_len)
+		*err = -FDT_ERR_BADLAYOUT;
+	else
+		*err = 0;
+	return cell;
+}
+
+int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
+		int *array, int count)
+{
+	const s32 *cell;
+	int i, err = 0;
+
+	debug("%s: %s\n", __func__, prop_name);
+	cell = get_prop_len(blob, node, prop_name, sizeof(s32) * count, &err);
+	if (!err) {
+		for (i = 0; i < count; i++)
+			array[i] = fdt32_to_cpu(cell[i]);
+	}
+	return err;
+}
+
+/**
+ * Look up a boolean property in a node and return it.
+ *
+ * A boolean properly is true if present in the device tree and false if not
+ * present, or present with a 0 value.
+ *
+ * @param blob	FDT blob
+ * @param node	node to examine
+ * @param prop_name	name of property to find
+ * @return 1 if the properly is present; 0 if it isn't present or is 0
+ */
+int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
+{
+	const s32 *cell;
+	int len;
+
+	debug("%s: %s\n", __func__, prop_name);
+	cell = fdt_getprop(blob, node, prop_name, &len);
+	if (!cell)
+		return 0;
+	if (len >= sizeof(u32) && *cell == 0)
+		return 0;
+
+	return 1;
+}
-- 
1.7.3.1

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

* [PATCH 03/14] arm: fdt: Ensure that an embedded fdt is word-aligned
  2011-11-24  3:54 [PATCH 01/14] fdt: Tidy up a few fdtdec problems Simon Glass
@ 2011-11-24  3:54 ` Simon Glass
  2011-11-24  3:54 ` [PATCH 06/14] tegra: fdt: Add device tree file for Tegra2 Seaboard Simon Glass
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

By putting the fdt blob into a distinctive area we can ensure that it appears
at the start of the data section and is word-aligned.

Note: It does not seem to be possible to get objcopy to honour its
--section-alignment flag, which would otherwise provide an easier fix
for this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/cpu/armv7/u-boot.lds |    5 +++++
 dts/Makefile                  |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
index 40ecf78..793e51b 100644
--- a/arch/arm/cpu/armv7/u-boot.lds
+++ b/arch/arm/cpu/armv7/u-boot.lds
@@ -43,6 +43,11 @@ SECTIONS
 
 	. = ALIGN(4);
 	.data : {
+		/*
+		 * Sadly objcopy seems to ignore --section-alignment.
+		 * Put any embedded device tree first so it is aligned.
+		 */
+		*(.dts.data)
 		*(.data)
 	}
 
diff --git a/dts/Makefile b/dts/Makefile
index 5792afd..83547d4 100644
--- a/dts/Makefile
+++ b/dts/Makefile
@@ -79,7 +79,7 @@ $(obj)dt.o: $(DT_BIN)
 	\
 	cd $(dir ${DT_BIN}) && \
 	$(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \
-		$(notdir ${DT_BIN}) $@
+		--prefix-sections=.dts $(notdir ${DT_BIN}) $@
 	rm $(DT_BIN)
 
 OBJS-$(CONFIG_OF_EMBED)	:= dt.o
-- 
1.7.3.1

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

* [PATCH 04/14] arm: fdt: Add skeleton device tree file
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2011-11-24  3:54   ` [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools Simon Glass
@ 2011-11-24  3:54   ` Simon Glass
  2011-11-24  3:54   ` [PATCH 05/14] tegra: fdt: Add Tegra2x " Simon Glass
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

This was taken from commit 1ea6b8f at:
git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 arch/arm/dts/skeleton.dtsi |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/dts/skeleton.dtsi

diff --git a/arch/arm/dts/skeleton.dtsi b/arch/arm/dts/skeleton.dtsi
new file mode 100644
index 0000000..b41d241
--- /dev/null
+++ b/arch/arm/dts/skeleton.dtsi
@@ -0,0 +1,13 @@
+/*
+ * Skeleton device tree; the bare minimum needed to boot; just include and
+ * add a compatible value.  The bootloader will typically populate the memory
+ * node.
+ */
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	chosen { };
+	aliases { };
+	memory { device_type = "memory"; reg = <0 0>; };
+};
-- 
1.7.3.1

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

* [PATCH 05/14] tegra: fdt: Add Tegra2x device tree file
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2011-11-24  3:54   ` [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools Simon Glass
  2011-11-24  3:54   ` [PATCH 04/14] arm: fdt: Add skeleton device tree file Simon Glass
@ 2011-11-24  3:54   ` Simon Glass
       [not found]     ` <1322106896-23054-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
  2011-11-24  3:54   ` [PATCH 07/14] tegra: fdt: Add initial device tree definitions for USB ports Simon Glass
                     ` (2 subsequent siblings)
  5 siblings, 1 reply; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

This was taken from commit 1ea6b8f at:
git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git

config.mk is updated to provide this file to boards through the
built-in mechanism:

/include/ ARCH_CPU_DTS

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 arch/arm/cpu/armv7/tegra2/config.mk |    2 +
 arch/arm/dts/tegra20.dtsi           |  147 +++++++++++++++++++++++++++++++++++
 2 files changed, 149 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/dts/tegra20.dtsi

diff --git a/arch/arm/cpu/armv7/tegra2/config.mk b/arch/arm/cpu/armv7/tegra2/config.mk
index 2303dba..fe9ef5b 100644
--- a/arch/arm/cpu/armv7/tegra2/config.mk
+++ b/arch/arm/cpu/armv7/tegra2/config.mk
@@ -31,3 +31,5 @@ CFLAGS_arch/arm/lib/board.o += -march=armv4t
 endif
 
 USE_PRIVATE_LIBGCC = yes
+
+CONFIG_ARCH_DEVICE_TREE := tegra20
diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
new file mode 100644
index 0000000..65d7e6a
--- /dev/null
+++ b/arch/arm/dts/tegra20.dtsi
@@ -0,0 +1,147 @@
+/include/ "skeleton.dtsi"
+
+/ {
+	compatible = "nvidia,tegra20";
+	interrupt-parent = <&intc>;
+
+	intc: interrupt-controller@50041000 {
+		compatible = "nvidia,tegra20-gic";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		reg = < 0x50041000 0x1000 >,
+		      < 0x50040100 0x0100 >;
+	};
+
+	i2c@7000c000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-i2c";
+		reg = <0x7000C000 0x100>;
+		interrupts = < 70 >;
+	};
+
+	i2c@7000c400 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-i2c";
+		reg = <0x7000C400 0x100>;
+		interrupts = < 116 >;
+	};
+
+	i2c@7000c500 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-i2c";
+		reg = <0x7000C500 0x100>;
+		interrupts = < 124 >;
+	};
+
+	i2c@7000d000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-i2c";
+		reg = <0x7000D000 0x200>;
+		interrupts = < 85 >;
+	};
+
+	i2s@70002800 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-i2s";
+		reg = <0x70002800 0x200>;
+		interrupts = < 45 >;
+		dma-channel = < 2 >;
+	};
+
+	i2s@70002a00 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-i2s";
+		reg = <0x70002a00 0x200>;
+		interrupts = < 35 >;
+		dma-channel = < 1 >;
+	};
+
+	das@70000c00 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "nvidia,tegra20-das";
+		reg = <0x70000c00 0x80>;
+	};
+
+	gpio: gpio@6000d000 {
+		compatible = "nvidia,tegra20-gpio";
+		reg = < 0x6000d000 0x1000 >;
+		interrupts = < 64 65 66 67 87 119 121 >;
+		#gpio-cells = <2>;
+		gpio-controller;
+	};
+
+	pinmux: pinmux@70000000 {
+		compatible = "nvidia,tegra20-pinmux";
+		reg = < 0x70000014 0x10    /* Tri-state registers */
+			0x70000080 0x20    /* Mux registers */
+			0x700000a0 0x14    /* Pull-up/down registers */
+			0x70000868 0xa8 >; /* Pad control registers */
+	};
+
+	serial@70006000 {
+		compatible = "nvidia,tegra20-uart";
+		reg = <0x70006000 0x40>;
+		reg-shift = <2>;
+		interrupts = < 68 >;
+	};
+
+	serial@70006040 {
+		compatible = "nvidia,tegra20-uart";
+		reg = <0x70006040 0x40>;
+		reg-shift = <2>;
+		interrupts = < 69 >;
+	};
+
+	serial@70006200 {
+		compatible = "nvidia,tegra20-uart";
+		reg = <0x70006200 0x100>;
+		reg-shift = <2>;
+		interrupts = < 78 >;
+	};
+
+	serial@70006300 {
+		compatible = "nvidia,tegra20-uart";
+		reg = <0x70006300 0x100>;
+		reg-shift = <2>;
+		interrupts = < 122 >;
+	};
+
+	serial@70006400 {
+		compatible = "nvidia,tegra20-uart";
+		reg = <0x70006400 0x100>;
+		reg-shift = <2>;
+		interrupts = < 123 >;
+	};
+
+	sdhci@c8000000 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000000 0x200>;
+		interrupts = < 46 >;
+	};
+
+	sdhci@c8000200 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000200 0x200>;
+		interrupts = < 47 >;
+	};
+
+	sdhci@c8000400 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000400 0x200>;
+		interrupts = < 51 >;
+	};
+
+	sdhci@c8000600 {
+		compatible = "nvidia,tegra20-sdhci";
+		reg = <0xc8000600 0x200>;
+		interrupts = < 63 >;
+	};
+};
+
-- 
1.7.3.1

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

* [PATCH 06/14] tegra: fdt: Add device tree file for Tegra2 Seaboard
  2011-11-24  3:54 [PATCH 01/14] fdt: Tidy up a few fdtdec problems Simon Glass
  2011-11-24  3:54 ` [PATCH 03/14] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
@ 2011-11-24  3:54 ` Simon Glass
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
       [not found] ` <1322106896-23054-11-git-send-email-sjg@chromium.org>
  3 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

This was taken from commit 1ea6b8f at:
git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 board/nvidia/dts/tegra2-seaboard.dts |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 board/nvidia/dts/tegra2-seaboard.dts

diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
new file mode 100644
index 0000000..7d0869a
--- /dev/null
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -0,0 +1,32 @@
+/dts-v1/;
+
+/memreserve/ 0x1c000000 0x04000000;
+/include/ ARCH_CPU_DTS
+
+/ {
+	model = "NVIDIA Seaboard";
+	compatible = "nvidia,seaboard", "nvidia,tegra20";
+
+	chosen {
+		bootargs = "vmalloc=192M video=tegrafb console=ttyS0,115200n8 root=/dev/mmcblk1p3 rw rootwait";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = < 0x00000000 0x40000000 >;
+	};
+
+	serial@70006300 {
+		clock-frequency = < 216000000 >;
+	};
+
+	sdhci@c8000400 {
+		cd-gpios = <&gpio 69 0>; /* gpio PI5 */
+		wp-gpios = <&gpio 57 0>; /* gpio PH1 */
+		power-gpios = <&gpio 70 0>; /* gpio PI6 */
+	};
+
+	sdhci@c8000600 {
+		support-8bit;
+	};
+};
-- 
1.7.3.1

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

* [PATCH 07/14] tegra: fdt: Add initial device tree definitions for USB ports
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (2 preceding siblings ...)
  2011-11-24  3:54   ` [PATCH 05/14] tegra: fdt: Add Tegra2x " Simon Glass
@ 2011-11-24  3:54   ` Simon Glass
  2011-11-24  3:54   ` [PATCH 14/14] tegra: fdt: Enable FDT support for Seaboard Simon Glass
  2011-11-28 18:33   ` [PATCH 01/14] fdt: Tidy up a few fdtdec problems Stephen Warren
  5 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

This is not available in kernel-land yet, but this initial
set of definitions provides the info we need.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 arch/arm/dts/tegra20.dtsi |   80 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 0 deletions(-)

diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index 65d7e6a..28d23da 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -143,5 +143,85 @@
 		reg = <0xc8000600 0x200>;
 		interrupts = < 63 >;
 	};
+
+/* This table has USB timing parameters for each Oscillator frequency we
+ * support. There are four sets of values:
+ *
+ * 1. PLLU configuration information (reference clock is osc/clk_m and
+ * PLLU-FOs are fixed at 12MHz/60MHz/480MHz).
+ *
+ *  Reference frequency     13.0MHz      19.2MHz      12.0MHz      26.0MHz
+ *  ----------------------------------------------------------------------
+ *      DIVN                960 (0x3c0)  200 (0c8)    960 (3c0h)   960 (3c0)
+ *      DIVM                13 (0d)      4 (04)       12 (0c)      26 (1a)
+ * Filter frequency (MHz)   1            4.8          6            2
+ * CPCON                    1100b        0011b        1100b        1100b
+ * LFCON0                   0            0            0            0
+ *
+ * 2. PLL CONFIGURATION & PARAMETERS for different clock generators:
+ *
+ * Reference frequency     13.0MHz         19.2MHz         12.0MHz     26.0MHz
+ * ---------------------------------------------------------------------------
+ * PLLU_ENABLE_DLY_COUNT   02 (0x02)       03 (03)         02 (02)     04 (04)
+ * PLLU_STABLE_COUNT       51 (33)         75 (4B)         47 (2F)    102 (66)
+ * PLL_ACTIVE_DLY_COUNT    05 (05)         06 (06)         04 (04)     09 (09)
+ * XTAL_FREQ_COUNT        127 (7F)        187 (BB)        118 (76)    254 (FE)
+ *
+ * 3. Debounce values IdDig, Avalid, Bvalid, VbusValid, VbusWakeUp, and
+ * SessEnd. Each of these signals have their own debouncer and for each of
+ * those one out of two debouncing times can be chosen (BIAS_DEBOUNCE_A or
+ * BIAS_DEBOUNCE_B).
+ *
+ * The values of DEBOUNCE_A and DEBOUNCE_B are calculated as follows:
+ *    0xffff -> No debouncing at all
+ *    <n> ms = <n> *1000 / (1/19.2MHz) / 4
+ *
+ * So to program a 1 ms debounce for BIAS_DEBOUNCE_A, we have:
+ * BIAS_DEBOUNCE_A[15:0] = 1000 * 19.2 / 4  = 4800 = 0x12c0
+ *
+ * We need to use only DebounceA for BOOTROM. We don't need the DebounceB
+ * values, so we can keep those to default.
+ *
+ * a4. The 20 microsecond delay after bias cell operation.
+ *  Reference frequency     13.0MHz      19.2MHz      12.0MHz      26.0MHz
+ */
+	usbparams@0 {
+		compatible = "nvidia,tegra20-usbparams";
+		osc-frequency = <13000000>;
+		/* DivN, DivM, DivP, CPCON, LFCON, Delays      Debounce, Bias */
+		params = <0x3c0 0x0d 0x00 0xc 0  0x02 0x33 0x05 0x7f  0x7ef4 5>;
+	};
+
+	usbparams@1 {
+		compatible = "nvidia,tegra20-usbparams";
+		osc-frequency = <19200000>;
+		params = <0x0c8 0x04 0x00 0x3 0  0x03 0x4b 0x06 0xbb  0xbb80 7>;
+	};
+
+	usbparams@2 {
+		compatible = "nvidia,tegra20-usbparams";
+		osc-frequency = <12000000>;
+		params = <0x3c0 0x0c 0x00 0xc 0  0x02 0x2f 0x04 0x76  0x7530 5>;
+	};
+
+	usbparams@3 {
+		compatible = "nvidia,tegra20-usbparams";
+		osc-frequency = <26000000>;
+		params = <0x3c0 0x1a 0x00 0xc 0  0x04 0x66 0x09 0xfe  0xfde8 9>;
+	};
+
+	usb@0xc5008000 {
+		compatible = "nvidia,tegra20-usb";
+		reg = <0xc5008000 0x8000>;
+		periph-id = <59>;	// PERIPH_ID_USB3
+		status = "disabled";
+	};
+
+	usb@0xc5000000 {
+		compatible = "nvidia,tegra20-usb";
+		reg = <0xc5000000 0x8000>;
+		periph-id = <22>;	// PERIPH_ID_USBD
+		status = "disabled";
+	};
 };
 
-- 
1.7.3.1

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

* [PATCH 14/14] tegra: fdt: Enable FDT support for Seaboard
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (3 preceding siblings ...)
  2011-11-24  3:54   ` [PATCH 07/14] tegra: fdt: Add initial device tree definitions for USB ports Simon Glass
@ 2011-11-24  3:54   ` Simon Glass
  2011-11-28 18:33   ` [PATCH 01/14] fdt: Tidy up a few fdtdec problems Stephen Warren
  5 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-11-24  3:54 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Devicetree Discuss, Albert ARIBAUD, Tom Warren

This switches Seaboard over to use FDT for run-time config instead of
CONFIG options. USB is the only user at present.

Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
 include/configs/seaboard.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
index df1b44a..03e9824 100644
--- a/include/configs/seaboard.h
+++ b/include/configs/seaboard.h
@@ -27,6 +27,11 @@
 #include <asm/sizes.h>
 #include "tegra2-common.h"
 
+/* Enable fdt support for Seaboard. Flash the image in u-boot-dtb.bin */
+#define CONFIG_DEFAULT_DEVICE_TREE	tegra2-seaboard
+#define CONFIG_OF_CONTROL
+#define CONFIG_OF_SEPARATE
+
 /* High-level configuration options */
 #define TEGRA2_SYSMEM		"mem=384M@0M nvmem=128M@384M mem=512M@512M"
 #define V_PROMPT		"Tegra2 (SeaBoard) # "
@@ -79,6 +84,8 @@
 #define CONFIG_USB_STORAGE
 #define CONFIG_CMD_USB
 
+#ifndef CONFIG_OF_CONTROL
+
 /* Select the order in which U-Boot sees USB ports */
 #define CONFIG_TEGRA_USB0	TEGRA_USB3_BASE
 #define CONFIG_TEGRA_USB1	TEGRA_USB1_BASE
@@ -86,4 +93,6 @@
 /* Put USB1 in host mode */
 #define CONFIG_TEGRA_USB1_HOST
 
+#endif
+
 #endif /* __CONFIG_H */
-- 
1.7.3.1

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

* Re: [PATCH 01/14] fdt: Tidy up a few fdtdec problems
       [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
                     ` (4 preceding siblings ...)
  2011-11-24  3:54   ` [PATCH 14/14] tegra: fdt: Enable FDT support for Seaboard Simon Glass
@ 2011-11-28 18:33   ` Stephen Warren
       [not found]     ` <4ED3D3F2.8070302-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-12-01 20:59     ` Simon Glass
  5 siblings, 2 replies; 28+ messages in thread
From: Stephen Warren @ 2011-11-28 18:33 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren,
	Albert ARIBAUD

On 11/23/2011 08:54 PM, Simon Glass wrote:
> This fixes three trivial issues in fdtdec.c:
> 1. fdtdec_get_is_enabled() doesn't really need a default value
> 2. The fdt must be word-aligned, since otherwise it will fail on ARM
> 3. The compat_names[] array is missing its first element

> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
...
>  #define COMPAT(id, name) name
>  static const char * const compat_names[COMPAT_COUNT] = {
> +	COMPAT(UNKNOWN, "<none>"),
>  };

Could you educate me on why that change is necessary? Maybe explain this
in the commit description?

> -int fdtdec_get_is_enabled(const void *blob, int node, int default_val)
> +int fdtdec_get_is_enabled(const void *blob, int node)
>  {
>  	const char *cell;
>  
>  	cell = fdt_getprop(blob, node, "status", NULL);
>  	if (cell)
>  		return 0 == strcmp(cell, "ok");
> -	return default_val;
> +	return 1;
>  }

Not that this patch changes this, but isn't "okay" also a legal
"enabled" value, and perhaps even the recommended value? See
http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-July/006389.html.

-- 
nvpublic

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
       [not found]     ` <1322106896-23054-3-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2011-11-28 18:41       ` Stephen Warren
       [not found]         ` <4ED3D5DC.10502-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
                           ` (2 more replies)
  0 siblings, 3 replies; 28+ messages in thread
From: Stephen Warren @ 2011-11-28 18:41 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren,
	Albert ARIBAUD

On 11/23/2011 08:54 PM, Simon Glass wrote:
> Add a function to lookup a property which is a phandle in a node, and
> another to read a fixed-length integer array from an fdt property.
> Also add a function to read boolean properties.
> 
> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

Looking at the U-Boot custodians web page, you need to send the core DT
changes (well, probably anything DT related) to Jerry Van Baren.

> +/**
> + * Look up a property in a node and return its contents in an integer
> + * array of given length. The property must have at least enough data for
> + * the array (4*count bytes). It may have more, but this will be ignored.
> + *
> + * @param blob		FDT blob
> + * @param node		node to examine
> + * @param prop_name	name of property to find
> + * @param array		array to fill with data
> + * @param count		number of array elements
> + * @return 0 if ok, or -FDT_ERR_NOTFOUND if the property is not found,
> + *		or -FDT_ERR_BADLAYOUT if not enough data
> + */
> +int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
> +		int *array, int count);

The kernel's equivalent of this function retrieves an array of U32s. Is
one version more correct than the other?

> +/**
> + * Look up a boolean property in a node and return it.
> + *
> + * A boolean properly is true if present in the device tree and false if not
> + * present, or present with a 0 value.
> + *
> + * @param blob	FDT blob
> + * @param node	node to examine
> + * @param prop_name	name of property to find
> + * @return 1 if the properly is present; 0 if it isn't present or is 0
> + */
> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name);

Does U-Boot allow use of the "bool" type here?


> +/**
> + * Look up a property in a node and check that it has a minimum length.
> + *
> + * @param blob		FDT blob
> + * @param node		node to examine
> + * @param prop_name	name of property to find
> + * @param min_len	minimum property length in bytes
> + * @param err		0 if ok, or -FDT_ERR_NOTFOUND if the property is not
> +			found, or -FDT_ERR_BADLAYOUT if not enough data
> + * @return pointer to cell, which is only valid if err == 0
> + */
> +static const void *get_prop_len(const void *blob, int node,
> +		const char *prop_name, int min_len, int *err)

Based on the function name, I'd expect it to return the length of the
property; perhaps get_prop_check_min_len?

> +/**
> + * Look up a boolean property in a node and return it.
> + *
> + * A boolean properly is true if present in the device tree and false if not
> + * present, or present with a 0 value.
> + *
> + * @param blob	FDT blob
> + * @param node	node to examine
> + * @param prop_name	name of property to find
> + * @return 1 if the properly is present; 0 if it isn't present or is 0
> + */
> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
> +{
> +	const s32 *cell;
> +	int len;
> +
> +	debug("%s: %s\n", __func__, prop_name);
> +	cell = fdt_getprop(blob, node, prop_name, &len);
> +	if (!cell)
> +		return 0;
> +	if (len >= sizeof(u32) && *cell == 0)
> +		return 0;
> +
> +	return 1;
> +}

In the kernel, I believe that property existence is all that's usually
checked. Is that wrong? Did the definition of a boolean property's value
in the function description above come from the specification? If a
property had a length of 0/1/2/3 with a zero value, it seems very odd to
treat that as true.

-- 
nvpublic

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

* Re: [PATCH 05/14] tegra: fdt: Add Tegra2x device tree file
       [not found]     ` <1322106896-23054-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2011-11-28 18:56       ` Stephen Warren
  2011-12-02  1:24         ` Simon Glass
  0 siblings, 1 reply; 28+ messages in thread
From: Stephen Warren @ 2011-11-28 18:56 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren,
	Albert ARIBAUD

On 11/23/2011 08:54 PM, Simon Glass wrote:
> This was taken from commit 1ea6b8f at:
> git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git

That's not the latest version in linux-next. Also, this doesn't include
quite a few changes that have been sent to the mailing lists but not yet
applied.

In particular, linux-next now includes a minimal USB binding. Should we
just use this in U-Boot for now? We should get review on the kernel
lists before bringing in this more advanced USB binding in U-Boot, and
perhaps even add the binding into the kernel at the same time?

Patches have been posted to:
* Convert to the finalized ARM GIC binding.
* Disable devices in the per-board .dts files that aren't used on those
boards.
* Various other cleanups in order to make the .dts files match the
kernel's non-DT board files.
* Perhaps more that I forget.

I suppose those could be applied to U-Boot as and when they are applied
to the kernel.

-- 
nvpublic

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

* Re: [PATCH 01/14] fdt: Tidy up a few fdtdec problems
       [not found]     ` <4ED3D3F2.8070302-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-11-29  1:10       ` David Gibson
  0 siblings, 0 replies; 28+ messages in thread
From: David Gibson @ 2011-11-29  1:10 UTC (permalink / raw)
  To: Stephen Warren
  Cc: U-Boot Mailing List, Albert ARIBAUD, Devicetree Discuss,
	Tom Warren

On Mon, Nov 28, 2011 at 11:33:22AM -0700, Stephen Warren wrote:
> On 11/23/2011 08:54 PM, Simon Glass wrote:
> > This fixes three trivial issues in fdtdec.c:
> > 1. fdtdec_get_is_enabled() doesn't really need a default value
> > 2. The fdt must be word-aligned, since otherwise it will fail on ARM
> > 3. The compat_names[] array is missing its first element
> 
> > diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> ...
> >  #define COMPAT(id, name) name
> >  static const char * const compat_names[COMPAT_COUNT] = {
> > +	COMPAT(UNKNOWN, "<none>"),
> >  };
> 
> Could you educate me on why that change is necessary? Maybe explain this
> in the commit description?
> 
> > -int fdtdec_get_is_enabled(const void *blob, int node, int default_val)
> > +int fdtdec_get_is_enabled(const void *blob, int node)
> >  {
> >  	const char *cell;
> >  
> >  	cell = fdt_getprop(blob, node, "status", NULL);
> >  	if (cell)
> >  		return 0 == strcmp(cell, "ok");
> > -	return default_val;
> > +	return 1;
> >  }
> 
> Not that this patch changes this, but isn't "okay" also a legal
> "enabled" value, and perhaps even the recommended value? See
> http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-July/006389.html.

Yes.  "okay", not "ok" is the standard value for the status property.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
       [not found]         ` <4ED3D5DC.10502-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-11-29  5:12           ` David Gibson
  0 siblings, 0 replies; 28+ messages in thread
From: David Gibson @ 2011-11-29  5:12 UTC (permalink / raw)
  To: Stephen Warren
  Cc: U-Boot Mailing List, Albert ARIBAUD, Devicetree Discuss,
	Tom Warren

On Mon, Nov 28, 2011 at 11:41:32AM -0700, Stephen Warren wrote:
> On 11/23/2011 08:54 PM, Simon Glass wrote:
> > Add a function to lookup a property which is a phandle in a node, and
> > another to read a fixed-length integer array from an fdt property.
> > Also add a function to read boolean properties.
> > 
> > Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> 
> Looking at the U-Boot custodians web page, you need to send the core DT
> changes (well, probably anything DT related) to Jerry Van Baren.
> 
> > +/**
> > + * Look up a property in a node and return its contents in an integer
> > + * array of given length. The property must have at least enough data for
> > + * the array (4*count bytes). It may have more, but this will be ignored.
> > + *
> > + * @param blob		FDT blob
> > + * @param node		node to examine
> > + * @param prop_name	name of property to find
> > + * @param array		array to fill with data
> > + * @param count		number of array elements
> > + * @return 0 if ok, or -FDT_ERR_NOTFOUND if the property is not found,
> > + *		or -FDT_ERR_BADLAYOUT if not enough data
> > + */
> > +int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
> > +		int *array, int count);
> 
> The kernel's equivalent of this function retrieves an array of U32s. Is
> one version more correct than the other?

Using u32 is a better idea.  The property formats are all defined in
terms of fixed width elements, so using a vague width type like int to
interact with it is a bad idea.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

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

* Re: [PATCH 01/14] fdt: Tidy up a few fdtdec problems
  2011-11-28 18:33   ` [PATCH 01/14] fdt: Tidy up a few fdtdec problems Stephen Warren
       [not found]     ` <4ED3D3F2.8070302-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-12-01 20:59     ` Simon Glass
  1 sibling, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-12-01 20:59 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Stephen,

On Mon, Nov 28, 2011 at 10:33 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 11/23/2011 08:54 PM, Simon Glass wrote:
>> This fixes three trivial issues in fdtdec.c:
>> 1. fdtdec_get_is_enabled() doesn't really need a default value
>> 2. The fdt must be word-aligned, since otherwise it will fail on ARM
>> 3. The compat_names[] array is missing its first element
>
>> diff --git a/lib/fdtdec.c b/lib/fdtdec.c
> ...
>>  #define COMPAT(id, name) name
>>  static const char * const compat_names[COMPAT_COUNT] = {
>> +     COMPAT(UNKNOWN, "<none>"),
>>  };
>
> Could you educate me on why that change is necessary? Maybe explain this
> in the commit description?

Yes I will update the description. The first element of the array is
supposed to be an invalid entry (see enum fdt_compat_id).

>
>> -int fdtdec_get_is_enabled(const void *blob, int node, int default_val)
>> +int fdtdec_get_is_enabled(const void *blob, int node)
>>  {
>>       const char *cell;
>>
>>       cell = fdt_getprop(blob, node, "status", NULL);
>>       if (cell)
>>               return 0 == strcmp(cell, "ok");
>> -     return default_val;
>> +     return 1;
>>  }
>
> Not that this patch changes this, but isn't "okay" also a legal
> "enabled" value, and perhaps even the recommended value? See
> http://lists.ozlabs.org/pipermail/devicetree-discuss/2011-July/006389.html.

Yes, I will change this, thanks.

Regards,
Simon

>
> --
> nvpublic
>

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
  2011-11-28 18:41       ` Stephen Warren
       [not found]         ` <4ED3D5DC.10502-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-12-02  1:01         ` Simon Glass
       [not found]           ` <CAPnjgZ29tsNXd1+1eXdTHRjgh_MQJrXoc23_oqO9UPJ73mu7ZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2011-12-02  3:33         ` Jerry Van Baren
  2 siblings, 1 reply; 28+ messages in thread
From: Simon Glass @ 2011-12-02  1:01 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Stephen,

On Mon, Nov 28, 2011 at 10:41 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 11/23/2011 08:54 PM, Simon Glass wrote:
>> Add a function to lookup a property which is a phandle in a node, and
>> another to read a fixed-length integer array from an fdt property.
>> Also add a function to read boolean properties.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
> Looking at the U-Boot custodians web page, you need to send the core DT
> changes (well, probably anything DT related) to Jerry Van Baren.

Yes the tag was there but not picked up as I didn't have Mike's alias
file in my tree. Will fix.

>
>> +/**
>> + * Look up a property in a node and return its contents in an integer
>> + * array of given length. The property must have at least enough data for
>> + * the array (4*count bytes). It may have more, but this will be ignored.
>> + *
>> + * @param blob               FDT blob
>> + * @param node               node to examine
>> + * @param prop_name  name of property to find
>> + * @param array              array to fill with data
>> + * @param count              number of array elements
>> + * @return 0 if ok, or -FDT_ERR_NOTFOUND if the property is not found,
>> + *           or -FDT_ERR_BADLAYOUT if not enough data
>> + */
>> +int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
>> +             int *array, int count);
>
> The kernel's equivalent of this function retrieves an array of U32s. Is
> one version more correct than the other?

I would prefer to have signed, but I will change it to use u32 *.

>
>> +/**
>> + * Look up a boolean property in a node and return it.
>> + *
>> + * A boolean properly is true if present in the device tree and false if not
>> + * present, or present with a 0 value.
>> + *
>> + * @param blob       FDT blob
>> + * @param node       node to examine
>> + * @param prop_name  name of property to find
>> + * @return 1 if the properly is present; 0 if it isn't present or is 0
>> + */
>> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
>
> Does U-Boot allow use of the "bool" type here?

Which bool type? It is returning an int.

>
>
>> +/**
>> + * Look up a property in a node and check that it has a minimum length.
>> + *
>> + * @param blob               FDT blob
>> + * @param node               node to examine
>> + * @param prop_name  name of property to find
>> + * @param min_len    minimum property length in bytes
>> + * @param err                0 if ok, or -FDT_ERR_NOTFOUND if the property is not
>> +                     found, or -FDT_ERR_BADLAYOUT if not enough data
>> + * @return pointer to cell, which is only valid if err == 0
>> + */
>> +static const void *get_prop_len(const void *blob, int node,
>> +             const char *prop_name, int min_len, int *err)
>
> Based on the function name, I'd expect it to return the length of the
> property; perhaps get_prop_check_min_len?

Changed, thanks.
>
>> +/**
>> + * Look up a boolean property in a node and return it.
>> + *
>> + * A boolean properly is true if present in the device tree and false if not
>> + * present, or present with a 0 value.
>> + *
>> + * @param blob       FDT blob
>> + * @param node       node to examine
>> + * @param prop_name  name of property to find
>> + * @return 1 if the properly is present; 0 if it isn't present or is 0
>> + */
>> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
>> +{
>> +     const s32 *cell;
>> +     int len;
>> +
>> +     debug("%s: %s\n", __func__, prop_name);
>> +     cell = fdt_getprop(blob, node, prop_name, &len);
>> +     if (!cell)
>> +             return 0;
>> +     if (len >= sizeof(u32) && *cell == 0)
>> +             return 0;
>> +
>> +     return 1;
>> +}
>
> In the kernel, I believe that property existence is all that's usually
> checked. Is that wrong? Did the definition of a boolean property's value
> in the function description above come from the specification? If a
> property had a length of 0/1/2/3 with a zero value, it seems very odd to
> treat that as true.

It is useful to be able to set the value to 0 or 1 (with fdtget/put),
rather than remove or add the property. A value with a length of less
than one cell is considered illegal here.

The basic idea is that the presence of the property means that it is
'true'. If it happens to have a value, then we allow that to specify
'false' if it is zero.

Thoughts?

Regards,
Simon

>
> --
> nvpublic
>

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

* Re: [PATCH 05/14] tegra: fdt: Add Tegra2x device tree file
  2011-11-28 18:56       ` Stephen Warren
@ 2011-12-02  1:24         ` Simon Glass
       [not found]           ` <CAPnjgZ11cFm15E9MHXno_YGp0NxdOHhGBavYbQBP5Nu_TOtx7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 28+ messages in thread
From: Simon Glass @ 2011-12-02  1:24 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Stephen,

On Mon, Nov 28, 2011 at 10:56 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 11/23/2011 08:54 PM, Simon Glass wrote:
>> This was taken from commit 1ea6b8f at:
>> git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git
>
> That's not the latest version in linux-next. Also, this doesn't include
> quite a few changes that have been sent to the mailing lists but not yet
> applied.

OK I see a newer version in 'next' that now has USB so have picked
that up. I picked 'master' originally.

>
> In particular, linux-next now includes a minimal USB binding. Should we
> just use this in U-Boot for now? We should get review on the kernel
> lists before bringing in this more advanced USB binding in U-Boot, and
> perhaps even add the binding into the kernel at the same time?

I copied my email to the device-tree mailing list. Hopefully that is
enough to get a review there. It feels wrong to send U-Boot patches to
the kernel list...?

>
> Patches have been posted to:
> * Convert to the finalized ARM GIC binding.
> * Disable devices in the per-board .dts files that aren't used on those
> boards.
> * Various other cleanups in order to make the .dts files match the
> kernel's non-DT board files.
> * Perhaps more that I forget.

Well I would prefer to pick these up when they are actually applied!

>
> I suppose those could be applied to U-Boot as and when they are applied
> to the kernel.

Yes I think so.

Regards,
Simon

>
> --
> nvpublic
>

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
  2011-11-28 18:41       ` Stephen Warren
       [not found]         ` <4ED3D5DC.10502-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-12-02  1:01         ` Simon Glass
@ 2011-12-02  3:33         ` Jerry Van Baren
  2011-12-02  4:58           ` Simon Glass
  2 siblings, 1 reply; 28+ messages in thread
From: Jerry Van Baren @ 2011-12-02  3:33 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

On 11/28/2011 01:41 PM, Stephen Warren wrote:
> On 11/23/2011 08:54 PM, Simon Glass wrote:
>> Add a function to lookup a property which is a phandle in a node, and
>> another to read a fixed-length integer array from an fdt property.
>> Also add a function to read boolean properties.
>>
>> Signed-off-by: Simon Glass<sjg@chromium.org>
>
> Looking at the U-Boot custodians web page, you need to send the core DT
> changes (well, probably anything DT related) to Jerry Van Baren.

Yeah, I saw the patch go by.  I did not recognize the file it patched 
and looked at the history:

commit b5220bc6ed6e6a197adf4926958dca1df4b420b0
Author: Simon Glass <sjg@chromium.org>
Date:   Mon Oct 24 19:15:32 2011 +0000

     fdt: add decode helper library

     This library provides useful functions to drivers which want to use
     the fdt to control their operation. Functions are provided to:
     :
     :

and the copyright is "Copyright (c) 2011 The Chromium OS Authors."

FDT helper functions have been accumulating in common/fdt_support.c 
rather than a separate file.  Simon, what is the history of 
lib/fdtdec.c?  Is it a shared file from the linux kernel?  If it is 
u-boot specific, it would probably be better to add the functions to 
fdt_support.c.

In the same vein, I also have not looked at the functions provided by 
fdtdec.c to see if there is any overlap with existing fdt_support.c 
functions (a quick look says not).

Best regards,
gvb

[snip]

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
  2011-12-02  3:33         ` Jerry Van Baren
@ 2011-12-02  4:58           ` Simon Glass
  2011-12-02 17:22             ` Jerry Van Baren
  0 siblings, 1 reply; 28+ messages in thread
From: Simon Glass @ 2011-12-02  4:58 UTC (permalink / raw)
  To: Jerry Van Baren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Jerry,

On Thu, Dec 1, 2011 at 7:33 PM, Jerry Van Baren <gvb.uboot@gmail.com> wrote:
> On 11/28/2011 01:41 PM, Stephen Warren wrote:
>>
>> On 11/23/2011 08:54 PM, Simon Glass wrote:
>>>
>>> Add a function to lookup a property which is a phandle in a node, and
>>> another to read a fixed-length integer array from an fdt property.
>>> Also add a function to read boolean properties.
>>>
>>> Signed-off-by: Simon Glass<sjg@chromium.org>
>>
>> Looking at the U-Boot custodians web page, you need to send the core DT
>> changes (well, probably anything DT related) to Jerry Van Baren.
>
> Yeah, I saw the patch go by.  I did not recognize the file it patched and
> looked at the history:
>
> commit b5220bc6ed6e6a197adf4926958dca1df4b420b0
> Author: Simon Glass <sjg@chromium.org>
> Date:   Mon Oct 24 19:15:32 2011 +0000
>
>    fdt: add decode helper library
>
>    This library provides useful functions to drivers which want to use
>    the fdt to control their operation. Functions are provided to:
>    :
>    :
>
> and the copyright is "Copyright (c) 2011 The Chromium OS Authors."
>
> FDT helper functions have been accumulating in common/fdt_support.c rather
> than a separate file.  Simon, what is the history of lib/fdtdec.c?  Is it a
> shared file from the linux kernel?  If it is u-boot specific, it would
> probably be better to add the functions to fdt_support.c.

There are sort-of two FDT strands within U-Boot. The main one is
support for putting together an FDT to pass to the kernel (cmd_fdt,
fdt_support), and the other is for U-Boot's own use (run-time
configuration of U-Boot, fdtdec). They both use libfdt.

I regard fdt_support as part of the former, and fdtdec (decode-only
helper functions) as part of the latter. At present when you turn on
CONFIG_OF_LIBFDT you get everything, but we could provide finer
granularity for platforms which only want to decode an FDT for
run-time config and don't want to mess with it. Since fdt_decode is
about 6KB of code that might be useful.

>
> In the same vein, I also have not looked at the functions provided by
> fdtdec.c to see if there is any overlap with existing fdt_support.c
> functions (a quick look says not).

No, they are pretty low-level. An argument could be made for them to
go into libfdt once they are stable, but we are certainly not there
yet. I have quite a few patches which add more functions for
extracting data.

Regards,
Simon

>
> Best regards,
> gvb
>
> [snip]
>

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
       [not found]           ` <CAPnjgZ29tsNXd1+1eXdTHRjgh_MQJrXoc23_oqO9UPJ73mu7ZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-12-02 15:55             ` Stephen Warren
  2011-12-02 16:38               ` Simon Glass
  0 siblings, 1 reply; 28+ messages in thread
From: Stephen Warren @ 2011-12-02 15:55 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren,
	Albert ARIBAUD

On 12/01/2011 06:01 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On Mon, Nov 28, 2011 at 10:41 AM, Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>> On 11/23/2011 08:54 PM, Simon Glass wrote:
>>> Add a function to lookup a property which is a phandle in a node, and
>>> another to read a fixed-length integer array from an fdt property.
>>> Also add a function to read boolean properties.
>>>
>>> Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>

>>> +/**
>>> + * Look up a boolean property in a node and return it.
>>> + *
>>> + * A boolean properly is true if present in the device tree and false if not
>>> + * present, or present with a 0 value.
>>> + *
>>> + * @param blob       FDT blob
>>> + * @param node       node to examine
>>> + * @param prop_name  name of property to find
>>> + * @return 1 if the properly is present; 0 if it isn't present or is 0
>>> + */
>>> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
>>
>> Does U-Boot allow use of the "bool" type here?
> 
> Which bool type? It is returning an int.

I was asking if the return type could be changed to bool.

>>> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
>>> +{
>>> +     const s32 *cell;
>>> +     int len;
>>> +
>>> +     debug("%s: %s\n", __func__, prop_name);
>>> +     cell = fdt_getprop(blob, node, prop_name, &len);
>>> +     if (!cell)
>>> +             return 0;
>>> +     if (len >= sizeof(u32) && *cell == 0)
>>> +             return 0;
>>> +
>>> +     return 1;
>>> +}
>>
>> In the kernel, I believe that property existence is all that's usually
>> checked. Is that wrong? Did the definition of a boolean property's value
>> in the function description above come from the specification? If a
>> property had a length of 0/1/2/3 with a zero value, it seems very odd to
>> treat that as true.
> 
> It is useful to be able to set the value to 0 or 1 (with fdtget/put),
> rather than remove or add the property. A value with a length of less
> than one cell is considered illegal here.
> 
> The basic idea is that the presence of the property means that it is
> 'true'. If it happens to have a value, then we allow that to specify
> 'false' if it is zero.

Well, it's more up to standard device tree practice, not me. I've
certainly sent patches that used a property with 0/1 value as a bool
and received review feedback from DT experts that DT represents bools
as present/absent properties, both with no value, so I assume zero
length.

-- 
nvpublic

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

* Re: [PATCH 05/14] tegra: fdt: Add Tegra2x device tree file
       [not found]           ` <CAPnjgZ11cFm15E9MHXno_YGp0NxdOHhGBavYbQBP5Nu_TOtx7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-12-02 15:58             ` Stephen Warren
  2011-12-02 16:47               ` Simon Glass
  0 siblings, 1 reply; 28+ messages in thread
From: Stephen Warren @ 2011-12-02 15:58 UTC (permalink / raw)
  To: Simon Glass
  Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren,
	Albert ARIBAUD

On 12/01/2011 06:24 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On Mon, Nov 28, 2011 at 10:56 AM, Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>> On 11/23/2011 08:54 PM, Simon Glass wrote:
>>> This was taken from commit 1ea6b8f at:
>>> git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git
>>
...
>> In particular, linux-next now includes a minimal USB binding. Should we
>> just use this in U-Boot for now? We should get review on the kernel
>> lists before bringing in this more advanced USB binding in U-Boot, and
>> perhaps even add the binding into the kernel at the same time?
> 
> I copied my email to the device-tree mailing list. Hopefully that is
> enough to get a review there. It feels wrong to send U-Boot patches to
> the kernel list...?

I think the kernel and U-boot need to co-ordinate on the DT bindings.
Posting at least to linux-tegra, the Tegra maintainers, and perhaps even
the kernel's domain-specific list (i.e. linux-usb) seems appropriate to
me. DT is a cross-functional thing, and really needs cross-functional
discussion and review. devicetree-discuss will cover the DT experts, but
probably not the CPU and subsystem experts.

-- 
nvpublic

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
  2011-12-02 15:55             ` Stephen Warren
@ 2011-12-02 16:38               ` Simon Glass
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-12-02 16:38 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Stephen,

On Fri, Dec 2, 2011 at 7:55 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 12/01/2011 06:01 PM, Simon Glass wrote:
>> Hi Stephen,
>>
>> On Mon, Nov 28, 2011 at 10:41 AM, Stephen Warren <swarren@nvidia.com> wrote:
>>> On 11/23/2011 08:54 PM, Simon Glass wrote:
>>>> Add a function to lookup a property which is a phandle in a node, and
>>>> another to read a fixed-length integer array from an fdt property.
>>>> Also add a function to read boolean properties.
>>>>
>>>> Signed-off-by: Simon Glass <sjg@chromium.org>
>
>>>> +/**
>>>> + * Look up a boolean property in a node and return it.
>>>> + *
>>>> + * A boolean properly is true if present in the device tree and false if not
>>>> + * present, or present with a 0 value.
>>>> + *
>>>> + * @param blob       FDT blob
>>>> + * @param node       node to examine
>>>> + * @param prop_name  name of property to find
>>>> + * @return 1 if the properly is present; 0 if it isn't present or is 0
>>>> + */
>>>> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
>>>
>>> Does U-Boot allow use of the "bool" type here?
>>
>> Which bool type? It is returning an int.
>
> I was asking if the return type could be changed to bool.

Sorry I misunderstood -  no U-Boot does not have a bool type yet.

>
>>>> +int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
>>>> +{
>>>> +     const s32 *cell;
>>>> +     int len;
>>>> +
>>>> +     debug("%s: %s\n", __func__, prop_name);
>>>> +     cell = fdt_getprop(blob, node, prop_name, &len);
>>>> +     if (!cell)
>>>> +             return 0;
>>>> +     if (len >= sizeof(u32) && *cell == 0)
>>>> +             return 0;
>>>> +
>>>> +     return 1;
>>>> +}
>>>
>>> In the kernel, I believe that property existence is all that's usually
>>> checked. Is that wrong? Did the definition of a boolean property's value
>>> in the function description above come from the specification? If a
>>> property had a length of 0/1/2/3 with a zero value, it seems very odd to
>>> treat that as true.
>>
>> It is useful to be able to set the value to 0 or 1 (with fdtget/put),
>> rather than remove or add the property. A value with a length of less
>> than one cell is considered illegal here.
>>
>> The basic idea is that the presence of the property means that it is
>> 'true'. If it happens to have a value, then we allow that to specify
>> 'false' if it is zero.
>
> Well, it's more up to standard device tree practice, not me. I've
> certainly sent patches that used a property with 0/1 value as a bool
> and received review feedback from DT experts that DT represents bools
> as present/absent properties, both with no value, so I assume zero
> length.

Yes that is the preferred way. However, it is useful to be able to
define a meaning when the property does have a value. The value may
come into the fdt later after compilation. At that point it is easier
to change a value rather than make something present/absent. For one
thing it can be done without adjust the size of the fdt blob.

Perhaps the solution is to adjust fdtput to support boolean values
explicitly (in that it would add or remove the property based on a
command-line 0/1 value).

Still I think it is useful to support a zero value meaning false when
it is provided.

Regards,
Simon

>
> --
> nvpublic
>

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

* Re: [PATCH 05/14] tegra: fdt: Add Tegra2x device tree file
  2011-12-02 15:58             ` Stephen Warren
@ 2011-12-02 16:47               ` Simon Glass
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-12-02 16:47 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Stephen,

On Fri, Dec 2, 2011 at 7:58 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 12/01/2011 06:24 PM, Simon Glass wrote:
>> Hi Stephen,
>>
>> On Mon, Nov 28, 2011 at 10:56 AM, Stephen Warren <swarren@nvidia.com> wrote:
>>> On 11/23/2011 08:54 PM, Simon Glass wrote:
>>>> This was taken from commit 1ea6b8f at:
>>>> git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git
>>>
> ...
>>> In particular, linux-next now includes a minimal USB binding. Should we
>>> just use this in U-Boot for now? We should get review on the kernel
>>> lists before bringing in this more advanced USB binding in U-Boot, and
>>> perhaps even add the binding into the kernel at the same time?
>>
>> I copied my email to the device-tree mailing list. Hopefully that is
>> enough to get a review there. It feels wrong to send U-Boot patches to
>> the kernel list...?
>
> I think the kernel and U-boot need to co-ordinate on the DT bindings.
> Posting at least to linux-tegra, the Tegra maintainers, and perhaps even
> the kernel's domain-specific list (i.e. linux-usb) seems appropriate to
> me. DT is a cross-functional thing, and really needs cross-functional
> discussion and review. devicetree-discuss will cover the DT experts, but
> probably not the CPU and subsystem experts.

I worry about the implication that I am blazing a trail here. I would
prefer to take the bindings as set down by the kernel and make them
work within U-Boot. The reasoning here is that Linux has more
demanding requirements, and more flexibility, so it is unlikely that
U-Boot would need more features in its fdt. The one exception might be
due to efficiency. If it takes 10ms and 50KB of code to figure out the
system state from the fdt then U-Boot people might get upset, so I do
want to make sure the bindings can be efficiently parsed by U-Boot
(hence my peripheral id approach).

Where those bindings don't exist yet, I would prefer to use a
place-holder until they are set, then change the U-Boot code later.
That process can take many months and we don't want to hold back
actual functionality in U-Boot just because we haven't finalized the
fdt definitions for a particular peripheral.

I will certainly widen my distribution list for fdt patches in the
hope that resolution can be reached then and there, but it will be
hard for kernel people to agree a binding until they have written /
modified the driver. IMO it would probably be a good idea for people
to subscribe to device-tree-discuss if they are interested in fdt
things, kernel or U-Boot or other. LKML already gets a huge amount of
traffic.

Regards,
Simon

>
> --
> nvpublic
>

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
  2011-12-02  4:58           ` Simon Glass
@ 2011-12-02 17:22             ` Jerry Van Baren
  2011-12-02 18:12               ` Simon Glass
  0 siblings, 1 reply; 28+ messages in thread
From: Jerry Van Baren @ 2011-12-02 17:22 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

On 12/01/2011 11:58 PM, Simon Glass wrote:
> Hi Jerry,
>
> On Thu, Dec 1, 2011 at 7:33 PM, Jerry Van Baren<gvb.uboot@gmail.com>  wrote:

[snip]

>> FDT helper functions have been accumulating in common/fdt_support.c rather
>> than a separate file.  Simon, what is the history of lib/fdtdec.c?  Is it a
>> shared file from the linux kernel?  If it is u-boot specific, it would
>> probably be better to add the functions to fdt_support.c.
>
> There are sort-of two FDT strands within U-Boot. The main one is
> support for putting together an FDT to pass to the kernel (cmd_fdt,
> fdt_support), and the other is for U-Boot's own use (run-time
> configuration of U-Boot, fdtdec). They both use libfdt.
>
> I regard fdt_support as part of the former, and fdtdec (decode-only
> helper functions) as part of the latter. At present when you turn on
> CONFIG_OF_LIBFDT you get everything, but we could provide finer
> granularity for platforms which only want to decode an FDT for
> run-time config and don't want to mess with it. Since fdt_decode is
> about 6KB of code that might be useful.

Ahh, I see.  I have not been closely tracking the u-boot config (fdtdec) 
improvements, so I did not recognize it as being part of that effort. 
That makes sense.

Thanks,
gvb

[snip]

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

* Re: [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools
  2011-12-02 17:22             ` Jerry Van Baren
@ 2011-12-02 18:12               ` Simon Glass
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-12-02 18:12 UTC (permalink / raw)
  To: Jerry Van Baren; +Cc: U-Boot Mailing List, Devicetree Discuss, Tom Warren

Hi Jerry,

On Fri, Dec 2, 2011 at 9:22 AM, Jerry Van Baren <gvb.uboot@gmail.com> wrote:
> On 12/01/2011 11:58 PM, Simon Glass wrote:
>>
>> Hi Jerry,
>>
>> On Thu, Dec 1, 2011 at 7:33 PM, Jerry Van Baren<gvb.uboot@gmail.com>
>>  wrote:
>
> [snip]
>
>>> FDT helper functions have been accumulating in common/fdt_support.c
>>> rather
>>> than a separate file.  Simon, what is the history of lib/fdtdec.c?  Is it
>>> a
>>> shared file from the linux kernel?  If it is u-boot specific, it would
>>> probably be better to add the functions to fdt_support.c.
>>
>> There are sort-of two FDT strands within U-Boot. The main one is
>> support for putting together an FDT to pass to the kernel (cmd_fdt,
>> fdt_support), and the other is for U-Boot's own use (run-time
>> configuration of U-Boot, fdtdec). They both use libfdt.
>>
>> I regard fdt_support as part of the former, and fdtdec (decode-only
>> helper functions) as part of the latter. At present when you turn on
>> CONFIG_OF_LIBFDT you get everything, but we could provide finer
>> granularity for platforms which only want to decode an FDT for
>> run-time config and don't want to mess with it. Since fdt_decode is
>> about 6KB of code that might be useful.
>
> Ahh, I see.  I have not been closely tracking the u-boot config (fdtdec)
> improvements, so I did not recognize it as being part of that effort. That
> makes sense.

You are welcome, thanks.

Regards
Simon

>
> Thanks,
> gvb
>
> [snip]
>

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

* Re: [PATCH 10/14] tegra: usb: Add support for USB peripheral
       [not found]                       ` <CAPnjgZ1G+mv6uv8SrdMm7DoqFjeeyVHYv6nbQxn9qixfbQMGvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-12-07 23:46                         ` Stephen Warren
  2011-12-08 21:24                           ` Simon Glass
  0 siblings, 1 reply; 28+ messages in thread
From: Stephen Warren @ 2011-12-07 23:46 UTC (permalink / raw)
  To: Simon Glass
  Cc: Remy Bohmer, U-Boot Mailing List, devicetree-discuss, Tom Warren,
	Albert ARIBAUD

On 12/06/2011 02:23 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On Tue, Dec 6, 2011 at 12:42 PM, Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>> On 12/05/2011 06:14 PM, Simon Glass wrote:
>>> Hi Stephen,
>>>
>>> On Mon, Dec 5, 2011 at 4:17 PM, Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>>>> On 12/05/2011 04:35 PM, Simon Glass wrote:
...
>>>>> Also the only way I can see it being hard-coded is by the kernel
>>>>> looking at the peripheral address and converting this to an ID. That
>>>>> seems really ugly to me. Or am I missing something?
>>>>
>>>> Well, the Tegra SD/MMC driver works exactly that way (well, mapping an
>>>> instance ID to both base address and periph ID), so there's certainly
>>>> precedent for this. And that driver is not unique.
>>>
>>> I don't know if I can NAK a comment but I would like to NAK this one.
>>
>> I don't know what that means; that you believe my statement is
>> incorrect, or you don't like the argument I'm basing on it or ...?
> 
> What happens is that the SD/MMC driver (dating from pre-FDT days) has
> a hard-coded base address and peripheral ID, based on an instance ID
> (0, 1, 2).

That's basically the exact same thing, it's just the exact fields that
are the key into and output from the table are different.

> I would expect that we want the FDT to control all of this - it
> already has the base address, can have the peripheral ID, and the
> instance ID (ordering) should be set by the FDT not hard-coded IMO.
> That's the reason for my NAK comment. It just seems completely wrong
> to duplicate this information in the driver and require the instance
> ordering to be hard-coded in the driver. It means that boards that
> want to change this ordering must fiddle around in the driver to make
> this work.
> 
> Also this is U-Boot, not the kernel. Commands like 'ext2load' require
> that you pass the instance ID to indicate which device to use.

SD/MMC is a very different use-case, and not a good analogy to USB.

With SD, the user always wants to identify a specific device that they
know contains their files.

With USB, the user doesn't care that there are multiple USB host
controllers in the SoC; they just want to plug in their device somewhere
and have it work. Having to decide which USB controller to enable at a
time is pretty hokey, given there's unlikely to be any indication at all
on the PCB or case which ports map to which USB controllers.

What the user might care about is selecting a enumerated particular USB
device. They'd only know which one after looking at some "lsusb" command
(or whatever it's called in U-Boot) in the general case.

Hence, I assert that USB host controller number is completely
irrelevant, and all should be active at once.

This of course is all somewhat moot given that I pointed out
ehci-tegra.c only supports one of the hosts anyway...

> OK, so is your objection that we ignore a peripheral that has no
> alias?

Yes.

And that enumeration is based on alias nodes not enumerating all nodes
that match the compatible flag.

> If I change the code to locate these and add them at the end
> would that be better?

Sure.

I think the best implementation would be to enumerate everything solely
based on compatible flags, and allowing "usb start" to accept either an
alias name (which would be fixed) or a DT unit address or node name
(which would be fixed) or a controller index (which might vary based on
enumeration order) to select the controller.

The next best implementation would be to enumerate solely based on
compatible flags, then sort the list based on alias, thus allowing alias
to cause a static order.

However, enumerating based on alias, then enumerating based on
compatible flags and adding any missing nodes would be fine.

>> As I mentioned elsewhere, the patches only allow one to actually use usb
>> controller 0; ehci-tegra.c's ehci_hcd_init() hard-codes port 0 when
>> calling tegrausb_start_port(). Rather than relying on non-standard
>> aliases usage to restrict the set of USB devices that get instantiated,
>> why not just add status = "disabled" to all but one USB host's node in
>> each board's .dts file; that's the standard way to disable devices.
> 
> I can do that, but how do I solve the ordering problem?

If you only have one enabled controller in the .dts file, there can't be
any ordering issue since there is always only 1 controller.

-- 
nvpublic

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

* Re: [PATCH 10/14] tegra: usb: Add support for USB peripheral
  2011-12-07 23:46                         ` [PATCH 10/14] tegra: usb: Add support for USB peripheral Stephen Warren
@ 2011-12-08 21:24                           ` Simon Glass
       [not found]                             ` <CAPnjgZ0AuBNkYKN0JHQyc7DdzwUSZivR+Dv2BkiFsKQBNMeP8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 28+ messages in thread
From: Simon Glass @ 2011-12-08 21:24 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, devicetree-discuss, Tom Warren

Hi Stephen,

On Wed, Dec 7, 2011 at 3:46 PM, Stephen Warren <swarren@nvidia.com> wrote:
> On 12/06/2011 02:23 PM, Simon Glass wrote:
>> Hi Stephen,
>>
>> On Tue, Dec 6, 2011 at 12:42 PM, Stephen Warren <swarren@nvidia.com> wrote:
>>> On 12/05/2011 06:14 PM, Simon Glass wrote:
>>>> Hi Stephen,
>>>>
>>>> On Mon, Dec 5, 2011 at 4:17 PM, Stephen Warren <swarren@nvidia.com> wrote:
>>>>> On 12/05/2011 04:35 PM, Simon Glass wrote:
> ...
>>>>>> Also the only way I can see it being hard-coded is by the kernel
>>>>>> looking at the peripheral address and converting this to an ID. That
>>>>>> seems really ugly to me. Or am I missing something?
>>>>>
>>>>> Well, the Tegra SD/MMC driver works exactly that way (well, mapping an
>>>>> instance ID to both base address and periph ID), so there's certainly
>>>>> precedent for this. And that driver is not unique.
>>>>
>>>> I don't know if I can NAK a comment but I would like to NAK this one.
>>>
>>> I don't know what that means; that you believe my statement is
>>> incorrect, or you don't like the argument I'm basing on it or ...?
>>
>> What happens is that the SD/MMC driver (dating from pre-FDT days) has
>> a hard-coded base address and peripheral ID, based on an instance ID
>> (0, 1, 2).
>
> That's basically the exact same thing, it's just the exact fields that
> are the key into and output from the table are different.
>
>> I would expect that we want the FDT to control all of this - it
>> already has the base address, can have the peripheral ID, and the
>> instance ID (ordering) should be set by the FDT not hard-coded IMO.
>> That's the reason for my NAK comment. It just seems completely wrong
>> to duplicate this information in the driver and require the instance
>> ordering to be hard-coded in the driver. It means that boards that
>> want to change this ordering must fiddle around in the driver to make
>> this work.
>>
>> Also this is U-Boot, not the kernel. Commands like 'ext2load' require
>> that you pass the instance ID to indicate which device to use.
>
> SD/MMC is a very different use-case, and not a good analogy to USB.
>
> With SD, the user always wants to identify a specific device that they
> know contains their files.
>
> With USB, the user doesn't care that there are multiple USB host
> controllers in the SoC; they just want to plug in their device somewhere
> and have it work. Having to decide which USB controller to enable at a
> time is pretty hokey, given there's unlikely to be any indication at all
> on the PCB or case which ports map to which USB controllers.
>
> What the user might care about is selecting a enumerated particular USB
> device. They'd only know which one after looking at some "lsusb" command
> (or whatever it's called in U-Boot) in the general case.
>
> Hence, I assert that USB host controller number is completely
> irrelevant, and all should be active at once.

In our case we do not want to look at the USB port the contains the 3G
modem, for example, just the external one which can contain a USB
stick.

>
> This of course is all somewhat moot given that I pointed out
> ehci-tegra.c only supports one of the hosts anyway...
>
>> OK, so is your objection that we ignore a peripheral that has no
>> alias?
>
> Yes.

OK. We will ignore it anyway since USB2 is marked as disabled, but I
agree that isn't true in general.

>
> And that enumeration is based on alias nodes not enumerating all nodes
> that match the compatible flag.
>
>> If I change the code to locate these and add them at the end
>> would that be better?
>
> Sure.
>
> I think the best implementation would be to enumerate everything solely
> based on compatible flags, and allowing "usb start" to accept either an
> alias name (which would be fixed) or a DT unit address or node name
> (which would be fixed) or a controller index (which might vary based on
> enumeration order) to select the controller.
>
> The next best implementation would be to enumerate solely based on
> compatible flags, then sort the list based on alias, thus allowing alias
> to cause a static order.
>
> However, enumerating based on alias, then enumerating based on
> compatible flags and adding any missing nodes would be fine.

Well ok. Since this is basically a small *addition* to the code
(scanning things that don't have an alias), and will have no effect
with the device tree as included in this series, I would like to do
this as a follow-on patch after the series. I hope you can live with
that also?

>
>>> As I mentioned elsewhere, the patches only allow one to actually use usb
>>> controller 0; ehci-tegra.c's ehci_hcd_init() hard-codes port 0 when
>>> calling tegrausb_start_port(). Rather than relying on non-standard
>>> aliases usage to restrict the set of USB devices that get instantiated,
>>> why not just add status = "disabled" to all but one USB host's node in
>>> each board's .dts file; that's the standard way to disable devices.
>>
>> I can do that, but how do I solve the ordering problem?
>
> If you only have one enabled controller in the .dts file, there can't be
> any ordering issue since there is always only 1 controller.

I really was referring to how it should be done. We will enable two
points. Only one is currently accessible due to us needing either a
parameter to 'usb start' or the virtual ehci hub code. But USB
upstreaming is not complete after this series - it is only a step in
the process. I feel that 14 patches is big enough for a series :-)

Regards,
Simon

>
> --
> nvpublic

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

* Re: [PATCH 10/14] tegra: usb: Add support for USB peripheral
       [not found]                             ` <CAPnjgZ0AuBNkYKN0JHQyc7DdzwUSZivR+Dv2BkiFsKQBNMeP8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2011-12-12 18:18                               ` Stephen Warren
  2011-12-12 18:42                                 ` Simon Glass
  0 siblings, 1 reply; 28+ messages in thread
From: Stephen Warren @ 2011-12-12 18:18 UTC (permalink / raw)
  To: Simon Glass
  Cc: Remy Bohmer, U-Boot Mailing List, devicetree-discuss, Tom Warren,
	Albert ARIBAUD

On 12/08/2011 02:24 PM, Simon Glass wrote:
> On Wed, Dec 7, 2011 at 3:46 PM, Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> wrote:
>> On 12/06/2011 02:23 PM, Simon Glass wrote:
...
>> I think the best implementation would be to enumerate everything solely
>> based on compatible flags, and allowing "usb start" to accept either an
>> alias name (which would be fixed) or a DT unit address or node name
>> (which would be fixed) or a controller index (which might vary based on
>> enumeration order) to select the controller.
>>
>> The next best implementation would be to enumerate solely based on
>> compatible flags, then sort the list based on alias, thus allowing alias
>> to cause a static order.
>>
>> However, enumerating based on alias, then enumerating based on
>> compatible flags and adding any missing nodes would be fine.
> 
> Well ok. Since this is basically a small *addition* to the code
> (scanning things that don't have an alias), and will have no effect
> with the device tree as included in this series, I would like to do
> this as a follow-on patch after the series. I hope you can live with
> that also?

I suppose it'll have to do.

It's totally the wrong way to go about it though, and will provide a bad
example that'll probably end up proliferating itself through the code
since it's the first example.

In other words rather than:

Now: Scan /aliases for USB, add then all.

Later: Scan device nodes for any that weren't in /aliases, add them all

I'd prefer to see:

Now: Scan /aliases for USB, add then all.

Later: Remove all the /aliases scanning code, fix the code to scan all
child nodes of the SoC node, find all nodes matching the USB compatible
flag, add them all. While adding a USB controller, check the /alias node
and honor any alias there if there is one.

-- 
nvpublic

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

* Re: [PATCH 10/14] tegra: usb: Add support for USB peripheral
  2011-12-12 18:18                               ` Stephen Warren
@ 2011-12-12 18:42                                 ` Simon Glass
  0 siblings, 0 replies; 28+ messages in thread
From: Simon Glass @ 2011-12-12 18:42 UTC (permalink / raw)
  To: Stephen Warren; +Cc: U-Boot Mailing List, devicetree-discuss, Tom Warren

Hi Stephen,

On Mon, Dec 12, 2011 at 10:18 AM, Stephen Warren <swarren@nvidia.com> wrote:
> On 12/08/2011 02:24 PM, Simon Glass wrote:
>> On Wed, Dec 7, 2011 at 3:46 PM, Stephen Warren <swarren@nvidia.com> wrote:
>>> On 12/06/2011 02:23 PM, Simon Glass wrote:
> ...
>>> I think the best implementation would be to enumerate everything solely
>>> based on compatible flags, and allowing "usb start" to accept either an
>>> alias name (which would be fixed) or a DT unit address or node name
>>> (which would be fixed) or a controller index (which might vary based on
>>> enumeration order) to select the controller.
>>>
>>> The next best implementation would be to enumerate solely based on
>>> compatible flags, then sort the list based on alias, thus allowing alias
>>> to cause a static order.
>>>
>>> However, enumerating based on alias, then enumerating based on
>>> compatible flags and adding any missing nodes would be fine.
>>
>> Well ok. Since this is basically a small *addition* to the code
>> (scanning things that don't have an alias), and will have no effect
>> with the device tree as included in this series, I would like to do
>> this as a follow-on patch after the series. I hope you can live with
>> that also?
>
> I suppose it'll have to do.
>
> It's totally the wrong way to go about it though, and will provide a bad
> example that'll probably end up proliferating itself through the code
> since it's the first example.
>
> In other words rather than:
>
> Now: Scan /aliases for USB, add then all.
>
> Later: Scan device nodes for any that weren't in /aliases, add them all
>
> I'd prefer to see:
>
> Now: Scan /aliases for USB, add then all.
>
> Later: Remove all the /aliases scanning code, fix the code to scan all
> child nodes of the SoC node, find all nodes matching the USB compatible
> flag, add them all. While adding a USB controller, check the /alias node
> and honor any alias there if there is one.

OK, perhaps I am thinking too closely about an efficient algorithm as
separate from the required function. This patch series does the 'Now'
but, and the 'Later' bit can be done as you say I think. Issues that
come include someone having an alias for port 2 but not 1, and having
to detect this and move things down at the end. I will need to think
about support in fdtdec to make this easy. That's why I want to do it
later as this patch series is already large and we are well aware of
its limitations in several areas (e.g. there is no way to use port 1
in U-Boot yet).

Regards,
Simon

>
> --
> nvpublic

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

end of thread, other threads:[~2011-12-12 18:42 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24  3:54 [PATCH 01/14] fdt: Tidy up a few fdtdec problems Simon Glass
2011-11-24  3:54 ` [PATCH 03/14] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
2011-11-24  3:54 ` [PATCH 06/14] tegra: fdt: Add device tree file for Tegra2 Seaboard Simon Glass
     [not found] ` <1322106896-23054-2-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-11-24  3:54   ` [PATCH 02/14] fdt: Add functions to access phandles, arrays and bools Simon Glass
     [not found]     ` <1322106896-23054-3-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-11-28 18:41       ` Stephen Warren
     [not found]         ` <4ED3D5DC.10502-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-11-29  5:12           ` David Gibson
2011-12-02  1:01         ` Simon Glass
     [not found]           ` <CAPnjgZ29tsNXd1+1eXdTHRjgh_MQJrXoc23_oqO9UPJ73mu7ZA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-02 15:55             ` Stephen Warren
2011-12-02 16:38               ` Simon Glass
2011-12-02  3:33         ` Jerry Van Baren
2011-12-02  4:58           ` Simon Glass
2011-12-02 17:22             ` Jerry Van Baren
2011-12-02 18:12               ` Simon Glass
2011-11-24  3:54   ` [PATCH 04/14] arm: fdt: Add skeleton device tree file Simon Glass
2011-11-24  3:54   ` [PATCH 05/14] tegra: fdt: Add Tegra2x " Simon Glass
     [not found]     ` <1322106896-23054-6-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-11-28 18:56       ` Stephen Warren
2011-12-02  1:24         ` Simon Glass
     [not found]           ` <CAPnjgZ11cFm15E9MHXno_YGp0NxdOHhGBavYbQBP5Nu_TOtx7A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-02 15:58             ` Stephen Warren
2011-12-02 16:47               ` Simon Glass
2011-11-24  3:54   ` [PATCH 07/14] tegra: fdt: Add initial device tree definitions for USB ports Simon Glass
2011-11-24  3:54   ` [PATCH 14/14] tegra: fdt: Enable FDT support for Seaboard Simon Glass
2011-11-28 18:33   ` [PATCH 01/14] fdt: Tidy up a few fdtdec problems Stephen Warren
     [not found]     ` <4ED3D3F2.8070302-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-11-29  1:10       ` David Gibson
2011-12-01 20:59     ` Simon Glass
     [not found] ` <1322106896-23054-11-git-send-email-sjg@chromium.org>
     [not found]   ` <4ED3DF1D.6080009@nvidia.com>
     [not found]     ` <CAPnjgZ1-yxq-O-vsy1gNJ8AOzh7Sz9j5PG9Tx1sKpnAxhApJAQ@mail.gmail.com>
     [not found]       ` <4EDD38AC.30908@nvidia.com>
     [not found]         ` <CAPnjgZ0MTaPa4pq1VXk_XbmuDyWTfy-H33W4deNVn2ALUrcW_A@mail.gmail.com>
     [not found]           ` <4EDD429E.8010507@nvidia.com>
     [not found]             ` <CAPnjgZ2G220G-i3PPtS4XJYY0ornWFOoK3=b93jG-6GE_g2O5w@mail.gmail.com>
     [not found]               ` <4EDD5F1B.5060205@nvidia.com>
     [not found]                 ` <CAPnjgZ2h7F228q=pXuf7M9vTASurY3R5an_QV-mrETLf8nzA1A@mail.gmail.com>
     [not found]                   ` <4EDE7E1C.2090203@nvidia.com>
     [not found]                     ` <CAPnjgZ1G+mv6uv8SrdMm7DoqFjeeyVHYv6nbQxn9qixfbQMGvA@mail.gmail.com>
     [not found]                       ` <CAPnjgZ1G+mv6uv8SrdMm7DoqFjeeyVHYv6nbQxn9qixfbQMGvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-07 23:46                         ` [PATCH 10/14] tegra: usb: Add support for USB peripheral Stephen Warren
2011-12-08 21:24                           ` Simon Glass
     [not found]                             ` <CAPnjgZ0AuBNkYKN0JHQyc7DdzwUSZivR+Dv2BkiFsKQBNMeP8A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-12 18:18                               ` Stephen Warren
2011-12-12 18:42                                 ` Simon Glass

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