embed_config.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. /* Board specific functions for those embedded 8xx boards that do
  2. * not have boot monitor support for board information.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. #include <linux/types.h>
  10. #include <linux/string.h>
  11. #include <asm/reg.h>
  12. #ifdef CONFIG_8xx
  13. #include <asm/mpc8xx.h>
  14. #endif
  15. #ifdef CONFIG_8260
  16. #include <asm/mpc8260.h>
  17. #include <asm/immap_cpm2.h>
  18. #endif
  19. #ifdef CONFIG_40x
  20. #include <asm/io.h>
  21. #endif
  22. #ifdef CONFIG_XILINX_VIRTEX
  23. #include <platforms/4xx/xparameters/xparameters.h>
  24. #endif
  25. extern unsigned long timebase_period_ns;
  26. /* For those boards that don't provide one.
  27. */
  28. #if !defined(CONFIG_MBX)
  29. static bd_t bdinfo;
  30. #endif
  31. /* IIC functions.
  32. * These are just the basic master read/write operations so we can
  33. * examine serial EEPROM.
  34. */
  35. extern void iic_read(uint devaddr, u_char *buf, uint offset, uint count);
  36. /* Supply a default Ethernet address for those eval boards that don't
  37. * ship with one. This is an address from the MBX board I have, so
  38. * it is unlikely you will find it on your network.
  39. */
  40. static ushort def_enet_addr[] = { 0x0800, 0x3e26, 0x1559 };
  41. #if defined(CONFIG_MBX)
  42. /* The MBX hands us a pretty much ready to go board descriptor. This
  43. * is where the idea started in the first place.
  44. */
  45. void
  46. embed_config(bd_t **bdp)
  47. {
  48. u_char *mp;
  49. u_char eebuf[128];
  50. int i = 8;
  51. bd_t *bd;
  52. bd = *bdp;
  53. /* Read the first 128 bytes of the EEPROM. There is more,
  54. * but this is all we need.
  55. */
  56. iic_read(0xa4, eebuf, 0, 128);
  57. /* All we are looking for is the Ethernet MAC address. The
  58. * first 8 bytes are 'MOTOROLA', so check for part of that.
  59. * Next, the VPD describes a MAC 'packet' as being of type 08
  60. * and size 06. So we look for that and the MAC must follow.
  61. * If there are more than one, we still only care about the first.
  62. * If it's there, assume we have a valid MAC address. If not,
  63. * grab our default one.
  64. */
  65. if ((*(uint *)eebuf) == 0x4d4f544f) {
  66. while (i < 127 && !(eebuf[i] == 0x08 && eebuf[i + 1] == 0x06))
  67. i += eebuf[i + 1] + 2; /* skip this packet */
  68. if (i == 127) /* Couldn't find. */
  69. mp = (u_char *)def_enet_addr;
  70. else
  71. mp = &eebuf[i + 2];
  72. }
  73. else
  74. mp = (u_char *)def_enet_addr;
  75. for (i=0; i<6; i++)
  76. bd->bi_enetaddr[i] = *mp++;
  77. /* The boot rom passes these to us in MHz. Linux now expects
  78. * them to be in Hz.
  79. */
  80. bd->bi_intfreq *= 1000000;
  81. bd->bi_busfreq *= 1000000;
  82. /* Stuff a baud rate here as well.
  83. */
  84. bd->bi_baudrate = 9600;
  85. }
  86. #endif /* CONFIG_MBX */
  87. #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC) || \
  88. defined(CONFIG_RPX8260) || defined(CONFIG_EP405)
  89. /* Helper functions for Embedded Planet boards.
  90. */
  91. /* Because I didn't find anything that would do this.......
  92. */
  93. u_char
  94. aschex_to_byte(u_char *cp)
  95. {
  96. u_char byte, c;
  97. c = *cp++;
  98. if ((c >= 'A') && (c <= 'F')) {
  99. c -= 'A';
  100. c += 10;
  101. } else if ((c >= 'a') && (c <= 'f')) {
  102. c -= 'a';
  103. c += 10;
  104. } else
  105. c -= '0';
  106. byte = c * 16;
  107. c = *cp;
  108. if ((c >= 'A') && (c <= 'F')) {
  109. c -= 'A';
  110. c += 10;
  111. } else if ((c >= 'a') && (c <= 'f')) {
  112. c -= 'a';
  113. c += 10;
  114. } else
  115. c -= '0';
  116. byte += c;
  117. return(byte);
  118. }
  119. static void
  120. rpx_eth(bd_t *bd, u_char *cp)
  121. {
  122. int i;
  123. for (i=0; i<6; i++) {
  124. bd->bi_enetaddr[i] = aschex_to_byte(cp);
  125. cp += 2;
  126. }
  127. }
  128. #ifdef CONFIG_RPX8260
  129. static uint
  130. rpx_baseten(u_char *cp)
  131. {
  132. uint retval;
  133. retval = 0;
  134. while (*cp != '\n') {
  135. retval *= 10;
  136. retval += (*cp) - '0';
  137. cp++;
  138. }
  139. return(retval);
  140. }
  141. #endif
  142. #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
  143. static void
  144. rpx_brate(bd_t *bd, u_char *cp)
  145. {
  146. uint rate;
  147. rate = 0;
  148. while (*cp != '\n') {
  149. rate *= 10;
  150. rate += (*cp) - '0';
  151. cp++;
  152. }
  153. bd->bi_baudrate = rate * 100;
  154. }
  155. static void
  156. rpx_cpuspeed(bd_t *bd, u_char *cp)
  157. {
  158. uint num, den;
  159. num = den = 0;
  160. while (*cp != '\n') {
  161. num *= 10;
  162. num += (*cp) - '0';
  163. cp++;
  164. if (*cp == '/') {
  165. cp++;
  166. den = (*cp) - '0';
  167. break;
  168. }
  169. }
  170. /* I don't know why the RPX just can't state the actual
  171. * CPU speed.....
  172. */
  173. if (den) {
  174. num /= den;
  175. num *= den;
  176. }
  177. bd->bi_intfreq = bd->bi_busfreq = num * 1000000;
  178. /* The 8xx can only run a maximum 50 MHz bus speed (until
  179. * Motorola changes this :-). Greater than 50 MHz parts
  180. * run internal/2 for bus speed.
  181. */
  182. if (num > 50)
  183. bd->bi_busfreq /= 2;
  184. }
  185. #endif
  186. #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC) || defined(CONFIG_EP405)
  187. static void
  188. rpx_memsize(bd_t *bd, u_char *cp)
  189. {
  190. uint size;
  191. size = 0;
  192. while (*cp != '\n') {
  193. size *= 10;
  194. size += (*cp) - '0';
  195. cp++;
  196. }
  197. bd->bi_memsize = size * 1024 * 1024;
  198. }
  199. #endif /* LITE || CLASSIC || EP405 */
  200. #if defined(CONFIG_EP405)
  201. static void
  202. rpx_nvramsize(bd_t *bd, u_char *cp)
  203. {
  204. uint size;
  205. size = 0;
  206. while (*cp != '\n') {
  207. size *= 10;
  208. size += (*cp) - '0';
  209. cp++;
  210. }
  211. bd->bi_nvramsize = size * 1024;
  212. }
  213. #endif /* CONFIG_EP405 */
  214. #endif /* Embedded Planet boards */
  215. #if defined(CONFIG_RPXLITE) || defined(CONFIG_RPXCLASSIC)
  216. /* Read the EEPROM on the RPX-Lite board.
  217. */
  218. void
  219. embed_config(bd_t **bdp)
  220. {
  221. u_char eebuf[256], *cp;
  222. bd_t *bd;
  223. /* Read the first 256 bytes of the EEPROM. I think this
  224. * is really all there is, and I hope if it gets bigger the
  225. * info we want is still up front.
  226. */
  227. bd = &bdinfo;
  228. *bdp = bd;
  229. #if 1
  230. iic_read(0xa8, eebuf, 0, 128);
  231. iic_read(0xa8, &eebuf[128], 128, 128);
  232. /* We look for two things, the Ethernet address and the
  233. * serial baud rate. The records are separated by
  234. * newlines.
  235. */
  236. cp = eebuf;
  237. for (;;) {
  238. if (*cp == 'E') {
  239. cp++;
  240. if (*cp == 'A') {
  241. cp += 2;
  242. rpx_eth(bd, cp);
  243. }
  244. }
  245. if (*cp == 'S') {
  246. cp++;
  247. if (*cp == 'B') {
  248. cp += 2;
  249. rpx_brate(bd, cp);
  250. }
  251. }
  252. if (*cp == 'D') {
  253. cp++;
  254. if (*cp == '1') {
  255. cp += 2;
  256. rpx_memsize(bd, cp);
  257. }
  258. }
  259. if (*cp == 'H') {
  260. cp++;
  261. if (*cp == 'Z') {
  262. cp += 2;
  263. rpx_cpuspeed(bd, cp);
  264. }
  265. }
  266. /* Scan to the end of the record.
  267. */
  268. while ((*cp != '\n') && (*cp != 0xff))
  269. cp++;
  270. /* If the next character is a 0 or ff, we are done.
  271. */
  272. cp++;
  273. if ((*cp == 0) || (*cp == 0xff))
  274. break;
  275. }
  276. bd->bi_memstart = 0;
  277. #else
  278. /* For boards without initialized EEPROM.
  279. */
  280. bd->bi_memstart = 0;
  281. bd->bi_memsize = (8 * 1024 * 1024);
  282. bd->bi_intfreq = 48000000;
  283. bd->bi_busfreq = 48000000;
  284. bd->bi_baudrate = 9600;
  285. #endif
  286. }
  287. #endif /* RPXLITE || RPXCLASSIC */
  288. #ifdef CONFIG_BSEIP
  289. /* Build a board information structure for the BSE ip-Engine.
  290. * There is more to come since we will add some environment
  291. * variables and a function to read them.
  292. */
  293. void
  294. embed_config(bd_t **bdp)
  295. {
  296. u_char *cp;
  297. int i;
  298. bd_t *bd;
  299. bd = &bdinfo;
  300. *bdp = bd;
  301. /* Baud rate and processor speed will eventually come
  302. * from the environment variables.
  303. */
  304. bd->bi_baudrate = 9600;
  305. /* Get the Ethernet station address from the Flash ROM.
  306. */
  307. cp = (u_char *)0xfe003ffa;
  308. for (i=0; i<6; i++) {
  309. bd->bi_enetaddr[i] = *cp++;
  310. }
  311. /* The rest of this should come from the environment as well.
  312. */
  313. bd->bi_memstart = 0;
  314. bd->bi_memsize = (16 * 1024 * 1024);
  315. bd->bi_intfreq = 48000000;
  316. bd->bi_busfreq = 48000000;
  317. }
  318. #endif /* BSEIP */
  319. #ifdef CONFIG_FADS
  320. /* Build a board information structure for the FADS.
  321. */
  322. void
  323. embed_config(bd_t **bdp)
  324. {
  325. u_char *cp;
  326. int i;
  327. bd_t *bd;
  328. bd = &bdinfo;
  329. *bdp = bd;
  330. /* Just fill in some known values.
  331. */
  332. bd->bi_baudrate = 9600;
  333. /* Use default enet.
  334. */
  335. cp = (u_char *)def_enet_addr;
  336. for (i=0; i<6; i++) {
  337. bd->bi_enetaddr[i] = *cp++;
  338. }
  339. bd->bi_memstart = 0;
  340. bd->bi_memsize = (8 * 1024 * 1024);
  341. bd->bi_intfreq = 40000000;
  342. bd->bi_busfreq = 40000000;
  343. }
  344. #endif /* FADS */
  345. #ifdef CONFIG_8260
  346. /* Compute 8260 clock values if the rom doesn't provide them.
  347. */
  348. static unsigned char bus2core_8260[] = {
  349. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  350. 3, 2, 2, 2, 4, 4, 5, 9, 6, 11, 8, 10, 3, 12, 7, 2,
  351. 6, 5, 13, 2, 14, 4, 15, 2, 3, 11, 8, 10, 16, 12, 7, 2,
  352. };
  353. static void
  354. clk_8260(bd_t *bd)
  355. {
  356. uint scmr, vco_out, clkin;
  357. uint plldf, pllmf, corecnf;
  358. volatile cpm2_map_t *ip;
  359. ip = (cpm2_map_t *)CPM_MAP_ADDR;
  360. scmr = ip->im_clkrst.car_scmr;
  361. /* The clkin is always bus frequency.
  362. */
  363. clkin = bd->bi_busfreq;
  364. /* Collect the bits from the scmr.
  365. */
  366. plldf = (scmr >> 12) & 1;
  367. pllmf = scmr & 0xfff;
  368. corecnf = (scmr >> 24) &0x1f;
  369. /* This is arithmetic from the 8260 manual.
  370. */
  371. vco_out = clkin / (plldf + 1);
  372. vco_out *= 2 * (pllmf + 1);
  373. bd->bi_vco = vco_out; /* Save for later */
  374. bd->bi_cpmfreq = vco_out / 2; /* CPM Freq, in MHz */
  375. bd->bi_intfreq = bd->bi_busfreq * bus2core_8260[corecnf] / 2;
  376. /* Set Baud rate divisor. The power up default is divide by 16,
  377. * but we set it again here in case it was changed.
  378. */
  379. ip->im_clkrst.car_sccr = 1; /* DIV 16 BRG */
  380. bd->bi_brgfreq = vco_out / 16;
  381. }
  382. static unsigned char bus2core_8280[] = {
  383. /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
  384. 3, 2, 2, 2, 4, 4, 5, 9, 6, 11, 8, 10, 3, 12, 7, 2,
  385. 6, 5, 13, 2, 14, 2, 15, 2, 3, 2, 2, 2, 16, 2, 2, 2,
  386. };
  387. static void
  388. clk_8280(bd_t *bd)
  389. {
  390. uint scmr, main_clk, clkin;
  391. uint pllmf, corecnf;
  392. volatile cpm2_map_t *ip;
  393. ip = (cpm2_map_t *)CPM_MAP_ADDR;
  394. scmr = ip->im_clkrst.car_scmr;
  395. /* The clkin is always bus frequency.
  396. */
  397. clkin = bd->bi_busfreq;
  398. /* Collect the bits from the scmr.
  399. */
  400. pllmf = scmr & 0xf;
  401. corecnf = (scmr >> 24) & 0x1f;
  402. /* This is arithmetic from the 8280 manual.
  403. */
  404. main_clk = clkin * (pllmf + 1);
  405. bd->bi_cpmfreq = main_clk / 2; /* CPM Freq, in MHz */
  406. bd->bi_intfreq = bd->bi_busfreq * bus2core_8280[corecnf] / 2;
  407. /* Set Baud rate divisor. The power up default is divide by 16,
  408. * but we set it again here in case it was changed.
  409. */
  410. ip->im_clkrst.car_sccr = (ip->im_clkrst.car_sccr & 0x3) | 0x1;
  411. bd->bi_brgfreq = main_clk / 16;
  412. }
  413. #endif
  414. #ifdef CONFIG_SBC82xx
  415. void
  416. embed_config(bd_t **bdp)
  417. {
  418. u_char *cp;
  419. int i;
  420. bd_t *bd;
  421. unsigned long pvr;
  422. bd = *bdp;
  423. bd = &bdinfo;
  424. *bdp = bd;
  425. bd->bi_baudrate = 9600;
  426. bd->bi_memsize = 256 * 1024 * 1024; /* just a guess */
  427. cp = (void*)SBC82xx_MACADDR_NVRAM_SCC1;
  428. memcpy(bd->bi_enetaddr, cp, 6);
  429. /* can busfreq be calculated? */
  430. pvr = mfspr(SPRN_PVR);
  431. if ((pvr & 0xffff0000) == 0x80820000) {
  432. bd->bi_busfreq = 100000000;
  433. clk_8280(bd);
  434. } else {
  435. bd->bi_busfreq = 66000000;
  436. clk_8260(bd);
  437. }
  438. }
  439. #endif /* SBC82xx */
  440. #if defined(CONFIG_EST8260) || defined(CONFIG_TQM8260)
  441. void
  442. embed_config(bd_t **bdp)
  443. {
  444. u_char *cp;
  445. int i;
  446. bd_t *bd;
  447. bd = *bdp;
  448. #if 0
  449. /* This is actually provided by my boot rom. I have it
  450. * here for those people that may load the kernel with
  451. * a JTAG/COP tool and not the rom monitor.
  452. */
  453. bd->bi_baudrate = 115200;
  454. bd->bi_intfreq = 200000000;
  455. bd->bi_busfreq = 66666666;
  456. bd->bi_cpmfreq = 66666666;
  457. bd->bi_brgfreq = 33333333;
  458. bd->bi_memsize = 16 * 1024 * 1024;
  459. #else
  460. /* The boot rom passes these to us in MHz. Linux now expects
  461. * them to be in Hz.
  462. */
  463. bd->bi_intfreq *= 1000000;
  464. bd->bi_busfreq *= 1000000;
  465. bd->bi_cpmfreq *= 1000000;
  466. bd->bi_brgfreq *= 1000000;
  467. #endif
  468. cp = (u_char *)def_enet_addr;
  469. for (i=0; i<6; i++) {
  470. bd->bi_enetaddr[i] = *cp++;
  471. }
  472. }
  473. #endif /* EST8260 */
  474. #ifdef CONFIG_SBS8260
  475. void
  476. embed_config(bd_t **bdp)
  477. {
  478. u_char *cp;
  479. int i;
  480. bd_t *bd;
  481. /* This should provided by the boot rom.
  482. */
  483. bd = &bdinfo;
  484. *bdp = bd;
  485. bd->bi_baudrate = 9600;
  486. bd->bi_memsize = 64 * 1024 * 1024;
  487. /* Set all of the clocks. We have to know the speed of the
  488. * external clock. The development board had 66 MHz.
  489. */
  490. bd->bi_busfreq = 66666666;
  491. clk_8260(bd);
  492. /* I don't know how to compute this yet.
  493. */
  494. bd->bi_intfreq = 133000000;
  495. cp = (u_char *)def_enet_addr;
  496. for (i=0; i<6; i++) {
  497. bd->bi_enetaddr[i] = *cp++;
  498. }
  499. }
  500. #endif /* SBS8260 */
  501. #ifdef CONFIG_RPX8260
  502. void
  503. embed_config(bd_t **bdp)
  504. {
  505. u_char *cp, *keyvals;
  506. int i;
  507. bd_t *bd;
  508. keyvals = (u_char *)*bdp;
  509. bd = &bdinfo;
  510. *bdp = bd;
  511. /* This is almost identical to the RPX-Lite/Classic functions
  512. * on the 8xx boards. It would be nice to have a key lookup
  513. * function in a string, but the format of all of the fields
  514. * is slightly different.
  515. */
  516. cp = keyvals;
  517. for (;;) {
  518. if (*cp == 'E') {
  519. cp++;
  520. if (*cp == 'A') {
  521. cp += 2;
  522. rpx_eth(bd, cp);
  523. }
  524. }
  525. if (*cp == 'S') {
  526. cp++;
  527. if (*cp == 'B') {
  528. cp += 2;
  529. bd->bi_baudrate = rpx_baseten(cp);
  530. }
  531. }
  532. if (*cp == 'D') {
  533. cp++;
  534. if (*cp == '1') {
  535. cp += 2;
  536. bd->bi_memsize = rpx_baseten(cp) * 1024 * 1024;
  537. }
  538. }
  539. if (*cp == 'X') {
  540. cp++;
  541. if (*cp == 'T') {
  542. cp += 2;
  543. bd->bi_busfreq = rpx_baseten(cp);
  544. }
  545. }
  546. if (*cp == 'N') {
  547. cp++;
  548. if (*cp == 'V') {
  549. cp += 2;
  550. bd->bi_nvsize = rpx_baseten(cp) * 1024 * 1024;
  551. }
  552. }
  553. /* Scan to the end of the record.
  554. */
  555. while ((*cp != '\n') && (*cp != 0xff))
  556. cp++;
  557. /* If the next character is a 0 or ff, we are done.
  558. */
  559. cp++;
  560. if ((*cp == 0) || (*cp == 0xff))
  561. break;
  562. }
  563. bd->bi_memstart = 0;
  564. /* The memory size includes both the 60x and local bus DRAM.
  565. * I don't want to use the local bus DRAM for real memory,
  566. * so subtract it out. It would be nice if they were separate
  567. * keys.
  568. */
  569. bd->bi_memsize -= 32 * 1024 * 1024;
  570. /* Set all of the clocks. We have to know the speed of the
  571. * external clock.
  572. */
  573. clk_8260(bd);
  574. /* I don't know how to compute this yet.
  575. */
  576. bd->bi_intfreq = 200000000;
  577. }
  578. #endif /* RPX6 for testing */
  579. #ifdef CONFIG_ADS8260
  580. void
  581. embed_config(bd_t **bdp)
  582. {
  583. u_char *cp;
  584. int i;
  585. bd_t *bd;
  586. /* This should provided by the boot rom.
  587. */
  588. bd = &bdinfo;
  589. *bdp = bd;
  590. bd->bi_baudrate = 9600;
  591. bd->bi_memsize = 16 * 1024 * 1024;
  592. /* Set all of the clocks. We have to know the speed of the
  593. * external clock. The development board had 66 MHz.
  594. */
  595. bd->bi_busfreq = 66666666;
  596. clk_8260(bd);
  597. /* I don't know how to compute this yet.
  598. */
  599. bd->bi_intfreq = 200000000;
  600. cp = (u_char *)def_enet_addr;
  601. for (i=0; i<6; i++) {
  602. bd->bi_enetaddr[i] = *cp++;
  603. }
  604. }
  605. #endif /* ADS8260 */
  606. #ifdef CONFIG_WILLOW
  607. void
  608. embed_config(bd_t **bdp)
  609. {
  610. u_char *cp;
  611. int i;
  612. bd_t *bd;
  613. /* Willow has Open Firmware....I should learn how to get this
  614. * information from it.
  615. */
  616. bd = &bdinfo;
  617. *bdp = bd;
  618. bd->bi_baudrate = 9600;
  619. bd->bi_memsize = 32 * 1024 * 1024;
  620. /* Set all of the clocks. We have to know the speed of the
  621. * external clock. The development board had 66 MHz.
  622. */
  623. bd->bi_busfreq = 66666666;
  624. clk_8260(bd);
  625. /* I don't know how to compute this yet.
  626. */
  627. bd->bi_intfreq = 200000000;
  628. cp = (u_char *)def_enet_addr;
  629. for (i=0; i<6; i++) {
  630. bd->bi_enetaddr[i] = *cp++;
  631. }
  632. }
  633. #endif /* WILLOW */
  634. #if defined(CONFIG_XILINX_ML300) || defined(CONFIG_XILINX_ML403)
  635. void
  636. embed_config(bd_t ** bdp)
  637. {
  638. static const unsigned long line_size = 32;
  639. static const unsigned long congruence_classes = 256;
  640. unsigned long addr;
  641. unsigned long dccr;
  642. bd_t *bd;
  643. /*
  644. * Invalidate the data cache if the data cache is turned off.
  645. * - The 405 core does not invalidate the data cache on power-up
  646. * or reset but does turn off the data cache. We cannot assume
  647. * that the cache contents are valid.
  648. * - If the data cache is turned on this must have been done by
  649. * a bootloader and we assume that the cache contents are
  650. * valid.
  651. */
  652. __asm__("mfdccr %0": "=r" (dccr));
  653. if (dccr == 0) {
  654. for (addr = 0;
  655. addr < (congruence_classes * line_size);
  656. addr += line_size) {
  657. __asm__("dccci 0,%0": :"b"(addr));
  658. }
  659. }
  660. bd = &bdinfo;
  661. *bdp = bd;
  662. bd->bi_memsize = XPAR_DDR_0_SIZE;
  663. bd->bi_intfreq = XPAR_CORE_CLOCK_FREQ_HZ;
  664. bd->bi_busfreq = XPAR_PLB_CLOCK_FREQ_HZ;
  665. bd->bi_pci_busfreq = XPAR_PCI_0_CLOCK_FREQ_HZ;
  666. timebase_period_ns = 1000000000 / bd->bi_tbfreq;
  667. /* see bi_tbfreq definition in arch/ppc/platforms/4xx/xilinx_ml300.h */
  668. }
  669. #endif /* CONFIG_XILINX_ML300 || CONFIG_XILINX_ML403 */
  670. #ifdef CONFIG_IBM_OPENBIOS
  671. /* This could possibly work for all treeboot roms.
  672. */
  673. #if defined(CONFIG_BUBINGA)
  674. #define BOARD_INFO_VECTOR 0xFFF80B50 /* openbios 1.19 moved this vector down - armin */
  675. #else
  676. #define BOARD_INFO_VECTOR 0xFFFE0B50
  677. #endif
  678. void
  679. embed_config(bd_t **bdp)
  680. {
  681. u_char *cp;
  682. int i;
  683. bd_t *bd, *treeboot_bd;
  684. bd_t *(*get_board_info)(void) =
  685. (bd_t *(*)(void))(*(unsigned long *)BOARD_INFO_VECTOR);
  686. #if !defined(CONFIG_STB03xxx)
  687. /* shut down the Ethernet controller that the boot rom
  688. * sometimes leaves running.
  689. */
  690. mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* 1st reset MAL */
  691. while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* wait for the reset */
  692. out_be32((volatile u32*)EMAC0_BASE,0x20000000); /* then reset EMAC */
  693. #endif
  694. bd = &bdinfo;
  695. *bdp = bd;
  696. if ((treeboot_bd = get_board_info()) != NULL) {
  697. memcpy(bd, treeboot_bd, sizeof(bd_t));
  698. }
  699. else {
  700. /* Hmmm...better try to stuff some defaults.
  701. */
  702. bd->bi_memsize = 16 * 1024 * 1024;
  703. cp = (u_char *)def_enet_addr;
  704. for (i=0; i<6; i++) {
  705. /* I should probably put different ones here,
  706. * hopefully only one is used.
  707. */
  708. bd->BD_EMAC_ADDR(0,i) = *cp;
  709. #ifdef CONFIG_PCI
  710. bd->bi_pci_enetaddr[i] = *cp++;
  711. #endif
  712. }
  713. bd->bi_tbfreq = 200 * 1000 * 1000;
  714. bd->bi_intfreq = 200000000;
  715. bd->bi_busfreq = 100000000;
  716. #ifdef CONFIG_PCI
  717. bd->bi_pci_busfreq = 66666666;
  718. #endif
  719. }
  720. /* Yeah, this look weird, but on Redwood 4 they are
  721. * different object in the structure. Sincr Redwwood 5
  722. * and Redwood 6 use OpenBIOS, it requires a special value.
  723. */
  724. #if defined(CONFIG_REDWOOD_5) || defined (CONFIG_REDWOOD_6)
  725. bd->bi_tbfreq = 27 * 1000 * 1000;
  726. #endif
  727. timebase_period_ns = 1000000000 / bd->bi_tbfreq;
  728. }
  729. #endif /* CONFIG_IBM_OPENBIOS */
  730. #ifdef CONFIG_EP405
  731. #include <linux/serial_reg.h>
  732. void
  733. embed_config(bd_t **bdp)
  734. {
  735. u32 chcr0;
  736. u_char *cp;
  737. bd_t *bd;
  738. /* Different versions of the PlanetCore firmware vary in how
  739. they set up the serial port - in particular whether they
  740. use the internal or external serial clock for UART0. Make
  741. sure the UART is in a known state. */
  742. /* FIXME: We should use the board's 11.0592MHz external serial
  743. clock - it will be more accurate for serial rates. For
  744. now, however the baud rates in ep405.h are for the internal
  745. clock. */
  746. chcr0 = mfdcr(DCRN_CHCR0);
  747. if ( (chcr0 & 0x1fff) != 0x103e ) {
  748. mtdcr(DCRN_CHCR0, (chcr0 & 0xffffe000) | 0x103e);
  749. /* The following tricks serial_init() into resetting the baud rate */
  750. writeb(0, UART0_IO_BASE + UART_LCR);
  751. }
  752. /* We haven't seen actual problems with the EP405 leaving the
  753. * EMAC running (as we have on Walnut). But the registers
  754. * suggest it may not be left completely quiescent. Reset it
  755. * just to be sure. */
  756. mtdcr(DCRN_MALCR(DCRN_MAL_BASE), MALCR_MMSR); /* 1st reset MAL */
  757. while (mfdcr(DCRN_MALCR(DCRN_MAL_BASE)) & MALCR_MMSR) {}; /* wait for the reset */
  758. out_be32((unsigned *)EMAC0_BASE,0x20000000); /* then reset EMAC */
  759. bd = &bdinfo;
  760. *bdp = bd;
  761. #if 1
  762. cp = (u_char *)0xF0000EE0;
  763. for (;;) {
  764. if (*cp == 'E') {
  765. cp++;
  766. if (*cp == 'A') {
  767. cp += 2;
  768. rpx_eth(bd, cp);
  769. }
  770. }
  771. if (*cp == 'D') {
  772. cp++;
  773. if (*cp == '1') {
  774. cp += 2;
  775. rpx_memsize(bd, cp);
  776. }
  777. }
  778. if (*cp == 'N') {
  779. cp++;
  780. if (*cp == 'V') {
  781. cp += 2;
  782. rpx_nvramsize(bd, cp);
  783. }
  784. }
  785. while ((*cp != '\n') && (*cp != 0xff))
  786. cp++;
  787. cp++;
  788. if ((*cp == 0) || (*cp == 0xff))
  789. break;
  790. }
  791. bd->bi_intfreq = 200000000;
  792. bd->bi_busfreq = 100000000;
  793. bd->bi_pci_busfreq= 33000000 ;
  794. #else
  795. bd->bi_memsize = 64000000;
  796. bd->bi_intfreq = 200000000;
  797. bd->bi_busfreq = 100000000;
  798. bd->bi_pci_busfreq= 33000000 ;
  799. #endif
  800. }
  801. #endif