/* $Id: xflash_intel.h,v 1.3 2002/03/06 15:25:08 whittle Exp $ */
/******************************************************************************
*
*       XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"
*       AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND
*       SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,
*       OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,
*       APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION
*       THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,
*       AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE
*       FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY
*       WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE
*       IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR
*       REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF
*       INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
*       FOR A PARTICULAR PURPOSE.
*
*       (c) Copyright 2002 Xilinx Inc.
*       All rights reserved.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file xflash_intel.h
*
* This is an Intel specific Flash memory component driver for CFI enabled
* parts.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who  Date     Changes
* ----- ---- -------- -----------------------------------------------
* 1.00a rmm  07/16/01 First release
* </pre>
*
******************************************************************************/

#ifndef XFLASH_INTEL_H /* prevent circular inclusions */
#define XFLASH_INTEL_H /* by using protection macros */

/***************************** Include Files *********************************/

#include "xbasic_types.h"
#include "xflash.h"

/************************** Constant Definitions *****************************/

/*
 * XFlash_DeviceControl command list
 */
#define XFL_INTEL_DEVCTL_SET_RYBY       0  /* Set RYBY pin mode */
#define XFL_INTEL_DEVCTL_GET_LAST_ERROR 1  /* Retrieve the last error data */

/*
 * RYBY Options
 * These options control the RYBY signal. They can be accessed with the
 * XFL_INTEL_DEVCTL_SET_RYBY command.
 */
#define XFL_INTEL_RYBY_PULSE_OFF            0  /* Do not pulse */
#define XFL_INTEL_RYBY_PULSE_ON_ERASE       1  /* Pulse on erase complete
                                                  only */
#define XFL_INTEL_RYBY_PULSE_ON_PROG        2  /* Pulse on program complete
                                                  only */
#define XFL_INTEL_RYBY_PULSE_ON_ERASE_PROG  3  /* Pulse on erase & program
                                                  complete */

/*
 * Status register bit definitions. Use these bitmaps to decipher the
 * return value of the XFL_INTEL_DEVCTL_GET_LAST_ERROR command.
 */
#define XFL_INTEL_SR_WSM_READY              0x80
#define XFL_INTEL_SR_ERASE_SUSPENDED        0x40
#define XFL_INTEL_SR_ERASE_OR_UNLOCK_ERROR  0x20
#define XFL_INTEL_SR_PROG_OR_LOCK_ERROR     0x10
#define XFL_INTEL_SR_VOLTAGE_ERROR          0x08
#define XFL_INTEL_SR_WRITE_SUSPENDED        0x04
#define XFL_INTEL_SR_BLOCK_LOCKED_ERROR     0x02

/*
 * Extended capabilities list
 * These bits can be read with the XFL_INTEL_DEVCTL_GET_SUPPORT1 command.
 *
 * XFL_INTEL_SUPPORT1_CHIP_ERASE - The part supports the chip erase command.
 *
 * XFL_INTEL_SUPPORT1_SUSPEND_ERASE - The part supports suspension and
 *   resumption of an erase operation.
 *
 * XFL_INTEL_SUPPORT1_SUSPEND_PROG - The part supports suspension and
 *   resumption of a programming operation.
 *
 * XFL_INTEL_SUPPORT1_LEGACY_LOCK - The part supports legacy lock/unlock.
 *
 * XFL_INTEL_SUPPORT1_QUEUED_ERASE - The part supports the queueing up of
 *   erase blocks.
 *
 * XFL_INTEL_SUPPORT1_INSTANT_LOCK - The part supports instant individual
 *   block locking.
 *
 * XFL_INTEL_SUPPORT1_PROTECTION_BIT - The part supports protection bits.
 *
 * XFL_INTEL_SUPPORT1_PAGE_MODE_READ - The part supports page-mode reads.
 *
 * XFL_INTEL_SUPPORT1_SYNC_READ - The part supports synchronous reads.
 *
 */
#define XFL_INTEL_SUPPORT1_CHIP_ERASE      0x80000000UL
#define XFL_INTEL_SUPPORT1_SUSPEND_ERASE   0x40000000UL
#define XFL_INTEL_SUPPORT1_SUSPEND_PROG    0x20000000UL
#define XFL_INTEL_SUPPORT1_LEGACY_LOCK     0x10000000UL
#define XFL_INTEL_SUPPORT1_QUEUED_ERASE    0x08000000UL
#define XFL_INTEL_SUPPORT1_INSTANT_LOCK    0x04000000UL
#define XFL_INTEL_SUPPORT1_PROTECTION_BIT  0x02000000UL
#define XFL_INTEL_SUPPORT1_PAGE_MODE_READ  0x01000000UL
#define XFL_INTEL_SUPPORT1_SYNC_READ       0x00800000UL

/*
 * Suspension capabilities list
 *
 * XFL_INTEL_PROG_AFTER_ERASE_SUSPEND - The part supports programming
 *   after suspending an erase operation
 */
#define XFL_INTEL_SUSPEND_SUPPORT_PROG_AFTER_ERASE 0x00000001UL

/**************************** Type Definitions *******************************/


/***************** Macros (Inline Functions) Definitions *********************/


/************************** Function Prototypes ******************************/

XStatus XFlashIntel_Initialize(XFlash *InstancePtr);
XStatus XFlashIntel_SelfTest(XFlash *InstancePtr);
XStatus XFlashIntel_Reset(XFlash *InstancePtr);
XStatus XFlashIntel_SetOptions(XFlash *InstancePtr, Xuint32 OptionsFlag);
Xuint32 XFlashIntel_GetOptions(XFlash *InstancePtr);
XFlashProperties* XFlashIntel_GetProperties(XFlash *InstancePtr);
XFlashGeometry*   XFlashIntel_GetGeometry(XFlash *InstancePtr);
XStatus XFlashIntel_DeviceControl(XFlash *InstancePtr, Xuint32 Command,
                                  Xuint32 Param, Xuint32 *ReturnPtr);

/*
 * Non-geometry aware API
 */
XStatus XFlashIntel_Read(XFlash *InstancePtr, Xuint32 Offset, Xuint32 Bytes,
                         void* DestPtr);

XStatus XFlashIntel_Write(XFlash *InstancePtr, Xuint32 Offset, Xuint32 Bytes,
                          void* SrcPtr);

XStatus XFlashIntel_WriteSuspend(XFlash *InstancePtr, Xuint32 Offset);
XStatus XFlashIntel_WriteResume(XFlash *InstancePtr, Xuint32 Offset);

XStatus XFlashIntel_Erase(XFlash *InstancePtr, Xuint32 Offset, Xuint32 Bytes);
XStatus XFlashIntel_EraseSuspend(XFlash *InstancePtr, Xuint32 Offset);
XStatus XFlashIntel_EraseResume(XFlash *InstancePtr, Xuint32 Offset);

XStatus XFlashIntel_Lock(XFlash *InstancePtr, Xuint32 Offset, Xuint32 Bytes);
XStatus XFlashIntel_Unlock(XFlash *InstancePtr, Xuint32 Offset, Xuint32 Bytes);
XStatus XFlashIntel_GetStatus(XFlash *InstancePtr, Xuint32 Offset);

/*
 * Geometry aware API
 */
XStatus XFlashIntel_ReadBlock(XFlash *InstancePtr, Xuint16 Region, Xuint16 Block,
                              Xuint32 Offset, Xuint32 Bytes, void* DestPtr);

XStatus XFlashIntel_WriteBlock(XFlash *InstancePtr, Xuint16 Region, Xuint16 Block,
                               Xuint32 Offset, Xuint32 Bytes, void* SrcPtr);

XStatus XFlashIntel_WriteBlockSuspend(XFlash *InstancePtr, Xuint16 Region,
                                      Xuint16 Block, Xuint32 Offset);

XStatus XFlashIntel_WriteBlockResume(XFlash *InstancePtr, Xuint16 Region,
                                      Xuint16 Block, Xuint32 Offset);

XStatus XFlashIntel_EraseBlock(XFlash *InstancePtr, Xuint16 Region, Xuint16 Block,
                               Xuint16 NumBlocks);

XStatus XFlashIntel_EraseBlockSuspend(XFlash *InstancePtr, Xuint16 Region,
                                      Xuint16 Block);

XStatus XFlashIntel_EraseBlockResume(XFlash *InstancePtr, Xuint16 Region,
                                      Xuint16 Block);

XStatus XFlashIntel_LockBlock(XFlash *InstancePtr, Xuint16 Region, Xuint16 Block,
                              Xuint16 NumBlocks);

XStatus XFlashIntel_UnlockBlock(XFlash *InstancePtr, Xuint16 Region, Xuint16 Block,
                                Xuint16 NumBlocks);

XStatus XFlashIntel_GetBlockStatus(XFlash *InstancePtr, Xuint16 Region,
                                   Xuint16 Block);

/*
 * Other commands
 */
XStatus XFlashIntel_EraseChip(XFlash *InstancePtr);

#endif            /* end of protection macro */
