lib/devicetree: Integrate flattened devicetree support

* Adapt to coreboot coding style.
* Use coreboot's endian conversion functions.
* Fix header and header guards.
* Get rid of unused functions.
* Add Kconfig to build it on ramstage.
* Replace size32 with ALIGN_UP and DIV_ROUND_UP.
* Add NULL pointer checks
* Convert constants to defines

Required for Cavium's BDK and uImage FIT support.

Change-Id: I6e6cd9f78fb402bd54d684097326d26eb78d552a
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25523
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 99322dc..a902e0c 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -135,6 +135,8 @@
 ramstage-$(CONFIG_GENERIC_UDELAY) += timer.c
 ramstage-y += b64_decode.c
 ramstage-$(CONFIG_ACPI_NHLT) += nhlt.c
+ramstage-y += list.c
+ramstage-$(CONFIG_FLATTENED_DEVICE_TREE) += device_tree.c
 
 romstage-y += cbmem_common.c
 romstage-y += imd_cbmem.c