public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] fdt_support.c: Allow late kernel cmdline modification
@ 2021-02-22 19:18 Niko Mauno
  2021-02-22 20:21 ` Tom Rini
  2021-05-06 15:02 ` Tom Rini
  0 siblings, 2 replies; 8+ messages in thread
From: Niko Mauno @ 2021-02-22 19:18 UTC (permalink / raw)
  To: u-boot

By declaring board-specific board_fdt_chosen_bootargs() the kernel
command line arguments can be adjusted before injecting to flat dt
chosen node.

Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
---
 common/fdt_support.c  | 12 +++++++++++-
 include/fdt_support.h | 10 ++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 08d540bfc8..4379507e30 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -269,6 +269,15 @@ int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end)
 	return 0;
 }
 
+/**
+ * board_fdt_chosen_bootargs - boards may override this function to use
+ *                             alternative kernel command line arguments
+ */
+__weak char *board_fdt_chosen_bootargs(void)
+{
+	return env_get("bootargs");
+}
+
 int fdt_chosen(void *fdt)
 {
 	int   nodeoffset;
@@ -286,7 +295,8 @@ int fdt_chosen(void *fdt)
 	if (nodeoffset < 0)
 		return nodeoffset;
 
-	str = env_get("bootargs");
+	str = board_fdt_chosen_bootargs();
+
 	if (str) {
 		err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
 				  strlen(str) + 1);
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 46eb1dbbb2..e2a4689cd8 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -185,6 +185,16 @@ int fdt_find_or_add_subnode(void *fdt, int parentoffset, const char *name);
  */
 int ft_board_setup(void *blob, struct bd_info *bd);
 
+/**
+ * board_fdt_chosen_bootargs() - Arbitrarily amend fdt kernel command line
+ *
+ * This is used for late modification of kernel command line arguments just
+ * before they are added into the /chosen node in flat device tree.
+ *
+ * @return: pointer to kernel command line arguments in memory
+ */
+char *board_fdt_chosen_bootargs(void);
+
 /*
  * The keystone2 SOC requires all 32 bit aliased addresses to be converted
  * to their 36 physical format. This has to happen after all fdt nodes
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-05-06 15:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-22 19:18 [PATCH] fdt_support.c: Allow late kernel cmdline modification Niko Mauno
2021-02-22 20:21 ` Tom Rini
2021-02-23  6:33   ` Niko Mauno
2021-02-24 13:51     ` Tom Rini
2021-02-25 16:09       ` Niko Mauno
2021-03-11  7:34         ` Niko Mauno
2021-03-15  5:28           ` Simon Glass
2021-05-06 15:02 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox