diff options
| author | Simon Glass <[email protected]> | 2023-07-12 09:04:42 -0600 |
|---|---|---|
| committer | Bin Meng <[email protected]> | 2023-07-17 13:38:35 +0800 |
| commit | 33ebcb468109c40ef0dce262be00a4c161265b90 (patch) | |
| tree | 7d2a0d0fd11a2d8c9329d2e83fb3f76ed8a39600 /boot | |
| parent | 63b7ccbf9ffe9e79a6762a94eec74c8159f11a14 (diff) | |
bootstd: Support automatically setting Linux parameters
Some Linux parameters can be set automatically by U-Boot, if it knows the
device being used. For example, since U-Boot knows the serial console
being used, it can add parameters for earlycon and console.
Add support for this.
Note that this is an experimental feature and we will see how useful it
turns out to be. It is very handy for ChromeOS, since otherwise it is very
difficult to manually determine the UART address or port number,
particularly in a script.
Provide an example of how this is used with ChromeOS.
Signed-off-by: Simon Glass <[email protected]>
Reviewed-by: Bin Meng <[email protected]>
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/bootflow.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/boot/bootflow.c b/boot/bootflow.c index 8c649e8e66c..81b5829d5b3 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -14,6 +14,7 @@ #include <dm.h> #include <env_internal.h> #include <malloc.h> +#include <serial.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> @@ -854,3 +855,35 @@ int bootflow_cmdline_get_arg(struct bootflow *bflow, const char *arg, return ret; } + +int bootflow_cmdline_auto(struct bootflow *bflow, const char *arg) +{ + struct serial_device_info info; + char buf[50]; + int ret; + + ret = serial_getinfo(gd->cur_serial_dev, &info); + if (ret) + return ret; + + *buf = '\0'; + if (!strcmp("earlycon", arg)) { + snprintf(buf, sizeof(buf), + "uart8250,mmio32,%#lx,%dn8", info.addr, + info.baudrate); + } else if (!strcmp("console", arg)) { + snprintf(buf, sizeof(buf), + "ttyS0,%dn8", info.baudrate); + } + + if (!*buf) { + printf("Unknown param '%s\n", arg); + return -ENOENT; + } + + ret = bootflow_cmdline_set_arg(bflow, arg, buf, true); + if (ret) + return ret; + + return 0; +} |
