]>
git.ipfire.org Git - people/ms/u-boot.git/blob - lib_ppc/board.c
2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
38 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
41 #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
44 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
47 #ifdef CONFIG_STATUS_LED
48 #include <status_led.h>
51 #ifdef CFG_ALLOC_DPRAM
52 #if !defined(CONFIG_8260)
57 #if defined(CONFIG_BAB7xx)
61 #if defined(CONFIG_POST)
64 #if defined(CONFIG_LOGBUFFER)
68 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
71 #if defined(CONFIG_HARD_I2C) || \
72 defined(CONFIG_SOFT_I2C)
75 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
76 void nand_init (void);
79 static char *failed
= "*** failed ***\n";
81 #if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
82 extern flash_info_t flash_info
[];
85 #include <environment.h>
87 #if ( ((CFG_ENV_ADDR+CFG_ENV_SIZE) < CFG_MONITOR_BASE) || \
88 (CFG_ENV_ADDR >= (CFG_MONITOR_BASE + CFG_MONITOR_LEN)) ) || \
89 defined(CFG_ENV_IS_IN_NVRAM)
90 #define TOTAL_MALLOC_LEN (CFG_MALLOC_LEN + CFG_ENV_SIZE)
92 #define TOTAL_MALLOC_LEN CFG_MALLOC_LEN
95 extern ulong __init_end
;
97 ulong monitor_flash_len
;
99 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
100 #include <bedbug/type.h>
104 * Begin and End of memory area for malloc(), and current "brk"
106 static ulong mem_malloc_start
= 0;
107 static ulong mem_malloc_end
= 0;
108 static ulong mem_malloc_brk
= 0;
110 /************************************************************************
112 ************************************************************************
116 * The Malloc area is immediately below the monitor copy in DRAM
118 static void mem_malloc_init (void)
120 DECLARE_GLOBAL_DATA_PTR
;
122 ulong dest_addr
= CFG_MONITOR_BASE
+ gd
->reloc_off
;
124 mem_malloc_end
= dest_addr
;
125 mem_malloc_start
= dest_addr
- TOTAL_MALLOC_LEN
;
126 mem_malloc_brk
= mem_malloc_start
;
128 memset ((void *) mem_malloc_start
,
130 mem_malloc_end
- mem_malloc_start
);
133 void *sbrk (ptrdiff_t increment
)
135 ulong old
= mem_malloc_brk
;
136 ulong
new = old
+ increment
;
138 if ((new < mem_malloc_start
) || (new > mem_malloc_end
)) {
141 mem_malloc_brk
= new;
142 return ((void *) old
);
145 char *strmhz (char *buf
, long hz
)
151 l
= sprintf (buf
, "%ld", n
);
152 m
= (hz
% 1000000L) / 1000L;
154 sprintf (buf
+ l
, ".%03ld", m
);
159 * All attempts to come up with a "common" initialization sequence
160 * that works for all boards and architectures failed: some of the
161 * requirements are just _too_ different. To get rid of the resulting
162 * mess of board dependend #ifdef'ed code we now make the whole
163 * initialization sequence configurable to the user.
165 * The requirements for any new initalization function is simple: it
166 * receives a pointer to the "global data" structure as it's only
167 * argument, and returns an integer return code, where 0 means
168 * "continue" and != 0 means "fatal error, hang the system".
170 typedef int (init_fnc_t
) (void);
172 /************************************************************************
174 ************************************************************************
175 * Some of this code should be moved into the core functions,
176 * but let's get it working (again) first...
179 static int init_baudrate (void)
181 DECLARE_GLOBAL_DATA_PTR
;
183 uchar tmp
[64]; /* long enough for environment variables */
184 int i
= getenv_r ("baudrate", tmp
, sizeof (tmp
));
186 gd
->baudrate
= (i
> 0)
187 ? (int) simple_strtoul (tmp
, NULL
, 10)
192 /***********************************************************************/
194 static int init_func_ram (void)
196 DECLARE_GLOBAL_DATA_PTR
;
198 #ifdef CONFIG_BOARD_TYPES
199 int board_type
= gd
->board_type
;
201 int board_type
= 0; /* use dummy arg */
205 if ((gd
->ram_size
= initdram (board_type
)) > 0) {
206 print_size (gd
->ram_size
, "\n");
213 /***********************************************************************/
215 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
216 static int init_func_i2c (void)
219 i2c_init (CFG_I2C_SPEED
, CFG_I2C_SLAVE
);
225 /***********************************************************************/
227 #if defined(CONFIG_WATCHDOG)
228 static int init_func_watchdog_init (void)
230 puts (" Watchdog enabled\n");
234 # define INIT_FUNC_WATCHDOG_INIT init_func_watchdog_init,
236 static int init_func_watchdog_reset (void)
241 # define INIT_FUNC_WATCHDOG_RESET init_func_watchdog_reset,
243 # define INIT_FUNC_WATCHDOG_INIT /* undef */
244 # define INIT_FUNC_WATCHDOG_RESET /* undef */
245 #endif /* CONFIG_WATCHDOG */
247 /************************************************************************
248 * Initialization sequence *
249 ************************************************************************
252 init_fnc_t
*init_sequence
[] = {
254 #if defined(CONFIG_BOARD_PRE_INIT)
255 board_pre_init
, /* very early board init code (fpga boot, etc.) */
258 get_clocks
, /* get CPU and bus clocks (etc.) */
260 #ifdef CFG_ALLOC_DPRAM
261 #if !defined(CONFIG_8260)
265 #if defined(CONFIG_BOARD_POSTCLK_INIT)
273 #if defined(CONFIG_8260)
276 #endif /* CONFIG_8260 */
278 #if defined(CONFIG_MPC5XXX)
280 #endif /* CONFIG_MPC5XXX */
282 INIT_FUNC_WATCHDOG_INIT
283 #if defined(CONFIG_BMW) || \
284 defined(CONFIG_COGENT) || \
285 defined(CONFIG_HYMOD) || \
286 defined(CONFIG_RSD_PROTO) || \
290 INIT_FUNC_WATCHDOG_RESET
291 #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
294 #if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
300 INIT_FUNC_WATCHDOG_RESET
302 #if defined(CFG_DRAM_TEST)
304 #endif /* CFG_DRAM_TEST */
305 INIT_FUNC_WATCHDOG_RESET
307 NULL
, /* Terminate this list */
310 /************************************************************************
312 * This is the first part of the initialization sequence that is
313 * implemented in C, but still running from ROM.
315 * The main purpose is to provide a (serial) console interface as
316 * soon as possible (so we can see any error messages), and to
317 * initialize the RAM so that we can relocate the monitor code to
320 * Be aware of the restrictions: global data is read-only, BSS is not
321 * initialized, and stack space is limited to a few kB.
323 ************************************************************************
326 void board_init_f (ulong bootflag
)
328 DECLARE_GLOBAL_DATA_PTR
;
331 ulong len
, addr
, addr_sp
;
333 init_fnc_t
**init_fnc_ptr
;
337 uchar tmp
[64]; /* long enough for environment variables */
340 /* Pointer is writable since we allocated a register for it */
341 gd
= (gd_t
*) (CFG_INIT_RAM_ADDR
+ CFG_GBL_DATA_OFFSET
);
344 /* Clear initial global data */
345 memset ((void *) gd
, 0, sizeof (gd_t
));
348 for (init_fnc_ptr
= init_sequence
; *init_fnc_ptr
; ++init_fnc_ptr
) {
349 if ((*init_fnc_ptr
) () != 0) {
355 * Now that we have DRAM mapped and working, we can
356 * relocate the code and continue running from DRAM.
358 * Reserve memory at end of RAM for (top down in that order):
359 * - kernel log buffer
363 * - board info struct
365 len
= (ulong
)&_end
- CFG_MONITOR_BASE
;
367 #ifndef CONFIG_VERY_BIG_RAM
368 addr
= CFG_SDRAM_BASE
+ gd
->ram_size
;
370 /* only allow stack below 256M */
371 addr
= CFG_SDRAM_BASE
+
372 (gd
->ram_size
> 256 << 20) ? 256 << 20 : gd
->ram_size
;
375 #ifdef CONFIG_LOGBUFFER
376 /* reserve kernel log buffer */
377 addr
-= (LOGBUFF_RESERVE
);
378 debug ("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN
, addr
);
383 * reserve protected RAM
385 i
= getenv_r ("pram", tmp
, sizeof (tmp
));
386 reg
= (i
> 0) ? simple_strtoul (tmp
, NULL
, 10) : CONFIG_PRAM
;
387 addr
-= (reg
<< 10); /* size is in kB */
388 debug ("Reserving %ldk for protected RAM at %08lx\n", reg
, addr
);
389 #endif /* CONFIG_PRAM */
391 /* round down to next 4 kB limit */
393 debug ("Top of RAM usable for U-Boot at: %08lx\n", addr
);
396 /* reserve memory for LCD display (always full pages) */
397 addr
= lcd_setmem (addr
);
399 #endif /* CONFIG_LCD */
401 #if defined(CONFIG_VIDEO) && defined(CONFIG_8xx)
402 /* reserve memory for video display (always full pages) */
403 addr
= video_setmem (addr
);
405 #endif /* CONFIG_VIDEO */
408 * reserve memory for U-Boot code, data & bss
409 * round down to next 4 kB limit
414 debug ("Reserving %ldk for U-Boot at: %08lx\n", len
>> 10, addr
);
416 #ifdef CONFIG_AMIGAONEG3SE
417 gd
->relocaddr
= addr
;
421 * reserve memory for malloc() arena
423 addr_sp
= addr
- TOTAL_MALLOC_LEN
;
424 debug ("Reserving %dk for malloc() at: %08lx\n",
425 TOTAL_MALLOC_LEN
>> 10, addr_sp
);
428 * (permanently) allocate a Board Info struct
429 * and a permanent copy of the "global" data
431 addr_sp
-= sizeof (bd_t
);
432 bd
= (bd_t
*) addr_sp
;
434 debug ("Reserving %d Bytes for Board Info at: %08lx\n",
435 sizeof (bd_t
), addr_sp
);
436 addr_sp
-= sizeof (gd_t
);
437 id
= (gd_t
*) addr_sp
;
438 debug ("Reserving %d Bytes for Global Data at: %08lx\n",
439 sizeof (gd_t
), addr_sp
);
442 * Finally, we set up a new (bigger) stack.
444 * Leave some safety gap for SP, force alignment on 16 byte boundary
445 * Clear initial stack frame
449 *((ulong
*) addr_sp
)-- = 0;
450 *((ulong
*) addr_sp
)-- = 0;
451 debug ("Stack Pointer at: %08lx\n", addr_sp
);
454 * Save local variables to board info struct
457 bd
->bi_memstart
= CFG_SDRAM_BASE
; /* start of DRAM memory */
458 bd
->bi_memsize
= gd
->ram_size
; /* size of DRAM memory in bytes */
461 bd
->bi_sramstart
= SRAM_BASE
; /* start of SRAM memory */
462 bd
->bi_sramsize
= SRAM_SIZE
; /* size of SRAM memory */
464 bd
->bi_sramstart
= 0; /* FIXME */ /* start of SRAM memory */
465 bd
->bi_sramsize
= 0; /* FIXME */ /* size of SRAM memory */
468 #if defined(CONFIG_8xx) || defined(CONFIG_8260) || defined(CONFIG_5xx)
469 bd
->bi_immr_base
= CFG_IMMR
; /* base of IMMR register */
471 #if defined(CONFIG_MPC5XXX)
472 bd
->bi_mbar_base
= CFG_MBAR
; /* base of internal registers */
475 bd
->bi_bootflags
= bootflag
; /* boot / reboot flag (for LynxOS) */
478 bd
->bi_intfreq
= gd
->cpu_clk
; /* Internal Freq, in Hz */
479 bd
->bi_busfreq
= gd
->bus_clk
; /* Bus Freq, in Hz */
480 #if defined(CONFIG_8260)
481 bd
->bi_cpmfreq
= gd
->cpm_clk
;
482 bd
->bi_brgfreq
= gd
->brg_clk
;
483 bd
->bi_sccfreq
= gd
->scc_clk
;
484 bd
->bi_vco
= gd
->vco_out
;
485 #endif /* CONFIG_8260 */
486 #if defined(CONFIG_MPC5XXX)
487 bd
->bi_ipbfreq
= gd
->ipb_clk
;
488 bd
->bi_pcifreq
= gd
->pci_clk
;
489 #endif /* CONFIG_MPC5XXX */
490 bd
->bi_baudrate
= gd
->baudrate
; /* Console Baudrate */
493 strncpy (bd
->bi_s_version
, "1.2", sizeof (bd
->bi_s_version
));
494 strncpy (bd
->bi_r_version
, U_BOOT_VERSION
, sizeof (bd
->bi_r_version
));
496 bd
->bi_procfreq
= gd
->cpu_clk
; /* Processor Speed, In Hz */
497 bd
->bi_plb_busfreq
= gd
->bus_clk
;
498 #if defined(CONFIG_405GP) || defined(CONFIG_405EP)
499 bd
->bi_pci_busfreq
= get_PCI_freq ();
503 debug ("New Stack Pointer is: %08lx\n", addr_sp
);
508 post_bootmode_init();
509 post_run (NULL
, POST_ROM
| post_bootmode_get(0));
514 memcpy (id
, (void *)gd
, sizeof (gd_t
));
516 relocate_code (addr_sp
, id
, addr
);
518 /* NOTREACHED - relocate_code() does not return */
522 /************************************************************************
524 * This is the next part if the initialization sequence: we are now
525 * running from RAM and have a "normal" C environment, i. e. global
526 * data can be written, BSS has been cleared, the stack size in not
527 * that critical any more, etc.
529 ************************************************************************
532 void board_init_r (gd_t
*id
, ulong dest_addr
)
534 DECLARE_GLOBAL_DATA_PTR
;
539 extern void malloc_bin_reloc (void);
540 #ifndef CFG_ENV_IS_NOWHERE
541 extern char * env_name_spec
;
548 gd
= id
; /* initialize RAM version of global data */
551 gd
->flags
|= GD_FLG_RELOC
; /* tell others: relocation done */
553 debug ("Now running in RAM - U-Boot at: %08lx\n", dest_addr
);
557 gd
->reloc_off
= dest_addr
- CFG_MONITOR_BASE
;
559 monitor_flash_len
= (ulong
)&__init_end
- dest_addr
;
562 * We have to relocate the command table manually
564 for (cmdtp
= &__u_boot_cmd_start
; cmdtp
!= &__u_boot_cmd_end
; cmdtp
++) {
566 addr
= (ulong
) (cmdtp
->cmd
) + gd
->reloc_off
;
568 printf ("Command \"%s\": 0x%08lx => 0x%08lx\n",
569 cmdtp
->name
, (ulong
) (cmdtp
->cmd
), addr
);
572 (int (*)(struct cmd_tbl_s
*, int, int, char *[]))addr
;
574 addr
= (ulong
)(cmdtp
->name
) + gd
->reloc_off
;
575 cmdtp
->name
= (char *)addr
;
578 addr
= (ulong
)(cmdtp
->usage
) + gd
->reloc_off
;
579 cmdtp
->usage
= (char *)addr
;
583 addr
= (ulong
)(cmdtp
->help
) + gd
->reloc_off
;
584 cmdtp
->help
= (char *)addr
;
588 /* there are some other pointer constants we must deal with */
589 #ifndef CFG_ENV_IS_NOWHERE
590 env_name_spec
+= gd
->reloc_off
;
595 #ifdef CONFIG_LOGBUFFER
596 logbuff_init_ptrs ();
599 post_output_backlog ();
605 #if defined(CONFIG_IP860) || defined(CONFIG_PCU_E) || defined (CONFIG_FLAGADM)
606 icache_enable (); /* it's time to enable the instruction cache */
609 #if defined(CONFIG_BAB7xx) || defined(CONFIG_CPC45)
611 * Do PCI configuration on BAB7xx and CPC45 _before_ the flash
612 * gets initialised, because we need the ISA resp. PCI_to_LOCAL bus
617 #if defined(CONFIG_BAB7xx)
619 * Initialise the ISA bridge
621 initialise_w83c553f ();
624 asm ("sync ; isync");
627 * Setup trap handlers
629 trap_init (dest_addr
);
631 #if !defined(CFG_NO_FLASH)
634 if ((flash_size
= flash_init ()) > 0) {
635 # ifdef CFG_FLASH_CHECKSUM
636 print_size (flash_size
, "");
638 * Compute and print flash CRC if flashchecksum is set to 'y'
640 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
642 s
= getenv ("flashchecksum");
643 if (s
&& (*s
== 'y')) {
644 printf (" CRC: %08lX",
646 (const unsigned char *) CFG_FLASH_BASE
,
651 # else /* !CFG_FLASH_CHECKSUM */
652 print_size (flash_size
, "\n");
653 # endif /* CFG_FLASH_CHECKSUM */
659 bd
->bi_flashstart
= CFG_FLASH_BASE
; /* update start of FLASH memory */
660 bd
->bi_flashsize
= flash_size
; /* size of FLASH memory (final value) */
661 # if defined(CONFIG_PCU_E) || defined(CONFIG_OXC)
662 bd
->bi_flashoffset
= 0;
663 # elif CFG_MONITOR_BASE == CFG_FLASH_BASE
664 bd
->bi_flashoffset
= monitor_flash_len
; /* reserved area for startup monitor */
666 bd
->bi_flashoffset
= 0;
668 #else /* CFG_NO_FLASH */
670 bd
->bi_flashsize
= 0;
671 bd
->bi_flashstart
= 0;
672 bd
->bi_flashoffset
= 0;
673 #endif /* !CFG_NO_FLASH */
677 /* initialize higher level parts of CPU like time base and timers */
682 /* initialize malloc() area */
687 # if !defined(CFG_ENV_IS_IN_EEPROM)
693 /* relocate environment function pointers etc. */
697 * Fill in missing fields of bd_info.
698 * We do this here, where we have "normal" access to the
699 * environment; we used to do this still running from ROM,
700 * where had to use getenv_r(), which can be pretty slow when
701 * the environment is in EEPROM.
703 s
= getenv ("ethaddr");
704 #if defined (CONFIG_MBX) || defined (CONFIG_RPXCLASSIC) || defined(CONFIG_IAD210)
706 board_get_enetaddr (bd
->bi_enetaddr
);
709 for (i
= 0; i
< 6; ++i
) {
710 bd
->bi_enetaddr
[i
] = s
? simple_strtoul (s
, &e
, 16) : 0;
712 s
= (*e
) ? e
+ 1 : e
;
715 if ((gd
->board_type
>> 16) == 2)
716 bd
->bi_ethspeed
= gd
->board_type
& 0xFFFF;
718 bd
->bi_ethspeed
= 0xFFFF;
722 load_sernum_ethaddr ();
725 #if defined(CFG_GT_6426x) || defined(CONFIG_PN62) || defined(CONFIG_PPCHAMELEONEVB)
726 /* handle the 2nd ethernet address */
728 s
= getenv ("eth1addr");
730 for (i
= 0; i
< 6; ++i
) {
731 bd
->bi_enet1addr
[i
] = s
? simple_strtoul (s
, &e
, 16) : 0;
733 s
= (*e
) ? e
+ 1 : e
;
736 #if defined(CFG_GT_6426x)
737 /* handle the 3rd ethernet address */
739 s
= getenv ("eth2addr");
741 for (i
= 0; i
< 6; ++i
) {
742 bd
->bi_enet2addr
[i
] = s
? simple_strtoul (s
, &e
, 16) : 0;
744 s
= (*e
) ? e
+ 1 : e
;
749 #if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
751 load_sernum_ethaddr ();
754 bd
->bi_ip_addr
= getenv_IPaddr ("ipaddr");
758 #if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx)
760 * Do pci configuration
765 /** leave this here (after malloc(), environment and PCI are working) **/
766 /* Initialize devices */
769 /* Initialize the jump table for applications */
772 /* Initialize the console (after the relocation and devices init) */
775 #if defined(CONFIG_CCM) || \
776 defined(CONFIG_COGENT) || \
777 defined(CONFIG_CPCI405) || \
778 defined(CONFIG_EVB64260) || \
779 defined(CONFIG_KUP4K) || \
780 defined(CONFIG_LWMON) || \
781 defined(CONFIG_PCU_E) || \
782 defined(CONFIG_W7O) || \
783 defined(CONFIG_MISC_INIT_R)
784 /* miscellaneous platform dependent initialisations */
789 if (bd
->bi_ethspeed
!= 0xFFFF)
790 hermes_start_lxt980 ((int) bd
->bi_ethspeed
);
793 #if (CONFIG_COMMANDS & CFG_CMD_NET) && ( \
794 defined(CONFIG_CCM) || \
795 defined(CONFIG_ELPT860) || \
796 defined(CONFIG_EP8260) || \
797 defined(CONFIG_IP860) || \
798 defined(CONFIG_IVML24) || \
799 defined(CONFIG_IVMS8) || \
800 defined(CONFIG_LWMON) || \
801 defined(CONFIG_MPC8260ADS) || \
802 defined(CONFIG_MPC8266ADS) || \
803 defined(CONFIG_PCU_E) || \
804 defined(CONFIG_RPXSUPER) || \
805 defined(CONFIG_SPD823TS) )
808 debug ("Reset Ethernet PHY\n");
812 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
818 debug ("U-Boot relocated to %08lx\n", dest_addr
);
825 /* Must happen after interrupts are initialized since
826 * an irq handler gets installed
828 #ifdef CONFIG_SERIAL_SOFTWARE_FIFO
829 serial_buffered_init();
832 #ifdef CONFIG_STATUS_LED
833 status_led_set (STATUS_LED_BOOT
, STATUS_LED_BLINKING
);
840 /* Insert function pointers now that we have relocated the code */
842 /* Initialize from environment */
843 if ((s
= getenv ("loadaddr")) != NULL
) {
844 load_addr
= simple_strtoul (s
, NULL
, 16);
846 #if (CONFIG_COMMANDS & CFG_CMD_NET)
847 if ((s
= getenv ("bootfile")) != NULL
) {
848 copy_filename (BootFile
, s
, sizeof (BootFile
));
850 #endif /* CFG_CMD_NET */
854 #if (CONFIG_COMMANDS & CFG_CMD_SCSI)
860 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
866 #if (CONFIG_COMMANDS & CFG_CMD_NAND)
869 nand_init(); /* go init the NAND */
872 #if (CONFIG_COMMANDS & CFG_CMD_NET) && defined(CONFIG_NET_MULTI)
879 post_run (NULL
, POST_RAM
| post_bootmode_get(0));
882 #if (CONFIG_COMMANDS & CFG_CMD_PCMCIA) && !(CONFIG_COMMANDS & CFG_CMD_IDE)
888 #if (CONFIG_COMMANDS & CFG_CMD_IDE)
890 # ifdef CONFIG_IDE_8xx_PCCARD
896 #endif /* CFG_CMD_IDE */
898 #ifdef CONFIG_LAST_STAGE_INIT
901 * Some parts can be only initialized if all others (like
902 * Interrupts) are up and running (i.e. the PC-style ISA
908 #if (CONFIG_COMMANDS & CFG_CMD_BEDBUG)
913 #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
915 * Export available size of memory for Linux,
916 * taking into account the protected RAM at top of memory
924 if ((s
= getenv ("pram")) != NULL
) {
925 pram
= simple_strtoul (s
, NULL
, 10);
932 #ifdef CONFIG_LOGBUFFER
933 /* Also take the logbuffer into account (pram is in kB) */
934 pram
+= (LOGBUFF_LEN
+LOGBUFF_OVERHEAD
)/1024;
936 sprintf (memsz
, "%ldk", (bd
->bi_memsize
/ 1024) - pram
);
937 setenv ("mem", memsz
);
941 #ifdef CONFIG_MODEM_SUPPORT
943 extern int do_mdm_init
;
944 do_mdm_init
= gd
->do_mdm_init
;
948 /* Initialization complete - start the monitor */
950 /* main_loop() can return to retry autoboot, if so just run it again. */
956 /* NOTREACHED - no way out of command loop except booting */
961 puts ("### ERROR ### Please RESET the board ###\n");
965 #ifdef CONFIG_MODEM_SUPPORT
966 /* called from main loop (common/main.c) */
967 extern void dbg(const char *fmt
, ...);
973 extern char console_buffer
[];
974 static inline void mdm_readline(char *buf
, int bufsiz
);
975 extern void enable_putc(void);
976 extern int hwflow_onoff(int);
978 enable_putc(); /* enable serial_putc() */
981 init_str
= getenv("mdm_flow_control");
982 if (init_str
&& (strcmp(init_str
, "rts/cts") == 0))
989 sprintf(env_str
, "mdm_init%d", i
);
990 if ((init_str
= getenv(env_str
)) != NULL
) {
991 serial_puts(init_str
);
994 mdm_readline(console_buffer
, CFG_CBSIZE
);
995 dbg("ini%d: [%s]", i
, console_buffer
);
997 if ((strcmp(console_buffer
, "OK") == 0) ||
998 (strcmp(console_buffer
, "ERROR") == 0)) {
999 dbg("ini%d: cmd done", i
);
1001 } else /* in case we are originating call ... */
1002 if (strncmp(console_buffer
, "CONNECT", 7) == 0) {
1003 dbg("ini%d: connect", i
);
1008 break; /* no init string - stop modem init */
1015 /* final stage - wait for connect */
1016 for(;i
> 1;) { /* if 'i' > 1 - wait for connection
1017 message from modem */
1018 mdm_readline(console_buffer
, CFG_CBSIZE
);
1019 dbg("ini_f: [%s]", console_buffer
);
1020 if (strncmp(console_buffer
, "CONNECT", 7) == 0) {
1021 dbg("ini_f: connected");
1029 /* 'inline' - We have to do it fast */
1030 static inline void mdm_readline(char *buf
, int bufsiz
)
1041 /* dbg("(%c)", c); */
1053 return; /* sanity check */
1063 #if 0 /* We could use plain global data, but the resulting code is bigger */
1065 * Pointer to initial global data area
1067 * Here we initialize it.
1069 #undef XTRN_DECLARE_GLOBAL_DATA_PTR
1070 #define XTRN_DECLARE_GLOBAL_DATA_PTR /* empty = allocate here */
1071 DECLARE_GLOBAL_DATA_PTR
= (gd_t
*) (CFG_INIT_RAM_ADDR
+ CFG_GBL_DATA_OFFSET
);
1074 /************************************************************************/