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/Kconfig b/src/lib/Kconfig
index bce0291..eb4c16e 100644
--- a/src/lib/Kconfig
+++ b/src/lib/Kconfig
@@ -17,6 +17,12 @@
 	help
 	  Selected by features that require `libhwbase` in ramstage.
 
+config FLATTENED_DEVICE_TREE
+	bool
+	help
+	  Selected by features that require to parse and manipulate a flattened
+	  devicetree in ramstage.
+
 if RAMSTAGE_LIBHWBASE
 
 config HWBASE_DYNAMIC_MMIO