aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtc/dtc.c
diff options
context:
space:
mode:
authorJohn Bonesio <bones@secretlab.ca>2010-11-17 18:28:20 -0500
committerGrant Likely <grant.likely@secretlab.ca>2011-01-03 18:02:49 -0500
commit658f29a51e9830e620bb9a1ce3534b318a38bfeb (patch)
treee6cc7cd9b9e17d97308619fd8516b77bcc038114 /scripts/dtc/dtc.c
parentcd1e65044d4473cca9a01bae7b7938f065044a4b (diff)
of/flattree: Update dtc to current mainline.
Pull in recent changes from the main dtc repository. These changes primarily allow multiple device trees to be declared which are merged by dtc. This feature allows us to include a basic dts file and then provide more information for the specific system through the merging functionality. Changes pulled from git://git.jdl.com/software/dtc.git commit id: 37c0b6a0, "dtc: Add code to make diffing trees easier" Signed-off-by: John Bonesio <bones@secretlab.ca> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'scripts/dtc/dtc.c')
-rw-r--r--scripts/dtc/dtc.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/scripts/dtc/dtc.c b/scripts/dtc/dtc.c
index d8fd43b4ac1a..cbc0193098e4 100644
--- a/scripts/dtc/dtc.c
+++ b/scripts/dtc/dtc.c
@@ -30,30 +30,7 @@ int quiet; /* Level of quietness */
30int reservenum; /* Number of memory reservation slots */ 30int reservenum; /* Number of memory reservation slots */
31int minsize; /* Minimum blob size */ 31int minsize; /* Minimum blob size */
32int padsize; /* Additional padding to blob */ 32int padsize; /* Additional padding to blob */
33 33int phandle_format = PHANDLE_BOTH; /* Use linux,phandle or phandle properties */
34char *join_path(const char *path, const char *name)
35{
36 int lenp = strlen(path);
37 int lenn = strlen(name);
38 int len;
39 int needslash = 1;
40 char *str;
41
42 len = lenp + lenn + 2;
43 if ((lenp > 0) && (path[lenp-1] == '/')) {
44 needslash = 0;
45 len--;
46 }
47
48 str = xmalloc(len);
49 memcpy(str, path, lenp);
50 if (needslash) {
51 str[lenp] = '/';
52 lenp++;
53 }
54 memcpy(str+lenp, name, lenn+1);
55 return str;
56}
57 34
58static void fill_fullpaths(struct node *tree, const char *prefix) 35static void fill_fullpaths(struct node *tree, const char *prefix)
59{ 36{
@@ -104,8 +81,15 @@ static void __attribute__ ((noreturn)) usage(void)
104 fprintf(stderr, "\t\tSet the physical boot cpu\n"); 81 fprintf(stderr, "\t\tSet the physical boot cpu\n");
105 fprintf(stderr, "\t-f\n"); 82 fprintf(stderr, "\t-f\n");
106 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n"); 83 fprintf(stderr, "\t\tForce - try to produce output even if the input tree has errors\n");
84 fprintf(stderr, "\t-s\n");
85 fprintf(stderr, "\t\tSort nodes and properties before outputting (only useful for\n\t\tcomparing trees)\n");
107 fprintf(stderr, "\t-v\n"); 86 fprintf(stderr, "\t-v\n");
108 fprintf(stderr, "\t\tPrint DTC version and exit\n"); 87 fprintf(stderr, "\t\tPrint DTC version and exit\n");
88 fprintf(stderr, "\t-H <phandle format>\n");
89 fprintf(stderr, "\t\tphandle formats are:\n");
90 fprintf(stderr, "\t\t\tlegacy - \"linux,phandle\" properties only\n");
91 fprintf(stderr, "\t\t\tepapr - \"phandle\" properties only\n");
92 fprintf(stderr, "\t\t\tboth - Both \"linux,phandle\" and \"phandle\" properties\n");
109 exit(3); 93 exit(3);
110} 94}
111 95
@@ -115,7 +99,7 @@ int main(int argc, char *argv[])
115 const char *inform = "dts"; 99 const char *inform = "dts";
116 const char *outform = "dts"; 100 const char *outform = "dts";
117 const char *outname = "-"; 101 const char *outname = "-";
118 int force = 0, check = 0; 102 int force = 0, check = 0, sort = 0;
119 const char *arg; 103 const char *arg;
120 int opt; 104 int opt;
121 FILE *outf = NULL; 105 FILE *outf = NULL;
@@ -127,7 +111,7 @@ int main(int argc, char *argv[])
127 minsize = 0; 111 minsize = 0;
128 padsize = 0; 112 padsize = 0;
129 113
130 while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:v")) != EOF) { 114 while ((opt = getopt(argc, argv, "hI:O:o:V:R:S:p:fcqb:vH:s")) != EOF) {
131 switch (opt) { 115 switch (opt) {
132 case 'I': 116 case 'I':
133 inform = optarg; 117 inform = optarg;
@@ -165,6 +149,22 @@ int main(int argc, char *argv[])
165 case 'v': 149 case 'v':
166 printf("Version: %s\n", DTC_VERSION); 150 printf("Version: %s\n", DTC_VERSION);
167 exit(0); 151 exit(0);
152 case 'H':
153 if (streq(optarg, "legacy"))
154 phandle_format = PHANDLE_LEGACY;
155 else if (streq(optarg, "epapr"))
156 phandle_format = PHANDLE_EPAPR;
157 else if (streq(optarg, "both"))
158 phandle_format = PHANDLE_BOTH;
159 else
160 die("Invalid argument \"%s\" to -H option\n",
161 optarg);
162 break;
163
164 case 's':
165 sort = 1;
166 break;
167
168 case 'h': 168 case 'h':
169 default: 169 default:
170 usage(); 170 usage();
@@ -182,6 +182,9 @@ int main(int argc, char *argv[])
182 if (minsize && padsize) 182 if (minsize && padsize)
183 die("Can't set both -p and -S\n"); 183 die("Can't set both -p and -S\n");
184 184
185 if (minsize)
186 fprintf(stderr, "DTC: Use of \"-S\" is deprecated; it will be removed soon, use \"-p\" instead\n");
187
185 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", 188 fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
186 inform, outform, arg); 189 inform, outform, arg);
187 190
@@ -200,6 +203,8 @@ int main(int argc, char *argv[])
200 fill_fullpaths(bi->dt, ""); 203 fill_fullpaths(bi->dt, "");
201 process_checks(force, bi); 204 process_checks(force, bi);
202 205
206 if (sort)
207 sort_tree(bi);
203 208
204 if (streq(outname, "-")) { 209 if (streq(outname, "-")) {
205 outf = stdout; 210 outf = stdout;