summaryrefslogtreecommitdiff
path: root/arch/arm
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2019-04-15 11:32:31 +0200
committerTom Warren <twarren@nvidia.com>2019-06-05 09:16:34 -0700
commitb571766453c83aadfd44f6c4adbb0130bbfa50e3 (patch)
treec48c044e6f7bb30fa476267d3b2760ba4abe6c90 /arch/arm
parent34e12e03c7f4cbd96e584a590d6e091c48ab8e3d (diff)
ARM: tegra: Import cbootargs value from cboot DTB
Read the boot arguments passed by cboot via the /chosen/bootargs property and store it in the cbootargs environment variable. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Tom Warren <twarren@nvidia.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-tegra/cboot.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/cboot.c b/arch/arm/mach-tegra/cboot.c
index 628909f291..a829ef794f 100644
--- a/arch/arm/mach-tegra/cboot.c
+++ b/arch/arm/mach-tegra/cboot.c
@@ -8,7 +8,9 @@
#include <fdt_support.h>
#include <fdtdec.h>
#include <stdlib.h>
+#include <string.h>
+#include <linux/ctype.h>
#include <linux/sizes.h>
#include <asm/arch/tegra.h>
@@ -546,10 +548,49 @@ out:
return err;
}
+static char *strip(const char *ptr)
+{
+ const char *end;
+
+ while (*ptr && isblank(*ptr))
+ ptr++;
+
+ /* empty string */
+ if (*ptr == '\0')
+ return strdup(ptr);
+
+ end = ptr;
+
+ while (end[1])
+ end++;
+
+ while (isblank(*end))
+ end--;
+
+ return strndup(ptr, end - ptr + 1);
+}
+
+static char *cboot_get_bootargs(const void *fdt)
+{
+ const char *args;
+ int offset, len;
+
+ offset = fdt_path_offset(fdt, "/chosen");
+ if (offset < 0)
+ return NULL;
+
+ args = fdt_getprop(fdt, offset, "bootargs", &len);
+ if (!args)
+ return NULL;
+
+ return strip(args);
+}
+
int cboot_late_init(void)
{
const void *fdt = (const void *)cboot_boot_x0;
uint8_t mac[ETH_ALEN];
+ char *bootargs;
int err;
set_calculated_env_vars();
@@ -569,5 +610,11 @@ int cboot_late_init(void)
printf("failed to set MAC address %pM: %d\n", mac, err);
}
+ bootargs = cboot_get_bootargs(fdt);
+ if (bootargs) {
+ env_set("cbootargs", bootargs);
+ free(bootargs);
+ }
+
return 0;
}