diff options
Diffstat (limited to 'common/deep-probe.c')
-rw-r--r-- | common/deep-probe.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/common/deep-probe.c b/common/deep-probe.c new file mode 100644 index 0000000000..1020ad93b7 --- /dev/null +++ b/common/deep-probe.c @@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include <common.h> +#include <deep-probe.h> +#include <of.h> + +enum deep_probe_state { + DEEP_PROBE_UNKONWN = -1, + DEEP_PROBE_NOT_SUPPORTED, + DEEP_PROBE_SUPPORTED +}; + +static enum deep_probe_state boardstate = DEEP_PROBE_UNKONWN; + +bool deep_probe_is_supported(void) +{ + struct deep_probe_entry *board; + + if (boardstate > DEEP_PROBE_UNKONWN) + return boardstate; + + /* determine boardstate */ + for (board = &__barebox_deep_probe_start; + board != &__barebox_deep_probe_end; board++) { + const struct of_device_id *matches = board->device_id; + + for (; matches->compatible; matches++) { + if (of_machine_is_compatible(matches->compatible)) { + boardstate = DEEP_PROBE_SUPPORTED; + printk("Deep probe supported due to %s\n", matches->compatible); + return true; + } + } + } + + boardstate = DEEP_PROBE_NOT_SUPPORTED; + return false; +} +EXPORT_SYMBOL_GPL(deep_probe_is_supported); |