* [PATCH v3 01/16] fdt: Tidy up a few fdtdec problems
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 02/16] fdt: Add functions to access phandles, arrays and bools Simon Glass
` (8 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This fixes five 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. This is needed
only because the first fdt_compat_id is defined to be invalid.
4. Added a header prototype for fdtdec_next_compatible()
5. Change fdtdec_next_alias() to only increment its 'upto' parameter
on success, to make the display error messages in the caller easier.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
include/fdtdec.h | 23 +++++++++++++++++++----
lib/fdtdec.c | 22 ++++++++++++++++------
2 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index d871cdd..49dbac4 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -82,6 +82,21 @@ int fdtdec_next_alias(const void *blob, const char *name,
enum fdt_compat_id id, int *upto);
/**
+ * Find the next compatible node for a peripheral.
+ *
+ * Do the first call with node = 0. This function will return a pointer to
+ * the next compatible node. Next time you call this function, pass the
+ * value returned, and the next node will be provided.
+ *
+ * @param blob FDT blob to use
+ * @param node Start node for search
+ * @param id Compatible ID to look for (enum fdt_compat_id)
+ * @return offset of next compatible node, or -FDT_ERR_NOTFOUND if no more
+ */
+int fdtdec_next_compatible(const void *blob, int node,
+ enum fdt_compat_id id);
+
+/**
* Look up an address property in a node and return it as an address.
* The property must hold either one address with no trailing data or
* one address with a length. This is only tested on 32-bit machines.
@@ -112,14 +127,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..55bbfc8 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,21 @@ 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;
+ /*
+ * It should say "okay", so only allow that. Some fdts use "ok" but
+ * this is a bug. Please fix your device tree source file. See here
+ * for discussion:
+ *
+ * http://www.mail-archive.com/u-boot-0aAXYlwwYIKGBzrmiIFOJg@public.gmane.org/msg71598.html
+ */
cell = fdt_getprop(blob, node, "status", NULL);
if (cell)
- return 0 == strcmp(cell, "ok");
- return default_val;
+ return 0 == strcmp(cell, "okay");
+ return 1;
}
enum fdt_compat_id fd_dec_lookup(const void *blob, int node)
@@ -122,14 +130,16 @@ int fdtdec_next_alias(const void *blob, const char *name,
/* snprintf() is not available */
assert(strlen(name) < MAX_STR_LEN);
sprintf(str, "%.*s%d", MAX_STR_LEN, name, *upto);
- (*upto)++;
node = find_alias_node(blob, str);
if (node < 0)
return node;
err = fdt_node_check_compatible(blob, node, compat_names[id]);
if (err < 0)
return err;
- return err ? -FDT_ERR_NOTFOUND : node;
+ if (err)
+ return -FDT_ERR_NOTFOUND;
+ (*upto)++;
+ return node;
}
/*
@@ -140,7 +150,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] 10+ messages in thread* [PATCH v3 02/16] fdt: Add functions to access phandles, arrays and bools
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-12-07 1:24 ` [PATCH v3 01/16] fdt: Tidy up a few fdtdec problems Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 04/16] fdt: Add basic support for decoding GPIO definitions Simon Glass
` (7 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
Add a function to look up 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, although there is no
actual boolean type in U-Boot.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
include/fdtdec.h | 40 ++++++++++++++++++++++++++++++++
lib/fdtdec.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 49dbac4..c414131 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -141,3 +141,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,
+ u32 *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, regardless of its 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
+ */
+int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 55bbfc8..ca6a698 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -155,3 +155,70 @@ 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_check_min_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,
+ u32 *array, int count)
+{
+ const u32 *cell;
+ int i, err = 0;
+
+ debug("%s: %s\n", __func__, prop_name);
+ cell = get_prop_check_min_len(blob, node, prop_name,
+ sizeof(u32) * count, &err);
+ if (!err) {
+ for (i = 0; i < count; i++)
+ array[i] = fdt32_to_cpu(cell[i]);
+ }
+ return err;
+}
+
+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);
+ return cell != NULL;
+}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 04/16] fdt: Add basic support for decoding GPIO definitions
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2011-12-07 1:24 ` [PATCH v3 01/16] fdt: Tidy up a few fdtdec problems Simon Glass
2011-12-07 1:24 ` [PATCH v3 02/16] fdt: Add functions to access phandles, arrays and bools Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 05/16] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
` (6 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This adds some support into fdtdec for reading GPIO definitions from
the fdt. We permit up to FDT_GPIO_MAX GPIOs in the system. Each GPIO
is of the form:
gpio-function-name = <phandle gpio_num flags>;
where:
phandle is a pointer to the GPIO node
gpio_num is the number of the GPIO (0 to 223)
flags is a flag, as follows:
bit meaning
0 0=polarity normal, 1=active low (inverted)
An example is:
gpio-enable-propounder = <&gpio 43 0>;
which means that GPIO 43 is used to enable the propounder (setting the
GPIO high), or that you can detect that the propounder is enabled by
checking if the GPIO is high (the fdt does not indicate input/output).
Two main functions are provided:
fdtdec_decode_gpio() reads a GPIO property from an fdt node and decodes it
into a structure.
fdtdec_setup_gpio() sets up the GPIO by calling gpio_request for you.
Both functions can cope with the property being missing, which is taken to
mean that that GPIO function is not available or is not needed.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
include/fdtdec.h | 45 +++++++++++++++++++++++++++++++
lib/fdtdec.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 123 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index c414131..a640db1 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -61,6 +61,23 @@ enum fdt_compat_id {
COMPAT_COUNT,
};
+/* GPIOs are numbered from 0 */
+enum {
+ FDT_GPIO_NONE = -1U, /* an invalid GPIO used to end our list */
+
+ FDT_GPIO_ACTIVE_LOW = 1 << 0, /* input is active low (else high) */
+};
+
+/* This is the state of a GPIO pin as defined by the fdt */
+struct fdt_gpio_state {
+ const char *name; /* name of the fdt property defining this */
+ uint gpio; /* GPIO number, or FDT_GPIO_NONE if none */
+ u8 flags; /* FDT_GPIO_... flags */
+};
+
+/* This tells us whether a fdt_gpio_state record is valid or not */
+#define fdt_gpio_isvalid(x) ((x)->gpio != FDT_GPIO_NONE)
+
/**
* Find the next numbered alias for a peripheral. This is used to enumerate
* all the peripherals of a certain type.
@@ -181,3 +198,31 @@ int fdtdec_get_int_array(const void *blob, int node, const char *prop_name,
* @return 1 if the properly is present; 0 if it isn't present
*/
int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
+
+/**
+ * Decode a single GPIOs from an FDT.
+ *
+ * If the property is not found, then the GPIO structure will still be
+ * initialised, with gpio set to FDT_GPIO_NONE. This makes it easy to
+ * provide optional GPIOs.
+ *
+ * @param blob FDT blob to use
+ * @param node Node to look at
+ * @param prop_name Node property name
+ * @param gpio gpio elements to fill from FDT
+ * @return 0 if ok, -FDT_ERR_NOTFOUND if the property is missing.
+ */
+int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
+ struct fdt_gpio_state *gpio);
+
+/**
+ * Set up a GPIO pin according to the provided gpio information. At present this
+ * just requests the GPIO.
+ *
+ * If the gpio is FDT_GPIO_NONE, no action is taken. This makes it easy to
+ * deal with optional GPIOs.
+ *
+ * @param gpio GPIO info to use for set up
+ * @return 0 if all ok or gpio was FDT_GPIO_NONE; -1 on error
+ */
+int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index ca6a698..69f8b66 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -24,6 +24,9 @@
#include <libfdt.h>
#include <fdtdec.h>
+/* we need the generic GPIO interface here */
+#include <asm-generic/gpio.h>
+
DECLARE_GLOBAL_DATA_PTR;
/*
@@ -222,3 +225,78 @@ int fdtdec_get_bool(const void *blob, int node, const char *prop_name)
cell = fdt_getprop(blob, node, prop_name, &len);
return cell != NULL;
}
+
+/**
+ * Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no
+ * terminating item.
+ *
+ * @param blob FDT blob to use
+ * @param node Node to look at
+ * @param prop_name Node property name
+ * @param gpio Array of gpio elements to fill from FDT. This will be
+ * untouched if either 0 or an error is returned
+ * @param max_count Maximum number of elements allowed
+ * @return number of GPIOs read if ok, -FDT_ERR_BADLAYOUT if max_count would
+ * be exceeded, or -FDT_ERR_NOTFOUND if the property is missing.
+ */
+static int fdtdec_decode_gpios(const void *blob, int node,
+ const char *prop_name, struct fdt_gpio_state *gpio,
+ int max_count)
+{
+ const struct fdt_property *prop;
+ const u32 *cell;
+ const char *name;
+ int len, i;
+
+ debug("%s: %s\n", __func__, prop_name);
+ assert(max_count > 0);
+ prop = fdt_get_property(blob, node, prop_name, &len);
+ if (!prop) {
+ debug("FDT: %s: property '%s' missing\n", __func__, prop_name);
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ /* We will use the name to tag the GPIO */
+ name = fdt_string(blob, prop->nameoff);
+ cell = (u32 *)prop->data;
+ len /= sizeof(u32) * 3; /* 3 cells per GPIO record */
+ if (len > max_count) {
+ debug("FDT: %s: too many GPIOs / cells for "
+ "property '%s'\n", __func__, prop_name);
+ return -FDT_ERR_BADLAYOUT;
+ }
+
+ /* Read out the GPIO data from the cells */
+ for (i = 0; i < len; i++, cell += 3) {
+ gpio[i].gpio = fdt32_to_cpu(cell[1]);
+ gpio[i].flags = fdt32_to_cpu(cell[2]);
+ gpio[i].name = name;
+ }
+
+ return len;
+}
+
+int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
+ struct fdt_gpio_state *gpio)
+{
+ int err;
+
+ debug("%s: %s\n", __func__, prop_name);
+ gpio->gpio = FDT_GPIO_NONE;
+ err = fdtdec_decode_gpios(blob, node, prop_name, gpio, 1);
+ return err == 1 ? 0 : err;
+}
+
+int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
+{
+ /*
+ * Return success if there is no GPIO defined. This is used for
+ * optional GPIOs)
+ */
+ if (!fdt_gpio_isvalid(gpio))
+ return 0;
+
+ if (gpio_request(gpio->gpio, gpio->name))
+ return -1;
+ return 0;
+}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 05/16] arm: fdt: Ensure that an embedded fdt is word-aligned
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (2 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 04/16] fdt: Add basic support for decoding GPIO definitions Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 06/16] arm: fdt: Add skeleton device tree file from kernel Simon Glass
` (5 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, 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-F7+t8E8rja9g9hUCZPvPmw@public.gmane.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] 10+ messages in thread* [PATCH v3 06/16] arm: fdt: Add skeleton device tree file from kernel
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (3 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 05/16] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 07/16] tegra: fdt: Add Tegra2x " Simon Glass
` (4 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This was taken from commit b48c54e2 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] 10+ messages in thread* [PATCH v3 07/16] tegra: fdt: Add Tegra2x device tree file from kernel
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (4 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 06/16] arm: fdt: Add skeleton device tree file from kernel Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 08/16] tegra: fdt: Add device tree file for Tegra2 Seaboard " Simon Glass
` (3 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This was taken from commit b48c54e2 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 | 169 +++++++++++++++++++++++++++++++++++
2 files changed, 171 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..6146d24
--- /dev/null
+++ b/arch/arm/dts/tegra20.dtsi
@@ -0,0 +1,169 @@
+/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 >;
+ };
+
+ usb@c5000000 {
+ compatible = "nvidia,tegra20-ehci", "usb-ehci";
+ reg = <0xc5000000 0x4000>;
+ interrupts = < 52 >;
+ phy_type = "utmi";
+ };
+
+ usb@c5004000 {
+ compatible = "nvidia,tegra20-ehci", "usb-ehci";
+ reg = <0xc5004000 0x4000>;
+ interrupts = < 53 >;
+ phy_type = "ulpi";
+ };
+
+ usb@c5008000 {
+ compatible = "nvidia,tegra20-ehci", "usb-ehci";
+ reg = <0xc5008000 0x4000>;
+ interrupts = < 129 >;
+ phy_type = "utmi";
+ };
+
+};
+
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 08/16] tegra: fdt: Add device tree file for Tegra2 Seaboard from kernel
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (5 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 07/16] tegra: fdt: Add Tegra2x " Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 09/16] tegra: usb: fdt: Add additional device tree definitions for USB ports Simon Glass
` (2 subsequent siblings)
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This was taken from commit b48c54e2 at:
git://git.kernel.org/pub/scm/linux/kernel/git/olof/tegra.git
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
board/nvidia/dts/tegra2-seaboard.dts | 36 ++++++++++++++++++++++++++++++++++
1 files changed, 36 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..dde5d03
--- /dev/null
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -0,0 +1,36 @@
+/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;
+ };
+
+ usb@c5000000 {
+ nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 */
+ };
+};
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 09/16] tegra: usb: fdt: Add additional device tree definitions for USB ports
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (6 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 08/16] tegra: fdt: Add device tree file for Tegra2 Seaboard " Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 10/16] tegra: usb: fdt: Add USB definitions for Tegra2 Seaboard Simon Glass
2011-12-07 1:24 ` [PATCH v3 16/16] tegra: fdt: Enable FDT support for Seaboard Simon Glass
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Remy Bohmer, Jerry Van Baren, Tom Warren,
Devicetree Discuss
This adds peripheral IDs to the USB part of the device tree for U-Boot.
The peripheral IDs provide easy access to clock registers. We will likely
remove this in favor of a full clock tree when it is available in the
kernel (but probably still retain the peripheral ID, just move it into
a clock node).
The USB timing information may vary between boards sometimes, but for
now we hard-code it in C. This is because all current T2x boards use
the same values, we will deal with T3x later and we first need to agree
on the format for this timing information in the fdt and may in fact
decide that it has no place there.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
arch/arm/dts/tegra20.dtsi | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index 6146d24..27e3127 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -149,6 +149,7 @@
reg = <0xc5000000 0x4000>;
interrupts = < 52 >;
phy_type = "utmi";
+ u-boot,periph-id = <22>; // PERIPH_ID_USBD
};
usb@c5004000 {
@@ -156,6 +157,7 @@
reg = <0xc5004000 0x4000>;
interrupts = < 53 >;
phy_type = "ulpi";
+ u-boot,periph-id = <58>; // PERIPH_ID_USB2
};
usb@c5008000 {
@@ -163,6 +165,7 @@
reg = <0xc5008000 0x4000>;
interrupts = < 129 >;
phy_type = "utmi";
+ u-boot,periph-id = <59>; // PERIPH_ID_USB3
};
};
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 10/16] tegra: usb: fdt: Add USB definitions for Tegra2 Seaboard
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (7 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 09/16] tegra: usb: fdt: Add additional device tree definitions for USB ports Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
2011-12-07 1:24 ` [PATCH v3 16/16] tegra: fdt: Enable FDT support for Seaboard Simon Glass
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Remy Bohmer, Jerry Van Baren, Tom Warren,
Devicetree Discuss
We set up two USB ports, one of which can be host or device.
For some reason the kernel version does enable both ports.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v2:
- Use "okay" instead of "ok" for fdt node status
- Remove 0x from fdt aliases
Changes in v3:
- Remove "okay" from nodes since this is the default anyway
- Fix device tree indenting with tabs instead of spaces
- Disable USB2 which is not used on Seaboard
board/nvidia/dts/tegra2-seaboard.dts | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
index dde5d03..839e761 100644
--- a/board/nvidia/dts/tegra2-seaboard.dts
+++ b/board/nvidia/dts/tegra2-seaboard.dts
@@ -11,6 +11,12 @@
bootargs = "vmalloc=192M video=tegrafb console=ttyS0,115200n8 root=/dev/mmcblk1p3 rw rootwait";
};
+ aliases {
+ /* This defines the order of our USB ports */
+ usb0 = "/usb@c5008000";
+ usb1 = "/usb@c5000000";
+ };
+
memory {
device_type = "memory";
reg = < 0x00000000 0x40000000 >;
@@ -31,6 +37,11 @@
};
usb@c5000000 {
- nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 */
+ nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 high to enable vbus */
+ support-host-mode;
+ };
+
+ usb@c5004000 {
+ status = "disabled";
};
};
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v3 16/16] tegra: fdt: Enable FDT support for Seaboard
[not found] ` <1323221055-20113-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (8 preceding siblings ...)
2011-12-07 1:24 ` [PATCH v3 10/16] tegra: usb: fdt: Add USB definitions for Tegra2 Seaboard Simon Glass
@ 2011-12-07 1:24 ` Simon Glass
9 siblings, 0 replies; 10+ messages in thread
From: Simon Glass @ 2011-12-07 1:24 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, 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>
---
Changes in v3:
- Drop Tegra USB alignment patch as we will deal with this another way
include/configs/seaboard.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/include/configs/seaboard.h b/include/configs/seaboard.h
index b6d9f7a..1dc775a 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) # "
--
1.7.3.1
^ permalink raw reply related [flat|nested] 10+ messages in thread