summaryrefslogtreecommitdiff
path: root/common/fdt_decode.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2011-05-15 07:19:44 -0700
committerSimon Glass <sjg@chromium.org>2011-08-24 10:01:32 -0700
commit889cf9258b29dfdbd325504b3860c6555db6766c (patch)
tree76b2711aa4c53a44a07b8478a7ef55a0c444844d /common/fdt_decode.c
parent9db0f13eec6529dbd7f717fc167e9d7f72523a04 (diff)
fdt: Add function to convert a compatible string into an ID
To select between different drivers we need to translate the compatible string into an ID number which we can use to select between different drivers for each function. BUG=chromium-os:11623 TEST=build and boot U-Boot on Seaboard Change-Id: I99a60f7e92a021cb7e23a85054e6b76cb9f2054c Reviewed-on: http://gerrit.chromium.org/gerrit/957 Tested-by: Simon Glass <sjg@chromium.org> Reviewed-by: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'common/fdt_decode.c')
-rw-r--r--common/fdt_decode.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c
index d149bf2145..d316d918d8 100644
--- a/common/fdt_decode.c
+++ b/common/fdt_decode.c
@@ -25,6 +25,14 @@
#include <fdt_support.h>
#include <fdt_decode.h>
+/*
+ * Here are the type we know about. One day we might allow drivers to
+ * register. For now we just put them here.
+ */
+static struct fdt_compat compat_types[] = {
+ { COMPAT_UNKNOWN, "<none>" },
+};
+
/**
* Look in the FDT for an alias with the given name and return its node.
*
@@ -122,7 +130,7 @@ void fdt_decode_uart_calc_divisor(struct fdt_uart *uart)
int fdt_decode_uart_console(const void *blob, struct fdt_uart *uart,
int default_baudrate)
{
- int node, i;
+ int node;
node = find_alias_node(blob, "console");
if (node < 0)
@@ -137,9 +145,22 @@ int fdt_decode_uart_console(const void *blob, struct fdt_uart *uart,
uart->enabled = get_is_enabled(blob, node, 1);
uart->interrupt = get_int(blob, node, "interrupts", -1);
uart->silent = get_int(blob, node, "silent", 0);
+ uart->compat = fdt_decode_lookup(blob, node);
/* Calculate divisor if required */
if (uart->divisor == -1)
fdt_decode_uart_calc_divisor(uart);
return 0;
}
+
+enum fdt_compat_id fdt_decode_lookup(const void *blob, int node)
+{
+ enum fdt_compat_id id;
+
+ /* Search our drivers */
+ for (id = COMPAT_UNKNOWN; id < COMPAT_COUNT; id++)
+ if (0 == fdt_node_check_compatible(blob, node,
+ compat_types[id].name))
+ return id;
+ return COMPAT_UNKNOWN;
+}