Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Core driver model support for ACPI table generation |
| 4 | * |
| 5 | * Copyright 2019 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #define LOG_CATEOGRY LOGC_ACPI |
| 10 | |
| 11 | #include <common.h> |
Simon Glass | 1ab1692 | 2022-07-31 12:28:48 -0600 | [diff] [blame] | 12 | #include <display_options.h> |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 13 | #include <dm.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 14 | #include <log.h> |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 15 | #include <malloc.h> |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 16 | #include <mapmem.h> |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 17 | #include <acpi/acpi_device.h> |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 18 | #include <dm/acpi.h> |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 19 | #include <dm/device-internal.h> |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 20 | #include <dm/root.h> |
| 21 | |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 22 | #define MAX_ACPI_ITEMS 100 |
| 23 | |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 24 | /** |
| 25 | * Type of table that we collected |
| 26 | * |
| 27 | * @TYPE_NONE: Not yet known |
| 28 | * @TYPE_SSDT: Items in the Secondary System Description Table |
| 29 | * @TYPE_DSDT: Items in the Differentiated System Description Table |
| 30 | * @TYPE_OTHER: Other (whole) |
| 31 | */ |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 32 | enum gen_type_t { |
| 33 | TYPE_NONE, |
| 34 | TYPE_SSDT, |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 35 | TYPE_DSDT, |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 36 | TYPE_OTHER, |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 37 | }; |
| 38 | |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 39 | const char *gen_type_str[] = { |
| 40 | "-", |
| 41 | "ssdt", |
| 42 | "dsdt", |
| 43 | "other", |
| 44 | }; |
| 45 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 46 | /* Type of method to call */ |
| 47 | enum method_t { |
| 48 | METHOD_WRITE_TABLES, |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 49 | METHOD_FILL_SSDT, |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 50 | METHOD_INJECT_DSDT, |
Simon Glass | cd9667b | 2020-07-07 21:32:08 -0600 | [diff] [blame] | 51 | METHOD_SETUP_NHLT, |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | /* Prototype for all methods */ |
| 55 | typedef int (*acpi_method)(const struct udevice *dev, struct acpi_ctx *ctx); |
| 56 | |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 57 | /** |
| 58 | * struct acpi_item - Holds info about ACPI data generated by a driver method |
| 59 | * |
| 60 | * @dev: Device that generated this data |
| 61 | * @type: Table type it refers to |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 62 | * @writer: Writer that wrote this table |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 63 | * @base: Pointer to base of table in its original location |
| 64 | * @buf: Buffer allocated to contain the data (NULL if not allocated) |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 65 | * @size: Size of the data in bytes |
| 66 | */ |
| 67 | struct acpi_item { |
| 68 | struct udevice *dev; |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 69 | const struct acpi_writer *writer; |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 70 | enum gen_type_t type; |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 71 | const char *base; |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 72 | char *buf; |
| 73 | int size; |
| 74 | }; |
| 75 | |
| 76 | /* List of ACPI items collected */ |
| 77 | static struct acpi_item acpi_item[MAX_ACPI_ITEMS]; |
| 78 | static int item_count; |
| 79 | |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 80 | int acpi_copy_name(char *out_name, const char *name) |
| 81 | { |
| 82 | strncpy(out_name, name, ACPI_NAME_LEN); |
| 83 | out_name[ACPI_NAME_LEN] = '\0'; |
| 84 | |
| 85 | return 0; |
| 86 | } |
| 87 | |
| 88 | int acpi_get_name(const struct udevice *dev, char *out_name) |
| 89 | { |
| 90 | struct acpi_ops *aops; |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 91 | const char *name; |
| 92 | int ret; |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 93 | |
| 94 | aops = device_get_acpi_ops(dev); |
| 95 | if (aops && aops->get_name) |
| 96 | return aops->get_name(dev, out_name); |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 97 | name = dev_read_string(dev, "acpi,name"); |
| 98 | if (name) |
| 99 | return acpi_copy_name(out_name, name); |
| 100 | ret = acpi_device_infer_name(dev, out_name); |
| 101 | if (ret) |
| 102 | return log_msg_ret("dev", ret); |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 103 | |
Simon Glass | 0964239 | 2020-07-07 13:12:11 -0600 | [diff] [blame] | 104 | return 0; |
Simon Glass | 9fb9e9b | 2020-04-09 10:27:38 -0600 | [diff] [blame] | 105 | } |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 106 | |
Simon Glass | 0123233 | 2020-07-07 21:32:07 -0600 | [diff] [blame] | 107 | int acpi_get_path(const struct udevice *dev, char *out_path, int maxlen) |
| 108 | { |
| 109 | const char *path; |
| 110 | int ret; |
| 111 | |
| 112 | path = dev_read_string(dev, "acpi,path"); |
| 113 | if (path) { |
| 114 | if (strlen(path) >= maxlen) |
Simon Glass | e74f8f8 | 2021-03-25 10:26:04 +1300 | [diff] [blame] | 115 | return -ENOSPC; |
Simon Glass | 0123233 | 2020-07-07 21:32:07 -0600 | [diff] [blame] | 116 | strcpy(out_path, path); |
| 117 | return 0; |
| 118 | } |
| 119 | ret = acpi_device_path(dev, out_path, maxlen); |
| 120 | if (ret) |
| 121 | return log_msg_ret("dev", ret); |
| 122 | |
| 123 | return 0; |
| 124 | } |
| 125 | |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 126 | /** |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 127 | * add_item() - Add a new item to the list of data collected |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 128 | * |
| 129 | * @ctx: ACPI context |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 130 | * @dev: Device that generated the data, if type != TYPE_OTHER |
| 131 | * @writer: Writer entry that generated the data, if type == TYPE_OTHER |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 132 | * @type: Table type it refers to |
| 133 | * @start: The start of the data (the end is obtained from ctx->current) |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 134 | * Return: 0 if OK, -ENOSPC if too many items, -ENOMEM if out of memory |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 135 | */ |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 136 | static int add_item(struct acpi_ctx *ctx, struct udevice *dev, |
| 137 | const struct acpi_writer *writer, enum gen_type_t type, |
| 138 | void *start) |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 139 | { |
| 140 | struct acpi_item *item; |
| 141 | void *end = ctx->current; |
| 142 | |
| 143 | if (item_count == MAX_ACPI_ITEMS) { |
| 144 | log_err("Too many items\n"); |
| 145 | return log_msg_ret("mem", -ENOSPC); |
| 146 | } |
| 147 | |
| 148 | item = &acpi_item[item_count]; |
| 149 | item->dev = dev; |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 150 | item->writer = writer; |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 151 | item->type = type; |
| 152 | item->size = end - start; |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 153 | item->base = start; |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 154 | if (!item->size) |
| 155 | return 0; |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 156 | if (type != TYPE_OTHER) { |
| 157 | item->buf = malloc(item->size); |
| 158 | if (!item->buf) |
| 159 | return log_msg_ret("mem", -ENOMEM); |
| 160 | memcpy(item->buf, start, item->size); |
| 161 | } |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 162 | item_count++; |
Heinrich Schuchardt | 3111225 | 2022-07-10 15:40:22 +0200 | [diff] [blame] | 163 | log_debug("* %s: Added type %d, %p, size %x\n", |
| 164 | dev ? dev->name : "other", type, start, item->size); |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 165 | |
| 166 | return 0; |
| 167 | } |
| 168 | |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 169 | int acpi_add_other_item(struct acpi_ctx *ctx, const struct acpi_writer *writer, |
| 170 | void *start) |
| 171 | { |
| 172 | return add_item(ctx, NULL, writer, TYPE_OTHER, start); |
| 173 | } |
| 174 | |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 175 | void acpi_dump_items(enum acpi_dump_option option) |
| 176 | { |
| 177 | int i; |
| 178 | |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 179 | printf("Seq Type Base Size Device/Writer\n"); |
| 180 | printf("--- ----- -------- ---- -------------\n"); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 181 | for (i = 0; i < item_count; i++) { |
| 182 | struct acpi_item *item = &acpi_item[i]; |
| 183 | |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 184 | printf("%3x %-5s %8lx %5x %s\n", i, |
| 185 | gen_type_str[item->type], |
| 186 | (ulong)map_to_sysmem(item->base), item->size, |
| 187 | item->dev ? item->dev->name : item->writer->name); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 188 | if (option == ACPI_DUMP_CONTENTS) { |
Simon Glass | 884dcfa | 2021-12-01 09:03:05 -0700 | [diff] [blame] | 189 | print_buffer(0, item->buf ? item->buf : item->base, 1, |
| 190 | item->size, 0); |
Simon Glass | 64bbc0d | 2020-07-07 13:12:12 -0600 | [diff] [blame] | 191 | printf("\n"); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 196 | static struct acpi_item *find_acpi_item(const char *devname) |
| 197 | { |
| 198 | int i; |
| 199 | |
| 200 | for (i = 0; i < item_count; i++) { |
| 201 | struct acpi_item *item = &acpi_item[i]; |
| 202 | |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 203 | if (item->dev && !strcmp(devname, item->dev->name)) |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 204 | return item; |
| 205 | } |
| 206 | |
| 207 | return NULL; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * sort_acpi_item_type - Sort the ACPI items into the desired order |
| 212 | * |
| 213 | * This looks up the ordering in the device tree and then adds each item one by |
| 214 | * one into the supplied buffer |
| 215 | * |
| 216 | * @ctx: ACPI context |
| 217 | * @start: Start position to put the sorted items. The items will follow each |
| 218 | * other in sorted order |
| 219 | * @type: Type of items to sort |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 220 | * Return: 0 if OK, -ve on error |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 221 | */ |
| 222 | static int sort_acpi_item_type(struct acpi_ctx *ctx, void *start, |
| 223 | enum gen_type_t type) |
| 224 | { |
| 225 | const u32 *order; |
| 226 | int size; |
| 227 | int count; |
| 228 | void *ptr; |
| 229 | void *end = ctx->current; |
| 230 | |
| 231 | ptr = start; |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 232 | order = ofnode_read_chosen_prop(type == TYPE_DSDT ? |
| 233 | "u-boot,acpi-dsdt-order" : |
| 234 | "u-boot,acpi-ssdt-order", &size); |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 235 | if (!order) { |
Simon Glass | 92136c1 | 2020-07-17 08:49:25 -0600 | [diff] [blame] | 236 | log_debug("Failed to find ordering, leaving as is\n"); |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | /* |
| 241 | * This algorithm rewrites the context buffer without changing its |
| 242 | * length. So there is no need to update ctx-current |
| 243 | */ |
| 244 | count = size / sizeof(u32); |
| 245 | while (count--) { |
| 246 | struct acpi_item *item; |
| 247 | const char *name; |
| 248 | ofnode node; |
| 249 | |
| 250 | node = ofnode_get_by_phandle(fdt32_to_cpu(*order++)); |
| 251 | name = ofnode_get_name(node); |
| 252 | item = find_acpi_item(name); |
| 253 | if (!item) { |
| 254 | log_err("Failed to find item '%s'\n", name); |
| 255 | return log_msg_ret("find", -ENOENT); |
| 256 | } |
| 257 | if (item->type == type) { |
| 258 | log_debug(" - add %s\n", item->dev->name); |
| 259 | memcpy(ptr, item->buf, item->size); |
| 260 | ptr += item->size; |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | /* |
| 265 | * If the sort order is missing an item then the output will be too |
| 266 | * small. Report this error since the item needs to be added to the |
| 267 | * ordering for the ACPI tables to be complete. |
| 268 | */ |
| 269 | if (ptr != end) { |
| 270 | log_warning("*** Missing bytes: ptr=%p, end=%p\n", ptr, end); |
| 271 | return -ENXIO; |
| 272 | } |
| 273 | |
| 274 | return 0; |
| 275 | } |
| 276 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 277 | acpi_method acpi_get_method(struct udevice *dev, enum method_t method) |
| 278 | { |
| 279 | struct acpi_ops *aops; |
| 280 | |
| 281 | aops = device_get_acpi_ops(dev); |
| 282 | if (aops) { |
| 283 | switch (method) { |
| 284 | case METHOD_WRITE_TABLES: |
| 285 | return aops->write_tables; |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 286 | case METHOD_FILL_SSDT: |
| 287 | return aops->fill_ssdt; |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 288 | case METHOD_INJECT_DSDT: |
| 289 | return aops->inject_dsdt; |
Simon Glass | cd9667b | 2020-07-07 21:32:08 -0600 | [diff] [blame] | 290 | case METHOD_SETUP_NHLT: |
| 291 | return aops->setup_nhlt; |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
| 295 | return NULL; |
| 296 | } |
| 297 | |
| 298 | int acpi_recurse_method(struct acpi_ctx *ctx, struct udevice *parent, |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 299 | enum method_t method, enum gen_type_t type) |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 300 | { |
| 301 | struct udevice *dev; |
| 302 | acpi_method func; |
| 303 | int ret; |
| 304 | |
| 305 | func = acpi_get_method(parent, method); |
| 306 | if (func) { |
Simon Glass | a385d49 | 2020-11-04 09:57:33 -0700 | [diff] [blame] | 307 | log_debug("- method %d, %s %p\n", method, parent->name, func); |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 308 | ret = device_of_to_plat(parent); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 309 | if (ret) |
| 310 | return log_msg_ret("ofdata", ret); |
Simon Glass | f93b904 | 2021-12-01 09:02:46 -0700 | [diff] [blame] | 311 | ctx->tab_start = ctx->current; |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 312 | ret = func(parent, ctx); |
| 313 | if (ret) |
| 314 | return log_msg_ret("func", ret); |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 315 | |
| 316 | /* Add the item to the internal list */ |
| 317 | if (type != TYPE_NONE) { |
Simon Glass | 877205e | 2021-12-01 09:03:04 -0700 | [diff] [blame] | 318 | ret = add_item(ctx, parent, NULL, type, ctx->tab_start); |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 319 | if (ret) |
| 320 | return log_msg_ret("add", ret); |
| 321 | } |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 322 | } |
| 323 | device_foreach_child(dev, parent) { |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 324 | ret = acpi_recurse_method(ctx, dev, method, type); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 325 | if (ret) |
| 326 | return log_msg_ret("recurse", ret); |
| 327 | } |
| 328 | |
| 329 | return 0; |
| 330 | } |
| 331 | |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 332 | int acpi_fill_ssdt(struct acpi_ctx *ctx) |
| 333 | { |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 334 | void *start = ctx->current; |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 335 | int ret; |
| 336 | |
| 337 | log_debug("Writing SSDT tables\n"); |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 338 | ret = acpi_recurse_method(ctx, dm_root(), METHOD_FILL_SSDT, TYPE_SSDT); |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 339 | log_debug("Writing SSDT finished, err=%d\n", ret); |
Simon Glass | 3c601b1 | 2020-07-07 13:12:06 -0600 | [diff] [blame] | 340 | ret = sort_acpi_item_type(ctx, start, TYPE_SSDT); |
| 341 | if (ret) |
| 342 | return log_msg_ret("build", ret); |
Simon Glass | d43e0ba | 2020-07-07 13:12:03 -0600 | [diff] [blame] | 343 | |
| 344 | return ret; |
| 345 | } |
| 346 | |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 347 | int acpi_inject_dsdt(struct acpi_ctx *ctx) |
| 348 | { |
| 349 | void *start = ctx->current; |
| 350 | int ret; |
| 351 | |
| 352 | log_debug("Writing DSDT tables\n"); |
Simon Glass | 990cd5b | 2020-07-07 13:12:08 -0600 | [diff] [blame] | 353 | ret = acpi_recurse_method(ctx, dm_root(), METHOD_INJECT_DSDT, |
| 354 | TYPE_DSDT); |
| 355 | log_debug("Writing DSDT finished, err=%d\n", ret); |
| 356 | ret = sort_acpi_item_type(ctx, start, TYPE_DSDT); |
| 357 | if (ret) |
| 358 | return log_msg_ret("build", ret); |
| 359 | |
| 360 | return ret; |
| 361 | } |
| 362 | |
Simon Glass | a385d49 | 2020-11-04 09:57:33 -0700 | [diff] [blame] | 363 | void acpi_reset_items(void) |
| 364 | { |
| 365 | item_count = 0; |
| 366 | } |
| 367 | |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 368 | int acpi_write_dev_tables(struct acpi_ctx *ctx) |
| 369 | { |
| 370 | int ret; |
| 371 | |
| 372 | log_debug("Writing device tables\n"); |
Simon Glass | ee61e60 | 2020-07-07 13:12:05 -0600 | [diff] [blame] | 373 | ret = acpi_recurse_method(ctx, dm_root(), METHOD_WRITE_TABLES, |
| 374 | TYPE_NONE); |
Simon Glass | 17968c3 | 2020-04-26 09:19:46 -0600 | [diff] [blame] | 375 | log_debug("Writing finished, err=%d\n", ret); |
| 376 | |
| 377 | return ret; |
| 378 | } |
Simon Glass | cd9667b | 2020-07-07 21:32:08 -0600 | [diff] [blame] | 379 | |
| 380 | int acpi_setup_nhlt(struct acpi_ctx *ctx, struct nhlt *nhlt) |
| 381 | { |
| 382 | int ret; |
| 383 | |
| 384 | log_debug("Setup NHLT\n"); |
| 385 | ctx->nhlt = nhlt; |
| 386 | ret = acpi_recurse_method(ctx, dm_root(), METHOD_SETUP_NHLT, TYPE_NONE); |
| 387 | log_debug("Setup finished, err=%d\n", ret); |
| 388 | |
| 389 | return ret; |
| 390 | } |