xilflash
Vitis Drivers API Documentation
xilflash_cfi.c File Reference

Overview

The file implements the functions for retrieval and translation of CFI data from a compliant flash device.

CFI contains data that defines part geometry, write/erase timing, and programming data.

Data is retrieved using macros defined in this xflash_cfi.h file. The macros simplify data extraction because they have been written to take into account the layout of parts on the data bus. To the library, CFI data appears as if it were always being read from a single 8-bit part (XFL_LAYOUT_X8_X8_X1) Otherwise, the retrieval code would have to contend with all the formats illustrated below. The illustration shows how the first three bytes of the CFI query data "QRY" appear in flash memory space for various part layouts.

                Byte Offset (Big-Endian)
                0123456789ABCDEF
                ----------------
                XFL_LAYOUT_X16_X16_X1   Q R Y
                XFL_LAYOUT_X16_X16_X2   Q Q R R Y Y

Where the holes between Q, R, and Y are NULL (all bits 0)

Note

This code is intended to be RTOS and processor independent. It works with physical addresses only. Any needs for dynamic memory management, threads, mutual exclusion, virtual memory, or cache control management must be satisfied by the layer above this library.

MODIFICATION HISTORY:
Ver   Who  Date     Changes


1.00a rmm 10/25/07 First release 1.00a mta 10/25/07 Updated to flash library 1.01a ksu 04/10/08 Added support for AMD CFI Interface 1.02a ksu 08/06/09 Added code to read the platform flash bank information 2.00a ktn 12/04/09 Updated to use the HAL processor APIs/macros 2.02a sdm 06/30/10 Updated to support AXI EMC with Little Endian Processor 3.00a sdm 03/03/11 Removed static parameters in mld and updated code to determine these parameters from the CFI data. 3.01a srt 03/02/12 Added support for Micron G18 Flash device to fix CRs 648372, 648282. Added DATA_SYNC to fix the CR 644750. 3.02a srt 05/30/12 Changed Implementation for Micron G18 Flash, which fixes the CR 662317. CR 662317 Description - Xilinx Platform Flash on ML605 fails to work. 3.04a srt 02/18/13 Fixed CR 700553. 4.5 tjs 08/13/18 Fixed compilation errors for ARMCC (CR#1008306) 4.7 akm 07/23/19 Initialized Status variable to XST_FAILURE. 4.10 akm 07/14/23 Added support for system device-tree flow.

Functions

int XFlashCFI_ReadCommon (XFlash *InstancePtr, u8 BusWidth)
 Retrieves the standard CFI data from the part(s), interpret the data, and update the provided geometry and properties structures. More...
 
int XFlashCFI_Read8 (u8 *Ptr, u8 Interleave, u8 Mode)
 Reads 8-bits of data from the CFI data location into a local variable. More...
 
int XFlashCFI_Read16 (u8 *Ptr, u8 Interleave, u8 Mode)
 Reads 16-bits of data from the CFI data location into a local variable. More...
 

Function Documentation

int XFlashCFI_Read16 ( u8 *  Ptr,
u8  Interleave,
u8  Mode 
)

Reads 16-bits of data from the CFI data location into a local variable.

Parameters
Ptris the pointer to read. Can be a pointer to any type.
Interleaveis the byte interleaving (based on part layout).
Modeis the mode of operation (based on part layout).
Returns
The 16-bit value at Ptr adjusted for the interleave factor.

Referenced by XFlashCFI_ReadCommon().

int XFlashCFI_Read8 ( u8 *  Ptr,
u8  Interleave,
u8  Mode 
)

Reads 8-bits of data from the CFI data location into a local variable.

Parameters
Ptris the pointer to read. Can be a pointer to any type.
Interleaveis the byte interleaving (based on part layout).
Modeis the mode of operation (based on part layout).
Returns
The byte at Ptr adjusted for the interleave factor.

Referenced by XFlashCFI_ReadCommon().

int XFlashCFI_ReadCommon ( XFlash *  InstancePtr,
u8  BusWidth 
)

Retrieves the standard CFI data from the part(s), interpret the data, and update the provided geometry and properties structures.

Extended CFI data is part specific and ignored here. This data must be read by the specific flash device family library.

Parameters
InstancePtris the pointer to the XFlash instance.
BusWidthis the total width of the flash memory, in bytes.
Returns
  • XST_SUCCESS if successful.
  • XFLASH_CFI_QUERY_ERROR if an error occurred interpreting the data.
  • XFLASH_PART_NOT_SUPPORTED if invalid Layout parameter.
Note
None.

References XFL_CFI_ADVANCE_PTR16, XFL_CFI_ADVANCE_PTR8, XFL_CFI_POSITION_PTR, XFL_LAYOUT_NUM_PARTS_MASK, XFlashCFI_Read16(), and XFlashCFI_Read8().

Referenced by XFlash_Initialize().