CC26xx Driver Library
flash.c
Go to the documentation of this file.
1 /******************************************************************************
2 * Filename: flash.c
3 * Revised: 2016-07-07 19:12:02 +0200 (Thu, 07 Jul 2016)
4 * Revision: 46848
5 *
6 * Description: Driver for on chip Flash.
7 *
8 * Copyright (c) 2015 - 2016, Texas Instruments Incorporated
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1) Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 *
17 * 2) Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * 3) Neither the name of the ORGANIZATION nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 ******************************************************************************/
38 
39 #include <inc/hw_types.h>
40 #include <inc/hw_ccfg.h>
41 #include <driverlib/flash.h>
42 #include <driverlib/rom.h>
43 #include <driverlib/chipinfo.h>
44 
45 //*****************************************************************************
46 //
47 // Handle support for DriverLib in ROM:
48 // This section will undo prototype renaming made in the header file
49 //
50 //*****************************************************************************
51 #if !defined(DOXYGEN)
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
64  #undef FlashProgram
65  #define FlashProgram NOROM_FlashProgram
66  #undef FlashEfuseReadRow
67  #define FlashEfuseReadRow NOROM_FlashEfuseReadRow
68  #undef FlashDisableSectorsForWrite
69  #define FlashDisableSectorsForWrite NOROM_FlashDisableSectorsForWrite
70 #endif
71 
72 
73 //*****************************************************************************
74 //
75 // Defines for accesses to the security control in the customer configuration
76 // area in flash top sector.
77 //
78 //*****************************************************************************
79 #define CCFG_OFFSET_SECURITY CCFG_O_BL_CONFIG
80 #define CCFG_OFFSET_SECT_PROT CCFG_O_CCFG_PROT_31_0
81 #define CCFG_SIZE_SECURITY 0x00000014
82 #define CCFG_SIZE_SECT_PROT 0x00000004
83 
84 //*****************************************************************************
85 //
86 // Default values for security control in customer configuration area in flash
87 // top sector.
88 //
89 //*****************************************************************************
90 const uint8_t g_pui8CcfgDefaultSec[] = {0xFF, 0xFF, 0xFF, 0xC5,
91  0xFF, 0xFF, 0xFF, 0xFF,
92  0xC5, 0xFF, 0xFF, 0xFF,
93  0xC5, 0xC5, 0xC5, 0xFF,
94  0xC5, 0xC5, 0xC5, 0xFF
95  };
96 
97 typedef uint32_t (* FlashPrgPointer_t) (uint8_t *, uint32_t, uint32_t);
98 
99 typedef uint32_t (* FlashSectorErasePointer_t) (uint32_t);
100 
101 //*****************************************************************************
102 //
103 // Function prototypes for static functions
104 //
105 //*****************************************************************************
106 static void SetReadMode(void);
107 
108 //*****************************************************************************
109 //
111 //
112 //*****************************************************************************
113 void
114 FlashPowerModeSet(uint32_t ui32PowerMode, uint32_t ui32BankGracePeriode,
115  uint32_t ui32PumpGracePeriode)
116 {
117  //
118  // Check the arguments.
119  //
120  ASSERT(ui32PowerMode == FLASH_PWR_ACTIVE_MODE ||
121  ui32PowerMode == FLASH_PWR_OFF_MODE ||
122  ui32PowerMode == FLASH_PWR_DEEP_STDBY_MODE);
123  ASSERT(ui32BankGracePeriode <= 0xFF);
124  ASSERT(ui32PumpGracePeriode <= 0xFFFF);
125 
126  switch(ui32PowerMode)
127  {
129  //
130  // Set bank power mode to ACTIVE.
131  //
132  HWREG(FLASH_BASE + FLASH_O_FBFALLBACK) =
133  (HWREG(FLASH_BASE + FLASH_O_FBFALLBACK) &
135 
136  //
137  // Set charge pump power mode to ACTIVE mode.
138  //
139  HWREG(FLASH_BASE + FLASH_O_FPAC1) =
141  break;
142 
143  case FLASH_PWR_OFF_MODE:
144  //
145  // Set bank grace periode.
146  //
147  HWREG(FLASH_BASE + FLASH_O_FBAC) =
148  (HWREG(FLASH_BASE + FLASH_O_FBAC) & (~FLASH_FBAC_BAGP_M)) |
149  ((ui32BankGracePeriode << FLASH_FBAC_BAGP_S) & FLASH_FBAC_BAGP_M);
150 
151  //
152  // Set pump grace periode.
153  //
154  HWREG(FLASH_BASE + FLASH_O_FPAC2) =
156  ((ui32PumpGracePeriode << FLASH_FPAC2_PAGP_S) & FLASH_FPAC2_PAGP_M);
157 
158  //
159  // Set bank power mode to SLEEP.
160  //
162 
163  //
164  // Set charge pump power mode to SLEEP mode.
165  //
167  break;
168 
170  //
171  // Set bank grace periode.
172  //
173  HWREG(FLASH_BASE + FLASH_O_FBAC) =
174  (HWREG(FLASH_BASE + FLASH_O_FBAC) & (~FLASH_FBAC_BAGP_M)) |
175  ((ui32BankGracePeriode << FLASH_FBAC_BAGP_S) & FLASH_FBAC_BAGP_M);
176 
177  //
178  // Set pump grace periode.
179  //
180  HWREG(FLASH_BASE + FLASH_O_FPAC2) =
182  ((ui32PumpGracePeriode << FLASH_FPAC2_PAGP_S) & FLASH_FPAC2_PAGP_M);
183 
184  //
185  // Set bank power mode to DEEP STANDBY mode.
186  //
187  HWREG(FLASH_BASE + FLASH_O_FBFALLBACK) =
188  (HWREG(FLASH_BASE + FLASH_O_FBFALLBACK) &
190 
191  //
192  // Set charge pump power mode to STANDBY mode.
193  //
195  break;
196  }
197 }
198 
199 //*****************************************************************************
200 //
202 //
203 //*****************************************************************************
204 uint32_t
206 {
207  uint32_t ui32PowerMode;
208  uint32_t ui32BankPwrMode;
209 
210  ui32BankPwrMode = HWREG(FLASH_BASE + FLASH_O_FBFALLBACK) &
212 
213  if(ui32BankPwrMode == FBFALLBACK_SLEEP)
214  {
215  ui32PowerMode = FLASH_PWR_OFF_MODE;
216  }
217  else if(ui32BankPwrMode == FBFALLBACK_DEEP_STDBY)
218  {
219  ui32PowerMode = FLASH_PWR_DEEP_STDBY_MODE;
220  }
221  else
222  {
223  ui32PowerMode = FLASH_PWR_ACTIVE_MODE;
224  }
225 
226  //
227  // Return power mode.
228  //
229  return(ui32PowerMode);
230 }
231 
232 //*****************************************************************************
233 //
235 //
236 //*****************************************************************************
237 void
238 FlashProtectionSet(uint32_t ui32SectorAddress, uint32_t ui32ProtectMode)
239 {
240  uint32_t ui32SectorNumber;
241 
242  //
243  // Check the arguments.
244  //
245  ASSERT(ui32SectorAddress <= (FLASHMEM_BASE + FlashSizeGet() -
246  FlashSectorSizeGet()));
247  ASSERT((ui32SectorAddress & (FlashSectorSizeGet() - 1)) == 00);
248 
249  if(ui32ProtectMode == FLASH_WRITE_PROTECT)
250  {
251  ui32SectorNumber = (ui32SectorAddress - FLASHMEM_BASE) /
254 
255  if(ui32SectorNumber <= 31)
256  {
257  HWREG(FLASH_BASE + FLASH_O_FSM_BSLE0) |= (1 << ui32SectorNumber);
258  HWREG(FLASH_BASE + FLASH_O_FSM_BSLP0) |= (1 << ui32SectorNumber);
259  }
260  else if(ui32SectorNumber <= 63)
261  {
262  HWREG(FLASH_BASE + FLASH_O_FSM_BSLE1) |=
263  (1 << (ui32SectorNumber & 0x1F));
264  HWREG(FLASH_BASE + FLASH_O_FSM_BSLP1) |=
265  (1 << (ui32SectorNumber & 0x1F));
266  }
267 
269  }
270 }
271 
272 //*****************************************************************************
273 //
275 //
276 //*****************************************************************************
277 uint32_t
278 FlashProtectionGet(uint32_t ui32SectorAddress)
279 {
280  uint32_t ui32SectorProtect;
281  uint32_t ui32SectorNumber;
282 
283  //
284  // Check the arguments.
285  //
286  ASSERT(ui32SectorAddress <= (FLASHMEM_BASE + FlashSizeGet() -
287  FlashSectorSizeGet()));
288  ASSERT((ui32SectorAddress & (FlashSectorSizeGet() - 1)) == 00);
289 
290  ui32SectorProtect = FLASH_NO_PROTECT;
291  ui32SectorNumber = (ui32SectorAddress - FLASHMEM_BASE) / FlashSectorSizeGet();
292 
293  if(ui32SectorNumber <= 31)
294  {
295  if((HWREG(FLASH_BASE + FLASH_O_FSM_BSLE0) & (1 << ui32SectorNumber)) &&
296  (HWREG(FLASH_BASE + FLASH_O_FSM_BSLP0) & (1 << ui32SectorNumber)))
297  {
298  ui32SectorProtect = FLASH_WRITE_PROTECT;
299  }
300  }
301  else if(ui32SectorNumber <= 63)
302  {
303  if((HWREG(FLASH_BASE + FLASH_O_FSM_BSLE1) &
304  (1 << (ui32SectorNumber & 0x1F))) &&
305  (HWREG(FLASH_BASE + FLASH_O_FSM_BSLP1) &
306  (1 << (ui32SectorNumber & 0x1F))))
307  {
308  ui32SectorProtect = FLASH_WRITE_PROTECT;
309  }
310  }
311 
312  return(ui32SectorProtect);
313 }
314 
315 //*****************************************************************************
316 //
318 //
319 //*****************************************************************************
320 uint32_t
321 FlashProtectionSave(uint32_t ui32SectorAddress)
322 {
323  uint32_t ui32ErrorReturn;
324  uint32_t ui32SectorNumber;
325  uint32_t ui32CcfgSectorAddr;
326  uint32_t ui32ProgBuf;
327 
328  ui32ErrorReturn = FAPI_STATUS_SUCCESS;
329 
330  //
331  // Check the arguments.
332  //
333  ASSERT(ui32SectorAddress <= (FLASHMEM_BASE + FlashSizeGet() -
334  FlashSectorSizeGet()));
335  ASSERT((ui32SectorAddress & (FlashSectorSizeGet() - 1)) == 00);
336 
337  if(FlashProtectionGet(ui32SectorAddress) == FLASH_WRITE_PROTECT)
338  {
339  //
340  // Find sector number for specified sector.
341  //
342  ui32SectorNumber = (ui32SectorAddress - FLASHMEM_BASE) / FlashSectorSizeGet();
343  ui32CcfgSectorAddr = FLASHMEM_BASE + FlashSizeGet() - FlashSectorSizeGet();
344 
345  //
346  // Adjust CCFG address to the 32-bit CCFG word holding the
347  // protect-bit for the specified sector.
348  //
349  ui32CcfgSectorAddr += (((ui32SectorNumber >> 5) * 4) + CCFG_OFFSET_SECT_PROT);
350 
351  //
352  // Find value to program by setting the protect-bit which
353  // corresponds to specified sector number, to 0.
354  // Leave other protect-bits unchanged.
355  //
356  ui32ProgBuf = (~(1 << (ui32SectorNumber & 0x1F))) &
357  *(uint32_t *)ui32CcfgSectorAddr;
358 
359  ui32ErrorReturn = FlashProgram((uint8_t*)&ui32ProgBuf, ui32CcfgSectorAddr,
361  }
362 
363  //
364  // Return status.
365  //
366  return(ui32ErrorReturn);
367 }
368 
369 //*****************************************************************************
370 //
372 //
373 //*****************************************************************************
374 uint32_t
375 FlashSectorErase(uint32_t ui32SectorAddress)
376 {
377  uint32_t ui32ErrorReturn;
378  FlashSectorErasePointer_t FuncPointer;
379 
380  //
381  // Check the arguments.
382  //
383  ASSERT(ui32SectorAddress <= (FLASHMEM_BASE + FlashSizeGet() -
384  FlashSectorSizeGet()));
385  ASSERT((ui32SectorAddress & (FlashSectorSizeGet() - 1)) == 00);
386 
387  //
388  // Call ROM function
389  //
390  FuncPointer = (uint32_t (*)(uint32_t)) (ROM_API_FLASH_TABLE[5]);
391  ui32ErrorReturn = FuncPointer(ui32SectorAddress);
392 
393  //
394  // Enable standby in flash bank since ROM function migth have disabled it
395  //
397 
398  //
399  // Return status of operation.
400  //
401  return(ui32ErrorReturn);
402 
403 }
404 
405 
406 //*****************************************************************************
407 //
409 //
410 //*****************************************************************************
411 uint32_t
412 FlashProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
413 {
414  uint32_t ui32ErrorReturn;
415  FlashPrgPointer_t FuncPointer;
416 
417  //
418  // Check the arguments.
419  //
420  ASSERT((ui32Address + ui32Count) <= (FLASHMEM_BASE + FlashSizeGet()));
421 
422  //
423  // Call ROM function
424  //
425  FuncPointer = (uint32_t (*)(uint8_t *, uint32_t, uint32_t)) (ROM_API_FLASH_TABLE[6]);
426  ui32ErrorReturn = FuncPointer( pui8DataBuffer, ui32Address, ui32Count);
427 
428  //
429  // Enable standby in flash bank since ROM function migth have disabled it
430  //
432 
433  //
434  // Return status of operation.
435  //
436  return(ui32ErrorReturn);
437 
438 }
439 
440 //*****************************************************************************
441 //
443 //
444 //*****************************************************************************
445 bool
446 FlashEfuseReadRow(uint32_t *pui32EfuseData, uint32_t ui32RowAddress)
447 {
448  bool bStatus;
449 
450  //
451  // Make sure the clock for the efuse is enabled
452  //
454 
455  //
456  // Set timing for EFUSE read operations.
457  //
460 
461  //
462  // Clear status register.
463  //
464  HWREG(FLASH_BASE + FLASH_O_EFUSEERROR) = 0;
465 
466  //
467  // Select the FuseROM block 0.
468  //
469  HWREG(FLASH_BASE + FLASH_O_EFUSEADDR) = 0x00000000;
470 
471  //
472  // Start the read operation.
473  //
474  HWREG(FLASH_BASE + FLASH_O_EFUSE) =
476  (ui32RowAddress & FLASH_EFUSE_DUMPWORD_M);
477 
478  //
479  // Wait for operation to finish.
480  //
482  {
483  }
484 
485  //
486  // Check if error reported.
487  //
489  {
490  //
491  // Set error status.
492  //
493  bStatus = 1;
494 
495  //
496  // Clear data.
497  //
498  *pui32EfuseData = 0;
499  }
500  else
501  {
502  //
503  // Set ok status.
504  //
505  bStatus = 0;
506 
507  //
508  // No error. Get data from data register.
509  //
510  *pui32EfuseData = HWREG(FLASH_BASE + FLASH_O_DATALOWER);
511  }
512 
513  //
514  // Disable the efuse clock to conserve power
515  //
517 
518  //
519  // Return the data.
520  //
521  return(bStatus);
522 }
523 
524 
525 //*****************************************************************************
526 //
528 //
529 //*****************************************************************************
530 void
532 {
533  //
534  // Configure flash back to read mode
535  //
536  SetReadMode();
537 
538  //
539  // Disable Level 1 Protection.
540  //
542 
543  //
544  // Disable all sectors for erase and programming.
545  //
546  HWREG(FLASH_BASE + FLASH_O_FBSE) = 0x0000;
547 
548  //
549  // Enable Level 1 Protection.
550  //
551  HWREG(FLASH_BASE + FLASH_O_FBPROT) = 0;
552 
553  //
554  // Protect sectors from sector erase.
555  //
557  HWREG(FLASH_BASE + FLASH_O_FSM_SECTOR1) = 0xFFFFFFFF;
558  HWREG(FLASH_BASE + FLASH_O_FSM_SECTOR2) = 0xFFFFFFFF;
560 }
561 
562 //*****************************************************************************
563 //
571 //
572 //*****************************************************************************
573 static void
575 {
576  uint32_t ui32TrimValue;
577  uint32_t ui32Value;
578 
579  //
580  // Configure the STANDBY_MODE_SEL, STANDBY_PW_SEL, DIS_STANDBY, DIS_IDLE,
581  // VIN_AT_X and VIN_BY_PASS for read mode
582  //
585  {
586  // Select trim values for external regulator mode:
587  // Configure STANDBY_MODE_SEL (OTP offset 0x308 bit 7)
588  // COnfigure STANDBY_PW_SEL (OTP offset 0x308 bit 6:5)
589  // Must be done while the register bit field CONFIG.DIS_STANDBY = 1
591 
592  ui32TrimValue =
593  HWREG(FLASH_CFG_BASE + FCFG1_OFFSET + FCFG1_O_FLASH_OTP_DATA4);
594 
595  ui32Value = ((ui32TrimValue &
599 
600  ui32Value |= ((ui32TrimValue &
604 
605  // Configure DIS_STANDBY (OTP offset 0x308 bit 4).
606  // Configure DIS_IDLE (OTP offset 0x308 bit 3).
607  ui32Value |= ((ui32TrimValue &
612 
613  HWREG(FLASH_BASE + FLASH_O_CFG) = (HWREG(FLASH_BASE + FLASH_O_CFG) &
617  FLASH_CFG_DIS_IDLE_M)) | ui32Value;
618 
619  // Check if sample and hold functionality is disabled.
621  {
622  //
623  // Wait for disabled sample and hold functionality to be stable.
624  //
625  while(!(HWREG(FLASH_BASE + FLASH_O_STAT) & FLASH_STAT_SAMHOLD_DIS))
626  {
627  }
628  }
629 
630  // Configure VIN_AT_X (OTP offset 0x308 bits 2:0)
631  ui32Value = ((ui32TrimValue &
635 
636  // Configure VIN_BY_PASS which is dependent on the VIN_AT_X value.
637  // If VIN_AT_X = 7 then VIN_BY_PASS should be 0 otherwise
638  // VIN_BY_PASS should be 1
639  if(((ui32Value & FLASH_FSEQPMP_VIN_AT_X_M) >>
640  FLASH_FSEQPMP_VIN_AT_X_S) != 0x7)
641  {
642  ui32Value |= FLASH_FSEQPMP_VIN_BY_PASS;
643  }
644 
645  HWREG(FLASH_BASE + FLASH_O_FLOCK) = 0xAAAA;
646  HWREG(FLASH_BASE + FLASH_O_FSEQPMP) =
647  (HWREG(FLASH_BASE + FLASH_O_FSEQPMP) &
649  FLASH_FSEQPMP_VIN_AT_X_M)) | ui32Value;
650  HWREG(FLASH_BASE + FLASH_O_FLOCK) = 0x55AA;
651  }
652  else
653  {
654  // Select trim values for internal regulator mode:
655  // Configure STANDBY_MODE_SEL (OTP offset 0x308 bit 15)
656  // COnfigure STANDBY_PW_SEL (OTP offset 0x308 bit 14:13)
657  // Must be done while the register bit field CONFIG.DIS_STANDBY = 1
659 
660  ui32TrimValue =
661  HWREG(FLASH_CFG_BASE + FCFG1_OFFSET + FCFG1_O_FLASH_OTP_DATA4);
662 
663  ui32Value = ((ui32TrimValue &
667 
668  ui32Value |= ((ui32TrimValue &
672 
673  // Configure DIS_STANDBY (OTP offset 0x308 bit 12).
674  // Configure DIS_IDLE (OTP offset 0x308 bit 11).
675  ui32Value |= ((ui32TrimValue &
680 
681  HWREG(FLASH_BASE + FLASH_O_CFG) = (HWREG(FLASH_BASE + FLASH_O_CFG) &
685  FLASH_CFG_DIS_IDLE_M)) | ui32Value;
686 
687  // Check if sample and hold functionality is disabled.
689  {
690  //
691  // Wait for disabled sample and hold functionality to be stable.
692  //
693  while(!(HWREG(FLASH_BASE + FLASH_O_STAT) & FLASH_STAT_SAMHOLD_DIS))
694  {
695  }
696  }
697 
698  // Configure VIN_AT_X (OTP offset 0x308 bits 10:8)
699  ui32Value = (((ui32TrimValue &
703 
704  // Configure VIN_BY_PASS which is dependent on the VIN_AT_X value.
705  // If VIN_AT_X = 7 then VIN_BY_PASS should be 0 otherwise
706  // VIN_BY_PASS should be 1
707  if(((ui32Value & FLASH_FSEQPMP_VIN_AT_X_M) >>
708  FLASH_FSEQPMP_VIN_AT_X_S) != 0x7)
709  {
710  ui32Value |= FLASH_FSEQPMP_VIN_BY_PASS;
711  }
712 
713  HWREG(FLASH_BASE + FLASH_O_FLOCK) = 0xAAAA;
714  HWREG(FLASH_BASE + FLASH_O_FSEQPMP) =
715  (HWREG(FLASH_BASE + FLASH_O_FSEQPMP) &
717  FLASH_FSEQPMP_VIN_AT_X_M)) | ui32Value;
718  HWREG(FLASH_BASE + FLASH_O_FLOCK) = 0x55AA;
719  }
720 }
721 
722 //*****************************************************************************
723 //
724 // HAPI Flash program function
725 //
726 //*****************************************************************************
727 uint32_t
728 MemBusWrkAroundHapiProgramFlash(uint8_t *pui8DataBuffer, uint32_t ui32Address,
729  uint32_t ui32Count)
730 {
731  uint32_t ui32ErrorReturn;
732  FlashPrgPointer_t FuncPointer;
733  uint32_t ui32RomAddr = HWREG(ROM_HAPI_TABLE_ADDR + (5 * 4));
734 
735  //
736  // Call ROM function
737  //
738  FuncPointer = (uint32_t (*)(uint8_t *, uint32_t, uint32_t)) (ui32RomAddr);
739  ui32ErrorReturn = FuncPointer( pui8DataBuffer, ui32Address, ui32Count);
740 
741  //
742  // Enable standby in flash bank since ROM function migth have disabled it
743  //
745 
746  //
747  // Return status of operation.
748  //
749  return(ui32ErrorReturn);
750 }
751 
752 //*****************************************************************************
753 //
754 // HAPI Flash sector erase function
755 //
756 //*****************************************************************************
757 uint32_t
758 MemBusWrkAroundHapiEraseSector(uint32_t ui32Address)
759 {
760  uint32_t ui32ErrorReturn;
761 
762  FlashSectorErasePointer_t FuncPointer;
763  uint32_t ui32RomAddr = HWREG(ROM_HAPI_TABLE_ADDR + (3 * 4));
764 
765  //
766  // Call ROM function
767  //
768  FuncPointer = (uint32_t (*)(uint32_t)) (ui32RomAddr);
769  ui32ErrorReturn = FuncPointer(ui32Address);
770 
771  //
772  // Enable standby in flash bank since ROM function migth have disabled it
773  //
775 
776  //
777  // Return status of operation.
778  //
779  return(ui32ErrorReturn);
780 }
#define FLASH_PWR_OFF_MODE
Definition: flash.h:125
static uint32_t FlashSectorSizeGet(void)
Get size of a flash sector in number of bytes.
Definition: flash.h:249
#define DUMPWORD_INSTR
Definition: flash.h:230
#define FBFALLBACK_DEEP_STDBY
Definition: flash.h:192
uint32_t FlashProtectionGet(uint32_t ui32SectorAddress)
Get sector protection.
Definition: flash.c:278
void FlashPowerModeSet(uint32_t ui32PowerMode, uint32_t ui32BankGracePeriode, uint32_t ui32PumpGracePeriode)
Set power mode.
Definition: flash.c:114
void FlashDisableSectorsForWrite(void)
Disables all sectors for erase and programming on the active bank.
Definition: flash.c:531
#define FCFG1_OFFSET
Definition: flash.h:150
uint32_t(* FlashSectorErasePointer_t)(uint32_t)
Definition: flash.c:99
#define FSM_REG_WRT_DISABLE
Definition: flash.h:184
uint32_t FlashPowerModeGet(void)
Get current configured power mode.
Definition: flash.c:205
#define FLASH_NO_PROTECT
Definition: flash.h:134
#define FAPI_STATUS_SUCCESS
Definition: flash.h:103
uint32_t MemBusWrkAroundHapiEraseSector(uint32_t ui32Address)
Definition: flash.c:758
#define FBFALLBACK_SLEEP
Definition: flash.h:191
uint32_t FlashSectorErase(uint32_t ui32SectorAddress)
Erase a flash sector.
Definition: flash.c:375
static uint32_t FlashSizeGet(void)
Get the size of the flash.
Definition: flash.h:273
#define FSM_REG_WRT_ENABLE
Definition: flash.h:183
#define ASSERT(expr)
Definition: debug.h:74
#define FBFALLBACK_ACTIVE
Definition: flash.h:193
bool FlashEfuseReadRow(uint32_t *pui32EfuseData, uint32_t ui32RowAddress)
Reads efuse data from specified row.
Definition: flash.c:446
#define CCFG_OFFSET_SECT_PROT
Definition: flash.c:80
static void SetReadMode(void)
Definition: flash.c:574
uint32_t MemBusWrkAroundHapiProgramFlash(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
Definition: flash.c:728
#define ROM_HAPI_TABLE_ADDR
Definition: rom.h:61
uint32_t FlashProtectionSave(uint32_t ui32SectorAddress)
Save sector protection to make it permanent.
Definition: flash.c:321
#define CCFG_SIZE_SECT_PROT
Definition: flash.c:82
#define FLASH_PWR_ACTIVE_MODE
Definition: flash.h:124
#define FLASH_WRITE_PROTECT
Definition: flash.h:135
void FlashProtectionSet(uint32_t ui32SectorAddress, uint32_t ui32ProtectMode)
Set sector protection.
Definition: flash.c:238
#define FLASH_PWR_DEEP_STDBY_MODE
Definition: flash.h:126
uint32_t(* FlashPrgPointer_t)(uint8_t *, uint32_t, uint32_t)
Definition: flash.c:97
#define ROM_API_FLASH_TABLE
Definition: rom.h:251
uint32_t FlashProgram(uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
Programs unprotected main bank flash sectors.
Definition: flash.c:412
const uint8_t g_pui8CcfgDefaultSec[]
Definition: flash.c:90