Commit c654b5172a65faba2b541ee1fda1738534d47241
1 parent
6f4dbc21e4
Exists in
v2017.01-smarct4x
and in
37 other branches
fdt: Add ft_system_setup() function for system device tree additions
Add an additional function for adding information to the device tree before booting. This permits additions which are not board-specific. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Anatolij Gustschin <agust@denx.de> Reviewed-by: Tom Rini <trini@ti.com>
Showing 5 changed files with 48 additions and 1 deletions Side-by-side Diff
README
... | ... | @@ -669,6 +669,13 @@ |
669 | 669 | Board code has addition modification that it wants to make |
670 | 670 | to the flat device tree before handing it off to the kernel |
671 | 671 | |
672 | + CONFIG_OF_SYSTEM_SETUP | |
673 | + | |
674 | + Other code has addition modification that it wants to make | |
675 | + to the flat device tree before handing it off to the kernel. | |
676 | + This causes ft_system_setup() to be called before booting | |
677 | + the kernel. | |
678 | + | |
672 | 679 | CONFIG_OF_BOOT_CPU |
673 | 680 | |
674 | 681 | This define fills in the correct boot CPU in the boot |
... | ... | @@ -3407,7 +3414,7 @@ |
3407 | 3414 | to 128 or 256, although it does not have to be power of 2). |
3408 | 3415 | |
3409 | 3416 | default: 4096 |
3410 | - | |
3417 | + | |
3411 | 3418 | CONFIG_MTD_UBI_BEB_LIMIT |
3412 | 3419 | This option specifies the maximum bad physical eraseblocks UBI |
3413 | 3420 | expects on the MTD device (per 1024 eraseblocks). If the |
common/cmd_fdt.c
... | ... | @@ -576,6 +576,18 @@ |
576 | 576 | } |
577 | 577 | } |
578 | 578 | #endif |
579 | +#ifdef CONFIG_OF_SYSTEM_SETUP | |
580 | + /* Call the board-specific fixup routine */ | |
581 | + else if (strncmp(argv[1], "sys", 3) == 0) { | |
582 | + int err = ft_system_setup(working_fdt, gd->bd); | |
583 | + | |
584 | + if (err) { | |
585 | + printf("Failed to add system information to FDT: %s\n", | |
586 | + fdt_strerror(err)); | |
587 | + return CMD_RET_FAILURE; | |
588 | + } | |
589 | + } | |
590 | +#endif | |
579 | 591 | /* Create a chosen node */ |
580 | 592 | else if (strncmp(argv[1], "cho", 3) == 0) { |
581 | 593 | unsigned long initrd_start = 0, initrd_end = 0; |
... | ... | @@ -1014,6 +1026,9 @@ |
1014 | 1026 | "addr [-c] <addr> [<length>] - Set the [control] fdt location to <addr>\n" |
1015 | 1027 | #ifdef CONFIG_OF_BOARD_SETUP |
1016 | 1028 | "fdt boardsetup - Do board-specific set up\n" |
1029 | +#endif | |
1030 | +#ifdef CONFIG_OF_SYSTEM_SETUP | |
1031 | + "fdt systemsetup - Do system-specific set up\n" | |
1017 | 1032 | #endif |
1018 | 1033 | "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active\n" |
1019 | 1034 | "fdt resize - Resize fdt to size + padding to 4k addr\n" |
common/image-fdt.c
... | ... | @@ -479,6 +479,13 @@ |
479 | 479 | goto err; |
480 | 480 | } |
481 | 481 | } |
482 | + if (IMAGE_OF_SYSTEM_SETUP) { | |
483 | + if (ft_system_setup(blob, gd->bd)) { | |
484 | + printf("ERROR: system-specific fdt fixup failed: %s\n", | |
485 | + fdt_strerror(fdt_ret)); | |
486 | + goto err; | |
487 | + } | |
488 | + } | |
482 | 489 | fdt_fixup_ethernet(blob); |
483 | 490 | |
484 | 491 | /* Delete the old LMB reservation */ |
include/fdt_support.h
... | ... | @@ -88,6 +88,18 @@ |
88 | 88 | void ft_cpu_setup(void *blob, bd_t *bd); |
89 | 89 | void ft_pci_setup(void *blob, bd_t *bd); |
90 | 90 | |
91 | +/** | |
92 | + * Add system-specific data to the FDT before booting the OS. | |
93 | + * | |
94 | + * Use CONFIG_SYS_FDT_PAD to ensure there is sufficient space. | |
95 | + * This function is called if CONFIG_OF_SYSTEM_SETUP is defined | |
96 | + * | |
97 | + * @param blob FDT blob to update | |
98 | + * @param bd_t Pointer to board data | |
99 | + * @return 0 if ok, or -FDT_ERR_... on error | |
100 | + */ | |
101 | +int ft_system_setup(void *blob, bd_t *bd); | |
102 | + | |
91 | 103 | void set_working_fdt_addr(void *addr); |
92 | 104 | int fdt_shrink_to_minimum(void *blob); |
93 | 105 | int fdt_increase_size(void *fdt, int add_len); |
include/image.h