rtt-f030/bsp/imxrt1052-evk/sdram_mpu_init.ini

237 lines
7.5 KiB
INI
Raw Normal View History

2017-10-26 15:39:32 +08:00
FUNC void SDRAM_WaitIpCmdDone(void)
{
unsigned long reg;
do
{
reg = _RDWORD(0x402F003C);
}while((reg & 0x3) == 0);
}
FUNC void _clock_init(void)
{
// Enable all clocks
_WDWORD(0x400FC068, 0xffffffff);
_WDWORD(0x400FC06C, 0xffffffff);
_WDWORD(0x400FC070, 0xffffffff);
_WDWORD(0x400FC074, 0xffffffff);
_WDWORD(0x400FC078, 0xffffffff);
_WDWORD(0x400FC07C, 0xffffffff);
_WDWORD(0x400FC080, 0xffffffff);
_WDWORD(0x400D8030, 0x00002001);
_WDWORD(0x400D8100, 0x00100000);
_WDWORD(0x400FC014, 0x00050D40);
}
FUNC void _sdr_Init(void)
{
// Config IOMUX
_WDWORD(0x401F8014, 0x00000000);
_WDWORD(0x401F8018, 0x00000000);
_WDWORD(0x401F801C, 0x00000000);
_WDWORD(0x401F8020, 0x00000000);
_WDWORD(0x401F8024, 0x00000000);
_WDWORD(0x401F8028, 0x00000000);
_WDWORD(0x401F802C, 0x00000000);
_WDWORD(0x401F8030, 0x00000000);
_WDWORD(0x401F8034, 0x00000000);
_WDWORD(0x401F8038, 0x00000000);
_WDWORD(0x401F803C, 0x00000000);
_WDWORD(0x401F8040, 0x00000000);
_WDWORD(0x401F8044, 0x00000000);
_WDWORD(0x401F8048, 0x00000000);
_WDWORD(0x401F804C, 0x00000000);
_WDWORD(0x401F8050, 0x00000000);
_WDWORD(0x401F8054, 0x00000000);
_WDWORD(0x401F8058, 0x00000000);
_WDWORD(0x401F805C, 0x00000000);
_WDWORD(0x401F8060, 0x00000000);
_WDWORD(0x401F8064, 0x00000000);
_WDWORD(0x401F8068, 0x00000000);
_WDWORD(0x401F806C, 0x00000000);
_WDWORD(0x401F8070, 0x00000000);
_WDWORD(0x401F8074, 0x00000000);
_WDWORD(0x401F8078, 0x00000000);
_WDWORD(0x401F807C, 0x00000000);
_WDWORD(0x401F8080, 0x00000000);
_WDWORD(0x401F8084, 0x00000000);
_WDWORD(0x401F8088, 0x00000000);
_WDWORD(0x401F808C, 0x00000000);
_WDWORD(0x401F8090, 0x00000000);
_WDWORD(0x401F8094, 0x00000000);
_WDWORD(0x401F8098, 0x00000000);
_WDWORD(0x401F809C, 0x00000000);
_WDWORD(0x401F80A0, 0x00000000);
_WDWORD(0x401F80A4, 0x00000000);
_WDWORD(0x401F80A8, 0x00000000);
_WDWORD(0x401F80AC, 0x00000000);
_WDWORD(0x401F80B0, 0x00000000);
_WDWORD(0x401F80B4, 0x00000000);
_WDWORD(0x401F80B8, 0x00000000);
// PAD ctrl
_WDWORD(0x401F8204, 0x000000F1);
_WDWORD(0x401F8208, 0x000000F1);
_WDWORD(0x401F820C, 0x000000F1);
_WDWORD(0x401F8210, 0x000000F1);
_WDWORD(0x401F8214, 0x000000F1);
_WDWORD(0x401F8218, 0x000000F1);
_WDWORD(0x401F821C, 0x000000F1);
_WDWORD(0x401F8220, 0x000000F1);
_WDWORD(0x401F8224, 0x000000F1);
_WDWORD(0x401F8228, 0x000000F1);
_WDWORD(0x401F822C, 0x000000F1);
_WDWORD(0x401F8230, 0x000000F1);
_WDWORD(0x401F8234, 0x000000F1);
_WDWORD(0x401F8238, 0x000000F1);
_WDWORD(0x401F823C, 0x000000F1);
_WDWORD(0x401F8240, 0x000000F1);
_WDWORD(0x401F8244, 0x000000F1);
_WDWORD(0x401F8248, 0x000000F1);
_WDWORD(0x401F824C, 0x000000F1);
_WDWORD(0x401F8250, 0x000000F1);
_WDWORD(0x401F8254, 0x000000F1);
_WDWORD(0x401F8258, 0x000000F1);
_WDWORD(0x401F825C, 0x000000F1);
_WDWORD(0x401F8260, 0x000000F1);
_WDWORD(0x401F8264, 0x000000F1);
_WDWORD(0x401F8268, 0x000000F1);
_WDWORD(0x401F826C, 0x000000F1);
_WDWORD(0x401F8270, 0x000000F1);
_WDWORD(0x401F8274, 0x000000F1);
_WDWORD(0x401F8278, 0x000000F1);
_WDWORD(0x401F827C, 0x000000F1);
_WDWORD(0x401F8280, 0x000000F1);
_WDWORD(0x401F8284, 0x000000F1);
_WDWORD(0x401F8288, 0x000000F1);
_WDWORD(0x401F828C, 0x000000F1);
_WDWORD(0x401F8290, 0x000000F1);
_WDWORD(0x401F8294, 0x000000F1);
_WDWORD(0x401F8298, 0x000000F1);
_WDWORD(0x401F829C, 0x000000F1);
_WDWORD(0x401F82A0, 0x000000F1);
_WDWORD(0x401F82A4, 0x000000F1);
_WDWORD(0x401F82A8, 0x000000F1);
_WDWORD(0x402F0000, 0x1000E000);
_WDWORD(0x402F0008, 0x00030524);
_WDWORD(0x402F000C, 0x06030524);
_WDWORD(0x402F0010, 0x8000001B);
_WDWORD(0x402F0014, 0x90000021);
_WDWORD(0x402F0004, 0x00000008);
_WDWORD(0x402F0040, 0x00000B27);
_WDWORD(0x402F0044, 0x00100100);
_WDWORD(0x402F0048, 0x00020201);
_WDWORD(0x402F004C, 0x08193D0E);
_WDWORD(0x402F0080, 0x00000021);
_WDWORD(0x402F0084, 0x00888888);
_WDWORD(0x402F0094, 0x00000002);
_WDWORD(0x402F0098, 0x00000000);
_WDWORD(0x402F0090, 0x80000000);
_WDWORD(0x402F009C, 0xA55A000F);
SDRAM_WaitIpCmdDone();
_WDWORD(0x402F0090, 0x80000000);
_WDWORD(0x402F009C, 0xA55A000C);
SDRAM_WaitIpCmdDone();
_WDWORD(0x402F0090, 0x80000000);
_WDWORD(0x402F009C, 0xA55A000C);
SDRAM_WaitIpCmdDone();
_WDWORD(0x402F00A0, 0x00000022);
_WDWORD(0x402F0090, 0x80000000);
_WDWORD(0x402F009C, 0xA55A000A);
SDRAM_WaitIpCmdDone();
}
FUNC void _mpu_Init()
{
unsigned long rbar0, rbar1, rbar2, rbar3, rbar4, rbar5, rbar6;
unsigned long rasr0, rasr1, rasr2, rasr3, rasr4, rasr5, rasr6;
unsigned long ctrl;
rbar0 = ((0xC0000000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (0U << 0U));
rbar1 = ((0x80000000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (1U << 0U));
rbar2 = ((0x60000000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (2U << 0U));
rbar3 = ((0x10000000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (3U << 0U));
rbar4 = ((0x08000000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (4U << 0U));
rbar5 = ((0x80000000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (5U << 0U));
rbar6 = ((0x81E00000U & ((0x7FFFFFFUL << 5U))) | (1UL << 4U) | (6U << 0U));
rasr0 = (0x3U << 24U) | (2UL << 19U) | (0xC0U << 8U) | (28U << 1U) | (1U << 0U);
rasr1 = (0x3U << 24U) | (2UL << 19U) | (0xC0U << 8U) | (29U << 1U) | (1U << 0U);
rasr2 = (0x3U << 24U) | (2UL << 19U) | (0xC0U << 8U) | (28U << 1U) | (1U << 0U);
rasr3 = (0x3U << 24U) | (2UL << 19U) | (0xC0U << 8U) | (27U << 1U) | (1U << 0U);
rasr4 = (0x3U << 24U) | (2UL << 19U) | (0xC0U << 8U) | (26U << 1U) | (1U << 0U);
rasr5 = (0x3U << 24U) | (3UL << 16U) | (0xC0U << 8U) | (25U << 1U) | (1U << 0U);
rasr6 = (0x3U << 24U) | (1UL << 19U) | (0xC0U << 8U) | (20U << 1U) | (1U << 0U);
/* Enable Privileged default memory map and the MPU. */
ctrl = (0x1U << 0) | (1U << 2U);
/* MPU_CTRL. */
_WDWORD(0xE000ED94, 0x0);
/* MPU_RBAR. */
_WDWORD(0xE000ED9C, rbar6);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr6);
/* MPU_RBAR. */
_WDWORD(0xE000ED9C, rbar5);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr5);
_WDWORD(0xE000ED9C, rbar4);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr4);
_WDWORD(0xE000ED9C, rbar3);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr3);
/* MPU_RBAR. */
_WDWORD(0xE000ED9C, rbar2);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr2);
_WDWORD(0xE000ED9C, rbar1);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr1);
_WDWORD(0xE000ED9C, rbar0);
/* MPU_RASR. */
_WDWORD(0xE000EDA0, rasr0);
/* MPU_CTRL. */
_WDWORD(0xE000ED94, ctrl);
}
FUNC void _flexram_init(void)
{
_WDWORD(0x400AC040, 0x80000000); //IOMUXC_GPR_GPR16
//_WDWORD(0x400AC044, 0xFFFFAA55); //IOMUXC_GPR_GPR17
_WDWORD(0x400AC044, 0xFFFFFFFF); //IOMUXC_GPR_GPR17
_WDWORD(0x400AC038, 0x00890000); //IOMUXC_GPR_GPR14
_WDWORD(0x400AC040, 0x80000007); //IOMUXC_GPR_GPR16
}
FUNC void Setup (void) {
_clock_init();
//_flexram_init();
_sdr_Init();
_mpu_Init();
SP = _RDWORD(0x00000000); // Setup Stack Pointer
PC = _RDWORD(0x00000004); // Setup Program Counter
_WDWORD(0xE000ED08, 0x00000000); // Setup Vector Table Offset Register
}
FUNC void OnResetExec (void) { // executes upon software RESET
Setup(); // Setup for Running
}
LOAD %L INCREMENTAL // Download
Setup(); // Setup for Running
// g, main