Commit 4b5786550db2da6192f8d5f38eeccbb372f878a8
Committed by
Tom Rini
1 parent
76b8f79c29
Exists in
master
and in
53 other branches
fdt: Allow fdt command to check and update control FDT
There is an existing fdt command to deal with the working FDT. Enhance this to support the control FDT also (CONFIG_OF_CONTROL). Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 34 additions and 13 deletions Side-by-side Diff
common/cmd_fdt.c
... | ... | @@ -100,38 +100,59 @@ |
100 | 100 | */ |
101 | 101 | if (argv[1][0] == 'a') { |
102 | 102 | unsigned long addr; |
103 | + int control = 0; | |
104 | + struct fdt_header *blob; | |
103 | 105 | /* |
104 | 106 | * Set the address [and length] of the fdt. |
105 | 107 | */ |
106 | - if (argc == 2) { | |
107 | - if (!fdt_valid(&working_fdt)) | |
108 | + argc -= 2; | |
109 | + argv += 2; | |
110 | +/* Temporary #ifdef - some archs don't have fdt_blob yet */ | |
111 | +#ifdef CONFIG_OF_CONTROL | |
112 | + if (argc && !strcmp(*argv, "-c")) { | |
113 | + control = 1; | |
114 | + argc--; | |
115 | + argv++; | |
116 | + } | |
117 | +#endif | |
118 | + if (argc == 0) { | |
119 | + if (control) | |
120 | + blob = (struct fdt_header *)gd->fdt_blob; | |
121 | + else | |
122 | + blob = working_fdt; | |
123 | + if (!blob || !fdt_valid(&blob)) | |
108 | 124 | return 1; |
109 | - printf("The address of the fdt is %p\n", working_fdt); | |
125 | + printf("The address of the fdt is %#08lx\n", | |
126 | + control ? (ulong)blob : | |
127 | + getenv_hex("fdtaddr", 0)); | |
110 | 128 | return 0; |
111 | 129 | } |
112 | 130 | |
113 | - addr = simple_strtoul(argv[2], NULL, 16); | |
114 | - set_working_fdt_addr((void *)addr); | |
115 | - | |
116 | - if (!fdt_valid(&working_fdt)) | |
131 | + addr = simple_strtoul(argv[0], NULL, 16); | |
132 | + blob = (struct fdt_header *)addr; | |
133 | + if (!fdt_valid(&blob)) | |
117 | 134 | return 1; |
135 | + if (control) | |
136 | + gd->fdt_blob = blob; | |
137 | + else | |
138 | + set_working_fdt_addr((void *)addr); | |
118 | 139 | |
119 | - if (argc >= 4) { | |
140 | + if (argc >= 2) { | |
120 | 141 | int len; |
121 | 142 | int err; |
122 | 143 | /* |
123 | 144 | * Optional new length |
124 | 145 | */ |
125 | - len = simple_strtoul(argv[3], NULL, 16); | |
126 | - if (len < fdt_totalsize(working_fdt)) { | |
146 | + len = simple_strtoul(argv[1], NULL, 16); | |
147 | + if (len < fdt_totalsize(blob)) { | |
127 | 148 | printf ("New length %d < existing length %d, " |
128 | 149 | "ignoring.\n", |
129 | - len, fdt_totalsize(working_fdt)); | |
150 | + len, fdt_totalsize(blob)); | |
130 | 151 | } else { |
131 | 152 | /* |
132 | 153 | * Open in place with a new length. |
133 | 154 | */ |
134 | - err = fdt_open_into(working_fdt, working_fdt, len); | |
155 | + err = fdt_open_into(blob, blob, len); | |
135 | 156 | if (err != 0) { |
136 | 157 | printf ("libfdt fdt_open_into(): %s\n", |
137 | 158 | fdt_strerror(err)); |
... | ... | @@ -960,7 +981,7 @@ |
960 | 981 | /********************************************************************/ |
961 | 982 | #ifdef CONFIG_SYS_LONGHELP |
962 | 983 | static char fdt_help_text[] = |
963 | - "addr <addr> [<length>] - Set the fdt location to <addr>\n" | |
984 | + "addr [-c] <addr> [<length>] - Set the [control] fdt location to <addr>\n" | |
964 | 985 | #ifdef CONFIG_OF_BOARD_SETUP |
965 | 986 | "fdt boardsetup - Do board-specific set up\n" |
966 | 987 | #endif |