ft_build.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /*
  2. * OF flat tree builder
  3. */
  4. #include <common.h>
  5. #include <malloc.h>
  6. #include <environment.h>
  7. #ifdef CONFIG_OF_FLAT_TREE
  8. #include <asm/errno.h>
  9. #include <stddef.h>
  10. #include <ft_build.h>
  11. /* align addr on a size boundary - adjust address up if needed -- Cort */
  12. #define _ALIGN(addr,size) (((addr)+(size)-1)&(~((size)-1)))
  13. static void ft_put_word(struct ft_cxt *cxt, u32 v)
  14. {
  15. if (cxt->overflow) /* do nothing */
  16. return;
  17. /* check for overflow */
  18. if (cxt->p + 4 > cxt->pstr) {
  19. cxt->overflow = 1;
  20. return;
  21. }
  22. *(u32 *) cxt->p = cpu_to_be32(v);
  23. cxt->p += 4;
  24. }
  25. static inline void ft_put_bin(struct ft_cxt *cxt, const void *data, int sz)
  26. {
  27. u8 *p;
  28. if (cxt->overflow) /* do nothing */
  29. return;
  30. /* next pointer pos */
  31. p = (u8 *) _ALIGN((unsigned long)cxt->p + sz, 4);
  32. /* check for overflow */
  33. if (p > cxt->pstr) {
  34. cxt->overflow = 1;
  35. return;
  36. }
  37. memcpy(cxt->p, data, sz);
  38. if ((sz & 3) != 0)
  39. memset(cxt->p + sz, 0, 4 - (sz & 3));
  40. cxt->p = p;
  41. }
  42. void ft_begin_node(struct ft_cxt *cxt, const char *name)
  43. {
  44. ft_put_word(cxt, OF_DT_BEGIN_NODE);
  45. ft_put_bin(cxt, name, strlen(name) + 1);
  46. }
  47. void ft_end_node(struct ft_cxt *cxt)
  48. {
  49. ft_put_word(cxt, OF_DT_END_NODE);
  50. }
  51. void ft_nop(struct ft_cxt *cxt)
  52. {
  53. ft_put_word(cxt, OF_DT_NOP);
  54. }
  55. static int lookup_string(struct ft_cxt *cxt, const char *name)
  56. {
  57. u8 *p;
  58. p = cxt->pstr;
  59. while (p < cxt->pstr_begin) {
  60. if (strcmp(p, name) == 0)
  61. return p - cxt->p_begin;
  62. p += strlen(p) + 1;
  63. }
  64. return -1;
  65. }
  66. void ft_prop(struct ft_cxt *cxt, const char *name, const void *data, int sz)
  67. {
  68. int len, off;
  69. if (cxt->overflow)
  70. return;
  71. len = strlen(name) + 1;
  72. off = lookup_string(cxt, name);
  73. if (off == -1) {
  74. /* check if we have space */
  75. if (cxt->p + 12 + sz + len > cxt->pstr) {
  76. cxt->overflow = 1;
  77. return;
  78. }
  79. cxt->pstr -= len;
  80. memcpy(cxt->pstr, name, len);
  81. off = cxt->pstr - cxt->p_begin;
  82. }
  83. /* now put offset from beginning of *STRUCTURE* */
  84. /* will be fixed up at the end */
  85. ft_put_word(cxt, OF_DT_PROP);
  86. ft_put_word(cxt, sz);
  87. ft_put_word(cxt, off);
  88. ft_put_bin(cxt, data, sz);
  89. }
  90. void ft_prop_str(struct ft_cxt *cxt, const char *name, const char *str)
  91. {
  92. ft_prop(cxt, name, str, strlen(str) + 1);
  93. }
  94. void ft_prop_int(struct ft_cxt *cxt, const char *name, int val)
  95. {
  96. u32 v = cpu_to_be32((u32) val);
  97. ft_prop(cxt, name, &v, 4);
  98. }
  99. /* start construction of the flat OF tree */
  100. void ft_begin(struct ft_cxt *cxt, void *blob, int max_size)
  101. {
  102. struct boot_param_header *bph = blob;
  103. u32 off;
  104. /* clear the cxt */
  105. memset(cxt, 0, sizeof(*cxt));
  106. cxt->bph = bph;
  107. cxt->max_size = max_size;
  108. /* zero everything in the header area */
  109. memset(bph, 0, sizeof(*bph));
  110. bph->magic = cpu_to_be32(OF_DT_HEADER);
  111. bph->version = cpu_to_be32(0x10);
  112. bph->last_comp_version = cpu_to_be32(0x10);
  113. /* start pointers */
  114. cxt->pres_begin = (u8 *) _ALIGN((unsigned long)(bph + 1), 8);
  115. cxt->pres = cxt->pres_begin;
  116. off = (unsigned long)cxt->pres_begin - (unsigned long)bph;
  117. bph->off_mem_rsvmap = cpu_to_be32(off);
  118. ((u64 *) cxt->pres)[0] = 0; /* phys = 0, size = 0, terminate */
  119. ((u64 *) cxt->pres)[1] = 0;
  120. cxt->p_anchor = cxt->pres + 16; /* over the terminator */
  121. }
  122. /* add a reserver physical area to the rsvmap */
  123. void ft_add_rsvmap(struct ft_cxt *cxt, u64 physaddr, u64 size)
  124. {
  125. ((u64 *) cxt->pres)[0] = cpu_to_be64(physaddr); /* phys = 0, size = 0, terminate */
  126. ((u64 *) cxt->pres)[1] = cpu_to_be64(size);
  127. cxt->pres += 16; /* advance */
  128. ((u64 *) cxt->pres)[0] = 0; /* phys = 0, size = 0, terminate */
  129. ((u64 *) cxt->pres)[1] = 0;
  130. /* keep track of size */
  131. cxt->res_size = cxt->pres + 16 - cxt->pres_begin;
  132. cxt->p_anchor = cxt->pres + 16; /* over the terminator */
  133. }
  134. void ft_begin_tree(struct ft_cxt *cxt)
  135. {
  136. cxt->p_begin = cxt->p_anchor;
  137. cxt->pstr_begin = (char *)cxt->bph + cxt->max_size; /* point at the end */
  138. cxt->p = cxt->p_begin;
  139. cxt->pstr = cxt->pstr_begin;
  140. }
  141. int ft_end_tree(struct ft_cxt *cxt)
  142. {
  143. struct boot_param_header *bph = cxt->bph;
  144. int off, sz, sz1;
  145. u32 tag, v;
  146. u8 *p;
  147. ft_put_word(cxt, OF_DT_END);
  148. if (cxt->overflow)
  149. return -ENOMEM;
  150. /* size of the areas */
  151. cxt->struct_size = cxt->p - cxt->p_begin;
  152. cxt->strings_size = cxt->pstr_begin - cxt->pstr;
  153. /* the offset we must move */
  154. off = (cxt->pstr_begin - cxt->p_begin) - cxt->strings_size;
  155. /* the new strings start */
  156. cxt->pstr_begin = cxt->p_begin + cxt->struct_size;
  157. /* move the whole string area */
  158. memmove(cxt->pstr_begin, cxt->pstr, cxt->strings_size);
  159. /* now perform the fixup of the strings */
  160. p = cxt->p_begin;
  161. while ((tag = be32_to_cpu(*(u32 *) p)) != OF_DT_END) {
  162. p += 4;
  163. if (tag == OF_DT_BEGIN_NODE) {
  164. p = (u8 *) _ALIGN((unsigned long)p + strlen(p) + 1, 4);
  165. continue;
  166. }
  167. if (tag == OF_DT_END_NODE || tag == OF_DT_NOP)
  168. continue;
  169. if (tag != OF_DT_PROP)
  170. return -EINVAL;
  171. sz = be32_to_cpu(*(u32 *) p);
  172. p += 4;
  173. v = be32_to_cpu(*(u32 *) p);
  174. v -= off;
  175. *(u32 *) p = cpu_to_be32(v); /* move down */
  176. p += 4;
  177. p = (u8 *) _ALIGN((unsigned long)p + sz, 4);
  178. }
  179. /* fix sizes */
  180. p = (char *)cxt->bph;
  181. sz = (cxt->pstr_begin + cxt->strings_size) - p;
  182. sz1 = _ALIGN(sz, 16); /* align at 16 bytes */
  183. if (sz != sz1)
  184. memset(p + sz, 0, sz1 - sz);
  185. bph->totalsize = cpu_to_be32(sz1);
  186. bph->off_dt_struct = cpu_to_be32(cxt->p_begin - p);
  187. bph->off_dt_strings = cpu_to_be32(cxt->pstr_begin - p);
  188. /* the new strings start */
  189. cxt->pstr_begin = cxt->p_begin + cxt->struct_size;
  190. cxt->pstr = cxt->pstr_begin + cxt->strings_size;
  191. return 0;
  192. }
  193. /**********************************************************************/
  194. static inline int isprint(int c)
  195. {
  196. return c >= 0x20 && c <= 0x7e;
  197. }
  198. static int is_printable_string(const void *data, int len)
  199. {
  200. const char *s = data;
  201. const char *ss;
  202. /* zero length is not */
  203. if (len == 0)
  204. return 0;
  205. /* must terminate with zero */
  206. if (s[len - 1] != '\0')
  207. return 0;
  208. ss = s;
  209. while (*s && isprint(*s))
  210. s++;
  211. /* not zero, or not done yet */
  212. if (*s != '\0' || (s + 1 - ss) < len)
  213. return 0;
  214. return 1;
  215. }
  216. static void print_data(const void *data, int len)
  217. {
  218. int i;
  219. const u8 *s;
  220. /* no data, don't print */
  221. if (len == 0)
  222. return;
  223. if (is_printable_string(data, len)) {
  224. puts(" = \"");
  225. puts(data);
  226. puts("\"");
  227. return;
  228. }
  229. switch (len) {
  230. case 1: /* byte */
  231. printf(" = <0x%02x>", (*(u8 *) data) & 0xff);
  232. break;
  233. case 2: /* half-word */
  234. printf(" = <0x%04x>", be16_to_cpu(*(u16 *) data) & 0xffff);
  235. break;
  236. case 4: /* word */
  237. printf(" = <0x%08x>", be32_to_cpu(*(u32 *) data) & 0xffffffffU);
  238. break;
  239. case 8: /* double-word */
  240. printf(" = <0x%16llx>", be64_to_cpu(*(uint64_t *) data));
  241. break;
  242. default: /* anything else... hexdump */
  243. printf(" = [");
  244. for (i = 0, s = data; i < len; i++)
  245. printf("%02x%s", s[i], i < len - 1 ? " " : "");
  246. printf("]");
  247. break;
  248. }
  249. }
  250. void ft_dump_blob(const void *bphp)
  251. {
  252. const struct boot_param_header *bph = bphp;
  253. const uint64_t *p_rsvmap = (const uint64_t *)
  254. ((const char *)bph + be32_to_cpu(bph->off_mem_rsvmap));
  255. const u32 *p_struct = (const u32 *)
  256. ((const char *)bph + be32_to_cpu(bph->off_dt_struct));
  257. const u32 *p_strings = (const u32 *)
  258. ((const char *)bph + be32_to_cpu(bph->off_dt_strings));
  259. u32 tag;
  260. const u32 *p;
  261. const char *s, *t;
  262. int depth, sz, shift;
  263. int i;
  264. uint64_t addr, size;
  265. if (be32_to_cpu(bph->magic) != OF_DT_HEADER) {
  266. /* not valid tree */
  267. return;
  268. }
  269. depth = 0;
  270. shift = 4;
  271. for (i = 0;; i++) {
  272. addr = be64_to_cpu(p_rsvmap[i * 2]);
  273. size = be64_to_cpu(p_rsvmap[i * 2 + 1]);
  274. if (addr == 0 && size == 0)
  275. break;
  276. printf("/memreserve/ 0x%llx 0x%llx;\n", addr, size);
  277. }
  278. p = p_struct;
  279. while ((tag = be32_to_cpu(*p++)) != OF_DT_END) {
  280. /* printf("tag: 0x%08x (%d)\n", tag, p - p_struct); */
  281. if (tag == OF_DT_BEGIN_NODE) {
  282. s = (const char *)p;
  283. p = (u32 *) _ALIGN((unsigned long)p + strlen(s) + 1, 4);
  284. printf("%*s%s {\n", depth * shift, "", s);
  285. depth++;
  286. continue;
  287. }
  288. if (tag == OF_DT_END_NODE) {
  289. depth--;
  290. printf("%*s};\n", depth * shift, "");
  291. continue;
  292. }
  293. if (tag == OF_DT_NOP) {
  294. printf("%*s[NOP]\n", depth * shift, "");
  295. continue;
  296. }
  297. if (tag != OF_DT_PROP) {
  298. fprintf(stderr, "%*s ** Unknown tag 0x%08x\n",
  299. depth * shift, "", tag);
  300. break;
  301. }
  302. sz = be32_to_cpu(*p++);
  303. s = (const char *)p_strings + be32_to_cpu(*p++);
  304. t = (const char *)p;
  305. p = (const u32 *)_ALIGN((unsigned long)p + sz, 4);
  306. printf("%*s%s", depth * shift, "", s);
  307. print_data(t, sz);
  308. printf(";\n");
  309. }
  310. }
  311. void ft_backtrack_node(struct ft_cxt *cxt)
  312. {
  313. if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE)
  314. return; /* XXX only for node */
  315. cxt->p -= 4;
  316. }
  317. /* note that the root node of the blob is "peeled" off */
  318. void ft_merge_blob(struct ft_cxt *cxt, void *blob)
  319. {
  320. struct boot_param_header *bph = (struct boot_param_header *)blob;
  321. u32 *p_struct = (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_struct));
  322. u32 *p_strings =
  323. (u32 *) ((char *)bph + be32_to_cpu(bph->off_dt_strings));
  324. u32 tag, *p;
  325. char *s, *t;
  326. int depth, sz;
  327. if (be32_to_cpu(*(u32 *) (cxt->p - 4)) != OF_DT_END_NODE)
  328. return; /* XXX only for node */
  329. cxt->p -= 4;
  330. depth = 0;
  331. p = p_struct;
  332. while ((tag = be32_to_cpu(*p++)) != OF_DT_END) {
  333. /* printf("tag: 0x%08x (%d) - %d\n", tag, p - p_struct, depth); */
  334. if (tag == OF_DT_BEGIN_NODE) {
  335. s = (char *)p;
  336. p = (u32 *) _ALIGN((unsigned long)p + strlen(s) + 1, 4);
  337. if (depth++ > 0)
  338. ft_begin_node(cxt, s);
  339. continue;
  340. }
  341. if (tag == OF_DT_END_NODE) {
  342. ft_end_node(cxt);
  343. if (--depth == 0)
  344. break;
  345. continue;
  346. }
  347. if (tag == OF_DT_NOP)
  348. continue;
  349. if (tag != OF_DT_PROP)
  350. break;
  351. sz = be32_to_cpu(*p++);
  352. s = (char *)p_strings + be32_to_cpu(*p++);
  353. t = (char *)p;
  354. p = (u32 *) _ALIGN((unsigned long)p + sz, 4);
  355. ft_prop(cxt, s, t, sz);
  356. }
  357. }
  358. void *ft_get_prop(void *bphp, const char *propname, int *szp)
  359. {
  360. struct boot_param_header *bph = bphp;
  361. uint32_t *p_struct =
  362. (uint32_t *) ((char *)bph + be32_to_cpu(bph->off_dt_struct));
  363. uint32_t *p_strings =
  364. (uint32_t *) ((char *)bph + be32_to_cpu(bph->off_dt_strings));
  365. uint32_t version = be32_to_cpu(bph->version);
  366. uint32_t tag;
  367. uint32_t *p;
  368. char *s, *t;
  369. char *ss;
  370. int sz;
  371. static char path[256], prop[256];
  372. path[0] = '\0';
  373. p = p_struct;
  374. while ((tag = be32_to_cpu(*p++)) != OF_DT_END) {
  375. if (tag == OF_DT_BEGIN_NODE) {
  376. s = (char *)p;
  377. p = (uint32_t *) _ALIGN((unsigned long)p + strlen(s) +
  378. 1, 4);
  379. strcat(path, s);
  380. strcat(path, "/");
  381. continue;
  382. }
  383. if (tag == OF_DT_END_NODE) {
  384. path[strlen(path) - 1] = '\0';
  385. ss = strrchr(path, '/');
  386. if (ss != NULL)
  387. ss[1] = '\0';
  388. continue;
  389. }
  390. if (tag == OF_DT_NOP)
  391. continue;
  392. if (tag != OF_DT_PROP)
  393. break;
  394. sz = be32_to_cpu(*p++);
  395. s = (char *)p_strings + be32_to_cpu(*p++);
  396. if (version < 0x10 && sz >= 8)
  397. p = (uint32_t *) _ALIGN((unsigned long)p, 8);
  398. t = (char *)p;
  399. p = (uint32_t *) _ALIGN((unsigned long)p + sz, 4);
  400. strcpy(prop, path);
  401. strcat(prop, s);
  402. if (strcmp(prop, propname) == 0) {
  403. *szp = sz;
  404. return t;
  405. }
  406. }
  407. return NULL;
  408. }
  409. /********************************************************************/
  410. extern unsigned char oftree_dtb[];
  411. extern unsigned int oftree_dtb_len;
  412. /* Function that returns a character from the environment */
  413. extern uchar(*env_get_char) (int);
  414. #define BDM(x) { .name = #x, .offset = offsetof(bd_t, bi_ ##x ) }
  415. #ifdef CONFIG_OF_HAS_BD_T
  416. static const struct {
  417. const char *name;
  418. int offset;
  419. } bd_map[] = {
  420. BDM(memstart),
  421. BDM(memsize),
  422. BDM(flashstart),
  423. BDM(flashsize),
  424. BDM(flashoffset),
  425. BDM(sramstart),
  426. BDM(sramsize),
  427. #if defined(CONFIG_5xx) || defined(CONFIG_8xx) || defined(CONFIG_8260) \
  428. || defined(CONFIG_E500)
  429. BDM(immr_base),
  430. #endif
  431. #if defined(CONFIG_MPC5xxx)
  432. BDM(mbar_base),
  433. #endif
  434. #if defined(CONFIG_MPC83XX)
  435. BDM(immrbar),
  436. #endif
  437. #if defined(CONFIG_MPC8220)
  438. BDM(mbar_base),
  439. BDM(inpfreq),
  440. BDM(pcifreq),
  441. BDM(pevfreq),
  442. BDM(flbfreq),
  443. BDM(vcofreq),
  444. #endif
  445. BDM(bootflags),
  446. BDM(ip_addr),
  447. BDM(intfreq),
  448. BDM(busfreq),
  449. #ifdef CONFIG_CPM2
  450. BDM(cpmfreq),
  451. BDM(brgfreq),
  452. BDM(sccfreq),
  453. BDM(vco),
  454. #endif
  455. #if defined(CONFIG_MPC5xxx)
  456. BDM(ipbfreq),
  457. BDM(pcifreq),
  458. #endif
  459. BDM(baudrate),
  460. };
  461. #endif
  462. void ft_setup(void *blob, int size, bd_t * bd, ulong initrd_start, ulong initrd_end)
  463. {
  464. u32 *p;
  465. int len;
  466. struct ft_cxt cxt;
  467. ulong clock;
  468. #if defined(CONFIG_OF_HAS_UBOOT_ENV)
  469. int k, nxt;
  470. #endif
  471. #if defined(CONFIG_OF_HAS_BD_T)
  472. u8 *end;
  473. #endif
  474. #if defined(CONFIG_OF_HAS_UBOOT_ENV) || defined(CONFIG_OF_HAS_BD_T)
  475. int i;
  476. static char tmpenv[256];
  477. #endif
  478. /* disable OF tree; booting old kernel */
  479. if (getenv("disable_of") != NULL) {
  480. memcpy(blob, bd, sizeof(*bd));
  481. return;
  482. }
  483. ft_begin(&cxt, blob, size);
  484. if (initrd_start && initrd_end)
  485. ft_add_rsvmap(&cxt, initrd_start, initrd_end - initrd_start + 1);
  486. ft_begin_tree(&cxt);
  487. ft_begin_node(&cxt, "");
  488. ft_end_node(&cxt);
  489. /* copy RO tree */
  490. ft_merge_blob(&cxt, oftree_dtb);
  491. /* back into root */
  492. ft_backtrack_node(&cxt);
  493. #ifdef CONFIG_OF_HAS_UBOOT_ENV
  494. ft_begin_node(&cxt, "u-boot-env");
  495. for (i = 0; env_get_char(i) != '\0'; i = nxt + 1) {
  496. char *s, *lval, *rval;
  497. for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) ;
  498. s = tmpenv;
  499. for (k = i; k < nxt && s < &tmpenv[sizeof(tmpenv) - 1]; ++k)
  500. *s++ = env_get_char(k);
  501. *s++ = '\0';
  502. lval = tmpenv;
  503. s = strchr(tmpenv, '=');
  504. if (s != NULL) {
  505. *s++ = '\0';
  506. rval = s;
  507. } else
  508. continue;
  509. ft_prop_str(&cxt, lval, rval);
  510. }
  511. ft_end_node(&cxt);
  512. #endif
  513. ft_begin_node(&cxt, "chosen");
  514. ft_prop_str(&cxt, "name", "chosen");
  515. ft_prop_str(&cxt, "bootargs", getenv("bootargs"));
  516. ft_prop_int(&cxt, "linux,platform", 0x600); /* what is this? */
  517. if (initrd_start && initrd_end) {
  518. ft_prop_int(&cxt, "linux,initrd-start", initrd_start);
  519. ft_prop_int(&cxt, "linux,initrd-end", initrd_end);
  520. }
  521. #ifdef OF_STDOUT_PATH
  522. ft_prop_str(&cxt, "linux,stdout-path", OF_STDOUT_PATH);
  523. #endif
  524. ft_end_node(&cxt);
  525. ft_end_node(&cxt); /* end root */
  526. ft_end_tree(&cxt);
  527. /*
  528. printf("merged OF-tree\n");
  529. ft_dump_blob(blob);
  530. */
  531. #ifdef CONFIG_OF_HAS_BD_T
  532. /* paste the bd_t at the end of the flat tree */
  533. end = (char *)blob +
  534. be32_to_cpu(((struct boot_param_header *)blob)->totalsize);
  535. memcpy(end, bd, sizeof(*bd));
  536. #endif
  537. #ifdef CONFIG_PPC
  538. #ifdef CONFIG_OF_HAS_BD_T
  539. for (i = 0; i < sizeof(bd_map)/sizeof(bd_map[0]); i++) {
  540. uint32_t v;
  541. sprintf(tmpenv, "/bd_t/%s", bd_map[i].name);
  542. v = *(uint32_t *)((char *)bd + bd_map[i].offset);
  543. p = ft_get_prop(blob, tmpenv, &len);
  544. if (p != NULL)
  545. *p = cpu_to_be32(v);
  546. }
  547. p = ft_get_prop(blob, "/bd_t/enetaddr", &len);
  548. if (p != NULL)
  549. memcpy(p, bd->bi_enetaddr, 6);
  550. p = ft_get_prop(blob, "/bd_t/ethspeed", &len);
  551. if (p != NULL)
  552. *p = cpu_to_be32((uint32_t) bd->bi_ethspeed);
  553. #endif
  554. clock = bd->bi_intfreq;
  555. p = ft_get_prop(blob, "/cpus/" OF_CPU "/clock-frequency", &len);
  556. if (p != NULL)
  557. *p = cpu_to_be32(clock);
  558. #ifdef OF_TBCLK
  559. clock = OF_TBCLK;
  560. p = ft_get_prop(blob, "/cpus/" OF_CPU "/timebase-frequency", &len);
  561. if (p != NULL)
  562. *p = cpu_to_be32(clock);
  563. #endif
  564. #endif /* __powerpc__ */
  565. #ifdef CONFIG_OF_BOARD_SETUP
  566. ft_board_setup(blob, bd);
  567. #endif
  568. /*
  569. printf("final OF-tree\n");
  570. ft_dump_blob(blob);
  571. */
  572. }
  573. #endif