Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 1 | #!/usr/bin/python |
Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0+ |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 3 | # |
| 4 | # Copyright (C) 2017 Google, Inc |
| 5 | # Written by Simon Glass <sjg@chromium.org> |
| 6 | # |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 7 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 8 | """Device tree to platform data class |
| 9 | |
| 10 | This supports converting device tree data to C structures definitions and |
| 11 | static data. |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 12 | |
| 13 | See doc/driver-model/of-plat.rst for more informaiton |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 14 | """ |
| 15 | |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 16 | import collections |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 17 | import copy |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 18 | from enum import IntEnum |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 19 | import os |
| 20 | import re |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 21 | import sys |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 22 | |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 23 | from dtoc import fdt |
| 24 | from dtoc import fdt_util |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 25 | |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 26 | # When we see these properties we ignore them - i.e. do not create a structure |
| 27 | # member |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 28 | PROP_IGNORE_LIST = [ |
| 29 | '#address-cells', |
| 30 | '#gpio-cells', |
| 31 | '#size-cells', |
| 32 | 'compatible', |
| 33 | 'linux,phandle', |
| 34 | "status", |
| 35 | 'phandle', |
| 36 | 'u-boot,dm-pre-reloc', |
| 37 | 'u-boot,dm-tpl', |
| 38 | 'u-boot,dm-spl', |
| 39 | ] |
| 40 | |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 41 | # C type declarations for the types we support |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 42 | TYPE_NAMES = { |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 43 | fdt.Type.INT: 'fdt32_t', |
| 44 | fdt.Type.BYTE: 'unsigned char', |
| 45 | fdt.Type.STRING: 'const char *', |
| 46 | fdt.Type.BOOL: 'bool', |
| 47 | fdt.Type.INT64: 'fdt64_t', |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 48 | } |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 49 | |
| 50 | STRUCT_PREFIX = 'dtd_' |
| 51 | VAL_PREFIX = 'dtv_' |
| 52 | |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 53 | class Ftype(IntEnum): |
| 54 | SOURCE, HEADER = range(2) |
| 55 | |
| 56 | |
| 57 | # This holds information about each type of output file dtoc can create |
| 58 | # type: Type of file (Ftype) |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 59 | # fname: Filename excluding directory, e.g. 'dt-plat.c' |
| 60 | # hdr_comment: Comment explaining the purpose of the file |
| 61 | OutputFile = collections.namedtuple('OutputFile', |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 62 | ['ftype', 'fname', 'method', 'hdr_comment']) |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 63 | |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 64 | # This holds information about a property which includes phandles. |
| 65 | # |
| 66 | # max_args: integer: Maximum number or arguments that any phandle uses (int). |
| 67 | # args: Number of args for each phandle in the property. The total number of |
| 68 | # phandles is len(args). This is a list of integers. |
| 69 | PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args']) |
| 70 | |
Simon Glass | c162211 | 2020-10-03 09:25:19 -0600 | [diff] [blame] | 71 | # Holds a single phandle link, allowing a C struct value to be assigned to point |
| 72 | # to a device |
| 73 | # |
| 74 | # var_node: C variable to assign (e.g. 'dtv_mmc.clocks[0].node') |
| 75 | # dev_name: Name of device to assign to (e.g. 'clock') |
| 76 | PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_name']) |
| 77 | |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 78 | |
Simon Glass | b42ed51 | 2020-12-23 08:11:23 -0700 | [diff] [blame] | 79 | class Driver: |
| 80 | """Information about a driver in U-Boot |
| 81 | |
| 82 | Attributes: |
| 83 | name: Name of driver. For U_BOOT_DRIVER(x) this is 'x' |
| 84 | """ |
| 85 | def __init__(self, name): |
| 86 | self.name = name |
| 87 | |
| 88 | def __eq__(self, other): |
| 89 | return self.name == other.name |
| 90 | |
| 91 | def __repr__(self): |
| 92 | return "Driver(name='%s')" % self.name |
| 93 | |
| 94 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 95 | def conv_name_to_c(name): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 96 | """Convert a device-tree name to a C identifier |
| 97 | |
Simon Glass | 2e0bf3f | 2017-06-18 22:09:04 -0600 | [diff] [blame] | 98 | This uses multiple replace() calls instead of re.sub() since it is faster |
| 99 | (400ms for 1m calls versus 1000ms for the 're' version). |
| 100 | |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 101 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 102 | name (str): Name to convert |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 103 | Return: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 104 | str: String containing the C version of this name |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 105 | """ |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 106 | new = name.replace('@', '_at_') |
| 107 | new = new.replace('-', '_') |
| 108 | new = new.replace(',', '_') |
| 109 | new = new.replace('.', '_') |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 110 | return new |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 111 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 112 | def tab_to(num_tabs, line): |
| 113 | """Append tabs to a line of text to reach a tab stop. |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 114 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 115 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 116 | num_tabs (int): Tab stop to obtain (0 = column 0, 1 = column 8, etc.) |
| 117 | line (str): Line of text to append to |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 118 | |
| 119 | Returns: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 120 | str: line with the correct number of tabs appeneded. If the line already |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 121 | extends past that tab stop then a single space is appended. |
| 122 | """ |
| 123 | if len(line) >= num_tabs * 8: |
| 124 | return line + ' ' |
| 125 | return line + '\t' * (num_tabs - len(line) // 8) |
| 126 | |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 127 | def get_value(ftype, value): |
| 128 | """Get a value as a C expression |
| 129 | |
| 130 | For integers this returns a byte-swapped (little-endian) hex string |
| 131 | For bytes this returns a hex string, e.g. 0x12 |
| 132 | For strings this returns a literal string enclosed in quotes |
| 133 | For booleans this return 'true' |
| 134 | |
| 135 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 136 | ftype (fdt.Type): Data type (fdt_util) |
| 137 | value (bytes): Data value, as a string of bytes |
| 138 | |
| 139 | Returns: |
| 140 | str: String representation of the value |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 141 | """ |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 142 | if ftype == fdt.Type.INT: |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 143 | val = '%#x' % fdt_util.fdt32_to_cpu(value) |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 144 | elif ftype == fdt.Type.BYTE: |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 145 | char = value[0] |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 146 | val = '%#x' % (ord(char) if isinstance(char, str) else char) |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 147 | elif ftype == fdt.Type.STRING: |
Simon Glass | 7f5e226 | 2020-07-07 21:32:06 -0600 | [diff] [blame] | 148 | # Handle evil ACPI backslashes by adding another backslash before them. |
| 149 | # So "\\_SB.GPO0" in the device tree effectively stays like that in C |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 150 | val = '"%s"' % value.replace('\\', '\\\\') |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 151 | elif ftype == fdt.Type.BOOL: |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 152 | val = 'true' |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 153 | else: # ftype == fdt.Type.INT64: |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 154 | val = '%#x' % value |
| 155 | return val |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 156 | |
| 157 | def get_compat_name(node): |
Walter Lozano | 5fe734c | 2020-07-23 00:22:03 -0300 | [diff] [blame] | 158 | """Get the node's list of compatible string as a C identifiers |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 159 | |
| 160 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 161 | node (fdt.Node): Node object to check |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 162 | Return: |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 163 | list of str: List of C identifiers for all the compatible strings |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 164 | """ |
| 165 | compat = node.props['compatible'].value |
Walter Lozano | 5fe734c | 2020-07-23 00:22:03 -0300 | [diff] [blame] | 166 | if not isinstance(compat, list): |
| 167 | compat = [compat] |
| 168 | return [conv_name_to_c(c) for c in compat] |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 169 | |
Simon Glass | 7a2add1 | 2017-06-18 22:09:02 -0600 | [diff] [blame] | 170 | |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 171 | class DtbPlatdata(): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 172 | """Provide a means to convert device tree binary data to platform data |
| 173 | |
| 174 | The output of this process is C structures which can be used in space- |
| 175 | constrained encvironments where the ~3KB code overhead of device tree |
| 176 | code is not affordable. |
| 177 | |
| 178 | Properties: |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 179 | _fdt: Fdt object, referencing the device tree |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 180 | _dtb_fname: Filename of the input device tree binary file |
Simon Glass | 192f813 | 2020-10-03 11:31:25 -0600 | [diff] [blame] | 181 | _valid_nodes: A list of Node object with compatible strings. The list |
| 182 | is ordered by conv_name_to_c(node.name) |
Simon Glass | eab3f62 | 2017-06-18 22:09:01 -0600 | [diff] [blame] | 183 | _include_disabled: true to include nodes marked status = "disabled" |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 184 | _outfile: The current output file (sys.stdout or a real file) |
Walter Lozano | a324e41 | 2020-06-25 01:10:08 -0300 | [diff] [blame] | 185 | _warning_disabled: true to disable warnings about driver names not found |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 186 | _lines: Stashed list of output lines for outputting in the future |
Simon Glass | b42ed51 | 2020-12-23 08:11:23 -0700 | [diff] [blame] | 187 | _drivers: Dict of valid driver names found in drivers/ |
| 188 | key: Driver name |
| 189 | value: Driver for that driver |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 190 | _driver_aliases: Dict that holds aliases for driver names |
| 191 | key: Driver alias declared with |
Simon Glass | df65db8 | 2020-12-28 20:34:57 -0700 | [diff] [blame] | 192 | DM_DRIVER_ALIAS(driver_alias, driver_name) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 193 | value: Driver name declared with U_BOOT_DRIVER(driver_name) |
Walter Lozano | d82062b | 2020-07-28 19:06:23 -0300 | [diff] [blame] | 194 | _drivers_additional: List of additional drivers to use during scanning |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 195 | _dirname: Directory to hold output files, or None for none (all files |
| 196 | go to stdout) |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 197 | _struct_data (dict): OrderedDict of dtplat structures to output |
| 198 | key (str): Node name, as a C identifier |
| 199 | value: dict containing structure fields: |
| 200 | key (str): Field name |
| 201 | value: Prop object with field information |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 202 | _basedir (str): Base directory of source tree |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 203 | """ |
Walter Lozano | d82062b | 2020-07-28 19:06:23 -0300 | [diff] [blame] | 204 | def __init__(self, dtb_fname, include_disabled, warning_disabled, |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 205 | drivers_additional=None): |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 206 | self._fdt = None |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 207 | self._dtb_fname = dtb_fname |
| 208 | self._valid_nodes = None |
Simon Glass | eab3f62 | 2017-06-18 22:09:01 -0600 | [diff] [blame] | 209 | self._include_disabled = include_disabled |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 210 | self._outfile = None |
Walter Lozano | a324e41 | 2020-06-25 01:10:08 -0300 | [diff] [blame] | 211 | self._warning_disabled = warning_disabled |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 212 | self._lines = [] |
Simon Glass | b42ed51 | 2020-12-23 08:11:23 -0700 | [diff] [blame] | 213 | self._drivers = {} |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 214 | self._driver_aliases = {} |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 215 | self._drivers_additional = drivers_additional or [] |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 216 | self._dirnames = [None] * len(Ftype) |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 217 | self._struct_data = collections.OrderedDict() |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 218 | self._basedir = None |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 219 | |
| 220 | def get_normalized_compat_name(self, node): |
| 221 | """Get a node's normalized compat name |
| 222 | |
Walter Lozano | 5fe734c | 2020-07-23 00:22:03 -0300 | [diff] [blame] | 223 | Returns a valid driver name by retrieving node's list of compatible |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 224 | string as a C identifier and performing a check against _drivers |
| 225 | and a lookup in driver_aliases printing a warning in case of failure. |
| 226 | |
| 227 | Args: |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 228 | node (Node): Node object to check |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 229 | Return: |
| 230 | Tuple: |
| 231 | Driver name associated with the first compatible string |
| 232 | List of C identifiers for all the other compatible strings |
| 233 | (possibly empty) |
| 234 | In case of no match found, the return will be the same as |
| 235 | get_compat_name() |
| 236 | """ |
Walter Lozano | 5fe734c | 2020-07-23 00:22:03 -0300 | [diff] [blame] | 237 | compat_list_c = get_compat_name(node) |
| 238 | |
| 239 | for compat_c in compat_list_c: |
Simon Glass | b42ed51 | 2020-12-23 08:11:23 -0700 | [diff] [blame] | 240 | if not compat_c in self._drivers.keys(): |
Walter Lozano | 5fe734c | 2020-07-23 00:22:03 -0300 | [diff] [blame] | 241 | compat_c = self._driver_aliases.get(compat_c) |
| 242 | if not compat_c: |
| 243 | continue |
| 244 | |
| 245 | aliases_c = compat_list_c |
| 246 | if compat_c in aliases_c: |
| 247 | aliases_c.remove(compat_c) |
| 248 | return compat_c, aliases_c |
| 249 | |
| 250 | if not self._warning_disabled: |
| 251 | print('WARNING: the driver %s was not found in the driver list' |
| 252 | % (compat_list_c[0])) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 253 | |
Walter Lozano | 5fe734c | 2020-07-23 00:22:03 -0300 | [diff] [blame] | 254 | return compat_list_c[0], compat_list_c[1:] |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 255 | |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 256 | def setup_output_dirs(self, output_dirs): |
| 257 | """Set up the output directories |
| 258 | |
| 259 | This should be done before setup_output() is called |
| 260 | |
| 261 | Args: |
| 262 | output_dirs (tuple of str): |
| 263 | Directory to use for C output files. |
| 264 | Use None to write files relative current directory |
| 265 | Directory to use for H output files. |
| 266 | Defaults to the C output dir |
| 267 | """ |
| 268 | def process_dir(ftype, dirname): |
| 269 | if dirname: |
| 270 | os.makedirs(dirname, exist_ok=True) |
| 271 | self._dirnames[ftype] = dirname |
| 272 | |
| 273 | if output_dirs: |
| 274 | c_dirname = output_dirs[0] |
| 275 | h_dirname = output_dirs[1] if len(output_dirs) > 1 else c_dirname |
| 276 | process_dir(Ftype.SOURCE, c_dirname) |
| 277 | process_dir(Ftype.HEADER, h_dirname) |
| 278 | |
| 279 | def setup_output(self, ftype, fname): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 280 | """Set up the output destination |
| 281 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 282 | Once this is done, future calls to self.out() will output to this |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 283 | file. The file used is as follows: |
| 284 | |
| 285 | self._dirnames[ftype] is None: output to fname, or stdout if None |
| 286 | self._dirnames[ftype] is not None: output to fname in that directory |
| 287 | |
| 288 | Calling this function multiple times will close the old file and open |
| 289 | the new one. If they are the same file, nothing happens and output will |
| 290 | continue to the same file. |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 291 | |
| 292 | Args: |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 293 | ftype (str): Type of file to create ('c' or 'h') |
| 294 | fname (str): Filename to send output to. If there is a directory in |
| 295 | self._dirnames for this file type, it will be put in that |
| 296 | directory |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 297 | """ |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 298 | dirname = self._dirnames[ftype] |
| 299 | if dirname: |
| 300 | pathname = os.path.join(dirname, fname) |
| 301 | if self._outfile: |
| 302 | self._outfile.close() |
| 303 | self._outfile = open(pathname, 'w') |
| 304 | elif fname: |
| 305 | if not self._outfile: |
| 306 | self._outfile = open(fname, 'w') |
Simon Glass | 6ca0c7a | 2020-12-28 20:34:48 -0700 | [diff] [blame] | 307 | else: |
| 308 | self._outfile = sys.stdout |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 309 | |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 310 | def finish_output(self): |
| 311 | """Finish outputing to a file |
| 312 | |
| 313 | This closes the output file, if one is in use |
| 314 | """ |
| 315 | if self._outfile != sys.stdout: |
| 316 | self._outfile.close() |
| 317 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 318 | def out(self, line): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 319 | """Output a string to the output file |
| 320 | |
| 321 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 322 | line (str): String to output |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 323 | """ |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 324 | self._outfile.write(line) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 325 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 326 | def buf(self, line): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 327 | """Buffer up a string to send later |
| 328 | |
| 329 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 330 | line (str): String to add to our 'buffer' list |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 331 | """ |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 332 | self._lines.append(line) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 333 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 334 | def get_buf(self): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 335 | """Get the contents of the output buffer, and clear it |
| 336 | |
| 337 | Returns: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 338 | list(str): The output buffer, which is then cleared for future use |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 339 | """ |
| 340 | lines = self._lines |
| 341 | self._lines = [] |
| 342 | return lines |
| 343 | |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 344 | def out_header(self, outfile): |
| 345 | """Output a message indicating that this is an auto-generated file |
| 346 | |
| 347 | Args: |
| 348 | outfile: OutputFile describing the file being generated |
| 349 | """ |
Simon Glass | 68d32c7 | 2017-08-29 14:16:01 -0600 | [diff] [blame] | 350 | self.out('''/* |
| 351 | * DO NOT MODIFY |
| 352 | * |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 353 | * %s. |
| 354 | * This was generated by dtoc from a .dtb (device tree binary) file. |
Simon Glass | 68d32c7 | 2017-08-29 14:16:01 -0600 | [diff] [blame] | 355 | */ |
| 356 | |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 357 | ''' % outfile.hdr_comment) |
Simon Glass | 68d32c7 | 2017-08-29 14:16:01 -0600 | [diff] [blame] | 358 | |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 359 | def get_phandle_argc(self, prop, node_name): |
| 360 | """Check if a node contains phandles |
Simon Glass | ce5621d | 2017-08-29 14:15:54 -0600 | [diff] [blame] | 361 | |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 362 | We have no reliable way of detecting whether a node uses a phandle |
| 363 | or not. As an interim measure, use a list of known property names. |
| 364 | |
| 365 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 366 | prop (fdt.Prop): Prop object to check |
| 367 | node_name (str): Node name, only used for raising an error |
| 368 | Returns: |
| 369 | int or None: Number of argument cells is this is a phandle, |
| 370 | else None |
| 371 | Raises: |
| 372 | ValueError: if the phandle cannot be parsed or the required property |
| 373 | is not present |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 374 | """ |
Walter Lozano | 179f0b6 | 2020-06-25 01:10:16 -0300 | [diff] [blame] | 375 | if prop.name in ['clocks', 'cd-gpios']: |
Simon Glass | 609e2b1 | 2018-07-06 10:27:31 -0600 | [diff] [blame] | 376 | if not isinstance(prop.value, list): |
| 377 | prop.value = [prop.value] |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 378 | val = prop.value |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 379 | i = 0 |
Simon Glass | ce5621d | 2017-08-29 14:15:54 -0600 | [diff] [blame] | 380 | |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 381 | max_args = 0 |
| 382 | args = [] |
| 383 | while i < len(val): |
| 384 | phandle = fdt_util.fdt32_to_cpu(val[i]) |
Simon Glass | 609e2b1 | 2018-07-06 10:27:31 -0600 | [diff] [blame] | 385 | # If we get to the end of the list, stop. This can happen |
| 386 | # since some nodes have more phandles in the list than others, |
| 387 | # but we allocate enough space for the largest list. So those |
| 388 | # nodes with shorter lists end up with zeroes at the end. |
| 389 | if not phandle: |
| 390 | break |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 391 | target = self._fdt.phandle_to_node.get(phandle) |
| 392 | if not target: |
| 393 | raise ValueError("Cannot parse '%s' in node '%s'" % |
| 394 | (prop.name, node_name)) |
Walter Lozano | 179f0b6 | 2020-06-25 01:10:16 -0300 | [diff] [blame] | 395 | cells = None |
| 396 | for prop_name in ['#clock-cells', '#gpio-cells']: |
| 397 | cells = target.props.get(prop_name) |
| 398 | if cells: |
| 399 | break |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 400 | if not cells: |
Walter Lozano | 179f0b6 | 2020-06-25 01:10:16 -0300 | [diff] [blame] | 401 | raise ValueError("Node '%s' has no cells property" % |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 402 | (target.name)) |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 403 | num_args = fdt_util.fdt32_to_cpu(cells.value) |
| 404 | max_args = max(max_args, num_args) |
| 405 | args.append(num_args) |
| 406 | i += 1 + num_args |
| 407 | return PhandleInfo(max_args, args) |
| 408 | return None |
Simon Glass | ce5621d | 2017-08-29 14:15:54 -0600 | [diff] [blame] | 409 | |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 410 | def scan_driver(self, fname): |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 411 | """Scan a driver file to build a list of driver names and aliases |
| 412 | |
| 413 | This procedure will populate self._drivers and self._driver_aliases |
| 414 | |
| 415 | Args |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 416 | fname: Driver filename to scan |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 417 | """ |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 418 | with open(fname, encoding='utf-8') as inf: |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 419 | try: |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 420 | buff = inf.read() |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 421 | except UnicodeDecodeError: |
| 422 | # This seems to happen on older Python versions |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 423 | print("Skipping file '%s' due to unicode error" % fname) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 424 | return |
| 425 | |
| 426 | # The following re will search for driver names declared as |
| 427 | # U_BOOT_DRIVER(driver_name) |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 428 | drivers = re.findall(r'U_BOOT_DRIVER\((.*)\)', buff) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 429 | |
| 430 | for driver in drivers: |
Simon Glass | b42ed51 | 2020-12-23 08:11:23 -0700 | [diff] [blame] | 431 | self._drivers[driver] = Driver(driver) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 432 | |
| 433 | # The following re will search for driver aliases declared as |
Simon Glass | df65db8 | 2020-12-28 20:34:57 -0700 | [diff] [blame] | 434 | # DM_DRIVER_ALIAS(alias, driver_name) |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 435 | driver_aliases = re.findall( |
Simon Glass | df65db8 | 2020-12-28 20:34:57 -0700 | [diff] [blame] | 436 | r'DM_DRIVER_ALIAS\(\s*(\w+)\s*,\s*(\w+)\s*\)', |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 437 | buff) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 438 | |
| 439 | for alias in driver_aliases: # pragma: no cover |
| 440 | if len(alias) != 2: |
| 441 | continue |
| 442 | self._driver_aliases[alias[1]] = alias[0] |
| 443 | |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 444 | def scan_drivers(self, basedir=None): |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 445 | """Scan the driver folders to build a list of driver names and aliases |
| 446 | |
| 447 | This procedure will populate self._drivers and self._driver_aliases |
| 448 | |
| 449 | """ |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 450 | if not basedir: |
| 451 | basedir = sys.argv[0].replace('tools/dtoc/dtoc', '') |
| 452 | if basedir == '': |
| 453 | basedir = './' |
| 454 | self._basedir = basedir |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 455 | for (dirpath, _, filenames) in os.walk(basedir): |
| 456 | for fname in filenames: |
| 457 | if not fname.endswith('.c'): |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 458 | continue |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 459 | self.scan_driver(dirpath + '/' + fname) |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 460 | |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 461 | for fname in self._drivers_additional: |
| 462 | if not isinstance(fname, str) or len(fname) == 0: |
Walter Lozano | d82062b | 2020-07-28 19:06:23 -0300 | [diff] [blame] | 463 | continue |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 464 | if fname[0] == '/': |
| 465 | self.scan_driver(fname) |
Walter Lozano | d82062b | 2020-07-28 19:06:23 -0300 | [diff] [blame] | 466 | else: |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 467 | self.scan_driver(basedir + '/' + fname) |
Walter Lozano | d82062b | 2020-07-28 19:06:23 -0300 | [diff] [blame] | 468 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 469 | def scan_dtb(self): |
Anatolij Gustschin | da707d4 | 2017-08-18 17:58:51 +0200 | [diff] [blame] | 470 | """Scan the device tree to obtain a tree of nodes and properties |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 471 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 472 | Once this is done, self._fdt.GetRoot() can be called to obtain the |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 473 | device tree root node, and progress from there. |
| 474 | """ |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 475 | self._fdt = fdt.FdtScan(self._dtb_fname) |
| 476 | |
Simon Glass | 192f813 | 2020-10-03 11:31:25 -0600 | [diff] [blame] | 477 | def scan_node(self, root, valid_nodes): |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 478 | """Scan a node and subnodes to build a tree of node and phandle info |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 479 | |
Simon Glass | 17ffd62 | 2017-08-29 14:15:53 -0600 | [diff] [blame] | 480 | This adds each node to self._valid_nodes. |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 481 | |
| 482 | Args: |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 483 | root (Node): Root node for scan |
| 484 | valid_nodes (list of Node): List of Node objects to add to |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 485 | """ |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 486 | for node in root.subnodes: |
| 487 | if 'compatible' in node.props: |
| 488 | status = node.props.get('status') |
Simon Glass | eab3f62 | 2017-06-18 22:09:01 -0600 | [diff] [blame] | 489 | if (not self._include_disabled and not status or |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 490 | status.value != 'disabled'): |
Simon Glass | 192f813 | 2020-10-03 11:31:25 -0600 | [diff] [blame] | 491 | valid_nodes.append(node) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 492 | |
| 493 | # recurse to handle any subnodes |
Simon Glass | 192f813 | 2020-10-03 11:31:25 -0600 | [diff] [blame] | 494 | self.scan_node(node, valid_nodes) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 495 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 496 | def scan_tree(self): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 497 | """Scan the device tree for useful information |
| 498 | |
| 499 | This fills in the following properties: |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 500 | _valid_nodes: A list of nodes we wish to consider include in the |
| 501 | platform data |
| 502 | """ |
Simon Glass | 192f813 | 2020-10-03 11:31:25 -0600 | [diff] [blame] | 503 | valid_nodes = [] |
| 504 | self.scan_node(self._fdt.GetRoot(), valid_nodes) |
| 505 | self._valid_nodes = sorted(valid_nodes, |
| 506 | key=lambda x: conv_name_to_c(x.name)) |
| 507 | for idx, node in enumerate(self._valid_nodes): |
| 508 | node.idx = idx |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 509 | |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 510 | @staticmethod |
| 511 | def get_num_cells(node): |
| 512 | """Get the number of cells in addresses and sizes for this node |
| 513 | |
| 514 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 515 | node (fdt.None): Node to check |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 516 | |
| 517 | Returns: |
| 518 | Tuple: |
| 519 | Number of address cells for this node |
| 520 | Number of size cells for this node |
| 521 | """ |
| 522 | parent = node.parent |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 523 | num_addr, num_size = 2, 2 |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 524 | if parent: |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 525 | addr_prop = parent.props.get('#address-cells') |
| 526 | size_prop = parent.props.get('#size-cells') |
| 527 | if addr_prop: |
| 528 | num_addr = fdt_util.fdt32_to_cpu(addr_prop.value) |
| 529 | if size_prop: |
| 530 | num_size = fdt_util.fdt32_to_cpu(size_prop.value) |
| 531 | return num_addr, num_size |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 532 | |
| 533 | def scan_reg_sizes(self): |
| 534 | """Scan for 64-bit 'reg' properties and update the values |
| 535 | |
| 536 | This finds 'reg' properties with 64-bit data and converts the value to |
| 537 | an array of 64-values. This allows it to be output in a way that the |
| 538 | C code can read. |
| 539 | """ |
| 540 | for node in self._valid_nodes: |
| 541 | reg = node.props.get('reg') |
| 542 | if not reg: |
| 543 | continue |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 544 | num_addr, num_size = self.get_num_cells(node) |
| 545 | total = num_addr + num_size |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 546 | |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 547 | if reg.type != fdt.Type.INT: |
Simon Glass | c38fee04 | 2018-07-06 10:27:32 -0600 | [diff] [blame] | 548 | raise ValueError("Node '%s' reg property is not an int" % |
| 549 | node.name) |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 550 | if len(reg.value) % total: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 551 | raise ValueError( |
| 552 | "Node '%s' reg property has %d cells " |
| 553 | 'which is not a multiple of na + ns = %d + %d)' % |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 554 | (node.name, len(reg.value), num_addr, num_size)) |
| 555 | reg.num_addr = num_addr |
| 556 | reg.num_size = num_size |
| 557 | if num_addr != 1 or num_size != 1: |
Simon Glass | c9a032c | 2020-11-08 20:36:17 -0700 | [diff] [blame] | 558 | reg.type = fdt.Type.INT64 |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 559 | i = 0 |
| 560 | new_value = [] |
| 561 | val = reg.value |
| 562 | if not isinstance(val, list): |
| 563 | val = [val] |
| 564 | while i < len(val): |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 565 | addr = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_addr) |
| 566 | i += num_addr |
| 567 | size = fdt_util.fdt_cells_to_cpu(val[i:], reg.num_size) |
| 568 | i += num_size |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 569 | new_value += [addr, size] |
| 570 | reg.value = new_value |
| 571 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 572 | def scan_structs(self): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 573 | """Scan the device tree building up the C structures we will use. |
| 574 | |
| 575 | Build a dict keyed by C struct name containing a dict of Prop |
| 576 | object for each struct field (keyed by property name). Where the |
| 577 | same struct appears multiple times, try to use the 'widest' |
| 578 | property, i.e. the one with a type which can express all others. |
| 579 | |
| 580 | Once the widest property is determined, all other properties are |
| 581 | updated to match that width. |
Simon Glass | 941f8f0 | 2020-10-03 11:31:24 -0600 | [diff] [blame] | 582 | |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 583 | The results are written to self._struct_data |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 584 | """ |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 585 | structs = self._struct_data |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 586 | for node in self._valid_nodes: |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 587 | node_name, _ = self.get_normalized_compat_name(node) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 588 | fields = {} |
| 589 | |
| 590 | # Get a list of all the valid properties in this node. |
| 591 | for name, prop in node.props.items(): |
| 592 | if name not in PROP_IGNORE_LIST and name[0] != '#': |
| 593 | fields[name] = copy.deepcopy(prop) |
| 594 | |
| 595 | # If we've seen this node_name before, update the existing struct. |
| 596 | if node_name in structs: |
| 597 | struct = structs[node_name] |
| 598 | for name, prop in fields.items(): |
| 599 | oldprop = struct.get(name) |
| 600 | if oldprop: |
| 601 | oldprop.Widen(prop) |
| 602 | else: |
| 603 | struct[name] = prop |
| 604 | |
| 605 | # Otherwise store this as a new struct. |
| 606 | else: |
| 607 | structs[node_name] = fields |
| 608 | |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 609 | for node in self._valid_nodes: |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 610 | node_name, _ = self.get_normalized_compat_name(node) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 611 | struct = structs[node_name] |
| 612 | for name, prop in node.props.items(): |
| 613 | if name not in PROP_IGNORE_LIST and name[0] != '#': |
| 614 | prop.Widen(struct[name]) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 615 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 616 | def scan_phandles(self): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 617 | """Figure out what phandles each node uses |
| 618 | |
| 619 | We need to be careful when outputing nodes that use phandles since |
| 620 | they must come after the declaration of the phandles in the C file. |
| 621 | Otherwise we get a compiler error since the phandle struct is not yet |
| 622 | declared. |
| 623 | |
| 624 | This function adds to each node a list of phandle nodes that the node |
| 625 | depends on. This allows us to output things in the right order. |
| 626 | """ |
| 627 | for node in self._valid_nodes: |
| 628 | node.phandles = set() |
| 629 | for pname, prop in node.props.items(): |
| 630 | if pname in PROP_IGNORE_LIST or pname[0] == '#': |
| 631 | continue |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 632 | info = self.get_phandle_argc(prop, node.name) |
| 633 | if info: |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 634 | # Process the list as pairs of (phandle, id) |
Simon Glass | 3deeb47 | 2017-08-29 14:15:59 -0600 | [diff] [blame] | 635 | pos = 0 |
| 636 | for args in info.args: |
| 637 | phandle_cell = prop.value[pos] |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 638 | phandle = fdt_util.fdt32_to_cpu(phandle_cell) |
| 639 | target_node = self._fdt.phandle_to_node[phandle] |
| 640 | node.phandles.add(target_node) |
Simon Glass | 3deeb47 | 2017-08-29 14:15:59 -0600 | [diff] [blame] | 641 | pos += 1 + args |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 642 | |
| 643 | |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 644 | def generate_structs(self): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 645 | """Generate struct defintions for the platform data |
| 646 | |
| 647 | This writes out the body of a header file consisting of structure |
| 648 | definitions for node in self._valid_nodes. See the documentation in |
Heinrich Schuchardt | c79f03c | 2020-02-25 21:35:39 +0100 | [diff] [blame] | 649 | doc/driver-model/of-plat.rst for more information. |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 650 | """ |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 651 | structs = self._struct_data |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 652 | self.out('#include <stdbool.h>\n') |
Masahiro Yamada | 75f82d0 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 653 | self.out('#include <linux/libfdt.h>\n') |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 654 | |
| 655 | # Output the struct definition |
| 656 | for name in sorted(structs): |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 657 | self.out('struct %s%s {\n' % (STRUCT_PREFIX, name)) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 658 | for pname in sorted(structs[name]): |
| 659 | prop = structs[name][pname] |
Simon Glass | ec3b5e4 | 2017-08-29 14:15:55 -0600 | [diff] [blame] | 660 | info = self.get_phandle_argc(prop, structs[name]) |
| 661 | if info: |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 662 | # For phandles, include a reference to the target |
Simon Glass | e94414b | 2017-08-29 14:15:56 -0600 | [diff] [blame] | 663 | struct_name = 'struct phandle_%d_arg' % info.max_args |
| 664 | self.out('\t%s%s[%d]' % (tab_to(2, struct_name), |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 665 | conv_name_to_c(prop.name), |
Simon Glass | 3deeb47 | 2017-08-29 14:15:59 -0600 | [diff] [blame] | 666 | len(info.args))) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 667 | else: |
| 668 | ptype = TYPE_NAMES[prop.type] |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 669 | self.out('\t%s%s' % (tab_to(2, ptype), |
| 670 | conv_name_to_c(prop.name))) |
| 671 | if isinstance(prop.value, list): |
| 672 | self.out('[%d]' % len(prop.value)) |
| 673 | self.out(';\n') |
| 674 | self.out('};\n') |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 675 | |
Simon Glass | 9d98b6e | 2020-12-23 08:11:20 -0700 | [diff] [blame] | 676 | def _output_list(self, node, prop): |
| 677 | """Output the C code for a devicetree property that holds a list |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 678 | |
| 679 | Args: |
Simon Glass | 9d98b6e | 2020-12-23 08:11:20 -0700 | [diff] [blame] | 680 | node (fdt.Node): Node to output |
| 681 | prop (fdt.Prop): Prop to output |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 682 | """ |
Simon Glass | 9d98b6e | 2020-12-23 08:11:20 -0700 | [diff] [blame] | 683 | self.buf('{') |
| 684 | vals = [] |
| 685 | # For phandles, output a reference to the platform data |
| 686 | # of the target node. |
| 687 | info = self.get_phandle_argc(prop, node.name) |
| 688 | if info: |
| 689 | # Process the list as pairs of (phandle, id) |
| 690 | pos = 0 |
| 691 | for args in info.args: |
| 692 | phandle_cell = prop.value[pos] |
| 693 | phandle = fdt_util.fdt32_to_cpu(phandle_cell) |
| 694 | target_node = self._fdt.phandle_to_node[phandle] |
| 695 | arg_values = [] |
| 696 | for i in range(args): |
| 697 | arg_values.append( |
| 698 | str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i]))) |
| 699 | pos += 1 + args |
| 700 | vals.append('\t{%d, {%s}}' % (target_node.idx, |
| 701 | ', '.join(arg_values))) |
| 702 | for val in vals: |
| 703 | self.buf('\n\t\t%s,' % val) |
| 704 | else: |
| 705 | for val in prop.value: |
| 706 | vals.append(get_value(prop.type, val)) |
Simon Glass | bc9e268 | 2020-10-03 09:25:18 -0600 | [diff] [blame] | 707 | |
Simon Glass | 9d98b6e | 2020-12-23 08:11:20 -0700 | [diff] [blame] | 708 | # Put 8 values per line to avoid very long lines. |
| 709 | for i in range(0, len(vals), 8): |
| 710 | if i: |
| 711 | self.buf(',\n\t\t') |
| 712 | self.buf(', '.join(vals[i:i + 8])) |
| 713 | self.buf('}') |
Simon Glass | bc9e268 | 2020-10-03 09:25:18 -0600 | [diff] [blame] | 714 | |
Simon Glass | 9fdd0c3 | 2020-12-23 08:11:21 -0700 | [diff] [blame] | 715 | def _declare_device(self, var_name, struct_name, node_parent): |
| 716 | """Add a device declaration to the output |
| 717 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 718 | This declares a U_BOOT_DRVINFO() for the device being processed |
Simon Glass | 9fdd0c3 | 2020-12-23 08:11:21 -0700 | [diff] [blame] | 719 | |
| 720 | Args: |
| 721 | var_name (str): C name for the node |
| 722 | struct_name (str): Name for the dt struct associated with the node |
| 723 | node_parent (Node): Parent of the node (or None if none) |
| 724 | """ |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 725 | self.buf('U_BOOT_DRVINFO(%s) = {\n' % var_name) |
Simon Glass | 9fdd0c3 | 2020-12-23 08:11:21 -0700 | [diff] [blame] | 726 | self.buf('\t.name\t\t= "%s",\n' % struct_name) |
| 727 | self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name)) |
| 728 | self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name)) |
| 729 | idx = -1 |
| 730 | if node_parent and node_parent in self._valid_nodes: |
| 731 | idx = node_parent.idx |
| 732 | self.buf('\t.parent_idx\t= %d,\n' % idx) |
| 733 | self.buf('};\n') |
| 734 | self.buf('\n') |
| 735 | |
Simon Glass | 9829eea | 2020-12-23 08:11:22 -0700 | [diff] [blame] | 736 | def _output_prop(self, node, prop): |
| 737 | """Output a line containing the value of a struct member |
| 738 | |
| 739 | Args: |
| 740 | node (Node): Node being output |
| 741 | prop (Prop): Prop object to output |
| 742 | """ |
| 743 | if prop.name in PROP_IGNORE_LIST or prop.name[0] == '#': |
| 744 | return |
| 745 | member_name = conv_name_to_c(prop.name) |
| 746 | self.buf('\t%s= ' % tab_to(3, '.' + member_name)) |
| 747 | |
| 748 | # Special handling for lists |
| 749 | if isinstance(prop.value, list): |
| 750 | self._output_list(node, prop) |
| 751 | else: |
| 752 | self.buf(get_value(prop.type, prop.value)) |
| 753 | self.buf(',\n') |
| 754 | |
| 755 | def _output_values(self, var_name, struct_name, node): |
| 756 | """Output the definition of a device's struct values |
| 757 | |
| 758 | Args: |
| 759 | var_name (str): C name for the node |
| 760 | struct_name (str): Name for the dt struct associated with the node |
| 761 | node (Node): Node being output |
| 762 | """ |
| 763 | self.buf('static struct %s%s %s%s = {\n' % |
| 764 | (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name)) |
| 765 | for pname in sorted(node.props): |
| 766 | self._output_prop(node, node.props[pname]) |
| 767 | self.buf('};\n') |
| 768 | |
Simon Glass | 9d98b6e | 2020-12-23 08:11:20 -0700 | [diff] [blame] | 769 | def output_node(self, node): |
| 770 | """Output the C code for a node |
Simon Glass | bc9e268 | 2020-10-03 09:25:18 -0600 | [diff] [blame] | 771 | |
Simon Glass | 9d98b6e | 2020-12-23 08:11:20 -0700 | [diff] [blame] | 772 | Args: |
| 773 | node (fdt.Node): node to output |
| 774 | """ |
Walter Lozano | e675d96 | 2020-07-03 08:07:17 -0300 | [diff] [blame] | 775 | struct_name, _ = self.get_normalized_compat_name(node) |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 776 | var_name = conv_name_to_c(node.name) |
Simon Glass | 192f813 | 2020-10-03 11:31:25 -0600 | [diff] [blame] | 777 | self.buf('/* Node %s index %d */\n' % (node.path, node.idx)) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 778 | |
Simon Glass | 9829eea | 2020-12-23 08:11:22 -0700 | [diff] [blame] | 779 | self._output_values(var_name, struct_name, node) |
Simon Glass | 9fdd0c3 | 2020-12-23 08:11:21 -0700 | [diff] [blame] | 780 | self._declare_device(var_name, struct_name, node.parent) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 781 | |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 782 | self.out(''.join(self.get_buf())) |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 783 | |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 784 | def generate_plat(self): |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 785 | """Generate device defintions for the platform data |
| 786 | |
| 787 | This writes out C platform data initialisation data and |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 788 | U_BOOT_DRVINFO() declarations for each valid node. Where a node has |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 789 | multiple compatible strings, a #define is used to make them equivalent. |
| 790 | |
Heinrich Schuchardt | c79f03c | 2020-02-25 21:35:39 +0100 | [diff] [blame] | 791 | See the documentation in doc/driver-model/of-plat.rst for more |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 792 | information. |
| 793 | """ |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 794 | self.out('/* Allow use of U_BOOT_DRVINFO() in this file */\n') |
Simon Glass | beddd7a | 2020-12-28 20:35:01 -0700 | [diff] [blame] | 795 | self.out('#define DT_PLAT_C\n') |
Simon Glass | 4c73d7b | 2020-10-03 11:31:41 -0600 | [diff] [blame] | 796 | self.out('\n') |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 797 | self.out('#include <common.h>\n') |
| 798 | self.out('#include <dm.h>\n') |
| 799 | self.out('#include <dt-structs.h>\n') |
| 800 | self.out('\n') |
Simon Glass | d570dec | 2017-06-18 22:08:58 -0600 | [diff] [blame] | 801 | |
Simon Glass | 16382ce | 2020-12-28 20:35:04 -0700 | [diff] [blame^] | 802 | for node in self._valid_nodes: |
Simon Glass | 1f730c8 | 2017-06-18 22:08:59 -0600 | [diff] [blame] | 803 | self.output_node(node) |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 804 | |
Walter Lozano | dc5b437 | 2020-06-25 01:10:13 -0300 | [diff] [blame] | 805 | # Define dm_populate_phandle_data() which will add the linking between |
Simon Glass | e10c0ff | 2020-12-28 20:34:55 -0700 | [diff] [blame] | 806 | # nodes using DM_DRVINFO_GET |
| 807 | # dtv_dmc_at_xxx.clocks[0].node = DM_DRVINFO_GET(clock_controller_at_xxx) |
Walter Lozano | dc5b437 | 2020-06-25 01:10:13 -0300 | [diff] [blame] | 808 | self.buf('void dm_populate_phandle_data(void) {\n') |
Walter Lozano | dc5b437 | 2020-06-25 01:10:13 -0300 | [diff] [blame] | 809 | self.buf('}\n') |
| 810 | |
| 811 | self.out(''.join(self.get_buf())) |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 812 | |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 813 | |
| 814 | # Types of output file we understand |
| 815 | # key: Command used to generate this file |
| 816 | # value: OutputFile for this command |
| 817 | OUTPUT_FILES = { |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 818 | 'struct': |
| 819 | OutputFile(Ftype.HEADER, 'dt-structs-gen.h', |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 820 | DtbPlatdata.generate_structs, |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 821 | 'Defines the structs used to hold devicetree data'), |
| 822 | 'platdata': |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 823 | OutputFile(Ftype.SOURCE, 'dt-plat.c', DtbPlatdata.generate_plat, |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 824 | 'Declares the U_BOOT_DRIVER() records and platform data'), |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 825 | } |
| 826 | |
Simon Glass | 6a65d8a | 2020-12-28 20:34:50 -0700 | [diff] [blame] | 827 | |
| 828 | def run_steps(args, dtb_file, include_disabled, output, output_dirs, |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 829 | warning_disabled=False, drivers_additional=None, basedir=None): |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 830 | """Run all the steps of the dtoc tool |
| 831 | |
| 832 | Args: |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 833 | args (list): List of non-option arguments provided to the problem |
| 834 | dtb_file (str): Filename of dtb file to process |
| 835 | include_disabled (bool): True to include disabled nodes |
Simon Glass | 6ca0c7a | 2020-12-28 20:34:48 -0700 | [diff] [blame] | 836 | output (str): Name of output file (None for stdout) |
Simon Glass | 6a65d8a | 2020-12-28 20:34:50 -0700 | [diff] [blame] | 837 | output_dirs (tuple of str): |
| 838 | Directory to put C output files |
| 839 | Directory to put H output files |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 840 | warning_disabled (bool): True to avoid showing warnings about missing |
| 841 | drivers |
Simon Glass | 2751123 | 2020-12-23 08:11:19 -0700 | [diff] [blame] | 842 | drivers_additional (list): List of additional drivers to use during |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 843 | scanning |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 844 | basedir (str): Base directory of U-Boot source code. Defaults to the |
| 845 | grandparent of this file's directory |
Simon Glass | 94ee3bd | 2020-11-08 20:36:21 -0700 | [diff] [blame] | 846 | Raises: |
| 847 | ValueError: if args has no command, or an unknown command |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 848 | """ |
| 849 | if not args: |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 850 | raise ValueError('Please specify a command: struct, platdata, all') |
| 851 | if output and output_dirs and any(output_dirs): |
| 852 | raise ValueError('Must specify either output or output_dirs, not both') |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 853 | |
Simon Glass | 93daa01 | 2020-12-03 16:55:16 -0700 | [diff] [blame] | 854 | plat = DtbPlatdata(dtb_file, include_disabled, warning_disabled, |
| 855 | drivers_additional) |
Simon Glass | 4f2059b | 2020-12-28 20:35:03 -0700 | [diff] [blame] | 856 | plat.scan_drivers(basedir) |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 857 | plat.scan_dtb() |
| 858 | plat.scan_tree() |
Simon Glass | 1b1fe41 | 2017-08-29 14:15:50 -0600 | [diff] [blame] | 859 | plat.scan_reg_sizes() |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 860 | plat.setup_output_dirs(output_dirs) |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 861 | plat.scan_structs() |
Simon Glass | 3fa797a | 2017-06-18 22:09:03 -0600 | [diff] [blame] | 862 | plat.scan_phandles() |
| 863 | |
Simon Glass | 4e8e846 | 2020-12-28 20:34:52 -0700 | [diff] [blame] | 864 | cmds = args[0].split(',') |
| 865 | if 'all' in cmds: |
| 866 | cmds = sorted(OUTPUT_FILES.keys()) |
| 867 | for cmd in cmds: |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 868 | outfile = OUTPUT_FILES.get(cmd) |
| 869 | if not outfile: |
| 870 | raise ValueError("Unknown command '%s': (use: %s)" % |
Simon Glass | 4e8e846 | 2020-12-28 20:34:52 -0700 | [diff] [blame] | 871 | (cmd, ', '.join(sorted(OUTPUT_FILES.keys())))) |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 872 | plat.setup_output(outfile.ftype, |
| 873 | outfile.fname if output_dirs else output) |
Simon Glass | 6b20884 | 2020-12-28 20:35:00 -0700 | [diff] [blame] | 874 | plat.out_header(outfile) |
Simon Glass | 5552678 | 2020-12-28 20:35:02 -0700 | [diff] [blame] | 875 | outfile.method(plat) |
Simon Glass | c3a310a8 | 2020-12-28 20:34:51 -0700 | [diff] [blame] | 876 | plat.finish_output() |