board.c 31 KB

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