Callisto4Bootloader: drivers/fsl_flexspi.c File Reference

Callisto4Bootloader

Macros | Enumerations | Functions | Variables
fsl_flexspi.c File Reference
`#include "fsl_flexspi.h"`
`#include <assert.h>`
`#include <stdbool.h>`
`#include "fsl_device_registers.h"`

Go to the source code of this file.

## Macros

#define | FLEXSPI_LUT_KEY_VAL (0x5AF05AF0ul)
| FlesSPI Unlock/Lock Key. More...
#define | FLEXSPI_WAIT_TIMEOUT_NS (500000000UL)
| FlexSPI timeout value, 500ms. More...
#define | FLEXSPI_FREQ_1GHz (1000000000UL)
#define | FREQ_1MHz (1000000UL)
#define | FLEXSPI_DLLCR_DEFAULT (0x100UL)
#define | FLEXSPI0_CLK_GATE_OFFSET 13U
#define | FLEXSPI1_CLK_GATE_OFFSET 15U
#define | CMD_LUT_FOR_IP_CMD 1
| LUT sequence id for IP command. More...
#define | FLEXSPI_PINMUX_VAL 0x08

## Enumerations

enum | { kFlexSpiDelayCellUnit_Min = 75, kFlexSpiDelayCellUnit_Max = 225 }

## Functions

static void | flexspi_swreset (FLEXSPI_Type *base)
| Reset internal logical of FlexSPI. More...
static void | flexspi_unlock_lut (FLEXSPI_Type *base)
| Unlock LUT. More...
static void | flexspi_lock_lut (FLEXSPI_Type *base)
| Lock LUT. More...
static void | flexspi_clear_ip_txfifo (FLEXSPI_Type *base)
| Clear IP TXFIFO. More...
static void | flexspi_clear_ip_rxfifo (FLEXSPI_Type *base)
| Clear IP RXFIO. More...
static void | flexspi_wait_until_ip_idle (FLEXSPI_Type *base)
| Wait Until FlexSPI IP is idle. More...
static FLEXSPI_Type * | flexspi_get_module_base (uint32_t instance)
| Get FlexSPI instance. More...
static void | flexspi_clear_error_status (FLEXSPI_Type *base)
| Clear FlexSPI error status. More...
status_t | flexspi_get_ticks (uint32_t *ticks, uint32_t intervalNs, uint32_t freq, uint32_t unit)
| Get interval ticks based on provided interval in terms of nano-seconds, frequency and unit. More...
static status_t | flexspi_extract_parallel_data (uint32_t *dst0, uint32_t *dst1, uint32_t *src, uint32_t length)
| Extract received data under parallel mode. More...
static status_t | flexspi_device_workmode_config (uint32_t instance, flexspi_mem_config_t *config, uint32_t baseAddr)
| Configure Device workmode via FlexSPI. More...
static status_t | flexspi_device_workmode_config_all_chips (uint32_t instance, flexspi_mem_config_t *config)
static status_t | flexspi_device_cmd_config (uint32_t instance, flexspi_mem_config_t *config, uint32_t baseAddr)
| Configure Device registers via FlexSPI. More...
static status_t | flexspi_device_cmd_config_all_chips (uint32_t instance, flexspi_mem_config_t *config)
bool | flexspi_is_parallel_mode (flexspi_mem_config_t *config)
| Check whether Parallel mode feature is enabled. More...
bool | flexspi_is_padsetting_override_enable (flexspi_mem_config_t *config)
| Check whether Pad Setting Override feature is enabled. More...
bool | flexspi_is_differential_clock_enable (flexspi_mem_config_t *config)
| Check whether Differential clock feature is enabled. More...
bool | flexspi_is_word_addressable (flexspi_mem_config_t *config)
| Check whether device works under word addressable mode. More...
bool | flexspi_is_ck2_enabled (flexspi_mem_config_t *config)
| Check whether CK2 feature is enabled. More...
bool | flexspi_is_ddr_mode_enable (flexspi_mem_config_t *config)
| Check whether DDR mode feature is enabled. More...
status_t | flexspi_configure_dll (uint32_t instance, flexspi_mem_config_t *config)
| Configure DLL register. More...
status_t | flexspi_config_mcr1 (uint32_t instance, flexspi_mem_config_t *config)
status_t | flexspi_config_flash_control_registers (uint32_t instance, flexspi_mem_config_t *config)
status_t | flexspi_config_ahb_buffers (FLEXSPI_Type *base, flexspi_mem_config_t *config)
status_t | flexspi_device_write_enable (uint32_t instance, flexspi_mem_config_t *config, bool isParallelMode, uint32_t baseAddr)
| Send Write enable command to Serial Memory device. More...
status_t | flexspi_init (uint32_t instance, flexspi_mem_config_t *config)
| Initialize FlexSPI. More...
status_t | flexspi_update_lut (uint32_t instance, uint32_t seqIndex, const uint32_t *lutBase, uint32_t seqNumber)
| Configure FlexSPI Lookup table. More...
status_t | flexspi_command_xfer (uint32_t instance, flexspi_xfer_t *xfer)
| Perform FlexSPI command. More...
void | flexspi_wait_idle (uint32_t instance)
| Wait until FlexSPI controller becomes idle. More...
void | flexspi_clear_cache (uint32_t instance)
| Clear FlexSPI cache. More...
status_t | flexspi_device_wait_busy (uint32_t instance, flexspi_mem_config_t *config, bool isParallelMode, uint32_t baseAddr)
| Wait until device is idle. More...
void | flexspi_clear_sequence_pointer (uint32_t instance)
| Clear FlexSPI sequence pointer. More...
void | flexspi_half_clock_control (uint32_t instance, uint32_t option)
| Half FlexSPI Clock. More...

## Variables

static FLEXSPI_Type *const | g_flexSpiInstances [] = FLEXSPI_BASE_PTRS

## Macro Definition Documentation

## ◆ CMD_LUT_FOR_IP_CMD

#define CMD_LUT_FOR_IP_CMD 1

LUT sequence id for IP command.

Definition at line 27 of file fsl_flexspi.c.

## ◆ FLEXSPI0_CLK_GATE_OFFSET

#define FLEXSPI0_CLK_GATE_OFFSET 13U

Definition at line 24 of file fsl_flexspi.c.

## ◆ FLEXSPI1_CLK_GATE_OFFSET

#define FLEXSPI1_CLK_GATE_OFFSET 15U

Definition at line 25 of file fsl_flexspi.c.

## ◆ FLEXSPI_DLLCR_DEFAULT

#define FLEXSPI_DLLCR_DEFAULT (0x100UL)

Definition at line 22 of file fsl_flexspi.c.

## ◆ FLEXSPI_FREQ_1GHz

#define FLEXSPI_FREQ_1GHz (1000000000UL)

Definition at line 19 of file fsl_flexspi.c.

## ◆ FLEXSPI_LUT_KEY_VAL

#define FLEXSPI_LUT_KEY_VAL (0x5AF05AF0ul)

FlesSPI Unlock/Lock Key.

Definition at line 17 of file fsl_flexspi.c.

## ◆ FLEXSPI_PINMUX_VAL

#define FLEXSPI_PINMUX_VAL 0x08

Definition at line 35 of file fsl_flexspi.c.

## ◆ FLEXSPI_WAIT_TIMEOUT_NS

#define FLEXSPI_WAIT_TIMEOUT_NS (500000000UL)

FlexSPI timeout value, 500ms.

Definition at line 18 of file fsl_flexspi.c.

## ◆ FREQ_1MHz

#define FREQ_1MHz (1000000UL)

Definition at line 21 of file fsl_flexspi.c.

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kFlexSpiDelayCellUnit_Min |
kFlexSpiDelayCellUnit_Max |

Definition at line 29 of file fsl_flexspi.c.

## Function Documentation

## ◆ flexspi_clear_cache()

void flexspi_clear_cache | ( | uint32_t | instance | ) |

Clear FlexSPI cache.

Definition at line 1189 of file fsl_flexspi.c.

## ◆ flexspi_clear_error_status()

void flexspi_clear_error_status | ( | FLEXSPI_Type * | base | ) |

static

Clear FlexSPI error status.

Definition at line 429 of file fsl_flexspi.c.

## ◆ flexspi_clear_ip_rxfifo()

static void flexspi_clear_ip_rxfifo | ( | FLEXSPI_Type * | base | ) |

static

Clear IP RXFIO.

Definition at line 401 of file fsl_flexspi.c.

## ◆ flexspi_clear_ip_txfifo()

static void flexspi_clear_ip_txfifo | ( | FLEXSPI_Type * | base | ) |

static

Clear IP TXFIFO.

Definition at line 393 of file fsl_flexspi.c.

## ◆ flexspi_clear_sequence_pointer()

void flexspi_clear_sequence_pointer | ( | uint32_t | instance | ) |

Clear FlexSPI sequence pointer.

Definition at line 1340 of file fsl_flexspi.c.

## ◆ flexspi_command_xfer()

status_t flexspi_command_xfer | ( | uint32_t | instance,
|  | flexspi_xfer_t * | xfer
| ) |  |

Perform FlexSPI command.

Definition at line 965 of file fsl_flexspi.c.

## ◆ flexspi_config_ahb_buffers()

status_t flexspi_config_ahb_buffers | ( | FLEXSPI_Type * | base,
|  | flexspi_mem_config_t * | config
| ) |  |

Definition at line 500 of file fsl_flexspi.c.

## ◆ flexspi_config_flash_control_registers()

status_t flexspi_config_flash_control_registers | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config
| ) |  |

Definition at line 435 of file fsl_flexspi.c.

## ◆ flexspi_config_mcr1()

status_t flexspi_config_mcr1 | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config
| ) |  |

Definition at line 360 of file fsl_flexspi.c.

## ◆ flexspi_configure_dll()

status_t flexspi_configure_dll | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config
| ) |  |

Configure DLL register.

Configure FlexSPI DLL register.

Definition at line 168 of file fsl_flexspi.c.

## ◆ flexspi_device_cmd_config()

status_t flexspi_device_cmd_config | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config,
|  | uint32_t | baseAddr
| ) |  |

static

Configure Device registers via FlexSPI.

Definition at line 665 of file fsl_flexspi.c.

## ◆ flexspi_device_cmd_config_all_chips()

status_t flexspi_device_cmd_config_all_chips | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config
| ) |  |

static

Definition at line 736 of file fsl_flexspi.c.

## ◆ flexspi_device_wait_busy()

status_t flexspi_device_wait_busy | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config,
|  | bool | isParallelMode,
|  | uint32_t | baseAddr
| ) |  |

Wait until device is idle.

Definition at line 1233 of file fsl_flexspi.c.

## ◆ flexspi_device_workmode_config()

status_t flexspi_device_workmode_config | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config,
|  | uint32_t | baseAddr
| ) |  |

static

Configure Device workmode via FlexSPI.

Definition at line 580 of file fsl_flexspi.c.

## ◆ flexspi_device_workmode_config_all_chips()

status_t flexspi_device_workmode_config_all_chips | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config
| ) |  |

static

Definition at line 631 of file fsl_flexspi.c.

## ◆ flexspi_device_write_enable()

status_t flexspi_device_write_enable | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config,
|  | bool | isParallelMode,
|  | uint32_t | baseAddr
| ) |  |

Send Write enable command to Serial Memory device.

Definition at line 543 of file fsl_flexspi.c.

## ◆ flexspi_extract_parallel_data()

static status_t flexspi_extract_parallel_data | ( | uint32_t * | dst0,
|  | uint32_t * | dst1,
|  | uint32_t * | src,
|  | uint32_t | length
| ) |  |

static

Extract received data under parallel mode.

Definition at line 1205 of file fsl_flexspi.c.

## ◆ flexspi_get_module_base()

static FLEXSPI_Type * flexspi_get_module_base | ( | uint32_t | instance | ) |

static

Get FlexSPI instance.

Definition at line 419 of file fsl_flexspi.c.

## ◆ flexspi_get_ticks()

status_t flexspi_get_ticks | ( | uint32_t * | ticks,
|  | uint32_t | intervalNs,
|  | uint32_t | freq,
|  | uint32_t | unit
| ) |  |

Get interval ticks based on provided interval in terms of nano-seconds, frequency and unit.

Definition at line 331 of file fsl_flexspi.c.

## ◆ flexspi_half_clock_control()

void flexspi_half_clock_control | ( | uint32_t | instance,
|  | uint32_t | option
| ) |  |

Half FlexSPI Clock.

Definition at line 1360 of file fsl_flexspi.c.

## ◆ flexspi_init()

status_t flexspi_init | ( | uint32_t | instance,
|  | flexspi_mem_config_t * | config
| ) |  |

Initialize FlexSPI.

Definition at line 769 of file fsl_flexspi.c.

## ◆ flexspi_is_ck2_enabled()

bool flexspi_is_ck2_enabled | ( | flexspi_mem_config_t * | config | ) |

Check whether CK2 feature is enabled.

Definition at line 143 of file fsl_flexspi.c.

## ◆ flexspi_is_ddr_mode_enable()

bool flexspi_is_ddr_mode_enable | ( | flexspi_mem_config_t * | config | ) |

Check whether DDR mode feature is enabled.

Definition at line 155 of file fsl_flexspi.c.

## ◆ flexspi_is_differential_clock_enable()

bool flexspi_is_differential_clock_enable | ( | flexspi_mem_config_t * | config | ) |

Check whether Differential clock feature is enabled.

Definition at line 119 of file fsl_flexspi.c.

## ◆ flexspi_is_padsetting_override_enable()

bool flexspi_is_padsetting_override_enable | ( | flexspi_mem_config_t * | config | ) |

Check whether Pad Setting Override feature is enabled.

Definition at line 107 of file fsl_flexspi.c.

## ◆ flexspi_is_parallel_mode()

bool flexspi_is_parallel_mode | ( | flexspi_mem_config_t * | config | ) |

Check whether Parallel mode feature is enabled.

Definition at line 95 of file fsl_flexspi.c.

## ◆ flexspi_is_word_addressable()

bool flexspi_is_word_addressable | ( | flexspi_mem_config_t * | config | ) |

Check whether device works under word addressable mode.

Definition at line 131 of file fsl_flexspi.c.

## ◆ flexspi_lock_lut()

static void flexspi_lock_lut | ( | FLEXSPI_Type * | base | ) |

static

Lock LUT.

Definition at line 89 of file fsl_flexspi.c.

## ◆ flexspi_swreset()

static void flexspi_swreset | ( | FLEXSPI_Type * | base | ) |

static

Reset internal logical of FlexSPI.

Definition at line 75 of file fsl_flexspi.c.

References FLEXSPI_MCR0_SWRESET_MASK, and FLEXSPI_Type::MCR0.

## ◆ flexspi_unlock_lut()

static void flexspi_unlock_lut | ( | FLEXSPI_Type * | base | ) |

static

Unlock LUT.

Definition at line 83 of file fsl_flexspi.c.

## ◆ flexspi_update_lut()

status_t flexspi_update_lut | ( | uint32_t | instance,
|  | uint32_t | seqIndex,
|  | const uint32_t * | lutBase,
|  | uint32_t | seqNumber
| ) |  |

Configure FlexSPI Lookup table.

Definition at line 924 of file fsl_flexspi.c.

## ◆ flexspi_wait_idle()

void flexspi_wait_idle | ( | uint32_t | instance | ) |

Wait until FlexSPI controller becomes idle.

Definition at line 1171 of file fsl_flexspi.c.

## ◆ flexspi_wait_until_ip_idle()

static void flexspi_wait_until_ip_idle | ( | FLEXSPI_Type * | base | ) |

static

Wait Until FlexSPI IP is idle.

Definition at line 409 of file fsl_flexspi.c.

## Variable Documentation

## ◆ g_flexSpiInstances

FLEXSPI_Type* const g_flexSpiInstances[] = FLEXSPI_BASE_PTRS

static

Definition at line 39 of file fsl_flexspi.c.