omap3530/beagle_drivers/wb/api/include/cyasmisc.h
changeset 27 117faf51deac
equal deleted inserted replaced
26:b7e488c49d0d 27:117faf51deac
       
     1 /* Cypress West Bridge API header file (cyasmisc.h)
       
     2  ## ===========================
       
     3  ##
       
     4  ##  Copyright Cypress Semiconductor Corporation, 2006-2009,
       
     5  ##  All Rights Reserved
       
     6  ##  UNPUBLISHED, LICENSED SOFTWARE.
       
     7  ##
       
     8  ##  CONFIDENTIAL AND PROPRIETARY INFORMATION
       
     9  ##  WHICH IS THE PROPERTY OF CYPRESS.
       
    10  ##
       
    11  ##  Use of this file is governed
       
    12  ##  by the license agreement included in the file
       
    13  ##
       
    14  ##     <install>/license/license.txt
       
    15  ##
       
    16  ##  where <install> is the Cypress software
       
    17  ##  installation root directory path.
       
    18  ##
       
    19  ## ===========================
       
    20 */
       
    21 
       
    22 #ifndef _INCLUDED_CYASMISC_H_
       
    23 #define _INCLUDED_CYASMISC_H_
       
    24 
       
    25 #include "cyashal.h"
       
    26 #include "cyastypes.h"
       
    27 #include "cyasmedia.h"
       
    28 
       
    29 #include "cyas_cplus_start.h"
       
    30 
       
    31 #define CY_AS_LEAVE_STANDBY_DELAY_CLOCK		(1)
       
    32 #define CY_AS_RESET_DELAY_CLOCK			(1)
       
    33 
       
    34 #define CY_AS_LEAVE_STANDBY_DELAY_CRYSTAL	(5)
       
    35 #define CY_AS_RESET_DELAY_CRYSTAL		(5)
       
    36 
       
    37 /* The maximum number of buses supported */
       
    38 #define	CY_AS_MAX_BUSES				        (2)
       
    39 
       
    40 /* The maximum number of storage devices supported per bus */
       
    41 #define	CY_AS_MAX_STORAGE_DEVICES			(1)
       
    42 
       
    43 #define CY_AS_FUNCTCBTYPE_DATA_MASK (0x60000000U)
       
    44 #define CY_AS_FUNCTCBTYPE_TYPE_MASK (0x1FFFFFFFU)
       
    45 
       
    46 #define CyAsFunctCBTypeGetType(t) ((CyAsFunctCBType)((t) & CY_AS_FUNCTCBTYPE_TYPE_MASK))
       
    47 #define CyAsFunctCBTypeContainsData(t) (((CyAsFunctCBType)((t) & CY_AS_FUNCTCBTYPE_DATA_MASK)) == CY_FUNCT_CB_DATA)
       
    48 
       
    49 /*****************************************************************************
       
    50  * West Bridge Types
       
    51  ****************************************************************************/
       
    52 
       
    53 /* Summary
       
    54    Specifies a handle to an West Bridge device
       
    55    
       
    56    Description
       
    57    This type represents an opaque handle to an West Bridge device.  This handle is
       
    58    created via the CyAsMiscCreateDevice() function and is used in all subsequent
       
    59    calls that communicate to the West Bridge device.
       
    60 
       
    61    See Also
       
    62    * CyAsMiscCreateDevice
       
    63    * CyAsMiscDestroyDevice
       
    64 */
       
    65 typedef void * CyAsDeviceHandle ;
       
    66 
       
    67 /* Summary
       
    68    This data type gives the mode for the DACK# signal
       
    69 */
       
    70 typedef enum CyAsDeviceDackMode
       
    71 {
       
    72     CyAsDeviceDackAck,		    /* Operate in the ACK mode */
       
    73     CyAsDeviceDackEob		    /* Operate in the EOB mode */
       
    74 } CyAsDeviceDackMode ;
       
    75 
       
    76 /* Summary
       
    77    This data structure gives the options for all hardware features.
       
    78 
       
    79    Description
       
    80    This structure contains the information required to initialize the West Bridge hardware.
       
    81    Any features of the device that can be configured by the caller are specified here.
       
    82    
       
    83    See Also
       
    84    * CyAsMiscConfigure
       
    85 */
       
    86 typedef struct CyAsDeviceConfig
       
    87 {
       
    88     CyBool                              srammode ;      /* If TRUE, the P port is running in SRAM mode. */
       
    89     CyBool				sync ;		/* If TRUE, the P port is synchronous, otherwise async */
       
    90     CyBool				dmaintr ;	/* If TRUE, DMA req will be delivered via the interrupt signal */
       
    91     CyAsDeviceDackMode			dackmode ;	/* Mode for the DACK# signal */
       
    92     CyBool				drqpol ;	/* If TRUE, the DRQ line is active high, otherwise active low */
       
    93     CyBool				dackpol ;	/* If TRUE, the DACK line is active high, otherwise active low */
       
    94     CyBool				crystal ;	/* If TRUE, the clock is connected to a crystal, otherwise it is
       
    95 							   connected to a clock */
       
    96 } CyAsDeviceConfig ;
       
    97 
       
    98 
       
    99 /* Summary
       
   100    Specifies a resource that can be owned by either the West Bridge device or by the processor.
       
   101  
       
   102    Description
       
   103    This enumerated type identifies a resource that can be owned either by
       
   104    the West Bridge device, or by the processor attached to the P port of the
       
   105    West Bridge device.
       
   106 
       
   107    See Also
       
   108    * CyAsMiscAcquireResource
       
   109    * CyAsMiscReleaseResource
       
   110 */
       
   111 typedef enum CyAsResourceType
       
   112 {
       
   113     CyAsBusUSB = 0, /* The USB D+ and D- pins */
       
   114     CyAsBus_1  = 1, /* The SDIO bus */
       
   115     CyAsBus_0  = 2	/* The NAND bus (not implemented) */
       
   116 } CyAsResourceType;
       
   117 
       
   118 /* Summary
       
   119    Specifies the reset type for a software reset operation.
       
   120 
       
   121    Description
       
   122    When the West Bridge device is reset, there are two types of reset that are
       
   123    possible.  This type indicates the type of reset requested.
       
   124 
       
   125    Notes
       
   126    Both of these reset types are software based resets; and are distinct from
       
   127    a chip level HARD reset that is applied through the reset pin on the West Bridge.
       
   128 
       
   129    The CyAsResetSoft type resets only the on-chip micro-controller in the West Bridge.
       
   130    In this case, the previously loaded firmware will continue running. However,
       
   131    the Storage and USB stack operations will need to be restarted, as any state
       
   132    relating to these would have been lost.
       
   133 
       
   134    The CyAsResetHard type resets the entire West Bridge chip, and will need a fresh
       
   135    configuration and firmware download.  
       
   136 
       
   137    See Also
       
   138    * <LINK CyAsMiscReset>
       
   139  */
       
   140 
       
   141 typedef enum CyAsResetType
       
   142 {
       
   143     CyAsResetSoft,					/* Just resets the West Bridge micro-controller */
       
   144     CyAsResetHard					/* Resets entire device, firmware must be reloaded and
       
   145 							   the West Bridge device must be re-initialized */
       
   146 } CyAsResetType;
       
   147 
       
   148 
       
   149 
       
   150 /* Summary
       
   151    This type specifies the polarity of the SD power pin.
       
   152 
       
   153    Description
       
   154    Sets the SD power pin ( port C, bit 6) to active low or active high.
       
   155 
       
   156 */
       
   157 
       
   158 typedef enum CyAsMiscSignalPolarity
       
   159 {
       
   160     CyAsMiscActiveHigh,
       
   161     CyAsMiscActiveLow
       
   162 
       
   163 } CyAsMiscSignalPolarity ;
       
   164 
       
   165 
       
   166 
       
   167 /* Summary
       
   168    This type specifies the type of the data returned by a Function Callback.
       
   169 
       
   170    Description
       
   171    CY_FUNCT_CB_NODATA - This callback does not return any additional information in the data field.
       
   172    CY_FUNCT_CB_DATA   - The data field is used, and the CyAsFunctCBType will also contain the type of this data.
       
   173 
       
   174    See Also
       
   175    CyAsFunctionCallback
       
   176 */
       
   177 typedef enum CyAsFunctCBType
       
   178 {
       
   179     CY_FUNCT_CB_INVALID = 0x0U, 
       
   180     CY_FUNCT_CB_MISC_GETFIRMWAREVERSION,        /* Data from a CyAsMiscGetFirmwareVersion call. */
       
   181     CY_FUNCT_CB_MISC_HEARTBEATCONTROL,          /* Data from a CyAsMiscHeartBeatControl call. */
       
   182     CY_FUNCT_CB_MISC_ACQUIRERESOURCE,           /* Data from a CyAsMiscAcquireResource call. */
       
   183     CY_FUNCT_CB_MISC_READMCUREGISTER,           /* Data from a CyAsMiscReadMCURegister call. */
       
   184     CY_FUNCT_CB_MISC_WRITEMCUREGISTER,          /* Data from a CyAsMiscWriteMCURegister call. */
       
   185     CY_FUNCT_CB_MISC_SETTRACELEVEL,             /* Data from a CyAsMiscSetTraceLevel call. */
       
   186     CY_FUNCT_CB_MISC_STORAGECHANGED,            /* Data from a CyAsMiscStorageChanged call. */
       
   187     CY_FUNCT_CB_MISC_GETGPIOVALUE,              /* Data from a CyAsMiscGetGpioValue call. */
       
   188     CY_FUNCT_CB_MISC_SETGPIOVALUE,              /* Data from a CyAsMiscSetGpioValue call. */
       
   189     CY_FUNCT_CB_MISC_DOWNLOADFIRMWARE,          /* Data from a CyAsMiscDownloadFirmware call. */
       
   190     CY_FUNCT_CB_MISC_ENTERSTANDBY,		/* Data from a CyAsMiscEnterStandby call. */
       
   191     CY_FUNCT_CB_MISC_ENTERSUSPEND,              /* Data from a CyAsMiscEnterSuspend call. */
       
   192     CY_FUNCT_CB_MISC_LEAVESUSPEND,              /* Data from a CyAsMiscLeaveSuspend call. */
       
   193     CY_FUNCT_CB_MISC_RESET,                     /* Data from a CyAsMiscReset call. */
       
   194     CY_FUNCT_CB_MISC_SETSDFREQ,                 /* Data from a CyAsMiscSetLowSpeedSDFreq or CyAsMiscSetHighSpeedSDFreq call. */
       
   195     CY_FUNCT_CB_MISC_RESERVELNABOOTAREA,        /* Data from a CyAsMiscSwitchPnandMode call */
       
   196     CY_FUNCT_CB_MISC_SETSDPOLARITY,             /* Data from a CyAsMiscSetSDPowerPolarity call */
       
   197 
       
   198     CY_FUNCT_CB_STOR_START,                     /* Data from a CyAsStorageStart call. */
       
   199     CY_FUNCT_CB_STOR_STOP,                      /* Data from a CyAsStorageStop call. */
       
   200     CY_FUNCT_CB_STOR_CLAIM,                     /* Data from a CyAsStorageClaim call. */
       
   201     CY_FUNCT_CB_STOR_RELEASE,                   /* Data from a CyAsStorageRelease call. */
       
   202     CY_FUNCT_CB_STOR_QUERYMEDIA,                /* Data from a CyAsStorageQueryMedia call. */
       
   203     CY_FUNCT_CB_STOR_QUERYBUS,                  /* Data from a CyAsStorageQueryBus call. */
       
   204     CY_FUNCT_CB_STOR_QUERYDEVICE,               /* Data from a CyAsStorageQueryDevice call. */
       
   205     CY_FUNCT_CB_STOR_QUERYUNIT,                 /* Data from a CyAsStorageQueryUnit call. */
       
   206     CY_FUNCT_CB_STOR_DEVICECONTROL,             /* Data from a CyAsStorageDeviceControl call. */
       
   207     CY_FUNCT_CB_STOR_SDREGISTERREAD,            /* Data from a CyAsStorageSDRegisterRead call. */
       
   208     CY_FUNCT_CB_STOR_PARTITION,                 /* Data from a CyAsStorageCreatePartition call. */
       
   209     CY_FUNCT_CB_STOR_GETTRANSFERAMOUNT,		/* Data from a CyAsStorageGetTransferAmount call. */
       
   210     CY_FUNCT_CB_STOR_ERASE,			/* Data from a CyAsStorageErase call. */
       
   211     CY_FUNCT_CB_ABORT_P2S_XFER,                 /* Data from a CyAsStorageCancelAsync call. */
       
   212     CY_FUNCT_CB_USB_START,                      /* Data from a CyAsUsbStart call. */
       
   213     CY_FUNCT_CB_USB_STOP,                       /* Data from a CyAsUsbStop call. */
       
   214     CY_FUNCT_CB_USB_CONNECT,                    /* Data from a CyAsUsbConnect call. */
       
   215     CY_FUNCT_CB_USB_DISCONNECT,                 /* Data from a CyAsUsbDisconnect call. */
       
   216     CY_FUNCT_CB_USB_SETENUMCONFIG,              /* Data from a CyAsUsbSetEnumConfig call. */
       
   217     CY_FUNCT_CB_USB_GETENUMCONFIG,              /* Data from a CyAsUsbGetEnumConfig call. */
       
   218     CY_FUNCT_CB_USB_SETDESCRIPTOR,              /* Data from a CyAsUsbSetDescriptor call. */
       
   219     CY_FUNCT_CB_USB_GETDESCRIPTOR,              /* Data from a CyAsUsbGetDescriptor call. */
       
   220     CY_FUNCT_CB_USB_COMMITCONFIG,               /* Data from a CyAsUsbCommitConfig call. */
       
   221     CY_FUNCT_CB_USB_GETNAK,			/* Data from a CyAsUsbGetNak call. */
       
   222     CY_FUNCT_CB_USB_GETSTALL,			/* Data from a CyAsUsbGetStall call. */
       
   223     CY_FUNCT_CB_USB_SIGNALREMOTEWAKEUP,         /* Data from a CyAsUsbSignalRemoteWakeup call. */
       
   224     CY_FUNCT_CB_USB_CLEARDESCRIPTORS,           /* Data from a CyAnUsbClearDescriptors call. */
       
   225     CY_FUNCT_CB_USB_SET_MSREPORT_THRESHOLD,     /* Data from a CyAnUsbSetMSReportThreshold call. */
       
   226     CY_FUNCT_CB_MTP_START,			/* Data from a CyAsMTPStart call. */
       
   227     CY_FUNCT_CB_MTP_STOP,			/* Data from a CyAsMTPStop call. */
       
   228     CY_FUNCT_CB_MTP_INIT_SEND_OBJECT,		/* Data from a CyAsMTPInitSendObject call. */
       
   229     CY_FUNCT_CB_MTP_CANCEL_SEND_OBJECT,		/* Data from a CyAsMTPCancelSendObject call. */
       
   230     CY_FUNCT_CB_MTP_INIT_GET_OBJECT,		/* Data from a CyAsMTPInitGetObject call. */
       
   231     CY_FUNCT_CB_MTP_CANCEL_GET_OBJECT,		/* Data from a CyAsMTPCancelGetObject call. */
       
   232     CY_FUNCT_CB_MTP_SEND_BLOCK_TABLE,		/* Data from a CyAsMTPSendBlockTable call. */
       
   233     CY_FUNCT_CB_MTP_STOP_STORAGE_ONLY,		/* Data from a CyAsMTPStopStorageOnly call. */
       
   234     CY_FUNCT_CB_NODATA = 0x40000000U,
       
   235     CY_FUNCT_CB_DATA =   0x20000000U
       
   236 } CyAsFunctCBType ;
       
   237 
       
   238 /* Summary
       
   239    This type specifies the general West Bridge function callback.
       
   240 
       
   241    Description
       
   242    This callback is supplied as an argument to all asynchronous functions in the API. It is
       
   243    called after the asynchronous function has completed. 
       
   244 
       
   245    See Also
       
   246    CyAsFunctCBType
       
   247 */
       
   248 typedef void (*CyAsFunctionCallback)(
       
   249     CyAsDeviceHandle	handle,
       
   250     CyAsReturnStatus_t	status,
       
   251     uint32_t		client,
       
   252     CyAsFunctCBType	type,
       
   253     void*		data) ;
       
   254 
       
   255 /* Summary
       
   256    This type specifies the general West Bridge event that has occurred.
       
   257 
       
   258    Description
       
   259    This type is used in the West Bridge misc callback function to indicate the type
       
   260    of callback.
       
   261 
       
   262    See Also
       
   263 */
       
   264 typedef enum CyAsMiscEventType
       
   265 {
       
   266     CyAsEventMiscInitialized = 0,		/* This event is sent when West Bridge has finished
       
   267 						   initialization and is ready to respond to 
       
   268 						   API calls. */
       
   269 
       
   270     CyAsEventMiscAwake,				/* This event is sent when West Bridge has left the
       
   271 						   standby state and is ready to respond to commands
       
   272 						   again. */
       
   273 
       
   274     CyAsEventMiscHeartBeat,                     /* This event is sent periodically from the firmware
       
   275                                                    to the processor. */
       
   276 
       
   277     CyAsEventMiscWakeup,                        /* This event is sent when the West Bridge has left the
       
   278                                                    suspend mode and is ready to respond to commands
       
   279                                                    again. */
       
   280 
       
   281     CyAsEventMiscDeviceMismatch                 /* This event is sent when the firmware image downloaded
       
   282                                                    cannot run on the active West Bridge device. */
       
   283 } CyAsMiscEventType ;
       
   284 
       
   285 /* Summary
       
   286    This type is the type of a callback function that is called when a West Bridge misc event occurs.
       
   287 
       
   288    Description
       
   289    At times West Bridge needs to inform the P port processor of events that have
       
   290    occurred.  These events are asynchronous to the thread of control on the P
       
   291    port processor and as such are generally delivered via a callback function that
       
   292    is called as part of an interrupt handler.  This type defines the type of function
       
   293    that must be provided as a callback function for West Bridge misc events.
       
   294 
       
   295    See Also
       
   296    * CyAsMiscEventType
       
   297 */
       
   298 typedef void (*CyAsMiscEventCallback)(
       
   299     CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   300     CyAsMiscEventType		ev,		/* The event type being reported */
       
   301     void *			evdata		/* The data assocaited with the event being reported */
       
   302 ) ;
       
   303 
       
   304 #ifndef __doxygen__
       
   305 /* Summary
       
   306    This enum provides info of various firmware trace levels.
       
   307 
       
   308    Description
       
   309    
       
   310    See Also
       
   311    * CyAsMiscSetTraceLevel
       
   312 */
       
   313 enum {
       
   314     CYAS_FW_TRACE_LOG_NONE = 0,         /* Log nothing. */
       
   315     CYAS_FW_TRACE_LOG_STATE,            /* Log state information. */
       
   316     CYAS_FW_TRACE_LOG_CALLS,            /* Log function calls. */
       
   317     CYAS_FW_TRACE_LOG_STACK_TRACE,      /* Log function calls with args. */
       
   318     CYAS_FW_TRACE_MAX_LEVEL             /* Max trace level sentinel. */
       
   319 };
       
   320 #endif
       
   321 
       
   322 /* Summary
       
   323    This enum lists the controllable GPIOs of the West Bridge device.
       
   324 
       
   325    Description
       
   326    The West Bridge device has GPIOs that can be used for user defined functions.
       
   327    This enumeration lists the GPIOs that are available on the device.
       
   328 
       
   329    Notes
       
   330    All of the GPIOs except UVALID can only be accessed when using West Bridge
       
   331    firmware images that support only SD/MMC/MMC+ storage devices. This
       
   332    functionality is not supported in firmware images that support NAND
       
   333    storage.
       
   334 
       
   335    See Also
       
   336    * CyAsMiscGetGpioValue
       
   337    * CyAsMiscSetGpioValue
       
   338  */
       
   339 typedef enum {
       
   340     CyAsMiscGpio_0 = 0,                 /* GPIO[0] pin */
       
   341     CyAsMiscGpio_1,                     /* GPIO[1] pin */
       
   342     CyAsMiscGpio_Nand_CE,               /* NAND_CE pin, output only */
       
   343     CyAsMiscGpio_Nand_CE2,              /* NAND_CE2 pin, output only */
       
   344     CyAsMiscGpio_Nand_WP,               /* NAND_WP pin, output only */
       
   345     CyAsMiscGpio_Nand_CLE,              /* NAND_CLE pin, output only */
       
   346     CyAsMiscGpio_Nand_ALE,              /* NAND_ALE pin, output only */
       
   347     CyAsMiscGpio_SD_POW,                /* SD_POW pin, output only, do not drive low while storage is active */
       
   348     CyAsMiscGpio_UValid                 /* UVALID pin */
       
   349 } CyAsMiscGpio;
       
   350 
       
   351 /* Summary
       
   352    This enum lists the set of clock frequencies that are supported for working
       
   353    with low speed SD media.
       
   354 
       
   355    Description
       
   356    West Bridge firmware uses a clock frequency less than the maximum possible rate
       
   357    for low speed SD media.  This can be changed to a setting equal to the maximum
       
   358    frequency as desired by the user.  This enumeration lists the different
       
   359    frequency settings that are supported.
       
   360 
       
   361    See Also
       
   362    * CyAsMiscSetLowSpeedSDFreq
       
   363  */
       
   364 typedef enum CyAsLowSpeedSDFreq
       
   365 {
       
   366     CY_AS_SD_DEFAULT_FREQ = 0,          /* Approx. 21.82 MHz, default value */
       
   367     CY_AS_SD_RATED_FREQ                 /* 24 MHz */
       
   368 } CyAsLowSpeedSDFreq ;
       
   369 
       
   370 /* Summary
       
   371    This enum lists the set of clock frequencies that are supported for working
       
   372    with high speed SD media.
       
   373 
       
   374    Description
       
   375    West Bridge firmware uses a 48 MHz clock by default to interface with high speed
       
   376    SD/MMC media.  This can be changed to 24 MHz if so desired by the user.  This enum
       
   377    lists the different frequencies that are supported.
       
   378 
       
   379    See Also
       
   380    * CyAsMiscSetHighSpeedSDFreq
       
   381  */
       
   382 typedef enum CyAsHighSpeedSDFreq
       
   383 {
       
   384     CY_AS_HS_SD_FREQ_48,                /* 48 MHz, default value */
       
   385     CY_AS_HS_SD_FREQ_24                 /* 24 MHz */
       
   386 } CyAsHighSpeedSDFreq ;
       
   387 
       
   388 /* Summary
       
   389    Struct encapsulating all information returned by the CyAsMiscGetFirmwareVersion call.
       
   390 
       
   391    Description
       
   392    This struct encapsulates all return values from the asynchronous
       
   393    CyAsMiscGetFirmwareVersion call, so that a single data argument can be
       
   394    passed to the user provided callback function.
       
   395 
       
   396    See Also
       
   397    * CyAsMiscGetFirmwareVersion
       
   398  */
       
   399 typedef struct CyAsGetFirmwareVersionData
       
   400 {
       
   401     uint16_t 	major;		/* Return value for major version number for the firmware */
       
   402     uint16_t 	minor;		/* Return value for minor version number for the firmware */
       
   403     uint16_t 	build;		/* Return value for build version number for the firmware */
       
   404     uint8_t     mediaType;      /* Return value for media types supported in the current firmware */
       
   405     CyBool	isDebugMode;    /* Return value to indicate the release or debug mode of firmware */
       
   406 } CyAsGetFirmwareVersionData ;
       
   407 
       
   408 
       
   409 /*****************************************************************************
       
   410  * West Bridge Functions
       
   411  ****************************************************************************/
       
   412 
       
   413 /* Summary
       
   414    This function creates a new West Bridge device and returns a handle to the device.
       
   415 
       
   416    Description
       
   417    This function initializes the API object that represents the West Bridge device and
       
   418    returns a handle to this device.  This handle is required for all West Bridge related
       
   419    functions to identify the specific West Bridge device.
       
   420 
       
   421    * Valid In Asynchronous Callback: NO
       
   422 
       
   423    Returns
       
   424    * CY_AS_ERROR_SUCCESS
       
   425    * CY_AS_ERROR_OUT_OF_MEMORY
       
   426 */
       
   427 EXTERN CyAsReturnStatus_t
       
   428 CyAsMiscCreateDevice(
       
   429         CyAsDeviceHandle *		handle_p,	/* Return value for handle to created device */
       
   430         CyAsHalDeviceTag		tag		/* The HAL specific tag for this device */
       
   431         ) ;
       
   432 
       
   433 /* Summary
       
   434    This functions destroys a previously created West Bridge device.
       
   435 
       
   436    Description
       
   437    When an West Bridge device is created, an opaque handle is returned that represents
       
   438    the device.  This function destroys that handle and frees all resources associated
       
   439    with the handle.
       
   440 
       
   441    * Valid In Asynchronous Callback: NO
       
   442 
       
   443    Returns
       
   444    * CY_AS_ERROR_SUCCESS
       
   445    * CY_AS_ERROR_INVALID_HANDLE
       
   446    * CY_AS_ERROR_STILL_RUNNING - The USB or STORAGE stacks are still running, they must be stopped before the device can be destroyed
       
   447    * CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED - the HAL layer failed to destroy a sleep channel
       
   448 */
       
   449 EXTERN CyAsReturnStatus_t
       
   450 CyAsMiscDestroyDevice(
       
   451         CyAsDeviceHandle		handle		/* Handle to the device to destroy */
       
   452         ) ;
       
   453 
       
   454 /* Summary
       
   455    This function initializes the hardware for basic communication with West Bridge.
       
   456 
       
   457    Description
       
   458    This function intializes the hardware to establish basic communication with
       
   459    the West Bridge device.  This is always the first function called to initialize
       
   460    communication with the West Bridge device.
       
   461 
       
   462    * Valid In Asynchronous Callback: NO
       
   463 
       
   464    Returns
       
   465    * CY_AS_ERROR_SUCCESS - the basic initialization was completed
       
   466    * CY_AS_ERROR_INVALID_HANDLE
       
   467    * CY_AS_ERROR_IN_STANDBY
       
   468    * CY_AS_ERROR_ALREADY_RUNNING
       
   469    * CY_AS_ERROR_OUT_OF_MEMORY
       
   470    * CY_AS_ERROR_NO_ANTIOCH - cannot find the West Bridge device
       
   471    * CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED - the HAL layer falied to create a sleep channel
       
   472 
       
   473    See Also
       
   474    * CyAsDeviceConfig
       
   475 */
       
   476 EXTERN CyAsReturnStatus_t
       
   477 CyAsMiscConfigureDevice(
       
   478         CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   479         CyAsDeviceConfig		*config_p	/* Configuration information */
       
   480         ) ;
       
   481 
       
   482 /* Summary
       
   483    This function returns non-zero if West Bridge is in standby and zero otherwise.
       
   484 
       
   485    Description
       
   486    West Bridge supports a standby mode.  This function is used to query West Bridge to determine
       
   487    if West Bridge is in a standby mode.
       
   488 
       
   489    * Valid In Asynchronous Callback: YES
       
   490 
       
   491    Returns
       
   492    * CY_AS_ERROR_SUCCESS
       
   493    * CY_AS_ERROR_INVALID_HANDLE
       
   494 */
       
   495 EXTERN CyAsReturnStatus_t
       
   496 CyAsMiscInStandby(
       
   497         CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   498         CyBool			        *standby	/* Return value for standby state */
       
   499         ) ;
       
   500 
       
   501 /* Summary
       
   502    This function downloads the firmware to West Bridge device.
       
   503 
       
   504    Description
       
   505    This function downloads firmware from a given location and with a given size
       
   506    to the West Bridge device.  After the firmware is downloaded the West Bridge device is
       
   507    moved out of configuration mode causing the firmware to be executed.  It is an
       
   508    error to call this function when the device is not in configuration mode.  The
       
   509    device is in configuration mode on power up and may be placed in configuration
       
   510    mode after power up with a hard reset.
       
   511 
       
   512    Notes
       
   513    The firmware must be on a word align boundary.
       
   514 
       
   515    * Valid In Asynchronous Callback: YES (if cb supplied)
       
   516    * Nestable: YES
       
   517 
       
   518    Returns
       
   519    * CY_AS_ERROR_SUCCESS - the firmware was sucessfully downloaded
       
   520    * CY_AS_ERROR_INVALID_HANDLE
       
   521    * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device was not configured
       
   522    * CY_AS_ERROR_NOT_IN_CONFIG_MODE
       
   523    * CY_AS_ERROR_INVALID_SIZE - the size of the firmware exceeded 32768 bytes
       
   524    * CY_AS_ERROR_ALIGNMENT_ERROR
       
   525    * CY_AS_ERROR_IN_STANDBY - trying to download while in standby mode
       
   526    * CY_AS_ERROR_TIMEOUT
       
   527 
       
   528    See Also
       
   529    * CyAsMiscReset
       
   530 */
       
   531 EXTERN CyAsReturnStatus_t
       
   532 CyAsMiscDownloadFirmware(
       
   533         CyAsDeviceHandle	  handle,	/* Handle to the device to configure */
       
   534         const void 			  *fw_p,	/* Pointer to the firmware to be downloaded */
       
   535         uint16_t			  size,		/* The size of the firmware in bytes */
       
   536         CyAsFunctionCallback  cb,       /* Callback to call when the operation is complete. */
       
   537         uint32_t			  client    /* Client data to be passed to the callback. */
       
   538         ) ;
       
   539 
       
   540 
       
   541 /* Summary
       
   542    This function returns the version number of the firmware running in the West Bridge device.
       
   543 
       
   544    Description
       
   545    This function queries the West Bridge device and retreives the firmware version number.  If
       
   546    the firmware is not loaded an error is returned indicated no firmware has been loaded.
       
   547 
       
   548    * Valid In Asynchronous Callback: YES (if cb supplied)
       
   549    * Nestable: YES
       
   550 
       
   551    Returns
       
   552    * CY_AS_ERROR_SUCCESS - the firmware version number was retreived
       
   553    * CY_AS_ERROR_INVALID_HANDLE
       
   554    * CY_AS_ERROR_NOT_CONFIGURED
       
   555    * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been downloaded to the device
       
   556    * CY_AS_ERROR_IN_STANDBY
       
   557    * CY_AS_ERROR_OUT_OF_MEMORY
       
   558    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   559 */
       
   560 EXTERN CyAsReturnStatus_t
       
   561 CyAsMiscGetFirmwareVersion(
       
   562         CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   563         CyAsGetFirmwareVersionData*	data,           /* Return values indicating the firmware version. */
       
   564         CyAsFunctionCallback	        cb,             /* Callback to call when the operation is complete. */
       
   565         uint32_t			client          /* Client data to be passed to the callback. */
       
   566         ) ;
       
   567 
       
   568 #if !defined(__doxygen__)
       
   569 
       
   570 /* Summary
       
   571    This function reads and returns the contents of an MCU accessible register on the West Bridge.
       
   572 
       
   573    Description
       
   574    This function requests the firmware to read and return the contents of an MCU accessible
       
   575    register through the mailboxes.
       
   576 
       
   577    * Valid In Asynchronous Callback: YES (if cb supplied)
       
   578    * Nestable: YES
       
   579 
       
   580    Returns
       
   581    * CY_AS_ERROR_SUCCESS - the register content was retrieved.
       
   582    * CY_AS_ERROR_INVALID_HANDLE
       
   583    * CY_AS_ERROR_NOT_CONFIGURED
       
   584    * CY_AS_ERROR_NO_FIRMWARE
       
   585    * CY_AS_ERROR_OUT_OF_MEMORY
       
   586    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   587    * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not support this command.
       
   588 */
       
   589 EXTERN CyAsReturnStatus_t 
       
   590 CyAsMiscReadMCURegister(
       
   591 	CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   592 	uint16_t			address,	/* Address of the register to read */
       
   593 	uint8_t				*value,		/* Return value for the MCU register content */
       
   594 	CyAsFunctionCallback		cb,             /* Callback to call when the operation is complete. */
       
   595 	uint32_t			client          /* Client data to be passed to the callback. */
       
   596 	) ;
       
   597 
       
   598 /* Summary
       
   599    This function writes to an MCU accessible register on the West Bridge.
       
   600 
       
   601    Description
       
   602    This function requests the firmware to write a specified value to an MCU accessible
       
   603    register through the mailboxes.
       
   604 
       
   605    * Valid In Asynchronous Callback: YES (if cb supplied)
       
   606    * Nestable: YES
       
   607 
       
   608    Notes
       
   609    This function is only for internal use by the West Bridge API layer.  Calling
       
   610    this function directly can cause device malfunction.
       
   611 
       
   612    Returns
       
   613    * CY_AS_ERROR_SUCCESS - the register content was updated.
       
   614    * CY_AS_ERROR_INVALID_HANDLE
       
   615    * CY_AS_ERROR_NOT_CONFIGURED
       
   616    * CY_AS_ERROR_NO_FIRMWARE
       
   617    * CY_AS_ERROR_OUT_OF_MEMORY
       
   618    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   619    * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not support this command.
       
   620 */
       
   621 EXTERN CyAsReturnStatus_t 
       
   622 CyAsMiscWriteMCURegister(
       
   623         CyAsDeviceHandle        handle,		/* Handle to the device to configure */
       
   624         uint16_t                address,        /* Address of the register to write */
       
   625         uint8_t			mask,           /* Mask to be applied on the register contents. */
       
   626         uint8_t                 value,          /* Data to be ORed with the register contents. */
       
   627         CyAsFunctionCallback	cb,             /* Callback to call when the operation is complete. */
       
   628         uint32_t		client          /* Client data to be passed to the callback. */
       
   629         ) ;
       
   630 
       
   631 #endif
       
   632 
       
   633 /* Summary
       
   634    This function will reset the West Bridge device and software API.
       
   635 
       
   636    Description
       
   637    This function will reset the West Bridge device and software API.  The reset operation can be
       
   638    a hard reset or a soft reset.  A hard reset will reset all aspects of the West Bridge device.
       
   639    The device will enter the configuration state and the firmware will have to be reloaded.  The
       
   640    device will also have to be re-initialized.  A soft reset just resets the West Bridge micro-
       
   641    controller.
       
   642 
       
   643    * Valid In Asynchronous Callback: NO
       
   644 
       
   645    Notes
       
   646    When a hard reset is issued, the firmware that may have been previously loaded will be lost
       
   647    and any configuration information set via CyAsMiscConfigureDevice() will be lost.  This will be
       
   648    reflected in the API maintained state of the device.  In order to re-establish communications 
       
   649    with the West Bridge device, CyAsMiscConfigureDevice() and CyAsMiscDownloadFirmware() must be 
       
   650    called again.
       
   651 
       
   652    * Valid In Asynchronous Callback: YES (if cb supplied)
       
   653    * Nestable: YES
       
   654 
       
   655    Returns
       
   656    * CY_AS_ERROR_SUCCESS - the device has been reset
       
   657    * CY_AS_ERROR_INVALID_HANDLE
       
   658    * CY_AS_ERROR_NOT_CONFIGURED
       
   659    * CY_AS_ERROR_NO_FIRMWARE
       
   660    * CY_AS_ERROR_NOT_YET_SUPPORTED - current soft reset is not supported
       
   661    * CY_AS_ERROR_ASYNC_PENDING - Reset is unable to flush pending async reads/writes in polling mode.
       
   662 
       
   663 
       
   664       See Also
       
   665    * CyAsMiscReset
       
   666 */
       
   667 EXTERN CyAsReturnStatus_t
       
   668 CyAsMiscReset(
       
   669 	CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   670 	CyAsResetType			type,		/* The type of reset to perform */
       
   671 	CyBool				flush,		/* If true, flush all pending writes to mass storage
       
   672 							   before performing the reset. */
       
   673 	CyAsFunctionCallback		cb,             /* Callback to call when the operation is complete. */
       
   674 	uint32_t			client          /* Client data to be passed to the callback. */
       
   675 	) ;
       
   676 
       
   677 /* Summary
       
   678    This function acquires a given resource.
       
   679 
       
   680    Description
       
   681    There are resources in the system that are shared between the West Bridge device and the processor
       
   682    attached to the P port of the West Bridge device.  This API provides a mechanism for the P port
       
   683    processor to acquire ownership of a resource.
       
   684 
       
   685    Notes
       
   686    The ownership of the resources controlled by CyAsMiscAcquireResource() and CyAsMiscReleaseResource()
       
   687    defaults to a known state at hardware reset.  After the firmware is loaded and begins execution the
       
   688    state of these resources may change.  At any point if the P Port processor needs to acquire a resource
       
   689    it should do so explicitly to be sure of ownership.
       
   690 
       
   691    Returns
       
   692    * CY_AS_ERROR_SUCCESS - the p port sucessfully acquired the resource of interest
       
   693    * CY_AS_ERROR_INVALID_HANDLE
       
   694    * CY_AS_ERROR_NOT_CONFIGURED
       
   695    * CY_AS_ERROR_NO_FIRMWARE
       
   696    * CY_AS_ERROR_INVALID_RESOURCE
       
   697    * CY_AS_ERROR_RESOURCE_ALREADY_OWNED - the p port already owns this resource
       
   698    * CY_AS_ERROR_NOT_ACQUIRED - the resource cannot be acquired
       
   699    * CY_AS_ERROR_OUT_OF_MEMORY
       
   700    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   701 
       
   702    See Also
       
   703    * CyAsResourceType
       
   704 */
       
   705 EXTERN CyAsReturnStatus_t 
       
   706 CyAsMiscAcquireResource(
       
   707 	CyAsDeviceHandle	handle,		/* Handle to the device to configure */
       
   708 	CyAsResourceType	*resource,	/* The resource to acquire */
       
   709 	CyBool				force,		/* If true, force West Bridge to release the resource */
       
   710 	CyAsFunctionCallback cb,        /* Callback to call when the operation is complete. */
       
   711 	uint32_t			client      /* Client data to be passed to the callback. */
       
   712 	) ;
       
   713 
       
   714 /* Summary
       
   715    This function releases a given resource.
       
   716 
       
   717    Description
       
   718    There are resources in the system that are shared between the West Bridge device and the processor
       
   719    attached to the P port of the West Bridge device.  This API provides a mechanism for the P port
       
   720    processor to release a resource that has previously been acquired via the CyAsMiscAcquireResource()
       
   721    call.
       
   722 
       
   723    * Valid In Asynchronous Callback: NO
       
   724 
       
   725    Returns
       
   726    * CY_AS_ERROR_SUCCESS - the p port sucessfully released the resource of interest
       
   727    * CY_AS_ERROR_INVALID_HANDLE
       
   728    * CY_AS_ERROR_NOT_CONFIGURED
       
   729    * CY_AS_ERROR_NO_FIRMWARE
       
   730    * CY_AS_ERROR_INVALID_RESOURCE
       
   731    * CY_AS_ERROR_RESOURCE_NOT_OWNED - the p port does not own the resource of interest
       
   732 
       
   733    See Also
       
   734    * CyAsResourceType
       
   735    * CyAsMiscAcquireResource
       
   736 */
       
   737 EXTERN CyAsReturnStatus_t 
       
   738 CyAsMiscReleaseResource(
       
   739 	CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   740 	CyAsResourceType		resource	/* The resource to release */
       
   741 	) ;
       
   742 
       
   743 #ifndef __doxygen__
       
   744 /* Summary
       
   745    This function sets the trace level for the West Bridge firmware.
       
   746 
       
   747    Description
       
   748    The West Bridge firmware has the ability to store information about the state and execution path
       
   749    of the firmware on a mass storage device attached to the West Bridge device.  This function 
       
   750    configures the specific mass storage device to be used and the type of information to be
       
   751    stored.  This state information is used for debugging purposes and must be interpreted by a
       
   752    Cypress provided tool.
       
   753 
       
   754    *Trace Level*
       
   755    The trace level indicates the amount of information to output.
       
   756    * 0 = no trace information is output
       
   757    * 1 = state information is output
       
   758    * 2 = function call information is output
       
   759    * 3 = function call, arguments, and return value information is output
       
   760 
       
   761    * Valid In Asynchronous Callback: NO
       
   762 
       
   763    Notes
       
   764    The media device and unit specified in this call will be overwritten and any data currently stored
       
   765    on this device and unit will be lost.
       
   766 
       
   767    * NOT IMPLEMENTED YET
       
   768 
       
   769    Returns
       
   770    * CY_AS_ERROR_SUCCESS - the trace configuration has been sucessfully changed
       
   771    * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
       
   772    * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device pair does not exist
       
   773    * CY_AS_ERROR_NO_SUCH_UNIT - the unit specified does not exist
       
   774    * CY_AS_ERROR_INVALID_TRACE_LEVEL - the trace level requested does not exist
       
   775    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   776 */
       
   777 EXTERN CyAsReturnStatus_t
       
   778 CyAsMiscSetTraceLevel(
       
   779 	CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   780 	uint8_t				level,		/* The trace level */
       
   781 	CyAsBusNumber_t			bus,		/* The bus for the output */
       
   782 	uint32_t 			device,		/* The device for the output */
       
   783 	uint32_t			unit,		/* The unit for the output */
       
   784 	CyAsFunctionCallback		cb,             /* Callback to call when the operation is complete. */
       
   785 	uint32_t			client          /* Client data to be passed to the callback. */
       
   786 	) ;
       
   787 #endif
       
   788 
       
   789 /* Summary
       
   790    This function places West Bridge into the low power standby mode.
       
   791 
       
   792    Description
       
   793    This function places West Bridge into a low power (sleep) mode, and cannot be called while the
       
   794    USB stack is active.  This function first instructs the West Bridge firmware that the device is
       
   795    about to be placed into sleep mode.  This allows West Bridge to complete any pending storage
       
   796    operations.  After the West Bridge device has responded that pending operations are complete,
       
   797    the device is placed in standby mode.
       
   798   
       
   799    There are two methods of placing the device in standby mode.  If the WAKEUP pin of the West Bridge
       
   800    is connected to a GPIO on the processor, the pin is de-asserted (via the HAL layer) and West Bridge
       
   801    enters into a sleep mode.  If the WAKEUP pin is not accessible, the processor can write into
       
   802    the power management control/status register on the West Bridge to put the device into sleep mode.
       
   803 
       
   804    * Valid In Asynchronous Callback: YES (if cb supplied)
       
   805    * Nestable: YES
       
   806 
       
   807    Returns
       
   808    * CY_AS_ERROR_SUCCESS - the function completed and West Bridge is in sleep mode
       
   809    * CY_AS_ERROR_INVALID_HANDLE
       
   810    * CY_AS_ERROR_ALREADY_STANDBY - the West Bridge device is already in sleep mode
       
   811    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   812    * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support changing the WAKEUP pin
       
   813    * CY_AS_ERROR_USB_RUNNING - The USB stack is still running when the EnterStandby call is made
       
   814    * CY_AS_ERROR_ASYNC_PENDING
       
   815    * CY_AS_ERROR_OUT_OF_MEMORY
       
   816    * CY_AS_ERROR_INVALID_RESPONSE
       
   817    * CY_AS_ERROR_SETTING_WAKEUP_PIN
       
   818    * CY_AS_ERROR_ASYNC_PENDING - In polling mode EnterStandby can not be called until all pending
       
   819 				 storage read/write requests have finished.
       
   820 
       
   821    See Also
       
   822    * CyAsMiscLeaveStandby
       
   823 */
       
   824 EXTERN CyAsReturnStatus_t
       
   825 CyAsMiscEnterStandbyEXU(
       
   826 	CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   827 	CyBool				pin,		/* If true, use the wakeup pin, otherwise use the register */
       
   828 	CyBool				uvalid_special,	/* Set true to enable specific usages of the
       
   829 							   UVALID signal, please refer to AN xx or ERRATA xx */
       
   830 	CyAsFunctionCallback		cb,             /* Callback to call when the operation is complete. */
       
   831 	uint32_t			client          /* Client data to be passed to the callback. */
       
   832 	) ;
       
   833 
       
   834 /* Summary
       
   835    This function is provided for backwards compatibility.
       
   836 
       
   837    Description
       
   838    Calling this function is the same as calling CyAsMiscEnterStandbyEx with True for the lowpower parameter.
       
   839 
       
   840    See Also
       
   841    * CyAsMiscEnterStandbyEx
       
   842 */
       
   843 EXTERN CyAsReturnStatus_t
       
   844 CyAsMiscEnterStandby(CyAsDeviceHandle handle, 
       
   845 			CyBool pin,
       
   846 			CyAsFunctionCallback cb,
       
   847 			uint32_t client
       
   848 			) ;
       
   849 
       
   850 /* Summary
       
   851    This function brings West Bridge out of sleep mode.
       
   852 
       
   853    Description
       
   854    This function asserts the WAKEUP pin (via the HAL layer).  This brings the West Bridge out of the sleep
       
   855    state and allows the West Bridge firmware to process the event causing the wakeup.  When all processing
       
   856    associated with the wakeup is complete, a callback function is called to tell the P port software that
       
   857    the firmware processing associated with wakeup is complete.
       
   858 
       
   859    * Valid In Asynchronous Callback: NO
       
   860 
       
   861    Returns:
       
   862    * CY_AS_ERROR_SUCCESS - the function completed and West Bridge is in sleep mode
       
   863    * CY_AS_ERROR_INVALID_HANDLE
       
   864    * CY_AS_ERROR_SETTING_WAKEUP_PIN
       
   865    * CY_AS_ERROR_NOT_IN_STANDBY - the West Bridge device is not in the sleep state
       
   866    * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response from the West Bridge firmware
       
   867    * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support changing the WAKEUP pin
       
   868 
       
   869    See Also
       
   870    * CyAsMiscEnterStandby
       
   871 */
       
   872 EXTERN CyAsReturnStatus_t
       
   873 CyAsMiscLeaveStandby(
       
   874 	CyAsDeviceHandle		handle,		/* Handle to the device to configure */
       
   875 	CyAsResourceType		resource	/* The resource causing the wakeup */
       
   876 	) ;
       
   877 
       
   878 /* Summary
       
   879    This function registers a callback function to be called when an asynchronous West Bridge MISC event occurs.
       
   880 
       
   881    Description
       
   882    When asynchronous misc events occur, a callback function can be called to alert the calling program.  This
       
   883    functions allows the calling program to register a callback.
       
   884 
       
   885    * Valid In Asynchronous Callback: NO
       
   886 
       
   887    Returns:
       
   888    * CY_AS_ERROR_SUCCESS
       
   889    * CY_AS_ERROR_INVALID_HANDLE
       
   890 */
       
   891 EXTERN CyAsReturnStatus_t
       
   892 CyAsMiscRegisterCallback(
       
   893 	CyAsDeviceHandle		handle,		/* Handle to the West Bridge device */
       
   894 	CyAsMiscEventCallback		callback	/* The function to call */
       
   895 	) ;
       
   896 
       
   897 /* Summary
       
   898    This function sets the logging level for log messages.
       
   899 
       
   900    Description
       
   901    The API can print messages via the CyAsHalPrintMessage capability.  This function sets the
       
   902    level of detail seen when printing messages from the API.
       
   903 
       
   904    * Valid In Asynchronous Callback:NO
       
   905 */
       
   906 EXTERN void
       
   907 CyAsMiscSetLogLevel(
       
   908 	uint8_t				level		/* Level to set, 0 is fewer messages, 255 is all */
       
   909 	) ;
       
   910 
       
   911 
       
   912 /* Summary
       
   913    This function tells West Bridge that SD or MMC media has been inserted or removed.
       
   914 
       
   915    Description
       
   916    In some hardware configurations, SD or MMC media detection is handled outside of the
       
   917    West Bridge device.  This function is called when a change is detected to inform the
       
   918    West Bridge firmware to check for storage media changes.
       
   919 
       
   920    * Valid In Asynchronous Callback: NO
       
   921 
       
   922    Returns:
       
   923    * CY_AS_ERROR_SUCCESS
       
   924    * CY_AS_ERROR_INVALID_HANDLE
       
   925    * CY_AS_ERROR_NOT_CONFIGURED
       
   926    * CY_AS_ERROR_NO_FIRMWARE
       
   927    * CY_AS_ERROR_IN_STANDBY
       
   928    * CY_AS_ERROR_OUT_OF_MEMORY
       
   929    * CY_AS_ERROR_INVALID_RESPONSE
       
   930 
       
   931    See Also
       
   932    * CyAsMiscStorageChanged
       
   933 
       
   934 */
       
   935 EXTERN CyAsReturnStatus_t
       
   936 CyAsMiscStorageChanged(	
       
   937 	CyAsDeviceHandle		handle,	        /* Handle to the West Bridge device */
       
   938 	CyAsFunctionCallback		cb,		/* Callback to call when the operation is complete. */
       
   939 	uint32_t			client		/* Client data to be passed to the callback. */
       
   940 	) ;
       
   941 
       
   942 /* Summary
       
   943    This function instructs the West Bridge firmware to start/stop sending periodic
       
   944    heartbeat messages to the processor.
       
   945 
       
   946    Description
       
   947    The West Bridge firmware can send heartbeat messages through the mailbox register
       
   948    once every 500 ms. This message can be an overhead as it causes regular Mailbox
       
   949    interrupts to happen, and is turned off by default. The message can be used to
       
   950    test and verify that the West Bridge firmware is alive. This API can be used to
       
   951    enable or disable the heartbeat message.
       
   952 
       
   953    * Valid In Asynchronous Callback: NO
       
   954  
       
   955    Returns
       
   956    * CY_AS_ERROR_SUCCESS - the function completed successfully
       
   957    * CY_AS_ERROR_INVALID_HANDLE
       
   958    * CY_AS_ERROR_NOT_CONFIGURED
       
   959    * CY_AS_ERROR_NO_FIRMWARE
       
   960    * CY_AS_ERROR_OUT_OF_MEMORY
       
   961    * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not been configured yet
       
   962    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the West Bridge device
       
   963 
       
   964 */
       
   965 EXTERN CyAsReturnStatus_t
       
   966 CyAsMiscHeartBeatControl(
       
   967         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
   968         CyBool                          enable,         /* Message enable/disable selection */
       
   969 	CyAsFunctionCallback		cb,             /* Callback to call when the operation is complete. */
       
   970 	uint32_t			client          /* Client data to be passed to the callback. */
       
   971         ) ;
       
   972 
       
   973 /* Summary
       
   974    This function gets the current state of a GPIO pin on the West Bridge device.
       
   975 
       
   976    Description
       
   977    The West Bridge device has GPIO pins that can be used for user defined functions.
       
   978    This function gets the current state of the specified GPIO pin. Calling this
       
   979    function will configure the corresponding pin as an input.
       
   980 
       
   981    * Valid In Asynchronous Callback: NO
       
   982 
       
   983    Notes
       
   984    Only GPIO[0], GPIO[1] and UVALID pins can be used as GP inputs. Of these pins,
       
   985    only the UVALID pin is supported by firmware images that include NAND storage
       
   986    support.
       
   987 
       
   988    Returns
       
   989    * CY_AS_ERROR_SUCCESS - the function completed successfully
       
   990    * CY_AS_ERROR_INVALID_HANDLE
       
   991    * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not been configured yet
       
   992    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the West Bridge device
       
   993    * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
       
   994    * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported by the firmware
       
   995 
       
   996    See Also
       
   997    * CyAsMiscGpio
       
   998    * CyAsMiscSetGpioValue
       
   999  */
       
  1000 EXTERN CyAsReturnStatus_t
       
  1001 CyAsMiscGetGpioValue(
       
  1002         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
  1003         CyAsMiscGpio                    pin,            /* Id of the GPIO pin to query */
       
  1004         uint8_t                        *value,          /* Current value of the GPIO pin */
       
  1005         CyAsFunctionCallback            cb,             /* Callback to call when the operation is complete. */
       
  1006         uint32_t                        client          /* Client data to be passed to the callback. */
       
  1007         ) ;
       
  1008 
       
  1009 /* Summary
       
  1010    This function updates the state of a GPIO pin on the West Bridge device.
       
  1011 
       
  1012    Description
       
  1013    The West Bridge device has GPIO pins that can be used for user defined functions.
       
  1014    This function updates the output value driven on a specified GPIO pin. Calling this
       
  1015    function will configure the corresponding pin as an output.
       
  1016 
       
  1017    * Valid In Asynchronous Callback: NO
       
  1018 
       
  1019    Notes
       
  1020    All of the pins listed under CyAsMiscGpio can be used as GP outputs. This feature
       
  1021    is note supported by firmware images that include NAND storage device support.
       
  1022 
       
  1023    Returns
       
  1024    * CY_AS_ERROR_SUCCESS - the function completed successfully
       
  1025    * CY_AS_ERROR_INVALID_HANDLE
       
  1026    * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not been configured yet
       
  1027    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the West Bridge device
       
  1028    * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
       
  1029    * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported by firmware.
       
  1030 
       
  1031    See Also
       
  1032    * CyAsMiscGpio
       
  1033    * CyAsMiscGetGpioValue
       
  1034  */
       
  1035 EXTERN CyAsReturnStatus_t
       
  1036 CyAsMiscSetGpioValue(
       
  1037         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
  1038         CyAsMiscGpio                    pin,            /* Id of the GPIO pin to set */
       
  1039         uint8_t                         value,          /* Value to be set on the GPIO pin */
       
  1040         CyAsFunctionCallback            cb,             /* Callback to call when the operation is complete. */
       
  1041         uint32_t                        client          /* Client data to be passed to the callback. */
       
  1042         ) ;
       
  1043 
       
  1044 /* Summary
       
  1045    Set the West Bridge device in the low power suspend mode.
       
  1046 
       
  1047    Description
       
  1048    The West Bridge device has a low power suspend mode where the USB core and the internal
       
  1049    microcontroller are powered down.  This function sets the West Bridge device into this
       
  1050    low power mode.  This mode can only be entered when there is no active USB connection;
       
  1051    i.e., when USB has not been connected or is suspended; and there are no pending USB
       
  1052    or storage asynchronous calls.
       
  1053    The device will exit the suspend mode and resume handling USB and processor requests
       
  1054    when any activity is detected on the CE#, D+/D- or GPIO[0] lines.
       
  1055 
       
  1056    * Valid In Asynchronous Callback: NO
       
  1057 
       
  1058    Notes
       
  1059    The GPIO[0] pin needs to be configured as an input for the gpio wakeup to work.
       
  1060    This flag should not be enabled if the pin is being used as a GP output.
       
  1061 
       
  1062    Returns
       
  1063    * CY_AS_ERROR_SUCCESS - the device was placed in suspend mode.
       
  1064    * CY_AS_ERROR_INVALID_HANDLE - the West Bridge handle passed in is invalid.
       
  1065    * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not yet been configured.
       
  1066    * CY_AS_ERROR_NO_FIRMWARE - no firmware has been downloaded to the device.
       
  1067    * CY_AS_ERROR_IN_STANDBY - the device is already in sleep mode.
       
  1068    * CY_AS_ERROR_USB_CONNECTED - the USB connection is active.
       
  1069    * CY_AS_ERROR_ASYNC_PENDING - asynchronous storage/USB calls are pending.
       
  1070    * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the operation.
       
  1071    * CY_AS_ERROR_INVALID_RESPONSE - command not recognised by firmware.
       
  1072 
       
  1073    See Also
       
  1074    * CyAsMiscLeaveSuspend
       
  1075  */
       
  1076 EXTERN CyAsReturnStatus_t
       
  1077 CyAsMiscEnterSuspend(
       
  1078         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
  1079         CyBool                          usb_wakeup_en,  /* Control the USB wakeup source */
       
  1080         CyBool                          gpio_wakeup_en, /* Control the GPIO[0] wakeup source */
       
  1081         CyAsFunctionCallback            cb,             /* Callback to call when suspend mode entry is complete */
       
  1082         uint32_t                        client          /* Client data to be passed to the callback. */
       
  1083         ) ;
       
  1084 
       
  1085 /* Summary
       
  1086    Wake up the West Bridge device from suspend mode.
       
  1087 
       
  1088    Description
       
  1089    This call wakes up the West Bridge device from suspend mode, and makes it ready
       
  1090    for accepting other commands from the API.  A CyAsEventMiscWakeup event will
       
  1091    be delivered to the callback registered with CyAsMiscRegisterCallback to
       
  1092    indicate that the wake up is complete.
       
  1093 
       
  1094    The CyAsEventMiscWakeup event will also be delivered if the wakeup happens
       
  1095    due to USB or GPIO activity.
       
  1096 
       
  1097    * Valid In Asynchronous Callback: NO
       
  1098 
       
  1099    Returns
       
  1100    * CY_AS_ERROR_SUCCESS - the device was woken up from suspend mode.
       
  1101    * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
       
  1102    * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been configured.
       
  1103    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the device.
       
  1104    * CY_AS_ERROR_NOT_IN_SUSPEND - the device is not in suspend mode.
       
  1105    * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the operation.
       
  1106    * CY_AS_ERROR_TIMEOUT - failed to wake up the device.
       
  1107 
       
  1108    See Also
       
  1109    * CyAsMiscEnterSuspend
       
  1110  */
       
  1111 EXTERN CyAsReturnStatus_t
       
  1112 CyAsMiscLeaveSuspend(
       
  1113         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
  1114         CyAsFunctionCallback            cb,             /* Callback to call when device has resumed operation. */
       
  1115         uint32_t                        client          /* Client data to be passed to the callback. */
       
  1116         ) ;
       
  1117 
       
  1118 /* Summary
       
  1119    Reserve first numzones zones of nand device for storing processor boot image. LNA firmware works 
       
  1120    on the first numzones zones of nand to enable the processor to boot.
       
  1121 
       
  1122    Description
       
  1123    This function reserves first numzones zones of nand device for storing processor boot image. 
       
  1124    This fonction MUST be completed before starting the storage stack for the setting to be taken 
       
  1125    into account.
       
  1126 
       
  1127    * Valid In Asynchronous Callback: YES
       
  1128 
       
  1129    Returns
       
  1130    * CY_AS_ERROR_SUCCESS                   - zones are reserved.
       
  1131    
       
  1132 */
       
  1133 EXTERN CyAsReturnStatus_t
       
  1134 CyAsMiscReserveLNABootArea(
       
  1135         CyAsDeviceHandle     handle,         /* Handle to the West Bridge device */
       
  1136         uint8_t numzones,                    /* number of nand zones to reserve */
       
  1137         CyAsFunctionCallback cb,             /* Callback to call when device has resumed operation. */
       
  1138         uint32_t client                      /* Client data to be passed to the callback. */
       
  1139 		) ;
       
  1140 
       
  1141 /* Summary
       
  1142    Select the clock frequency to be used when talking to low speed (non-high speed)
       
  1143    SD media.
       
  1144    
       
  1145    Description
       
  1146    West Bridge firmware uses a clock frequency less than the maximum possible rate
       
  1147    for low speed SD media.  This function selects the frequency setting from between
       
  1148    the default speed and the maximum speed. This fonction MUST be completed before
       
  1149    starting the storage stack for the setting to be taken into account.
       
  1150 
       
  1151    * Valid in Asynchronous Callback: Yes (if cb is non-zero)
       
  1152    * Nestable: Yes
       
  1153 
       
  1154    Returns
       
  1155    * CY_AS_ERROR_SUCCESS - the operation completed successfully.
       
  1156    * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
       
  1157    * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been configured.
       
  1158    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the device.
       
  1159    * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the operation.
       
  1160    * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend mode.
       
  1161    * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting desired.
       
  1162    * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to the operation.
       
  1163    * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support the operation.
       
  1164 
       
  1165    See Also
       
  1166    * CyAsLowSpeedSDFreq
       
  1167  */
       
  1168 EXTERN CyAsReturnStatus_t
       
  1169 CyAsMiscSetLowSpeedSDFreq(
       
  1170         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
  1171         CyAsLowSpeedSDFreq              setting,        /* Frequency setting desired for low speed SD cards */
       
  1172         CyAsFunctionCallback            cb,             /* Callback to call on completion */
       
  1173         uint32_t                        client          /* Client data to be passed to the callback */
       
  1174         ) ;
       
  1175 
       
  1176 /* Summary
       
  1177    Select the clock frequency to be used when talking to high speed SD/MMC media.
       
  1178    
       
  1179    Description
       
  1180    West Bridge firmware uses a 48 MHz clock to interface with high speed SD/MMC
       
  1181    media.  This clock rate can be restricted to 24 MHz if desired.  This function
       
  1182    selects the frequency setting to be used. This fonction MUST be completed before
       
  1183    starting the storage stack for the setting to be taken into account.
       
  1184 
       
  1185    * Valid in Asynchronous Callback: Yes (if cb is non-zero)
       
  1186    * Nestable: Yes
       
  1187 
       
  1188    Returns
       
  1189    * CY_AS_ERROR_SUCCESS - the operation completed successfully.
       
  1190    * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
       
  1191    * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been configured.
       
  1192    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the device.
       
  1193    * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the operation.
       
  1194    * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend mode.
       
  1195    * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting desired.
       
  1196    * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to the operation.
       
  1197    * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support the operation.
       
  1198 
       
  1199    See Also
       
  1200    * CyAsLowSpeedSDFreq
       
  1201  */
       
  1202 EXTERN CyAsReturnStatus_t
       
  1203 CyAsMiscSetHighSpeedSDFreq(
       
  1204         CyAsDeviceHandle                handle,         /* Handle to the West Bridge device */
       
  1205         CyAsHighSpeedSDFreq             setting,        /* Frequency setting desired for high speed SD cards */
       
  1206         CyAsFunctionCallback            cb,             /* Callback to call on completion */
       
  1207         uint32_t                        client          /* Client data to be passed to the callback */
       
  1208         ) ;
       
  1209 /* Summary
       
  1210    Select the polarity of the SD_POW output driven by West Bridge.
       
  1211    
       
  1212    Description
       
  1213    The SD_POW signal driven by West Bridge can be used to control the supply
       
  1214    of Vcc to the SD/MMC media connected to the device.  This signal is driven
       
  1215    as an active high signal by default.  This function can be used to change the
       
  1216    polarity of this signal if required. This fonction MUST be completed before
       
  1217    starting the storage stack for the setting to be taken into account.
       
  1218 
       
  1219    * Valid in Asynchronous Callback: Yes (if cb is non-zero)
       
  1220    * Nestable: Yes
       
  1221 
       
  1222    Returns
       
  1223    * CY_AS_ERROR_SUCCESS - the operation completed successfully.
       
  1224    * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
       
  1225    * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been configured.
       
  1226    * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to the device.
       
  1227    * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the operation.
       
  1228    * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend mode.
       
  1229    * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting desired.
       
  1230    * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to the operation.
       
  1231    * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support the operation.
       
  1232 
       
  1233    See Also
       
  1234    * CyAsMiscSignalPolarity
       
  1235  */
       
  1236 EXTERN CyAsReturnStatus_t
       
  1237 CyAsMiscSetSDPowerPolarity(
       
  1238     CyAsDeviceHandle handle,                            /* Handle to the West Bridge device */
       
  1239     CyAsMiscSignalPolarity polarity,                    /* Desired polarity setting to the SD_POW signal. */
       
  1240     CyAsFunctionCallback cb,                            /* Callback to call on completion. */
       
  1241     uint32_t client                                     /* Client data to be passed to the callback. */
       
  1242     ) ;
       
  1243 
       
  1244 /* For supporting deprecated functions */
       
  1245 #include "cyasmisc_dep.h"    
       
  1246 
       
  1247 #include "cyas_cplus_end.h"
       
  1248 
       
  1249 #endif				/* _INCLUDED_CYASMISC_H_ */
       
  1250