board.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311
  1. /*
  2. * (C) Copyright 2000-2006
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <watchdog.h>
  25. #include <command.h>
  26. #include <malloc.h>
  27. #include <devices.h>
  28. #ifdef CONFIG_8xx
  29. #include <mpc8xx.h>
  30. #endif
  31. #ifdef CONFIG_5xx
  32. #include <mpc5xx.h>
  33. #endif
  34. #ifdef CONFIG_MPC5xxx
  35. #include <mpc5xxx.h>
  36. #endif
  37. #if defined(CONFIG_CMD_IDE)
  38. #include <ide.h>
  39. #endif
  40. #if defined(CONFIG_CMD_SATA)
  41. #include <sata.h>
  42. #endif
  43. #if defined(CONFIG_CMD_SCSI)
  44. #include <scsi.h>
  45. #endif
  46. #if defined(CONFIG_CMD_KGDB)
  47. #include <kgdb.h>
  48. #endif
  49. #ifdef CONFIG_STATUS_LED
  50. #include <status_led.h>
  51. #endif
  52. #include <net.h>
  53. #include <serial.h>
  54. #ifdef CFG_ALLOC_DPRAM
  55. #if !defined(CONFIG_CPM2)
  56. #include <commproc.h>
  57. #endif
  58. #endif
  59. #include <version.h>
  60. #if defined(CONFIG_BAB7xx)
  61. #include <w83c553f.h>
  62. #endif
  63. #include <dtt.h>
  64. #if defined(CONFIG_POST)
  65. #include <post.h>
  66. #endif
  67. #if defined(CONFIG_LOGBUFFER)
  68. #include <logbuff.h>
  69. #endif
  70. #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500)
  71. #include <asm/cache.h>
  72. #endif
  73. #ifdef CONFIG_PS2KBD
  74. #include <keyboard.h>
  75. #endif
  76. #ifdef CFG_UPDATE_FLASH_SIZE
  77. extern int update_flash_size (int flash_size);
  78. #endif
  79. #if defined(CONFIG_SC3)
  80. extern void sc3_read_eeprom(void);
  81. #endif
  82. #if defined(CONFIG_CMD_DOC)
  83. void doc_init (void);
  84. #endif
  85. #if defined(CONFIG_HARD_I2C) || \
  86. defined(CONFIG_SOFT_I2C)
  87. #include <i2c.h>
  88. #endif
  89. #if defined(CONFIG_HARD_SPI)
  90. #include <spi.h>
  91. #endif
  92. #include <nand.h>
  93. static char *failed = "*** failed ***\n";
  94. #if defined(CONFIG_OXC) || defined(CONFIG_PCU_E) || defined(CONFIG_RMU)
  95. extern flash_info_t flash_info[];
  96. #endif
  97. #if defined(CONFIG_START_IDE)
  98. extern int board_start_ide(void);
  99. #endif
  100. #include <environment.h>
  101. DECLARE_GLOBAL_DATA_PTR;
  102. #if defined(CFG_ENV_IS_EMBEDDED)
  103. #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
  104. #elif ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
  105. (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
  106. defined(CFG_ENV_IS_IN_NVRAM)
  107. #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
  108. #else
  109. #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
  110. #endif
  111. #if !defined(CFG_MEM_TOP_HIDE)
  112. #define CFG_MEM_TOP_HIDE 0
  113. #endif
  114. extern ulong __init_end;
  115. extern ulong _end;
  116. ulong monitor_flash_len;
  117. #if defined(CONFIG_CMD_BEDBUG)
  118. #include <bedbug/type.h>
  119. #endif
  120. /*
  121. * Begin and End of memory area for malloc(), and current "brk"
  122. */
  123. static ulong mem_malloc_start = 0;
  124. static ulong mem_malloc_end = 0;
  125. static ulong mem_malloc_brk = 0;
  126. /************************************************************************
  127. * Utilities *
  128. ************************************************************************
  129. */
  130. /*
  131. * The Malloc area is immediately below the monitor copy in DRAM
  132. */
  133. static void mem_malloc_init (void)
  134. {
  135. #if !defined(CONFIG_RELOC_FIXUP_WORKS)
  136. mem_malloc_end = CFG_MONITOR_BASE + gd->reloc_off;
  137. #endif
  138. mem_malloc_start = mem_malloc_end - TOTAL_MALLOC_LEN;
  139. mem_malloc_brk = mem_malloc_start;
  140. memset ((void *) mem_malloc_start,
  141. 0,
  142. mem_malloc_end - mem_malloc_start);
  143. }
  144. void *sbrk (ptrdiff_t increment)
  145. {
  146. ulong old = mem_malloc_brk;
  147. ulong new = old + increment;
  148. if ((new < mem_malloc_start) || (new > mem_malloc_end)) {
  149. return (NULL);
  150. }
  151. mem_malloc_brk = new;
  152. return ((void *) old);
  153. }
  154. char *strmhz (char *buf, long hz)
  155. {
  156. long l, n;
  157. long m;
  158. n = hz / 1000000L;
  159. l = sprintf (buf, "%ld", n);
  160. m = (hz % 1000000L) / 1000L;
  161. if (m != 0)
  162. sprintf (buf + l, ".%03ld", m);
  163. return (buf);
  164. }
  165. /*
  166. * All attempts to come up with a "common" initialization sequence
  167. * that works for all boards and architectures failed: some of the
  168. * requirements are just _too_ different. To get rid of the resulting
  169. * mess of board dependend #ifdef'ed code we now make the whole
  170. * initialization sequence configurable to the user.
  171. *
  172. * The requirements for any new initalization function is simple: it
  173. * receives a pointer to the "global data" structure as it's only
  174. * argument, and returns an integer return code, where 0 means
  175. * "continue" and != 0 means "fatal error, hang the system".
  176. */
  177. typedef int (init_fnc_t) (void);
  178. /************************************************************************
  179. * Init Utilities *
  180. ************************************************************************
  181. * Some of this code should be moved into the core functions,
  182. * but let's get it working (again) first...
  183. */
  184. static int init_baudrate (void)
  185. {
  186. char tmp[64]; /* long enough for environment variables */
  187. int i = getenv_r ("baudrate", tmp, sizeof (tmp));
  188. gd->baudrate = (i > 0)
  189. ? (int) simple_strtoul (tmp, NULL, 10)
  190. : CONFIG_BAUDRATE;
  191. return (0);
  192. }
  193. /***********************************************************************/
  194. void __board_add_ram_info(int use_default)
  195. {
  196. /* please define platform specific board_add_ram_info() */
  197. }
  198. void board_add_ram_info(int) __attribute__((weak, alias("__board_add_ram_info")));
  199. static int init_func_ram (void)
  200. {
  201. #ifdef CONFIG_BOARD_TYPES
  202. int board_type = gd->board_type;
  203. #else
  204. int board_type = 0; /* use dummy arg */
  205. #endif
  206. puts ("DRAM: ");
  207. if ((gd->ram_size = initdram (board_type)) > 0) {
  208. print_size (gd->ram_size, "");
  209. board_add_ram_info(0);
  210. putc('\n');
  211. return (0);
  212. }
  213. puts (failed);
  214. return (1);
  215. }
  216. /***********************************************************************/
  217. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  218. static int init_func_i2c (void)
  219. {
  220. puts ("I2C: ");
  221. i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
  222. puts ("ready\n");
  223. return (0);
  224. }
  225. #endif
  226. #if defined(CONFIG_HARD_SPI)
  227. static int init_func_spi (void)
  228. {
  229. puts ("SPI: ");
  230. spi_init ();
  231. puts ("ready\n");
  232. return (0);
  233. }
  234. #endif
  235. /***********************************************************************/
  236. #if defined(CONFIG_WATCHDOG)
  237. static int init_func_watchdog_init (void)
  238. {
  239. puts (" Watchdog enabled\n");
  240. WATCHDOG_RESET ();
  241. return (0);
  242. }
  243. # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
  244. static int init_func_watchdog_reset (void)
  245. {
  246. WATCHDOG_RESET ();
  247. return (0);
  248. }
  249. # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset,
  250. #else
  251. # define INIT_FUNC_WATCHDOG_INIT /* undef */
  252. # define INIT_FUNC_WATCHDOG_RESET /* undef */
  253. #endif /* CONFIG_WATCHDOG */
  254. /************************************************************************
  255. * Initialization sequence *
  256. ************************************************************************
  257. */
  258. init_fnc_t *init_sequence[] = {
  259. #if defined(CONFIG_BOARD_EARLY_INIT_F)
  260. board_early_init_f,
  261. #endif
  262. #if !defined(CONFIG_8xx_CPUCLK_DEFAULT)
  263. get_clocks, /* get CPU and bus clocks (etc.) */
  264. #if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
  265. && !defined(CONFIG_TQM885D)
  266. adjust_sdram_tbs_8xx,
  267. #endif
  268. init_timebase,
  269. #endif
  270. #ifdef CFG_ALLOC_DPRAM
  271. #if !defined(CONFIG_CPM2)
  272. dpram_init,
  273. #endif
  274. #endif
  275. #if defined(CONFIG_BOARD_POSTCLK_INIT)
  276. board_postclk_init,
  277. #endif
  278. env_init,
  279. #if defined(CONFIG_8xx_CPUCLK_DEFAULT)
  280. get_clocks_866, /* get CPU and bus clocks according to the environment variable */
  281. sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */
  282. init_timebase,
  283. #endif
  284. init_baudrate,
  285. serial_init,
  286. console_init_f,
  287. display_options,
  288. #if defined(CONFIG_8260)
  289. prt_8260_rsr,
  290. prt_8260_clks,
  291. #endif /* CONFIG_8260 */
  292. #if defined(CONFIG_MPC83XX)
  293. prt_83xx_rsr,
  294. #endif
  295. checkcpu,
  296. #if defined(CONFIG_MPC5xxx)
  297. prt_mpc5xxx_clks,
  298. #endif /* CONFIG_MPC5xxx */
  299. #if defined(CONFIG_MPC8220)
  300. prt_mpc8220_clks,
  301. #endif
  302. checkboard,
  303. INIT_FUNC_WATCHDOG_INIT
  304. #if defined(CONFIG_MISC_INIT_F)
  305. misc_init_f,
  306. #endif
  307. INIT_FUNC_WATCHDOG_RESET
  308. #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
  309. init_func_i2c,
  310. #endif
  311. #if defined(CONFIG_HARD_SPI)
  312. init_func_spi,
  313. #endif
  314. #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
  315. dtt_init,
  316. #endif
  317. #ifdef CONFIG_POST
  318. post_init_f,
  319. #endif
  320. INIT_FUNC_WATCHDOG_RESET
  321. init_func_ram,
  322. #if defined(CFG_DRAM_TEST)
  323. testdram,
  324. #endif /* CFG_DRAM_TEST */
  325. INIT_FUNC_WATCHDOG_RESET
  326. NULL, /* Terminate this list */
  327. };
  328. #ifndef CONFIG_MAX_MEM_MAPPED
  329. #define CONFIG_MAX_MEM_MAPPED (256 << 20)
  330. #endif
  331. ulong get_effective_memsize(void)
  332. {
  333. #ifndef CONFIG_VERY_BIG_RAM
  334. return gd->ram_size;
  335. #else
  336. /* limit stack to what we can reasonable map */
  337. return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
  338. CONFIG_MAX_MEM_MAPPED : gd->ram_size);
  339. #endif
  340. }
  341. /************************************************************************
  342. *
  343. * This is the first part of the initialization sequence that is
  344. * implemented in C, but still running from ROM.
  345. *
  346. * The main purpose is to provide a (serial) console interface as
  347. * soon as possible (so we can see any error messages), and to
  348. * initialize the RAM so that we can relocate the monitor code to
  349. * RAM.
  350. *
  351. * Be aware of the restrictions: global data is read-only, BSS is not
  352. * initialized, and stack space is limited to a few kB.
  353. *
  354. ************************************************************************
  355. */
  356. #ifdef CONFIG_LOGBUFFER
  357. unsigned long logbuffer_base(void)
  358. {
  359. return CFG_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN;
  360. }
  361. #endif
  362. void board_init_f (ulong bootflag)
  363. {
  364. bd_t *bd;
  365. ulong len, addr, addr_sp;
  366. ulong *s;
  367. gd_t *id;
  368. init_fnc_t **init_fnc_ptr;
  369. #ifdef CONFIG_PRAM
  370. int i;
  371. ulong reg;
  372. uchar tmp[64]; /* long enough for environment variables */
  373. #endif
  374. /* Pointer is writable since we allocated a register for it */
  375. gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  376. /* compiler optimization barrier needed for GCC >= 3.4 */
  377. __asm__ __volatile__("": : :"memory");
  378. #if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX) && \
  379. !defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx)
  380. /* Clear initial global data */
  381. memset ((void *) gd, 0, sizeof (gd_t));
  382. #endif
  383. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  384. if ((*init_fnc_ptr) () != 0) {
  385. hang ();
  386. }
  387. }
  388. /*
  389. * Now that we have DRAM mapped and working, we can
  390. * relocate the code and continue running from DRAM.
  391. *
  392. * Reserve memory at end of RAM for (top down in that order):
  393. * - area that won't get touched by U-Boot and Linux (optional)
  394. * - kernel log buffer
  395. * - protected RAM
  396. * - LCD framebuffer
  397. * - monitor code
  398. * - board info struct
  399. */
  400. len = (ulong)&_end - CFG_MONITOR_BASE;
  401. /*
  402. * Subtract specified amount of memory to hide so that it won't
  403. * get "touched" at all by U-Boot. By fixing up gd->ram_size
  404. * the Linux kernel should now get passed the now "corrected"
  405. * memory size and won't touch it either. This should work
  406. * for arch/ppc and arch/powerpc. Only Linux board ports in
  407. * arch/powerpc with bootwrapper support, that recalculate the
  408. * memory size from the SDRAM controller setup will have to
  409. * get fixed.
  410. */
  411. gd->ram_size -= CFG_MEM_TOP_HIDE;
  412. addr = CFG_SDRAM_BASE + get_effective_memsize();
  413. #ifdef CONFIG_LOGBUFFER
  414. #ifndef CONFIG_ALT_LB_ADDR
  415. /* reserve kernel log buffer */
  416. addr -= (LOGBUFF_RESERVE);
  417. debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
  418. #endif
  419. #endif
  420. #ifdef CONFIG_PRAM
  421. /*
  422. * reserve protected RAM
  423. */
  424. i = getenv_r ("pram", (char *)tmp, sizeof (tmp));
  425. reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;
  426. addr -= (reg << 10); /* size is in kB */
  427. debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  428. #endif /* CONFIG_PRAM */
  429. /* round down to next 4 kB limit */
  430. addr &= ~(4096 - 1);
  431. debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
  432. #ifdef CONFIG_LCD
  433. /* reserve memory for LCD display (always full pages) */
  434. addr = lcd_setmem (addr);
  435. gd->fb_base = addr;
  436. #endif /* CONFIG_LCD */
  437. #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx)
  438. /* reserve memory for video display (always full pages) */
  439. addr = video_setmem (addr);
  440. gd->fb_base = addr;
  441. #endif /* CONFIG_VIDEO */
  442. /*
  443. * reserve memory for U-Boot code, data & bss
  444. * round down to next 4 kB limit
  445. */
  446. addr -= len;
  447. addr &= ~(4096 - 1);
  448. #ifdef CONFIG_E500
  449. /* round down to next 64 kB limit so that IVPR stays aligned */
  450. addr &= ~(65536 - 1);
  451. #endif
  452. debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
  453. #ifdef CONFIG_AMIGAONEG3SE
  454. gd->relocaddr = addr;
  455. #endif
  456. /*
  457. * reserve memory for malloc() arena
  458. */
  459. addr_sp = addr - TOTAL_MALLOC_LEN;
  460. debug ("Reserving %dk for malloc() at: %08lx\n",
  461. TOTAL_MALLOC_LEN >> 10, addr_sp);
  462. /*
  463. * (permanently) allocate a Board Info struct
  464. * and a permanent copy of the "global" data
  465. */
  466. addr_sp -= sizeof (bd_t);
  467. bd = (bd_t *) addr_sp;
  468. gd->bd = bd;
  469. debug ("Reserving %d Bytes for Board Info at: %08lx\n",
  470. sizeof (bd_t), addr_sp);
  471. addr_sp -= sizeof (gd_t);
  472. id = (gd_t *) addr_sp;
  473. debug ("Reserving %d Bytes for Global Data at: %08lx\n",
  474. sizeof (gd_t), addr_sp);
  475. /*
  476. * Finally, we set up a new (bigger) stack.
  477. *
  478. * Leave some safety gap for SP, force alignment on 16 byte boundary
  479. * Clear initial stack frame
  480. */
  481. addr_sp -= 16;
  482. addr_sp &= ~0xF;
  483. s = (ulong *)addr_sp;
  484. *s-- = 0;
  485. *s-- = 0;
  486. addr_sp = (ulong)s;
  487. debug ("Stack Pointer at: %08lx\n", addr_sp);
  488. /*
  489. * Save local variables to board info struct
  490. */
  491. bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */
  492. bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
  493. #ifdef CONFIG_IP860
  494. bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */
  495. bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */
  496. #elif defined CONFIG_MPC8220
  497. bd->bi_sramstart = CFG_SRAM_BASE; /* start of SRAM memory */
  498. bd->bi_sramsize = CFG_SRAM_SIZE; /* size of SRAM memory */
  499. #else
  500. bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */
  501. bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */
  502. #endif
  503. #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \
  504. defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
  505. bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */
  506. #endif
  507. #if defined(CONFIG_MPC5xxx)
  508. bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */
  509. #endif
  510. #if defined(CONFIG_MPC83XX)
  511. bd->bi_immrbar = CFG_IMMR;
  512. #endif
  513. #if defined(CONFIG_MPC8220)
  514. bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */
  515. bd->bi_inpfreq = gd->inp_clk;
  516. bd->bi_pcifreq = gd->pci_clk;
  517. bd->bi_vcofreq = gd->vco_clk;
  518. bd->bi_pevfreq = gd->pev_clk;
  519. bd->bi_flbfreq = gd->flb_clk;
  520. /* store bootparam to sram (backward compatible), here? */
  521. {
  522. u32 *sram = (u32 *)CFG_SRAM_BASE;
  523. *sram++ = gd->ram_size;
  524. *sram++ = gd->bus_clk;
  525. *sram++ = gd->inp_clk;
  526. *sram++ = gd->cpu_clk;
  527. *sram++ = gd->vco_clk;
  528. *sram++ = gd->flb_clk;
  529. *sram++ = 0xb8c3ba11; /* boot signature */
  530. }
  531. #endif
  532. bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
  533. WATCHDOG_RESET ();
  534. bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
  535. bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
  536. #if defined(CONFIG_CPM2)
  537. bd->bi_cpmfreq = gd->cpm_clk;
  538. bd->bi_brgfreq = gd->brg_clk;
  539. bd->bi_sccfreq = gd->scc_clk;
  540. bd->bi_vco = gd->vco_out;
  541. #endif /* CONFIG_CPM2 */
  542. #if defined(CONFIG_MPC512X)
  543. bd->bi_ipsfreq = gd->ips_clk;
  544. #endif /* CONFIG_MPC512X */
  545. #if defined(CONFIG_MPC5xxx)
  546. bd->bi_ipbfreq = gd->ipb_clk;
  547. bd->bi_pcifreq = gd->pci_clk;
  548. #endif /* CONFIG_MPC5xxx */
  549. bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
  550. #ifdef CFG_EXTBDINFO
  551. strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
  552. strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
  553. bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
  554. bd->bi_plb_busfreq = gd->bus_clk;
  555. #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
  556. defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  557. defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  558. bd->bi_pci_busfreq = get_PCI_freq ();
  559. bd->bi_opbfreq = get_OPB_freq ();
  560. #elif defined(CONFIG_XILINX_ML300)
  561. bd->bi_pci_busfreq = get_PCI_freq ();
  562. #endif
  563. #endif
  564. debug ("New Stack Pointer is: %08lx\n", addr_sp);
  565. WATCHDOG_RESET ();
  566. #ifdef CONFIG_POST
  567. post_bootmode_init();
  568. post_run (NULL, POST_ROM | post_bootmode_get(0));
  569. #endif
  570. WATCHDOG_RESET();
  571. memcpy (id, (void *)gd, sizeof (gd_t));
  572. relocate_code (addr_sp, id, addr);
  573. /* NOTREACHED - relocate_code() does not return */
  574. }
  575. /************************************************************************
  576. *
  577. * This is the next part if the initialization sequence: we are now
  578. * running from RAM and have a "normal" C environment, i. e. global
  579. * data can be written, BSS has been cleared, the stack size in not
  580. * that critical any more, etc.
  581. *
  582. ************************************************************************
  583. */
  584. void board_init_r (gd_t *id, ulong dest_addr)
  585. {
  586. cmd_tbl_t *cmdtp;
  587. char *s, *e;
  588. bd_t *bd;
  589. int i;
  590. extern void malloc_bin_reloc (void);
  591. #ifndef CFG_ENV_IS_NOWHERE
  592. extern char * env_name_spec;
  593. #endif
  594. #ifndef CFG_NO_FLASH
  595. ulong flash_size;
  596. #endif
  597. gd = id; /* initialize RAM version of global data */
  598. bd = gd->bd;
  599. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  600. #if defined(CONFIG_RELOC_FIXUP_WORKS)
  601. gd->reloc_off = 0;
  602. mem_malloc_end = dest_addr;
  603. #else
  604. gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
  605. #endif
  606. #ifdef CONFIG_SERIAL_MULTI
  607. serial_initialize();
  608. #endif
  609. debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  610. WATCHDOG_RESET ();
  611. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  612. board_early_init_r ();
  613. #endif
  614. monitor_flash_len = (ulong)&__init_end - dest_addr;
  615. /*
  616. * We have to relocate the command table manually
  617. */
  618. for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
  619. ulong addr;
  620. addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
  621. #if 0
  622. printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
  623. cmdtp->name, (ulong) (cmdtp->cmd), addr);
  624. #endif
  625. cmdtp->cmd =
  626. (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
  627. addr = (ulong)(cmdtp->name) + gd->reloc_off;
  628. cmdtp->name = (char *)addr;
  629. if (cmdtp->usage) {
  630. addr = (ulong)(cmdtp->usage) + gd->reloc_off;
  631. cmdtp->usage = (char *)addr;
  632. }
  633. #ifdef CFG_LONGHELP
  634. if (cmdtp->help) {
  635. addr = (ulong)(cmdtp->help) + gd->reloc_off;
  636. cmdtp->help = (char *)addr;
  637. }
  638. #endif
  639. }
  640. /* there are some other pointer constants we must deal with */
  641. #ifndef CFG_ENV_IS_NOWHERE
  642. env_name_spec += gd->reloc_off;
  643. #endif
  644. WATCHDOG_RESET ();
  645. #ifdef CONFIG_LOGBUFFER
  646. logbuff_init_ptrs ();
  647. #endif
  648. #ifdef CONFIG_POST
  649. post_output_backlog ();
  650. post_reloc ();
  651. #endif
  652. WATCHDOG_RESET();
  653. #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || \
  654. defined (CONFIG_FLAGADM) || defined(CONFIG_MPC83XX)
  655. icache_enable (); /* it's time to enable the instruction cache */
  656. #endif
  657. #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500)
  658. unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
  659. #endif
  660. #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45)
  661. /*
  662. * Do PCI configuration on BAB7xx and CPC45 _before_ the flash
  663. * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus
  664. * bridge there.
  665. */
  666. pci_init ();
  667. #endif
  668. #if defined(CONFIG_BAB7xx)
  669. /*
  670. * Initialise the ISA bridge
  671. */
  672. initialise_w83c553f ();
  673. #endif
  674. asm ("sync ; isync");
  675. /*
  676. * Setup trap handlers
  677. */
  678. trap_init (dest_addr);
  679. #if !defined(CFG_NO_FLASH)
  680. puts ("FLASH: ");
  681. if ((flash_size = flash_init ()) > 0) {
  682. # ifdef CFG_FLASH_CHECKSUM
  683. print_size (flash_size, "");
  684. /*
  685. * Compute and print flash CRC if flashchecksum is set to 'y'
  686. *
  687. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  688. */
  689. s = getenv ("flashchecksum");
  690. if (s && (*s == 'y')) {
  691. printf (" CRC: %08lX",
  692. crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size)
  693. );
  694. }
  695. putc ('\n');
  696. # else /* !CFG_FLASH_CHECKSUM */
  697. print_size (flash_size, "\n");
  698. # endif /* CFG_FLASH_CHECKSUM */
  699. } else {
  700. puts (failed);
  701. hang ();
  702. }
  703. bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */
  704. bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
  705. #if defined(CFG_UPDATE_FLASH_SIZE)
  706. /* Make a update of the Memctrl. */
  707. update_flash_size (flash_size);
  708. #endif
  709. # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU)
  710. /* flash mapped at end of memory map */
  711. bd->bi_flashoffset = TEXT_BASE + flash_size;
  712. # elif CFG_MONITOR_BASE == CFG_FLASH_BASE
  713. bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */
  714. # else
  715. bd->bi_flashoffset = 0;
  716. # endif
  717. #else /* CFG_NO_FLASH */
  718. bd->bi_flashsize = 0;
  719. bd->bi_flashstart = 0;
  720. bd->bi_flashoffset = 0;
  721. #endif /* !CFG_NO_FLASH */
  722. WATCHDOG_RESET ();
  723. /* initialize higher level parts of CPU like time base and timers */
  724. cpu_init_r ();
  725. WATCHDOG_RESET ();
  726. /* initialize malloc() area */
  727. mem_malloc_init ();
  728. malloc_bin_reloc ();
  729. #ifdef CONFIG_SPI
  730. # if !defined(CFG_ENV_IS_IN_EEPROM)
  731. spi_init_f ();
  732. # endif
  733. spi_init_r ();
  734. #endif
  735. #if defined(CONFIG_CMD_NAND)
  736. WATCHDOG_RESET ();
  737. puts ("NAND: ");
  738. nand_init(); /* go init the NAND */
  739. #endif
  740. /* relocate environment function pointers etc. */
  741. env_relocate ();
  742. /*
  743. * Fill in missing fields of bd_info.
  744. * We do this here, where we have "normal" access to the
  745. * environment; we used to do this still running from ROM,
  746. * where had to use getenv_r(), which can be pretty slow when
  747. * the environment is in EEPROM.
  748. */
  749. #if defined(CFG_EXTBDINFO)
  750. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  751. #if defined(CONFIG_I2CFAST)
  752. /*
  753. * set bi_iic_fast for linux taking environment variable
  754. * "i2cfast" into account
  755. */
  756. {
  757. char *s = getenv ("i2cfast");
  758. if (s && ((*s == 'y') || (*s == 'Y'))) {
  759. bd->bi_iic_fast[0] = 1;
  760. bd->bi_iic_fast[1] = 1;
  761. } else {
  762. bd->bi_iic_fast[0] = 0;
  763. bd->bi_iic_fast[1] = 0;
  764. }
  765. }
  766. #else
  767. bd->bi_iic_fast[0] = 0;
  768. bd->bi_iic_fast[1] = 0;
  769. #endif /* CONFIG_I2CFAST */
  770. #endif /* CONFIG_405GP, CONFIG_405EP */
  771. #endif /* CFG_EXTBDINFO */
  772. #if defined(CONFIG_SC3)
  773. sc3_read_eeprom();
  774. #endif
  775. #if defined (CFG_ID_EEPROM) || defined (CFG_I2C_MAC_OFFSET)
  776. mac_read_from_eeprom();
  777. #endif
  778. s = getenv ("ethaddr");
  779. #if defined (CONFIG_MBX) || \
  780. defined (CONFIG_RPXCLASSIC) || \
  781. defined(CONFIG_IAD210) || \
  782. defined(CONFIG_V38B)
  783. if (s == NULL)
  784. board_get_enetaddr (bd->bi_enetaddr);
  785. else
  786. #endif
  787. for (i = 0; i < 6; ++i) {
  788. bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  789. if (s)
  790. s = (*e) ? e + 1 : e;
  791. }
  792. #ifdef CONFIG_HERMES
  793. if ((gd->board_type >> 16) == 2)
  794. bd->bi_ethspeed = gd->board_type & 0xFFFF;
  795. else
  796. bd->bi_ethspeed = 0xFFFF;
  797. #endif
  798. #ifdef CONFIG_NX823
  799. load_sernum_ethaddr ();
  800. #endif
  801. #ifdef CONFIG_HAS_ETH1
  802. /* handle the 2nd ethernet address */
  803. s = getenv ("eth1addr");
  804. for (i = 0; i < 6; ++i) {
  805. bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  806. if (s)
  807. s = (*e) ? e + 1 : e;
  808. }
  809. #endif
  810. #ifdef CONFIG_HAS_ETH2
  811. /* handle the 3rd ethernet address */
  812. s = getenv ("eth2addr");
  813. #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
  814. if (s == NULL)
  815. board_get_enetaddr(bd->bi_enet2addr);
  816. else
  817. #endif
  818. for (i = 0; i < 6; ++i) {
  819. bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  820. if (s)
  821. s = (*e) ? e + 1 : e;
  822. }
  823. #endif
  824. #ifdef CONFIG_HAS_ETH3
  825. /* handle 4th ethernet address */
  826. s = getenv("eth3addr");
  827. #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
  828. if (s == NULL)
  829. board_get_enetaddr(bd->bi_enet3addr);
  830. else
  831. #endif
  832. for (i = 0; i < 6; ++i) {
  833. bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  834. if (s)
  835. s = (*e) ? e + 1 : e;
  836. }
  837. #endif
  838. #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
  839. defined(CONFIG_TQM8272) || \
  840. defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
  841. defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP)
  842. load_sernum_ethaddr ();
  843. #endif
  844. /* IP Address */
  845. bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
  846. WATCHDOG_RESET ();
  847. #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45)
  848. /*
  849. * Do pci configuration
  850. */
  851. pci_init ();
  852. #endif
  853. /** leave this here (after malloc(), environment and PCI are working) **/
  854. /* Initialize devices */
  855. devices_init ();
  856. /* Initialize the jump table for applications */
  857. jumptable_init ();
  858. #if defined(CONFIG_API)
  859. /* Initialize API */
  860. api_init ();
  861. #endif
  862. /* Initialize the console (after the relocation and devices init) */
  863. console_init_r ();
  864. #if defined(CONFIG_CCM) || \
  865. defined(CONFIG_COGENT) || \
  866. defined(CONFIG_CPCI405) || \
  867. defined(CONFIG_EVB64260) || \
  868. defined(CONFIG_KUP4K) || \
  869. defined(CONFIG_KUP4X) || \
  870. defined(CONFIG_LWMON) || \
  871. defined(CONFIG_PCU_E) || \
  872. defined(CONFIG_SC3) || \
  873. defined(CONFIG_W7O) || \
  874. defined(CONFIG_MISC_INIT_R)
  875. /* miscellaneous platform dependent initialisations */
  876. misc_init_r ();
  877. #endif
  878. #ifdef CONFIG_HERMES
  879. if (bd->bi_ethspeed != 0xFFFF)
  880. hermes_start_lxt980 ((int) bd->bi_ethspeed);
  881. #endif
  882. #if defined(CONFIG_CMD_KGDB)
  883. WATCHDOG_RESET ();
  884. puts ("KGDB: ");
  885. kgdb_init ();
  886. #endif
  887. debug ("U-Boot relocated to %08lx\n", dest_addr);
  888. /*
  889. * Enable Interrupts
  890. */
  891. interrupt_init ();
  892. /* Must happen after interrupts are initialized since
  893. * an irq handler gets installed
  894. */
  895. #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
  896. serial_buffered_init();
  897. #endif
  898. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  899. status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
  900. #endif
  901. udelay (20);
  902. set_timer (0);
  903. /* Initialize from environment */
  904. if ((s = getenv ("loadaddr")) != NULL) {
  905. load_addr = simple_strtoul (s, NULL, 16);
  906. }
  907. #if defined(CONFIG_CMD_NET)
  908. if ((s = getenv ("bootfile")) != NULL) {
  909. copy_filename (BootFile, s, sizeof (BootFile));
  910. }
  911. #endif
  912. WATCHDOG_RESET ();
  913. #if defined(CONFIG_CMD_SCSI)
  914. WATCHDOG_RESET ();
  915. puts ("SCSI: ");
  916. scsi_init ();
  917. #endif
  918. #if defined(CONFIG_CMD_DOC)
  919. WATCHDOG_RESET ();
  920. puts ("DOC: ");
  921. doc_init ();
  922. #endif
  923. #if defined(CONFIG_CMD_NET)
  924. #if defined(CONFIG_NET_MULTI)
  925. WATCHDOG_RESET ();
  926. puts ("Net: ");
  927. #endif
  928. eth_initialize (bd);
  929. #endif
  930. #if defined(CONFIG_CMD_NET) && ( \
  931. defined(CONFIG_CCM) || \
  932. defined(CONFIG_ELPT860) || \
  933. defined(CONFIG_EP8260) || \
  934. defined(CONFIG_IP860) || \
  935. defined(CONFIG_IVML24) || \
  936. defined(CONFIG_IVMS8) || \
  937. defined(CONFIG_MPC8260ADS) || \
  938. defined(CONFIG_MPC8266ADS) || \
  939. defined(CONFIG_MPC8560ADS) || \
  940. defined(CONFIG_PCU_E) || \
  941. defined(CONFIG_RPXSUPER) || \
  942. defined(CONFIG_STXGP3) || \
  943. defined(CONFIG_SPD823TS) || \
  944. defined(CONFIG_RESET_PHY_R) )
  945. WATCHDOG_RESET ();
  946. debug ("Reset Ethernet PHY\n");
  947. reset_phy ();
  948. #endif
  949. #ifdef CONFIG_POST
  950. post_run (NULL, POST_RAM | post_bootmode_get(0));
  951. #endif
  952. #if defined(CONFIG_CMD_PCMCIA) \
  953. && !defined(CONFIG_CMD_IDE)
  954. WATCHDOG_RESET ();
  955. puts ("PCMCIA:");
  956. pcmcia_init ();
  957. #endif
  958. #if defined(CONFIG_CMD_IDE)
  959. WATCHDOG_RESET ();
  960. # ifdef CONFIG_IDE_8xx_PCCARD
  961. puts ("PCMCIA:");
  962. # else
  963. puts ("IDE: ");
  964. #endif
  965. #if defined(CONFIG_START_IDE)
  966. if (board_start_ide())
  967. ide_init ();
  968. #else
  969. ide_init ();
  970. #endif
  971. #endif
  972. #if defined(CONFIG_CMD_SATA)
  973. puts ("SATA: ");
  974. sata_initialize ();
  975. #endif
  976. #ifdef CONFIG_LAST_STAGE_INIT
  977. WATCHDOG_RESET ();
  978. /*
  979. * Some parts can be only initialized if all others (like
  980. * Interrupts) are up and running (i.e. the PC-style ISA
  981. * keyboard).
  982. */
  983. last_stage_init ();
  984. #endif
  985. #if defined(CONFIG_CMD_BEDBUG)
  986. WATCHDOG_RESET ();
  987. bedbug_init ();
  988. #endif
  989. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  990. /*
  991. * Export available size of memory for Linux,
  992. * taking into account the protected RAM at top of memory
  993. */
  994. {
  995. ulong pram;
  996. uchar memsz[32];
  997. #ifdef CONFIG_PRAM
  998. char *s;
  999. if ((s = getenv ("pram")) != NULL) {
  1000. pram = simple_strtoul (s, NULL, 10);
  1001. } else {
  1002. pram = CONFIG_PRAM;
  1003. }
  1004. #else
  1005. pram=0;
  1006. #endif
  1007. #ifdef CONFIG_LOGBUFFER
  1008. #ifndef CONFIG_ALT_LB_ADDR
  1009. /* Also take the logbuffer into account (pram is in kB) */
  1010. pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
  1011. #endif
  1012. #endif
  1013. sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
  1014. setenv ("mem", (char *)memsz);
  1015. }
  1016. #endif
  1017. #ifdef CONFIG_PS2KBD
  1018. puts ("PS/2: ");
  1019. kbd_init();
  1020. #endif
  1021. #ifdef CONFIG_MODEM_SUPPORT
  1022. {
  1023. extern int do_mdm_init;
  1024. do_mdm_init = gd->do_mdm_init;
  1025. }
  1026. #endif
  1027. /* Initialization complete - start the monitor */
  1028. /* main_loop() can return to retry autoboot, if so just run it again. */
  1029. for (;;) {
  1030. WATCHDOG_RESET ();
  1031. main_loop ();
  1032. }
  1033. /* NOTREACHED - no way out of command loop except booting */
  1034. }
  1035. void hang (void)
  1036. {
  1037. puts ("### ERROR ### Please RESET the board ###\n");
  1038. show_boot_progress(-30);
  1039. for (;;);
  1040. }
  1041. #ifdef CONFIG_MODEM_SUPPORT
  1042. /* called from main loop (common/main.c) */
  1043. /* 'inline' - We have to do it fast */
  1044. static inline void mdm_readline(char *buf, int bufsiz)
  1045. {
  1046. char c;
  1047. char *p;
  1048. int n;
  1049. n = 0;
  1050. p = buf;
  1051. for(;;) {
  1052. c = serial_getc();
  1053. /* dbg("(%c)", c); */
  1054. switch(c) {
  1055. case '\r':
  1056. break;
  1057. case '\n':
  1058. *p = '\0';
  1059. return;
  1060. default:
  1061. if(n++ > bufsiz) {
  1062. *p = '\0';
  1063. return; /* sanity check */
  1064. }
  1065. *p = c;
  1066. p++;
  1067. break;
  1068. }
  1069. }
  1070. }
  1071. extern void dbg(const char *fmt, ...);
  1072. int mdm_init (void)
  1073. {
  1074. char env_str[16];
  1075. char *init_str;
  1076. int i;
  1077. extern char console_buffer[];
  1078. extern void enable_putc(void);
  1079. extern int hwflow_onoff(int);
  1080. enable_putc(); /* enable serial_putc() */
  1081. #ifdef CONFIG_HWFLOW
  1082. init_str = getenv("mdm_flow_control");
  1083. if (init_str && (strcmp(init_str, "rts/cts") == 0))
  1084. hwflow_onoff (1);
  1085. else
  1086. hwflow_onoff(-1);
  1087. #endif
  1088. for (i = 1;;i++) {
  1089. sprintf(env_str, "mdm_init%d", i);
  1090. if ((init_str = getenv(env_str)) != NULL) {
  1091. serial_puts(init_str);
  1092. serial_puts("\n");
  1093. for(;;) {
  1094. mdm_readline(console_buffer, CFG_CBSIZE);
  1095. dbg("ini%d: [%s]", i, console_buffer);
  1096. if ((strcmp(console_buffer, "OK") == 0) ||
  1097. (strcmp(console_buffer, "ERROR") == 0)) {
  1098. dbg("ini%d: cmd done", i);
  1099. break;
  1100. } else /* in case we are originating call ... */
  1101. if (strncmp(console_buffer, "CONNECT", 7) == 0) {
  1102. dbg("ini%d: connect", i);
  1103. return 0;
  1104. }
  1105. }
  1106. } else
  1107. break; /* no init string - stop modem init */
  1108. udelay(100000);
  1109. }
  1110. udelay(100000);
  1111. /* final stage - wait for connect */
  1112. for(;i > 1;) { /* if 'i' > 1 - wait for connection
  1113. message from modem */
  1114. mdm_readline(console_buffer, CFG_CBSIZE);
  1115. dbg("ini_f: [%s]", console_buffer);
  1116. if (strncmp(console_buffer, "CONNECT", 7) == 0) {
  1117. dbg("ini_f: connected");
  1118. return 0;
  1119. }
  1120. }
  1121. return 0;
  1122. }
  1123. #endif
  1124. #if 0 /* We could use plain global data, but the resulting code is bigger */
  1125. /*
  1126. * Pointer to initial global data area
  1127. *
  1128. * Here we initialize it.
  1129. */
  1130. #undef XTRN_DECLARE_GLOBAL_DATA_PTR
  1131. #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
  1132. DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  1133. #endif /* 0 */
  1134. /************************************************************************/