xilflash
Vitis Drivers API Documentation
xilflash_cfi.h File Reference

Overview

This file contains methods used to extract and interpret Common Flash Interface(CFI) from a flash memory part that supports the CFI query command.

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 2.00a ktn 12/04/09 Updated to use the HAL processor APIs/macros

Macros

#define XFLASH_CFI_H
 < prevent circular inclusions More...
 
#define XFL_CFI_POSITION_PTR(Ptr, BaseAddr, Interleave, ByteAddr)
 Moves the CFI data pointer to a physical address that corresponds to a specific CFI byte offset. More...
 
#define XFL_CFI_ADVANCE_PTR8(Ptr, Interleave)   (Ptr = (void*)((u32)Ptr + (Interleave)))
 Advances the CFI pointer to the next byte. More...
 
#define XFL_CFI_ADVANCE_PTR16(Ptr, Interleave)   (Ptr = (void*)((u32)Ptr + ((Interleave) << 1)))
 Advances the CFI pointer to the next 16-bit quantity. More...
 
Layout constants
#define XFL_LAYOUT_NUM_PARTS_MASK   0x000000FF
 LAYOUT constants are used to parse the XFL_LAYOUT_X* constants. More...
 
#define XFL_LAYOUT_PART_MODE_MASK   0x0000FF00
 
#define XFL_LAYOUT_PART_WIDTH_MASK   0x00FF0000
 
#define XFL_LAYOUT_CFI_INTERL_MASK   0xFF000000
 
#define XFL_LAYOUT_NUM_PARTS_1   0x00000001
 
#define XFL_LAYOUT_NUM_PARTS_2   0x00000002
 
#define XFL_LAYOUT_NUM_PARTS_4   0x00000004
 
#define XFL_LAYOUT_PART_MODE_8   0x00000100
 
#define XFL_LAYOUT_PART_MODE_16   0x00000200
 
#define XFL_LAYOUT_PART_WIDTH_8   0x00010000
 
#define XFL_LAYOUT_PART_WIDTH_16   0x00020000
 
#define XFL_LAYOUT_CFI_INTERL_1   0x01000000
 
#define XFL_LAYOUT_CFI_INTERL_2   0x02000000
 
#define XFL_LAYOUT_CFI_INTERL_4   0x04000000
 
#define XFL_LAYOUT_CFI_INTERL_8   0x08000000
 

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...
 

Macro Definition Documentation

#define XFL_CFI_ADVANCE_PTR16 (   Ptr,
  Interleave 
)    (Ptr = (void*)((u32)Ptr + ((Interleave) << 1)))

Advances the CFI pointer to the next 16-bit quantity.

Parameters
Ptris the pointer to advance. Can be a pointer to any type.
Interleaveis the byte interleaving (based on part layout).
Returns
Adjusted Ptr.

Referenced by XFlashCFI_ReadCommon().

#define XFL_CFI_ADVANCE_PTR8 (   Ptr,
  Interleave 
)    (Ptr = (void*)((u32)Ptr + (Interleave)))

Advances the CFI pointer to the next byte.

Parameters
Ptris the pointer to advance. Can be a pointer to any type.
Interleaveis the byte interleaving (based on part layout).
Returns
Adjusted Ptr.

Referenced by XFlashCFI_ReadCommon().

#define XFL_CFI_POSITION_PTR (   Ptr,
  BaseAddr,
  Interleave,
  ByteAddr 
)
Value:
( \
Ptr = (void*)((u32)BaseAddr + ((u32)Interleave * \
(u32)ByteAddr)) \
)

Moves the CFI data pointer to a physical address that corresponds to a specific CFI byte offset.

Parameters
Ptris the pointer to modify. Can be of any type.
BaseAddris the base address of flash part.
Interleaveis the byte interleaving (based on part layout).
ByteAddris the byte offset within CFI data to read.
Returns
The Ptr argument is set to point at the CFI byte specified by the ByteAddr parameter.

Referenced by XFlashCFI_ReadCommon().

#define XFL_LAYOUT_NUM_PARTS_MASK   0x000000FF

LAYOUT constants are used to parse the XFL_LAYOUT_X* constants.

Referenced by XFlashCFI_ReadCommon().

#define XFLASH_CFI_H

< prevent circular inclusions

by using protection macros

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().