dt: run C pre-processor on *.dts, create some standard headers

This branch enhances the support for running dtc on device tree files.
 
 A dedicated directory is created for header files that provide constants
 for device-tree bindings.
 
 The kbuild dependency script processor is enhanced to support processing
 the dependency outputs from multiple separate commands at once.
 
 The kbuild dtc rule is modified so that the C pre-processor is always
 applied when compiling any device tree.
 
 Some standard headers are created which define common constants for GPIO,
 IRQ, and ARM GIC device tree bindings.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.11 (GNU/Linux)
 
 iQIcBAABAgAGBQJRXxlRAAoJEMzrak5tbycxaSsQAMDw5JoNgRubYvwBIZxrHAL8
 ELVIVrMujh1EquLW1+AdDYP5JGVkBzYdNmBkNyb2nPpTDPMeTrOHsMA2V3PtRHsF
 bvdO49xIoqJS4hr9qAq781a8LUW6+vo++Fptjcp4+2uLF1vMDFB9sbe3AAc4j0Tg
 6cqRrCQjNxtZFMTzUyj1KftCshW3A4xH5+Lr/tpMWLd+mpvJorDbaxSDTNDfq2WF
 ZmfzOybt7F8mu6SK6ar+XsJp0gX8hGV7zNPeHcClFKeguyA5YKfCZKeo6PTJlMA1
 yZ9UfaLVLXTfy+l/aM8fG5m9QvtiBy9oZK5kyM6r83DC0mI9Rnc9oohdpCvfmgu8
 3YOXU8BoouN/HrJQJLZHPiqN1Dj7i+PDTqrz6YTQ/Aa23XJCyvVZmmsUaXv/uy5b
 uJsyU1QiMdO6p25Q/EC1xfJbdCSUQz+pRdo1w3liqoGynrj87/MUF+qApPKz5qkx
 lJc5HyHw63Uw3ql5l/JmpXfYgeQC6Ie593+9bXEFQqJGai2sbu7eDS5SjTrp77Z4
 t+K28dTLm+fkE53pZb3YuLryGdRA22+bmOOsOpnE6PUyvZjDK1TVU0Q3XprSriW/
 ZBomvCoK5Kd+2Ioxf9p/u8cRwjM19cz1NCAV+cSvN4uI8YYT4sMGFAScT6nK4mCf
 ircNDR1WEIrtCbwzHazL
 =4/RH
 -----END PGP SIGNATURE-----

Merge tag 'tegra-for-3.10-dtc-cpp-chroot-std-headers' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra into for-next

Pull DT C pre-processor changes from Stephen Warren:

dt: run C pre-processor on *.dts, create some standard headers

This branch enhances the support for running dtc on device tree files.

A dedicated directory is created for header files that provide constants
for device-tree bindings.

The kbuild dependency script processor is enhanced to support processing
the dependency outputs from multiple separate commands at once.

The kbuild dtc rule is modified so that the C pre-processor is always
applied when compiling any device tree.

Some standard headers are created which define common constants for GPIO,
IRQ, and ARM GIC device tree bindings.
This commit is contained in:
Rob Herring 2013-04-09 14:59:04 -05:00
commit a2f682aeee
6 changed files with 125 additions and 42 deletions

View File

@ -0,0 +1 @@
../../../../../include/dt-bindings

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -156,9 +156,9 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
ld_flags = $(LDFLAGS) $(ldflags-y) 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 \
-I$(srctree)/arch/$(SRCARCH)/include/dts \ -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \
-undef -D__DTS__ -undef -D__DTS__
# Finds the multi-part object the current object will be linked into # Finds the multi-part object the current object will be linked into
@ -269,20 +269,17 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
$(call cmd,dt_S_dtb) $(call cmd,dt_S_dtb)
quiet_cmd_dtc = DTC $@ 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 $(obj)/%.dtb: $(src)/%.dts FORCE
$(call if_changed_dep,dtc) $(call if_changed_dep,dtc)
dtc-tmp = $(subst $(comma),_,$(dot-target).dts) 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)
$(obj)/%.dtb: $(src)/%.dtsp FORCE
$(call if_changed_dep,dtc_cpp)
# Bzip2 # Bzip2
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------

View File

@ -320,49 +320,78 @@ static void parse_dep_file(void *map, size_t len)
char *end = m + len; char *end = m + len;
char *p; char *p;
char s[PATH_MAX]; char s[PATH_MAX];
int first; int is_target;
int saw_any_target = 0;
p = strchr(m, ':'); int is_first_dep = 0;
if (!p) {
fprintf(stderr, "fixdep: parse error\n");
exit(1);
}
memcpy(s, m, p-m); s[p-m] = 0;
m = p+1;
clear_config(); clear_config();
first = 1;
while (m < end) { while (m < end) {
/* Skip any "white space" */
while (m < end && (*m == ' ' || *m == '\\' || *m == '\n')) while (m < end && (*m == ' ' || *m == '\\' || *m == '\n'))
m++; m++;
/* Find next "white space" */
p = m; p = m;
while (p < end && *p != ' ') p++; while (p < end && *p != ' ' && *p != '\\' && *p != '\n')
if (p == end) {
do p--; while (!isalnum(*p));
p++; p++;
} /* Is the token we found a target name? */
memcpy(s, m, p-m); s[p-m] = 0; 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") && if (strrcmp(s, "include/generated/autoconf.h") &&
strrcmp(s, "arch/um/include/uml-config.h") && strrcmp(s, "arch/um/include/uml-config.h") &&
strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, "include/linux/kconfig.h") &&
strrcmp(s, ".ver")) { strrcmp(s, ".ver")) {
/* /*
* Do not list the source file as dependency, so that * Do not list the source file as dependency,
* kbuild is not confused if a .c file is rewritten * so that kbuild is not confused if a .c file
* into .S or vice versa. Storing it in source_* is * is rewritten into .S or vice versa. Storing
* needed for modpost to compute srcversions. * it in source_* is needed for modpost to
* compute srcversions.
*/ */
if (first) { if (is_first_dep) {
printf("source_%s := %s\n\n", target, s); /*
printf("deps_%s := \\\n", target); * 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 } else
printf(" %s \\\n", s); printf(" %s \\\n", s);
do_config_file(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; 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("\n%s: $(deps_%s)\n\n", target, target);
printf("$(deps_%s):\n", target); printf("$(deps_%s):\n", target);
} }