board.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303
  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. void board_init_f (ulong bootflag)
  357. {
  358. bd_t *bd;
  359. ulong len, addr, addr_sp;
  360. ulong *s;
  361. gd_t *id;
  362. init_fnc_t **init_fnc_ptr;
  363. #ifdef CONFIG_PRAM
  364. int i;
  365. ulong reg;
  366. uchar tmp[64]; /* long enough for environment variables */
  367. #endif
  368. /* Pointer is writable since we allocated a register for it */
  369. gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  370. /* compiler optimization barrier needed for GCC >= 3.4 */
  371. __asm__ __volatile__("": : :"memory");
  372. #if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
  373. /* Clear initial global data */
  374. memset ((void *) gd, 0, sizeof (gd_t));
  375. #endif
  376. for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  377. if ((*init_fnc_ptr) () != 0) {
  378. hang ();
  379. }
  380. }
  381. /*
  382. * Now that we have DRAM mapped and working, we can
  383. * relocate the code and continue running from DRAM.
  384. *
  385. * Reserve memory at end of RAM for (top down in that order):
  386. * - area that won't get touched by U-Boot and Linux (optional)
  387. * - kernel log buffer
  388. * - protected RAM
  389. * - LCD framebuffer
  390. * - monitor code
  391. * - board info struct
  392. */
  393. len = (ulong)&_end - CFG_MONITOR_BASE;
  394. /*
  395. * Subtract specified amount of memory to hide so that it won't
  396. * get "touched" at all by U-Boot. By fixing up gd->ram_size
  397. * the Linux kernel should now get passed the now "corrected"
  398. * memory size and won't touch it either. This should work
  399. * for arch/ppc and arch/powerpc. Only Linux board ports in
  400. * arch/powerpc with bootwrapper support, that recalculate the
  401. * memory size from the SDRAM controller setup will have to
  402. * get fixed.
  403. */
  404. gd->ram_size -= CFG_MEM_TOP_HIDE;
  405. addr = CFG_SDRAM_BASE + get_effective_memsize();
  406. #ifdef CONFIG_LOGBUFFER
  407. #ifndef CONFIG_ALT_LB_ADDR
  408. /* reserve kernel log buffer */
  409. addr -= (LOGBUFF_RESERVE);
  410. debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, addr);
  411. #endif
  412. #endif
  413. #ifdef CONFIG_PRAM
  414. /*
  415. * reserve protected RAM
  416. */
  417. i = getenv_r ("pram", (char *)tmp, sizeof (tmp));
  418. reg = (i > 0) ? simple_strtoul ((const char *)tmp, NULL, 10) : CONFIG_PRAM;
  419. addr -= (reg << 10); /* size is in kB */
  420. debug ("Reserving %ldk for protected RAM at %08lx\n", reg, addr);
  421. #endif /* CONFIG_PRAM */
  422. /* round down to next 4 kB limit */
  423. addr &= ~(4096 - 1);
  424. debug ("Top of RAM usable for U-Boot at: %08lx\n", addr);
  425. #ifdef CONFIG_LCD
  426. /* reserve memory for LCD display (always full pages) */
  427. addr = lcd_setmem (addr);
  428. gd->fb_base = addr;
  429. #endif /* CONFIG_LCD */
  430. #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx)
  431. /* reserve memory for video display (always full pages) */
  432. addr = video_setmem (addr);
  433. gd->fb_base = addr;
  434. #endif /* CONFIG_VIDEO */
  435. /*
  436. * reserve memory for U-Boot code, data & bss
  437. * round down to next 4 kB limit
  438. */
  439. addr -= len;
  440. addr &= ~(4096 - 1);
  441. #ifdef CONFIG_E500
  442. /* round down to next 64 kB limit so that IVPR stays aligned */
  443. addr &= ~(65536 - 1);
  444. #endif
  445. debug ("Reserving %ldk for U-Boot at: %08lx\n", len >> 10, addr);
  446. #ifdef CONFIG_AMIGAONEG3SE
  447. gd->relocaddr = addr;
  448. #endif
  449. /*
  450. * reserve memory for malloc() arena
  451. */
  452. addr_sp = addr - TOTAL_MALLOC_LEN;
  453. debug ("Reserving %dk for malloc() at: %08lx\n",
  454. TOTAL_MALLOC_LEN >> 10, addr_sp);
  455. /*
  456. * (permanently) allocate a Board Info struct
  457. * and a permanent copy of the "global" data
  458. */
  459. addr_sp -= sizeof (bd_t);
  460. bd = (bd_t *) addr_sp;
  461. gd->bd = bd;
  462. debug ("Reserving %d Bytes for Board Info at: %08lx\n",
  463. sizeof (bd_t), addr_sp);
  464. addr_sp -= sizeof (gd_t);
  465. id = (gd_t *) addr_sp;
  466. debug ("Reserving %d Bytes for Global Data at: %08lx\n",
  467. sizeof (gd_t), addr_sp);
  468. /*
  469. * Finally, we set up a new (bigger) stack.
  470. *
  471. * Leave some safety gap for SP, force alignment on 16 byte boundary
  472. * Clear initial stack frame
  473. */
  474. addr_sp -= 16;
  475. addr_sp &= ~0xF;
  476. s = (ulong *)addr_sp;
  477. *s-- = 0;
  478. *s-- = 0;
  479. addr_sp = (ulong)s;
  480. debug ("Stack Pointer at: %08lx\n", addr_sp);
  481. /*
  482. * Save local variables to board info struct
  483. */
  484. bd->bi_memstart = CFG_SDRAM_BASE; /* start of DRAM memory */
  485. bd->bi_memsize = gd->ram_size; /* size of DRAM memory in bytes */
  486. #ifdef CONFIG_IP860
  487. bd->bi_sramstart = SRAM_BASE; /* start of SRAM memory */
  488. bd->bi_sramsize = SRAM_SIZE; /* size of SRAM memory */
  489. #elif defined CONFIG_MPC8220
  490. bd->bi_sramstart = CFG_SRAM_BASE; /* start of SRAM memory */
  491. bd->bi_sramsize = CFG_SRAM_SIZE; /* size of SRAM memory */
  492. #else
  493. bd->bi_sramstart = 0; /* FIXME */ /* start of SRAM memory */
  494. bd->bi_sramsize = 0; /* FIXME */ /* size of SRAM memory */
  495. #endif
  496. #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx) || \
  497. defined(CONFIG_E500) || defined(CONFIG_MPC86xx)
  498. bd->bi_immr_base = CFG_IMMR; /* base of IMMR register */
  499. #endif
  500. #if defined(CONFIG_MPC5xxx)
  501. bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */
  502. #endif
  503. #if defined(CONFIG_MPC83XX)
  504. bd->bi_immrbar = CFG_IMMR;
  505. #endif
  506. #if defined(CONFIG_MPC8220)
  507. bd->bi_mbar_base = CFG_MBAR; /* base of internal registers */
  508. bd->bi_inpfreq = gd->inp_clk;
  509. bd->bi_pcifreq = gd->pci_clk;
  510. bd->bi_vcofreq = gd->vco_clk;
  511. bd->bi_pevfreq = gd->pev_clk;
  512. bd->bi_flbfreq = gd->flb_clk;
  513. /* store bootparam to sram (backward compatible), here? */
  514. {
  515. u32 *sram = (u32 *)CFG_SRAM_BASE;
  516. *sram++ = gd->ram_size;
  517. *sram++ = gd->bus_clk;
  518. *sram++ = gd->inp_clk;
  519. *sram++ = gd->cpu_clk;
  520. *sram++ = gd->vco_clk;
  521. *sram++ = gd->flb_clk;
  522. *sram++ = 0xb8c3ba11; /* boot signature */
  523. }
  524. #endif
  525. bd->bi_bootflags = bootflag; /* boot / reboot flag (for LynxOS) */
  526. WATCHDOG_RESET ();
  527. bd->bi_intfreq = gd->cpu_clk; /* Internal Freq, in Hz */
  528. bd->bi_busfreq = gd->bus_clk; /* Bus Freq, in Hz */
  529. #if defined(CONFIG_CPM2)
  530. bd->bi_cpmfreq = gd->cpm_clk;
  531. bd->bi_brgfreq = gd->brg_clk;
  532. bd->bi_sccfreq = gd->scc_clk;
  533. bd->bi_vco = gd->vco_out;
  534. #endif /* CONFIG_CPM2 */
  535. #if defined(CONFIG_MPC512X)
  536. bd->bi_ipsfreq = gd->ips_clk;
  537. #endif /* CONFIG_MPC512X */
  538. #if defined(CONFIG_MPC5xxx)
  539. bd->bi_ipbfreq = gd->ipb_clk;
  540. bd->bi_pcifreq = gd->pci_clk;
  541. #endif /* CONFIG_MPC5xxx */
  542. bd->bi_baudrate = gd->baudrate; /* Console Baudrate */
  543. #ifdef CFG_EXTBDINFO
  544. strncpy ((char *)bd->bi_s_version, "1.2", sizeof (bd->bi_s_version));
  545. strncpy ((char *)bd->bi_r_version, U_BOOT_VERSION, sizeof (bd->bi_r_version));
  546. bd->bi_procfreq = gd->cpu_clk; /* Processor Speed, In Hz */
  547. bd->bi_plb_busfreq = gd->bus_clk;
  548. #if defined(CONFIG_405GP) || defined(CONFIG_405EP) || \
  549. defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
  550. defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  551. bd->bi_pci_busfreq = get_PCI_freq ();
  552. bd->bi_opbfreq = get_OPB_freq ();
  553. #elif defined(CONFIG_XILINX_ML300)
  554. bd->bi_pci_busfreq = get_PCI_freq ();
  555. #endif
  556. #endif
  557. debug ("New Stack Pointer is: %08lx\n", addr_sp);
  558. WATCHDOG_RESET ();
  559. #ifdef CONFIG_POST
  560. post_bootmode_init();
  561. post_run (NULL, POST_ROM | post_bootmode_get(0));
  562. #endif
  563. WATCHDOG_RESET();
  564. memcpy (id, (void *)gd, sizeof (gd_t));
  565. relocate_code (addr_sp, id, addr);
  566. /* NOTREACHED - relocate_code() does not return */
  567. }
  568. /************************************************************************
  569. *
  570. * This is the next part if the initialization sequence: we are now
  571. * running from RAM and have a "normal" C environment, i. e. global
  572. * data can be written, BSS has been cleared, the stack size in not
  573. * that critical any more, etc.
  574. *
  575. ************************************************************************
  576. */
  577. void board_init_r (gd_t *id, ulong dest_addr)
  578. {
  579. cmd_tbl_t *cmdtp;
  580. char *s, *e;
  581. bd_t *bd;
  582. int i;
  583. extern void malloc_bin_reloc (void);
  584. #ifndef CFG_ENV_IS_NOWHERE
  585. extern char * env_name_spec;
  586. #endif
  587. #ifndef CFG_NO_FLASH
  588. ulong flash_size;
  589. #endif
  590. gd = id; /* initialize RAM version of global data */
  591. bd = gd->bd;
  592. gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */
  593. #if defined(CONFIG_RELOC_FIXUP_WORKS)
  594. gd->reloc_off = 0;
  595. mem_malloc_end = dest_addr;
  596. #else
  597. gd->reloc_off = dest_addr - CFG_MONITOR_BASE;
  598. #endif
  599. #ifdef CONFIG_SERIAL_MULTI
  600. serial_initialize();
  601. #endif
  602. debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr);
  603. WATCHDOG_RESET ();
  604. #if defined(CONFIG_BOARD_EARLY_INIT_R)
  605. board_early_init_r ();
  606. #endif
  607. monitor_flash_len = (ulong)&__init_end - dest_addr;
  608. /*
  609. * We have to relocate the command table manually
  610. */
  611. for (cmdtp = &__u_boot_cmd_start; cmdtp != &__u_boot_cmd_end; cmdtp++) {
  612. ulong addr;
  613. addr = (ulong) (cmdtp->cmd) + gd->reloc_off;
  614. #if 0
  615. printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
  616. cmdtp->name, (ulong) (cmdtp->cmd), addr);
  617. #endif
  618. cmdtp->cmd =
  619. (int (*)(struct cmd_tbl_s *, int, int, char *[]))addr;
  620. addr = (ulong)(cmdtp->name) + gd->reloc_off;
  621. cmdtp->name = (char *)addr;
  622. if (cmdtp->usage) {
  623. addr = (ulong)(cmdtp->usage) + gd->reloc_off;
  624. cmdtp->usage = (char *)addr;
  625. }
  626. #ifdef CFG_LONGHELP
  627. if (cmdtp->help) {
  628. addr = (ulong)(cmdtp->help) + gd->reloc_off;
  629. cmdtp->help = (char *)addr;
  630. }
  631. #endif
  632. }
  633. /* there are some other pointer constants we must deal with */
  634. #ifndef CFG_ENV_IS_NOWHERE
  635. env_name_spec += gd->reloc_off;
  636. #endif
  637. WATCHDOG_RESET ();
  638. #ifdef CONFIG_LOGBUFFER
  639. logbuff_init_ptrs ();
  640. #endif
  641. #ifdef CONFIG_POST
  642. post_output_backlog ();
  643. post_reloc ();
  644. #endif
  645. WATCHDOG_RESET();
  646. #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || \
  647. defined (CONFIG_FLAGADM) || defined(CONFIG_MPC83XX)
  648. icache_enable (); /* it's time to enable the instruction cache */
  649. #endif
  650. #if defined(CFG_INIT_RAM_LOCK) && defined(CONFIG_E500)
  651. unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */
  652. #endif
  653. #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45)
  654. /*
  655. * Do PCI configuration on BAB7xx and CPC45 _before_ the flash
  656. * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus
  657. * bridge there.
  658. */
  659. pci_init ();
  660. #endif
  661. #if defined(CONFIG_BAB7xx)
  662. /*
  663. * Initialise the ISA bridge
  664. */
  665. initialise_w83c553f ();
  666. #endif
  667. asm ("sync ; isync");
  668. /*
  669. * Setup trap handlers
  670. */
  671. trap_init (dest_addr);
  672. #if !defined(CFG_NO_FLASH)
  673. puts ("FLASH: ");
  674. if ((flash_size = flash_init ()) > 0) {
  675. # ifdef CFG_FLASH_CHECKSUM
  676. print_size (flash_size, "");
  677. /*
  678. * Compute and print flash CRC if flashchecksum is set to 'y'
  679. *
  680. * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
  681. */
  682. s = getenv ("flashchecksum");
  683. if (s && (*s == 'y')) {
  684. printf (" CRC: %08lX",
  685. crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size)
  686. );
  687. }
  688. putc ('\n');
  689. # else /* !CFG_FLASH_CHECKSUM */
  690. print_size (flash_size, "\n");
  691. # endif /* CFG_FLASH_CHECKSUM */
  692. } else {
  693. puts (failed);
  694. hang ();
  695. }
  696. bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */
  697. bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
  698. #if defined(CFG_UPDATE_FLASH_SIZE)
  699. /* Make a update of the Memctrl. */
  700. update_flash_size (flash_size);
  701. #endif
  702. # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU)
  703. /* flash mapped at end of memory map */
  704. bd->bi_flashoffset = TEXT_BASE + flash_size;
  705. # elif CFG_MONITOR_BASE == CFG_FLASH_BASE
  706. bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */
  707. # else
  708. bd->bi_flashoffset = 0;
  709. # endif
  710. #else /* CFG_NO_FLASH */
  711. bd->bi_flashsize = 0;
  712. bd->bi_flashstart = 0;
  713. bd->bi_flashoffset = 0;
  714. #endif /* !CFG_NO_FLASH */
  715. WATCHDOG_RESET ();
  716. /* initialize higher level parts of CPU like time base and timers */
  717. cpu_init_r ();
  718. WATCHDOG_RESET ();
  719. /* initialize malloc() area */
  720. mem_malloc_init ();
  721. malloc_bin_reloc ();
  722. #ifdef CONFIG_SPI
  723. # if !defined(CFG_ENV_IS_IN_EEPROM)
  724. spi_init_f ();
  725. # endif
  726. spi_init_r ();
  727. #endif
  728. #if defined(CONFIG_CMD_NAND)
  729. WATCHDOG_RESET ();
  730. puts ("NAND: ");
  731. nand_init(); /* go init the NAND */
  732. #endif
  733. /* relocate environment function pointers etc. */
  734. env_relocate ();
  735. /*
  736. * Fill in missing fields of bd_info.
  737. * We do this here, where we have "normal" access to the
  738. * environment; we used to do this still running from ROM,
  739. * where had to use getenv_r(), which can be pretty slow when
  740. * the environment is in EEPROM.
  741. */
  742. #if defined(CFG_EXTBDINFO)
  743. #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
  744. #if defined(CONFIG_I2CFAST)
  745. /*
  746. * set bi_iic_fast for linux taking environment variable
  747. * "i2cfast" into account
  748. */
  749. {
  750. char *s = getenv ("i2cfast");
  751. if (s && ((*s == 'y') || (*s == 'Y'))) {
  752. bd->bi_iic_fast[0] = 1;
  753. bd->bi_iic_fast[1] = 1;
  754. } else {
  755. bd->bi_iic_fast[0] = 0;
  756. bd->bi_iic_fast[1] = 0;
  757. }
  758. }
  759. #else
  760. bd->bi_iic_fast[0] = 0;
  761. bd->bi_iic_fast[1] = 0;
  762. #endif /* CONFIG_I2CFAST */
  763. #endif /* CONFIG_405GP, CONFIG_405EP */
  764. #endif /* CFG_EXTBDINFO */
  765. #if defined(CONFIG_SC3)
  766. sc3_read_eeprom();
  767. #endif
  768. #if defined (CFG_ID_EEPROM) || defined (CFG_I2C_MAC_OFFSET)
  769. mac_read_from_eeprom();
  770. #endif
  771. s = getenv ("ethaddr");
  772. #if defined (CONFIG_MBX) || \
  773. defined (CONFIG_RPXCLASSIC) || \
  774. defined(CONFIG_IAD210) || \
  775. defined(CONFIG_V38B)
  776. if (s == NULL)
  777. board_get_enetaddr (bd->bi_enetaddr);
  778. else
  779. #endif
  780. for (i = 0; i < 6; ++i) {
  781. bd->bi_enetaddr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  782. if (s)
  783. s = (*e) ? e + 1 : e;
  784. }
  785. #ifdef CONFIG_HERMES
  786. if ((gd->board_type >> 16) == 2)
  787. bd->bi_ethspeed = gd->board_type & 0xFFFF;
  788. else
  789. bd->bi_ethspeed = 0xFFFF;
  790. #endif
  791. #ifdef CONFIG_NX823
  792. load_sernum_ethaddr ();
  793. #endif
  794. #ifdef CONFIG_HAS_ETH1
  795. /* handle the 2nd ethernet address */
  796. s = getenv ("eth1addr");
  797. for (i = 0; i < 6; ++i) {
  798. bd->bi_enet1addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  799. if (s)
  800. s = (*e) ? e + 1 : e;
  801. }
  802. #endif
  803. #ifdef CONFIG_HAS_ETH2
  804. /* handle the 3rd ethernet address */
  805. s = getenv ("eth2addr");
  806. #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
  807. if (s == NULL)
  808. board_get_enetaddr(bd->bi_enet2addr);
  809. else
  810. #endif
  811. for (i = 0; i < 6; ++i) {
  812. bd->bi_enet2addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  813. if (s)
  814. s = (*e) ? e + 1 : e;
  815. }
  816. #endif
  817. #ifdef CONFIG_HAS_ETH3
  818. /* handle 4th ethernet address */
  819. s = getenv("eth3addr");
  820. #if defined(CONFIG_XPEDITE1K) || defined(CONFIG_METROBOX) || defined(CONFIG_KAREF)
  821. if (s == NULL)
  822. board_get_enetaddr(bd->bi_enet3addr);
  823. else
  824. #endif
  825. for (i = 0; i < 6; ++i) {
  826. bd->bi_enet3addr[i] = s ? simple_strtoul (s, &e, 16) : 0;
  827. if (s)
  828. s = (*e) ? e + 1 : e;
  829. }
  830. #endif
  831. #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
  832. defined(CONFIG_TQM8272) || \
  833. defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || \
  834. defined(CONFIG_KUP4X) || defined(CONFIG_PCS440EP)
  835. load_sernum_ethaddr ();
  836. #endif
  837. /* IP Address */
  838. bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
  839. WATCHDOG_RESET ();
  840. #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45)
  841. /*
  842. * Do pci configuration
  843. */
  844. pci_init ();
  845. #endif
  846. /** leave this here (after malloc(), environment and PCI are working) **/
  847. /* Initialize devices */
  848. devices_init ();
  849. /* Initialize the jump table for applications */
  850. jumptable_init ();
  851. #if defined(CONFIG_API)
  852. /* Initialize API */
  853. api_init ();
  854. #endif
  855. /* Initialize the console (after the relocation and devices init) */
  856. console_init_r ();
  857. #if defined(CONFIG_CCM) || \
  858. defined(CONFIG_COGENT) || \
  859. defined(CONFIG_CPCI405) || \
  860. defined(CONFIG_EVB64260) || \
  861. defined(CONFIG_KUP4K) || \
  862. defined(CONFIG_KUP4X) || \
  863. defined(CONFIG_LWMON) || \
  864. defined(CONFIG_PCU_E) || \
  865. defined(CONFIG_SC3) || \
  866. defined(CONFIG_W7O) || \
  867. defined(CONFIG_MISC_INIT_R)
  868. /* miscellaneous platform dependent initialisations */
  869. misc_init_r ();
  870. #endif
  871. #ifdef CONFIG_HERMES
  872. if (bd->bi_ethspeed != 0xFFFF)
  873. hermes_start_lxt980 ((int) bd->bi_ethspeed);
  874. #endif
  875. #if defined(CONFIG_CMD_KGDB)
  876. WATCHDOG_RESET ();
  877. puts ("KGDB: ");
  878. kgdb_init ();
  879. #endif
  880. debug ("U-Boot relocated to %08lx\n", dest_addr);
  881. /*
  882. * Enable Interrupts
  883. */
  884. interrupt_init ();
  885. /* Must happen after interrupts are initialized since
  886. * an irq handler gets installed
  887. */
  888. #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
  889. serial_buffered_init();
  890. #endif
  891. #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
  892. status_led_set (STATUS_LED_BOOT, STATUS_LED_BLINKING);
  893. #endif
  894. udelay (20);
  895. set_timer (0);
  896. /* Initialize from environment */
  897. if ((s = getenv ("loadaddr")) != NULL) {
  898. load_addr = simple_strtoul (s, NULL, 16);
  899. }
  900. #if defined(CONFIG_CMD_NET)
  901. if ((s = getenv ("bootfile")) != NULL) {
  902. copy_filename (BootFile, s, sizeof (BootFile));
  903. }
  904. #endif
  905. WATCHDOG_RESET ();
  906. #if defined(CONFIG_CMD_SCSI)
  907. WATCHDOG_RESET ();
  908. puts ("SCSI: ");
  909. scsi_init ();
  910. #endif
  911. #if defined(CONFIG_CMD_DOC)
  912. WATCHDOG_RESET ();
  913. puts ("DOC: ");
  914. doc_init ();
  915. #endif
  916. #if defined(CONFIG_CMD_NET)
  917. #if defined(CONFIG_NET_MULTI)
  918. WATCHDOG_RESET ();
  919. puts ("Net: ");
  920. #endif
  921. eth_initialize (bd);
  922. #endif
  923. #if defined(CONFIG_CMD_NET) && ( \
  924. defined(CONFIG_CCM) || \
  925. defined(CONFIG_ELPT860) || \
  926. defined(CONFIG_EP8260) || \
  927. defined(CONFIG_IP860) || \
  928. defined(CONFIG_IVML24) || \
  929. defined(CONFIG_IVMS8) || \
  930. defined(CONFIG_MPC8260ADS) || \
  931. defined(CONFIG_MPC8266ADS) || \
  932. defined(CONFIG_MPC8560ADS) || \
  933. defined(CONFIG_PCU_E) || \
  934. defined(CONFIG_RPXSUPER) || \
  935. defined(CONFIG_STXGP3) || \
  936. defined(CONFIG_SPD823TS) || \
  937. defined(CONFIG_RESET_PHY_R) )
  938. WATCHDOG_RESET ();
  939. debug ("Reset Ethernet PHY\n");
  940. reset_phy ();
  941. #endif
  942. #ifdef CONFIG_POST
  943. post_run (NULL, POST_RAM | post_bootmode_get(0));
  944. #endif
  945. #if defined(CONFIG_CMD_PCMCIA) \
  946. && !defined(CONFIG_CMD_IDE)
  947. WATCHDOG_RESET ();
  948. puts ("PCMCIA:");
  949. pcmcia_init ();
  950. #endif
  951. #if defined(CONFIG_CMD_IDE)
  952. WATCHDOG_RESET ();
  953. # ifdef CONFIG_IDE_8xx_PCCARD
  954. puts ("PCMCIA:");
  955. # else
  956. puts ("IDE: ");
  957. #endif
  958. #if defined(CONFIG_START_IDE)
  959. if (board_start_ide())
  960. ide_init ();
  961. #else
  962. ide_init ();
  963. #endif
  964. #endif
  965. #if defined(CONFIG_CMD_SATA)
  966. puts ("SATA: ");
  967. sata_initialize ();
  968. #endif
  969. #ifdef CONFIG_LAST_STAGE_INIT
  970. WATCHDOG_RESET ();
  971. /*
  972. * Some parts can be only initialized if all others (like
  973. * Interrupts) are up and running (i.e. the PC-style ISA
  974. * keyboard).
  975. */
  976. last_stage_init ();
  977. #endif
  978. #if defined(CONFIG_CMD_BEDBUG)
  979. WATCHDOG_RESET ();
  980. bedbug_init ();
  981. #endif
  982. #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
  983. /*
  984. * Export available size of memory for Linux,
  985. * taking into account the protected RAM at top of memory
  986. */
  987. {
  988. ulong pram;
  989. uchar memsz[32];
  990. #ifdef CONFIG_PRAM
  991. char *s;
  992. if ((s = getenv ("pram")) != NULL) {
  993. pram = simple_strtoul (s, NULL, 10);
  994. } else {
  995. pram = CONFIG_PRAM;
  996. }
  997. #else
  998. pram=0;
  999. #endif
  1000. #ifdef CONFIG_LOGBUFFER
  1001. #ifndef CONFIG_ALT_LB_ADDR
  1002. /* Also take the logbuffer into account (pram is in kB) */
  1003. pram += (LOGBUFF_LEN+LOGBUFF_OVERHEAD)/1024;
  1004. #endif
  1005. #endif
  1006. sprintf ((char *)memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
  1007. setenv ("mem", (char *)memsz);
  1008. }
  1009. #endif
  1010. #ifdef CONFIG_PS2KBD
  1011. puts ("PS/2: ");
  1012. kbd_init();
  1013. #endif
  1014. #ifdef CONFIG_MODEM_SUPPORT
  1015. {
  1016. extern int do_mdm_init;
  1017. do_mdm_init = gd->do_mdm_init;
  1018. }
  1019. #endif
  1020. /* Initialization complete - start the monitor */
  1021. /* main_loop() can return to retry autoboot, if so just run it again. */
  1022. for (;;) {
  1023. WATCHDOG_RESET ();
  1024. main_loop ();
  1025. }
  1026. /* NOTREACHED - no way out of command loop except booting */
  1027. }
  1028. void hang (void)
  1029. {
  1030. puts ("### ERROR ### Please RESET the board ###\n");
  1031. show_boot_progress(-30);
  1032. for (;;);
  1033. }
  1034. #ifdef CONFIG_MODEM_SUPPORT
  1035. /* called from main loop (common/main.c) */
  1036. /* 'inline' - We have to do it fast */
  1037. static inline void mdm_readline(char *buf, int bufsiz)
  1038. {
  1039. char c;
  1040. char *p;
  1041. int n;
  1042. n = 0;
  1043. p = buf;
  1044. for(;;) {
  1045. c = serial_getc();
  1046. /* dbg("(%c)", c); */
  1047. switch(c) {
  1048. case '\r':
  1049. break;
  1050. case '\n':
  1051. *p = '\0';
  1052. return;
  1053. default:
  1054. if(n++ > bufsiz) {
  1055. *p = '\0';
  1056. return; /* sanity check */
  1057. }
  1058. *p = c;
  1059. p++;
  1060. break;
  1061. }
  1062. }
  1063. }
  1064. extern void dbg(const char *fmt, ...);
  1065. int mdm_init (void)
  1066. {
  1067. char env_str[16];
  1068. char *init_str;
  1069. int i;
  1070. extern char console_buffer[];
  1071. extern void enable_putc(void);
  1072. extern int hwflow_onoff(int);
  1073. enable_putc(); /* enable serial_putc() */
  1074. #ifdef CONFIG_HWFLOW
  1075. init_str = getenv("mdm_flow_control");
  1076. if (init_str && (strcmp(init_str, "rts/cts") == 0))
  1077. hwflow_onoff (1);
  1078. else
  1079. hwflow_onoff(-1);
  1080. #endif
  1081. for (i = 1;;i++) {
  1082. sprintf(env_str, "mdm_init%d", i);
  1083. if ((init_str = getenv(env_str)) != NULL) {
  1084. serial_puts(init_str);
  1085. serial_puts("\n");
  1086. for(;;) {
  1087. mdm_readline(console_buffer, CFG_CBSIZE);
  1088. dbg("ini%d: [%s]", i, console_buffer);
  1089. if ((strcmp(console_buffer, "OK") == 0) ||
  1090. (strcmp(console_buffer, "ERROR") == 0)) {
  1091. dbg("ini%d: cmd done", i);
  1092. break;
  1093. } else /* in case we are originating call ... */
  1094. if (strncmp(console_buffer, "CONNECT", 7) == 0) {
  1095. dbg("ini%d: connect", i);
  1096. return 0;
  1097. }
  1098. }
  1099. } else
  1100. break; /* no init string - stop modem init */
  1101. udelay(100000);
  1102. }
  1103. udelay(100000);
  1104. /* final stage - wait for connect */
  1105. for(;i > 1;) { /* if 'i' > 1 - wait for connection
  1106. message from modem */
  1107. mdm_readline(console_buffer, CFG_CBSIZE);
  1108. dbg("ini_f: [%s]", console_buffer);
  1109. if (strncmp(console_buffer, "CONNECT", 7) == 0) {
  1110. dbg("ini_f: connected");
  1111. return 0;
  1112. }
  1113. }
  1114. return 0;
  1115. }
  1116. #endif
  1117. #if 0 /* We could use plain global data, but the resulting code is bigger */
  1118. /*
  1119. * Pointer to initial global data area
  1120. *
  1121. * Here we initialize it.
  1122. */
  1123. #undef XTRN_DECLARE_GLOBAL_DATA_PTR
  1124. #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
  1125. DECLARE_GLOBAL_DATA_PTR = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
  1126. #endif /* 0 */
  1127. /************************************************************************/