board.c 30 KB

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