* [PATCH v5 01/18] fdt: Add basic support for decoding GPIO definitions
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
@ 2012-01-24 23:20 ` Simon Glass
2012-01-24 23:20 ` [PATCH v5 02/18] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
` (11 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:20 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren
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:
enable-propounder-gpios = <&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.
[For reference, from Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>. It may be that
we add this extra complexity later if needed:
The correct way to parse such a GPIO property in general is:
* Read the first cell.
* Find the node referenced by the phandle (the controller).
* Ensure property gpio-controller is present in the controller node.
* Read property #gpio-cells from the controller node.
* Extract #gpio-cells from the original property.
* Keep processing more cells from the original property; there may be
multiple GPIOs listed.
According to the binding documentation in the Linux kernel, Samsung
Exynos4 doesn't use this format, and while all other chips do have a
flags cell, about 50% of the controllers indicate the cell is unused.
]
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v5:
- Fixed endian bug in fdtdec_decode_gpios()
- Make sure GPIO name is NULL if incorrectly decoded
include/fdtdec.h | 45 ++++++++++++++++++++++++++++++
lib/fdtdec.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 124 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 047f603..6c0a2d1 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.
@@ -227,3 +244,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 977528b..c748cac 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;
/*
@@ -336,3 +339,79 @@ 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, fdt32_to_cpu(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;
+ gpio->name = NULL;
+ 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.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 02/18] arm: fdt: Ensure that an embedded fdt is word-aligned
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-01-24 23:20 ` [PATCH v5 01/18] fdt: Add basic support for decoding GPIO definitions Simon Glass
@ 2012-01-24 23:20 ` Simon Glass
2012-01-24 23:20 ` [PATCH v5 03/18] arm: fdt: Add skeleton device tree file from kernel Simon Glass
` (10 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:20 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.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 03/18] arm: fdt: Add skeleton device tree file from kernel
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-01-24 23:20 ` [PATCH v5 01/18] fdt: Add basic support for decoding GPIO definitions Simon Glass
2012-01-24 23:20 ` [PATCH v5 02/18] arm: fdt: Ensure that an embedded fdt is word-aligned Simon Glass
@ 2012-01-24 23:20 ` Simon Glass
2012-01-24 23:20 ` [PATCH v5 04/18] tegra: fdt: Add Tegra2x " Simon Glass
` (9 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:20 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.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 04/18] tegra: fdt: Add Tegra2x device tree file from kernel
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (2 preceding siblings ...)
2012-01-24 23:20 ` [PATCH v5 03/18] arm: fdt: Add skeleton device tree file from kernel Simon Glass
@ 2012-01-24 23:20 ` Simon Glass
2012-01-24 23:20 ` [PATCH v5 05/18] tegra: fdt: Add device tree file for Tegra2 Seaboard " Simon Glass
` (8 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:20 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 | 168 +++++++++++++++++++++++++++++++++++
2 files changed, 170 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..a9a98ea
--- /dev/null
+++ b/arch/arm/dts/tegra20.dtsi
@@ -0,0 +1,168 @@
+/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.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 05/18] tegra: fdt: Add device tree file for Tegra2 Seaboard from kernel
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (3 preceding siblings ...)
2012-01-24 23:20 ` [PATCH v5 04/18] tegra: fdt: Add Tegra2x " Simon Glass
@ 2012-01-24 23:20 ` Simon Glass
2012-01-24 23:21 ` [PATCH v5 06/18] fdt: Add staging area for device tree binding documentation Simon Glass
` (7 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:20 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.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 06/18] fdt: Add staging area for device tree binding documentation
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (4 preceding siblings ...)
2012-01-24 23:20 ` [PATCH v5 05/18] tegra: fdt: Add device tree file for Tegra2 Seaboard " Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
2012-01-24 23:21 ` [PATCH v5 07/18] fdt: Add tegra-usb bindings file from linux Simon Glass
` (6 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren
Add a directory to hold device tree binding files, to permit easy review
of this material in U-Boot patches.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v4:
- Add staging area for device tree bindings used in U-Boot
Changes in v5:
- Update README to indicate that we will commit fdt documentation to U-Boot
doc/device-tree-bindings/README | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
create mode 100644 doc/device-tree-bindings/README
diff --git a/doc/device-tree-bindings/README b/doc/device-tree-bindings/README
new file mode 100644
index 0000000..2ea3439
--- /dev/null
+++ b/doc/device-tree-bindings/README
@@ -0,0 +1,17 @@
+Device Tree Bindings Staging Area
+=================================
+
+This directory contains device tree bindings for U-Boot.
+
+These follow along with Linux kernel bindings, with a few additions. By
+adding the files here, U-Boot patches can clearly show thees additions.
+This makes it easier for device tree people to review these additions in
+patches sent to the U-Boot mailing list.
+
+The intent IS to commit these files to U-Boot. Hopefully at some point
+the files will be stored in another repo (shared with Linux) which is
+brought in as needed. Changes here are intended to mirror changes in the
+Linux Documentation/devicetree/bindings/ directory.
+
+sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org
+17-Jan-12
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 07/18] fdt: Add tegra-usb bindings file from linux
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (5 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 06/18] fdt: Add staging area for device tree binding documentation Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
2012-01-24 23:21 ` [PATCH v5 08/18] tegra: fdt: Add additional USB binding Simon Glass
` (5 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren
This file is taken from the Linux mailing list.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
doc/device-tree-bindings/usb/tegra-usb.txt | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
create mode 100644 doc/device-tree-bindings/usb/tegra-usb.txt
diff --git a/doc/device-tree-bindings/usb/tegra-usb.txt b/doc/device-tree-bindings/usb/tegra-usb.txt
new file mode 100644
index 0000000..035d63d
--- /dev/null
+++ b/doc/device-tree-bindings/usb/tegra-usb.txt
@@ -0,0 +1,13 @@
+Tegra SOC USB controllers
+
+The device node for a USB controller that is part of a Tegra
+SOC is as described in the document "Open Firmware Recommended
+Practice : Universal Serial Bus" with the following modifications
+and additions :
+
+Required properties :
+ - compatible : Should be "nvidia,tegra20-ehci" for USB controllers
+ used in host mode.
+ - phy_type : Should be one of "ulpi" or "utmi".
+ - nvidia,vbus-gpio : If present, specifies a gpio that needs to be
+ activated for the bus to be powered.
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 08/18] tegra: fdt: Add additional USB binding
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (6 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 07/18] fdt: Add tegra-usb bindings file from linux Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
[not found] ` <1327447272-30182-9-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-01-24 23:21 ` [PATCH v5 09/18] tegra: fdt: Add clock bindings Simon Glass
` (4 subsequent siblings)
12 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This adds a property to indicate a port which can switch between host and device
mode.
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v5:
- Add dr_mode property to control host/device/otg mode
- Add nvidia,has-legacy-mode property per review comments
doc/device-tree-bindings/usb/tegra-usb.txt | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/doc/device-tree-bindings/usb/tegra-usb.txt b/doc/device-tree-bindings/usb/tegra-usb.txt
index 035d63d..b7174a3 100644
--- a/doc/device-tree-bindings/usb/tegra-usb.txt
+++ b/doc/device-tree-bindings/usb/tegra-usb.txt
@@ -11,3 +11,15 @@ Required properties :
- phy_type : Should be one of "ulpi" or "utmi".
- nvidia,vbus-gpio : If present, specifies a gpio that needs to be
activated for the bus to be powered.
+
+Optional properties:
+ - dr_mode : dual role mode. Indicates the working mode for
+ nvidia,tegra20-ehci compatible controllers. Can be "host", "peripheral",
+ or "otg". Default to "host" if not defined for backward compatibility.
+ host means this is a host controller
+ peripheral means it is device controller
+ otg means it can operate as either ("on the go")
+ - nvidia,has-legacy-mode : boolean indicates whether this controller can
+ operate in legacy mode (as APX 2500 / 2600). In legacy mode some
+ registers are accessed through the APB_MISC base address instead of
+ the USB controller.
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 09/18] tegra: fdt: Add clock bindings
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (7 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 08/18] tegra: fdt: Add additional USB binding Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
2012-01-24 23:21 ` [PATCH v5 10/18] tegra: usb: fdt: Add additional device tree definitions for USB ports Simon Glass
` (3 subsequent siblings)
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Devicetree Discuss, Jerry Van Baren, Tom Warren
This adds a basic binding for the oscillator and peripheral clocks. The
second cell is the clock number, defined as the bit number within the clock
enable register if the peripheral clock.
This uses the RFC clock bindings from Grant Likely so may change later:
https://lkml.org/lkml/2011/12/12/498
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v4:
- Add clock bindings for Tegra2x
arch/arm/dts/tegra20.dtsi | 27 ++++++++++++
doc/device-tree-bindings/clock/tegra-periphclk | 51 ++++++++++++++++++++++++
2 files changed, 78 insertions(+), 0 deletions(-)
create mode 100644 doc/device-tree-bindings/clock/tegra-periphclk
diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index a9a98ea..ec75747 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -4,6 +4,33 @@
compatible = "nvidia,tegra20";
interrupt-parent = <&intc>;
+ clocks = <&osc_clk>;
+ clock-names = "osc_clk";
+ clock-ranges;
+
+ clocks {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* The frequency of this clock is board-specific */
+ osc_clk: oscclk {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ };
+
+ /*
+ * This node provides clocks to all peripherals. We don't
+ * enumerate the clock names for now since there are no
+ * users of this information.
+ */
+ periph_clk: periphclk {
+ compatible = "tegra,periphclk";
+ #clock-cells = <1>;
+ clocks = <&osc_clk>;
+ reg = <0x60006000 400>;
+ };
+ };
+
intc: interrupt-controller@50041000 {
compatible = "nvidia,tegra20-gic";
interrupt-controller;
diff --git a/doc/device-tree-bindings/clock/tegra-periphclk b/doc/device-tree-bindings/clock/tegra-periphclk
new file mode 100644
index 0000000..8d21e4d
--- /dev/null
+++ b/doc/device-tree-bindings/clock/tegra-periphclk
@@ -0,0 +1,51 @@
+Clock controllers
+
+(there isn't yet a binding in Linux, so this describes what is in U-Boot)
+
+The device node for a clock controller is as described in the document
+"Open Firmware Recommended Practice : Universal Serial Bus" with the
+following modifications and additions :
+
+This is based on Grant Likely's proposed patch for clock bindings.
+
+Required properties :
+ - compatible : Should be "tegra,periphclk" for peripheral clock controller
+ - clocks : Should contain a single phandle pointing to the oscillator clock
+
+Peripherals which refer to a clock should have a property called "clocks" with
+two cells: phandle of the peripheral clock and the clock ID number (which
+is the bit number in the peripheral clock controller enable register numbered
+from 0).
+
+Example:
+
+clocks {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* The frequency of this clock is board-specific */
+ osc_clk: oscclk {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ };
+
+ /*
+ * This node provides clocks to all peripherals. We don't
+ * enumerate the clock names for now since there are no
+ * users of this information.
+ */
+ periph_clk: periphclk {
+ compatible = "tegra,periphclk";
+ #clock-cells = <1>;
+ clocks = <&osc_clk>;
+ reg = <0x60006000 400>;
+ };
+};
+
+usb@c5004000 {
+ compatible = "nvidia,tegra20-ehci", "usb-ehci";
+ reg = <0xc5004000 0x4000>;
+ interrupts = < 53 >;
+ phy_type = "ulpi";
+ clocks = <&periph_clk 58>; // PERIPH_ID_USB2
+};
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 10/18] tegra: usb: fdt: Add additional device tree definitions for USB ports
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (8 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 09/18] tegra: fdt: Add clock bindings Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
[not found] ` <1327447272-30182-11-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2012-01-24 23:21 ` [PATCH v5 11/18] tegra: usb: fdt: Add USB definitions for Tegra2 Seaboard Simon Glass
` (2 subsequent siblings)
12 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Albert ARIBAUD, Remy Bohmer, Jerry Van Baren, Tom Warren,
Devicetree Discuss
This adds clock references to the USB part of the device tree for U-Boot.
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>
---
Changes in v5:
- Add dr_mode property to control host/device/otg mode
- Add nvidia,has-legacy-mode property per review comments
- Change device tree comment style from // to /* */
arch/arm/dts/tegra20.dtsi | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi
index ec75747..b2e3a40 100644
--- a/arch/arm/dts/tegra20.dtsi
+++ b/arch/arm/dts/tegra20.dtsi
@@ -176,6 +176,9 @@
reg = <0xc5000000 0x4000>;
interrupts = < 52 >;
phy_type = "utmi";
+ clocks = <&periph_clk 22>; /* PERIPH_ID_USBD */
+ dr_mode = "otg";
+ nvidia,has-legacy-mode;
};
usb@c5004000 {
@@ -183,6 +186,8 @@
reg = <0xc5004000 0x4000>;
interrupts = < 53 >;
phy_type = "ulpi";
+ clocks = <&periph_clk 58>; /* PERIPH_ID_USB2 */
+ dr_mode = "host";
};
usb@c5008000 {
@@ -190,6 +195,8 @@
reg = <0xc5008000 0x4000>;
interrupts = < 129 >;
phy_type = "utmi";
+ clocks = <&periph_clk 59>; /* PERIPH_ID_USB3 */
+ dr_mode = "otg";
};
};
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 11/18] tegra: usb: fdt: Add USB definitions for Tegra2 Seaboard
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (9 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 10/18] tegra: usb: fdt: Add additional device tree definitions for USB ports Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
2012-01-24 23:21 ` [PATCH v5 13/18] fdt: Add function to return peripheral/clock ID Simon Glass
2012-01-24 23:21 ` [PATCH v5 18/18] tegra: fdt: Enable FDT support for Seaboard Simon Glass
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 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:
- Remove 0x from fdt aliases
- Use "okay" instead of "ok" for fdt node status
Changes in v3:
- Disable USB2 which is not used on Seaboard
- Fix device tree indenting with tabs instead of spaces
- Remove "okay" from nodes since this is the default anyway
Changes in v5:
- Remove support-host-mode property
board/nvidia/dts/tegra2-seaboard.dts | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/board/nvidia/dts/tegra2-seaboard.dts b/board/nvidia/dts/tegra2-seaboard.dts
index dde5d03..f53690f 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 >;
@@ -33,4 +39,8 @@
usb@c5000000 {
nvidia,vbus-gpio = <&gpio 24 0>; /* PD0 */
};
+
+ usb@c5004000 {
+ status = "disabled";
+ };
};
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 13/18] fdt: Add function to return peripheral/clock ID
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (10 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 11/18] tegra: usb: fdt: Add USB definitions for Tegra2 Seaboard Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
2012-01-24 23:21 ` [PATCH v5 18/18] tegra: fdt: Enable FDT support for Seaboard Simon Glass
12 siblings, 0 replies; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 UTC (permalink / raw)
To: U-Boot Mailing List; +Cc: Devicetree Discuss, Tom Warren, Jerry Van Baren
A common requirement is to find the clock ID for a peripheral. This is the
second cell of the 'clocks' property (the first being the phandle itself).
Signed-off-by: Simon Glass <sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
---
Changes in v4:
- Add fdtdec function to return peripheral ID
include/fdtdec.h | 13 +++++++++++++
lib/fdtdec.c | 13 +++++++++++++
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 6c0a2d1..f3115a6 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -272,3 +272,16 @@ int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
* @return 0 if all ok or gpio was FDT_GPIO_NONE; -1 on error
*/
int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
+
+/**
+ * Decode a peripheral ID from a device tree node. This may be a temporary
+ * function depending on what happens with clocks in the Linux fdt.
+ *
+ * This works by looking up the peripheral's 'clocks' node and reading out
+ * the second cell, which is the clock number / peripheral ID.
+ *
+ * @param blob FDT blob to use
+ * @param node Node to look at
+ * @return
+ */
+int fdtdec_decode_periph_id(const void *blob, int node);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index c748cac..f999ed0 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -415,3 +415,16 @@ int fdtdec_setup_gpio(struct fdt_gpio_state *gpio)
return -1;
return 0;
}
+
+int fdtdec_decode_periph_id(const void *blob, int node)
+{
+ u32 cell[2];
+ int err;
+
+ err = fdtdec_get_int_array(blob, node, "clocks", cell,
+ ARRAY_SIZE(cell));
+ if (err)
+ return -1;
+
+ return cell[1];
+}
--
1.7.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH v5 18/18] tegra: fdt: Enable FDT support for Seaboard
[not found] ` <1327447272-30182-1-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
` (11 preceding siblings ...)
2012-01-24 23:21 ` [PATCH v5 13/18] fdt: Add function to return peripheral/clock ID Simon Glass
@ 2012-01-24 23:21 ` Simon Glass
[not found] ` <1327447272-30182-19-git-send-email-sjg-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
12 siblings, 1 reply; 19+ messages in thread
From: Simon Glass @ 2012-01-24 23:21 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.7.3
^ permalink raw reply related [flat|nested] 19+ messages in thread