diff options
author | David Daney <david.daney@cavium.com> | 2012-07-05 12:12:38 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-07-23 08:54:52 -0400 |
commit | ab25383983fb8d7786696f5371e75e79c3e9a405 (patch) | |
tree | 7e35f3abdd680e2cccf3749a2a21b07bc02c7c5b | |
parent | a339aef90470cf21debb138f95e22adf143eecca (diff) |
of/lib: Allow scripts/dtc/libfdt to be used from kernel code
libfdt is part of the device tree support in scripts/dtc/libfdt. For
some platforms that use the Device Tree, we want to be able to edit
the flattened device tree form.
We don't want to burden kernel builds that do not require it, so we
gate compilation of libfdt files with CONFIG_LIBFDT. So if it is
needed, you need to do this in your Kconfig:
select LIBFDT
And in the Makefile of the code using libfdt something like:
ccflags-y := -I$(src)/../../../scripts/dtc/libfdt
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: devicetree-discuss@lists.ozlabs.org
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: linux-kernel@vger.kernel.org
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | include/linux/libfdt.h | 8 | ||||
-rw-r--r-- | include/linux/libfdt_env.h | 13 | ||||
-rw-r--r-- | lib/Kconfig | 6 | ||||
-rw-r--r-- | lib/Makefile | 5 | ||||
-rw-r--r-- | lib/fdt.c | 2 | ||||
-rw-r--r-- | lib/fdt_ro.c | 2 | ||||
-rw-r--r-- | lib/fdt_rw.c | 2 | ||||
-rw-r--r-- | lib/fdt_strerror.c | 2 | ||||
-rw-r--r-- | lib/fdt_sw.c | 2 | ||||
-rw-r--r-- | lib/fdt_wip.c | 2 |
10 files changed, 44 insertions, 0 deletions
diff --git a/include/linux/libfdt.h b/include/linux/libfdt.h new file mode 100644 index 000000000000..4c0306c69b4e --- /dev/null +++ b/include/linux/libfdt.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _INCLUDE_LIBFDT_H_ | ||
2 | #define _INCLUDE_LIBFDT_H_ | ||
3 | |||
4 | #include <linux/libfdt_env.h> | ||
5 | #include "../../scripts/dtc/libfdt/fdt.h" | ||
6 | #include "../../scripts/dtc/libfdt/libfdt.h" | ||
7 | |||
8 | #endif /* _INCLUDE_LIBFDT_H_ */ | ||
diff --git a/include/linux/libfdt_env.h b/include/linux/libfdt_env.h new file mode 100644 index 000000000000..01508c7b8c81 --- /dev/null +++ b/include/linux/libfdt_env.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef _LIBFDT_ENV_H | ||
2 | #define _LIBFDT_ENV_H | ||
3 | |||
4 | #include <linux/string.h> | ||
5 | |||
6 | #include <asm/byteorder.h> | ||
7 | |||
8 | #define fdt32_to_cpu(x) be32_to_cpu(x) | ||
9 | #define cpu_to_fdt32(x) cpu_to_be32(x) | ||
10 | #define fdt64_to_cpu(x) be64_to_cpu(x) | ||
11 | #define cpu_to_fdt64(x) cpu_to_be64(x) | ||
12 | |||
13 | #endif /* _LIBFDT_ENV_H */ | ||
diff --git a/lib/Kconfig b/lib/Kconfig index a9e15403434e..e091300b2045 100644 --- a/lib/Kconfig +++ b/lib/Kconfig | |||
@@ -395,4 +395,10 @@ config SIGNATURE | |||
395 | Digital signature verification. Currently only RSA is supported. | 395 | Digital signature verification. Currently only RSA is supported. |
396 | Implementation is done using GnuPG MPI library | 396 | Implementation is done using GnuPG MPI library |
397 | 397 | ||
398 | # | ||
399 | # libfdt files, only selected if needed. | ||
400 | # | ||
401 | config LIBFDT | ||
402 | bool | ||
403 | |||
398 | endmenu | 404 | endmenu |
diff --git a/lib/Makefile b/lib/Makefile index 8c31a0cb75e9..2f2be5a8734c 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -130,6 +130,11 @@ obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o | |||
130 | 130 | ||
131 | obj-$(CONFIG_STMP_DEVICE) += stmp_device.o | 131 | obj-$(CONFIG_STMP_DEVICE) += stmp_device.o |
132 | 132 | ||
133 | libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o | ||
134 | $(foreach file, $(libfdt_files), \ | ||
135 | $(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt)) | ||
136 | lib-$(CONFIG_LIBFDT) += $(libfdt_files) | ||
137 | |||
133 | hostprogs-y := gen_crc32table | 138 | hostprogs-y := gen_crc32table |
134 | clean-files := crc32table.h | 139 | clean-files := crc32table.h |
135 | 140 | ||
diff --git a/lib/fdt.c b/lib/fdt.c new file mode 100644 index 000000000000..97f20069fc37 --- /dev/null +++ b/lib/fdt.c | |||
@@ -0,0 +1,2 @@ | |||
1 | #include <linux/libfdt_env.h> | ||
2 | #include "../scripts/dtc/libfdt/fdt.c" | ||
diff --git a/lib/fdt_ro.c b/lib/fdt_ro.c new file mode 100644 index 000000000000..f73c04ea7be4 --- /dev/null +++ b/lib/fdt_ro.c | |||
@@ -0,0 +1,2 @@ | |||
1 | #include <linux/libfdt_env.h> | ||
2 | #include "../scripts/dtc/libfdt/fdt_ro.c" | ||
diff --git a/lib/fdt_rw.c b/lib/fdt_rw.c new file mode 100644 index 000000000000..0c1f0f4a4b13 --- /dev/null +++ b/lib/fdt_rw.c | |||
@@ -0,0 +1,2 @@ | |||
1 | #include <linux/libfdt_env.h> | ||
2 | #include "../scripts/dtc/libfdt/fdt_rw.c" | ||
diff --git a/lib/fdt_strerror.c b/lib/fdt_strerror.c new file mode 100644 index 000000000000..8713e3ff4707 --- /dev/null +++ b/lib/fdt_strerror.c | |||
@@ -0,0 +1,2 @@ | |||
1 | #include <linux/libfdt_env.h> | ||
2 | #include "../scripts/dtc/libfdt/fdt_strerror.c" | ||
diff --git a/lib/fdt_sw.c b/lib/fdt_sw.c new file mode 100644 index 000000000000..9ac7e50c76ce --- /dev/null +++ b/lib/fdt_sw.c | |||
@@ -0,0 +1,2 @@ | |||
1 | #include <linux/libfdt_env.h> | ||
2 | #include "../scripts/dtc/libfdt/fdt_sw.c" | ||
diff --git a/lib/fdt_wip.c b/lib/fdt_wip.c new file mode 100644 index 000000000000..45b3fc3d3ba1 --- /dev/null +++ b/lib/fdt_wip.c | |||
@@ -0,0 +1,2 @@ | |||
1 | #include <linux/libfdt_env.h> | ||
2 | #include "../scripts/dtc/libfdt/fdt_wip.c" | ||