xilflash.c File Reference

#include "include/xilflash.h"
#include "include/xilflash_cfi.h"

Functions

int XFlash_Initialize (XFlash *InstancePtr, u32 BaseAddress, u8 BusWidth, int IsPlatformFlash)
int XFlash_Read (XFlash *InstancePtr, u32 Offset, u32 Bytes, void *DestPtr)
int XFlash_Write (XFlash *InstancePtr, u32 Offset, u32 Bytes, void *SrcPtr)
int XFlash_Erase (XFlash *InstancePtr, u32 Offset, u32 Bytes)
int XFlash_Lock (XFlash *InstancePtr, u32 Offset, u32 Bytes)
int XFlash_Unlock (XFlash *InstancePtr, u32 Offset, u32 Bytes)
int XFlash_Reset (XFlash *InstancePtr)
int XFlash_DeviceControl (XFlash *InstancePtr, u32 Command, DeviceCtrlParam *Parameters)
int XFlash_IsReady (XFlash *InstancePtr)
int XFlashGeometry_ToAbsolute (XFlashGeometry *InstancePtr, u16 Region, u16 Block, u32 BlockOffset, u32 *AbsoluteOffsetPtr)
int XFlashGeometry_ToBlock (XFlashGeometry *InstancePtr, u32 AbsoluteOffset, u16 *RegionPtr, u16 *BlockPtr, u32 *BlockOffsetPtr)

Detailed Description

This file contains the library functions to Initialize, Read, Write, Erase, Lock and Unlock the Parallel Flash Device. The family specific functionalities are implemented in DeviceControl API. Refer xilflash.h for detailed description.

Note:
None
 MODIFICATION HISTORY:

 Ver   Who  Date     Changes
 ----- ---- -------- -----------------------------------------------
 1.00a rmm  10/20/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  06/16/09 Added support for multiple banks in Intel flash.
                     Added support for Xilinx Platform Flash XL. If the
                     user selects to use the Xilinx Platfrom Flash XL then
                     it is set to Async mode during the initialization.
                     If the user wants to use it in Sync mode then it can be
                     done using the XFlash_DeviceControl API.
 2.00a ktn  12/04/09 Updated to use the HAL processor APIs/macros.
 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.
 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.
 

Function Documentation

int XFlash_DeviceControl XFlash InstancePtr,
u32  Command,
DeviceCtrlParam *  Parameters
 

This function is used to execute device specific commands. For a list of device specific commands, see the xilflash.h.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Command is the device specific command to issue.
Parameters specifies the arguments passed to the device control function.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_NOT_SUPPORTED if the command is not recognized/supported by the device(s).
Note:
None.

int XFlash_Erase XFlash InstancePtr,
u32  Offset,
u32  Bytes
 

This function erases the specified address range in the flash device. The number of bytes to erase can be any number as long as it is within the bounds of the device(s).

The device is polled until an error or the operation completes successfully.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Offset is the offset into the device(s) address space from which to begin erasure.
Bytes is the number of bytes to erase.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the destination address range is not completely within the addressable areas of the device(s).
Note:
Due to flash memory design, the range actually erased may be larger than what was specified by the Offset & Bytes parameters. This will occur if the parameters do not align to block boundaries.

int XFlash_Initialize XFlash InstancePtr,
u32  BaseAddress,
u8  BusWidth,
int  IsPlatformFlash
 

Initializes a specific XFlash instance. The initialization entails:

  • Check the Device family type.
  • Issuing the CFI query command.
  • Get and translate relevant CFI query information.
  • Set default options for the instance.
  • Setup the VTable.
  • Call the family initialize function of the instance.
  • Initialize the Xilinx Platform Flash XL to Async mode if the user selects to use the Platform Flash XL in the MLD. The Platform Flash XL is an Intel CFI complaint device.

Parameters:
InstancePtr is a pointer to the XFlash instance.
BaseAddress is the base address of the flash memory.
BusWidth is the total width of the flash memory, in bytes.
IsPlatformFlash is used to specify if the flash is a platform flash.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_PART_NOT_SUPPORTED if the command set algorithm or Layout is not supported by any flash family compiled into the system.
  • XFLASH_CFI_QUERY_ERROR if the device would not enter CFI query mode. Either the device(s) do not support CFI, the wrong BaseAddress param was used, an unsupported part layout exists, or a hardware problem exists with the part.
Note:
BusWidth is not the width of an individual part. Its the total operating width. For example, if there are two 16-bit parts, with one tied to data lines D0-D15 and other tied to D15-D31, BusWidth would be (32 / 8) = 4. If a single 16-bit flash is in 8-bit mode, then BusWidth should be (8 / 8) = 1.

int XFlash_IsReady XFlash InstancePtr  ) 
 

Checks the readiness of the device, which means it has been successfully initialized.

Parameters:
InstancePtr is a pointer to the XFlash instance.
Returns:
TRUE if the device has been initialized (but not necessarily started), and FALSE otherwise.
Note:
None.

int XFlash_Lock XFlash InstancePtr,
u32  Offset,
u32  Bytes
 

This function Locks the blocks in the specified range of the flash device(s).

The device is polled until an error or the operation completes successfully.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Offset is the offset into the device(s) address space from which to begin block locking. The first three bytes of every block is reserved for special purpose. The offset should be atleast three bytes from start of the block.
Bytes indicates the number of bytes to Lock in the Block starting from Offset.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the destination address range is not completely within the addressable areas of the device(s).
Note:
Due to flash memory design, the range actually locked may be larger than what was specified by the Offset & Bytes parameters. This will occur if the parameters do not align to block boundaries.

int XFlash_Read XFlash InstancePtr,
u32  Offset,
u32  Bytes,
void *  DestPtr
 

This function reads the data from the Flash device and copies it into the specified user buffer. The source and destination addresses can be on any alignment supported by the processor.

The device is polled until an error or the operation completes successfully.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Offset is the offset into the device(s) address space from which to read.
Bytes is the number of bytes to copy.
DestPtr is the destination address to copy data to.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the source address does not start within the addressable areas of the device(s).
Note:
This function allows the transfer of data past the end of the device's address space. If this occurs, then results are undefined.

int XFlash_Reset XFlash InstancePtr  ) 
 

This function resets the flash device and places it in read mode.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_BUSY if the flash devices were in the middle of an operation and could not be reset.
  • XFLASH_ERROR if the device(s) have experienced an internal error during the operation. XFlash_DeviceControl() must be used to access the cause of the device specific error. condition.
Note:
None.

int XFlash_Unlock XFlash InstancePtr,
u32  Offset,
u32  Bytes
 

This function Unlocks the blocks in the specified range of the flash device(s).

The device is polled until an error or the operation completes successfully.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Offset is the offset into the device(s) address space from which to begin block UnLocking. The first three bytes of every block is reserved for special purpose. The offset should be atleast three bytes from start of the block.
Bytes indicates the number of bytes to UnLock in the Block starting from Offset.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the destination address range is not completely within the addressable areas of the device(s).
Note:
None.

int XFlash_Write XFlash InstancePtr,
u32  Offset,
u32  Bytes,
void *  SrcPtr
 

This function programs the flash device(s) with data specified in the user buffer. The source and destination address must be aligned to the width of the flash's data bus.

The device is polled until an error or the operation completes successfully.

Parameters:
InstancePtr is the pointer to the XFlash instance.
Offset is the offset into the device(s) address space from which to begin programming. Must be aligned to the width of the flash's data bus.
Bytes is the number of bytes to program.
SrcPtr is the source address containing data to be programmed. Must be aligned to the width of the flash's data bus. The SrcPtr doesn't have to be aligned to the flash width if the processor supports unaligned access. But, since this library is generic, and some processors (eg. Microblaze) do not support unaligned access; this API requires the SrcPtr to be aligned.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ERROR if a write error occurred. This error is usually device specific. Use XFlash_DeviceControl() to retrieve specific error conditions. When this error is returned, it is possible that the target address range was only partially programmed.
Note:
None.

int XFlashGeometry_ToAbsolute XFlashGeometry InstancePtr,
u16  Region,
u16  Block,
u32  BlockOffset,
u32 *  AbsoluteOffsetPtr
 

Converts block coordinates to a part offset. Region, Block, & BlockOffset are converted to PartOffset

Parameters:
InstancePtr is the pointer to the XFlash instance.
Region is the erase region the physical address appears in.
Block is the block within Region the physical address appears in.
BlockOffset is the offset within Block where the physical address appears.
AbsoluteOffsetPtr is the returned offset value.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the block coordinates are invalid.
Note:
None.

int XFlashGeometry_ToBlock XFlashGeometry InstancePtr,
u32  AbsoluteOffset,
u16 *  RegionPtr,
u16 *  BlockPtr,
u32 *  BlockOffsetPtr
 

Converts part offset block coordinates. PartOffset is converted to Region, Block & BlockOffset

Parameters:
InstancePtr is the pointer to the XFlashGeometry.
AbsoluteOffset is the offset within part to find block coordinates for.
RegionPtr is the region that corresponds to AbsoluteOffset. This is a return parameter.
BlockPtr is the block within Region that corresponds to AbsoluteOffset. This is a return parameter.
BlockOffsetPtr is the offset within Block that corresponds to AbsoluteOffset. This is a return parameter.
Returns:
  • XST_SUCCESS if successful.
  • XFLASH_ADDRESS_ERROR if the block coordinates are invalid.
Note:
None.


Generated on Thu Feb 13 14:37:13 2014 for 2014.1_doc by  doxygen 1.4.5