b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | --- a/arch/powerpc/Kconfig |
| 2 | +++ b/arch/powerpc/Kconfig |
| 3 | @@ -885,6 +885,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 | @@ -1060,6 +1060,17 @@ int __init early_init_dt_scan_chosen(uns |
| 21 | if (p != NULL && l > 0) |
| 22 | strlcpy(data, p, min(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 |