]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PL35xSmc: Clean SMC driver to replace hardcoded Chip Select into the...
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Jul 2011 16:33:22 +0000 (16:33 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 1 Jul 2011 16:33:22 +0000 (16:33 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11959 6f19259b-4bc3-4df7-8a09-765794883524

14 files changed:
ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbBoot.S [new file with mode: 0755]
ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbBoot.asm [new file with mode: 0755]
ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.S
ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbHelper.asm
ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbSecLib.inf
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressLib.inf
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/ArmVExpressSecLib.inf
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.S [new file with mode: 0755]
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.asm [new file with mode: 0755]
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.S
ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Helper.asm
ArmPlatformPkg/Drivers/PL35xSmc/InitializeSMC.S
ArmPlatformPkg/Drivers/PL35xSmc/InitializeSMC.asm
ArmPlatformPkg/Include/Drivers/PL35xSmc.h

diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbBoot.S b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbBoot.S
new file mode 100755 (executable)
index 0000000..037efd9
--- /dev/null
@@ -0,0 +1,37 @@
+//\r
+//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+//\r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+//\r
+\r
+#include <AsmMacroIoLib.h>\r
+#include <Base.h>\r
+#include <Library/ArmPlatformLib.h>\r
+#include <ArmPlatform.h>\r
+#include <AutoGen.h>\r
+\r
+.text\r
+.align 3\r
+\r
+GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)\r
+\r
+/**\r
+  Initialize the memory where the initial stacks will reside\r
+\r
+  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
+  In some platform, this region is already initialized and the implementation of this function can\r
+  do nothing. This memory can also represent the Secure RAM.\r
+  This function is called before the satck has been set up. Its implementation must ensure the stack\r
+  pointer is not used (probably required to use assembly language)\r
+\r
+**/\r
+ASM_PFX(ArmPlatformInitializeBootMemory):\r
+  // The SMC does not need to be initialized for RTSM\r
+  bx    lr\r
diff --git a/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbBoot.asm b/ArmPlatformPkg/ArmRealViewEbPkg/Library/ArmRealViewEbLibRTSM/ArmRealViewEbBoot.asm
new file mode 100755 (executable)
index 0000000..272a05a
--- /dev/null
@@ -0,0 +1,39 @@
+//\r
+//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+//\r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+//\r
+\r
+#include <AsmMacroIoLib.h>\r
+#include <Base.h>\r
+#include <Library/ArmPlatformLib.h>\r
+#include <ArmPlatform.h>\r
+#include <AutoGen.h>\r
+\r
+  INCLUDE AsmMacroIoLib.inc\r
+\r
+  EXPORT  ArmPlatformInitializeBootMemory\r
+\r
+  PRESERVE8\r
+  AREA    CTA9x4BootMode, CODE, READONLY\r
+\r
+/**\r
+  Initialize the memory where the initial stacks will reside\r
+\r
+  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
+  In some platform, this region is already initialized and the implementation of this function can\r
+  do nothing. This memory can also represent the Secure RAM.\r
+  This function is called before the satck has been set up. Its implementation must ensure the stack\r
+  pointer is not used (probably required to use assembly language)\r
+\r
+**/\r
+ArmPlatformInitializeBootMemory\r
+  // The SMC does not need to be initialized for RTSM\r
+  bx    lr\r
index ca18aa88ddb9706db1ca8a6fd2afd340de41d752..3bbdf6f52d974e3ed718fc860691e8bde3811d65 100644 (file)
 #include <AsmMacroIoLib.h>\r
 #include <Base.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/ArmPlatformLib.h>\r
 #include <ArmPlatform.h>\r
 #include <AutoGen.h>\r
 \r
-#Start of Code section\r
 .text\r
 .align 3\r
 \r
-GCC_ASM_EXPORT(ArmPlatformIsMemoryInitialized)\r
 GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)\r
 \r
 /**\r
@@ -45,18 +44,4 @@ ASM_PFX(ArmPlatformIsMemoryInitialized):
   tst   r0, #0x200\r
   bx   lr\r
     \r
-/**\r
-  Initialize the memory where the initial stacks will reside\r
-\r
-  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
-  In some platform, this region is already initialized and the implementation of this function can\r
-  do nothing. This memory can also represent the Secure RAM.\r
-  This function is called before the satck has been set up. Its implementation must ensure the stack\r
-  pointer is not used (probably required to use assembly language)\r
-\r
-**/\r
-ASM_PFX(ArmPlatformInitializeBootMemory):\r
-  // The SMC does not need to be initialized for RTSM\r
-  bx    lr\r
-\r
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED
\ No newline at end of file
index c0b4263a352bff510a903a0831cae7030e24e8bc..b72fc6f37e7d2a90758eb443751477584c5eb78a 100644 (file)
@@ -1,26 +1,26 @@
 //\r
 //  Copyright (c) 2011, ARM Limited. All rights reserved.\r
-//  \r
-//  This program and the accompanying materials                          \r
-//  are licensed and made available under the terms and conditions of the BSD License         \r
-//  which accompanies this distribution.  The full text of the license may be found at        \r
-//  http://opensource.org/licenses/bsd-license.php                                            \r
 //\r
-//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 //\r
 //\r
 \r
 #include <AsmMacroIoLib.h>\r
 #include <Base.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/ArmPlatformLib.h>\r
 #include <ArmPlatform.h>\r
 #include <AutoGen.h>\r
 \r
   INCLUDE AsmMacroIoLib.inc\r
   \r
   EXPORT  ArmPlatformIsMemoryInitialized\r
-  EXPORT  ArmPlatformInitializeBootMemory\r
   \r
   PRESERVE8\r
   AREA    ArmRealViewEbHelper, CODE, READONLY\r
@@ -45,19 +45,4 @@ ArmPlatformIsMemoryInitialized
   and   r0, r0, #0x200\r
   tst   r0, #0x200\r
   bx   lr\r
-    \r
-/**\r
-  Initialize the memory where the initial stacks will reside\r
-\r
-  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
-  In some platform, this region is already initialized and the implementation of this function can\r
-  do nothing. This memory can also represent the Secure RAM.\r
-  This function is called before the satck has been set up. Its implementation must ensure the stack\r
-  pointer is not used (probably required to use assembly language)\r
-\r
-**/\r
-ArmPlatformInitializeBootMemory\r
-  // The SMC does not need to be initialized for RTSM\r
-  bx    lr\r
-  \r
   END\r
index dc4d560b140265ab4bc943f4b641b6afb2f396e7..d4a603718b0829899a92c07427f0a9367b7bb44a 100644 (file)
@@ -34,6 +34,8 @@
   ArmRealViewEb.c\r
   ArmRealViewEbHelper.asm   | RVCT\r
   ArmRealViewEbHelper.S     | GCC\r
+  ArmRealViewEbBoot.asm     | RVCT\r
+  ArmRealViewEbBoot.S       | GCC\r
 \r
 [Protocols]\r
 \r
index 5670fab7c41345fe67d1a9505521b95444e1cdb6..f160622d78184a4b7e7b38025e162833d7ada8eb 100644 (file)
@@ -31,7 +31,6 @@
   ArmLib
   ArmTrustZoneLib
   MemoryAllocationLib
-  PL354SmcLib
   PL341DmcLib
   PL301AxiLib
   L2X0CacheLib
@@ -40,6 +39,8 @@
 [Sources.common]
   CTA9x4.c
   CTA9x4Mem.c
+  CTA9x4Helper.asm   | RVCT
+  CTA9x4Helper.S     | GCC
 
 [Protocols]
 
index 0a1054a28b4817927d5ca31decfa05177cc017dc..3f08784ff572577c936f9ea06f68127595d3b9cb 100644 (file)
@@ -34,7 +34,7 @@
   L2X0CacheLib\r
   PL301AxiLib\r
   PL341DmcLib\r
-  PL354SmcLib\r
+  PL35xSmcLib\r
   SerialPortLib\r
 \r
 [Sources.common]\r
@@ -42,6 +42,8 @@
   CTA9x4.c\r
   CTA9x4Helper.asm   | RVCT\r
   CTA9x4Helper.S     | GCC\r
+  CTA9x4Boot.asm     | RVCT\r
+  CTA9x4Boot.S       | GCC\r
 \r
 [Protocols]\r
 \r
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.S b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.S
new file mode 100755 (executable)
index 0000000..c53c11f
--- /dev/null
@@ -0,0 +1,110 @@
+//\r
+//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+//\r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+//\r
+\r
+#include <AsmMacroIoLib.h>\r
+#include <Base.h>\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Drivers/PL35xSmc.h>\r
+#include <ArmPlatform.h>\r
+#include <AutoGen.h>\r
+\r
+.text\r
+.align 3\r
+\r
+GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)\r
+GCC_ASM_IMPORT(PL35xSmcInitialize)\r
+\r
+//\r
+// For each Chip Select: ChipSelect / SetCycle / SetOpMode\r
+//\r
+VersatileExpressSmcConfiguration:\r
+    // NOR Flash 0\r
+    .word     PL350_SMC_DIRECT_CMD_ADDR_CS(0)\r
+    .word     PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) :OR: PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) :OR: PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) :OR: PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) :OR: PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
+    .word     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_ADV\r
+\r
+    // NOR Flash 1\r
+    .word     PL350_SMC_DIRECT_CMD_ADDR_CS(4)\r
+    .word     PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) :OR: PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) :OR: PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) :OR: PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) :OR: PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
+    .word     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_ADV\r
+\r
+    // SRAM\r
+    .word     PL350_SMC_DIRECT_CMD_ADDR_CS(2)\r
+    .word     PL350_SMC_SET_CYCLE_SRAM_T_RC(0x8) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) :OR: PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WP(0x6) :OR: PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
+    .word     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_ADV\r
+\r
+    // Usb/Eth/VRAM\r
+    .word     PL350_SMC_DIRECT_CMD_ADDR_CS(3)\r
+    .word     PL350_SMC_SET_CYCLE_SRAM_T_RC(0xA) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WC(0xA) :OR: PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x2) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) :OR: PL350_SMC_SET_CYCLE_SRAM_T_PC(0x3) :OR: PL350_SMC_SET_CYCLE_SRAM_T_TR(0x6)\r
+    .word     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
+\r
+    // Memory Mapped Peripherals\r
+    .word     PL350_SMC_DIRECT_CMD_ADDR_CS(7)\r
+    .word     PL350_SMC_SET_CYCLE_SRAM_T_RC(0x6) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) :OR: PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) :OR: PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
+    .word     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
+\r
+    // VRAM\r
+    .word     PL350_SMC_DIRECT_CMD_ADDR_CS(1)\r
+    .word     0x00049249\r
+    .word     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
+VersatileExpressSmcConfigurationEnd:\r
+\r
+/**\r
+  Initialize the memory where the initial stacks will reside\r
+\r
+  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
+  In some platform, this region is already initialized and the implementation of this function can\r
+  do nothing. This memory can also represent the Secure RAM.\r
+  This function is called before the satck has been set up. Its implementation must ensure the stack\r
+  pointer is not used (probably required to use assembly language)\r
+\r
+**/\r
+ASM_PFX(ArmPlatformInitializeBootMemory):\r
+  mov   r5, lr\r
+\r
+  //\r
+  // Initialize PL354 SMC\r
+  //\r
+  LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)\r
+  ldr   r2, =VersatileExpressSmcConfiguration\r
+  ldr   r3, =VersatileExpressSmcConfigurationEnd\r
+  blx   ASM_PFX(PL35xSmcInitialize)\r
+\r
+  //\r
+  // Page mode setup for VRAM\r
+  //\r
+  LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)\r
+\r
+  // Read current state\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, = 0x00000000\r
+  str     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+\r
+  // Enable page mode\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, = 0x00000000\r
+  str     r0, [r2, #0]\r
+  ldr     r0, = 0x00900090\r
+  str     r0, [r2, #0]\r
+\r
+  // Confirm page mode enabled\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, = 0x00000000\r
+  str     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+\r
+  bx    r5\r
diff --git a/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.asm b/ArmPlatformPkg/ArmVExpressPkg/Library/ArmVExpressLibCTA9x4/CTA9x4Boot.asm
new file mode 100755 (executable)
index 0000000..5a08307
--- /dev/null
@@ -0,0 +1,112 @@
+//\r
+//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+//\r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+//\r
+\r
+#include <AsmMacroIoLib.h>\r
+#include <Base.h>\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Drivers/PL35xSmc.h>\r
+#include <ArmPlatform.h>\r
+#include <AutoGen.h>\r
+\r
+  INCLUDE AsmMacroIoLib.inc\r
+\r
+  EXPORT  ArmPlatformInitializeBootMemory\r
+  IMPORT  PL35xSmcInitialize\r
+\r
+  PRESERVE8\r
+  AREA    CTA9x4BootMode, CODE, READONLY\r
+\r
+//\r
+// For each Chip Select: ChipSelect / SetCycle / SetOpMode\r
+//\r
+VersatileExpressSmcConfiguration\r
+    // NOR Flash 0\r
+    DCD     PL350_SMC_DIRECT_CMD_ADDR_CS(0)\r
+    DCD     PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) :OR: PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) :OR: PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) :OR: PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) :OR: PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
+    DCD     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_ADV\r
+\r
+    // NOR Flash 1\r
+    DCD     PL350_SMC_DIRECT_CMD_ADDR_CS(4)\r
+    DCD     PL350_SMC_SET_CYCLE_NAND_T_RC(0xA) :OR: PL350_SMC_SET_CYCLE_NAND_T_WC(0x3) :OR: PL350_SMC_SET_CYCLE_NAND_T_REA(0x1) :OR: PL350_SMC_SET_CYCLE_NAND_T_WP(0x7) :OR: PL350_SMC_SET_CYCLE_NAND_T_AR(0x1)\r
+    DCD     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT :OR: PL350_SMC_SET_OPMODE_SET_ADV\r
+\r
+    // SRAM\r
+    DCD     PL350_SMC_DIRECT_CMD_ADDR_CS(2)\r
+    DCD     PL350_SMC_SET_CYCLE_SRAM_T_RC(0x8) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) :OR: PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WP(0x6) :OR: PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
+    DCD     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_ADV\r
+\r
+    // Usb/Eth/VRAM\r
+    DCD     PL350_SMC_DIRECT_CMD_ADDR_CS(3)\r
+    DCD     PL350_SMC_SET_CYCLE_SRAM_T_RC(0xA) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WC(0xA) :OR: PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x2) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) :OR: PL350_SMC_SET_CYCLE_SRAM_T_PC(0x3) :OR: PL350_SMC_SET_CYCLE_SRAM_T_TR(0x6)\r
+    DCD     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
+\r
+    // Memory Mapped Peripherals\r
+    DCD     PL350_SMC_DIRECT_CMD_ADDR_CS(7)\r
+    DCD     PL350_SMC_SET_CYCLE_SRAM_T_RC(0x6) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WC(0x5) :OR: PL350_SMC_SET_CYCLE_SRAM_T_CEOE(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_WP(0x2) :OR: PL350_SMC_SET_CYCLE_SRAM_T_PC(0x1) :OR: PL350_SMC_SET_CYCLE_SRAM_T_TR(0x1)\r
+    DCD     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
+\r
+    // VRAM\r
+    DCD     PL350_SMC_DIRECT_CMD_ADDR_CS(1)\r
+    DCD     0x00049249\r
+    DCD     PL350_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL350_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL350_SMC_SET_OPMODE_SET_WR_SYNC\r
+VersatileExpressSmcConfigurationEnd\r
+\r
+/**\r
+  Initialize the memory where the initial stacks will reside\r
+\r
+  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
+  In some platform, this region is already initialized and the implementation of this function can\r
+  do nothing. This memory can also represent the Secure RAM.\r
+  This function is called before the satck has been set up. Its implementation must ensure the stack\r
+  pointer is not used (probably required to use assembly language)\r
+\r
+**/\r
+ArmPlatformInitializeBootMemory\r
+  mov   r5, lr\r
+\r
+  //\r
+  // Initialize PL354 SMC\r
+  //\r
+  LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)\r
+  ldr   r2, =VersatileExpressSmcConfiguration\r
+  ldr   r3, =VersatileExpressSmcConfigurationEnd\r
+  blx   PL35xSmcInitialize\r
+\r
+  //\r
+  // Page mode setup for VRAM\r
+  //\r
+  LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)\r
+\r
+  // Read current state\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, = 0x00000000\r
+  str     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+\r
+  // Enable page mode\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, = 0x00000000\r
+  str     r0, [r2, #0]\r
+  ldr     r0, = 0x00900090\r
+  str     r0, [r2, #0]\r
+\r
+  // Confirm page mode enabled\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+  ldr     r0, = 0x00000000\r
+  str     r0, [r2, #0]\r
+  ldr     r0, [r2, #0]\r
+\r
+  bx    r5\r
index 2987cbee53c9ea1260c11f071acdefc06b901beb..b66b05190742c3203593a2d1cc0ecbcfac8e2bdc 100644 (file)
 #include <Base.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/ArmPlatformLib.h>\r
-#include <Drivers/PL354Smc.h>\r
+#include <ArmPlatform.h>\r
 #include <AutoGen.h>\r
 \r
 .text\r
 .align 3\r
 \r
 GCC_ASM_EXPORT(ArmPlatformIsMemoryInitialized)\r
-GCC_ASM_EXPORT(ArmPlatformInitializeBootMemory)\r
-.extern ASM_PFX(SMCInitializeNOR)\r
-.extern ASM_PFX(SMCInitializeSRAM)\r
-.extern ASM_PFX(SMCInitializePeripherals)\r
-.extern ASM_PFX(SMCInitializeVRAM)\r
 \r
 /**\r
   Called at the early stage of the Boot phase to know if the memory has already been initialized\r
@@ -49,44 +44,3 @@ ASM_PFX(ArmPlatformIsMemoryInitialized):
   tst   r0, #0x40000000\r
   bx   lr\r
 \r
-/**\r
-  Initialize the memory where the initial stacks will reside\r
-\r
-  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
-  In some platform, this region is already initialized and the implementation of this function can\r
-  do nothing. This memory can also represent the Secure RAM.\r
-  This function is called before the satck has been set up. Its implementation must ensure the stack\r
-  pointer is not used (probably required to use assembly language)\r
-\r
-**/\r
-ASM_PFX(ArmPlatformInitializeBootMemory):\r
-  mov   r5, lr\r
-\r
-  //\r
-  // Initialize PL354 SMC\r
-  //\r
-  LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)\r
-\r
-  // NOR Flash 0\r
-  LoadConstantToReg (PL354_SMC_DIRECT_CMD_ADDR_CS(0,0), r2)\r
-  blx   ASM_PFX(SMCInitializeNOR)\r
-\r
-  // NOR Flash 1\r
-  LoadConstantToReg (PL354_SMC_DIRECT_CMD_ADDR_CS(1,0), r2)\r
-  blx   ASM_PFX(SMCInitializeNOR)\r
-\r
-  // Setup SRAM\r
-  blx   ASM_PFX(SMCInitializeSRAM)\r
-\r
-  // Memory Mapped Peripherals\r
-  blx   ASM_PFX(SMCInitializePeripherals)\r
-\r
-  // Initialize VRAM\r
-  //TODO: Check if we really must inititialize Video SRAM in UEFI. Does Linux can do it ? Does the Video driver can do it ?\r
-  //      It will be faster (only initialize if required) and easier (remove assembly code because of a stack available) to move this initialization.\r
-  LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)\r
-  blx   ASM_PFX(SMCInitializeVRAM)\r
-\r
-  bx   r5\r
-\r
-.end\r
index 3b353558e6e01ba1444515fb4a01269fc277a93f..e81888c9fb7b616f1fc7b48f13e76d31fca01870 100644 (file)
@@ -1,32 +1,27 @@
 //\r
 //  Copyright (c) 2011, ARM Limited. All rights reserved.\r
-//  \r
-//  This program and the accompanying materials                          \r
-//  are licensed and made available under the terms and conditions of the BSD License         \r
-//  which accompanies this distribution.  The full text of the license may be found at        \r
-//  http://opensource.org/licenses/bsd-license.php                                            \r
 //\r
-//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 //\r
 //\r
 \r
 #include <AsmMacroIoLib.h>\r
 #include <Base.h>\r
 #include <Library/PcdLib.h>\r
+#include <Library/ArmPlatformLib.h>\r
 #include <ArmPlatform.h>\r
-#include <Drivers/PL354Smc.h>\r
 #include <AutoGen.h>\r
 \r
   INCLUDE AsmMacroIoLib.inc\r
-  \r
-  EXPORT  ArmPlatformIsMemoryInitialized\r
+\r
   EXPORT  ArmPlatformInitializeBootMemory\r
-  IMPORT  SMCInitializeNOR\r
-  IMPORT  SMCInitializeSRAM\r
-  IMPORT  SMCInitializePeripherals\r
-  IMPORT  SMCInitializeVRAM\r
-  \r
+\r
   PRESERVE8\r
   AREA    CTA9x4Helper, CODE, READONLY\r
 \r
@@ -51,44 +46,3 @@ ArmPlatformIsMemoryInitialized
   tst   r0, #0x40000000\r
   bx   lr\r
     \r
-/**\r
-  Initialize the memory where the initial stacks will reside\r
-\r
-  This memory can contain the initial stacks (Secure and Secure Monitor stacks).\r
-  In some platform, this region is already initialized and the implementation of this function can\r
-  do nothing. This memory can also represent the Secure RAM.\r
-  This function is called before the satck has been set up. Its implementation must ensure the stack\r
-  pointer is not used (probably required to use assembly language)\r
-\r
-**/\r
-ArmPlatformInitializeBootMemory\r
-  mov   r5, lr\r
-\r
-  //\r
-  // Initialize PL354 SMC\r
-  //\r
-  LoadConstantToReg (ARM_VE_SMC_CTRL_BASE, r1)\r
-\r
-  // NOR Flash 0\r
-  mov   r2, PL354_SMC_DIRECT_CMD_ADDR_CS(0,0)\r
-  blx   SMCInitializeNOR\r
-\r
-  // NOR Flash 1\r
-  mov   r2, PL354_SMC_DIRECT_CMD_ADDR_CS(1,0)\r
-  blx   SMCInitializeNOR\r
-\r
-  // Setup SRAM\r
-  blx   SMCInitializeSRAM\r
-\r
-  // Memory Mapped Peripherals\r
-  blx   SMCInitializePeripherals\r
-\r
-  // Initialize VRAM\r
-  //TODO: Check if we really must inititialize Video SRAM in UEFI. Does Linux can do it ? Does the Video driver can do it ?\r
-  //      It will be faster (only initialize if required) and easier (remove assembly code because of a stack available) to move this initialization.\r
-  LoadConstantToReg (VRAM_MOTHERBOARD_BASE, r2)\r
-  blx   SMCInitializeVRAM\r
-\r
-  bx   r5\r
-\r
-  END\r
index 789c12cfe6ad8eb0aeb93b4209ce49a3e7032a3d..c7c535985efafb20728075f8ca8c4290761d3beb 100755 (executable)
 #Maintain 8 byte alignment\r
 .align 3\r
 \r
+GCC_ASM_EXPORT(PL35xSmcInitialize)\r
 \r
-GCC_ASM_EXPORT(SMCInitializeNOR)\r
-GCC_ASM_EXPORT(SMCInitializeSRAM)\r
-GCC_ASM_EXPORT(SMCInitializePeripherals)\r
-GCC_ASM_EXPORT(SMCInitializeVRAM)\r
-\r
-\r
-# CS0  CS0-Interf0     NOR1 flash on the motherboard\r
-# CS1  CS1-Interf0     Reserved for the motherboard\r
-# CS2  CS2-Interf0     SRAM on the motherboard\r
-# CS3  CS3-Interf0     memory-mapped Ethernet and USB controllers on the motherboard\r
-# CS4  CS0-Interf1     NOR2 flash on the motherboard\r
-# CS5  CS1-Interf1     memory-mapped peripherals\r
-# CS6  CS2-Interf1     memory-mapped peripherals\r
-# CS7  CS3-Interf1     system memory-mapped peripherals on the motherboard.\r
-\r
-// IN r1 SmcBase\r
-// IN r2 ChipSelect\r
+// IN r1 Smc Base Address\r
+// IN r2 Smc Configuration Start Address\r
+// IN r3 Smc Configuration End Address\r
 // NOTE: This code is been called before any stack has been setup. It means some registers\r
 //       could be overwritten (case of 'r0')\r
-ASM_PFX(SMCInitializeNOR):\r
-#\r
-# Setup NOR1 (CS0-Interface0)\r
-#\r
-\r
-  # Write to set_cycle register(holding register for NOR 1 cycle register or NAND cycle register)\r
-     #Read cycle timeout = 0xA (0:3)\r
-     #Write cycle timeout = 0x3(7:4)\r
-     #OE Assertion Delay = 0x9(11:8)\r
-     #WE Assertion delay = 0x3(15:12)\r
-     #Page cycle timeout = 0x2(19:16)  \r
-  LoadConstantToReg (0x0002393A,r0)       @ldr     r0, = 0x0002393A\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
-  \r
-  # Write to set_opmode register(holding register for NOR 1 opomode register or NAND opmode register)\r
-     # 0x00000002 = MemoryWidth: 32bit\r
-     # 0x00000028 = ReadMemoryBurstLength:continuous\r
-     # 0x00000280 = WriteMemoryBurstLength:continuous\r
-     # 0x00000800 = Set Address Valid\r
-  LoadConstantToReg (0x00000AAA,r0)       @ldr     r0, = 0x00000AAA\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-\r
- # Write to direct_cmd register so that the NOR 1 registers(set-cycles and opmode) are updated with holding registers\r
-     # 0x00000000 = ChipSelect0-Interface 0\r
-     # 0x00400000 = CmdTypes: UpdateRegs\r
-  LoadConstantToReg (0x00400000,r0)       @ldr     r0, = 0x00400000\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-  \r
-  bx lr\r
-\r
-ASM_PFX(SMCInitializeSRAM):\r
-#\r
-# Setup SRAM (CS2-Interface0)\r
-#\r
-  LoadConstantToReg (0x00027158,r0)       @ldr     r0, = 0x00027158\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
-\r
-  # 0x00000002 = MemoryWidth: 32bit\r
-  # 0x00000800 = Set Address Valid\r
-  LoadConstantToReg (0x00000802,r0)       @ldr     r0, = 0x00000802\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-  \r
-  # 0x01000000 = ChipSelect2-Interface 0\r
-  # 0x00400000 = CmdTypes: UpdateRegs\r
-  LoadConstantToReg (0x01400000,r0)       @ldr     r0, = 0x01400000\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-\r
-  bx    lr\r
+ASM_PFX(PL35xSmcInitialize):\r
+  // While (SmcConfigurationStart < SmcConfigurationEnd)\r
+  cmp   r2, r3\r
+  blxge lr\r
 \r
-ASM_PFX(SMCInitializePeripherals):\r
-#\r
-# USB/Eth/VRAM (CS3-Interface0)\r
-#\r
-  LoadConstantToReg (0x000CD2AA,r0)      @ldr     r0, = 0x000CD2AA\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  # 0x00000002 = MemoryWidth: 32bit\r
-  # 0x00000004 = Memory reads are synchronous\r
-  # 0x00000040 = Memory writes are synchronous\r
-  LoadConstantToReg (0x00000046,r0)      @ldr     r0, = 0x00000046\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  # 0x01800000 = ChipSelect3-Interface 0\r
-  # 0x00400000 = CmdTypes: UpdateRegs\r
-  LoadConstantToReg (0x01C00000,r0)      @ldr     r0, = 0x01C00000\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
+  // Write to set_cycle register(holding register for NOR 1 cycle register or NAND cycle register)\r
+  ldr   r0, [r2, #0x4]\r
+  str   r0, [r1, #PL350_SMC_SET_CYCLES_OFFSET]\r
 \r
-#\r
-# Setup NOR3 (CS0-Interface1)\r
-#\r
-  LoadConstantToReg (0x0002393A,r0)      @ldr     r0, = 0x0002393A\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  # 0x00000002 = MemoryWidth: 32bit\r
-  # 0x00000028 = ReadMemoryBurstLength:continuous\r
-  # 0x00000280 = WriteMemoryBurstLength:continuous\r
-  # 0x00000800 = Set Address Valid\r
-  LoadConstantToReg (0x00000AAA,r0)      @ldr     r0, = 0x00000AAA\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  # 0x02000000 = ChipSelect0-Interface 1\r
-  # 0x00400000 = CmdTypes: UpdateRegs\r
-  LoadConstantToReg (0x02400000,r0)      @ldr     r0, = 0x02400000\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
\r
-#\r
-# Setup Peripherals (CS3-Interface1)\r
-#\r
-  LoadConstantToReg (0x00025156,r0)      @ldr     r0, = 0x00025156\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  # 0x00000002 = MemoryWidth: 32bit\r
-  # 0x00000004 = Memory reads are synchronous\r
-  # 0x00000040 = Memory writes are synchronous\r
-  LoadConstantToReg (0x00000046,r0)      @ldr     r0, = 0x00000046\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  # 0x03800000 = ChipSelect3-Interface 1\r
-  # 0x00400000 = CmdTypes: UpdateRegs\r
-  LoadConstantToReg (0x03C00000,r0)      @ldr     r0, = 0x03C00000\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-  bx    lr\r
+  // Write to set_opmode register(holding register for NOR 1 opomode register or NAND opmode register)\r
+  ldr   r0, [r2, #0x8]\r
+  str   r0, [r1, #PL350_SMC_SET_OPMODE_OFFSET]\r
 \r
-// IN r1 SmcBase\r
-// IN r2 VideoSRamBase\r
-// NOTE: This code is been called before any stack has been setup. It means some registers\r
-//       could be overwritten (case of 'r0')\r
-ASM_PFX(SMCInitializeVRAM):\r
-#\r
-# Setup VRAM (CS1-Interface0)\r
-#\r
-  LoadConstantToReg (0x00049249,r0)      @ldr     r0, =  0x00049249\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  # 0x00000002 = MemoryWidth: 32bit\r
-  # 0x00000004 = Memory reads are synchronous\r
-  # 0x00000040 = Memory writes are synchronous\r
-  LoadConstantToReg (0x00000046,r0)      @ldr     r0, = 0x00000046\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  # 0x00800000 = ChipSelect1-Interface 0\r
-  # 0x00400000 = CmdTypes: UpdateRegs\r
-  LoadConstantToReg (0x00C00000,r0)      @ldr     r0, = 0x00C00000\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-  \r
-#\r
-# Page mode setup for VRAM\r
-#\r
-  #read current state \r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, [r2, #0]  \r
-  LoadConstantToReg (0x00000000,r0)      @ldr     r0, = 0x00000000\r
-  str     r0, [r2, #0] \r
-  ldr     r0, [r2, #0]  \r
+  // Write to direct_cmd register so that the NOR 1 registers(set-cycles and opmode) are updated with holding registers\r
+  ldr   r0, =PL350_SMC_DIRECT_CMD_ADDR_CMD_UPDATE\r
+  ldr   r4, [r2, #0x0]\r
+  orr   r0, r0, r4\r
+  str   r0, [r1, #PL350_SMC_DIRECT_CMD_OFFSET]\r
 \r
-  #enable page mode \r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, [r2, #0]  \r
-  LoadConstantToReg (0x00000000,r0)      @ldr     r0, = 0x00000000\r
-  str     r0, [r2, #0] \r
-  LoadConstantToReg (0x00900090,r0)      @ldr     r0, = 0x00900090\r
-  str     r0, [r2, #0] \r
+  add   r2, #0xC\r
+  b     ASM_PFX(PL350SmcInitialize)\r
 \r
-  #confirm page mode enabled\r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, [r2, #0]  \r
-  LoadConstantToReg (0x00000000,r0)      @ldr     r0, = 0x00000000\r
-  str     r0, [r2, #0] \r
-  ldr     r0, [r2, #0]  \r
-  \r
-  bx    lr\r
-  \r
 ASM_FUNCTION_REMOVE_IF_UNREFERENCED
\ No newline at end of file
index 732500e13a37efc2294ccd3ed4c4fa7b32544435..8edc6c1028eff4473c3876b26376d8f957eaa7ac 100755 (executable)
 \r
   INCLUDE AsmMacroIoLib.inc\r
   \r
-  EXPORT  SMCInitializeNOR\r
-  EXPORT  SMCInitializeSRAM\r
-  EXPORT  SMCInitializePeripherals\r
-  EXPORT  SMCInitializeVRAM\r
+  EXPORT  PL35xSmcInitialize\r
 \r
   PRESERVE8\r
   AREA    ModuleInitializeSMC, CODE, READONLY\r
   \r
-// CS0  CS0-Interf0     NOR1 flash on the motherboard\r
-// CS1  CS1-Interf0     Reserved for the motherboard\r
-// CS2  CS2-Interf0     SRAM on the motherboard\r
-// CS3  CS3-Interf0     memory-mapped Ethernet and USB controllers on the motherboard\r
-// CS4  CS0-Interf1     NOR2 flash on the motherboard\r
-// CS5  CS1-Interf1     memory-mapped peripherals\r
-// CS6  CS2-Interf1     memory-mapped peripherals\r
-// CS7  CS3-Interf1     system memory-mapped peripherals on the motherboard.\r
-\r
-// IN r1 SmcBase\r
-// IN r2 ChipSelect\r
+// IN r1 Smc Base Address\r
+// IN r2 Smc Configuration Start Address\r
+// IN r3 Smc Configuration End Address\r
 // NOTE: This code is been called before any stack has been setup. It means some registers\r
 //       could be overwritten (case of 'r0')\r
-SMCInitializeNOR\r
+PL35xSmcInitialize\r
+  // While (SmcConfigurationStart < SmcConfigurationEnd)\r
+  cmp   r2, r3\r
+  blxge lr\r
+\r
   // Write to set_cycle register(holding register for NOR 1 cycle register or NAND cycle register)\r
-  //   - Read cycle timeout  = 0xA (0:3)\r
-  //   - Write cycle timeout = 0x3(7:4)\r
-  //   - OE Assertion Delay  = 0x9(11:8)\r
-  //   - WE Assertion delay  = 0x3(15:12)\r
-  //   - Page cycle timeout  = 0x2(19:16)\r
-  ldr     r0, = 0x0002393A\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
-  \r
+  ldr   r0, [r2, #0x4]\r
+  str   r0, [r1, #PL350_SMC_SET_CYCLES_OFFSET]\r
+\r
   // Write to set_opmode register(holding register for NOR 1 opomode register or NAND opmode register)\r
-  ldr     r0, = (PL354_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT :OR: PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT :OR: PL354_SMC_SET_OPMODE_SET_ADV)\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
+  ldr   r0, [r2, #0x8]\r
+  str   r0, [r1, #PL350_SMC_SET_OPMODE_OFFSET]\r
 \r
   // Write to direct_cmd register so that the NOR 1 registers(set-cycles and opmode) are updated with holding registers\r
-  ldr     r0, =PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE\r
-  orr     r0, r0, r2\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-  \r
-  bx    lr\r
-\r
-\r
-//\r
-// Setup SRAM (CS2-Interface0)\r
-//\r
-SMCInitializeSRAM\r
-  ldr     r0, = 0x00027158\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
-\r
-  ldr     r0, =(PL354_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL354_SMC_SET_OPMODE_SET_ADV)\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-  \r
-  ldr     r0, =(PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE :OR: PL354_SMC_DIRECT_CMD_ADDR_CS(0,2))\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-\r
-  bx    lr\r
-\r
-SMCInitializePeripherals\r
-//\r
-// USB/Eth/VRAM (CS3-Interface0)\r
-//\r
-  ldr     r0, = 0x000CD2AA\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  ldr     r0, =(PL354_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL354_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL354_SMC_SET_OPMODE_SET_WR_SYNC)\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  ldr     r0, =(PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE :OR: PL354_SMC_DIRECT_CMD_ADDR_CS(0,3))\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-\r
-\r
-//\r
-// Setup Peripherals (CS3-Interface1)\r
-//\r
-  ldr     r0, = 0x00025156\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  ldr     r0, =(PL354_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL354_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL354_SMC_SET_OPMODE_SET_WR_SYNC)\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  ldr     r0, =(PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE :OR: PL354_SMC_DIRECT_CMD_ADDR_CS(1,3))\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-\r
-  bx    lr\r
-\r
+  ldr   r0, =PL350_SMC_DIRECT_CMD_ADDR_CMD_UPDATE\r
+  ldr   r4, [r2, #0x0]\r
+  orr   r0, r0, r4\r
+  str   r0, [r1, #PL350_SMC_DIRECT_CMD_OFFSET]\r
 \r
-// IN r1 SmcBase\r
-// IN r2 VideoSRamBase\r
-// NOTE: This code is been called before any stack has been setup. It means some registers\r
-//       could be overwritten (case of 'r0')\r
-SMCInitializeVRAM\r
-  //\r
-  // Setup VRAM (CS1-Interface0)\r
-  //\r
-  ldr     r0, =  0x00049249\r
-  str     r0, [r1, #PL354_SMC_SET_CYCLES_OFFSET]\r
\r
-  ldr     r0, = (PL354_SMC_SET_OPMODE_MEM_WIDTH_32 :OR: PL354_SMC_SET_OPMODE_SET_RD_SYNC :OR: PL354_SMC_SET_OPMODE_SET_WR_SYNC)\r
-  str     r0, [r1, #PL354_SMC_SET_OPMODE_OFFSET]\r
-        \r
-  ldr     r0, = (PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE :OR: PL354_SMC_DIRECT_CMD_ADDR_CS(0,1))\r
-  str     r0, [r1, #PL354_SMC_DIRECT_CMD_OFFSET]\r
-  \r
-  //\r
-  // Page mode setup for VRAM\r
-  //\r
-\r
-  // Read current state\r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, = 0x00000000\r
-  str     r0, [r2, #0] \r
-  ldr     r0, [r2, #0]  \r
+  add   r2, #0xC\r
+  b     PL35xSmcInitialize\r
 \r
-  // Enable page mode\r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, = 0x00000000\r
-  str     r0, [r2, #0] \r
-  ldr     r0, = 0x00900090\r
-  str     r0, [r2, #0] \r
-\r
-  // Confirm page mode enabled\r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, [r2, #0]  \r
-  ldr     r0, = 0x00000000\r
-  str     r0, [r2, #0] \r
-  ldr     r0, [r2, #0]  \r
-  \r
-  bx    lr\r
-  \r
-  END\r
index 0da47f99827bd9ab9cd9e47ac9270e5c3e008ae2..52d64f482b95b7c6e8d3c5e9a49ddec728ef35cd 100644 (file)
 *\r
 **/\r
 \r
-#ifndef PL354SMC_H_\r
-#define PL354SMC_H_\r
+#ifndef PL35xSMC_H_\r
+#define PL35xSMC_H_\r
 \r
-#define PL354_SMC_DIRECT_CMD_OFFSET  0x10\r
-#define PL354_SMC_SET_CYCLES_OFFSET  0x14\r
-#define PL354_SMC_SET_OPMODE_OFFSET  0x18\r
+#define PL350_SMC_DIRECT_CMD_OFFSET  0x10\r
+#define PL350_SMC_SET_CYCLES_OFFSET  0x14\r
+#define PL350_SMC_SET_OPMODE_OFFSET  0x18\r
 \r
-#define PL354_SMC_DIRECT_CMD_ADDR(addr)             ((addr) & 0xFFFFF)\r
-#define PL354_SMC_DIRECT_CMD_ADDR_SET_CRE           (1 << 20)\r
-#define PL354_SMC_DIRECT_CMD_ADDR_CMD_MODE_UPDATE   (3 << 21)\r
-#define PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE        (2 << 21)\r
-#define PL354_SMC_DIRECT_CMD_ADDR_CMD_MODE          (1 << 21)\r
-#define PL354_SMC_DIRECT_CMD_ADDR_CMD_UPDATE_AXI    (0 << 21)\r
-#define PL354_SMC_DIRECT_CMD_ADDR_CS(interf,chip)   (((interf) << 25) | ((chip) << 23))\r
+#define PL350_SMC_DIRECT_CMD_ADDR(addr)                 ((addr) & 0xFFFFF)\r
+#define PL350_SMC_DIRECT_CMD_ADDR_SET_CRE               (1 << 20)\r
+#define PL350_SMC_DIRECT_CMD_ADDR_CMD_MODE_UPDATE       (3 << 21)\r
+#define PL350_SMC_DIRECT_CMD_ADDR_CMD_UPDATE            (2 << 21)\r
+#define PL350_SMC_DIRECT_CMD_ADDR_CMD_MODE              (1 << 21)\r
+#define PL350_SMC_DIRECT_CMD_ADDR_CMD_UPDATE_AXI        (0 << 21)\r
+#define PL350_SMC_DIRECT_CMD_ADDR_CS_INTERF(interf,chip) (((interf) << 25) | ((chip) << 23))\r
+#define PL350_SMC_DIRECT_CMD_ADDR_CS(ChipSelect)        (((ChipSelect) & 0x7) << 23)\r
 \r
-#define PL354_SMC_SET_OPMODE_MEM_WIDTH_8                (0 << 0)\r
-#define PL354_SMC_SET_OPMODE_MEM_WIDTH_16               (1 << 0)\r
-#define PL354_SMC_SET_OPMODE_MEM_WIDTH_32               (2 << 0)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_SYNC                (1 << 2)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_1      (0 << 3)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_4      (1 << 3)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_8      (2 << 3)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_16     (3 << 3)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_32     (4 << 3)\r
-#define PL354_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT   (5 << 3)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_SYNC                (1 << 6)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_1      (0 << 7)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_4      (1 << 7)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_8      (2 << 7)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_16     (3 << 7)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_32     (4 << 7)\r
-#define PL354_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT   (5 << 7)\r
-#define PL354_SMC_SET_OPMODE_SET_BAA                    (1 << 10)\r
-#define PL354_SMC_SET_OPMODE_SET_ADV                    (1 << 11)\r
-#define PL354_SMC_SET_OPMODE_SET_BLS                    (1 << 12)\r
-#define PL354_SMC_SET_OPMODE_SET_BURST_ALIGN_ANY        (0 << 13)\r
-#define PL354_SMC_SET_OPMODE_SET_BURST_ALIGN_32         (1 << 13)\r
-#define PL354_SMC_SET_OPMODE_SET_BURST_ALIGN_64         (2 << 13)\r
-#define PL354_SMC_SET_OPMODE_SET_BURST_ALIGN_128        (3 << 13)\r
-#define PL354_SMC_SET_OPMODE_SET_BURST_ALIGN_256        (4 << 13)\r
+#define PL350_SMC_SET_OPMODE_MEM_WIDTH_8                (0 << 0)\r
+#define PL350_SMC_SET_OPMODE_MEM_WIDTH_16               (1 << 0)\r
+#define PL350_SMC_SET_OPMODE_MEM_WIDTH_32               (2 << 0)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_SYNC                (1 << 2)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_1      (0 << 3)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_4      (1 << 3)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_8      (2 << 3)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_16     (3 << 3)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_32     (4 << 3)\r
+#define PL350_SMC_SET_OPMODE_SET_RD_BURST_LENGTH_CONT   (5 << 3)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_SYNC                (1 << 6)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_1      (0 << 7)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_4      (1 << 7)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_8      (2 << 7)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_16     (3 << 7)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_32     (4 << 7)\r
+#define PL350_SMC_SET_OPMODE_SET_WR_BURST_LENGTH_CONT   (5 << 7)\r
+#define PL350_SMC_SET_OPMODE_SET_BAA                    (1 << 10)\r
+#define PL350_SMC_SET_OPMODE_SET_ADV                    (1 << 11)\r
+#define PL350_SMC_SET_OPMODE_SET_BLS                    (1 << 12)\r
+#define PL350_SMC_SET_OPMODE_SET_BURST_ALIGN_ANY        (0 << 13)\r
+#define PL350_SMC_SET_OPMODE_SET_BURST_ALIGN_32         (1 << 13)\r
+#define PL350_SMC_SET_OPMODE_SET_BURST_ALIGN_64         (2 << 13)\r
+#define PL350_SMC_SET_OPMODE_SET_BURST_ALIGN_128        (3 << 13)\r
+#define PL350_SMC_SET_OPMODE_SET_BURST_ALIGN_256        (4 << 13)\r
 \r
+#define PL350_SMC_SET_CYCLE_NAND_T_RC(t)                (((t) & 0xF) << 0)\r
+#define PL350_SMC_SET_CYCLE_NAND_T_WC(t)                (((t) & 0xF) << 4)\r
+#define PL350_SMC_SET_CYCLE_NAND_T_REA(t)              (((t) & 0x7) << 8)\r
+#define PL350_SMC_SET_CYCLE_NAND_T_WP(t)                (((t) & 0x7) << 11)\r
+#define PL350_SMC_SET_CYCLE_NAND_T_CLR(t)                (((t) & 0x7) << 14)\r
+#define PL350_SMC_SET_CYCLE_NAND_T_AR(t)                (((t) & 0x7) << 17)\r
+#define PL350_SMC_SET_CYCLE_NAND_T_RR(t)                (((t) & 0x7) << 20)\r
+\r
+#define PL350_SMC_SET_CYCLE_SRAM_T_RC(t)                (((t) & 0xF) << 0)\r
+#define PL350_SMC_SET_CYCLE_SRAM_T_WC(t)                (((t) & 0xF) << 4)\r
+#define PL350_SMC_SET_CYCLE_SRAM_T_CEOE(t)              (((t) & 0x7) << 8)\r
+#define PL350_SMC_SET_CYCLE_SRAM_T_WP(t)                (((t) & 0x7) << 11)\r
+#define PL350_SMC_SET_CYCLE_SRAM_T_PC(t)                (((t) & 0x7) << 14)\r
+#define PL350_SMC_SET_CYCLE_SRAM_T_TR(t)                (((t) & 0x7) << 17)\r
+#define PL350_SMC_SET_CYCLE_SRAM_WE_TIME                (1 << 20)\r
 \r
 #endif\r