Пример #1
0
void board_init_r(gd_t *gd, ulong dest_addr)
{
	/* Pointer is writable since we allocated a register for it */
	gd = (gd_t *)CONFIG_SPL_GD_ADDR;
	bd_t *bd;

	memset(gd, 0, sizeof(gd_t));
	bd = (bd_t *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
	memset(bd, 0, sizeof(bd_t));
	gd->bd = bd;
	bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
	bd->bi_memsize = CONFIG_SYS_L2_SIZE;

	probecpu();
	get_clocks();
	mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
			CONFIG_SPL_RELOC_MALLOC_SIZE);
#ifndef CONFIG_SPL_NAND_BOOT
	env_init();
#endif
#ifdef CONFIG_SPL_MMC_BOOT
	mmc_initialize(bd);
#endif
	/* relocate environment function pointers etc. */
#ifdef CONFIG_SPL_NAND_BOOT
	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
			    (uchar *)CONFIG_ENV_ADDR);

	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
	gd->env_valid = 1;
#else
	env_relocate();
#endif

#ifdef CONFIG_SYS_I2C
	i2c_init_all();
#else
	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
#endif

	gd->ram_size = initdram(0);
#ifdef CONFIG_SPL_NAND_BOOT
	puts("Tertiary program loader running in sram...");
#else
	puts("Second program loader running in sram...\n");
#endif

#ifdef CONFIG_SPL_MMC_BOOT
	mmc_boot();
#elif defined(CONFIG_SPL_SPI_BOOT)
	spi_boot();
#elif defined(CONFIG_SPL_NAND_BOOT)
	nand_boot();
#endif
}
int dram_init(void)
{
	/*
	 * When resuming from deep sleep, the I2C channel may not be
	 * in the default channel. So, switch to the default channel
	 * before accessing DDR SPD.
	 */
	select_i2c_ch_pca9547(I2C_MUX_CH_DEFAULT);
	gd->ram_size = initdram(0);

	return 0;
}
Пример #3
0
int dram_init (void)
{
	DECLARE_GLOBAL_DATA_PTR;
	unsigned int i;
#if defined(MV_INC_BOARD_DDIM)
	unsigned int dramTotalSize=0;
#endif
	MV_32 memBase;

#if defined(MV_INC_BOARD_DDIM)
	/* Call dramInit */
	if (0 == (dramTotalSize = initdram(0)))
	{
		printf("DRAM Initialization Failed\n");
		reset_cpu();
		return (1);
	}
#endif

	//mvIntrfaceParamPrint();

	for(i = 0; i< MV_DRAM_MAX_CS; i++)
	{
		MV_CPU_DEC_WIN addrDecWin;
		if((mvCpuIfTargetWinGet(SDRAM_CS0 + i, &addrDecWin) == MV_OK) &&
		   (addrDecWin.enable == MV_TRUE)){
			memBase = addrDecWin.addrWin.baseLow;
			gd->bd->bi_dram[i].start = memBase;
			gd->bd->bi_dram[i].size = addrDecWin.addrWin.size;
		}
		//dramTotalSize += gd->bd->bi_dram[i].size;
//		if (gd->bd->bi_dram[i].size)
//		{
			//printf("DRAM CS[%d] base 0x%08x   ",i, gd->bd->bi_dram[i].start);
			//mvSizePrint(gd->bd->bi_dram[i].size);
			//printf("\n");
//		}
	}
 
//	printf("DRAM Total ");
//	mvSizePrint(dramTotalSize);
//	mvIntrfaceWidthPrint();
//	printf("\n");

#ifdef MV_INC_DRAM_MFG_TEST
	mvDramMfgTrst();
#endif
        return 0;
}
Пример #4
0
static int init_func_ram(void)
{
#ifdef	CONFIG_BOARD_TYPES
	int board_type = gd->board_type;
#else
	int board_type = 0;	/* use dummy arg */
#endif

	gd->ram_size = initdram(board_type);

	if (gd->ram_size > 0)
		return 0;

	puts("*** failed ***\n");
	return 1;
}
Пример #5
0
static int init_func_ram(void)
{
#ifdef	CONFIG_BOARD_TYPES
	int board_type = gd->board_type;
#else
	int board_type = 0;	/* use dummy arg */
#endif
	puts("DRAM:  ");

	gd->ram_size = initdram(board_type);
	if (gd->ram_size > 0) {
		print_size(gd->ram_size, "\n");
		return 0;
	}
	puts(failed);
	return 1;
}
Пример #6
0
/*
 * SPL version of board_init_f()
 */
void board_init_f(ulong bootflag)
{
    /*
     * First we need to initialize the SDRAM, so that the real
     * U-Boot or the OS (Linux) can be loaded
     */
    initdram(0);

    /* Clear bss */
    memset(__bss_start, '\0', __bss_end - __bss_start);

    /*
     * Init global_data pointer. Has to be done before calling
     * get_clocks(), as it stores some clock values into gd needed
     * later on in the serial driver.
     */
    /* Pointer is writable since we allocated a register for it */
    gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
    /* Clear initial global data */
    memset((void *)gd, 0, sizeof(gd_t));

    /*
     * get_clocks() needs to be called so that the serial driver
     * works correctly
     */
    get_clocks();

    /*
     * Do rudimental console / serial setup
     */
    preloader_console_init();

    /*
     * Call board_init_r() (SPL framework version) to load and boot
     * real U-Boot or OS
     */
    board_init_r(NULL, 0);
    /* Does not return!!! */
}
Пример #7
0
void board_init_r(gd_t *gd, ulong dest_addr)
{
	/* Pointer is writable since we allocated a register for it */
	gd = (gd_t *)CONFIG_SPL_GD_ADDR;
	bd_t *bd;

	memset(gd, 0, sizeof(gd_t));
	bd = (bd_t *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
	memset(bd, 0, sizeof(bd_t));
	gd->bd = bd;
	bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
	bd->bi_memsize = CONFIG_SYS_L2_SIZE;

	arch_cpu_init();
	get_clocks();
	mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
			CONFIG_SPL_RELOC_MALLOC_SIZE);
	gd->flags |= GD_FLG_FULL_MALLOC_INIT;

	/* relocate environment function pointers etc. */
	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
			    (uchar *)CONFIG_ENV_ADDR);
	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
	gd->env_valid = 1;

	i2c_init_all();

	gd->ram_size = initdram(0);

#ifdef CONFIG_SPL_NAND_BOOT
	puts("TPL\n");
#else
	puts("SPL\n");
#endif

	nand_boot();
}
Пример #8
0
int dram_init(void)
{
	gd->ram_size = initdram(0);

	return 0;
}
Пример #9
0
void board_init_f(ulong board_type)
{
	gd_t gd_data;
	gd_t *new_gd;
	bd_t *bd;
	unsigned long *new_sp;
	unsigned long monitor_len;
	unsigned long monitor_addr;
	unsigned long addr;
	long sdram_size;

	/* Initialize the global data pointer */
	memset(&gd_data, 0, sizeof(gd_data));
	gd = &gd_data;

	/* Perform initialization sequence */
	board_early_init_f();
	cpu_init();
	board_postclk_init();
	env_init();
	init_baudrate();
	serial_init();
	console_init_f();
	display_banner();
	sdram_size = initdram(board_type);

	/* If we have no SDRAM, we can't go on */
	if (sdram_size <= 0)
		panic("No working SDRAM available\n");

	/*
	 * Now that we have DRAM mapped and working, we can
	 * relocate the code and continue running from DRAM.
	 *
	 * Reserve memory at end of RAM for (top down in that order):
	 *  - u-boot image
	 *  - heap for malloc()
	 *  - board info struct
	 *  - global data struct
	 *  - stack
	 */
	addr = CONFIG_SYS_SDRAM_BASE + sdram_size;
	monitor_len = __bss_end__ - _text;

	/*
	 * Reserve memory for u-boot code, data and bss.
	 * Round down to next 4 kB limit.
	 */
	addr -= monitor_len;
	addr &= ~(4096UL - 1);
	monitor_addr = addr;

	/* Reserve memory for malloc() */
	addr -= CONFIG_SYS_MALLOC_LEN;

#ifdef CONFIG_SYS_DMA_ALLOC_LEN
	/* Reserve DMA memory (must be cache aligned) */
	addr &= ~(CONFIG_SYS_DCACHE_LINESZ - 1);
	addr -= CONFIG_SYS_DMA_ALLOC_LEN;
#endif

#ifdef CONFIG_LCD
#ifdef CONFIG_FB_ADDR
	printf("LCD: Frame buffer allocated at preset 0x%08x\n",
	       CONFIG_FB_ADDR);
	gd->fb_base = (void *)CONFIG_FB_ADDR;
#else
	addr = lcd_setmem(addr);
	printf("LCD: Frame buffer allocated at 0x%08lx\n", addr);
	gd->fb_base = (void *)addr;
#endif /* CONFIG_FB_ADDR */
#endif /* CONFIG_LCD */

	/* Allocate a Board Info struct on a word boundary */
	addr -= sizeof(bd_t);
	addr &= ~3UL;
	gd->bd = bd = (bd_t *)addr;

	/* Allocate a new global data copy on a 8-byte boundary. */
	addr -= sizeof(gd_t);
	addr &= ~7UL;
	new_gd = (gd_t *)addr;

	/* And finally, a new, bigger stack. */
	new_sp = (unsigned long *)addr;
	gd->stack_end = addr;
	*(--new_sp) = 0;
	*(--new_sp) = 0;

	/*
	 * Initialize the board information struct with the
	 * information we have.
	 */
	bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
	bd->bi_dram[0].size = sdram_size;
	bd->bi_baudrate = gd->baudrate;

	memcpy(new_gd, gd, sizeof(gd_t));

	relocate_code((unsigned long)new_sp, new_gd, monitor_addr);
}
/*
 * USB boot routine
 *
 * Desc: usb boot.
 * Retn: 0 for success, -1 for error.
 */
int usb_boot(unsigned zero, unsigned type, unsigned tags)
{
#ifdef DEBUG
	serial_puts_info("Usb_boot:  In function of usb_boot ...\n");
#endif
	/* see all of files in android-1.5r2/bootable/bootloader/legacy/usbloader */
	unsigned long ram_size;
	unsigned long addr;

	 USB_STATUS status = {NULL, {0, 0}, 0, 0, 0};
         int usb_last_stat;

	/* must do this before board_init() so that we
        ** use the partition table in the tags if it 
        ** already exists 
        */
	linux_type = board_machtype();
	linux_tags = 0;
#ifdef DEBUG	
	serial_puts_info("Usb_boot:  Board init ...\n");
#endif
	board_init();
	ram_size = initdram(0);
/*test*/
    if (ram_size > EMC_LOW_SDRAM_SPACE_SIZE)
                ram_size = EMC_LOW_SDRAM_SPACE_SIZE;
/*test*/
	addr = CFG_SDRAM_BASE + ram_size;

	/* We can reserve some RAM "on top" here. */
	/* round down to next 4 kB limit. */
	addr &= ~(4096 - 1);
#ifdef DEBUG
	serial_puts_info("Usb_boot:  Lcd_setmem ...\n");
#endif
	addr = lcd_setmem(addr);
	fb_base = addr;
#ifdef DEBUG
	serial_puts_info("Usb_boot:  Drv_lcd_init ...\n");
#endif
	drv_lcd_init();
	lcd_console_init();
	
#if 0
	memset(print_buf, 0, PRINT_BUF_MAX);
	strcpy(print_buf, "123456:USB FastBoot:bbb");
	lcd_puts(print_buf);
	memset(print_buf, 0, PRINT_BUF_MAX);
	cprintf(print_buf, ":ABC%dEFG:a\rabc",3);
	lcd_puts(print_buf);
#endif

#if 1
	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "USB FastBoot:  V %s\n", FAST_BOOT_VERSION);
	lcd_puts(print_buf);

	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "Machine ID:    %d v %d\n", linux_type, revision);
	lcd_puts(print_buf);
	
	memset(print_buf, '\0', PRINT_BUF_MAX);
	cprintf(print_buf, "Build Date:    "__DATE__", "__TIME__"\n");
	lcd_puts(print_buf);

	/* memset(print_buf, '\0', PRINT_BUF_MAX); */
	/* cprintf(print_buf, "Serial Number: %s\n", "UNKNOWN"); */
	/* lcd_puts(print_buf); */
#endif

#if 1
	serial_puts_msg("\nUSB FastBoot: V ");
	serial_puts_msg(FAST_BOOT_VERSION);
	serial_puts_msg(" \n");

	serial_puts_msg("Machine ID: ");
	dump_uint(linux_type);
	serial_puts_msg("  v ");
	dump_uint(revision);
	serial_puts_msg(" \n");

	serial_puts_msg("Build Date: ");
	serial_puts_msg(__DATE__);
	serial_puts_msg("  ");
	serial_puts_msg(__TIME__);
	serial_puts_msg("\n");
	
	serial_puts_msg("Serial Number: ");
	if (serialno[0])
		serial_puts_msg(serialno);
	else
		serial_puts_msg("UNKNOWN\n");
#endif
	flash_dump_ptn();
	jz4780_usbloader_init();
        usb_last_stat = 1;

	for(;;) {
            /* if(__usb_detected()) { */
            /*     if(usb_last_stat == 0) { */
            /*         serial_puts("USB status:   ONLINE\n"); */
            /*         memset(print_buf, 0, PRINT_BUF_MAX); */
            /*         cprintf(print_buf, "\rUSB status:   ONLINE"); */
            /*         lcd_puts(print_buf); */
            /*     } */
            /*     usb_last_stat = 1; */
            /* } else { */
            /*     if(usb_last_stat == 1) { */
            /*         serial_puts("USB status:   OFFLINE\n"); */
            /*         memset(print_buf, 0, PRINT_BUF_MAX); */
            /*         cprintf(print_buf, "\rUSB status:  OFFLINE"); */
            /*         lcd_puts(print_buf); */
            /*     } */
            /*     usb_last_stat = 0; */
            /* } */
            jz4780_usb_poll(&status);
	}
	
	return 0;
}