Browse Source

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>
master
David Daney 9 years ago
committed by Ralf Baechle
parent
commit
ab25383983
10 changed files with 44 additions and 0 deletions
  1. +8
    -0
      include/linux/libfdt.h
  2. +13
    -0
      include/linux/libfdt_env.h
  3. +6
    -0
      lib/Kconfig
  4. +5
    -0
      lib/Makefile
  5. +2
    -0
      lib/fdt.c
  6. +2
    -0
      lib/fdt_ro.c
  7. +2
    -0
      lib/fdt_rw.c
  8. +2
    -0
      lib/fdt_strerror.c
  9. +2
    -0
      lib/fdt_sw.c
  10. +2
    -0
      lib/fdt_wip.c

+ 8
- 0
include/linux/libfdt.h View File

@ -0,0 +1,8 @@
#ifndef _INCLUDE_LIBFDT_H_
#define _INCLUDE_LIBFDT_H_
#include <linux/libfdt_env.h>
#include "../../scripts/dtc/libfdt/fdt.h"
#include "../../scripts/dtc/libfdt/libfdt.h"
#endif /* _INCLUDE_LIBFDT_H_ */

+ 13
- 0
include/linux/libfdt_env.h View File

@ -0,0 +1,13 @@
#ifndef _LIBFDT_ENV_H
#define _LIBFDT_ENV_H
#include <linux/string.h>
#include <asm/byteorder.h>
#define fdt32_to_cpu(x) be32_to_cpu(x)
#define cpu_to_fdt32(x) cpu_to_be32(x)
#define fdt64_to_cpu(x) be64_to_cpu(x)
#define cpu_to_fdt64(x) cpu_to_be64(x)
#endif /* _LIBFDT_ENV_H */

+ 6
- 0
lib/Kconfig View File

@ -395,4 +395,10 @@ config SIGNATURE
Digital signature verification. Currently only RSA is supported.
Implementation is done using GnuPG MPI library
#
# libfdt files, only selected if needed.
#
config LIBFDT
bool
endmenu

+ 5
- 0
lib/Makefile View File

@ -130,6 +130,11 @@ obj-$(CONFIG_GENERIC_STRNLEN_USER) += strnlen_user.o
obj-$(CONFIG_STMP_DEVICE) += stmp_device.o
libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o
$(foreach file, $(libfdt_files), \
$(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
lib-$(CONFIG_LIBFDT) += $(libfdt_files)
hostprogs-y := gen_crc32table
clean-files := crc32table.h


+ 2
- 0
lib/fdt.c View File

@ -0,0 +1,2 @@
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt.c"

+ 2
- 0
lib/fdt_ro.c View File

@ -0,0 +1,2 @@
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_ro.c"

+ 2
- 0
lib/fdt_rw.c View File

@ -0,0 +1,2 @@
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_rw.c"

+ 2
- 0
lib/fdt_strerror.c View File

@ -0,0 +1,2 @@
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_strerror.c"

+ 2
- 0
lib/fdt_sw.c View File

@ -0,0 +1,2 @@
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_sw.c"

+ 2
- 0
lib/fdt_wip.c View File

@ -0,0 +1,2 @@
#include <linux/libfdt_env.h>
#include "../scripts/dtc/libfdt/fdt_wip.c"

Loading…
Cancel
Save