Callisto4Bootloader: drivers/flexspi_nor_flash.h File Reference

Callisto4Bootloader

Data Structures | Macros | Typedefs | Enumerations | Functions
flexspi_nor_flash.h File Reference
`#include <fsl_flexspi.h>`
`#include "fsl_common.h"`
`#include "bootloader_common.h"`

Go to the source code of this file.

## Data Structures

struct | _serial_nor_config_option
union | flash_run_context_t
struct | _flexspi_nor_config

## Macros

#define | NOR_CMD_INDEX_READ CMD_INDEX_READ
| 0 More...
#define | NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS
| 1 More...
#define | NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE
| 2 More...
#define | NOR_CMD_INDEX_ERASESECTOR 3
| 3 More...
#define | NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE
| 4 More...
#define | NOR_CMD_INDEX_CHIPERASE 5
| 5 More...
#define | NOR_CMD_INDEX_DUMMY 6
| 6 More...
#define | NOR_CMD_INDEX_ERASEBLOCK 7
| 7 More...
#define | NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ
| 0 READ LUT sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_READSTATUS CMD_LUT_SEQ_IDX_READSTATUS
| 1 Read Status LUT sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI 2
| 2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_WRITEENABLE CMD_LUT_SEQ_IDX_WRITEENABLE
| 3 Write Enable sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI 4
| 4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5
| 5 Erase Sector sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8
| 8 Erase Block sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM CMD_LUT_SEQ_IDX_WRITE
| 9 Program sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11
| 11 Chip Erase sequence in lookupTable id stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13
| 13 Read SFDP sequence in lookupTable id stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD 14
| 14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block More...
#define | NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD 15
| 15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk More...

## Typedefs

typedef struct _serial_nor_config_option | serial_nor_config_option_t
typedef struct _flexspi_nor_config | flexspi_nor_config_t

## Enumerations

enum

_flexspi_nor_status {
kStatus_FLEXSPINOR_ProgramFail = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 0), kStatus_FLEXSPINOR_EraseSectorFail = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 1), kStatus_FLEXSPINOR_EraseAllFail = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 2), kStatus_FLEXSPINOR_WaitTimeout = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 3),
kStatus_FlexSPINOR_NotSupported = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 4), kStatus_FlexSPINOR_WriteAlignmentError = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 5), kStatus_FlexSPINOR_CommandFailure, kStatus_FlexSPINOR_SFDP_NotFound = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 7),
kStatus_FLEXSPINOR_Unsupported_SFDP_Version, kStatus_FLEXSPINOR_Flash_NotFound = MAKE_STATUS(kStatusGroup_FLEXSPINOR, 9), kStatus_FLEXSPINOR_DTRRead_DummyProbeFailed
}

enum

{
kSerialNorCfgOption_Tag = 0x0c, kSerialNorCfgOption_DeviceType_ReadSFDP_SDR = 0, kSerialNorCfgOption_DeviceType_ReadSFDP_DDR = 1, kSerialNorCfgOption_DeviceType_HyperFLASH1V8 = 2,
kSerialNorCfgOption_DeviceType_HyperFLASH3V0 = 3, kSerialNorCfgOption_DeviceType_MacronixOctalDDR = 4, kSerialNorCfgOption_DeviceType_MacronixOctalSDR = 5, kSerialNorCfgOption_DeviceType_MicronOctalDDR = 6,
kSerialNorCfgOption_DeviceType_MicronOctalSDR = 7, kSerialNorCfgOption_DeviceType_AdestoOctalDDR = 8, kSerialNorCfgOption_DeviceType_AdestoOctalSDR = 9
}

enum | { kSerialNorQuadMode_NotConfig = 0, kSerialNorQuadMode_StatusReg1_Bit6 = 1, kSerialNorQuadMode_StatusReg2_Bit1 = 2, kSerialNorQuadMode_StatusReg2_Bit7 = 3, kSerialNorQuadMode_StatusReg2_Bit1_0x31 = 4 }
enum | { kSerialNorEnhanceMode_Disabled = 0, kSerialNorEnhanceMode_0_4_4_Mode = 1, kSerialNorEnhanceMode_0_8_8_Mode = 2, kSerialNorEnhanceMode_DataOrderSwapped = 3, kSerialNorEnhanceMode_2ndPinMux = 4 }
enum | { kSerialNorConnection_SinglePortA, kSerialNorConnection_Parallel, kSerialNorConnection_SinglePortB, kSerialNorConnection_BothPorts }

enum

{
kRestoreSequence_None = 0, kRestoreSequence_HW_Reset = 1, kRestoreSequence_4QPI_FF = 2, kRestoreSequence_5QPI_FF = 3,
kRestoreSequence_8QPI_FF = 4, kRestoreSequence_Send_F0 = 5, kRestoreSequence_Send_66_99 = 6, kRestoreSequence_Send_6699_9966 = 7,
kRestoreSequence_Send_06_FF
}

enum | { kFlashInstMode_ExtendedSpi = 0x00, kFlashInstMode_0_4_4_SDR = 0x01, kFlashInstMode_0_4_4_DDR = 0x02, kFlashInstMode_QPI_SDR = 0x41, kFlashInstMode_QPI_DDR = 0x42, kFlashInstMode_OPI_SDR = 0x81, kFlashInstMode_OPI_DDR = 0x82 }

## Functions

status_t | flexspi_nor_flash_init (uint32_t instance, flexspi_nor_config_t *config)
| Initialize Serial NOR devices via FlexSPI. More...
status_t | flexspi_nor_flash_page_program (uint32_t instance, flexspi_nor_config_t *config, uint32_t dstAddr, const uint32_t *src)
| Program data to Serial NOR via FlexSPI. More...
status_t | flexspi_nor_flash_erase_all (uint32_t instance, flexspi_nor_config_t *config)
| Erase all the Serial NOR devices connected on FlexSPI. More...
status_t | flexspi_nor_flash_erase_sector (uint32_t instance, flexspi_nor_config_t *config, uint32_t address)
| Erase one sector specified by address. More...
status_t | flexspi_nor_flash_erase_block (uint32_t instance, flexspi_nor_config_t *config, uint32_t address)
| Erase one block specified by address. More...
status_t | flexspi_nor_get_config (uint32_t instance, flexspi_nor_config_t *config, serial_nor_config_option_t *option)
| Get FlexSPI NOR Configuration Block based on specified option. More...
status_t | flexspi_nor_flash_erase (uint32_t instance, flexspi_nor_config_t *config, uint32_t start, uint32_t length)
| Erase Flash Region specified by address and length. More...
status_t | flexspi_nor_flash_read (uint32_t instance, flexspi_nor_config_t *config, uint32_t *dst, uint32_t start, uint32_t bytes)
| Read data from Serial NOR. More...
status_t | flexspi_nor_write_persistent (const uint32_t data)
| Write FlexSPI persistent content. More...
status_t | flexspi_nor_read_persistent (uint32_t *data)
| Read FlexSPI persistent content. More...
status_t | flexspi_nor_restore_spi_protocol (uint32_t instance, flexspi_nor_config_t *config, flash_run_context_t *run_ctx)
| Restore Flash to SPI protocol. More...

## Macro Definition Documentation

## ◆ NOR_CMD_INDEX_CHIPERASE

#define NOR_CMD_INDEX_CHIPERASE 5

5

Definition at line 23 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_DUMMY

#define NOR_CMD_INDEX_DUMMY 6

6

Definition at line 24 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_ERASEBLOCK

#define NOR_CMD_INDEX_ERASEBLOCK 7

7

Definition at line 25 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_ERASESECTOR

#define NOR_CMD_INDEX_ERASESECTOR 3

3

Definition at line 21 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_PAGEPROGRAM

#define NOR_CMD_INDEX_PAGEPROGRAM CMD_INDEX_WRITE

4

Definition at line 22 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_READ

#define NOR_CMD_INDEX_READ CMD_INDEX_READ

0

Definition at line 18 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_READSTATUS

#define NOR_CMD_INDEX_READSTATUS CMD_INDEX_READSTATUS

1

Definition at line 19 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_INDEX_WRITEENABLE

#define NOR_CMD_INDEX_WRITEENABLE CMD_INDEX_WRITEENABLE

2

Definition at line 20 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_CHIPERASE

#define NOR_CMD_LUT_SEQ_IDX_CHIPERASE 11

11 Chip Erase sequence in lookupTable id stored in config block

Definition at line 40 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK

#define NOR_CMD_LUT_SEQ_IDX_ERASEBLOCK 8

8 Erase Block sequence id in lookupTable stored in config block

Definition at line 37 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_ERASESECTOR

#define NOR_CMD_LUT_SEQ_IDX_ERASESECTOR 5

5 Erase Sector sequence id in lookupTable stored in config block

Definition at line 36 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD

#define NOR_CMD_LUT_SEQ_IDX_EXIT_NOCMD 15

15 Exit 0-4-4/0-8-8 mode sequence id in lookupTable stored in config blobk

Definition at line 44 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM

#define NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM CMD_LUT_SEQ_IDX_WRITE

9 Program sequence id in lookupTable stored in config block

Definition at line 38 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_READ

#define NOR_CMD_LUT_SEQ_IDX_READ CMD_LUT_SEQ_IDX_READ

0 READ LUT sequence id in lookupTable stored in config block

Definition at line 27 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_READ_SFDP

#define NOR_CMD_LUT_SEQ_IDX_READ_SFDP 13

13 Read SFDP sequence in lookupTable id stored in config block

Definition at line 41 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_READSTATUS

#define NOR_CMD_LUT_SEQ_IDX_READSTATUS CMD_LUT_SEQ_IDX_READSTATUS

1 Read Status LUT sequence id in lookupTable stored in config block

Definition at line 28 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI

#define NOR_CMD_LUT_SEQ_IDX_READSTATUS_XPI 2

2 Read status DPI/QPI/OPI sequence id in lookupTable stored in config block

Definition at line 30 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD

#define NOR_CMD_LUT_SEQ_IDX_RESTORE_NOCMD 14

14 Restore 0-4-4/0-8-8 mode sequence id in lookupTable stored in config block

Definition at line 42 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_WRITEENABLE

#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE CMD_LUT_SEQ_IDX_WRITEENABLE

3 Write Enable sequence id in lookupTable stored in config block

Definition at line 32 of file flexspi_nor_flash.h.

## ◆ NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI

#define NOR_CMD_LUT_SEQ_IDX_WRITEENABLE_XPI 4

4 Write Enable DPI/QPI/OPI sequence id in lookupTable stored in config block

Definition at line 34 of file flexspi_nor_flash.h.

## Typedef Documentation

## ◆ flexspi_nor_config_t

typedef struct _flexspi_nor_config flexspi_nor_config_t

## ◆ serial_nor_config_option_t

typedef struct _serial_nor_config_option serial_nor_config_option_t

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kSerialNorCfgOption_Tag |
kSerialNorCfgOption_DeviceType_ReadSFDP_SDR |
kSerialNorCfgOption_DeviceType_ReadSFDP_DDR |
kSerialNorCfgOption_DeviceType_HyperFLASH1V8 |
kSerialNorCfgOption_DeviceType_HyperFLASH3V0 |
kSerialNorCfgOption_DeviceType_MacronixOctalDDR |
kSerialNorCfgOption_DeviceType_MacronixOctalSDR |
kSerialNorCfgOption_DeviceType_MicronOctalDDR |
kSerialNorCfgOption_DeviceType_MicronOctalSDR |
kSerialNorCfgOption_DeviceType_AdestoOctalDDR |
kSerialNorCfgOption_DeviceType_AdestoOctalSDR |

Definition at line 66 of file flexspi_nor_flash.h.

## ◆ anonymous enum

anonymous enum

Enumerator
kSerialNorQuadMode_NotConfig |
kSerialNorQuadMode_StatusReg1_Bit6 |
kSerialNorQuadMode_StatusReg2_Bit1 |
kSerialNorQuadMode_StatusReg2_Bit7 |
kSerialNorQuadMode_StatusReg2_Bit1_0x31 |

Definition at line 81 of file flexspi_nor_flash.h.

## ◆ anonymous enum

anonymous enum

Enumerator
kSerialNorEnhanceMode_Disabled |
kSerialNorEnhanceMode_0_4_4_Mode |
kSerialNorEnhanceMode_0_8_8_Mode |
kSerialNorEnhanceMode_DataOrderSwapped |
kSerialNorEnhanceMode_2ndPinMux |

Definition at line 90 of file flexspi_nor_flash.h.

## ◆ anonymous enum

anonymous enum

Enumerator
kSerialNorConnection_SinglePortA |
kSerialNorConnection_Parallel |
kSerialNorConnection_SinglePortB |
kSerialNorConnection_BothPorts |

Definition at line 99 of file flexspi_nor_flash.h.

## ◆ anonymous enum

anonymous enum

Enumerator
kRestoreSequence_None |
kRestoreSequence_HW_Reset |
kRestoreSequence_4QPI_FF |
kRestoreSequence_5QPI_FF |
kRestoreSequence_8QPI_FF |
kRestoreSequence_Send_F0 |
kRestoreSequence_Send_66_99 |
kRestoreSequence_Send_6699_9966 |
kRestoreSequence_Send_06_FF |

Definition at line 157 of file flexspi_nor_flash.h.

## ◆ anonymous enum

anonymous enum

Enumerator
kFlashInstMode_ExtendedSpi |
kFlashInstMode_0_4_4_SDR |
kFlashInstMode_0_4_4_DDR |
kFlashInstMode_QPI_SDR |
kFlashInstMode_QPI_DDR |
kFlashInstMode_OPI_SDR |
kFlashInstMode_OPI_DDR |

Definition at line 170 of file flexspi_nor_flash.h.

## ◆ _flexspi_nor_status

enum _flexspi_nor_status

Enumerator
kStatus_FLEXSPINOR_ProgramFail | Status for Page programming failure.
kStatus_FLEXSPINOR_EraseSectorFail | Status for Sector Erase failure.
kStatus_FLEXSPINOR_EraseAllFail | Status for Chip Erase failure.
kStatus_FLEXSPINOR_WaitTimeout | Status for timeout.
kStatus_FlexSPINOR_NotSupported |
kStatus_FlexSPINOR_WriteAlignmentError | Status for Alignement error.
kStatus_FlexSPINOR_CommandFailure | Status for Erase/Program Verify Error.
kStatus_FlexSPINOR_SFDP_NotFound | Status for SFDP read failure.
kStatus_FLEXSPINOR_Unsupported_SFDP_Version | Status for Unrecognized SFDP version.
kStatus_FLEXSPINOR_Flash_NotFound | Status for Flash detection failure.
kStatus_FLEXSPINOR_DTRRead_DummyProbeFailed | Status for DDR Read dummy probe failure.

Definition at line 48 of file flexspi_nor_flash.h.

## Function Documentation

## ◆ flexspi_nor_flash_erase()

status_t flexspi_nor_flash_erase | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | uint32_t | start,
|  | uint32_t | length
| ) |  |

Erase Flash Region specified by address and length.

Referenced by C4_QSPI_erase(), and writeSector().

## ◆ flexspi_nor_flash_erase_all()

status_t flexspi_nor_flash_erase_all | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config
| ) |  |

Erase all the Serial NOR devices connected on FlexSPI.

## ◆ flexspi_nor_flash_erase_block()

status_t flexspi_nor_flash_erase_block | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | uint32_t | address
| ) |  |

Erase one block specified by address.

## ◆ flexspi_nor_flash_erase_sector()

status_t flexspi_nor_flash_erase_sector | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | uint32_t | address
| ) |  |

Erase one sector specified by address.

## ◆ flexspi_nor_flash_init()

status_t flexspi_nor_flash_init | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config
| ) |  |

Initialize Serial NOR devices via FlexSPI.

Referenced by C4_QSPI_init().

## ◆ flexspi_nor_flash_page_program()

status_t flexspi_nor_flash_page_program | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | uint32_t | dstAddr,
|  | const uint32_t * | src
| ) |  |

Program data to Serial NOR via FlexSPI.

Referenced by writeSector().

## ◆ flexspi_nor_flash_read()

status_t flexspi_nor_flash_read | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | uint32_t * | dst,
|  | uint32_t | start,
|  | uint32_t | bytes
| ) |  |

Read data from Serial NOR.

Referenced by C4_QSPI_read(), and C4_QSPI_write().

## ◆ flexspi_nor_get_config()

status_t flexspi_nor_get_config | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | serial_nor_config_option_t * | option
| ) |  |

Get FlexSPI NOR Configuration Block based on specified option.

Referenced by C4_QSPI_getConfig().

## ◆ flexspi_nor_read_persistent()

status_t flexspi_nor_read_persistent | ( | uint32_t * | data | ) |

Read FlexSPI persistent content.

## ◆ flexspi_nor_restore_spi_protocol()

status_t flexspi_nor_restore_spi_protocol | ( | uint32_t | instance,
|  | flexspi_nor_config_t * | config,
|  | flash_run_context_t * | run_ctx
| ) |  |

Restore Flash to SPI protocol.

## ◆ flexspi_nor_write_persistent()

status_t flexspi_nor_write_persistent | ( | const uint32_t | data | ) |

Write FlexSPI persistent content.