Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 1 | /* |
| 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 Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 31 | #include <asm/global_data.h> |
| 32 | #include <fdt.h> |
| 33 | #include <libfdt.h> |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 34 | #include <fdt_support.h> |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 35 | |
| 36 | #define MAX_LEVEL 32 /* how deeply nested we will go */ |
Gerald Van Baren | fd61e55 | 2007-06-25 23:25:28 -0400 | [diff] [blame] | 37 | #define SCRATCHPAD 1024 /* bytes of scratchpad memory */ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 38 | |
| 39 | /* |
| 40 | * Global data (for the gd->bd) |
| 41 | */ |
| 42 | DECLARE_GLOBAL_DATA_PTR; |
| 43 | |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 44 | static int fdt_valid(void); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 45 | static int fdt_parse_prop(char *pathp, char *prop, char *newval, |
| 46 | char *data, int *len); |
Kumar Gala | dbaf07c | 2007-11-21 14:07:46 -0600 | [diff] [blame] | 47 | static int fdt_print(const char *pathp, char *prop, int depth); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 48 | |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 49 | /* |
| 50 | * Flattened Device Tree command, see the help for parameter definitions. |
| 51 | */ |
| 52 | int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) |
| 53 | { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 54 | if (argc < 2) { |
| 55 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 56 | return 1; |
| 57 | } |
| 58 | |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 59 | /******************************************************************** |
| 60 | * Set the address of the fdt |
| 61 | ********************************************************************/ |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 62 | if (argv[1][0] == 'a') { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 63 | /* |
| 64 | * Set the address [and length] of the fdt. |
| 65 | */ |
| 66 | fdt = (struct fdt_header *)simple_strtoul(argv[2], NULL, 16); |
| 67 | |
| 68 | if (!fdt_valid()) { |
| 69 | return 1; |
| 70 | } |
| 71 | |
| 72 | if (argc >= 4) { |
| 73 | int len; |
| 74 | int err; |
| 75 | /* |
| 76 | * Optional new length |
| 77 | */ |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 78 | len = simple_strtoul(argv[3], NULL, 16); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 79 | if (len < fdt_totalsize(fdt)) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 80 | printf ("New length %d < existing length %d, " |
| 81 | "ignoring.\n", |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 82 | len, fdt_totalsize(fdt)); |
| 83 | } else { |
| 84 | /* |
| 85 | * Open in place with a new length. |
| 86 | */ |
| 87 | err = fdt_open_into(fdt, fdt, len); |
| 88 | if (err != 0) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 89 | printf ("libfdt fdt_open_into(): %s\n", |
| 90 | fdt_strerror(err)); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /******************************************************************** |
| 96 | * Move the fdt |
| 97 | ********************************************************************/ |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 98 | } else if ((argv[1][0] == 'm') && (argv[1][1] == 'o')) { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 99 | struct fdt_header *newaddr; |
| 100 | int len; |
| 101 | int err; |
| 102 | |
Gerald Van Baren | 6be07cc | 2007-04-25 22:47:15 -0400 | [diff] [blame] | 103 | if (argc < 4) { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 104 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 105 | return 1; |
| 106 | } |
| 107 | |
| 108 | /* |
| 109 | * Set the address and length of the fdt. |
| 110 | */ |
| 111 | fdt = (struct fdt_header *)simple_strtoul(argv[2], NULL, 16); |
| 112 | if (!fdt_valid()) { |
| 113 | return 1; |
| 114 | } |
| 115 | |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 116 | newaddr = (struct fdt_header *)simple_strtoul(argv[3],NULL,16); |
Gerald Van Baren | 6be07cc | 2007-04-25 22:47:15 -0400 | [diff] [blame] | 117 | |
| 118 | /* |
| 119 | * If the user specifies a length, use that. Otherwise use the |
| 120 | * current length. |
| 121 | */ |
| 122 | if (argc <= 4) { |
| 123 | len = fdt_totalsize(fdt); |
| 124 | } else { |
| 125 | len = simple_strtoul(argv[4], NULL, 16); |
| 126 | if (len < fdt_totalsize(fdt)) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 127 | printf ("New length 0x%X < existing length " |
| 128 | "0x%X, aborting.\n", |
Gerald Van Baren | 6be07cc | 2007-04-25 22:47:15 -0400 | [diff] [blame] | 129 | len, fdt_totalsize(fdt)); |
| 130 | return 1; |
| 131 | } |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /* |
| 135 | * Copy to the new location. |
| 136 | */ |
| 137 | err = fdt_open_into(fdt, newaddr, len); |
| 138 | if (err != 0) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 139 | printf ("libfdt fdt_open_into(): %s\n", |
| 140 | fdt_strerror(err)); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 141 | return 1; |
| 142 | } |
| 143 | fdt = newaddr; |
| 144 | |
| 145 | /******************************************************************** |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 146 | * Make a new node |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 147 | ********************************************************************/ |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 148 | } else if ((argv[1][0] == 'm') && (argv[1][1] == 'k')) { |
| 149 | char *pathp; /* path */ |
| 150 | char *nodep; /* new node to add */ |
| 151 | int nodeoffset; /* node offset from libfdt */ |
| 152 | int err; |
| 153 | |
| 154 | /* |
| 155 | * Parameters: Node path, new node to be appended to the path. |
| 156 | */ |
| 157 | if (argc < 4) { |
| 158 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 159 | return 1; |
| 160 | } |
| 161 | |
| 162 | pathp = argv[2]; |
| 163 | nodep = argv[3]; |
| 164 | |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 165 | nodeoffset = fdt_path_offset (fdt, pathp); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 166 | if (nodeoffset < 0) { |
| 167 | /* |
| 168 | * Not found or something else bad happened. |
| 169 | */ |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 170 | printf ("libfdt fdt_path_offset() returned %s\n", |
Gerald Van Baren | 06e19a0 | 2007-05-21 23:27:16 -0400 | [diff] [blame] | 171 | fdt_strerror(nodeoffset)); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 172 | return 1; |
| 173 | } |
| 174 | err = fdt_add_subnode(fdt, nodeoffset, nodep); |
| 175 | if (err < 0) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 176 | printf ("libfdt fdt_add_subnode(): %s\n", |
| 177 | fdt_strerror(err)); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 178 | return 1; |
| 179 | } |
| 180 | |
| 181 | /******************************************************************** |
| 182 | * Set the value of a property in the fdt. |
| 183 | ********************************************************************/ |
| 184 | } else if (argv[1][0] == 's') { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 185 | char *pathp; /* path */ |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 186 | char *prop; /* property */ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 187 | int nodeoffset; /* node offset from libfdt */ |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 188 | static char data[SCRATCHPAD]; /* storage for the property */ |
| 189 | int len; /* new length of the property */ |
| 190 | int ret; /* return value */ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 191 | |
| 192 | /* |
Gerald Van Baren | ea6d8be | 2008-01-05 14:52:04 -0500 | [diff] [blame] | 193 | * Parameters: Node path, property, optional value. |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 194 | */ |
Gerald Van Baren | ea6d8be | 2008-01-05 14:52:04 -0500 | [diff] [blame] | 195 | if (argc < 4) { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 196 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 197 | return 1; |
| 198 | } |
| 199 | |
| 200 | pathp = argv[2]; |
| 201 | prop = argv[3]; |
Gerald Van Baren | ea6d8be | 2008-01-05 14:52:04 -0500 | [diff] [blame] | 202 | if (argc == 4) { |
| 203 | len = 0; |
| 204 | } else { |
| 205 | ret = fdt_parse_prop(pathp, prop, argv[4], data, &len); |
| 206 | if (ret != 0) |
| 207 | return ret; |
| 208 | } |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 209 | |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 210 | nodeoffset = fdt_path_offset (fdt, pathp); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 211 | if (nodeoffset < 0) { |
| 212 | /* |
| 213 | * Not found or something else bad happened. |
| 214 | */ |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 215 | printf ("libfdt fdt_path_offset() returned %s\n", |
Gerald Van Baren | 06e19a0 | 2007-05-21 23:27:16 -0400 | [diff] [blame] | 216 | fdt_strerror(nodeoffset)); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 217 | return 1; |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 218 | } |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 219 | |
| 220 | ret = fdt_setprop(fdt, nodeoffset, prop, data, len); |
| 221 | if (ret < 0) { |
| 222 | printf ("libfdt fdt_setprop(): %s\n", fdt_strerror(ret)); |
| 223 | return 1; |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | /******************************************************************** |
| 227 | * Print (recursive) / List (single level) |
| 228 | ********************************************************************/ |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 229 | } else if ((argv[1][0] == 'p') || (argv[1][0] == 'l')) { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 230 | int depth = MAX_LEVEL; /* how deep to print */ |
| 231 | char *pathp; /* path */ |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 232 | char *prop; /* property */ |
| 233 | int ret; /* return value */ |
Kumar Gala | f738b4a | 2007-10-25 16:15:07 -0500 | [diff] [blame] | 234 | static char root[2] = "/"; |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 235 | |
| 236 | /* |
| 237 | * list is an alias for print, but limited to 1 level |
| 238 | */ |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 239 | if (argv[1][0] == 'l') { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 240 | depth = 1; |
| 241 | } |
| 242 | |
| 243 | /* |
| 244 | * Get the starting path. The root node is an oddball, |
| 245 | * the offset is zero and has no name. |
| 246 | */ |
Kumar Gala | f738b4a | 2007-10-25 16:15:07 -0500 | [diff] [blame] | 247 | if (argc == 2) |
| 248 | pathp = root; |
| 249 | else |
| 250 | pathp = argv[2]; |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 251 | if (argc > 3) |
| 252 | prop = argv[3]; |
| 253 | else |
| 254 | prop = NULL; |
| 255 | |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 256 | ret = fdt_print(pathp, prop, depth); |
| 257 | if (ret != 0) |
| 258 | return ret; |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 259 | |
| 260 | /******************************************************************** |
| 261 | * Remove a property/node |
| 262 | ********************************************************************/ |
Kumar Gala | 804887e | 2008-02-15 03:34:36 -0600 | [diff] [blame] | 263 | } else if ((argv[1][0] == 'r') && (argv[1][1] == 'm')) { |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 264 | int nodeoffset; /* node offset from libfdt */ |
| 265 | int err; |
| 266 | |
| 267 | /* |
| 268 | * Get the path. The root node is an oddball, the offset |
| 269 | * is zero and has no name. |
| 270 | */ |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 271 | nodeoffset = fdt_path_offset (fdt, argv[2]); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 272 | if (nodeoffset < 0) { |
| 273 | /* |
| 274 | * Not found or something else bad happened. |
| 275 | */ |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 276 | printf ("libfdt fdt_path_offset() returned %s\n", |
Gerald Van Baren | 06e19a0 | 2007-05-21 23:27:16 -0400 | [diff] [blame] | 277 | fdt_strerror(nodeoffset)); |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 278 | return 1; |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 279 | } |
| 280 | /* |
| 281 | * Do the delete. A fourth parameter means delete a property, |
| 282 | * otherwise delete the node. |
| 283 | */ |
| 284 | if (argc > 3) { |
| 285 | err = fdt_delprop(fdt, nodeoffset, argv[3]); |
| 286 | if (err < 0) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 287 | printf("libfdt fdt_delprop(): %s\n", |
| 288 | fdt_strerror(err)); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 289 | return err; |
| 290 | } |
| 291 | } else { |
| 292 | err = fdt_del_node(fdt, nodeoffset); |
| 293 | if (err < 0) { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 294 | printf("libfdt fdt_del_node(): %s\n", |
| 295 | fdt_strerror(err)); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 296 | return err; |
| 297 | } |
| 298 | } |
Kumar Gala | 804887e | 2008-02-15 03:34:36 -0600 | [diff] [blame] | 299 | |
| 300 | /******************************************************************** |
| 301 | * Display header info |
| 302 | ********************************************************************/ |
| 303 | } else if (argv[1][0] == 'h') { |
| 304 | u32 version = fdt_version(fdt); |
| 305 | printf("magic:\t\t\t0x%x\n", fdt_magic(fdt)); |
| 306 | printf("totalsize:\t\t0x%x (%d)\n", fdt_totalsize(fdt), fdt_totalsize(fdt)); |
| 307 | printf("off_dt_struct:\t\t0x%x\n", fdt_off_dt_struct(fdt)); |
| 308 | printf("off_dt_strings:\t\t0x%x\n", fdt_off_dt_strings(fdt)); |
| 309 | printf("off_mem_rsvmap:\t\t0x%x\n", fdt_off_mem_rsvmap(fdt)); |
| 310 | printf("version:\t\t%d\n", version); |
| 311 | printf("last_comp_version:\t%d\n", fdt_last_comp_version(fdt)); |
| 312 | if (version >= 2) |
| 313 | printf("boot_cpuid_phys:\t0x%x\n", |
| 314 | fdt_boot_cpuid_phys(fdt)); |
| 315 | if (version >= 3) |
| 316 | printf("size_dt_strings:\t0x%x\n", |
| 317 | fdt_size_dt_strings(fdt)); |
| 318 | if (version >= 17) |
| 319 | printf("size_dt_struct:\t\t0x%x\n", |
| 320 | fdt_size_dt_struct(fdt)); |
| 321 | printf("number mem_rsv:\t\t0x%x\n", fdt_num_mem_rsv(fdt)); |
| 322 | printf("\n"); |
| 323 | |
| 324 | /******************************************************************** |
| 325 | * Set boot cpu id |
| 326 | ********************************************************************/ |
Kumar Gala | fe30a35 | 2008-02-20 14:32:36 -0600 | [diff] [blame] | 327 | } else if ((argv[1][0] == 'b') && (argv[1][1] == 'o') && |
| 328 | (argv[1][2] == 'o')) { |
Kumar Gala | 804887e | 2008-02-15 03:34:36 -0600 | [diff] [blame] | 329 | unsigned long tmp = simple_strtoul(argv[2], NULL, 16); |
| 330 | fdt_set_boot_cpuid_phys(fdt, tmp); |
| 331 | |
| 332 | /******************************************************************** |
| 333 | * memory command |
| 334 | ********************************************************************/ |
| 335 | } else if ((argv[1][0] == 'm') && (argv[1][1] == 'e')) { |
| 336 | uint64_t addr, size; |
| 337 | int err; |
| 338 | #ifdef CFG_64BIT_STRTOUL |
| 339 | addr = simple_strtoull(argv[2], NULL, 16); |
| 340 | size = simple_strtoull(argv[3], NULL, 16); |
| 341 | #else |
| 342 | addr = simple_strtoul(argv[2], NULL, 16); |
| 343 | size = simple_strtoul(argv[3], NULL, 16); |
| 344 | #endif |
| 345 | err = fdt_fixup_memory(fdt, addr, size); |
| 346 | if (err < 0) |
| 347 | return err; |
| 348 | |
| 349 | /******************************************************************** |
| 350 | * mem reserve commands |
| 351 | ********************************************************************/ |
| 352 | } else if ((argv[1][0] == 'r') && (argv[1][1] == 's')) { |
| 353 | if (argv[2][0] == 'p') { |
| 354 | uint64_t addr, size; |
| 355 | int total = fdt_num_mem_rsv(fdt); |
| 356 | int j, err; |
| 357 | printf("index\t\t start\t\t size\n"); |
| 358 | printf("-------------------------------" |
| 359 | "-----------------\n"); |
| 360 | for (j = 0; j < total; j++) { |
| 361 | err = fdt_get_mem_rsv(fdt, j, &addr, &size); |
| 362 | if (err < 0) { |
| 363 | printf("libfdt fdt_get_mem_rsv(): %s\n", |
| 364 | fdt_strerror(err)); |
| 365 | return err; |
| 366 | } |
| 367 | printf(" %x\t%08x%08x\t%08x%08x\n", j, |
| 368 | (u32)(addr >> 32), |
| 369 | (u32)(addr & 0xffffffff), |
| 370 | (u32)(size >> 32), |
| 371 | (u32)(size & 0xffffffff)); |
| 372 | } |
| 373 | } else if (argv[2][0] == 'a') { |
| 374 | uint64_t addr, size; |
| 375 | int err; |
| 376 | #ifdef CFG_64BIT_STRTOUL |
| 377 | addr = simple_strtoull(argv[3], NULL, 16); |
| 378 | size = simple_strtoull(argv[4], NULL, 16); |
| 379 | #else |
| 380 | addr = simple_strtoul(argv[3], NULL, 16); |
| 381 | size = simple_strtoul(argv[4], NULL, 16); |
| 382 | #endif |
| 383 | err = fdt_add_mem_rsv(fdt, addr, size); |
| 384 | |
| 385 | if (err < 0) { |
| 386 | printf("libfdt fdt_add_mem_rsv(): %s\n", |
| 387 | fdt_strerror(err)); |
| 388 | return err; |
| 389 | } |
| 390 | } else if (argv[2][0] == 'd') { |
| 391 | unsigned long idx = simple_strtoul(argv[3], NULL, 16); |
| 392 | int err = fdt_del_mem_rsv(fdt, idx); |
| 393 | |
| 394 | if (err < 0) { |
| 395 | printf("libfdt fdt_del_mem_rsv(): %s\n", |
| 396 | fdt_strerror(err)); |
| 397 | return err; |
| 398 | } |
| 399 | } else { |
| 400 | /* Unrecognized command */ |
| 401 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 402 | return 1; |
| 403 | } |
Kim Phillips | 99dffca | 2007-07-17 13:57:04 -0500 | [diff] [blame] | 404 | } |
Gerald Van Baren | fd61e55 | 2007-06-25 23:25:28 -0400 | [diff] [blame] | 405 | #ifdef CONFIG_OF_BOARD_SETUP |
Kim Phillips | 99dffca | 2007-07-17 13:57:04 -0500 | [diff] [blame] | 406 | /* Call the board-specific fixup routine */ |
| 407 | else if (argv[1][0] == 'b') |
Gerald Van Baren | fd61e55 | 2007-06-25 23:25:28 -0400 | [diff] [blame] | 408 | ft_board_setup(fdt, gd->bd); |
| 409 | #endif |
Kim Phillips | 99dffca | 2007-07-17 13:57:04 -0500 | [diff] [blame] | 410 | /* Create a chosen node */ |
| 411 | else if (argv[1][0] == 'c') |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 412 | fdt_chosen(fdt, 0, 0, 1); |
Kim Phillips | 99dffca | 2007-07-17 13:57:04 -0500 | [diff] [blame] | 413 | else { |
| 414 | /* Unrecognized command */ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 415 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 416 | return 1; |
| 417 | } |
| 418 | |
| 419 | return 0; |
| 420 | } |
| 421 | |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 422 | /****************************************************************************/ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 423 | |
| 424 | static int fdt_valid(void) |
| 425 | { |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 426 | int err; |
| 427 | |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 428 | if (fdt == NULL) { |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 429 | printf ("The address of the fdt is invalid (NULL).\n"); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 430 | return 0; |
| 431 | } |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 432 | |
| 433 | err = fdt_check_header(fdt); |
| 434 | if (err == 0) |
| 435 | return 1; /* valid */ |
| 436 | |
| 437 | if (err < 0) { |
Gerald Van Baren | 2511403 | 2007-05-12 09:47:25 -0400 | [diff] [blame] | 438 | printf("libfdt fdt_check_header(): %s", fdt_strerror(err)); |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 439 | /* |
| 440 | * Be more informative on bad version. |
| 441 | */ |
| 442 | if (err == -FDT_ERR_BADVERSION) { |
| 443 | if (fdt_version(fdt) < FDT_FIRST_SUPPORTED_VERSION) { |
| 444 | printf (" - too old, fdt $d < %d", |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 445 | fdt_version(fdt), |
| 446 | FDT_FIRST_SUPPORTED_VERSION); |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 447 | fdt = NULL; |
| 448 | } |
| 449 | if (fdt_last_comp_version(fdt) > FDT_LAST_SUPPORTED_VERSION) { |
| 450 | printf (" - too new, fdt $d > %d", |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 451 | fdt_version(fdt), |
| 452 | FDT_LAST_SUPPORTED_VERSION); |
Gerald Van Baren | 64dbbd4 | 2007-04-06 14:19:43 -0400 | [diff] [blame] | 453 | fdt = NULL; |
| 454 | } |
| 455 | return 0; |
| 456 | } |
| 457 | printf("\n"); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 458 | return 0; |
| 459 | } |
| 460 | return 1; |
| 461 | } |
| 462 | |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 463 | /****************************************************************************/ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 464 | |
| 465 | /* |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 466 | * Parse the user's input, partially heuristic. Valid formats: |
| 467 | * <00> - hex byte |
| 468 | * <0011> - hex half word (16 bits) |
| 469 | * <00112233> - hex word (32 bits) |
| 470 | * - hex double words (64 bits) are not supported, must use |
| 471 | * a byte stream instead. |
| 472 | * [00 11 22 .. nn] - byte stream |
| 473 | * "string" - If the the value doesn't start with "<" or "[", it is |
| 474 | * treated as a string. Note that the quotes are |
| 475 | * stripped by the parser before we get the string. |
| 476 | */ |
| 477 | static int fdt_parse_prop(char *pathp, char *prop, char *newval, |
| 478 | char *data, int *len) |
| 479 | { |
| 480 | char *cp; /* temporary char pointer */ |
| 481 | unsigned long tmp; /* holds converted values */ |
| 482 | |
| 483 | if (*newval == '<') { |
| 484 | /* |
| 485 | * Bigger values than bytes. |
| 486 | */ |
| 487 | *len = 0; |
| 488 | newval++; |
| 489 | while ((*newval != '>') && (*newval != '\0')) { |
| 490 | cp = newval; |
| 491 | tmp = simple_strtoul(cp, &newval, 16); |
| 492 | if ((newval - cp) <= 2) { |
| 493 | *data = tmp & 0xFF; |
| 494 | data += 1; |
| 495 | *len += 1; |
| 496 | } else if ((newval - cp) <= 4) { |
| 497 | *(uint16_t *)data = __cpu_to_be16(tmp); |
| 498 | data += 2; |
| 499 | *len += 2; |
| 500 | } else if ((newval - cp) <= 8) { |
| 501 | *(uint32_t *)data = __cpu_to_be32(tmp); |
| 502 | data += 4; |
| 503 | *len += 4; |
| 504 | } else { |
| 505 | printf("Sorry, I could not convert \"%s\"\n", |
| 506 | cp); |
| 507 | return 1; |
| 508 | } |
| 509 | while (*newval == ' ') |
| 510 | newval++; |
| 511 | } |
| 512 | if (*newval != '>') { |
| 513 | printf("Unexpected character '%c'\n", *newval); |
| 514 | return 1; |
| 515 | } |
| 516 | } else if (*newval == '[') { |
| 517 | /* |
| 518 | * Byte stream. Convert the values. |
| 519 | */ |
| 520 | *len = 0; |
| 521 | newval++; |
| 522 | while ((*newval != ']') && (*newval != '\0')) { |
| 523 | tmp = simple_strtoul(newval, &newval, 16); |
| 524 | *data++ = tmp & 0xFF; |
Gerald Van Baren | fd61e55 | 2007-06-25 23:25:28 -0400 | [diff] [blame] | 525 | *len = *len + 1; |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 526 | while (*newval == ' ') |
| 527 | newval++; |
| 528 | } |
| 529 | if (*newval != ']') { |
| 530 | printf("Unexpected character '%c'\n", *newval); |
| 531 | return 1; |
| 532 | } |
| 533 | } else { |
| 534 | /* |
| 535 | * Assume it is a string. Copy it into our data area for |
| 536 | * convenience (including the terminating '\0'). |
| 537 | */ |
| 538 | *len = strlen(newval) + 1; |
| 539 | strcpy(data, newval); |
| 540 | } |
| 541 | return 0; |
| 542 | } |
| 543 | |
| 544 | /****************************************************************************/ |
| 545 | |
| 546 | /* |
| 547 | * Heuristic to guess if this is a string or concatenated strings. |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 548 | */ |
| 549 | |
| 550 | static int is_printable_string(const void *data, int len) |
| 551 | { |
| 552 | const char *s = data; |
| 553 | |
| 554 | /* zero length is not */ |
| 555 | if (len == 0) |
| 556 | return 0; |
| 557 | |
| 558 | /* must terminate with zero */ |
| 559 | if (s[len - 1] != '\0') |
| 560 | return 0; |
| 561 | |
| 562 | /* printable or a null byte (concatenated strings) */ |
| 563 | while (((*s == '\0') || isprint(*s)) && (len > 0)) { |
| 564 | /* |
| 565 | * If we see a null, there are three possibilities: |
| 566 | * 1) If len == 1, it is the end of the string, printable |
| 567 | * 2) Next character also a null, not printable. |
| 568 | * 3) Next character not a null, continue to check. |
| 569 | */ |
| 570 | if (s[0] == '\0') { |
| 571 | if (len == 1) |
| 572 | return 1; |
| 573 | if (s[1] == '\0') |
| 574 | return 0; |
| 575 | } |
| 576 | s++; |
| 577 | len--; |
| 578 | } |
| 579 | |
| 580 | /* Not the null termination, or not done yet: not printable */ |
| 581 | if (*s != '\0' || (len != 0)) |
| 582 | return 0; |
| 583 | |
| 584 | return 1; |
| 585 | } |
| 586 | |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 587 | |
| 588 | /* |
| 589 | * Print the property in the best format, a heuristic guess. Print as |
| 590 | * a string, concatenated strings, a byte, word, double word, or (if all |
| 591 | * else fails) it is printed as a stream of bytes. |
| 592 | */ |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 593 | static void print_data(const void *data, int len) |
| 594 | { |
| 595 | int j; |
| 596 | const u8 *s; |
| 597 | |
| 598 | /* no data, don't print */ |
| 599 | if (len == 0) |
| 600 | return; |
| 601 | |
| 602 | /* |
| 603 | * It is a string, but it may have multiple strings (embedded '\0's). |
| 604 | */ |
| 605 | if (is_printable_string(data, len)) { |
| 606 | puts("\""); |
| 607 | j = 0; |
| 608 | while (j < len) { |
| 609 | if (j > 0) |
| 610 | puts("\", \""); |
| 611 | puts(data); |
| 612 | j += strlen(data) + 1; |
| 613 | data += strlen(data) + 1; |
| 614 | } |
| 615 | puts("\""); |
| 616 | return; |
| 617 | } |
| 618 | |
| 619 | switch (len) { |
| 620 | case 1: /* byte */ |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 621 | printf("<0x%02x>", (*(u8 *) data) & 0xff); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 622 | break; |
| 623 | case 2: /* half-word */ |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 624 | printf("<0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 625 | break; |
| 626 | case 4: /* word */ |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 627 | printf("<0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 628 | break; |
| 629 | case 8: /* double-word */ |
| 630 | #if __WORDSIZE == 64 |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 631 | printf("<0x%016llx>", be64_to_cpu(*(uint64_t *) data)); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 632 | #else |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 633 | printf("<0x%08x ", be32_to_cpu(*(u32 *) data) & 0xffffffffU); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 634 | data += 4; |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 635 | printf("0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU); |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 636 | #endif |
| 637 | break; |
| 638 | default: /* anything else... hexdump */ |
| 639 | printf("["); |
| 640 | for (j = 0, s = data; j < len; j++) |
| 641 | printf("%02x%s", s[j], j < len - 1 ? " " : ""); |
| 642 | printf("]"); |
| 643 | |
| 644 | break; |
| 645 | } |
| 646 | } |
| 647 | |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 648 | /****************************************************************************/ |
| 649 | |
| 650 | /* |
| 651 | * Recursively print (a portion of) the fdt. The depth parameter |
| 652 | * determines how deeply nested the fdt is printed. |
| 653 | */ |
Kumar Gala | dbaf07c | 2007-11-21 14:07:46 -0600 | [diff] [blame] | 654 | static int fdt_print(const char *pathp, char *prop, int depth) |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 655 | { |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 656 | static char tabs[MAX_LEVEL+1] = |
| 657 | "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" |
| 658 | "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"; |
Kumar Gala | dbaf07c | 2007-11-21 14:07:46 -0600 | [diff] [blame] | 659 | const void *nodep; /* property node pointer */ |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 660 | int nodeoffset; /* node offset from libfdt */ |
| 661 | int nextoffset; /* next node offset from libfdt */ |
| 662 | uint32_t tag; /* tag */ |
| 663 | int len; /* length of the property */ |
| 664 | int level = 0; /* keep track of nesting level */ |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 665 | const struct fdt_property *fdt_prop; |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 666 | |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 667 | nodeoffset = fdt_path_offset (fdt, pathp); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 668 | if (nodeoffset < 0) { |
| 669 | /* |
| 670 | * Not found or something else bad happened. |
| 671 | */ |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 672 | printf ("libfdt fdt_path_offset() returned %s\n", |
Gerald Van Baren | 06e19a0 | 2007-05-21 23:27:16 -0400 | [diff] [blame] | 673 | fdt_strerror(nodeoffset)); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 674 | return 1; |
| 675 | } |
| 676 | /* |
| 677 | * The user passed in a property as well as node path. |
| 678 | * Print only the given property and then return. |
| 679 | */ |
| 680 | if (prop) { |
| 681 | nodep = fdt_getprop (fdt, nodeoffset, prop, &len); |
| 682 | if (len == 0) { |
| 683 | /* no property value */ |
| 684 | printf("%s %s\n", pathp, prop); |
| 685 | return 0; |
| 686 | } else if (len > 0) { |
Gerald Van Baren | 28f384b | 2007-11-23 19:43:20 -0500 | [diff] [blame] | 687 | printf("%s = ", prop); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 688 | print_data (nodep, len); |
| 689 | printf("\n"); |
| 690 | return 0; |
| 691 | } else { |
| 692 | printf ("libfdt fdt_getprop(): %s\n", |
| 693 | fdt_strerror(len)); |
| 694 | return 1; |
| 695 | } |
| 696 | } |
| 697 | |
| 698 | /* |
| 699 | * The user passed in a node path and no property, |
| 700 | * print the node and all subnodes. |
| 701 | */ |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 702 | while(level >= 0) { |
Kumar Gala | 8d04f02 | 2007-10-24 11:04:22 -0500 | [diff] [blame] | 703 | tag = fdt_next_tag(fdt, nodeoffset, &nextoffset); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 704 | switch(tag) { |
| 705 | case FDT_BEGIN_NODE: |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 706 | pathp = fdt_get_name(fdt, nodeoffset, NULL); |
| 707 | if (level <= depth) { |
| 708 | if (pathp == NULL) |
| 709 | pathp = "/* NULL pointer error */"; |
| 710 | if (*pathp == '\0') |
| 711 | pathp = "/"; /* root is nameless */ |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 712 | printf("%s%s {\n", |
| 713 | &tabs[MAX_LEVEL - level], pathp); |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 714 | } |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 715 | level++; |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 716 | if (level >= MAX_LEVEL) { |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 717 | printf("Nested too deep, aborting.\n"); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 718 | return 1; |
| 719 | } |
| 720 | break; |
| 721 | case FDT_END_NODE: |
| 722 | level--; |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 723 | if (level <= depth) |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 724 | printf("%s};\n", &tabs[MAX_LEVEL - level]); |
| 725 | if (level == 0) { |
| 726 | level = -1; /* exit the loop */ |
| 727 | } |
| 728 | break; |
| 729 | case FDT_PROP: |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 730 | fdt_prop = fdt_offset_ptr(fdt, nodeoffset, |
| 731 | sizeof(*fdt_prop)); |
| 732 | pathp = fdt_string(fdt, |
| 733 | fdt32_to_cpu(fdt_prop->nameoff)); |
| 734 | len = fdt32_to_cpu(fdt_prop->len); |
| 735 | nodep = fdt_prop->data; |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 736 | if (len < 0) { |
| 737 | printf ("libfdt fdt_getprop(): %s\n", |
| 738 | fdt_strerror(len)); |
| 739 | return 1; |
| 740 | } else if (len == 0) { |
| 741 | /* the property has no value */ |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 742 | if (level <= depth) |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 743 | printf("%s%s;\n", |
| 744 | &tabs[MAX_LEVEL - level], |
| 745 | pathp); |
| 746 | } else { |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 747 | if (level <= depth) { |
Gerald Van Baren | 28f384b | 2007-11-23 19:43:20 -0500 | [diff] [blame] | 748 | printf("%s%s = ", |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 749 | &tabs[MAX_LEVEL - level], |
| 750 | pathp); |
| 751 | print_data (nodep, len); |
| 752 | printf(";\n"); |
| 753 | } |
| 754 | } |
| 755 | break; |
| 756 | case FDT_NOP: |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 757 | printf("/* NOP */\n", &tabs[MAX_LEVEL - level]); |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 758 | break; |
| 759 | case FDT_END: |
| 760 | return 1; |
| 761 | default: |
Gerald Van Baren | 9162352 | 2007-11-22 17:23:23 -0500 | [diff] [blame] | 762 | if (level <= depth) |
Gerald Van Baren | addd8ce | 2007-05-16 22:39:59 -0400 | [diff] [blame] | 763 | printf("Unknown tag 0x%08X\n", tag); |
| 764 | return 1; |
| 765 | } |
| 766 | nodeoffset = nextoffset; |
| 767 | } |
| 768 | return 0; |
| 769 | } |
| 770 | |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 771 | /********************************************************************/ |
| 772 | |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 773 | U_BOOT_CMD( |
| 774 | fdt, 5, 0, do_fdt, |
| 775 | "fdt - flattened device tree utility commands\n", |
| 776 | "addr <addr> [<length>] - Set the fdt location to <addr>\n" |
Gerald Van Baren | fd61e55 | 2007-06-25 23:25:28 -0400 | [diff] [blame] | 777 | #ifdef CONFIG_OF_BOARD_SETUP |
| 778 | "fdt boardsetup - Do board-specific set up\n" |
| 779 | #endif |
Gerald Van Baren | 238cb7a | 2008-01-05 15:33:29 -0500 | [diff] [blame] | 780 | "fdt move <fdt> <newaddr> <length> - Copy the fdt to <addr> and make it active\n" |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 781 | "fdt print <path> [<prop>] - Recursive print starting at <path>\n" |
| 782 | "fdt list <path> [<prop>] - Print one level starting at <path>\n" |
| 783 | "fdt set <path> <prop> [<val>] - Set <property> [to <val>]\n" |
| 784 | "fdt mknode <path> <node> - Create a new node after <path>\n" |
| 785 | "fdt rm <path> [<prop>] - Delete the node or <property>\n" |
Kumar Gala | 804887e | 2008-02-15 03:34:36 -0600 | [diff] [blame] | 786 | "fdt header - Display header info\n" |
| 787 | "fdt bootcpu <id> - Set boot cpuid\n" |
| 788 | "fdt memory <addr> <size> - Add/Update memory node\n" |
| 789 | "fdt rsvmem print - Show current mem reserves\n" |
| 790 | "fdt rsvmem add <addr> <size> - Add a mem reserve\n" |
| 791 | "fdt rsvmem delete <index> - Delete a mem reserves\n" |
Gerald Van Baren | fd61e55 | 2007-06-25 23:25:28 -0400 | [diff] [blame] | 792 | "fdt chosen - Add/update the /chosen branch in the tree\n" |
Gerald Van Baren | 238cb7a | 2008-01-05 15:33:29 -0500 | [diff] [blame] | 793 | "NOTE: If the path or property you are setting/printing has a '#' character\n" |
| 794 | " or spaces, you MUST escape it with a \\ character or quote it with \".\n" |
Gerald Van Baren | 781e09e | 2007-03-31 12:22:10 -0400 | [diff] [blame] | 795 | ); |