Exemplo n.º 1
0
/* do some early init */
void s_init(void)
{
	int in_sdram = 0;
#ifdef CONFIG_SPL
		in_sdram = is_running_in_sdram();
#endif
	watchdog_init();
	sw_gpio_init();
	clock_init();
	gpio_init();
#ifdef CONFIG_SPL
	if (!in_sdram)
		sdram_init();
#endif
}
Exemplo n.º 2
0
void board_init_r(gd_t *id, ulong dest_addr)
{
	char *s;
	bd_t *bd;
	ulong malloc_start;
#if !defined(CONFIG_SYS_NO_FLASH)
	ulong flash_size;
#endif

	gd = id;
	bd = gd->bd;

	gd->flags |= GD_FLG_RELOC;	/* tell others: relocation done */

	monitor_flash_len = _end_ofs;

	/* Enable caches */
	enable_caches();

//	debug("monitor flash len: %08lX\n", monitor_flash_len);
#ifdef CONFIG_ALLWINNER
#ifdef DEBUG
//	printf("sunxi script init\n");
#endif
	sw_gpio_init();
	if(script_parser_fetch("target", "storage_type", &storage_type, sizeof(int)))
		storage_type = 0;
	if((storage_type <= 0) || (storage_type > 2))
	{
		int used;

		used = 1;
		script_parser_patch("nand_para", "nand_used", &used, 1);
		used = 0;
		script_parser_patch("mmc2_para", "sdc_used", &used, 1);
		storage_type = 0;
	}
	else if(1 == storage_type)
	{
		mmc_card_no = 0;
	}
	else
	{
		int used;

		used = 0;
		script_parser_patch("nand_para", "nand_used", &used, 1);
		used = 1;
		script_parser_patch("mmc2_para", "sdc_used", &used, 1);

		mmc_card_no = 2;
	}
#ifdef DEBUG
	{
		int used;

		printf("test storage_type=%d, mmc_card_no=%d\n", storage_type, mmc_card_no);
		if(!script_parser_fetch("nand_para", "nand_used", &used, sizeof(int)))
		{
			printf("nand_para nand_used = %d\n", used);
		}
		if(!script_parser_fetch("mmc2_para", "sdc_used", &used, sizeof(int)))
		{
			printf("mmc2_para sdc_used = %d\n", used);
		}
		printf("test over\n");
	}
#endif	
	if(script_parser_fetch("uart_para", "uart_debug_port", &uart_console, sizeof(int)))
		uart_console = 0;
#endif
	board_init();	/* Setup chipselects */

#ifdef CONFIG_SERIAL_MULTI
	serial_initialize();
#endif

	debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr);

#ifdef CONFIG_LOGBUFFER
	logbuff_init_ptrs();
#endif
#ifdef CONFIG_POST
	post_output_backlog();
#endif

	/* The Malloc area is immediately below the monitor copy in DRAM */
	malloc_start = dest_addr - TOTAL_MALLOC_LEN;
	mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN);

#if !defined(CONFIG_SYS_NO_FLASH)
	puts("Flash: ");

	flash_size = flash_init();
	if (flash_size > 0) {
# ifdef CONFIG_SYS_FLASH_CHECKSUM
		print_size(flash_size, "");
		/*
		 * Compute and print flash CRC if flashchecksum is set to 'y'
		 *
		 * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
		 */
		s = getenv("flashchecksum");
		if (s && (*s == 'y')) {
			printf("  CRC: %08X", crc32(0,
				(const unsigned char *) CONFIG_SYS_FLASH_BASE,
				flash_size));
		}
		putc('\n');
# else	/* !CONFIG_SYS_FLASH_CHECKSUM */
		print_size(flash_size, "\n");
# endif /* CONFIG_SYS_FLASH_CHECKSUM */
	} else {
		puts(failed);
		hang();
	}
#endif

#ifdef CONFIG_ALLWINNER
	if(!storage_type){
		puts("NAND:  ");
		nand_init();		/* go init the NAND */
	}
	else{
		puts("MMC:   ");
        mmc_initialize(bd);
	}
	sunxi_flash_handle_init();
	sunxi_partition_init();
#else
#if defined(CONFIG_CMD_NAND)
	if(!storage_type){
		puts("NAND:  ");
		nand_init();        /* go init the NAND */
	}
#endif/*CONFIG_CMD_NAND*/


#if defined(CONFIG_GENERIC_MMC)
	if(storage_type){
		puts("MMC:   ");
		mmc_initialize(bd);
	}
#endif/*CONFIG_GENERIC_MMC*/
#endif/*CONFIG_ALLWINNER*/


#if defined(CONFIG_CMD_ONENAND)
	onenand_init();
#endif

#ifdef CONFIG_HAS_DATAFLASH
	AT91F_DataflashInit();
	dataflash_print_info();
#endif

	/* initialize environment */
	env_relocate();

#if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
	arm_pci_init();
#endif

	/* IP Address */
	gd->bd->bi_ip_addr = getenv_IPaddr("ipaddr");

	stdio_init();	/* get the devices list going. */

	jumptable_init();

#if defined(CONFIG_API)
	/* Initialize API */
	api_init();
#endif

	console_init_r();	/* fully init console as a device */

#if defined(CONFIG_ARCH_MISC_INIT)
	/* miscellaneous arch dependent initialisations */
	arch_misc_init();
#endif
#if defined(CONFIG_MISC_INIT_R)
	/* miscellaneous platform dependent initialisations */
	misc_init_r();
#endif

	 /* set up exceptions */
	interrupt_init();
	/* enable exceptions */
	enable_interrupts();

	/* Perform network card initialisation if necessary */
#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
	/* XXX: this needs to be moved to board init */
	if (getenv("ethaddr")) {
		uchar enetaddr[6];
		eth_getenv_enetaddr("ethaddr", enetaddr);
		smc_set_mac_addr(enetaddr);
	}
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */

	/* Initialize from environment */
	s = getenv("loadaddr");
	if (s != NULL)
		load_addr = simple_strtoul(s, NULL, 16);
#if defined(CONFIG_CMD_NET)
	s = getenv("bootfile");
	if (s != NULL)
		copy_filename(BootFile, s, sizeof(BootFile));
#endif

#ifdef BOARD_LATE_INIT
	board_late_init();
#endif

#ifdef CONFIG_BITBANGMII
	bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
	puts("Net:   ");
#endif
	eth_initialize(gd->bd);
#if defined(CONFIG_RESET_PHY_R)
	debug("Reset Ethernet PHY\n");
	reset_phy();
#endif
#endif

#ifdef CONFIG_POST
	post_run(NULL, POST_RAM | post_bootmode_get(0));
#endif

#if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER)
	/*
	 * Export available size of memory for Linux,
	 * taking into account the protected RAM at top of memory
	 */
	{
		ulong pram;
		uchar memsz[32];
#ifdef CONFIG_PRAM
		char *s;

		s = getenv("pram");
		if (s != NULL)
			pram = simple_strtoul(s, NULL, 10);
		else
			pram = CONFIG_PRAM;
#else
		pram = 0;
#endif
#ifdef CONFIG_LOGBUFFER
#ifndef CONFIG_ALT_LB_ADDR
		/* Also take the logbuffer into account (pram is in kB) */
		pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
#endif
#endif
		sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram);
		setenv("mem", (char *)memsz);
	}
#endif

	/* main_loop() can return to retry autoboot, if so just run it again. */
	for (;;) {
		main_loop();
	}

	/* NOTREACHED - no way out of command loop except booting */
}