blob: 699441b51ad31f48d4eed59357fb0c608dccde52 [file] [log] [blame]
Gerald Van Baren781e09e2007-03-31 12:22:10 -04001/*
2 * (C) Copyright 2007
3 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
4 * Based on code written by:
5 * Pantelis Antoniou <pantelis.antoniou@gmail.com> and
6 * Matthew McClintock <msm@freescale.com>
7 *
8 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27#include <common.h>
28#include <command.h>
29#include <linux/ctype.h>
30#include <linux/types.h>
Gerald Van Baren781e09e2007-03-31 12:22:10 -040031#include <asm/global_data.h>
32#include <fdt.h>
33#include <libfdt.h>
Gerald Van Baren64dbbd42007-04-06 14:19:43 -040034#include <fdt_support.h>
Gerald Van Baren781e09e2007-03-31 12:22:10 -040035
36#define MAX_LEVEL 32 /* how deeply nested we will go */
Gerald Van Barenfd61e552007-06-25 23:25:28 -040037#define SCRATCHPAD 1024 /* bytes of scratchpad memory */
Joe Hershbergerf0a29d42012-08-17 10:34:36 +000038#ifndef CONFIG_CMD_FDT_MAX_DUMP
39#define CONFIG_CMD_FDT_MAX_DUMP 64
40#endif
Gerald Van Baren781e09e2007-03-31 12:22:10 -040041
42/*
43 * Global data (for the gd->bd)
44 */
45DECLARE_GLOBAL_DATA_PTR;
46
Gerald Van Baren781e09e2007-03-31 12:22:10 -040047static int fdt_valid(void);
Wolfgang Denk54841ab2010-06-28 22:00:46 +020048static int fdt_parse_prop(char *const*newval, int count, char *data, int *len);
Kumar Galadbaf07c2007-11-21 14:07:46 -060049static int fdt_print(const char *pathp, char *prop, int depth);
Gerald Van Baren781e09e2007-03-31 12:22:10 -040050
Gerald Van Baren781e09e2007-03-31 12:22:10 -040051/*
Gerald Van Barenae9e97f2008-06-10 22:15:58 -040052 * The working_fdt points to our working flattened device tree.
53 */
54struct fdt_header *working_fdt;
55
Kumar Gala54f9c862008-08-15 08:24:39 -050056void set_working_fdt_addr(void *addr)
57{
58 char buf[17];
59
60 working_fdt = addr;
61
62 sprintf(buf, "%lx", (unsigned long)addr);
63 setenv("fdtaddr", buf);
64}
65
Gerald Van Barenae9e97f2008-06-10 22:15:58 -040066/*
Gerald Van Baren781e09e2007-03-31 12:22:10 -040067 * Flattened Device Tree command, see the help for parameter definitions.
68 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +020069int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Gerald Van Baren781e09e2007-03-31 12:22:10 -040070{
Wolfgang Denk47e26b12010-07-17 01:06:04 +020071 if (argc < 2)
Simon Glass4c12eeb2011-12-10 08:44:01 +000072 return CMD_RET_USAGE;
Gerald Van Baren781e09e2007-03-31 12:22:10 -040073
Wolfgang Denk47e26b12010-07-17 01:06:04 +020074 /*
Gerald Van Baren781e09e2007-03-31 12:22:10 -040075 * Set the address of the fdt
Wolfgang Denk47e26b12010-07-17 01:06:04 +020076 */
Gerald Van Baren25114032007-05-12 09:47:25 -040077 if (argv[1][0] == 'a') {
Kumar Gala54f9c862008-08-15 08:24:39 -050078 unsigned long addr;
Gerald Van Baren781e09e2007-03-31 12:22:10 -040079 /*
80 * Set the address [and length] of the fdt.
81 */
Kumar Gala7dbc38a2008-08-15 08:24:35 -050082 if (argc == 2) {
83 if (!fdt_valid()) {
84 return 1;
85 }
86 printf("The address of the fdt is %p\n", working_fdt);
87 return 0;
88 }
89
Kumar Gala54f9c862008-08-15 08:24:39 -050090 addr = simple_strtoul(argv[2], NULL, 16);
91 set_working_fdt_addr((void *)addr);
Gerald Van Baren781e09e2007-03-31 12:22:10 -040092
93 if (!fdt_valid()) {
94 return 1;
95 }
96
97 if (argc >= 4) {
98 int len;
99 int err;
100 /*
101 * Optional new length
102 */
Gerald Van Baren91623522007-11-22 17:23:23 -0500103 len = simple_strtoul(argv[3], NULL, 16);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500104 if (len < fdt_totalsize(working_fdt)) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400105 printf ("New length %d < existing length %d, "
106 "ignoring.\n",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500107 len, fdt_totalsize(working_fdt));
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400108 } else {
109 /*
110 * Open in place with a new length.
111 */
Kim Phillipse489b9c2008-06-10 11:06:17 -0500112 err = fdt_open_into(working_fdt, working_fdt, len);
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400113 if (err != 0) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400114 printf ("libfdt fdt_open_into(): %s\n",
115 fdt_strerror(err));
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400116 }
117 }
118 }
119
Marek Vasute02c9452012-09-05 08:34:44 +0200120 return CMD_RET_SUCCESS;
121 }
122
123 if (!working_fdt) {
124 puts(
125 "No FDT memory address configured. Please configure\n"
126 "the FDT address via \"fdt addr <address>\" command.\n"
127 "Aborting!\n");
128 return CMD_RET_FAILURE;
129 }
130
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200131 /*
Kim Phillipse489b9c2008-06-10 11:06:17 -0500132 * Move the working_fdt
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200133 */
Marek Vasute02c9452012-09-05 08:34:44 +0200134 if (strncmp(argv[1], "mo", 2) == 0) {
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400135 struct fdt_header *newaddr;
136 int len;
137 int err;
138
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200139 if (argc < 4)
Simon Glass4c12eeb2011-12-10 08:44:01 +0000140 return CMD_RET_USAGE;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400141
142 /*
143 * Set the address and length of the fdt.
144 */
Kim Phillipse489b9c2008-06-10 11:06:17 -0500145 working_fdt = (struct fdt_header *)simple_strtoul(argv[2], NULL, 16);
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400146 if (!fdt_valid()) {
147 return 1;
148 }
149
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400150 newaddr = (struct fdt_header *)simple_strtoul(argv[3],NULL,16);
Gerald Van Baren6be07cc2007-04-25 22:47:15 -0400151
152 /*
153 * If the user specifies a length, use that. Otherwise use the
154 * current length.
155 */
156 if (argc <= 4) {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500157 len = fdt_totalsize(working_fdt);
Gerald Van Baren6be07cc2007-04-25 22:47:15 -0400158 } else {
159 len = simple_strtoul(argv[4], NULL, 16);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500160 if (len < fdt_totalsize(working_fdt)) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400161 printf ("New length 0x%X < existing length "
162 "0x%X, aborting.\n",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500163 len, fdt_totalsize(working_fdt));
Gerald Van Baren6be07cc2007-04-25 22:47:15 -0400164 return 1;
165 }
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400166 }
167
168 /*
169 * Copy to the new location.
170 */
Kim Phillipse489b9c2008-06-10 11:06:17 -0500171 err = fdt_open_into(working_fdt, newaddr, len);
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400172 if (err != 0) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400173 printf ("libfdt fdt_open_into(): %s\n",
174 fdt_strerror(err));
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400175 return 1;
176 }
Kim Phillipse489b9c2008-06-10 11:06:17 -0500177 working_fdt = newaddr;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400178
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200179 /*
Gerald Van Baren25114032007-05-12 09:47:25 -0400180 * Make a new node
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200181 */
Gerald Van Baren2fb698b2008-06-09 21:02:17 -0400182 } else if (strncmp(argv[1], "mk", 2) == 0) {
Gerald Van Baren25114032007-05-12 09:47:25 -0400183 char *pathp; /* path */
184 char *nodep; /* new node to add */
185 int nodeoffset; /* node offset from libfdt */
186 int err;
187
188 /*
189 * Parameters: Node path, new node to be appended to the path.
190 */
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200191 if (argc < 4)
Simon Glass4c12eeb2011-12-10 08:44:01 +0000192 return CMD_RET_USAGE;
Gerald Van Baren25114032007-05-12 09:47:25 -0400193
194 pathp = argv[2];
195 nodep = argv[3];
196
Kim Phillipse489b9c2008-06-10 11:06:17 -0500197 nodeoffset = fdt_path_offset (working_fdt, pathp);
Gerald Van Baren25114032007-05-12 09:47:25 -0400198 if (nodeoffset < 0) {
199 /*
200 * Not found or something else bad happened.
201 */
Kumar Gala8d04f022007-10-24 11:04:22 -0500202 printf ("libfdt fdt_path_offset() returned %s\n",
Gerald Van Baren06e19a02007-05-21 23:27:16 -0400203 fdt_strerror(nodeoffset));
Gerald Van Baren25114032007-05-12 09:47:25 -0400204 return 1;
205 }
Kim Phillipse489b9c2008-06-10 11:06:17 -0500206 err = fdt_add_subnode(working_fdt, nodeoffset, nodep);
Gerald Van Baren25114032007-05-12 09:47:25 -0400207 if (err < 0) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400208 printf ("libfdt fdt_add_subnode(): %s\n",
209 fdt_strerror(err));
Gerald Van Baren25114032007-05-12 09:47:25 -0400210 return 1;
211 }
212
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200213 /*
Kim Phillipse489b9c2008-06-10 11:06:17 -0500214 * Set the value of a property in the working_fdt.
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200215 */
Gerald Van Baren25114032007-05-12 09:47:25 -0400216 } else if (argv[1][0] == 's') {
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400217 char *pathp; /* path */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400218 char *prop; /* property */
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400219 int nodeoffset; /* node offset from libfdt */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400220 static char data[SCRATCHPAD]; /* storage for the property */
221 int len; /* new length of the property */
222 int ret; /* return value */
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400223
224 /*
Gerald Van Barenea6d8be2008-01-05 14:52:04 -0500225 * Parameters: Node path, property, optional value.
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400226 */
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200227 if (argc < 4)
Simon Glass4c12eeb2011-12-10 08:44:01 +0000228 return CMD_RET_USAGE;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400229
230 pathp = argv[2];
231 prop = argv[3];
Gerald Van Barenea6d8be2008-01-05 14:52:04 -0500232 if (argc == 4) {
233 len = 0;
234 } else {
Andy Fleming4abd8442008-03-31 20:45:56 -0500235 ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
Gerald Van Barenea6d8be2008-01-05 14:52:04 -0500236 if (ret != 0)
237 return ret;
238 }
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400239
Kim Phillipse489b9c2008-06-10 11:06:17 -0500240 nodeoffset = fdt_path_offset (working_fdt, pathp);
Gerald Van Baren25114032007-05-12 09:47:25 -0400241 if (nodeoffset < 0) {
242 /*
243 * Not found or something else bad happened.
244 */
Kumar Gala8d04f022007-10-24 11:04:22 -0500245 printf ("libfdt fdt_path_offset() returned %s\n",
Gerald Van Baren06e19a02007-05-21 23:27:16 -0400246 fdt_strerror(nodeoffset));
Gerald Van Baren25114032007-05-12 09:47:25 -0400247 return 1;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400248 }
Gerald Van Baren25114032007-05-12 09:47:25 -0400249
Kim Phillipse489b9c2008-06-10 11:06:17 -0500250 ret = fdt_setprop(working_fdt, nodeoffset, prop, data, len);
Gerald Van Baren25114032007-05-12 09:47:25 -0400251 if (ret < 0) {
252 printf ("libfdt fdt_setprop(): %s\n", fdt_strerror(ret));
253 return 1;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400254 }
255
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200256 /*
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400257 * Print (recursive) / List (single level)
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200258 */
Gerald Van Baren25114032007-05-12 09:47:25 -0400259 } else if ((argv[1][0] == 'p') || (argv[1][0] == 'l')) {
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400260 int depth = MAX_LEVEL; /* how deep to print */
261 char *pathp; /* path */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400262 char *prop; /* property */
263 int ret; /* return value */
Kumar Galaf738b4a2007-10-25 16:15:07 -0500264 static char root[2] = "/";
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400265
266 /*
267 * list is an alias for print, but limited to 1 level
268 */
Gerald Van Baren25114032007-05-12 09:47:25 -0400269 if (argv[1][0] == 'l') {
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400270 depth = 1;
271 }
272
273 /*
274 * Get the starting path. The root node is an oddball,
275 * the offset is zero and has no name.
276 */
Kumar Galaf738b4a2007-10-25 16:15:07 -0500277 if (argc == 2)
278 pathp = root;
279 else
280 pathp = argv[2];
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400281 if (argc > 3)
282 prop = argv[3];
283 else
284 prop = NULL;
285
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400286 ret = fdt_print(pathp, prop, depth);
287 if (ret != 0)
288 return ret;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400289
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200290 /*
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400291 * Remove a property/node
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200292 */
Gerald Van Baren2fb698b2008-06-09 21:02:17 -0400293 } else if (strncmp(argv[1], "rm", 2) == 0) {
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400294 int nodeoffset; /* node offset from libfdt */
295 int err;
296
297 /*
298 * Get the path. The root node is an oddball, the offset
299 * is zero and has no name.
300 */
Kim Phillipse489b9c2008-06-10 11:06:17 -0500301 nodeoffset = fdt_path_offset (working_fdt, argv[2]);
Gerald Van Baren25114032007-05-12 09:47:25 -0400302 if (nodeoffset < 0) {
303 /*
304 * Not found or something else bad happened.
305 */
Kumar Gala8d04f022007-10-24 11:04:22 -0500306 printf ("libfdt fdt_path_offset() returned %s\n",
Gerald Van Baren06e19a02007-05-21 23:27:16 -0400307 fdt_strerror(nodeoffset));
Gerald Van Baren25114032007-05-12 09:47:25 -0400308 return 1;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400309 }
310 /*
311 * Do the delete. A fourth parameter means delete a property,
312 * otherwise delete the node.
313 */
314 if (argc > 3) {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500315 err = fdt_delprop(working_fdt, nodeoffset, argv[3]);
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400316 if (err < 0) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400317 printf("libfdt fdt_delprop(): %s\n",
318 fdt_strerror(err));
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400319 return err;
320 }
321 } else {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500322 err = fdt_del_node(working_fdt, nodeoffset);
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400323 if (err < 0) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400324 printf("libfdt fdt_del_node(): %s\n",
325 fdt_strerror(err));
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400326 return err;
327 }
328 }
Kumar Gala804887e2008-02-15 03:34:36 -0600329
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200330 /*
Kumar Gala804887e2008-02-15 03:34:36 -0600331 * Display header info
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200332 */
Kumar Gala804887e2008-02-15 03:34:36 -0600333 } else if (argv[1][0] == 'h') {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500334 u32 version = fdt_version(working_fdt);
335 printf("magic:\t\t\t0x%x\n", fdt_magic(working_fdt));
336 printf("totalsize:\t\t0x%x (%d)\n", fdt_totalsize(working_fdt),
337 fdt_totalsize(working_fdt));
338 printf("off_dt_struct:\t\t0x%x\n",
339 fdt_off_dt_struct(working_fdt));
340 printf("off_dt_strings:\t\t0x%x\n",
341 fdt_off_dt_strings(working_fdt));
342 printf("off_mem_rsvmap:\t\t0x%x\n",
343 fdt_off_mem_rsvmap(working_fdt));
Kumar Gala804887e2008-02-15 03:34:36 -0600344 printf("version:\t\t%d\n", version);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500345 printf("last_comp_version:\t%d\n",
346 fdt_last_comp_version(working_fdt));
Kumar Gala804887e2008-02-15 03:34:36 -0600347 if (version >= 2)
348 printf("boot_cpuid_phys:\t0x%x\n",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500349 fdt_boot_cpuid_phys(working_fdt));
Kumar Gala804887e2008-02-15 03:34:36 -0600350 if (version >= 3)
351 printf("size_dt_strings:\t0x%x\n",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500352 fdt_size_dt_strings(working_fdt));
Kumar Gala804887e2008-02-15 03:34:36 -0600353 if (version >= 17)
354 printf("size_dt_struct:\t\t0x%x\n",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500355 fdt_size_dt_struct(working_fdt));
356 printf("number mem_rsv:\t\t0x%x\n",
357 fdt_num_mem_rsv(working_fdt));
Kumar Gala804887e2008-02-15 03:34:36 -0600358 printf("\n");
359
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200360 /*
Kumar Gala804887e2008-02-15 03:34:36 -0600361 * Set boot cpu id
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200362 */
Gerald Van Baren2fb698b2008-06-09 21:02:17 -0400363 } else if (strncmp(argv[1], "boo", 3) == 0) {
Kumar Gala804887e2008-02-15 03:34:36 -0600364 unsigned long tmp = simple_strtoul(argv[2], NULL, 16);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500365 fdt_set_boot_cpuid_phys(working_fdt, tmp);
Kumar Gala804887e2008-02-15 03:34:36 -0600366
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200367 /*
Kumar Gala804887e2008-02-15 03:34:36 -0600368 * memory command
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200369 */
Gerald Van Baren2fb698b2008-06-09 21:02:17 -0400370 } else if (strncmp(argv[1], "me", 2) == 0) {
Kumar Gala804887e2008-02-15 03:34:36 -0600371 uint64_t addr, size;
372 int err;
Heiko Schocher4b142fe2009-12-03 11:21:21 +0100373 addr = simple_strtoull(argv[2], NULL, 16);
374 size = simple_strtoull(argv[3], NULL, 16);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500375 err = fdt_fixup_memory(working_fdt, addr, size);
Kumar Gala804887e2008-02-15 03:34:36 -0600376 if (err < 0)
377 return err;
378
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200379 /*
Kumar Gala804887e2008-02-15 03:34:36 -0600380 * mem reserve commands
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200381 */
Gerald Van Baren2fb698b2008-06-09 21:02:17 -0400382 } else if (strncmp(argv[1], "rs", 2) == 0) {
Kumar Gala804887e2008-02-15 03:34:36 -0600383 if (argv[2][0] == 'p') {
384 uint64_t addr, size;
Kim Phillipse489b9c2008-06-10 11:06:17 -0500385 int total = fdt_num_mem_rsv(working_fdt);
Kumar Gala804887e2008-02-15 03:34:36 -0600386 int j, err;
387 printf("index\t\t start\t\t size\n");
388 printf("-------------------------------"
389 "-----------------\n");
390 for (j = 0; j < total; j++) {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500391 err = fdt_get_mem_rsv(working_fdt, j, &addr, &size);
Kumar Gala804887e2008-02-15 03:34:36 -0600392 if (err < 0) {
393 printf("libfdt fdt_get_mem_rsv(): %s\n",
394 fdt_strerror(err));
395 return err;
396 }
397 printf(" %x\t%08x%08x\t%08x%08x\n", j,
398 (u32)(addr >> 32),
399 (u32)(addr & 0xffffffff),
400 (u32)(size >> 32),
401 (u32)(size & 0xffffffff));
402 }
403 } else if (argv[2][0] == 'a') {
404 uint64_t addr, size;
405 int err;
Kumar Gala804887e2008-02-15 03:34:36 -0600406 addr = simple_strtoull(argv[3], NULL, 16);
407 size = simple_strtoull(argv[4], NULL, 16);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500408 err = fdt_add_mem_rsv(working_fdt, addr, size);
Kumar Gala804887e2008-02-15 03:34:36 -0600409
410 if (err < 0) {
411 printf("libfdt fdt_add_mem_rsv(): %s\n",
412 fdt_strerror(err));
413 return err;
414 }
415 } else if (argv[2][0] == 'd') {
416 unsigned long idx = simple_strtoul(argv[3], NULL, 16);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500417 int err = fdt_del_mem_rsv(working_fdt, idx);
Kumar Gala804887e2008-02-15 03:34:36 -0600418
419 if (err < 0) {
420 printf("libfdt fdt_del_mem_rsv(): %s\n",
421 fdt_strerror(err));
422 return err;
423 }
424 } else {
425 /* Unrecognized command */
Simon Glass4c12eeb2011-12-10 08:44:01 +0000426 return CMD_RET_USAGE;
Kumar Gala804887e2008-02-15 03:34:36 -0600427 }
Kim Phillips99dffca2007-07-17 13:57:04 -0500428 }
Gerald Van Barenfd61e552007-06-25 23:25:28 -0400429#ifdef CONFIG_OF_BOARD_SETUP
Kim Phillips99dffca2007-07-17 13:57:04 -0500430 /* Call the board-specific fixup routine */
Gerald Van Baren2fb698b2008-06-09 21:02:17 -0400431 else if (strncmp(argv[1], "boa", 3) == 0)
Kim Phillipse489b9c2008-06-10 11:06:17 -0500432 ft_board_setup(working_fdt, gd->bd);
Gerald Van Barenfd61e552007-06-25 23:25:28 -0400433#endif
Kim Phillips99dffca2007-07-17 13:57:04 -0500434 /* Create a chosen node */
Kumar Galaf953d992008-08-15 08:24:34 -0500435 else if (argv[1][0] == 'c') {
436 unsigned long initrd_start = 0, initrd_end = 0;
437
Wolfgang Denk47e26b12010-07-17 01:06:04 +0200438 if ((argc != 2) && (argc != 4))
Simon Glass4c12eeb2011-12-10 08:44:01 +0000439 return CMD_RET_USAGE;
Kumar Galaf953d992008-08-15 08:24:34 -0500440
441 if (argc == 4) {
442 initrd_start = simple_strtoul(argv[2], NULL, 16);
443 initrd_end = simple_strtoul(argv[3], NULL, 16);
444 }
445
Heiko Schocher56844a22008-09-11 08:11:23 +0200446 fdt_chosen(working_fdt, 1);
447 fdt_initrd(working_fdt, initrd_start, initrd_end, 1);
Kumar Gala40afac22008-08-15 08:24:44 -0500448 }
449 /* resize the fdt */
450 else if (strncmp(argv[1], "re", 2) == 0) {
451 fdt_resize(working_fdt);
452 }
453 else {
Kim Phillips99dffca2007-07-17 13:57:04 -0500454 /* Unrecognized command */
Simon Glass4c12eeb2011-12-10 08:44:01 +0000455 return CMD_RET_USAGE;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400456 }
457
458 return 0;
459}
460
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400461/****************************************************************************/
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400462
463static int fdt_valid(void)
464{
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400465 int err;
466
Kim Phillipse489b9c2008-06-10 11:06:17 -0500467 if (working_fdt == NULL) {
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400468 printf ("The address of the fdt is invalid (NULL).\n");
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400469 return 0;
470 }
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400471
Kim Phillipse489b9c2008-06-10 11:06:17 -0500472 err = fdt_check_header(working_fdt);
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400473 if (err == 0)
474 return 1; /* valid */
475
476 if (err < 0) {
Gerald Van Baren25114032007-05-12 09:47:25 -0400477 printf("libfdt fdt_check_header(): %s", fdt_strerror(err));
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400478 /*
479 * Be more informative on bad version.
480 */
481 if (err == -FDT_ERR_BADVERSION) {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500482 if (fdt_version(working_fdt) <
483 FDT_FIRST_SUPPORTED_VERSION) {
Andrew Klossnerdc4b0b32008-07-07 06:41:14 -0700484 printf (" - too old, fdt %d < %d",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500485 fdt_version(working_fdt),
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400486 FDT_FIRST_SUPPORTED_VERSION);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500487 working_fdt = NULL;
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400488 }
Kim Phillipse489b9c2008-06-10 11:06:17 -0500489 if (fdt_last_comp_version(working_fdt) >
490 FDT_LAST_SUPPORTED_VERSION) {
Andrew Klossnerdc4b0b32008-07-07 06:41:14 -0700491 printf (" - too new, fdt %d > %d",
Kim Phillipse489b9c2008-06-10 11:06:17 -0500492 fdt_version(working_fdt),
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400493 FDT_LAST_SUPPORTED_VERSION);
Kim Phillipse489b9c2008-06-10 11:06:17 -0500494 working_fdt = NULL;
Gerald Van Baren64dbbd42007-04-06 14:19:43 -0400495 }
496 return 0;
497 }
498 printf("\n");
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400499 return 0;
500 }
501 return 1;
502}
503
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400504/****************************************************************************/
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400505
506/*
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400507 * Parse the user's input, partially heuristic. Valid formats:
Andy Fleming4abd8442008-03-31 20:45:56 -0500508 * <0x00112233 4 05> - an array of cells. Numbers follow standard
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200509 * C conventions.
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400510 * [00 11 22 .. nn] - byte stream
511 * "string" - If the the value doesn't start with "<" or "[", it is
512 * treated as a string. Note that the quotes are
513 * stripped by the parser before we get the string.
Andy Fleming4abd8442008-03-31 20:45:56 -0500514 * newval: An array of strings containing the new property as specified
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200515 * on the command line
Andy Fleming4abd8442008-03-31 20:45:56 -0500516 * count: The number of strings in the array
517 * data: A bytestream to be placed in the property
518 * len: The length of the resulting bytestream
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400519 */
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200520static int fdt_parse_prop(char * const *newval, int count, char *data, int *len)
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400521{
522 char *cp; /* temporary char pointer */
Andy Fleming4abd8442008-03-31 20:45:56 -0500523 char *newp; /* temporary newval char pointer */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400524 unsigned long tmp; /* holds converted values */
Andy Fleming4abd8442008-03-31 20:45:56 -0500525 int stridx = 0;
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400526
Andy Fleming4abd8442008-03-31 20:45:56 -0500527 *len = 0;
528 newp = newval[0];
529
530 /* An array of cells */
531 if (*newp == '<') {
532 newp++;
533 while ((*newp != '>') && (stridx < count)) {
534 /*
535 * Keep searching until we find that last ">"
536 * That way users don't have to escape the spaces
537 */
538 if (*newp == '\0') {
539 newp = newval[++stridx];
540 continue;
541 }
542
543 cp = newp;
544 tmp = simple_strtoul(cp, &newp, 0);
545 *(uint32_t *)data = __cpu_to_be32(tmp);
546 data += 4;
547 *len += 4;
548
549 /* If the ptr didn't advance, something went wrong */
550 if ((newp - cp) <= 0) {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400551 printf("Sorry, I could not convert \"%s\"\n",
552 cp);
553 return 1;
554 }
Andy Fleming4abd8442008-03-31 20:45:56 -0500555
556 while (*newp == ' ')
557 newp++;
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400558 }
Andy Fleming4abd8442008-03-31 20:45:56 -0500559
560 if (*newp != '>') {
561 printf("Unexpected character '%c'\n", *newp);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400562 return 1;
563 }
Andy Fleming4abd8442008-03-31 20:45:56 -0500564 } else if (*newp == '[') {
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400565 /*
566 * Byte stream. Convert the values.
567 */
Andy Fleming4abd8442008-03-31 20:45:56 -0500568 newp++;
Ken MacLeod6e748ea2009-09-11 15:16:18 -0500569 while ((stridx < count) && (*newp != ']')) {
570 while (*newp == ' ')
571 newp++;
572 if (*newp == '\0') {
573 newp = newval[++stridx];
574 continue;
575 }
576 if (!isxdigit(*newp))
577 break;
Andy Fleming4abd8442008-03-31 20:45:56 -0500578 tmp = simple_strtoul(newp, &newp, 16);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400579 *data++ = tmp & 0xFF;
Gerald Van Barenfd61e552007-06-25 23:25:28 -0400580 *len = *len + 1;
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400581 }
Andy Fleming4abd8442008-03-31 20:45:56 -0500582 if (*newp != ']') {
Andrew Klossnerdc4b0b32008-07-07 06:41:14 -0700583 printf("Unexpected character '%c'\n", *newp);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400584 return 1;
585 }
586 } else {
587 /*
Ken MacLeod6e748ea2009-09-11 15:16:18 -0500588 * Assume it is one or more strings. Copy it into our
589 * data area for convenience (including the
590 * terminating '\0's).
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400591 */
Andy Fleming4abd8442008-03-31 20:45:56 -0500592 while (stridx < count) {
Ken MacLeod6e748ea2009-09-11 15:16:18 -0500593 size_t length = strlen(newp) + 1;
Andy Fleming4abd8442008-03-31 20:45:56 -0500594 strcpy(data, newp);
Ken MacLeod6e748ea2009-09-11 15:16:18 -0500595 data += length;
596 *len += length;
Andy Fleming4abd8442008-03-31 20:45:56 -0500597 newp = newval[++stridx];
598 }
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400599 }
600 return 0;
601}
602
603/****************************************************************************/
604
605/*
606 * Heuristic to guess if this is a string or concatenated strings.
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400607 */
608
609static int is_printable_string(const void *data, int len)
610{
611 const char *s = data;
612
613 /* zero length is not */
614 if (len == 0)
615 return 0;
616
617 /* must terminate with zero */
618 if (s[len - 1] != '\0')
619 return 0;
620
621 /* printable or a null byte (concatenated strings) */
622 while (((*s == '\0') || isprint(*s)) && (len > 0)) {
623 /*
624 * If we see a null, there are three possibilities:
625 * 1) If len == 1, it is the end of the string, printable
626 * 2) Next character also a null, not printable.
627 * 3) Next character not a null, continue to check.
628 */
629 if (s[0] == '\0') {
630 if (len == 1)
631 return 1;
632 if (s[1] == '\0')
633 return 0;
634 }
635 s++;
636 len--;
637 }
638
639 /* Not the null termination, or not done yet: not printable */
640 if (*s != '\0' || (len != 0))
641 return 0;
642
643 return 1;
644}
645
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400646
647/*
648 * Print the property in the best format, a heuristic guess. Print as
649 * a string, concatenated strings, a byte, word, double word, or (if all
650 * else fails) it is printed as a stream of bytes.
651 */
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400652static void print_data(const void *data, int len)
653{
654 int j;
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400655
656 /* no data, don't print */
657 if (len == 0)
658 return;
659
660 /*
661 * It is a string, but it may have multiple strings (embedded '\0's).
662 */
663 if (is_printable_string(data, len)) {
664 puts("\"");
665 j = 0;
666 while (j < len) {
667 if (j > 0)
668 puts("\", \"");
669 puts(data);
670 j += strlen(data) + 1;
671 data += strlen(data) + 1;
672 }
673 puts("\"");
674 return;
675 }
676
Andy Fleming4abd8442008-03-31 20:45:56 -0500677 if ((len %4) == 0) {
Joe Hershbergerf0a29d42012-08-17 10:34:36 +0000678 if (len > CONFIG_CMD_FDT_MAX_DUMP)
679 printf("* 0x%08x [0x%08x]", (unsigned int)data, len);
680 else {
681 const u32 *p;
Andy Fleming4abd8442008-03-31 20:45:56 -0500682
Joe Hershbergerf0a29d42012-08-17 10:34:36 +0000683 printf("<");
684 for (j = 0, p = data; j < len/4; j++)
685 printf("0x%08x%s", fdt32_to_cpu(p[j]),
686 j < (len/4 - 1) ? " " : "");
687 printf(">");
688 }
Andy Fleming4abd8442008-03-31 20:45:56 -0500689 } else { /* anything else... hexdump */
Joe Hershbergerf0a29d42012-08-17 10:34:36 +0000690 if (len > CONFIG_CMD_FDT_MAX_DUMP)
691 printf("* 0x%08x [0x%08x]", (unsigned int)data, len);
692 else {
693 const u8 *s;
Andy Fleming4abd8442008-03-31 20:45:56 -0500694
Joe Hershbergerf0a29d42012-08-17 10:34:36 +0000695 printf("[");
696 for (j = 0, s = data; j < len; j++)
697 printf("%02x%s", s[j], j < len - 1 ? " " : "");
698 printf("]");
699 }
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400700 }
701}
702
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400703/****************************************************************************/
704
705/*
Kim Phillipse489b9c2008-06-10 11:06:17 -0500706 * Recursively print (a portion of) the working_fdt. The depth parameter
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400707 * determines how deeply nested the fdt is printed.
708 */
Kumar Galadbaf07c2007-11-21 14:07:46 -0600709static int fdt_print(const char *pathp, char *prop, int depth)
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400710{
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400711 static char tabs[MAX_LEVEL+1] =
712 "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"
713 "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
Kumar Galadbaf07c2007-11-21 14:07:46 -0600714 const void *nodep; /* property node pointer */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400715 int nodeoffset; /* node offset from libfdt */
716 int nextoffset; /* next node offset from libfdt */
717 uint32_t tag; /* tag */
718 int len; /* length of the property */
719 int level = 0; /* keep track of nesting level */
Gerald Van Baren91623522007-11-22 17:23:23 -0500720 const struct fdt_property *fdt_prop;
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400721
Kim Phillipse489b9c2008-06-10 11:06:17 -0500722 nodeoffset = fdt_path_offset (working_fdt, pathp);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400723 if (nodeoffset < 0) {
724 /*
725 * Not found or something else bad happened.
726 */
Kumar Gala8d04f022007-10-24 11:04:22 -0500727 printf ("libfdt fdt_path_offset() returned %s\n",
Gerald Van Baren06e19a02007-05-21 23:27:16 -0400728 fdt_strerror(nodeoffset));
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400729 return 1;
730 }
731 /*
732 * The user passed in a property as well as node path.
733 * Print only the given property and then return.
734 */
735 if (prop) {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500736 nodep = fdt_getprop (working_fdt, nodeoffset, prop, &len);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400737 if (len == 0) {
738 /* no property value */
739 printf("%s %s\n", pathp, prop);
740 return 0;
741 } else if (len > 0) {
Gerald Van Baren28f384b2007-11-23 19:43:20 -0500742 printf("%s = ", prop);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400743 print_data (nodep, len);
744 printf("\n");
745 return 0;
746 } else {
747 printf ("libfdt fdt_getprop(): %s\n",
748 fdt_strerror(len));
749 return 1;
750 }
751 }
752
753 /*
754 * The user passed in a node path and no property,
755 * print the node and all subnodes.
756 */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400757 while(level >= 0) {
Kim Phillipse489b9c2008-06-10 11:06:17 -0500758 tag = fdt_next_tag(working_fdt, nodeoffset, &nextoffset);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400759 switch(tag) {
760 case FDT_BEGIN_NODE:
Kim Phillipse489b9c2008-06-10 11:06:17 -0500761 pathp = fdt_get_name(working_fdt, nodeoffset, NULL);
Gerald Van Baren91623522007-11-22 17:23:23 -0500762 if (level <= depth) {
763 if (pathp == NULL)
764 pathp = "/* NULL pointer error */";
765 if (*pathp == '\0')
766 pathp = "/"; /* root is nameless */
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400767 printf("%s%s {\n",
768 &tabs[MAX_LEVEL - level], pathp);
Gerald Van Baren91623522007-11-22 17:23:23 -0500769 }
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400770 level++;
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400771 if (level >= MAX_LEVEL) {
Gerald Van Baren91623522007-11-22 17:23:23 -0500772 printf("Nested too deep, aborting.\n");
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400773 return 1;
774 }
775 break;
776 case FDT_END_NODE:
777 level--;
Gerald Van Baren91623522007-11-22 17:23:23 -0500778 if (level <= depth)
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400779 printf("%s};\n", &tabs[MAX_LEVEL - level]);
780 if (level == 0) {
781 level = -1; /* exit the loop */
782 }
783 break;
784 case FDT_PROP:
Kim Phillipse489b9c2008-06-10 11:06:17 -0500785 fdt_prop = fdt_offset_ptr(working_fdt, nodeoffset,
Gerald Van Baren91623522007-11-22 17:23:23 -0500786 sizeof(*fdt_prop));
Kim Phillipse489b9c2008-06-10 11:06:17 -0500787 pathp = fdt_string(working_fdt,
Gerald Van Baren91623522007-11-22 17:23:23 -0500788 fdt32_to_cpu(fdt_prop->nameoff));
789 len = fdt32_to_cpu(fdt_prop->len);
790 nodep = fdt_prop->data;
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400791 if (len < 0) {
792 printf ("libfdt fdt_getprop(): %s\n",
793 fdt_strerror(len));
794 return 1;
795 } else if (len == 0) {
796 /* the property has no value */
Gerald Van Baren91623522007-11-22 17:23:23 -0500797 if (level <= depth)
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400798 printf("%s%s;\n",
799 &tabs[MAX_LEVEL - level],
800 pathp);
801 } else {
Gerald Van Baren91623522007-11-22 17:23:23 -0500802 if (level <= depth) {
Gerald Van Baren28f384b2007-11-23 19:43:20 -0500803 printf("%s%s = ",
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400804 &tabs[MAX_LEVEL - level],
805 pathp);
806 print_data (nodep, len);
807 printf(";\n");
808 }
809 }
810 break;
811 case FDT_NOP:
Andrew Klossnerdc4b0b32008-07-07 06:41:14 -0700812 printf("%s/* NOP */\n", &tabs[MAX_LEVEL - level]);
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400813 break;
814 case FDT_END:
815 return 1;
816 default:
Gerald Van Baren91623522007-11-22 17:23:23 -0500817 if (level <= depth)
Gerald Van Barenaddd8ce2007-05-16 22:39:59 -0400818 printf("Unknown tag 0x%08X\n", tag);
819 return 1;
820 }
821 nodeoffset = nextoffset;
822 }
823 return 0;
824}
825
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400826/********************************************************************/
827
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400828U_BOOT_CMD(
Andy Fleming4abd8442008-03-31 20:45:56 -0500829 fdt, 255, 0, do_fdt,
Peter Tyser2fb26042009-01-27 18:03:12 -0600830 "flattened device tree utility commands",
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400831 "addr <addr> [<length>] - Set the fdt location to <addr>\n"
Gerald Van Barenfd61e552007-06-25 23:25:28 -0400832#ifdef CONFIG_OF_BOARD_SETUP
833 "fdt boardsetup - Do board-specific set up\n"
834#endif
Gerald Van Baren238cb7a2008-01-05 15:33:29 -0500835 "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active\n"
Kumar Gala40afac22008-08-15 08:24:44 -0500836 "fdt resize - Resize fdt to size + padding to 4k addr\n"
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400837 "fdt print <path> [<prop>] - Recursive print starting at <path>\n"
838 "fdt list <path> [<prop>] - Print one level starting at <path>\n"
839 "fdt set <path> <prop> [<val>] - Set <property> [to <val>]\n"
840 "fdt mknode <path> <node> - Create a new node after <path>\n"
841 "fdt rm <path> [<prop>] - Delete the node or <property>\n"
Kumar Gala804887e2008-02-15 03:34:36 -0600842 "fdt header - Display header info\n"
843 "fdt bootcpu <id> - Set boot cpuid\n"
844 "fdt memory <addr> <size> - Add/Update memory node\n"
845 "fdt rsvmem print - Show current mem reserves\n"
846 "fdt rsvmem add <addr> <size> - Add a mem reserve\n"
847 "fdt rsvmem delete <index> - Delete a mem reserves\n"
Kumar Galaf953d992008-08-15 08:24:34 -0500848 "fdt chosen [<start> <end>] - Add/update the /chosen branch in the tree\n"
849 " <start>/<end> - initrd start/end addr\n"
Gerald Van Baren109c30f2008-08-22 14:37:05 -0400850 "NOTE: Dereference aliases by omiting the leading '/', "
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200851 "e.g. fdt print ethernet0."
Gerald Van Baren781e09e2007-03-31 12:22:10 -0400852);