2018-09-14 19:57:24 +09:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
|
|
|
# Copyright (c) 2018 Google, Inc
|
|
|
|
# Written by Simon Glass <sjg@chromium.org>
|
|
|
|
#
|
|
|
|
# Entry-type module for U-Boot device tree files
|
|
|
|
#
|
|
|
|
|
2020-04-18 09:09:03 +09:00
|
|
|
from binman.entry import Entry
|
|
|
|
from binman.etype.blob import Entry_blob
|
2018-09-14 19:57:24 +09:00
|
|
|
|
|
|
|
class Entry_blob_dtb(Entry_blob):
|
|
|
|
"""A blob that holds a device tree
|
|
|
|
|
|
|
|
This is a blob containing a device tree. The contents of the blob are
|
|
|
|
obtained from the list of available device-tree files, managed by the
|
|
|
|
'state' module.
|
|
|
|
"""
|
|
|
|
def __init__(self, section, etype, node):
|
2019-08-24 22:22:44 +09:00
|
|
|
# Put this here to allow entry-docs and help to work without libfdt
|
|
|
|
global state
|
2020-04-18 09:09:03 +09:00
|
|
|
from binman import state
|
2019-08-24 22:22:44 +09:00
|
|
|
|
2018-09-14 19:57:24 +09:00
|
|
|
Entry_blob.__init__(self, section, etype, node)
|
|
|
|
|
|
|
|
def ObtainContents(self):
|
|
|
|
"""Get the device-tree from the list held by the 'state' module"""
|
|
|
|
self._filename = self.GetDefaultFilename()
|
2019-07-21 03:23:32 +09:00
|
|
|
self._pathname, _ = state.GetFdtContents(self.GetFdtEtype())
|
2019-07-09 05:25:38 +09:00
|
|
|
return Entry_blob.ReadBlobContents(self)
|
2018-09-14 19:57:24 +09:00
|
|
|
|
|
|
|
def ProcessContents(self):
|
|
|
|
"""Re-read the DTB contents so that we get any calculated properties"""
|
2019-07-21 03:23:32 +09:00
|
|
|
_, indata = state.GetFdtContents(self.GetFdtEtype())
|
2019-07-09 05:25:38 +09:00
|
|
|
data = self.CompressData(indata)
|
2019-07-09 05:25:35 +09:00
|
|
|
return self.ProcessContentsUpdate(data)
|
2019-07-21 03:23:25 +09:00
|
|
|
|
2019-07-21 03:23:31 +09:00
|
|
|
def GetFdtEtype(self):
|
|
|
|
"""Get the entry type of this device tree
|
|
|
|
|
|
|
|
This can be 'u-boot-dtb', 'u-boot-spl-dtb' or 'u-boot-tpl-dtb'
|
|
|
|
Returns:
|
|
|
|
Entry type if any, e.g. 'u-boot-dtb'
|
|
|
|
"""
|
|
|
|
return None
|
|
|
|
|
2019-07-21 03:23:28 +09:00
|
|
|
def GetFdts(self):
|
|
|
|
"""Get the device trees used by this entry
|
2019-07-21 03:23:25 +09:00
|
|
|
|
|
|
|
Returns:
|
2019-07-21 03:23:28 +09:00
|
|
|
Dict:
|
|
|
|
key: Filename from this entry (without the path)
|
2019-07-21 03:23:31 +09:00
|
|
|
value: Tuple:
|
|
|
|
Fdt object for this dtb, or None if not available
|
|
|
|
Filename of file containing this dtb
|
2019-07-21 03:23:25 +09:00
|
|
|
"""
|
2019-07-21 03:23:31 +09:00
|
|
|
fname = self.GetDefaultFilename()
|
|
|
|
return {self.GetFdtEtype(): [self, fname]}
|
2019-07-21 03:24:08 +09:00
|
|
|
|
|
|
|
def WriteData(self, data, decomp=True):
|
|
|
|
ok = Entry_blob.WriteData(self, data, decomp)
|
|
|
|
|
|
|
|
# Update the state module, since it has the authoritative record of the
|
|
|
|
# device trees used. If we don't do this, then state.GetFdtContents()
|
|
|
|
# will still return the old contents
|
|
|
|
state.UpdateFdtContents(self.GetFdtEtype(), data)
|
|
|
|
return ok
|