summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorTomaz Solc <tomaz.solc@tablix.org>2019-02-27 14:22:15 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-04 08:48:15 +0100
commit67e38cdac3e94b3a3f6aa38a539073e659fea52c (patch)
tree607db5316d6df5f504d0905f3fa5172eb212380d /arch
parente390c8799d914bc4ef84c934b7875078489c26ab (diff)
downloadbarebox-67e38cdac3e94b3a3f6aa38a539073e659fea52c.tar.gz
barebox-67e38cdac3e94b3a3f6aa38a539073e659fea52c.tar.xz
ARM: rpi: save bootargs from VC FDT to vc.bootargs
When booting a Raspberry Pi, it is useful to extract bootargs from the device tree that was created by the VideoCore firmware. These bootargs contain for example settings for the framebuffer that the kernel needs to properly set the video output. This commit extracts the bootargs in the board initialization code and saves them to the vc.bootargs global variable. For example, a bootloader environment can then add the contents of this variable to linux.bootargs.vc, which then gets included into the final bootargs for the kernel using CONFIG_FLEXIBLE_BOOTARGS. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/boards/raspberry-pi/rpi-common.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
index fffa882a70..9d334cde12 100644
--- a/arch/arm/boards/raspberry-pi/rpi-common.c
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -30,6 +30,7 @@
#include <asm/barebox-arm.h>
#include <generated/mach-types.h>
#include <linux/sizes.h>
+#include <globalvar.h>
#include <mach/core.h>
#include <mach/mbox.h>
@@ -375,11 +376,50 @@ static int rpi_env_init(void)
return 0;
}
+/* Extract /chosen/bootargs from the VideoCore FDT into vc.bootargs
+ * global variable. */
+static int rpi_vc_fdt_bootargs(void *fdt)
+{
+ int ret = 0;
+ struct device_node *root = NULL, *node;
+ const char *cmdline;
+
+ root = of_unflatten_dtb(fdt);
+ if (IS_ERR(root)) {
+ ret = PTR_ERR(root);
+ root = NULL;
+ goto out;
+ }
+
+ node = of_find_node_by_path_from(root, "/chosen");
+ if (!node) {
+ pr_err("no /chosen node\n");
+ ret = -ENOENT;
+ goto out;
+ }
+
+ cmdline = of_get_property(node, "bootargs", NULL);
+ if (!cmdline) {
+ pr_err("no bootargs property in the /chosen node\n");
+ ret = -ENOENT;
+ goto out;
+ }
+
+ globalvar_add_simple("vc.bootargs", cmdline);
+
+out:
+ if (root)
+ of_delete_node(root);
+
+ return ret;
+}
+
static void rpi_vc_fdt(void)
{
void *saved_vc_fdt;
struct fdt_header *oftree;
unsigned long magic, size;
+ int ret;
/* VideoCore FDT was copied in PBL just above Barebox memory */
saved_vc_fdt = (void *)(arm_mem_endmem_get());
@@ -401,6 +441,13 @@ static void rpi_vc_fdt(void)
pr_err("failed to save videocore fdt to a file\n");
return;
}
+
+ ret = rpi_vc_fdt_bootargs(saved_vc_fdt);
+ if (ret) {
+ pr_err("failed to extract bootargs from videocore fdt: %d\n",
+ ret);
+ return;
+ }
}
static int rpi_devices_init(void)