board.c 30 KB

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