embed_config.c 20 KB

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