embed_config.c 19 KB

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