]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.S
ArmPlatformPkg: Introduce Primary core macros
[mirror_edk2.git] / ArmPlatformPkg / ArmVExpressPkg / Library / ArmVExpressLibCTA9x4 / CTA9x4Boot.S
CommitLineData
c52e2dca 1//\r
2// Copyright (c) 2011, ARM Limited. All rights reserved.\r
3//\r
4// This program and the accompanying materials\r
5// are licensed and made available under the terms and conditions of the BSD License\r
6// which accompanies this distribution. The full text of the license may be found at\r
7// http://opensource.org/licenses/bsd-license.php\r
8//\r
9// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11//\r
12//\r
13\r
14#include <AsmMacroIoLib.h>\r
15#include <Base.h>\r
16#include <Library/ArmPlatformLib.h>\r
17#include <Drivers/PL35xSmc.h>\r
18#include <ArmPlatform.h>\r
19#include <AutoGen.h>\r
20\r
21.text\r
22.align 3\r
23\r
24GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)\r
25GCC_ASM_IMPORT(PL35xSmcInitialize)\r
26\r
27//\r
28// For each Chip Select: ChipSelect / SetCycle / SetOpMode\r
29//\r
30VersatileExpressSmcConfiguration:\r
31 // NOR Flash 0\r
32 .word PL350_SMC_DIRECT_CMD_ADDR_CS(0)\r
3723a71a 33 .word PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) | PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) | PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) | PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) | PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
34 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_ADV\r
c52e2dca 35\r
36 // NOR Flash 1\r
37 .word PL350_SMC_DIRECT_CMD_ADDR_CS(4)\r
3723a71a 38 .word PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) | PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) | PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) | PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) | PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
39 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT | PL350_SMC_SET_OPMODE_SET_ADV\r
c52e2dca 40\r
41 // SRAM\r
42 .word PL350_SMC_DIRECT_CMD_ADDR_CS(2)\r
3723a71a 43 .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0x8) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x6) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
44 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_ADV\r
c52e2dca 45\r
46 // Usb/Eth/VRAM\r
47 .word PL350_SMC_DIRECT_CMD_ADDR_CS(3)\r
3723a71a 48 .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0xA) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0xA) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x3) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x6)\r
49 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
c52e2dca 50\r
51 // Memory Mapped Peripherals\r
52 .word PL350_SMC_DIRECT_CMD_ADDR_CS(7)\r
3723a71a 53 .word PL350_SMC_SET_CYCLE_SRAM_T_RC(0x6) | PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) | PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) | PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) | PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
54 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
c52e2dca 55\r
56 // VRAM\r
57 .word PL350_SMC_DIRECT_CMD_ADDR_CS(1)\r
58 .word 0x00049249\r
3723a71a 59 .word PL350_SMC_SET_OPMODE_MEM_WIDTH_32 | PL350_SMC_SET_OPMODE_SET_RD_SYNC | PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
c52e2dca 60VersatileExpressSmcConfigurationEnd:\r
61\r
62/**\r
63 Initialize the memory where the initial stacks will reside\r
64\r
65 This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
66 In some platform, this region is already initialized and the implementation of this function can\r
67 do nothing. This memory can also represent the Secure RAM.\r
68 This function is called before the satck has been set up. Its implementation must ensure the stack\r
69 pointer is not used (probably required to use assembly language)\r
70\r
71**/\r
72ASM_PFX(ArmPlatformInitializeBootMemory):\r
73 mov r5, lr\r
74\r
75 //\r
76 // Initialize PL354 SMC\r
77 //\r
78 LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)\r
1d36ec02 79 LoadConstantToReg (VersatileExpressSmcConfiguration, r2)\r
80 LoadConstantToReg (VersatileExpressSmcConfigurationEnd, r3)\r
c52e2dca 81 blx ASM_PFX(PL35xSmcInitialize)\r
82\r
83 //\r
84 // Page mode setup for VRAM\r
85 //\r
86 LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)\r
87\r
88 // Read current state\r
89 ldr r0, [r2, #0]\r
90 ldr r0, [r2, #0]\r
91 ldr r0, = 0x00000000\r
92 str r0, [r2, #0]\r
93 ldr r0, [r2, #0]\r
94\r
95 // Enable page mode\r
96 ldr r0, [r2, #0]\r
97 ldr r0, [r2, #0]\r
98 ldr r0, = 0x00000000\r
99 str r0, [r2, #0]\r
1d36ec02 100 LoadConstantToReg (0x00900090, r0)\r
c52e2dca 101 str r0, [r2, #0]\r
102\r
103 // Confirm page mode enabled\r
104 ldr r0, [r2, #0]\r
105 ldr r0, [r2, #0]\r
106 ldr r0, = 0x00000000\r
107 str r0, [r2, #0]\r
108 ldr r0, [r2, #0]\r
109\r
110 bx r5\r