board.c 31 KB

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