summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChe-Liang Chiou <clchiou@chromium.org>2011-06-23 15:18:55 -0700
committerSimon Glass <sjg@chromium.org>2011-08-29 10:39:37 -0700
commit05359910e5f1695b756b3f78f3ddb4682ae71d42 (patch)
tree2e014b086135b0cfe86cbc8dd1d4ed5aefddae0a
parentccef09b77676858d87b62ec57a6691719d552df4 (diff)
fdt: load boot command from device tree
Load boot command from /config/bootcmd of device tree if none of the environment variables that set boot command exist. These variables may include failbootcmd, altbootcmd, and bootcmd. BUG=chromium-os:16508 TEST=manual 1. Make sure you do not define any CONFIG_BOOTCOMMAND or equivalent 2. Add "bootcmd" property to your /config node of dts: config { ... bootcmd = "echo '**** load boot command from fdt! ****'"; }; 3. Run u-boot and see that message prints out Change-Id: I0ca6a777e23c1a8f024fada24ed507dc2e6fd898 Reviewed-on: http://gerrit.chromium.org/gerrit/3150 Tested-by: Che-Liang Chiou <clchiou@chromium.org> Reviewed-by: Che-Liang Chiou <clchiou@chromium.org>
-rw-r--r--common/fdt_decode.c17
-rw-r--r--common/main.c9
-rw-r--r--include/fdt_decode.h10
3 files changed, 36 insertions, 0 deletions
diff --git a/common/fdt_decode.c b/common/fdt_decode.c
index fd849cc3f0..d695dcdee8 100644
--- a/common/fdt_decode.c
+++ b/common/fdt_decode.c
@@ -509,3 +509,20 @@ int fdt_decode_sdmmc(const void *blob, int node, struct fdt_sdmmc *config)
decode_gpio(blob, node, "power-gpio", &config->power_gpio);
return 0;
}
+
+char *fdt_decode_get_config_string(const void *blob, const char *prop_name)
+{
+ const char *nodep;
+ int nodeoffset;
+ int len;
+
+ nodeoffset = fdt_path_offset(blob, "/config");
+ if (nodeoffset < 0)
+ return NULL;
+
+ nodep = fdt_getprop(blob, nodeoffset, prop_name, &len);
+ if (!nodep)
+ return NULL;
+
+ return (char *)nodep;
+}
diff --git a/common/main.c b/common/main.c
index 2730c6f22f..174377ed2b 100644
--- a/common/main.c
+++ b/common/main.c
@@ -38,6 +38,10 @@
#include <hush.h>
#endif
+#ifdef CONFIG_OF_CONTROL
+#include <fdt_decode.h>
+#endif /* CONFIG_OF_CONTROL */
+
#include <post.h>
#if defined(CONFIG_SILENT_CONSOLE) || defined(CONFIG_POST) || defined(CONFIG_CMDLINE_EDITING)
@@ -373,6 +377,11 @@ void main_loop (void)
else
#endif /* CONFIG_BOOTCOUNT_LIMIT */
s = getenv ("bootcmd");
+#ifdef CONFIG_OF_CONTROL
+ /* Load bootcmd from fdt if none of above env variables exist. */
+ if (!s)
+ s = fdt_decode_get_config_string(gd->blob, "bootcmd");
+#endif /* CONFIG_OF_CONTROL */
debug ("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>");
diff --git a/include/fdt_decode.h b/include/fdt_decode.h
index 7b478a8138..a90a0a24c6 100644
--- a/include/fdt_decode.h
+++ b/include/fdt_decode.h
@@ -348,3 +348,13 @@ int fdt_decode_usb(const void *blob, int node, unsigned osc_frequency_mhz,
* -FDT_ERR_MISSING.
*/
int fdt_decode_sdmmc(const void *blob, int node, struct fdt_sdmmc *config);
+
+/**
+ * Look in the FDT for a config item with the given name and return its value
+ * as a string.
+ *
+ * @param blob FDT blob
+ * @param prop_name property name to look up
+ * @returns property string, NULL on error.
+ */
+char *fdt_decode_get_config_string(const void *blob, const char *prop_name);