39 #include <inc/hw_types.h>
40 #include <inc/hw_ccfg.h>
52 #undef FlashPowerModeSet
53 #define FlashPowerModeSet NOROM_FlashPowerModeSet
54 #undef FlashPowerModeGet
55 #define FlashPowerModeGet NOROM_FlashPowerModeGet
56 #undef FlashProtectionSet
57 #define FlashProtectionSet NOROM_FlashProtectionSet
58 #undef FlashProtectionGet
59 #define FlashProtectionGet NOROM_FlashProtectionGet
60 #undef FlashProtectionSave
61 #define FlashProtectionSave NOROM_FlashProtectionSave
62 #undef FlashSectorErase
63 #define FlashSectorErase NOROM_FlashSectorErase
65 #define FlashProgram NOROM_FlashProgram
66 #undef FlashEfuseReadRow
67 #define FlashEfuseReadRow NOROM_FlashEfuseReadRow
68 #undef FlashDisableSectorsForWrite
69 #define FlashDisableSectorsForWrite NOROM_FlashDisableSectorsForWrite
81 #define CCFG_SIZE_SECURITY 0x00000014
82 #define CCFG_SIZE_SECT_PROT 0x00000004
91 0xFF, 0xFF, 0xFF, 0xFF,
92 0xC5, 0xFF, 0xFF, 0xFF,
93 0xC5, 0xC5, 0xC5, 0xFF,
94 0xC5, 0xC5, 0xC5, 0xFF
115 uint32_t ui32PumpGracePeriode)
123 ASSERT(ui32BankGracePeriode <= 0xFF);
124 ASSERT(ui32PumpGracePeriode <= 0xFFFF);
126 switch(ui32PowerMode)
207 uint32_t ui32PowerMode;
208 uint32_t ui32BankPwrMode;
229 return(ui32PowerMode);
240 uint32_t ui32SectorNumber;
255 if(ui32SectorNumber <= 31)
260 else if(ui32SectorNumber <= 63)
263 (1 << (ui32SectorNumber & 0x1F));
265 (1 << (ui32SectorNumber & 0x1F));
280 uint32_t ui32SectorProtect;
281 uint32_t ui32SectorNumber;
293 if(ui32SectorNumber <= 31)
301 else if(ui32SectorNumber <= 63)
304 (1 << (ui32SectorNumber & 0x1F))) &&
306 (1 << (ui32SectorNumber & 0x1F))))
312 return(ui32SectorProtect);
323 uint32_t ui32ErrorReturn;
324 uint32_t ui32SectorNumber;
325 uint32_t ui32CcfgSectorAddr;
326 uint32_t ui32ProgBuf;
356 ui32ProgBuf = (~(1 << (ui32SectorNumber & 0x1F))) &
357 *(uint32_t *)ui32CcfgSectorAddr;
359 ui32ErrorReturn =
FlashProgram((uint8_t*)&ui32ProgBuf, ui32CcfgSectorAddr,
366 return(ui32ErrorReturn);
377 uint32_t ui32ErrorReturn;
391 ui32ErrorReturn = FuncPointer(ui32SectorAddress);
401 return(ui32ErrorReturn);
412 FlashProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
414 uint32_t ui32ErrorReturn;
426 ui32ErrorReturn = FuncPointer( pui8DataBuffer, ui32Address, ui32Count);
436 return(ui32ErrorReturn);
576 uint32_t ui32TrimValue;
595 ui32Value = ((ui32TrimValue &
600 ui32Value |= ((ui32TrimValue &
607 ui32Value |= ((ui32TrimValue &
631 ui32Value = ((ui32TrimValue &
663 ui32Value = ((ui32TrimValue &
668 ui32Value |= ((ui32TrimValue &
675 ui32Value |= ((ui32TrimValue &
699 ui32Value = (((ui32TrimValue &
731 uint32_t ui32ErrorReturn;
738 FuncPointer = (uint32_t (*)(uint8_t *, uint32_t, uint32_t)) (ui32RomAddr);
739 ui32ErrorReturn = FuncPointer( pui8DataBuffer, ui32Address, ui32Count);
749 return(ui32ErrorReturn);
760 uint32_t ui32ErrorReturn;
768 FuncPointer = (uint32_t (*)(uint32_t)) (ui32RomAddr);
769 ui32ErrorReturn = FuncPointer(ui32Address);
779 return(ui32ErrorReturn);
#define FLASH_PWR_OFF_MODE
static uint32_t FlashSectorSizeGet(void)
Get size of a flash sector in number of bytes.
#define FBFALLBACK_DEEP_STDBY
uint32_t FlashProtectionGet(uint32_t ui32SectorAddress)
Get sector protection.
void FlashPowerModeSet(uint32_t ui32PowerMode, uint32_t ui32BankGracePeriode, uint32_t ui32PumpGracePeriode)
Set power mode.
void FlashDisableSectorsForWrite(void)
Disables all sectors for erase and programming on the active bank.
uint32_t(* FlashSectorErasePointer_t)(uint32_t)
#define FSM_REG_WRT_DISABLE
uint32_t FlashPowerModeGet(void)
Get current configured power mode.
#define FAPI_STATUS_SUCCESS
uint32_t MemBusWrkAroundHapiEraseSector(uint32_t ui32Address)
uint32_t FlashSectorErase(uint32_t ui32SectorAddress)
Erase a flash sector.
static uint32_t FlashSizeGet(void)
Get the size of the flash.
#define FSM_REG_WRT_ENABLE
#define FBFALLBACK_ACTIVE
bool FlashEfuseReadRow(uint32_t *pui32EfuseData, uint32_t ui32RowAddress)
Reads efuse data from specified row.
#define CCFG_OFFSET_SECT_PROT
static void SetReadMode(void)
uint32_t MemBusWrkAroundHapiProgramFlash(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
#define ROM_HAPI_TABLE_ADDR
uint32_t FlashProtectionSave(uint32_t ui32SectorAddress)
Save sector protection to make it permanent.
#define CCFG_SIZE_SECT_PROT
#define FLASH_PWR_ACTIVE_MODE
#define FLASH_WRITE_PROTECT
void FlashProtectionSet(uint32_t ui32SectorAddress, uint32_t ui32ProtectMode)
Set sector protection.
#define FLASH_PWR_DEEP_STDBY_MODE
uint32_t(* FlashPrgPointer_t)(uint8_t *, uint32_t, uint32_t)
#define ROM_API_FLASH_TABLE
uint32_t FlashProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
Programs unprotected main bank flash sectors.
const uint8_t g_pui8CcfgDefaultSec[]