a99555f949bb4c9f5565c704cbb04c932d677dd8
[oweals/openwrt.git] / target / linux / mpc85xx / patches-5.4 / 102-powerpc-add-cmdline-override.patch
1 --- a/arch/powerpc/Kconfig
2 +++ b/arch/powerpc/Kconfig
3 @@ -809,6 +809,14 @@ config CMDLINE_FORCE
4           This is useful if you cannot or don't want to change the
5           command-line options your boot loader passes to the kernel.
6  
7 +config CMDLINE_OVERRIDE
8 +    bool "Use alternative cmdline from device tree"
9 +    help
10 +      Some bootloaders may have uneditable bootargs. While CMDLINE_FORCE can
11 +      be used, this is not a good option for kernels that are shared across
12 +      devices. This setting enables using "chosen/cmdline-override" as the
13 +      cmdline if it exists in the device tree.
14 +
15  config EXTRA_TARGETS
16         string "Additional default image types"
17         help
18 --- a/drivers/of/fdt.c
19 +++ b/drivers/of/fdt.c
20 @@ -1091,6 +1091,17 @@ int __init early_init_dt_scan_chosen(uns
21         if (p != NULL && l > 0)
22                 strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
23  
24 +    /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
25 +     * device tree option of chosen/bootargs-override. This is
26 +     * helpful on boards where u-boot sets bootargs, and is unable
27 +     * to be modified.
28 +     */
29 +#ifdef CONFIG_CMDLINE_OVERRIDE
30 +       p = of_get_flat_dt_prop(node, "bootargs-override", &l);
31 +       if (p != NULL && l > 0)
32 +               strlcpy(data, p, min((int)l, COMMAND_LINE_SIZE));
33 +#endif
34 +
35         /*
36          * CONFIG_CMDLINE is meant to be a default in case nothing else
37          * managed to set the command line, unless CONFIG_CMDLINE_FORCE