Add fdt helper component

Add a new component that implements helper functions on top of libfdt.

Signed-off-by: Balint Dobszay <balint.dobszay@arm.com>
Change-Id: I43a4562433b6e81d5f5e4944c2161d5b542f537b
diff --git a/components/common/fdt/fdt_helpers.c b/components/common/fdt/fdt_helpers.c
new file mode 100644
index 0000000..eaf7922
--- /dev/null
+++ b/components/common/fdt/fdt_helpers.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
+ */
+
+#include "fdt_helpers.h"
+
+bool dt_get_u32(const void *fdt, int node, const char *prop_name, uint32_t *prop_val)
+{
+	const fdt32_t *u32_prop = NULL;
+	int len = 0;
+
+	if (!fdt || !prop_name || !prop_val)
+		return false;
+
+	u32_prop = fdt_getprop(fdt, node, prop_name, &len);
+	if (!u32_prop || len != sizeof(*u32_prop))
+		return false;
+
+	*prop_val = fdt32_to_cpu(*u32_prop);
+
+	return true;
+}
+
+bool dt_get_u64(const void *fdt, int node, const char *prop_name, uint64_t *prop_val)
+{
+	const fdt64_t *u64_prop = NULL;
+	int len = 0;
+
+	if (!fdt || !prop_name || !prop_val)
+		return false;
+
+	u64_prop = fdt_getprop(fdt, node, prop_name, &len);
+	if (!u64_prop || len != sizeof(*u64_prop))
+		return false;
+
+	*prop_val = fdt64_to_cpu(*u64_prop);
+
+	return true;
+}