summaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt_select.py
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2016-09-20 09:34:53 -0400
committerTom Rini <trini@konsulko.com>2016-09-20 09:34:53 -0400
commita2ed3f452dd1cf4982fe46d5111d200909786686 (patch)
treea66b5a2f3b6491df7ba9345178502959fb19c84f /tools/dtoc/fdt_select.py
parent60c629b836fb6b6ae79e4e0663977056d75de198 (diff)
parent8f224b3734d042884a8981a14db64c48e87b87a2 (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'tools/dtoc/fdt_select.py')
-rw-r--r--tools/dtoc/fdt_select.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/dtoc/fdt_select.py b/tools/dtoc/fdt_select.py
new file mode 100644
index 0000000000..18a36d88a0
--- /dev/null
+++ b/tools/dtoc/fdt_select.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2016 Google, Inc
+# Written by Simon Glass <sjg@chromium.org>
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+# Bring in either the normal fdt library (which relies on libfdt) or the
+# fallback one (which uses fdtget and is slower). Both provide the same
+# interface for this file to use.
+try:
+ import fdt_normal
+ have_libfdt = True
+except ImportError:
+ have_libfdt = False
+ import fdt_fallback
+
+def FdtScan(fname):
+ """Returns a new Fdt object from the implementation we are using"""
+ if have_libfdt:
+ dtb = fdt_normal.FdtNormal(fname)
+ else:
+ dtb = fdt_fallback.FdtFallback(fname)
+ dtb.Scan()
+ return dtb