From 06d6750e0d9647298da760c0e69d9479ac207c14 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Fri, 29 Dec 2017 18:08:30 +0000 Subject: [PATCH] stand/fdt: Consistently apply fdt_overlays Overlays were previously not applied when U-Boot provides FDT or EFI provides FDT, only when we load FDT from /boot/dtb given name from U-Boot. Make all three paths lead to loading fdt_overlays and applying them, so that fdt_overlays can be expected to Just Work. Reviewed by: gonzo, imp, manu Differential Revision: https://reviews.freebsd.org/D13664 --- stand/efi/fdt/efi_fdt.c | 20 ++++++++++++++------ stand/uboot/fdt/uboot_fdt.c | 5 ++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/stand/efi/fdt/efi_fdt.c b/stand/efi/fdt/efi_fdt.c index d6757689c896..5fcb6ad1588b 100644 --- a/stand/efi/fdt/efi_fdt.c +++ b/stand/efi/fdt/efi_fdt.c @@ -44,19 +44,27 @@ int fdt_platform_load_dtb(void) { struct fdt_header *hdr; + const char *s; hdr = efi_get_table(&fdtdtb); - if (hdr != NULL) { - if (fdt_load_dtb_addr(hdr) == 0) { - printf("Using DTB provided by EFI at %p.\n", hdr); - return (0); - } + if (hdr == NULL) + return (1); + if (fdt_load_dtb_addr(hdr) != 0) + return (1); + printf("Using DTB provided by EFI at %p.\n", hdr); + + s = getenv("fdt_overlays"); + if (s != NULL && *s != '\0') { + printf("Loading DTB overlays: '%s'\n", s); + fdt_load_dtb_overlays(s); } - return (1); + return (0); } void fdt_platform_fixups(void) { + + fdt_apply_overlays(); } diff --git a/stand/uboot/fdt/uboot_fdt.c b/stand/uboot/fdt/uboot_fdt.c index 186531005401..5d7581d699c4 100644 --- a/stand/uboot/fdt/uboot_fdt.c +++ b/stand/uboot/fdt/uboot_fdt.c @@ -64,7 +64,8 @@ fdt_platform_load_dtb(void) if (fdt_load_dtb_addr(hdr) == 0) { printf("Using DTB provided by U-Boot at " "address %p.\n", hdr); - return (0); + rv = 0; + goto exit; } } } @@ -83,9 +84,11 @@ fdt_platform_load_dtb(void) if (fdt_load_dtb_file(s) == 0) { printf("Loaded DTB from file '%s'.\n", s); rv = 0; + goto exit; } } +exit: if (rv == 0) { s = getenv("fdt_overlays"); if (s == NULL)