#include <fdt_support.h>
#define MAX_LEVEL 32 /* how deeply nested we will go */
-#define SCRATCHPAD 1024 /* bytes of scratchpad memory */
+#define SCRATCHPAD 1024 /* bytes of scratchpad memory */
/*
* Global data (for the gd->bd)
*/
DECLARE_GLOBAL_DATA_PTR;
-/*
- * Function prototypes/declarations.
- */
static int fdt_valid(void);
static int fdt_parse_prop(char *pathp, char *prop, char *newval,
char *data, int *len);
static int fdt_print(char *pathp, char *prop, int depth);
-static int findnodeoffset(const char *pathp)
-{
- int nodeoffset;
-
- if (strcmp(pathp, "/") == 0) {
- nodeoffset = 0;
- } else {
- nodeoffset = fdt_find_node_by_path (fdt, pathp);
- if (nodeoffset < 0) {
- /*
- * Not found or something else bad happened.
- */
- printf ("findnodeoffset() libfdt: %s\n",
- fdt_strerror(nodeoffset));
- }
- }
- return nodeoffset;
-}
-
/*
* Flattened Device Tree command, see the help for parameter definitions.
*/
pathp = argv[2];
nodep = argv[3];
- nodeoffset = findnodeoffset(pathp);
+ nodeoffset = fdt_find_node_by_path (fdt, pathp);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
+ printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ fdt_strerror(nodeoffset));
return 1;
}
err = fdt_add_subnode(fdt, nodeoffset, nodep);
prop = argv[3];
newval = argv[4];
- nodeoffset = findnodeoffset(pathp);
+ nodeoffset = fdt_find_node_by_path (fdt, pathp);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
+ printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ fdt_strerror(nodeoffset));
return 1;
}
ret = fdt_parse_prop(pathp, prop, newval, data, &len);
* Get the path. The root node is an oddball, the offset
* is zero and has no name.
*/
- nodeoffset = findnodeoffset(argv[2]);
+ nodeoffset = fdt_find_node_by_path (fdt, argv[2]);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
+ printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ fdt_strerror(nodeoffset));
return 1;
}
/*
return err;
}
}
-
- /********************************************************************
- * Create a chosen node
- ********************************************************************/
- } else if (argv[1][0] == 'c') {
+ }
+#ifdef CONFIG_OF_BOARD_SETUP
+ /* Call the board-specific fixup routine */
+ else if (argv[1][0] == 'b')
+ ft_board_setup(fdt, gd->bd);
+#endif
+ /* Create a chosen node */
+ else if (argv[1][0] == 'c')
fdt_chosen(fdt, 0, 0, 1);
- /********************************************************************
- * Create a u-boot-env node
- ********************************************************************/
- } else if (argv[1][0] == 'e') {
+#ifdef CONFIG_OF_HAS_UBOOT_ENV
+ /* Create a u-boot-env node */
+ else if (argv[1][0] == 'e')
fdt_env(fdt);
-
- /********************************************************************
- * Create a bd_t node
- ********************************************************************/
- } else if (argv[1][0] == 'b') {
+#endif
+#ifdef CONFIG_OF_HAS_BD_T
+ /* Create a bd_t node */
+ else if (argv[1][0] == 'b')
fdt_bd_t(fdt);
-
- /********************************************************************
- * Unrecognized command
- ********************************************************************/
- } else {
+#endif
+ else {
+ /* Unrecognized command */
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
while ((*newval != ']') && (*newval != '\0')) {
tmp = simple_strtoul(newval, &newval, 16);
*data++ = tmp & 0xFF;
- *len++;
+ *len = *len + 1;
while (*newval == ' ')
newval++;
}
int len; /* length of the property */
int level = 0; /* keep track of nesting level */
- nodeoffset = findnodeoffset(pathp);
+ nodeoffset = fdt_find_node_by_path (fdt, pathp);
if (nodeoffset < 0) {
/*
* Not found or something else bad happened.
*/
+ printf ("libfdt fdt_find_node_by_path() returned %s\n",
+ fdt_strerror(nodeoffset));
return 1;
}
/*
fdt, 5, 0, do_fdt,
"fdt - flattened device tree utility commands\n",
"addr <addr> [<length>] - Set the fdt location to <addr>\n"
+#ifdef CONFIG_OF_BOARD_SETUP
+ "fdt boardsetup - Do board-specific set up\n"
+#endif
"fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr>\n"
"fdt print <path> [<prop>] - Recursive print starting at <path>\n"
"fdt list <path> [<prop>] - Print one level starting at <path>\n"
"fdt set <path> <prop> [<val>] - Set <property> [to <val>]\n"
"fdt mknode <path> <node> - Create a new node after <path>\n"
"fdt rm <path> [<prop>] - Delete the node or <property>\n"
- "fdt chosen - Add/update the \"/chosen\" branch in the tree\n"
+ "fdt chosen - Add/update the /chosen branch in the tree\n"
#ifdef CONFIG_OF_HAS_UBOOT_ENV
- "fdt env - Add/replace the \"/u-boot-env\" branch in the tree\n"
+ "fdt env - Add/replace the /u-boot-env branch in the tree\n"
#endif
#ifdef CONFIG_OF_HAS_BD_T
- "fdt bd_t - Add/replace the \"/bd_t\" branch in the tree\n"
+ "fdt bd_t - Add/replace the /bd_t branch in the tree\n"
#endif
"Hints:\n"
- " * If the property you are setting/printing has a '#' character,\n"
- " you MUST escape it with a \\ character or quote it with \" or\n"
- " it will be ignored as a comment.\n"
- " * If the value has spaces in it, you MUST escape the spaces with\n"
- " \\ characters or quote it with \"\"\n"
+ " If the property you are setting/printing has a '#' character or spaces,\n"
+ " you MUST escape it with a \\ character or quote it with \".\n"
"Examples: fdt print / # print the whole tree\n"
" fdt print /cpus \"#address-cells\"\n"
" fdt set /cpus \"#address-cells\" \"[00 00 00 01]\"\n"