diff options
Diffstat (limited to 'commands/of_overlay.c')
-rw-r--r-- | commands/of_overlay.c | 64 |
1 files changed, 29 insertions, 35 deletions
diff --git a/commands/of_overlay.c b/commands/of_overlay.c index de3c3dcee5..2013c4b278 100644 --- a/commands/of_overlay.c +++ b/commands/of_overlay.c @@ -1,19 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2019 Michael Tretter <m.tretter@pengutronix.de>, Pengutronix - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: © 2019 Michael Tretter <m.tretter@pengutronix.de>, Pengutronix #include <command.h> #include <common.h> @@ -24,45 +10,46 @@ #include <getopt.h> #include <libfile.h> #include <of.h> +#include <linux/clk.h> static int do_of_overlay(int argc, char *argv[]) { - int opt, ret; - struct fdt_header *fdt; + int ret; struct device_node *overlay; - const char *search_path = NULL; + bool live_tree = false; + int opt; - while ((opt = getopt(argc, argv, "S:")) > 0) { + while ((opt = getopt(argc, argv, "l")) > 0) { switch (opt) { - case 'S': - search_path = optarg; + case 'l': + live_tree = true; break; - default: - return COMMAND_ERROR_USAGE; } } if (argc != optind + 1) return COMMAND_ERROR_USAGE; - fdt = read_file(argv[optind], NULL); - if (!fdt) { - printf("cannot read %s\n", argv[optind]); + if (live_tree && !IS_ENABLED(CONFIG_OF_OVERLAY_LIVE)) { + printf("Support for live tree overlays is disabled. Enable CONFIG_OF_OVERLAY_LIVE\n"); return 1; } - overlay = of_unflatten_dtb(fdt); - free(fdt); + overlay = of_read_file(argv[optind]); if (IS_ERR(overlay)) return PTR_ERR(overlay); - if (search_path) { - ret = of_firmware_load_overlay(overlay, search_path); + if (live_tree) { + ret = of_overlay_apply_tree(of_get_root_node(), overlay); if (ret) goto err; + + of_clk_init(); + of_probe(); + } else { + ret = of_register_overlay(overlay); } - ret = of_register_overlay(overlay); if (ret) { printf("cannot apply oftree overlay: %s\n", strerror(-ret)); goto err; @@ -76,14 +63,21 @@ err: } BAREBOX_CMD_HELP_START(of_overlay) +BAREBOX_CMD_HELP_TEXT("Register a device tree overlay file (dtbo) with barebox.") +BAREBOX_CMD_HELP_TEXT("By default the overlay is registered as a fixup and the") +BAREBOX_CMD_HELP_TEXT("overlay will then be applied to the Linux device tree.") +BAREBOX_CMD_HELP_TEXT("With -l given the overlay is applied to the barebox live") +BAREBOX_CMD_HELP_TEXT("tree instead. This involves probing new devices added in") +BAREBOX_CMD_HELP_TEXT("the overlay file.") +BAREBOX_CMD_HELP_TEXT("") BAREBOX_CMD_HELP_TEXT("Options:") -BAREBOX_CMD_HELP_OPT("-S path", "load firmware using this search path") +BAREBOX_CMD_HELP_OPT("-l", "apply to barebox live tree") BAREBOX_CMD_HELP_END BAREBOX_CMD_START(of_overlay) .cmd = do_of_overlay, - BAREBOX_CMD_DESC("register device tree overlay as fixup") - BAREBOX_CMD_OPTS("[-S path] FILE") + BAREBOX_CMD_DESC("register device tree overlay") + BAREBOX_CMD_OPTS("[-l] FILE") BAREBOX_CMD_GROUP(CMD_GRP_MISC) BAREBOX_CMD_HELP(cmd_of_overlay_help) BAREBOX_CMD_END |