fdt_select.py 681 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/python
  2. #
  3. # Copyright (C) 2016 Google, Inc
  4. # Written by Simon Glass <sjg@chromium.org>
  5. #
  6. # SPDX-License-Identifier: GPL-2.0+
  7. #
  8. # Bring in either the normal fdt library (which relies on libfdt) or the
  9. # fallback one (which uses fdtget and is slower). Both provide the same
  10. # interface for this file to use.
  11. try:
  12. import fdt_normal
  13. have_libfdt = True
  14. except ImportError:
  15. have_libfdt = False
  16. import fdt_fallback
  17. def FdtScan(fname):
  18. """Returns a new Fdt object from the implementation we are using"""
  19. if have_libfdt:
  20. dtb = fdt_normal.FdtNormal(fname)
  21. else:
  22. dtb = fdt_fallback.FdtFallback(fname)
  23. dtb.Scan()
  24. return dtb