#include <linux/types.h>
#include <dma.h>
#include <config.h>

void fast_copy(void)
{
	u32 len, dest_addr, src_addr;

#ifdef CONFIG_TARGET_ASIC
#if ((defined CONFIG_RTS_NOR_BOOT) || (defined CONFIG_FLASH_START))
	/*set baud rate , dramc clock/(4*2) */
	REG32(SPIC_VA + SPIC_BAUDR) = 0x04;

	/*set dual_o  read command*/
	REG32(SPIC_VA + SPIC_READ_DUAL_DATA) = 0x3b;

	/*set dual_o read dummy to : baud *2 * dummy+ 5 */
	REG32(SPIC_VA + SPIC_AUTO_LENGTH) = 0x28030045;

	/*set dual_o auto read valid*/
	REG32(SPIC_VA + SPIC_VALID_CMD) = 0x202;
#endif

#ifdef CONFIG_RTS_NAND_BOOT
	/*set baud rate*/
	REG32(SNFC_BAUDR) = 8;

	/*set auto length*/
	REG32(SNFC_AUTO_LENGTH) = 0x8c;
#endif
#endif

	dest_addr = CONFIG_LOAD_BASE;
	src_addr = CONFIG_SYS_FLASH_BASE + CONFIG_RAM_OFFSET;
	len = CONFIG_RAM_SIZE;


	if (len % 8)
		len = (len / 8) * 8 + 8;
	else
		len = len;


	dma_copy((src_addr & 0x1FFFFFFF), (dest_addr & 0x7FFFFFFF), len);

#ifdef CONFIG_TARGET_ASIC
#if ((defined CONFIG_RTS_NOR_BOOT) || (defined CONFIG_FLASH_START))
	REG32(SPIC_VA + SPIC_BAUDR) = 0x08;
#endif
#endif
}
