]> rtime.felk.cvut.cz Git - arc.git/commitdiff
Minor fixes in Fls
authortojo <devnull@localhost>
Tue, 14 Dec 2010 16:44:04 +0000 (17:44 +0100)
committertojo <devnull@localhost>
Tue, 14 Dec 2010 16:44:04 +0000 (17:44 +0100)
arch/ppc/mpc55xx/drivers/Fls.c
arch/ppc/mpc55xx/drivers/Fls_H7F.c
include/Fls.h

index 7713bef34008dcf9aa68271b4921f24de93306eb..759becf834518262fbe8cf5b41577135d2724124 100644 (file)
@@ -86,6 +86,8 @@
 #define SHADOW_ROW_SIZE                0x00008000\r
 #define FLASH_PAGE_SIZE    H7FB_PAGE_SIZE\r
 \r
+#define FLASH_TOTAL_BLOCKS ( 20 )\r
+\r
 #if 0\r
 #define VFLAGS_ADDR_SECT               (1<<0)\r
 #define VFLAGS_ADDR_PAGE               (1<<1)\r
@@ -263,7 +265,7 @@ static inline int Fls_Validate( uint32 addr,uint32 length, uint32 api,uint32 rv
   }\r
 \r
 #define FLS_VALIDATE_PARAM_DATA_W_RV(_ptr,_api, _rv) \\r
-  if( (_ptr)==((void *)0)) { \\r
+  if(( (uint32)(_ptr)%FLS_READ_PAGE_SIZE != 0 ) || ( (_ptr)==((void *)0))) { \
     Det_ReportError(MODULE_ID_FLS,0,_api,FLS_E_PARAM_DATA); \\r
     return _rv; \\r
   }\r
@@ -480,7 +482,7 @@ static void address_to_erase_blocks( Fls_EraseBlockType *eraseBlocks, uint32 add
   endBlock = address_to_block( addr + size - 1,&rem );\r
 \r
   // Check so our implementation holds..\r
-  assert( endBlock<=32 );\r
+  assert( endBlock <= FLASH_TOTAL_BLOCKS );\r
 \r
 #define BLOCK_MASK 0x0003ffffUL\r
 \r
@@ -491,9 +493,9 @@ static void address_to_erase_blocks( Fls_EraseBlockType *eraseBlocks, uint32 add
 \r
 \r
   // shift things in to make freescale driver happy\r
-  eraseBlocks->lowEnabledBlocks = mask&0x3f; // ????\r
-  eraseBlocks->midEnabledBlocks = (mask>>10)&3; // ????\r
-  eraseBlocks->highEnabledBlocks = mask>>12;\r
+  eraseBlocks->lowEnabledBlocks = mask&0x3ff;   // Bits 0..9 indicats low blocks
+  eraseBlocks->midEnabledBlocks = (mask>>10)&3; // Bits 10..11 indicats mid blocks
+  eraseBlocks->highEnabledBlocks = mask>>12;    // Bits 12..19 indicats high blocks
 \r
 \r
   return ;\r
@@ -536,8 +538,8 @@ void Fls_Init( const Fls_ConfigType *ConfigPtr )
 Std_ReturnType Fls_Erase(      Fls_AddressType   TargetAddress,\r
                           Fls_LengthType    Length )\r
 {\r
-  uint32 block;\r
-  uint32 sBlock;\r
+  uint32 endBlock;\r
+  uint32 startBlock;\r
   uint32 rem;\r
   Fls_EraseBlockType eraseBlock;\r
   Fls_EraseInfoType eraseInfo;\r
@@ -553,14 +555,14 @@ Std_ReturnType Fls_Erase( Fls_AddressType   TargetAddress,
      return E_NOT_OK;\r
 \r
   // TargetAddress\r
-  sBlock = address_to_block(TargetAddress,&rem);\r
+  startBlock = address_to_block(TargetAddress,&rem);\r
 \r
-  if( (sBlock == (-1)) || (rem!=0) ) {\r
+  if( (startBlock == (-1)) || (rem!=0) ) {\r
     DET_REPORTERROR(MODULE_ID_FLS,0,0x0,FLS_E_PARAM_ADDRESS );\r
     return E_NOT_OK;\r
   }\r
 \r
-  block = address_to_block(TargetAddress+Length,&rem);\r
+  endBlock = address_to_block(TargetAddress+Length,&rem);\r
 \r
   // Check if we trying to erase a partition that we are executing in\r
   pc = Fls_GetPc();\r
@@ -569,8 +571,7 @@ Std_ReturnType Fls_Erase(   Fls_AddressType   TargetAddress,
        uint32 pcBlock = address_to_block(pc,&rem);\r
        uint8 *partMap = Fls_Global.config->FlsBlockToPartitionMap;\r
 \r
-       if( (partMap[pcBlock] >= partMap[sBlock]) && (partMap[pcBlock] <= partMap[block]) ) {\r
-//    if( address_to_block(pc,&rem) == Fls_Global.config->FlsBlockToPartitionMap[block] ) {\r
+       if( (partMap[pcBlock] >= partMap[startBlock]) && (partMap[pcBlock] <= partMap[endBlock]) ) {\r
         // Can't erase and in the same partition we are executing\r
         assert(0);\r
     }\r
@@ -828,5 +829,27 @@ void Fls_GetVersionInfo( Std_VersionInfoType *VersioninfoPtr )
   memcpy(VersioninfoPtr, &_Fls_VersionInfo, sizeof(Std_VersionInfoType));\r
 }\r
 \r
+void Fls_Check( uint32 flsBaseAddress, uint32 flsTotalSize )\r
+{\r
+  // ECC checking is always on by default.\r
+  // If a non correctable error is discovered\r
+  // we will get an IVOR2 exception.\r
+\r
+  // Enable Flash Non_Correctible Reporting,\r
+  // Not really necessary but makes more information\r
+  // available in the MCM registers if an error occurs.\r
+  MCM.ECR.B.EFNCR = 1;\r
+\r
+  // Read flash in 32bit chunks, it's most efficient.\r
+  uint32* memoryChunkPtr = (uint32*)flsBaseAddress;\r
+  uint32* flsTotalSizePtr = (uint32*)flsTotalSize;\r
+  uint32  memoryChunk = *memoryChunkPtr; // The first read\r
+\r
+  // Read the rest of the flash, chunk by chunk\r
+  while(memoryChunkPtr < flsTotalSizePtr)\r
+  {\r
+    memoryChunk=*(memoryChunkPtr++);\r
+  }\r
+}\r
 \r
 \r
index d4da25743222623c9681cee75951877b71d13fcb..4f8375ac5713aea9f6895e0f1ef6f199b7505512 100644 (file)
@@ -375,6 +375,7 @@ UINT32 Fls_H7F_Program ( PSSD_CONFIG pSSDConfig, Fls_ProgInfoType *pInfo )
       returnCode = Fls_H7F_ProgramStatus(pSSDConfig,pInfo);\r
       break;\r
     default:\r
+      returnCode = 0;\r
       assert(0);\r
       break;\r
     }\r
index d0a08c6329189cb4e6f4d18b7d7c2cb3cd526e59..740bd40a20dd2cbfb6b5fe3bf459419aff5e4acc 100644 (file)
@@ -143,5 +143,6 @@ void Fls_SetMode(           Fls_ModeType Mode );
 \r
 void Fls_GetVersionInfo( Std_VersionInfoType *VersioninfoPtr );\r
 \r
+void Fls_Check( uint32 flsBaseAddress, uint32 flsTotalSize );\r
 \r
 #endif /*FLS_H_*/\r