Kinetis Bootloader  2.0.0
Common bootloader for Kinetis devices
Qspi_driver

Data Structures

struct  SFLASH_CONFIGURATION_PARAM_PTR
 QuadSPI Config block structure. More...
 

Enumerations

enum  __qspi_config_block_tags {
  kQspiConfigTag = FOUR_CHAR_CODE('k', 'q', 'c', 'f'),
  kQspiVersionTag = FOUR_CHAR_CODE(0, 2, 1, 'Q')
}
 
enum  qspiflash_mode_option_t {
  kQspiFlashMode_Serial = 0,
  kQspiFlashMode_Parallel = 1
}
 QSPI Flash mode options. More...
 
enum  qspiflash_pad_t {
  kQspiFlashPad_Single = 0,
  kQspiFlashPad_Dual = 1,
  kQspiFlashPad_Quad = 2,
  kQspiFlashPad_Octal = 3
}
 External spi flash pad definition. More...
 
enum  qspi_serial_clock_freq_t {
  kQspiSerialClockFreq_Low = 0,
  kQspiSerialClockFreq_Mid = 1,
  kQspiSerialClockFreq_High = 2
}
 QSPI Serial Clock Frequency options. More...
 
enum  qspiflash_property_t {
  kQspiFlashProperty_InitStatus = 0,
  kQspiFlaghProperty_StartAddress = 1,
  kQspiFlashProperty_TotalFlashSizeInKBytes = 2,
  kQspiFlashProperty_PageSize = 3,
  kQspiFlashProperty_SectorSize = 4,
  kQspiFlashProperty_BlockSize = 5,
  kQspiFlashProperty_TotalFlashSize = 0x10
}
 QSPI flash property tag values. More...
 
enum  qspi_endianess_t {
  kQspiEndianess_64BE = 0U,
  kQspiEndianess_32LE = 1U,
  kQspiEndianess_32BE = 2U,
  kQspiEndianess_64LE = 3U
}
 Endianess supported by QSPI module. More...
 
enum  qspi_port_enable_t {
  kQspiPort_EnablePortA = 0U,
  kQspiPort_EnableBothPorts = 1
}
 Port Enablement Option. More...
 
enum  qspi_ahb_data_transfer_size_t {
  kQspiAHBDataTransferSize_64Bytes = 8U,
  kQspiAHBDataTransferSize_256Bytes = 32U,
  kQspiAHBDataTransferSize_512Bytes = 64U
}
 Definition for AHB data tranfer size. More...
 
enum  qspiflash_status_t {
  kStatus_QspiFlashSizeError = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 0),
  kStatus_QspiFlashAlignmentError = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 1),
  kStatus_QspiFlashAddressError = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 2),
  kStatus_QspiFlashCommandFailure = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 3),
  kStatus_QspiFlashUnknownProperty = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 4),
  kStatus_QspiNotConfigured = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 5),
  kStatus_QspiCommandNotSupported = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 6),
  kStatus_QspiCommandTimeout = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 7),
  kStatus_QspiWriteFailure = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 8),
  kStatusQspiModuleBusy = MAKE_STATUS(kStatusGroup_QuadSPIDriver, 9)
}
 Error codes of QuadSPI driver. More...
 

Functions

status_t quadspi_get_property (uint32_t whichProperty, uint32_t *value)
 Get Property from QSPI driver. More...
 
status_t quadspi_page_program (uint32_t dst_addr, const uint32_t *src, uint32_t lengthInBytes)
 Page program to external spi flash. More...
 
status_t quadspi_init (qspi_config_t *config_base)
 Intialize QSPI module according to parameters passed in. More...
 
bool is_quadspi_configured (void)
 Get the status of quadspi configuration. More...
 
status_t quadspi_iomux_configuration (qspi_config_t *config_base)
 Configure pinmux of QSPI module according to parameters passed in. More...
 
void quadspi_serial_clock_configure (qspi_serial_clock_freq_t freq)
 Configure QSPI serial clock frquency. More...
 
status_t quadspi_erase_all (void)
 Erase the entire spi flash devices. More...
 
status_t quadspi_erase_sector (uint32_t address)
 Erase one sector from the provided address. More...
 
status_t quadspi_cache_clear (void)
 Flush QSPI cache. More...
 

Usage Information


Data Structure Documentation

struct qspi_config_t

QuadSPI Config block structure.

+ Collaboration diagram for SFLASH_CONFIGURATION_PARAM_PTR:
Data Fields
uint32_t busy_bit_offset Flash device busy bit offset in status register.
uint32_t column_address_space The width of the column address.
uint32_t config_cmd_en Enable config commands.
uint32_t config_cmds[QSPI_PRE_CMD_CNT] Config comands, used to configure nor flash.
uint32_t config_cmds_args[QSPI_PRE_CMD_CNT] Config commands arguments.
uint32_t cs_hold_time CS hold time in terms of serial clock.(for example 1 serial clock cyle)
uint32_t cs_setup_time CS setup time in terms of serial clock.(for example 1 serial clock cyle)
uint32_t data_hold_time Serial flash data In Hold time, valid value: 0/1/2.
uint32_t ddr_mode_enable Enable DDR mode if set to TRUE.
uint32_t ddrsmp Select the sampling point for incomming data when serial flash is in DDR mdoe.
uint32_t device_cmd Command to be tranferred to device.
uint32_t device_mode_config_en Determine if it is required to config working mode of external spi flash.
uint32_t differential_clock_pin_enable Differential flash clock pins enable.
uint32_t dqs_enable Enable DQS mode if set to TRUE.
uint32_t dqs_fa_delay_chain_sel dqs fa delay chain selection
uint32_t dqs_fb_delay_chain_sel dqs fb delay chain selection
uint32_t dqs_inverse_sel Select clock source for internal DQS generation.
uint32_t dqs_latency_enable DQS Latency Enable.
uint32_t dqs_loopback Sets DQS LoopBack Mode to enable Dummy Pad MCR[24].
uint32_t dqs_loopback_internal 0: dqs loopback from pad, 1: dqs loopback internally
uint32_t dqs_phase_sel dqs phase sel
uint32_t erase_all_cmd_address_offset Address for EraseAll command.
uint32_t flash_CK2_clock_pin_enable Flash CK2 clock pin enable.
uint32_t fsdly Full speed phase selection for SDR instructions.
uint32_t fsphs Full speed delay selection for SDR instructions.
uint32_t ips_command_second_divider second devider for all IPS commands.
uint32_t is_spansion_hyperflash Determine if connected spi flash device belongs to Hyperflash family.
uint32_t lengthInBytes Total length of strcut in bytes.
uint32_t look_up_table[QSPI_LUT_MAX_ENTRIES] Set of seq to perform optimum read on SFLASH as as per vendor SFLASH.
uint32_t need_multi_phases Determine if multiple hases command are needed.
uint32_t pagesize page Size of Serial Flash
uint32_t parallel_mode_enable Enable Individual or parrallel mode.
uint32_t portA_cs1 Enable PORTA CS1.
uint32_t portB_cs1 Enable PORTB CS1.
uint32_t pre_erase_cmd_address_offset Address for PreErase command.
uint32_t pre_program_cmd_address_offset Address for PreProgram command.
uint32_t pre_read_status_cmd_address_offset Address for PreReadStatus command.
uint32_t pre_unlock_cmd_address_offset Address for PreWriteEnable command.
uint32_t reserved0[2] Reserved for K80.
uint32_t reserved1[2] reserved
uint32_t reserved2[3] Reserved words to make sure qspi config block is page-aligend.
uint32_t sclk_freq In 00 - 24MHz, 01 - 48MHz, 10 - 96MHz,(only for SDR Mode)
uint32_t sectorsize sector Size of Serial Flash
uint32_t sflash_A1_size Size of flash connected on QSPI0A Ports and QSPI0A_SS0, in terms of Bytes.
uint32_t sflash_A2_size Size of flash connected on QSPI0A Ports and QSPI0A_SS1, in terms of Bytes.
uint32_t sflash_B1_size Size of flash connected on QSPI0B Ports and QSPI0B_SS0, in terms of Bytes.
uint32_t sflash_B2_size Size of flash connected on QSPI0B Ports and QSPI0B_SS1, in terms of Bytes.
uint32_t sflash_port 0–Only Port-A, 1–Both PortA and PortB
uint32_t sflash_type SPI flash type: 0-Single,1–Dual 2–Quad, 3– Octal.
uint32_t tag Set to magic number of 'kqcf'.
uint32_t timeout_milliseconds

timeout in terms of millisecond in case of infinite loop in qspi driver 0 represents disabling timeout check. This value is valid since version 1.1.0

uint32_t unlock_cmd_address_offset Address for WriteEnable command.
standard_version_t version

version of config struct the version number i organized as following:

uint32_t word_addressable Determine if the serial flash is word addressable.
uint32_t write_cmd_ipcr IPCR value of Write command.

Enumeration Type Documentation

Enumerator
kQspiConfigTag 

Tag value used to validate the qspi config block.

kQspiVersion1.1 Support Parallel mode, timeout check kQspiVersion1.2 Support configuring QuadSPI_FLSHCR[TDH]

Definition for AHB data tranfer size.

Enumerator
kQspiAHBDataTransferSize_64Bytes 

AHB data transfer size is 64bytes.

kQspiAHBDataTransferSize_256Bytes 

AHB data transfer size is 256bytes.

kQspiAHBDataTransferSize_512Bytes 

AHB data transfer size is 512bytes.

Endianess supported by QSPI module.

Enumerator
kQspiEndianess_64BE 

64-bit Big Endian

kQspiEndianess_32LE 

32-bit Little Endian

kQspiEndianess_32BE 

32-bit Big Endian

kQspiEndianess_64LE 

64-bit Little Endian

Port Enablement Option.

Enumerator
kQspiPort_EnablePortA 

Only PORTA is enabled.

kQspiPort_EnableBothPorts 

Enable Both PoartA and PortB.

QSPI Serial Clock Frequency options.

Enumerator
kQspiSerialClockFreq_Low 

QuadSPI module works at low frequency.

kQspiSerialClockFreq_Mid 

QuadSPI module works at mid frequency.

kQspiSerialClockFreq_High 

QuadSPI module works at high frequency.

QSPI Flash mode options.

Enumerator
kQspiFlashMode_Serial 

Serial mode.

kQspiFlashMode_Parallel 

Parallel mode.

External spi flash pad definition.

Enumerator
kQspiFlashPad_Single 

Single-pad spi flash.

kQspiFlashPad_Dual 

Dual-pad spi flash.

kQspiFlashPad_Quad 

Quad-pad spi flash.

kQspiFlashPad_Octal 

Octal-pad spi flash.

QSPI flash property tag values.

Enumerator
kQspiFlaghProperty_StartAddress 

Tag used to retrieve start address.

kQspiFlashProperty_TotalFlashSizeInKBytes 

Tag used to retrieve total flash size in terms of KByte.

kQspiFlashProperty_PageSize 

Tag used to retreive page size in terms of byte.

kQspiFlashProperty_SectorSize 

Tag used to retrieve sector size in term of byte.

kQspiFlashProperty_BlockSize 

Tag used to retrieve block size in terms of byte.

kQspiFlashProperty_TotalFlashSize 

Tag used to retrieve total flash size in terms of byte.

Error codes of QuadSPI driver.

Enumerator
kStatus_QspiFlashSizeError 

Error code which represents that flash size is error.

kStatus_QspiFlashAlignmentError 

Error code which represents that start address for programming is not page aligned.

kStatus_QspiFlashAddressError 

Error code which represents that the address is invalid.

kStatus_QspiFlashCommandFailure 

Error code which represents that the operation is not successfully executed.

kStatus_QspiFlashUnknownProperty 

Error code which represents that the property is not supported.

kStatus_QspiNotConfigured 

Error code which represents that qspi module is not configured yet.

kStatus_QspiCommandNotSupported 

Error code which represents that a command is not supported under certain mode.

kStatus_QspiCommandTimeout 

Error code which represents that operation is timeout.

kStatus_QspiWriteFailure 

Error code which represents that QSPI cannot perform write operation at expected frequency.

kStatusQspiModuleBusy 

Error code which represents that the QSPI module is busy, which may be caused by incorrect.

Function Documentation

bool is_quadspi_configured ( void  )

Get the status of quadspi configuration.

This function return True or False which represents the QuadSPI module is successfully configured or not configured yet respectively.

Returns
true or false
status_t quadspi_cache_clear ( void  )

Flush QSPI cache.

Returns
kStatus_Success
status_t quadspi_erase_all ( void  )

Erase the entire spi flash devices.

Returns
An error code or kStatus_Success
status_t quadspi_erase_sector ( uint32_t  address)

Erase one sector from the provided address.

Parameters
addressThe start address of the sector to be erased.
Returns
An error code or kStatus_Success
status_t quadspi_get_property ( uint32_t  whichProperty,
uint32_t *  value 
)

Get Property from QSPI driver.

This function is used to retrieve qspi related properties

Parameters
wichPropertyProperty tag
valuePointer which is used to return the propery value
Returns
An error code or kStatus_Success
status_t quadspi_init ( qspi_config_t config_base)

Intialize QSPI module according to parameters passed in.

This function intializes and configures QuadSPI module according to the pointer which points to quad spi config block

Parameters
config_baseBase address of a quadspi config block
Returns
An error code or kStatus_Success
status_t quadspi_iomux_configuration ( qspi_config_t config_base)

Configure pinmux of QSPI module according to parameters passed in.

This function configures pinmux for QSPI modules dynamically according to the pointer which points to a qspi config block. This function is target-specific, should be implemented in BSP.

Parameters
config_baseA pointer which points to a qspi config block
Returns
An error code or kStatus_Success
status_t quadspi_page_program ( uint32_t  dst_addr,
const uint32_t *  src,
uint32_t  lengthInBytes 
)

Page program to external spi flash.

This function programs certain length of data to expected address according to parameters passed in

Parameters
dst_addrDestination Address to be programmed
srcData to be programmed
lengthInBytesSize of data to be programmed
Returns
An error code or kStatus_Success
void quadspi_serial_clock_configure ( qspi_serial_clock_freq_t  freq)

Configure QSPI serial clock frquency.

This function configures the serial clock frequency of QSPI module according to the expected option. This function is target-specific, should be implemented in BSP.

Parameters
freqenumerated variable represent serial clock frequency