blob: 18a36d88a0250cc79efc3b9a36e700b77b58b6bb [file] [log] [blame]
Simon Glassba482582016-07-25 18:59:02 -06001#!/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
9# Bring in either the normal fdt library (which relies on libfdt) or the
10# fallback one (which uses fdtget and is slower). Both provide the same
11# interface for this file to use.
12try:
Simon Glassa06a34b2016-07-25 18:59:04 -060013 import fdt_normal
Simon Glassba482582016-07-25 18:59:02 -060014 have_libfdt = True
15except ImportError:
16 have_libfdt = False
Simon Glassa06a34b2016-07-25 18:59:04 -060017 import fdt_fallback
Simon Glassba482582016-07-25 18:59:02 -060018
19def FdtScan(fname):
20 """Returns a new Fdt object from the implementation we are using"""
Simon Glassa06a34b2016-07-25 18:59:04 -060021 if have_libfdt:
22 dtb = fdt_normal.FdtNormal(fname)
23 else:
24 dtb = fdt_fallback.FdtFallback(fname)
Simon Glassba482582016-07-25 18:59:02 -060025 dtb.Scan()
26 return dtb