1 #include <asm/arch/sci_types.h>
3 #include <asm/arch/cmd_def.h>
4 #include <asm/arch/packet.h>
5 #include <asm/arch/dl_engine.h>
6 #include <asm/arch/sio_drv.h>
7 #include "mcu_command.h"
8 #include <asm/arch/usb_boot.h>
9 #include <asm/arch/dma_drv_fdl.h>
10 #include <asm/arch/sc_reg.h>
12 #include "fdl_cmd_proc.h"
15 extern const unsigned char FDL2_signature[][24];
16 extern int sprd_clean_rtc(void);
18 static void fdl_error(void)
20 //sio_putstr("The second FDL failed!\r\n");
21 for (;;) /*Do nothing*/;
24 * Avoid const string comment out by -O2 opt level of compiler
26 const unsigned char **FDL2_GetSig (void)
28 return (const unsigned char **) FDL2_signature;
30 extern unsigned long _bss_end;
32 extern unsigned long _bss_start;
34 static int bss_end_end;
35 static int bss_start_start;
36 char mempool[1024*1024] = {0};
38 extern void sprdbat_get_vbatauxadc_caldata (void);
39 extern uint32_t sprdbat_get_vbatauxadc_caltype(void);
40 extern int DCDC_Cal_ArmCore(void);
44 /* All hardware initialization has been done in the 1st FDL,
45 * so we don't do initialization stuff here.
46 * The UART has also been opened by the 1st FDL and the baudrate
47 * has been setted correctly.
50 uint32 sigture_address;
53 printf("fdl main \n");
56 sigture_address = (uint32)FDL2_signature;
58 #if defined(CHIP_ENDIAN_DEFAULT_LITTLE) && defined(CHIP_ENDIAN_BIG)
65 bss_start_start = _bss_start;
66 bss_end_end = _bss_end;
67 mem_malloc_init (&mempool[0], 1024*1024);
69 mem_malloc_init (_bss_end, CONFIG_SYS_MALLOC_LEN);
72 #if defined (CONFIG_SC8830) || defined(CONFIG_SC9630)
73 /* add calibration in fdl-2 */
74 sprdbat_get_vbatauxadc_caldata();
75 if (sprdbat_get_vbatauxadc_caltype() != 0)
84 #ifdef CONFIG_EMMC_BOOT
85 /* Initialize eMMC. */
86 extern int mmc_legacy_init(int dev);
95 #ifdef FPGA_TRACE_DOWNLOAD
102 /* Register command handler */
104 FDL_DlReg(BSL_CMD_START_DATA, FDL2_Download_Start, 0);
105 FDL_DlReg(BSL_CMD_MIDST_DATA, FDL2_Download_Midst, 0);
106 FDL_DlReg(BSL_CMD_END_DATA, FDL2_Download_End, 0);
107 FDL_DlReg(BSL_CMD_READ_FLASH_START, FDL2_Read_Start, 0);
108 FDL_DlReg(BSL_CMD_READ_FLASH_MIDST, FDL2_Read_Midst, 0);
109 FDL_DlReg(BSL_CMD_READ_FLASH_END, FDL2_Read_End, 0);
110 FDL_DlReg(BSL_ERASE_FLASH, FDL2_Erase, 0);
111 FDL_DlReg(BSL_REPARTITION, FDL2_Repartition, 0);
112 FDL_DlReg(BSL_CMD_NORMAL_RESET, FDL_McuResetNormal/*mcu_reset_boot*/, 0);
113 FDL_DlReg(BSL_CMD_READ_CHIP_TYPE, FDL_McuReadChipType, 0);
114 FDL_DlReg(BSL_CMD_READ_MCP_TYPE, FDL_McuReadMcpType, 0);
115 //Send BSL_INCOMPATIBLE_PARTITION because of FDL2 will know nothing about new partition
116 FDL_SendAckPacket (BSL_INCOMPATIBLE_PARTITION);
118 /* Start the download process. */
119 FDL_DlEntry (DL_STAGE_CONNECTED);
123 /* If we get here, there must be something wrong. */