]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
Merge branch 'master' of git://git.denx.de/u-boot-dm
authorTom Rini <trini@ti.com>
Sat, 21 Jun 2014 00:03:51 +0000 (20:03 -0400)
committerTom Rini <trini@ti.com>
Sat, 21 Jun 2014 00:03:51 +0000 (20:03 -0400)
38 files changed:
README
arch/arm/dts/include/dt-bindings [new symlink]
arch/arm/dts/tegra114.dtsi
arch/arm/dts/tegra124.dtsi
arch/arm/dts/tegra20.dtsi
arch/arm/dts/tegra30.dtsi
arch/arm/include/asm/io.h
arch/microblaze/dts/include/dt-bindings [new symlink]
arch/sandbox/dts/include/dt-bindings [new symlink]
arch/sandbox/include/asm/io.h
arch/x86/dts/include/dt-bindings [new symlink]
common/Makefile
common/cmd_iotrace.c [new file with mode: 0644]
common/iotrace.c [new file with mode: 0644]
doc/driver-model/README.txt
drivers/core/lists.c
drivers/core/root.c
drivers/core/uclass.c
drivers/demo/demo-shape.c
drivers/demo/demo-simple.c
drivers/gpio/gpio-uclass.c
drivers/gpio/sandbox.c
include/configs/sandbox.h
include/configs/tegra-common.h
include/dm/device-internal.h
include/dm/device.h
include/dm/lists.h
include/dm/root.h
include/dm/uclass.h
include/dt-bindings/gpio/gpio.h [new file with mode: 0644]
include/dt-bindings/gpio/tegra-gpio.h [new file with mode: 0644]
include/dt-bindings/interrupt-controller/arm-gic.h [new file with mode: 0644]
include/dt-bindings/interrupt-controller/irq.h [new file with mode: 0644]
include/iotrace.h [new file with mode: 0644]
scripts/Makefile.lib
test/dm/Makefile
test/dm/cmd_dm.c
test/dm/test-fdt.c

diff --git a/README b/README
index 7129df822c17c9c9bc5c7089ec54b0fed6381d01..fe5cacbaa55a86450838b0cc129b538732a8daea 100644 (file)
--- a/README
+++ b/README
@@ -1000,6 +1000,7 @@ The following options need to be configured:
                CONFIG_CMD_IMLS           List all images found in NOR flash
                CONFIG_CMD_IMLS_NAND    * List all images found in NAND flash
                CONFIG_CMD_IMMAP        * IMMR dump support
+               CONFIG_CMD_IOTRACE      * I/O tracing for debugging
                CONFIG_CMD_IMPORTENV    * import an environment
                CONFIG_CMD_INI          * import data from an ini file into the env
                CONFIG_CMD_IRQ          * irqinfo
@@ -1171,6 +1172,28 @@ The following options need to be configured:
                Note that if the GPIO device uses I2C, then the I2C interface
                must also be configured. See I2C Support, below.
 
+- I/O tracing:
+               When CONFIG_IO_TRACE is selected, U-Boot intercepts all I/O
+               accesses and can checksum them or write a list of them out
+               to memory. See the 'iotrace' command for details. This is
+               useful for testing device drivers since it can confirm that
+               the driver behaves the same way before and after a code
+               change. Currently this is supported on sandbox and arm. To
+               add support for your architecture, add '#include <iotrace.h>'
+               to the bottom of arch/<arch>/include/asm/io.h and test.
+
+               Example output from the 'iotrace stats' command is below.
+               Note that if the trace buffer is exhausted, the checksum will
+               still continue to operate.
+
+                       iotrace is enabled
+                       Start:  10000000        (buffer start address)
+                       Size:   00010000        (buffer size)
+                       Offset: 00000120        (current buffer offset)
+                       Output: 10000120        (start + offset)
+                       Count:  00000018        (number of trace records)
+                       CRC32:  9526fb66        (CRC32 of all trace records)
+
 - Timestamp Support:
 
                When CONFIG_TIMESTAMP is selected, the timestamp
@@ -5308,6 +5331,11 @@ Information structure as we define in include/asm-<arch>/u-boot.h,
 and make sure that your definition of IMAP_ADDR uses the same value
 as your U-Boot configuration in CONFIG_SYS_IMMR.
 
+Note that U-Boot now has a driver model, a unified model for drivers.
+If you are adding a new driver, plumb it into driver model. If there
+is no uclass available, you are encouraged to create one. See
+doc/driver-model.
+
 
 Configuring the Linux kernel:
 -----------------------------
diff --git a/arch/arm/dts/include/dt-bindings b/arch/arm/dts/include/dt-bindings
new file mode 120000 (symlink)
index 0000000..0cecb3d
--- /dev/null
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
index f52fcf14dddc2f0f712a2624f2617af27b1c1314..59434e0a8f76dd540f506a235da06b2b24c55206 100644 (file)
@@ -1,3 +1,6 @@
+#include <dt-bindings/gpio/tegra-gpio.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
 #include "skeleton.dtsi"
 
 / {
                              0 143 0x04>;
        };
 
-       gpio: gpio {
+       gpio: gpio@6000d000 {
                compatible = "nvidia,tegra114-gpio", "nvidia,tegra30-gpio";
                reg = <0x6000d000 0x1000>;
-               interrupts = <0 32 0x04
-                             0 33 0x04
-                             0 34 0x04
-                             0 35 0x04
-                             0 55 0x04
-                             0 87 0x04
-                             0 89 0x04
-                             0 125 0x04>;
+               interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                #interrupt-cells = <2>;
index 18a8b24b71f788c130f6007d4410cecad64cbcb0..4561c5f839438c4bdf4e181e38fbde57ff9e780f 100644 (file)
@@ -1,3 +1,6 @@
+#include <dt-bindings/gpio/tegra-gpio.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
 #include "skeleton.dtsi"
 
 / {
        gpio: gpio@6000d000 {
                compatible = "nvidia,tegra124-gpio", "nvidia,tegra30-gpio";
                reg = <0x6000d000 0x1000>;
-               interrupts = <0 32 0x04
-                             0 33 0x04
-                             0 34 0x04
-                             0 35 0x04
-                             0 55 0x04
-                             0 87 0x04
-                             0 89 0x04
-                             0 125 0x04>;
+               interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                #interrupt-cells = <2>;
index 3805750581f42fc0788545137d38ce056f4ed6bd..a524f6eed4107b669ecc935b247f6b2393bd2629 100644 (file)
@@ -1,3 +1,6 @@
+#include <dt-bindings/gpio/tegra-gpio.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
 #include "skeleton.dtsi"
 
 / {
 
        gpio: gpio@6000d000 {
                compatible = "nvidia,tegra20-gpio";
-               reg = < 0x6000d000 0x1000 >;
-               interrupts = < 64 65 66 67 87 119 121 >;
+               reg = <0x6000d000 0x1000>;
+               interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
+               #interrupt-cells = <2>;
+               interrupt-controller;
        };
 
        pinmux: pinmux@70000000 {
index fee1c36efb2a510c6027412576424401bf3d684e..7be3791fc9a679536a1d63b1aac3fbb81c03eb31 100644 (file)
@@ -1,3 +1,6 @@
+#include <dt-bindings/gpio/tegra-gpio.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
 #include "skeleton.dtsi"
 
 / {
                clocks = <&tegra_car 34>;
        };
 
-       gpio: gpio {
+       gpio: gpio@6000d000 {
                compatible = "nvidia,tegra30-gpio";
                reg = <0x6000d000 0x1000>;
-               interrupts = <0 32 0x04
-                             0 33 0x04
-                             0 34 0x04
-                             0 35 0x04
-                             0 55 0x04
-                             0 87 0x04
-                             0 89 0x04
-                             0 125 0x04>;
+               interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
                #gpio-cells = <2>;
                gpio-controller;
                #interrupt-cells = <2>;
index 6a1f05ac3efd5326723a94440fc21feee285034c..9f35fd694b35124d9d2db94aea84df36b9c3727d 100644 (file)
@@ -437,4 +437,7 @@ out:
 
 #endif /* __mem_isa */
 #endif /* __KERNEL__ */
+
+#include <iotrace.h>
+
 #endif /* __ASM_ARM_IO_H */
diff --git a/arch/microblaze/dts/include/dt-bindings b/arch/microblaze/dts/include/dt-bindings
new file mode 120000 (symlink)
index 0000000..0cecb3d
--- /dev/null
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
diff --git a/arch/sandbox/dts/include/dt-bindings b/arch/sandbox/dts/include/dt-bindings
new file mode 120000 (symlink)
index 0000000..0cecb3d
--- /dev/null
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
index 7956041171f52beaaeb5b263da17926414d5dcdd..895fcb872f6a375876fdd05c5fe73714871fbc00 100644 (file)
@@ -40,4 +40,14 @@ static inline void unmap_sysmem(const void *vaddr)
 /* Map from a pointer to our RAM buffer */
 phys_addr_t map_to_sysmem(const void *ptr);
 
+/* Define nops for sandbox I/O access */
+#define readb(addr) 0
+#define readw(addr) 0
+#define readl(addr) 0
+#define writeb(v, addr)
+#define writew(v, addr)
+#define writel(v, addr)
+
+#include <iotrace.h>
+
 #endif
diff --git a/arch/x86/dts/include/dt-bindings b/arch/x86/dts/include/dt-bindings
new file mode 120000 (symlink)
index 0000000..0cecb3d
--- /dev/null
@@ -0,0 +1 @@
+../../../../include/dt-bindings
\ No newline at end of file
index f6cd98012a18a3e50c59a68fb8515b1ea5359589..de5cce86cc6990c99a3f2f5d5d59084343f5fb01 100644 (file)
@@ -114,6 +114,7 @@ obj-$(CONFIG_CMD_FUSE) += cmd_fuse.o
 obj-$(CONFIG_CMD_GETTIME) += cmd_gettime.o
 obj-$(CONFIG_CMD_GPIO) += cmd_gpio.o
 obj-$(CONFIG_CMD_I2C) += cmd_i2c.o
+obj-$(CONFIG_CMD_IOTRACE) += cmd_iotrace.o
 obj-$(CONFIG_CMD_HASH) += cmd_hash.o
 obj-$(CONFIG_CMD_IDE) += cmd_ide.o
 obj-$(CONFIG_CMD_IMMAP) += cmd_immap.o
@@ -261,6 +262,7 @@ obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
 obj-$(CONFIG_OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_FIT) += image-fit.o
 obj-$(CONFIG_FIT_SIGNATURE) += image-sig.o
+obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
 obj-y += stdio.o
 
diff --git a/common/cmd_iotrace.c b/common/cmd_iotrace.c
new file mode 100644 (file)
index 0000000..f54276d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <iotrace.h>
+
+static void do_print_stats(void)
+{
+       ulong start, size, offset, count;
+
+       printf("iotrace is %sabled\n", iotrace_get_enabled() ? "en" : "dis");
+       iotrace_get_buffer(&start, &size, &offset, &count);
+       printf("Start:  %08lx\n", start);
+       printf("Size:   %08lx\n", size);
+       printf("Offset: %08lx\n", offset);
+       printf("Output: %08lx\n", start + offset);
+       printf("Count:  %08lx\n", count);
+       printf("CRC32:  %08lx\n", (ulong)iotrace_get_checksum());
+}
+
+static int do_set_buffer(int argc, char * const argv[])
+{
+       ulong addr = 0, size = 0;
+
+       if (argc == 2) {
+               addr = simple_strtoul(*argv++, NULL, 16);
+               size = simple_strtoul(*argv++, NULL, 16);
+       } else if (argc != 0) {
+               return CMD_RET_USAGE;
+       }
+
+       iotrace_set_buffer(addr, size);
+
+       return 0;
+}
+
+int do_iotrace(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       const char *cmd = argc < 2 ? NULL : argv[1];
+
+       if (!cmd)
+               return cmd_usage(cmdtp);
+       switch (*cmd) {
+       case 'b':
+               return do_set_buffer(argc - 2, argv + 2);
+       case 'p':
+               iotrace_set_enabled(0);
+               break;
+       case 'r':
+               iotrace_set_enabled(1);
+               break;
+       case 's':
+               do_print_stats();
+               break;
+       default:
+               return CMD_RET_USAGE;
+       }
+
+       return 0;
+}
+
+U_BOOT_CMD(
+       iotrace,        4,      1,      do_iotrace,
+       "iotrace utility commands",
+       "stats                        - display iotrace stats\n"
+       "iotrace buffer <address> <size>      - set iotrace buffer\n"
+       "iotrace pause                        - pause tracing\n"
+       "iotrace resume                       - resume tracing"
+);
diff --git a/common/iotrace.c b/common/iotrace.c
new file mode 100644 (file)
index 0000000..ced426e
--- /dev/null
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2014 Google, Inc.
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#define IOTRACE_IMPL
+
+#include <common.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Support up to the machine word length for now */
+typedef ulong iovalue_t;
+
+enum iotrace_flags {
+       IOT_8 = 0,
+       IOT_16,
+       IOT_32,
+
+       IOT_READ = 0 << 3,
+       IOT_WRITE = 1 << 3,
+};
+
+/**
+ * struct iotrace_record - Holds a single I/O trace record
+ *
+ * @flags: I/O access type
+ * @addr: Address of access
+ * @value: Value written or read
+ */
+struct iotrace_record {
+       enum iotrace_flags flags;
+       phys_addr_t addr;
+       iovalue_t value;
+};
+
+/**
+ * struct iotrace - current trace status and checksum
+ *
+ * @start:     Start address of iotrace buffer
+ * @size:      Size of iotrace buffer in bytes
+ * @offset:    Current write offset into iotrace buffer
+ * @crc32:     Current value of CRC chceksum of trace records
+ * @enabled:   true if enabled, false if disabled
+ */
+static struct iotrace {
+       ulong start;
+       ulong size;
+       ulong offset;
+       u32 crc32;
+       bool enabled;
+} iotrace;
+
+static void add_record(int flags, const void *ptr, ulong value)
+{
+       struct iotrace_record srec, *rec = &srec;
+
+       /*
+        * We don't support iotrace before relocation. Since the trace buffer
+        * is set up by a command, it can't be enabled at present. To change
+        * this we would need to set the iotrace buffer at build-time. See
+        * lib/trace.c for how this might be done if you are interested.
+        */
+       if (!(gd->flags & GD_FLG_RELOC) || !iotrace.enabled)
+               return;
+
+       /* Store it if there is room */
+       if (iotrace.offset + sizeof(*rec) < iotrace.size) {
+               rec = (struct iotrace_record *)map_sysmem(
+                                       iotrace.start + iotrace.offset,
+                                       sizeof(value));
+       }
+
+       rec->flags = flags;
+       rec->addr = map_to_sysmem(ptr);
+       rec->value = value;
+
+       /* Update our checksum */
+       iotrace.crc32 = crc32(iotrace.crc32, (unsigned char *)rec,
+                             sizeof(*rec));
+
+       iotrace.offset += sizeof(struct iotrace_record);
+}
+
+u32 iotrace_readl(const void *ptr)
+{
+       u32 v;
+
+       v = readl(ptr);
+       add_record(IOT_32 | IOT_READ, ptr, v);
+
+       return v;
+}
+
+void iotrace_writel(ulong value, const void *ptr)
+{
+       add_record(IOT_32 | IOT_WRITE, ptr, value);
+       writel(value, ptr);
+}
+
+u16 iotrace_readw(const void *ptr)
+{
+       u32 v;
+
+       v = readw(ptr);
+       add_record(IOT_16 | IOT_READ, ptr, v);
+
+       return v;
+}
+
+void iotrace_writew(ulong value, const void *ptr)
+{
+       add_record(IOT_16 | IOT_WRITE, ptr, value);
+       writew(value, ptr);
+}
+
+u8 iotrace_readb(const void *ptr)
+{
+       u32 v;
+
+       v = readb(ptr);
+       add_record(IOT_8 | IOT_READ, ptr, v);
+
+       return v;
+}
+
+void iotrace_writeb(ulong value, const void *ptr)
+{
+       add_record(IOT_8 | IOT_WRITE, ptr, value);
+       writeb(value, ptr);
+}
+
+void iotrace_reset_checksum(void)
+{
+       iotrace.crc32 = 0;
+}
+
+u32 iotrace_get_checksum(void)
+{
+       return iotrace.crc32;
+}
+
+void iotrace_set_enabled(int enable)
+{
+       iotrace.enabled = enable;
+}
+
+int iotrace_get_enabled(void)
+{
+       return iotrace.enabled;
+}
+
+void iotrace_set_buffer(ulong start, ulong size)
+{
+       iotrace.start = start;
+       iotrace.size = size;
+       iotrace.offset = 0;
+       iotrace.crc32 = 0;
+}
+
+void iotrace_get_buffer(ulong *start, ulong *size, ulong *offset, ulong *count)
+{
+       *start = iotrace.start;
+       *size = iotrace.size;
+       *offset = iotrace.offset;
+       *count = iotrace.offset / sizeof(struct iotrace_record);
+}
index a5035beca6e36c0270b2b6efe9bde9bff591ed49..22c3fcb6eff81aedb062d197e97f5ab089eb3f50 100644 (file)
@@ -222,7 +222,44 @@ device tree) and probe.
 Platform Data
 -------------
 
-Where does the platform data come from? See demo-pdata.c which
+Platform data is like Linux platform data, if you are familiar with that.
+It provides the board-specific information to start up a device.
+
+Why is this information not just stored in the device driver itself? The
+idea is that the device driver is generic, and can in principle operate on
+any board that has that type of device. For example, with modern
+highly-complex SoCs it is common for the IP to come from an IP vendor, and
+therefore (for example) the MMC controller may be the same on chips from
+different vendors. It makes no sense to write independent drivers for the
+MMC controller on each vendor's SoC, when they are all almost the same.
+Similarly, we may have 6 UARTs in an SoC, all of which are mostly the same,
+but lie at different addresses in the address space.
+
+Using the UART example, we have a single driver and it is instantiated 6
+times by supplying 6 lots of platform data. Each lot of platform data
+gives the driver name and a pointer to a structure containing information
+about this instance - e.g. the address of the register space. It may be that
+one of the UARTS supports RS-485 operation - this can be added as a flag in
+the platform data, which is set for this one port and clear for the rest.
+
+Think of your driver as a generic piece of code which knows how to talk to
+a device, but needs to know where it is, any variant/option information and
+so on. Platform data provides this link between the generic piece of code
+and the specific way it is bound on a particular board.
+
+Examples of platform data include:
+
+   - The base address of the IP block's register space
+   - Configuration options, like:
+         - the SPI polarity and maximum speed for a SPI controller
+         - the I2C speed to use for an I2C device
+         - the number of GPIOs available in a GPIO device
+
+Where does the platform data come from? It is either held in a structure
+which is compiled into U-Boot, or it can be parsed from the Device Tree
+(see 'Device Tree' below).
+
+For an example of how it can be compiled in, see demo-pdata.c which
 sets up a table of driver names and their associated platform data.
 The data can be interpreted by the drivers however they like - it is
 basically a communication scheme between the board-specific code and
@@ -259,21 +296,30 @@ following device tree fragment:
                sides = <4>;
        };
 
+This means that instead of having lots of U_BOOT_DEVICE() declarations in
+the board file, we put these in the device tree. This approach allows a lot
+more generality, since the same board file can support many types of boards
+(e,g. with the same SoC) just by using different device trees. An added
+benefit is that the Linux device tree can be used, thus further simplifying
+the task of board-bring up either for U-Boot or Linux devs (whoever gets to
+the board first!).
 
 The easiest way to make this work it to add a few members to the driver:
 
        .platdata_auto_alloc_size = sizeof(struct dm_test_pdata),
        .ofdata_to_platdata = testfdt_ofdata_to_platdata,
-       .probe  = testfdt_drv_probe,
 
 The 'auto_alloc' feature allowed space for the platdata to be allocated
-and zeroed before the driver's ofdata_to_platdata method is called. This
-method reads the information out of the device tree and puts it in
-dev->platdata. Then the probe method is called to set up the device.
+and zeroed before the driver's ofdata_to_platdata() method is called. The
+ofdata_to_platdata() method, which the driver write supplies, should parse
+the device tree node for this device and place it in dev->platdata. Thus
+when the probe method is called later (to set up the device ready for use)
+the platform data will be present.
 
 Note that both methods are optional. If you provide an ofdata_to_platdata
-method then it will be called first (after bind). If you provide a probe
-method it will be called next.
+method then it will be called first (during activation). If you provide a
+probe method it will be called next. See Driver Lifecycle below for more
+details.
 
 If you don't want to have the platdata automatically allocated then you
 can leave out platdata_auto_alloc_size. In this case you can use malloc
@@ -295,6 +341,166 @@ numbering comes from include/dm/uclass.h. To add a new uclass, add to the
 end of the enum there, then declare your uclass as above.
 
 
+Driver Lifecycle
+----------------
+
+Here are the stages that a device goes through in driver model. Note that all
+methods mentioned here are optional - e.g. if there is no probe() method for
+a device then it will not be called. A simple device may have very few
+methods actually defined.
+
+1. Bind stage
+
+A device and its driver are bound using one of these two methods:
+
+   - Scan the U_BOOT_DEVICE() definitions. U-Boot It looks up the
+name specified by each, to find the appropriate driver. It then calls
+device_bind() to create a new device and bind' it to its driver. This will
+call the device's bind() method.
+
+   - Scan through the device tree definitions. U-Boot looks at top-level
+nodes in the the device tree. It looks at the compatible string in each node
+and uses the of_match part of the U_BOOT_DRIVER() structure to find the
+right driver for each node. It then calls device_bind() to bind the
+newly-created device to its driver (thereby creating a device structure).
+This will also call the device's bind() method.
+
+At this point all the devices are known, and bound to their drivers. There
+is a 'struct udevice' allocated for all devices. However, nothing has been
+activated (except for the root device). Each bound device that was created
+from a U_BOOT_DEVICE() declaration will hold the platdata pointer specified
+in that declaration. For a bound device created from the device tree,
+platdata will be NULL, but of_offset will be the offset of the device tree
+node that caused the device to be created. The uclass is set correctly for
+the device.
+
+The device's bind() method is permitted to perform simple actions, but
+should not scan the device tree node, not initialise hardware, nor set up
+structures or allocate memory. All of these tasks should be left for
+the probe() method.
+
+Note that compared to Linux, U-Boot's driver model has a separate step of
+probe/remove which is independent of bind/unbind. This is partly because in
+U-Boot it may be expensive to probe devices and we don't want to do it until
+they are needed, or perhaps until after relocation.
+
+2. Activation/probe
+
+When a device needs to be used, U-Boot activates it, by following these
+steps (see device_probe()):
+
+   a. If priv_auto_alloc_size is non-zero, then the device-private space
+   is allocated for the device and zeroed. It will be accessible as
+   dev->priv. The driver can put anything it likes in there, but should use
+   it for run-time information, not platform data (which should be static
+   and known before the device is probed).
+
+   b. If platdata_auto_alloc_size is non-zero, then the platform data space
+   is allocated. This is only useful for device tree operation, since
+   otherwise you would have to specific the platform data in the
+   U_BOOT_DEVICE() declaration. The space is allocated for the device and
+   zeroed. It will be accessible as dev->platdata.
+
+   c. If the device's uclass specifies a non-zero per_device_auto_alloc_size,
+   then this space is allocated and zeroed also. It is allocated for and
+   stored in the device, but it is uclass data. owned by the uclass driver.
+   It is possible for the device to access it.
+
+   d. All parent devices are probed. It is not possible to activate a device
+   unless its predecessors (all the way up to the root device) are activated.
+   This means (for example) that an I2C driver will require that its bus
+   be activated.
+
+   e. If the driver provides an ofdata_to_platdata() method, then this is
+   called to convert the device tree data into platform data. This should
+   do various calls like fdtdec_get_int(gd->fdt_blob, dev->of_offset, ...)
+   to access the node and store the resulting information into dev->platdata.
+   After this point, the device works the same way whether it was bound
+   using a device tree node or U_BOOT_DEVICE() structure. In either case,
+   the platform data is now stored in the platdata structure. Typically you
+   will use the platdata_auto_alloc_size feature to specify the size of the
+   platform data structure, and U-Boot will automatically allocate and zero
+   it for you before entry to ofdata_to_platdata(). But if not, you can
+   allocate it yourself in ofdata_to_platdata(). Note that it is preferable
+   to do all the device tree decoding in ofdata_to_platdata() rather than
+   in probe(). (Apart from the ugliness of mixing configuration and run-time
+   data, one day it is possible that U-Boot will cache platformat data for
+   devices which are regularly de/activated).
+
+   f. The device's probe() method is called. This should do anything that
+   is required by the device to get it going. This could include checking
+   that the hardware is actually present, setting up clocks for the
+   hardware and setting up hardware registers to initial values. The code
+   in probe() can access:
+
+      - platform data in dev->platdata (for configuration)
+      - private data in dev->priv (for run-time state)
+      - uclass data in dev->uclass_priv (for things the uclass stores
+        about this device)
+
+   Note: If you don't use priv_auto_alloc_size then you will need to
+   allocate the priv space here yourself. The same applies also to
+   platdata_auto_alloc_size. Remember to free them in the remove() method.
+
+   g. The device is marked 'activated'
+
+   h. The uclass's post_probe() method is called, if one exists. This may
+   cause the uclass to do some housekeeping to record the device as
+   activated and 'known' by the uclass.
+
+3. Running stage
+
+The device is now activated and can be used. From now until it is removed
+all of the above structures are accessible. The device appears in the
+uclass's list of devices (so if the device is in UCLASS_GPIO it will appear
+as a device in the GPIO uclass). This is the 'running' state of the device.
+
+4. Removal stage
+
+When the device is no-longer required, you can call device_remove() to
+remove it. This performs the probe steps in reverse:
+
+   a. The uclass's pre_remove() method is called, if one exists. This may
+   cause the uclass to do some housekeeping to record the device as
+   deactivated and no-longer 'known' by the uclass.
+
+   b. All the device's children are removed. It is not permitted to have
+   an active child device with a non-active parent. This means that
+   device_remove() is called for all the children recursively at this point.
+
+   c. The device's remove() method is called. At this stage nothing has been
+   deallocated so platform data, private data and the uclass data will all
+   still be present. This is where the hardware can be shut down. It is
+   intended that the device be completely inactive at this point, For U-Boot
+   to be sure that no hardware is running, it should be enough to remove
+   all devices.
+
+   d. The device memory is freed (platform data, private data, uclass data).
+
+   Note: Because the platform data for a U_BOOT_DEVICE() is defined with a
+   static pointer, it is not de-allocated during the remove() method. For
+   a device instantiated using the device tree data, the platform data will
+   be dynamically allocated, and thus needs to be deallocated during the
+   remove() method, either:
+
+      1. if the platdata_auto_alloc_size is non-zero, the deallocation
+      happens automatically within the driver model core; or
+
+      2. when platdata_auto_alloc_size is 0, both the allocation (in probe()
+      or preferably ofdata_to_platdata()) and the deallocation in remove()
+      are the responsibility of the driver author.
+
+   e. The device is marked inactive. Note that it is still bound, so the
+   device structure itself is not freed at this point. Should the device be
+   activated again, then the cycle starts again at step 2 above.
+
+5. Unbind stage
+
+The device is unbound. This is the step that actually destroys the device.
+If a parent has children these will be destroyed first. After this point
+the device does not exist and its memory has be deallocated.
+
+
 Data Structures
 ---------------
 
@@ -315,7 +521,7 @@ is little or no 'driver model' code to write.
 - Moved some data from code into data structure - e.g. store a pointer to
 the driver operations structure in the driver, rather than passing it
 to the driver bind function.
-- Rename some structures to make them more similar to Linux (struct device
+- Rename some structures to make them more similar to Linux (struct udevice
 instead of struct instance, struct platdata, etc.)
 - Change the name 'core' to 'uclass', meaning U-Boot class. It seems that
 this concept relates to a class of drivers (or a subsystem). We shouldn't
index 205b140ef3d7c9d367df75f94ad62c1510454197..afb59d1d8dd277f62601c225679064f341dbdfa5 100644 (file)
@@ -14,6 +14,7 @@
 #include <dm/platdata.h>
 #include <dm/uclass.h>
 #include <dm/util.h>
+#include <fdtdec.h>
 #include <linux/compiler.h>
 
 struct driver *lists_driver_lookup_name(const char *name)
@@ -94,7 +95,7 @@ int lists_bind_drivers(struct udevice *parent)
  * tree error
  */
 static int driver_check_compatible(const void *blob, int offset,
-                                  const struct device_id *of_match)
+                                  const struct udevice_id *of_match)
 {
        int ret;
 
index 4977875c7f947f60178b60a824a2a109147acbc6..1cbb096494d2638a57c1a9d7998cda9685054896 100644 (file)
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <errno.h>
 #include <malloc.h>
+#include <libfdt.h>
 #include <dm/device.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
@@ -42,9 +43,9 @@ int dm_init(void)
                dm_warn("Virtual root driver already exists!\n");
                return -EINVAL;
        }
-       INIT_LIST_HEAD(&gd->uclass_root);
+       INIT_LIST_HEAD(&DM_UCLASS_ROOT_NON_CONST);
 
-       ret = device_bind_by_name(NULL, &root_info, &gd->dm_root);
+       ret = device_bind_by_name(NULL, &root_info, &DM_ROOT_NON_CONST);
        if (ret)
                return ret;
 
@@ -55,7 +56,7 @@ int dm_scan_platdata(void)
 {
        int ret;
 
-       ret = lists_bind_drivers(gd->dm_root);
+       ret = lists_bind_drivers(DM_ROOT_NON_CONST);
        if (ret == -ENOENT) {
                dm_warn("Some drivers were not found\n");
                ret = 0;
index f6867e4a23226cf5b7aa631f431da314f256dfc8..34723ec42a75fccca2df41a95c3b5a37ae0ec9d6 100644 (file)
@@ -75,7 +75,7 @@ static int uclass_add(enum uclass_id id, struct uclass **ucp)
        uc->uc_drv = uc_drv;
        INIT_LIST_HEAD(&uc->sibling_node);
        INIT_LIST_HEAD(&uc->dev_head);
-       list_add(&uc->sibling_node, &gd->uclass_root);
+       list_add(&uc->sibling_node, &DM_UCLASS_ROOT_NON_CONST);
 
        if (uc_drv->init) {
                ret = uc_drv->init(uc);
index a68cc1092cf4720e7c6dce8b3ee7775b96b511c1..3fa9c5994703d473494a4d2199ecae3e34a0c9c0 100644 (file)
@@ -111,7 +111,7 @@ static int shape_ofdata_to_platdata(struct udevice *dev)
        return 0;
 }
 
-static const struct device_id demo_shape_id[] = {
+static const struct udevice_id demo_shape_id[] = {
        { "demo-shape", 0 },
        { },
 };
index 11def86032c6b0a319dae3d4add27d061a546bce..2bcb7dfb479c4c123b3e2b875e4df4c680906290 100644 (file)
@@ -32,7 +32,7 @@ static int demo_shape_ofdata_to_platdata(struct udevice *dev)
        return demo_parse_dt(dev);
 }
 
-static const struct device_id demo_shape_id[] = {
+static const struct udevice_id demo_shape_id[] = {
        { "demo-simple", 0 },
        { },
 };
index fa2c2fb7c47c391ca5c505dafd98946f5098171e..f1bbc587961709dec3922c52c76585227acecd9b 100644 (file)
@@ -58,7 +58,7 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
                uc_priv = dev->uclass_priv;
                len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
 
-               if (!strncmp(name, uc_priv->bank_name, len)) {
+               if (!strncasecmp(name, uc_priv->bank_name, len)) {
                        if (strict_strtoul(name + len, 10, &offset))
                                continue;
                        if (devp)
index 09cebe2286f434317f8072092a0274ac410aefbf..75ada5d3871a844935c22b1bb9557f2e3229c84f 100644 (file)
@@ -239,7 +239,7 @@ static int gpio_sandbox_probe(struct udevice *dev)
        return 0;
 }
 
-static const struct device_id sandbox_gpio_ids[] = {
+static const struct udevice_id sandbox_gpio_ids[] = {
        { .compatible = "sandbox,gpio" },
        { }
 };
index a14509404253fd78b0d47131e4d6888953d54dc7..12b69d9a249f08d4991189c2a28cb2bd02eb8ee6 100644 (file)
@@ -16,6 +16,9 @@
 
 #endif
 
+#define CONFIG_IO_TRACE
+#define CONFIG_CMD_IOTRACE
+
 #define CONFIG_SYS_TIMER_RATE          1000000
 
 #define CONFIG_BOOTSTAGE
index 129acf2cbf81551c35608ffbba17b0f1228e7dbb..3b88a83c04f3763a446b071b89926992f1b029a6 100644 (file)
@@ -19,6 +19,9 @@
 
 #include <asm/arch/tegra.h>            /* get chip and board defs */
 
+#define CONFIG_DM
+#define CONFIG_CMD_DM
+
 #define CONFIG_SYS_TIMER_RATE          1000000
 #define CONFIG_SYS_TIMER_COUNTER       NV_PA_TMRUS_BASE
 
index ea3df36632d80fc907412e4d5c71771006206d53..26e5cf530ebc8b6bb81ec34c72abc0a4ecd268f2 100644 (file)
@@ -84,4 +84,8 @@ int device_remove(struct udevice *dev);
  */
 int device_unbind(struct udevice *dev);
 
+/* Cast away any volatile pointer */
+#define DM_ROOT_NON_CONST              (((gd_t *)gd)->dm_root)
+#define DM_UCLASS_ROOT_NON_CONST       (((gd_t *)gd)->uclass_root)
+
 #endif
index ec049824e8cf485a07d5619963e6fafe56c345c6..ae75a3f54db53c927fb81159b42f7870c81b64f7 100644 (file)
@@ -21,7 +21,7 @@ struct driver_info;
 #define DM_FLAG_ACTIVATED      (1 << 0)
 
 /* DM is responsible for allocating and freeing platdata */
-#define DM_FLAG_ALLOC_PDATA    (2 << 0)
+#define DM_FLAG_ALLOC_PDATA    (1 << 1)
 
 /**
  * struct udevice - An instance of a driver
@@ -75,11 +75,11 @@ struct udevice {
 #define device_active(dev)     ((dev)->flags & DM_FLAG_ACTIVATED)
 
 /**
- * struct device_id - Lists the compatible strings supported by a driver
+ * struct udevice_id - Lists the compatible strings supported by a driver
  * @compatible: Compatible string
  * @data: Data for this compatible string
  */
-struct device_id {
+struct udevice_id {
        const char *compatible;
        ulong data;
 };
@@ -121,7 +121,7 @@ struct device_id {
 struct driver {
        char *name;
        enum uclass_id id;
-       const struct device_id *of_match;
+       const struct udevice_id *of_match;
        int (*bind)(struct udevice *dev);
        int (*probe)(struct udevice *dev);
        int (*remove)(struct udevice *dev);
index 7feba4b00ff98df67a7affe486a567c60cb12f0e..49d87e617687465d289b88e9a002f0ac4ea14223 100644 (file)
@@ -32,8 +32,28 @@ struct driver *lists_driver_lookup_name(const char *name);
  */
 struct uclass_driver *lists_uclass_lookup(enum uclass_id id);
 
+/**
+ * lists_bind_drivers() - search for and bind all drivers to parent
+ *
+ * This searches the U_BOOT_DEVICE() structures and creates new devices for
+ * each one. The devices will have @parent as their parent.
+ *
+ * @parent: parent driver (root)
+ * @early_only: If true, bind only drivers with the DM_INIT_F flag. If false
+ * bind all drivers.
+ */
 int lists_bind_drivers(struct udevice *parent);
 
+/**
+ * lists_bind_fdt() - bind a device tree node
+ *
+ * This creates a new device bound to the given device tree node, with
+ * @parent as its parent.
+ *
+ * @parent: parent driver (root)
+ * @blob: device tree blob
+ * @offset: offset of this device tree node
+ */
 int lists_bind_fdt(struct udevice *parent, const void *blob, int offset);
 
 #endif
index 3018bc8627a54c132eed61f799c1ac0c594bfe6f..a4826a6e3cc485abeb619604c13ac4767abe6184 100644 (file)
@@ -41,7 +41,7 @@ int dm_scan_platdata(void);
 int dm_scan_fdt(const void *blob);
 
 /**
- * dm_init() - Initialize Driver Model structures
+ * dm_init() - Initialise Driver Model structures
  *
  * This function will initialize roots of driver tree and class tree.
  * This needs to be called before anything uses the DM
index 931d9c0b9a1f78cf099939abb2224ce7ba242c04..afd9923fb382fc8c6e6ee55bcde331ca8f5615a4 100644 (file)
@@ -26,7 +26,7 @@
  * @priv: Private data for this uclass
  * @uc_drv: The driver for the uclass itself, not to be confused with a
  * 'struct driver'
- * dev_head: List of devices in this uclass (devices are attached to their
+ * @dev_head: List of devices in this uclass (devices are attached to their
  * uclass when their bind method is called)
  * @sibling_node: Next uclass in the linked list of uclasses
  */
@@ -96,12 +96,14 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);
 /**
  * uclass_get_device() - Get a uclass device based on an ID and index
  *
+ * The device is probed to activate it ready for use.
+ *
  * id: ID to look up
  * @index: Device number within that uclass (0=first)
- * @ucp: Returns pointer to uclass (there is only one per for each ID)
+ * @devp: Returns pointer to device (there is only one per for each ID)
  * @return 0 if OK, -ve on error
  */
-int uclass_get_device(enum uclass_id id, int index, struct udevice **ucp);
+int uclass_get_device(enum uclass_id id, int index, struct udevice **devp);
 
 /**
  * uclass_first_device() - Get the first device in a uclass
@@ -129,7 +131,7 @@ int uclass_next_device(struct udevice **devp);
  *
  * @pos: struct udevice * to hold the current device. Set to NULL when there
  * are no more devices.
- * uc: uclass to scan
+ * @uc: uclass to scan
  */
 #define uclass_foreach_dev(pos, uc)                                    \
        for (pos = list_entry((&(uc)->dev_head)->next, typeof(*pos),    \
diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h
new file mode 100644 (file)
index 0000000..e6b1e0a
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * This header provides constants for most GPIO bindings.
+ *
+ * Most GPIO bindings include a flags cell as part of the GPIO specifier.
+ * In most cases, the format of the flags cell uses the standard values
+ * defined in this header.
+ */
+
+#ifndef _DT_BINDINGS_GPIO_GPIO_H
+#define _DT_BINDINGS_GPIO_GPIO_H
+
+#define GPIO_ACTIVE_HIGH 0
+#define GPIO_ACTIVE_LOW 1
+
+#endif
diff --git a/include/dt-bindings/gpio/tegra-gpio.h b/include/dt-bindings/gpio/tegra-gpio.h
new file mode 100644 (file)
index 0000000..197dc28
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * This header provides constants for binding nvidia,tegra*-gpio.
+ *
+ * The first cell in Tegra's GPIO specifier is the GPIO ID. The macros below
+ * provide names for this.
+ *
+ * The second cell contains standard flag values specified in gpio.h.
+ */
+
+#ifndef _DT_BINDINGS_GPIO_TEGRA_GPIO_H
+#define _DT_BINDINGS_GPIO_TEGRA_GPIO_H
+
+#include <dt-bindings/gpio/gpio.h>
+
+#define TEGRA_GPIO_BANK_ID_A 0
+#define TEGRA_GPIO_BANK_ID_B 1
+#define TEGRA_GPIO_BANK_ID_C 2
+#define TEGRA_GPIO_BANK_ID_D 3
+#define TEGRA_GPIO_BANK_ID_E 4
+#define TEGRA_GPIO_BANK_ID_F 5
+#define TEGRA_GPIO_BANK_ID_G 6
+#define TEGRA_GPIO_BANK_ID_H 7
+#define TEGRA_GPIO_BANK_ID_I 8
+#define TEGRA_GPIO_BANK_ID_J 9
+#define TEGRA_GPIO_BANK_ID_K 10
+#define TEGRA_GPIO_BANK_ID_L 11
+#define TEGRA_GPIO_BANK_ID_M 12
+#define TEGRA_GPIO_BANK_ID_N 13
+#define TEGRA_GPIO_BANK_ID_O 14
+#define TEGRA_GPIO_BANK_ID_P 15
+#define TEGRA_GPIO_BANK_ID_Q 16
+#define TEGRA_GPIO_BANK_ID_R 17
+#define TEGRA_GPIO_BANK_ID_S 18
+#define TEGRA_GPIO_BANK_ID_T 19
+#define TEGRA_GPIO_BANK_ID_U 20
+#define TEGRA_GPIO_BANK_ID_V 21
+#define TEGRA_GPIO_BANK_ID_W 22
+#define TEGRA_GPIO_BANK_ID_X 23
+#define TEGRA_GPIO_BANK_ID_Y 24
+#define TEGRA_GPIO_BANK_ID_Z 25
+#define TEGRA_GPIO_BANK_ID_AA 26
+#define TEGRA_GPIO_BANK_ID_BB 27
+#define TEGRA_GPIO_BANK_ID_CC 28
+#define TEGRA_GPIO_BANK_ID_DD 29
+#define TEGRA_GPIO_BANK_ID_EE 30
+#define TEGRA_GPIO_BANK_ID_FF 31
+
+#define TEGRA_GPIO(bank, offset) \
+       ((TEGRA_GPIO_BANK_ID_##bank * 8) + offset)
+
+#endif
diff --git a/include/dt-bindings/interrupt-controller/arm-gic.h b/include/dt-bindings/interrupt-controller/arm-gic.h
new file mode 100644 (file)
index 0000000..1ea1b70
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * This header provides constants for the ARM GIC.
+ */
+
+#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_ARM_GIC_H
+#define _DT_BINDINGS_INTERRUPT_CONTROLLER_ARM_GIC_H
+
+#include <dt-bindings/interrupt-controller/irq.h>
+
+/* interrupt specific cell 0 */
+
+#define GIC_SPI 0
+#define GIC_PPI 1
+
+/*
+ * Interrupt specifier cell 2.
+ * The flaggs in irq.h are valid, plus those below.
+ */
+#define GIC_CPU_MASK_RAW(x) ((x) << 8)
+#define GIC_CPU_MASK_SIMPLE(num) GIC_CPU_MASK_RAW((1 << (num)) - 1)
+
+#endif
diff --git a/include/dt-bindings/interrupt-controller/irq.h b/include/dt-bindings/interrupt-controller/irq.h
new file mode 100644 (file)
index 0000000..33a1003
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * This header provides constants for most IRQ bindings.
+ *
+ * Most IRQ bindings include a flags cell as part of the IRQ specifier.
+ * In most cases, the format of the flags cell uses the standard values
+ * defined in this header.
+ */
+
+#ifndef _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H
+#define _DT_BINDINGS_INTERRUPT_CONTROLLER_IRQ_H
+
+#define IRQ_TYPE_NONE          0
+#define IRQ_TYPE_EDGE_RISING   1
+#define IRQ_TYPE_EDGE_FALLING  2
+#define IRQ_TYPE_EDGE_BOTH     (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)
+#define IRQ_TYPE_LEVEL_HIGH    4
+#define IRQ_TYPE_LEVEL_LOW     8
+
+#endif
diff --git a/include/iotrace.h b/include/iotrace.h
new file mode 100644 (file)
index 0000000..9bd1f16
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2014 Google, Inc.
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef __IOTRACE_H
+#define __IOTRACE_H
+
+#include <linux/types.h>
+
+/*
+ * This file is designed to be included in arch/<arch>/include/asm/io.h.
+ * It redirects all IO access through a tracing/checksumming feature for
+ * testing purposes.
+ */
+
+#if defined(CONFIG_IO_TRACE) && !defined(IOTRACE_IMPL) && \
+       !defined(CONFIG_SPL_BUILD)
+
+#undef readl
+#define readl(addr)    iotrace_readl((const void *)(addr))
+
+#undef writel
+#define writel(val, addr)      iotrace_writel(val, (const void *)(addr))
+
+#undef readw
+#define readw(addr)    iotrace_readw((const void *)(addr))
+
+#undef writew
+#define writew(val, addr)      iotrace_writew(val, (const void *)(addr))
+
+#undef readb
+#define readb(addr)    iotrace_readb((const void *)(addr))
+
+#undef writeb
+#define writeb(val, addr)      iotrace_writeb(val, (const void *)(addr))
+
+#endif
+
+/* Tracing functions which mirror their io.h counterparts */
+u32 iotrace_readl(const void *ptr);
+void iotrace_writel(ulong value, const void *ptr);
+u16 iotrace_readw(const void *ptr);
+void iotrace_writew(ulong value, const void *ptr);
+u8 iotrace_readb(const void *ptr);
+void iotrace_writeb(ulong value, const void *ptr);
+
+/**
+ * iotrace_reset_checksum() - Reset the iotrace checksum
+ */
+void iotrace_reset_checksum(void);
+
+/**
+ * iotrace_get_checksum() - Get the current checksum value
+ *
+ * @return currect checksum value
+ */
+u32 iotrace_get_checksum(void);
+
+/**
+ * iotrace_set_enabled() - Set whether iotracing is enabled or not
+ *
+ * This controls whether the checksum is updated and a trace record added
+ * for each I/O access.
+ *
+ * @enable: true to enable iotracing, false to disable
+ */
+void iotrace_set_enabled(int enable);
+
+/**
+ * iotrace_get_enabled() - Get whether iotracing is enabled or not
+ *
+ * @return true if enabled, false if disabled
+ */
+int iotrace_get_enabled(void);
+
+/**
+ * iotrace_set_buffer() - Set position and size of iotrace buffer
+ *
+ * Defines where the iotrace buffer goes, and resets the output pointer to
+ * the start of the buffer.
+ *
+ * The buffer can be 0 size in which case the checksum is updated but no
+ * trace records are writen. If the buffer is exhausted, the offset will
+ * continue to increase but not new data will be written.
+ *
+ * @start: Start address of buffer
+ * @size: Size of buffer in bytes
+ */
+void iotrace_set_buffer(ulong start, ulong size);
+
+/**
+ * iotrace_get_buffer() - Get buffer information
+ *
+ * @start: Returns start address of buffer
+ * @size: Returns size of buffer in bytes
+ * @offset: Returns the byte offset where the next output trace record will
+ * @count: Returns the number of trace records recorded
+ * be written (or would be if the buffer was large enough)
+ */
+void iotrace_get_buffer(ulong *start, ulong *size, ulong *offset, ulong *count);
+
+#endif /* __IOTRACE_H */
index 326844ce36e774e7390040501d3dfc17452c5844..072abaafb189b9f512a677e67ca2a571af2ce2c4 100644 (file)
@@ -153,6 +153,7 @@ ld_flags       = $(LDFLAGS) $(ldflags-y)
 # Modified for U-Boot
 dtc_cpp_flags  = -Wp,-MD,$(depfile).pre.tmp -nostdinc                    \
                 -I$(srctree)/arch/$(ARCH)/dts                           \
+                -I$(srctree)/arch/$(ARCH)/dts/include                   \
                 -undef -D__DTS__
 
 # Finds the multi-part object the current object will be linked into
index 4e9afe6c9cec17b4cbc6bc075d59e414e33812b9..c0f21351d7435cf9399baf6c0ad5a6b59dcdff85 100644 (file)
@@ -15,4 +15,6 @@ obj-$(CONFIG_DM_TEST) += ut.o
 # subsystem you must add sandbox tests here.
 obj-$(CONFIG_DM_TEST) += core.o
 obj-$(CONFIG_DM_TEST) += ut.o
+ifneq ($(CONFIG_SANDBOX),)
 obj-$(CONFIG_DM_GPIO) += gpio.o
+endif
index 083f15c31d137c6456ba457c9d2a6cab820653b6..aa8122c00541f41b4e46845977628775bc172ca0 100644 (file)
@@ -23,7 +23,7 @@ static int display_succ(struct udevice *in, char *buf)
        char local[16];
        struct udevice *pos, *n, *prev = NULL;
 
-       printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
+       printf("%s- %s @ %08lx", buf, in->name, (ulong)map_to_sysmem(in));
        if (in->flags & DM_FLAG_ACTIVATED)
                puts(" - activated");
        puts("\n");
@@ -62,7 +62,7 @@ static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
        struct udevice *root;
 
        root = dm_root();
-       printf("ROOT %08x\n", map_to_sysmem(root));
+       printf("ROOT %08lx\n", (ulong)map_to_sysmem(root));
        return dm_dump(root);
 }
 
@@ -84,8 +84,8 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
                for (ret = uclass_first_device(id, &dev);
                     dev;
                     ret = uclass_next_device(&dev)) {
-                       printf("  %s @  %08x:\n", dev->name,
-                              map_to_sysmem(dev));
+                       printf("  %s @ %08lx:\n", dev->name,
+                              (ulong)map_to_sysmem(dev));
                }
                puts("\n");
        }
@@ -93,16 +93,23 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
        return 0;
 }
 
+#ifdef CONFIG_DM_TEST
 static int do_dm_test(cmd_tbl_t *cmdtp, int flag, int argc,
                          char * const argv[])
 {
        return dm_test_main();
 }
+#define TEST_HELP "\ndm test         Run tests"
+#else
+#define TEST_HELP
+#endif
 
 static cmd_tbl_t test_commands[] = {
        U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""),
        U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""),
+#ifdef CONFIG_DM_TEST
        U_BOOT_CMD_MKENT(test, 1, 1, do_dm_test, "", ""),
+#endif
 };
 
 static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -128,6 +135,6 @@ U_BOOT_CMD(
        dm,     2,      1,      do_dm,
        "Driver model low level access",
        "tree         Dump driver model tree\n"
-       "dm uclass        Dump list of instances for each uclass\n"
-       "dm test         Run tests"
+       "dm uclass        Dump list of instances for each uclass"
+       TEST_HELP
 );
index 6eccf111279c2bbee53417f508c6b3ed514b8156..98e3936527ea11a594f4abd215c86b9fdfaf01ba 100644 (file)
@@ -53,7 +53,7 @@ static int testfdt_drv_probe(struct udevice *dev)
        return 0;
 }
 
-static const struct device_id testfdt_ids[] = {
+static const struct udevice_id testfdt_ids[] = {
        {
                .compatible = "denx,u-boot-fdt-test",
                .data = DM_TEST_TYPE_FIRST },