From c58299aa87544a590c62bda0bf52b69fa56cb8d5 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 20 Feb 2013 13:39:41 -0700 Subject: [PATCH 1/9] kbuild: create an "include chroot" for DT bindings The recent dtc+cpp support allows header files and C pre-processor defines/macros to be used when compiling device tree files. These headers will typically define various constants that are part of the device tree bindings. The original patch which set up the dtc+cpp include path only considered using those headers from device tree files. However, most are also useful for kernel code which needs to interpret the device tree. In both the DT files and the kernel, I'd like to include the DT-related headers in the same way, for example, . That will simplify any text which discusses the DT header locations. Creating a for kernel source to use is as simple as placing files into include/dt-bindings/. However, when compiling DT files, the include path should be restricted so that only the dt-bindings path is available; arbitrary kernel headers shouldn't be exposed. For this reason, create a specific include directory for use by dtc+cpp, and symlink dt-bindings from there to the actual location of include/dt-bindings/. For want of a better location, place this "include chroot" into the existing dts/ directory. arch/*/boot/dts/include/dt-bindings -> ../../../../../include/dt-bindings Some headers used by device tree files may not be useful to the kernel; they may be used simply to aid in constructing the DT file (e.g. macros to create a node), but not define any information that the kernel needs to share. These may be placed directly into arch/*/boot/dts/ along with the DT files themselves. Acked-by: Michal Marek Acked-by: Shawn Guo Acked-by: Rob Herring Signed-off-by: Stephen Warren --- arch/arm/boot/dts/include/dt-bindings | 1 + scripts/Makefile.lib | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 120000 arch/arm/boot/dts/include/dt-bindings diff --git a/arch/arm/boot/dts/include/dt-bindings b/arch/arm/boot/dts/include/dt-bindings new file mode 120000 index 000000000000..08c00e4972fa --- /dev/null +++ b/arch/arm/boot/dts/include/dt-bindings @@ -0,0 +1 @@ +../../../../../include/dt-bindings \ No newline at end of file diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 07125e697d7a..af35521b00a4 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -158,7 +158,7 @@ ld_flags = $(LDFLAGS) $(ldflags-y) dtc_cpp_flags = -Wp,-MD,$(depfile) -nostdinc \ -I$(srctree)/arch/$(SRCARCH)/boot/dts \ - -I$(srctree)/arch/$(SRCARCH)/include/dts \ + -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into From 2ab8a99661f4ce052bbad064237c441371df8751 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 6 Mar 2013 10:27:45 -0700 Subject: [PATCH 2/9] kbuild: fixdep: support concatenated dep files The current use-case for fixdep is: a source file is run through a single processing step, which creates a single dependency file as a side-effect, which fixdep transforms into the file used by the kernel build process. In order to transparently run the C pre-processor on device-tree files, we wish to run both gcc -E and dtc on a source file in a single rule. This generates two dependency files, which must be transformed together into the file used by the kernel build process. This change modifies fixdep so it can process the concatenation of multiple separate input dependency files, and produce a correct unified output. The code changes have the slight benefit of transforming the loop in parse_dep_file() into more of a lexer/tokenizer, with the loop body being more of a parser. Previously, some of this logic was mixed together before the loop. I also added some comments, which I hope are useful. Benchmarking shows that on a cross-compiled ARM tegra_defconfig build, there is less than 0.5 seconds speed decrease with this change, on top of a build time of ~2m24s. This is probably within the noise. Signed-off-by: Stephen Warren Acked-by: Rob Herring --- scripts/basic/fixdep.c | 93 +++++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 32 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 7f6425e24ce3..078fe1d64e7d 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -320,49 +320,78 @@ static void parse_dep_file(void *map, size_t len) char *end = m + len; char *p; char s[PATH_MAX]; - int first; - - p = strchr(m, ':'); - if (!p) { - fprintf(stderr, "fixdep: parse error\n"); - exit(1); - } - memcpy(s, m, p-m); s[p-m] = 0; - m = p+1; + int is_target; + int saw_any_target = 0; + int is_first_dep = 0; clear_config(); - first = 1; while (m < end) { + /* Skip any "white space" */ while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) m++; + /* Find next "white space" */ p = m; - while (p < end && *p != ' ') p++; - if (p == end) { - do p--; while (!isalnum(*p)); + while (p < end && *p != ' ' && *p != '\\' && *p != '\n') p++; + /* Is the token we found a target name? */ + is_target = (*(p-1) == ':'); + /* Don't write any target names into the dependency file */ + if (is_target) { + /* The /next/ file is the first dependency */ + is_first_dep = 1; + } else { + /* Save this token/filename */ + memcpy(s, m, p-m); + s[p - m] = 0; + + /* Ignore certain dependencies */ + if (strrcmp(s, "include/generated/autoconf.h") && + strrcmp(s, "arch/um/include/uml-config.h") && + strrcmp(s, "include/linux/kconfig.h") && + strrcmp(s, ".ver")) { + /* + * Do not list the source file as dependency, + * so that kbuild is not confused if a .c file + * is rewritten into .S or vice versa. Storing + * it in source_* is needed for modpost to + * compute srcversions. + */ + if (is_first_dep) { + /* + * If processing the concatenation of + * multiple dependency files, only + * process the first target name, which + * will be the original source name, + * and ignore any other target names, + * which will be intermediate temporary + * files. + */ + if (!saw_any_target) { + saw_any_target = 1; + printf("source_%s := %s\n\n", + target, s); + printf("deps_%s := \\\n", + target); + } + is_first_dep = 0; + } else + printf(" %s \\\n", s); + do_config_file(s); + } } - memcpy(s, m, p-m); s[p-m] = 0; - if (strrcmp(s, "include/generated/autoconf.h") && - strrcmp(s, "arch/um/include/uml-config.h") && - strrcmp(s, "include/linux/kconfig.h") && - strrcmp(s, ".ver")) { - /* - * Do not list the source file as dependency, so that - * kbuild is not confused if a .c file is rewritten - * into .S or vice versa. Storing it in source_* is - * needed for modpost to compute srcversions. - */ - if (first) { - printf("source_%s := %s\n\n", target, s); - printf("deps_%s := \\\n", target); - } else - printf(" %s \\\n", s); - do_config_file(s); - } - first = 0; + /* + * Start searching for next token immediately after the first + * "whitespace" character that follows this token. + */ m = p + 1; } + + if (!saw_any_target) { + fprintf(stderr, "fixdep: parse error; no targets found\n"); + exit(1); + } + printf("\n%s: $(deps_%s)\n\n", target, target); printf("$(deps_%s):\n", target); } From 85f02be8e5fd48a9bf8c719a4f12b4209b1e55b5 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 6 Mar 2013 10:28:02 -0700 Subject: [PATCH 3/9] kbuild: cmd_dtc_cpp: extract deps from both gcc -E and dtc Prior to this change, when compiling *.dts to *.dtb, the dependency output from dtc would be used, and when compiling *.dtsp to *.dtb, the dependency output from gcc -E alone would be used, despite dtc also being invoked (on a temporary file that was guaranteed to have no dependencies). With this change, when compiling *.dtsp to *.dtb, the dependency files from both gcc -E and dtc are used. This will allow cmd_dtc_cpp to replace cmd_dtc in a future change. In turn, that will allow the C pre- processor to be run transparently on *.dts, without the need to a separate rule or file extension to trigger it. Signed-off-by: Stephen Warren Acked-by: Rob Herring --- scripts/Makefile.lib | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index af35521b00a4..6104335234c6 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -156,7 +156,7 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ ld_flags = $(LDFLAGS) $(ldflags-y) -dtc_cpp_flags = -Wp,-MD,$(depfile) -nostdinc \ +dtc_cpp_flags = -Wp,-MD,$(depfile).pre -nostdinc \ -I$(srctree)/arch/$(SRCARCH)/boot/dts \ -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ -undef -D__DTS__ @@ -278,7 +278,8 @@ dtc-tmp = $(subst $(comma),_,$(dot-target).dts) quiet_cmd_dtc_cpp = DTC+CPP $@ cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ - $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $(dtc-tmp) + $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile).dtc $(dtc-tmp) ; \ + cat $(depfile).pre $(depfile).dtc > $(depfile) $(obj)/%.dtb: $(src)/%.dtsp FORCE $(call if_changed_dep,dtc_cpp) From b40b25fff8205dd18124d8fc87b2c9c57f269b5f Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 6 Mar 2013 10:58:37 -0700 Subject: [PATCH 4/9] kbuild: always run gcc -E on *.dts, remove cmd_dtc_cpp Replace cmd_dtc with cmd_dtc_cpp, and delete the latter. Previously, a special file extension (.dtsp) was required to trigger the C pre-processor to run on device tree files. This was ugly. Now that previous changes have enhanced cmd_dtc_cpp to collect dependency information from both gcc -E and dtc, we can transparently run the pre- processor on all device tree files, irrespective of whether they use /include/ or #include syntax to include *.dtsi. Signed-off-by: Stephen Warren Acked-by: Rob Herring --- scripts/Makefile.lib | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 6104335234c6..3e73dfd838cd 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -269,21 +269,17 @@ $(obj)/%.dtb.S: $(obj)/%.dtb $(call cmd,dt_S_dtb) quiet_cmd_dtc = DTC $@ -cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $< +cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ + $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ + -i $(srctree)/arch/$(SRCARCH)/boot/dts $(DTC_FLAGS) \ + -d $(depfile).dtc $(dtc-tmp) ; \ + cat $(depfile).pre $(depfile).dtc > $(depfile) $(obj)/%.dtb: $(src)/%.dts FORCE $(call if_changed_dep,dtc) dtc-tmp = $(subst $(comma),_,$(dot-target).dts) -quiet_cmd_dtc_cpp = DTC+CPP $@ -cmd_dtc_cpp = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ - $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile).dtc $(dtc-tmp) ; \ - cat $(depfile).pre $(depfile).dtc > $(depfile) - -$(obj)/%.dtb: $(src)/%.dtsp FORCE - $(call if_changed_dep,dtc_cpp) - # Bzip2 # --------------------------------------------------------------------------- From 71fab21fee07fd6d5f1a984db387cc5e4596f3fa Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Tue, 12 Feb 2013 17:22:36 -0700 Subject: [PATCH 5/9] ARM: dt: add header to define GPIO flags Many GPIO device tree bindings use the same flags. Create a header to define those. Signed-off-by: Stephen Warren Acked-by: Rob Herring --- include/dt-bindings/gpio/gpio.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 include/dt-bindings/gpio/gpio.h diff --git a/include/dt-bindings/gpio/gpio.h b/include/dt-bindings/gpio/gpio.h new file mode 100644 index 000000000000..e6b1e0a808ae --- /dev/null +++ b/include/dt-bindings/gpio/gpio.h @@ -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 From 840ef8b7cc584a23c4f9d05352f4dbaf8e56e5ab Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 13 Feb 2013 12:50:11 -0700 Subject: [PATCH 6/9] ARM: dt: add header to define IRQ flags Many IRQ device tree bindings use the same flags. Create a header to define those. Signed-off-by: Stephen Warren Acked-by: Rob Herring --- .../dt-bindings/interrupt-controller/irq.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 include/dt-bindings/interrupt-controller/irq.h diff --git a/include/dt-bindings/interrupt-controller/irq.h b/include/dt-bindings/interrupt-controller/irq.h new file mode 100644 index 000000000000..33a1003c55aa --- /dev/null +++ b/include/dt-bindings/interrupt-controller/irq.h @@ -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 From 4be505d4fc7a07371a2b658469ca1dda99993ca3 Mon Sep 17 00:00:00 2001 From: Stephen Warren Date: Wed, 13 Feb 2013 12:50:48 -0700 Subject: [PATCH 7/9] ARM: dt: create a DT header for the GIC The ARM GIC binding defines a few custom cells and flags for its IRQ specifier. Provide names for those. Signed-off-by: Stephen Warren Acked-by: Rob Herring --- .../interrupt-controller/arm-gic.h | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 include/dt-bindings/interrupt-controller/arm-gic.h diff --git a/include/dt-bindings/interrupt-controller/arm-gic.h b/include/dt-bindings/interrupt-controller/arm-gic.h new file mode 100644 index 000000000000..1ea1b702fec2 --- /dev/null +++ b/include/dt-bindings/interrupt-controller/arm-gic.h @@ -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 + +/* 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 From d450f445f9a654080a6be4094376c2192d9a1f36 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Tue, 19 Feb 2013 02:58:25 +0300 Subject: [PATCH 8/9] : fix compilation warnings with DT disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following compilation warnings (in Simon Horman's renesas.git repo): In file included from arch/arm/mach-shmobile/setup-r8a7779.c:24:0: include/linux/of_platform.h:107:13: warning: ‘struct of_device_id’ declared inside parameter list [enabled by default] include/linux/of_platform.h:107:13: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] include/linux/of_platform.h:107:13: warning: ‘struct device_node’ declared inside parameter list [enabled by default] only #include's headers with definitions of the above mentioned structures if CONFIG_OF_DEVICE=y but uses them even if not. One solution is to move some #include's out of #ifdef CONFIG_OF_DEVICE and use incomplete declarations for the rest of the structures where the #ifdef move doesn't help... Reported-by: Vladimir Barinov Signed-off-by: Sergei Shtylyov Signed-off-by: Rob Herring --- include/linux/of_platform.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h index 3863a4dbdf18..2a93b64a3869 100644 --- a/include/linux/of_platform.h +++ b/include/linux/of_platform.h @@ -11,9 +11,10 @@ * */ -#ifdef CONFIG_OF_DEVICE #include #include + +#ifdef CONFIG_OF_DEVICE #include #include #include @@ -100,7 +101,7 @@ extern int of_platform_populate(struct device_node *root, #if !defined(CONFIG_OF_ADDRESS) struct of_dev_auxdata; -struct device; +struct device_node; static inline int of_platform_populate(struct device_node *root, const struct of_device_id *matches, const struct of_dev_auxdata *lookup, From a2b9ea73967386ec5e524ab206bd549d5aafea17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Thu, 25 Apr 2013 14:27:57 +0200 Subject: [PATCH 9/9] Documentation/devicetree: make semantic of initrd-end more explicit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-König Signed-off-by: Rob Herring --- Documentation/devicetree/usage-model.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/usage-model.txt b/Documentation/devicetree/usage-model.txt index ef9d06c9f8fd..0efedaad5165 100644 --- a/Documentation/devicetree/usage-model.txt +++ b/Documentation/devicetree/usage-model.txt @@ -191,9 +191,11 @@ Linux it will look something like this: }; The bootargs property contains the kernel arguments, and the initrd-* -properties define the address and size of an initrd blob. The -chosen node may also optionally contain an arbitrary number of -additional properties for platform-specific configuration data. +properties define the address and size of an initrd blob. Note that +initrd-end is the first address after the initrd image, so this doesn't +match the usual semantic of struct resource. The chosen node may also +optionally contain an arbitrary number of additional properties for +platform-specific configuration data. During early boot, the architecture setup code calls of_scan_flat_dt() several times with different helper callbacks to parse device tree