linux/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc.h
<<
>>
Prefs
   1/* Cypress West Bridge API header file (cyasmisc.h)
   2## ===========================
   3## Copyright (C) 2010  Cypress Semiconductor
   4##
   5## This program is free software; you can redistribute it and/or
   6## modify it under the terms of the GNU General Public License
   7## as published by the Free Software Foundation; either version 2
   8## of the License, or (at your option) any later version.
   9##
  10## This program is distributed in the hope that it will be useful,
  11## but WITHOUT ANY WARRANTY; without even the implied warranty of
  12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13## GNU General Public License for more details.
  14##
  15## You should have received a copy of the GNU General Public License
  16## along with this program; if not, write to the Free Software
  17## Foundation, Inc., 51 Franklin Street
  18## Fifth Floor, Boston, MA  02110-1301, USA.
  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 cy_as_funct_c_b_type_get_type(t) \
  47        ((cy_as_funct_c_b_type)((t) & CY_AS_FUNCTCBTYPE_TYPE_MASK))
  48#define cy_as_funct_c_b_type_contains_data(t) \
  49        (((cy_as_funct_c_b_type)((t) & \
  50                CY_AS_FUNCTCBTYPE_DATA_MASK)) == CY_FUNCT_CB_DATA)
  51
  52/**************************************
  53 * West Bridge Types
  54 **************************************/
  55
  56/* Summary
  57   Specifies a handle to an West Bridge device
  58
  59   Description
  60   This type represents an opaque handle to an West Bridge device.
  61   This handle is created via the CyAsMiscCreateDevice() function
  62   and is used in all subsequent calls that communicate to the West
  63   Bridge device.
  64
  65   See Also
  66   * CyAsMiscCreateDevice
  67   * CyAsMiscDestroyDevice
  68*/
  69typedef void *cy_as_device_handle;
  70
  71/* Summary
  72   This data type gives the mode for the DACK# signal
  73*/
  74typedef enum cy_as_device_dack_mode {
  75        cy_as_device_dack_ack, /* Operate in the ACK mode */
  76        cy_as_device_dack_eob /* Operate in the EOB mode */
  77} cy_as_device_dack_mode;
  78
  79/* Summary
  80   This data structure gives the options for all hardware features.
  81
  82   Description
  83   This structure contains the information required to initialize the
  84   West Bridge hardware. Any features of the device that can be
  85   configured by the caller are specified here.
  86
  87   See Also
  88   * CyAsMiscConfigure
  89*/
  90typedef struct cy_as_device_config {
  91        /* If TRUE, the P port is running in SRAM mode. */
  92        cy_bool srammode;
  93        /* If TRUE, the P port is synchronous, otherwise async */
  94        cy_bool sync;
  95        /* If TRUE, DMA req will be delivered via the interrupt signal */
  96        cy_bool dmaintr;
  97        /* Mode for the DACK# signal */
  98        cy_as_device_dack_mode dackmode;
  99        /* If TRUE, the DRQ line is active high, otherwise active low */
 100        cy_bool drqpol;
 101        /* If TRUE, the DACK line is active high, otherwise active low */
 102        cy_bool dackpol;
 103        /* If TRUE, the clock is connected to a crystal, otherwise it is
 104                        connected to a clock */
 105        cy_bool crystal;
 106} cy_as_device_config;
 107
 108
 109/* Summary
 110   Specifies a resource that can be owned by either the West Bridge
 111   device or by the processor.
 112
 113   Description
 114   This enumerated type identifies a resource that can be owned
 115   either by the West Bridge device, or by the processor attached to
 116   the P port of the West Bridge device.
 117
 118   See Also
 119   * CyAsMiscAcquireResource
 120   * CyAsMiscReleaseResource
 121*/
 122typedef enum cy_as_resource_type {
 123        cy_as_bus_u_s_b = 0, /* The USB D+ and D- pins */
 124        cy_as_bus_1  = 1, /* The SDIO bus */
 125        cy_as_bus_0  = 2        /* The NAND bus (not implemented) */
 126} cy_as_resource_type;
 127
 128/* Summary
 129   Specifies the reset type for a software reset operation.
 130
 131   Description
 132   When the West Bridge device is reset, there are two types of
 133   reset that arE possible.  This type indicates the type of reset
 134   requested.
 135
 136   Notes
 137   Both of these reset types are software based resets; and are
 138   distinct from a chip level HARD reset that is applied through
 139   the reset pin on the West Bridge.
 140
 141   The CyAsResetSoft type resets only the on-chip micro-controller
 142   in the West Bridge. In this case, the previously loaded firmware
 143   will continue running. However, the Storage and USB stack
 144   operations will need to be restarted, as any state relating to
 145   these would have been lost.
 146
 147   The CyAsResetHard type resets the entire West Bridge chip, and will
 148   need a fresh configuration and firmware download.
 149
 150   See Also
 151   * <LINK CyAsMiscReset>
 152 */
 153
 154typedef enum cy_as_reset_type {
 155        /* Just resets the West Bridge micro-controller */
 156        cy_as_reset_soft,
 157        /* Resets entire device, firmware must be reloaded and
 158        the west bridge device must be re-initialized */
 159        cy_as_reset_hard
 160} cy_as_reset_type;
 161
 162
 163
 164/* Summary
 165   This type specifies the polarity of the SD power pin.
 166
 167   Description
 168   Sets the SD power pin ( port C, bit 6) to active low or
 169   active high.
 170
 171*/
 172
 173typedef enum cy_as_misc_signal_polarity {
 174        cy_as_misc_active_high,
 175        cy_as_misc_active_low
 176
 177} cy_as_misc_signal_polarity;
 178
 179
 180
 181/* Summary
 182        This type specifies the type of the data returned by a Function
 183        Callback.
 184
 185        Description
 186        CY_FUNCT_CB_NODATA - This callback does not return any additional
 187        information in the data field.
 188        CY_FUNCT_CB_DATA   - The data field is used, and the CyAsFunctCBType
 189        will also contain the type of this data.
 190
 191        See Also
 192        CyAsFunctionCallback
 193*/
 194typedef enum cy_as_funct_c_b_type {
 195        CY_FUNCT_CB_INVALID = 0x0U,
 196        /* Data from a CyAsMiscGetFirmwareVersion call. */
 197        CY_FUNCT_CB_MISC_GETFIRMWAREVERSION,
 198        /* Data from a CyAsMiscHeartBeatControl call. */
 199        CY_FUNCT_CB_MISC_HEARTBEATCONTROL,
 200        /* Data from a CyAsMiscAcquireResource call. */
 201        CY_FUNCT_CB_MISC_ACQUIRERESOURCE,
 202        /* Data from a CyAsMiscReadMCURegister call. */
 203        CY_FUNCT_CB_MISC_READMCUREGISTER,
 204        /* Data from a CyAsMiscWriteMCURegister call. */
 205        CY_FUNCT_CB_MISC_WRITEMCUREGISTER,
 206        /* Data from a CyAsMiscSetTraceLevel call. */
 207        CY_FUNCT_CB_MISC_SETTRACELEVEL,
 208        /* Data from a CyAsMiscStorageChanged call. */
 209        CY_FUNCT_CB_MISC_STORAGECHANGED,
 210        /* Data from a CyAsMiscGetGpioValue call. */
 211        CY_FUNCT_CB_MISC_GETGPIOVALUE,
 212        /* Data from a CyAsMiscSetGpioValue call. */
 213        CY_FUNCT_CB_MISC_SETGPIOVALUE,
 214        /* Data from a CyAsMiscDownloadFirmware call. */
 215        CY_FUNCT_CB_MISC_DOWNLOADFIRMWARE,
 216        /* Data from a CyAsMiscEnterStandby call. */
 217        CY_FUNCT_CB_MISC_ENTERSTANDBY,
 218        /* Data from a CyAsMiscEnterSuspend call. */
 219        CY_FUNCT_CB_MISC_ENTERSUSPEND,
 220        /* Data from a CyAsMiscLeaveSuspend call. */
 221        CY_FUNCT_CB_MISC_LEAVESUSPEND,
 222        /* Data from a CyAsMiscReset call. */
 223        CY_FUNCT_CB_MISC_RESET,
 224        /* Data from a CyAsMiscSetLowSpeedSDFreq or
 225         * CyAsMiscSetHighSpeedSDFreq call. */
 226        CY_FUNCT_CB_MISC_SETSDFREQ,
 227        /* Data from a CyAsMiscSwitchPnandMode call */
 228        CY_FUNCT_CB_MISC_RESERVELNABOOTAREA,
 229        /* Data from a CyAsMiscSetSDPowerPolarity call */
 230        CY_FUNCT_CB_MISC_SETSDPOLARITY,
 231
 232        /* Data from a CyAsStorageStart call. */
 233        CY_FUNCT_CB_STOR_START,
 234        /* Data from a CyAsStorageStop call. */
 235        CY_FUNCT_CB_STOR_STOP,
 236        /* Data from a CyAsStorageClaim call. */
 237        CY_FUNCT_CB_STOR_CLAIM,
 238        /* Data from a CyAsStorageRelease call. */
 239        CY_FUNCT_CB_STOR_RELEASE,
 240        /* Data from a CyAsStorageQueryMedia call. */
 241        CY_FUNCT_CB_STOR_QUERYMEDIA,
 242        /* Data from a CyAsStorageQueryBus call. */
 243        CY_FUNCT_CB_STOR_QUERYBUS,
 244        /* Data from a CyAsStorageQueryDevice call. */
 245        CY_FUNCT_CB_STOR_QUERYDEVICE,
 246        /* Data from a CyAsStorageQueryUnit call. */
 247        CY_FUNCT_CB_STOR_QUERYUNIT,
 248        /* Data from a CyAsStorageDeviceControl call. */
 249        CY_FUNCT_CB_STOR_DEVICECONTROL,
 250        /* Data from a CyAsStorageSDRegisterRead call. */
 251        CY_FUNCT_CB_STOR_SDREGISTERREAD,
 252        /* Data from a CyAsStorageCreatePartition call. */
 253        CY_FUNCT_CB_STOR_PARTITION,
 254        /* Data from a CyAsStorageGetTransferAmount call. */
 255        CY_FUNCT_CB_STOR_GETTRANSFERAMOUNT,
 256        /* Data from a CyAsStorageErase call. */
 257        CY_FUNCT_CB_STOR_ERASE,
 258        /* Data from a CyAsStorageCancelAsync call. */
 259        CY_FUNCT_CB_ABORT_P2S_XFER,
 260        /* Data from a CyAsUsbStart call. */
 261        CY_FUNCT_CB_USB_START,
 262        /* Data from a CyAsUsbStop call. */
 263        CY_FUNCT_CB_USB_STOP,
 264        /* Data from a CyAsUsbConnect call. */
 265        CY_FUNCT_CB_USB_CONNECT,
 266        /* Data from a CyAsUsbDisconnect call. */
 267        CY_FUNCT_CB_USB_DISCONNECT,
 268        /* Data from a CyAsUsbSetEnumConfig call. */
 269        CY_FUNCT_CB_USB_SETENUMCONFIG,
 270        /* Data from a CyAsUsbGetEnumConfig call. */
 271        CY_FUNCT_CB_USB_GETENUMCONFIG,
 272        /* Data from a CyAsUsbSetDescriptor call. */
 273        CY_FUNCT_CB_USB_SETDESCRIPTOR,
 274        /* Data from a CyAsUsbGetDescriptor call. */
 275        CY_FUNCT_CB_USB_GETDESCRIPTOR,
 276        /* Data from a CyAsUsbCommitConfig call. */
 277        CY_FUNCT_CB_USB_COMMITCONFIG,
 278        /* Data from a CyAsUsbGetNak call. */
 279        CY_FUNCT_CB_USB_GETNAK,
 280        /* Data from a CyAsUsbGetStall call. */
 281        CY_FUNCT_CB_USB_GETSTALL,
 282        /* Data from a CyAsUsbSignalRemoteWakeup call. */
 283        CY_FUNCT_CB_USB_SIGNALREMOTEWAKEUP,
 284        /* Data from a CyAnUsbClearDescriptors call. */
 285        CY_FUNCT_CB_USB_CLEARDESCRIPTORS,
 286        /* Data from a CyAnUsbSetMSReportThreshold call. */
 287        CY_FUNCT_CB_USB_SET_MSREPORT_THRESHOLD,
 288        /* Data from a CyAsMTPStart call. */
 289        CY_FUNCT_CB_MTP_START,
 290        /* Data from a CyAsMTPStop call. */
 291        CY_FUNCT_CB_MTP_STOP,
 292        /* Data from a CyAsMTPInitSendObject call. */
 293        CY_FUNCT_CB_MTP_INIT_SEND_OBJECT,
 294        /* Data from a CyAsMTPCancelSendObject call. */
 295        CY_FUNCT_CB_MTP_CANCEL_SEND_OBJECT,
 296        /* Data from a CyAsMTPInitGetObject call. */
 297        CY_FUNCT_CB_MTP_INIT_GET_OBJECT,
 298        /* Data from a CyAsMTPCancelGetObject call. */
 299        CY_FUNCT_CB_MTP_CANCEL_GET_OBJECT,
 300        /* Data from a CyAsMTPSendBlockTable call. */
 301        CY_FUNCT_CB_MTP_SEND_BLOCK_TABLE,
 302        /* Data from a CyAsMTPStopStorageOnly call. */
 303        CY_FUNCT_CB_MTP_STOP_STORAGE_ONLY,
 304        CY_FUNCT_CB_NODATA = 0x40000000U,
 305        CY_FUNCT_CB_DATA =   0x20000000U
 306} cy_as_funct_c_b_type;
 307
 308/* Summary
 309   This type specifies the general West Bridge function callback.
 310
 311   Description
 312   This callback is supplied as an argument to all asynchronous
 313   functions in the API. It iS called after the asynchronous function
 314   has completed.
 315
 316   See Also
 317   CyAsFunctCBType
 318*/
 319typedef void (*cy_as_function_callback)(
 320        cy_as_device_handle     handle,
 321        cy_as_return_status_t   status,
 322        uint32_t                client,
 323        cy_as_funct_c_b_type    type,
 324        void    *data);
 325
 326/* Summary
 327   This type specifies the general West Bridge event that has
 328   occurred.
 329
 330   Description
 331   This type is used in the West Bridge misc callback function to
 332   indicate the type of callback.
 333
 334   See Also
 335*/
 336typedef enum cy_as_misc_event_type {
 337        /* This event is sent when West Bridge has finished
 338        initialization and is ready to respond to API calls. */
 339        cy_as_event_misc_initialized = 0,
 340
 341        /* This event is sent when West Bridge has left the
 342        standby state and is ready to respond to commands again. */
 343        cy_as_event_misc_awake,
 344
 345        /* This event is sent periodically from the firmware
 346        to the processor. */
 347        cy_as_event_misc_heart_beat,
 348
 349        /* This event is sent when the West Bridge has left the
 350        suspend mode and is ready to respond to commands
 351        again. */
 352        cy_as_event_misc_wakeup,
 353
 354         /* This event is sent when the firmware image downloaded
 355        cannot run on the active west bridge device. */
 356        cy_as_event_misc_device_mismatch
 357} cy_as_misc_event_type;
 358
 359/* Summary
 360   This type is the type of a callback function that is called when a
 361   West Bridge misc event occurs.
 362
 363   Description
 364   At times West Bridge needs to inform the P port processor of events
 365   that have occurred. These events are asynchronous to the thread of
 366   control on the P port processor and as such are generally delivered
 367   via a callback function that is called as part of an interrupt
 368   handler. This type defines the type of function that must be provided
 369   as a callback function for West Bridge misc events.
 370
 371   See Also
 372   * CyAsMiscEventType
 373*/
 374typedef void (*cy_as_misc_event_callback)(
 375        /* Handle to the device to configure */
 376        cy_as_device_handle             handle,
 377        /* The event type being reported */
 378        cy_as_misc_event_type           ev,
 379        /* The data assocaited with the event being reported */
 380        void *evdata
 381);
 382
 383#ifndef __doxygen__
 384/* Summary
 385   This enum provides info of various firmware trace levels.
 386
 387   Description
 388
 389   See Also
 390   * CyAsMiscSetTraceLevel
 391*/
 392enum {
 393        CYAS_FW_TRACE_LOG_NONE = 0,     /* Log nothing. */
 394        CYAS_FW_TRACE_LOG_STATE,        /* Log state information. */
 395        CYAS_FW_TRACE_LOG_CALLS,        /* Log function calls. */
 396        CYAS_FW_TRACE_LOG_STACK_TRACE,  /* Log function calls with args. */
 397        CYAS_FW_TRACE_MAX_LEVEL         /* Max trace level sentinel. */
 398};
 399#endif
 400
 401/* Summary
 402   This enum lists the controllable GPIOs of the West Bridge device.
 403
 404   Description
 405   The West Bridge device has GPIOs that can be used for user defined functions.
 406   This enumeration lists the GPIOs that are available on the device.
 407
 408   Notes
 409   All of the GPIOs except UVALID can only be accessed when using West Bridge
 410   firmware images that support only SD/MMC/MMC+ storage devices. This
 411   functionality is not supported in firmware images that support NAND
 412   storage.
 413
 414   See Also
 415   * CyAsMiscGetGpioValue
 416   * CyAsMiscSetGpioValue
 417 */
 418typedef enum {
 419        cy_as_misc_gpio_0 = 0,  /* GPIO[0] pin */
 420        cy_as_misc_gpio_1, /* GPIO[1] pin */
 421        cy_as_misc_gpio__nand_CE, /* NAND_CE pin, output only */
 422        cy_as_misc_gpio__nand_CE2, /* NAND_CE2 pin, output only */
 423        cy_as_misc_gpio__nand_WP, /* NAND_WP pin, output only */
 424        cy_as_misc_gpio__nand_CLE, /* NAND_CLE pin, output only */
 425        cy_as_misc_gpio__nand_ALE, /* NAND_ALE pin, output only */
 426        /* SD_POW pin, output only, do not drive low while storage is active */
 427        cy_as_misc_gpio_SD_POW,
 428        cy_as_misc_gpio_U_valid                          /* UVALID pin */
 429} cy_as_misc_gpio;
 430
 431/* Summary
 432   This enum lists the set of clock frequencies that are supported for
 433   working with low speed SD media.
 434
 435   Description
 436   West Bridge firmware uses a clock frequency less than the maximum
 437   possible rate for low speed SD media.  This can be changed to a
 438   setting equal to the maximum frequency as desired by the user. This
 439   enumeration lists the different frequency settings that are
 440   supported.
 441
 442   See Also
 443   * CyAsMiscSetLowSpeedSDFreq
 444 */
 445typedef enum cy_as_low_speed_sd_freq {
 446        /* Approx. 21.82 MHz, default value */
 447        CY_AS_SD_DEFAULT_FREQ = 0,
 448        /* 24 MHz */
 449        CY_AS_SD_RATED_FREQ
 450} cy_as_low_speed_sd_freq;
 451
 452/* Summary
 453   This enum lists the set of clock frequencies that are supported
 454   for working with high speed SD media.
 455
 456   Description
 457   West Bridge firmware uses a 48 MHz clock by default to interface
 458   with high speed SD/MMC media.  This can be changed to 24 MHz if
 459   so desired by the user. This enum lists the different frequencies
 460   that are supported.
 461
 462   See Also
 463   * CyAsMiscSetHighSpeedSDFreq
 464 */
 465typedef enum cy_as_high_speed_sd_freq {
 466        CY_AS_HS_SD_FREQ_48, /* 48 MHz, default value */
 467        CY_AS_HS_SD_FREQ_24     /* 24 MHz */
 468} cy_as_high_speed_sd_freq;
 469
 470/* Summary
 471   Struct encapsulating all information returned by the
 472   CyAsMiscGetFirmwareVersion call.
 473
 474   Description
 475   This struct encapsulates all return values from the asynchronous
 476   CyAsMiscGetFirmwareVersion call, so that a single data argument
 477   can be passed to the user provided callback function.
 478
 479   See Also
 480   * CyAsMiscGetFirmwareVersion
 481 */
 482typedef struct cy_as_get_firmware_version_data {
 483        /* Return value for major version number for the firmware */
 484        uint16_t         major;
 485        /* Return value for minor version number for the firmware */
 486        uint16_t         minor;
 487        /* Return value for build version number for the firmware */
 488        uint16_t         build;
 489        /* Return value for media types supported in the current firmware */
 490        uint8_t  media_type;
 491        /* Return value to indicate the release or debug mode of firmware */
 492        cy_bool is_debug_mode;
 493} cy_as_get_firmware_version_data;
 494
 495
 496/*****************************
 497 * West Bridge Functions
 498 *****************************/
 499
 500/* Summary
 501   This function creates a new West Bridge device and returns a
 502   handle to the device.
 503
 504   Description
 505   This function initializes the API object that represents the West
 506   Bridge device and returns a handle to this device.  This handle is
 507   required for all West Bridge related functions to identify the
 508   specific West Bridge device.
 509
 510   * Valid In Asynchronous Callback: NO
 511
 512   Returns
 513   * CY_AS_ERROR_SUCCESS
 514   * CY_AS_ERROR_OUT_OF_MEMORY
 515*/
 516EXTERN cy_as_return_status_t
 517cy_as_misc_create_device(
 518        /* Return value for handle to created device */
 519        cy_as_device_handle *handle_p,
 520        /* The HAL specific tag for this device */
 521        cy_as_hal_device_tag            tag
 522        );
 523
 524/* Summary
 525   This functions destroys a previously created West Bridge device.
 526
 527   Description
 528   When an West Bridge device is created, an opaque handle is returned
 529   that represents the device.  This function destroys that handle and
 530   frees all resources associated with the handle.
 531
 532   * Valid In Asynchronous Callback: NO
 533
 534   Returns
 535   * CY_AS_ERROR_SUCCESS
 536   * CY_AS_ERROR_INVALID_HANDLE
 537   * CY_AS_ERROR_STILL_RUNNING - The USB or STORAGE stacks are still
 538   *    running, they must be stopped before the device can be destroyed
 539   * CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED - the HAL layer failed to
 540   *    destroy a sleep channel
 541*/
 542EXTERN cy_as_return_status_t
 543cy_as_misc_destroy_device(
 544        /* Handle to the device to destroy */
 545        cy_as_device_handle             handle
 546        );
 547
 548/* Summary
 549   This function initializes the hardware for basic communication with
 550   West Bridge.
 551
 552   Description
 553   This function intializes the hardware to establish basic
 554   communication with the West Bridge device.  This is always the first
 555   function called to initialize communication with the West Bridge
 556   device.
 557
 558   * Valid In Asynchronous Callback: NO
 559
 560   Returns
 561   * CY_AS_ERROR_SUCCESS - the basic initialization was completed
 562   * CY_AS_ERROR_INVALID_HANDLE
 563   * CY_AS_ERROR_IN_STANDBY
 564   * CY_AS_ERROR_ALREADY_RUNNING
 565   * CY_AS_ERROR_OUT_OF_MEMORY
 566   * CY_AS_ERROR_NO_ANTIOCH - cannot find the West Bridge device
 567   * CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED -
 568   *    the HAL layer falied to create a sleep channel
 569
 570   See Also
 571   * CyAsDeviceConfig
 572*/
 573EXTERN cy_as_return_status_t
 574cy_as_misc_configure_device(
 575        /* Handle to the device to configure */
 576        cy_as_device_handle             handle,
 577        /* Configuration information */
 578        cy_as_device_config             *config_p
 579        );
 580
 581/* Summary
 582   This function returns non-zero if West Bridge is in standby and
 583   zero otherwise.
 584
 585   Description
 586   West Bridge supports a standby mode.  This function is used to
 587   query West Bridge to determine if West Bridge is in a standby
 588   mode.
 589
 590   * Valid In Asynchronous Callback: YES
 591
 592   Returns
 593   * CY_AS_ERROR_SUCCESS
 594   * CY_AS_ERROR_INVALID_HANDLE
 595*/
 596EXTERN cy_as_return_status_t
 597cy_as_misc_in_standby(
 598        /* Handle to the device to configure */
 599        cy_as_device_handle             handle,
 600        /* Return value for standby state */
 601        cy_bool                                 *standby
 602        );
 603
 604/* Summary
 605   This function downloads the firmware to West Bridge device.
 606
 607   Description
 608   This function downloads firmware from a given location and with a
 609   given size to the West Bridge device.  After the firmware is
 610   downloaded the West Bridge device is moved out of configuration
 611   mode causing the firmware to be executed.  It is an error to call
 612   this function when the device is not in configuration mode.  The
 613   device is in configuration mode on power up and may be placed in
 614   configuration mode after power up with a hard reset.
 615
 616   Notes
 617   The firmware must be on a word align boundary.
 618
 619   * Valid In Asynchronous Callback: YES (if cb supplied)
 620   * Nestable: YES
 621
 622   Returns
 623   * CY_AS_ERROR_SUCCESS - the firmware was sucessfully downloaded
 624   * CY_AS_ERROR_INVALID_HANDLE
 625   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
 626   *    was not configured
 627   * CY_AS_ERROR_NOT_IN_CONFIG_MODE
 628   * CY_AS_ERROR_INVALID_SIZE - the size of the firmware
 629   *    exceeded 32768 bytes
 630   * CY_AS_ERROR_ALIGNMENT_ERROR
 631   * CY_AS_ERROR_IN_STANDBY - trying to download
 632   *    while in standby mode
 633   * CY_AS_ERROR_TIMEOUT
 634
 635   See Also
 636   * CyAsMiscReset
 637*/
 638EXTERN cy_as_return_status_t
 639cy_as_misc_download_firmware(
 640        /* Handle to the device to configure */
 641        cy_as_device_handle       handle,
 642        /* Pointer to the firmware to be downloaded */
 643        const void                         *fw_p,
 644        /* The size of the firmware in bytes */
 645        uint16_t                          size,
 646        /* Callback to call when the operation is complete. */
 647        cy_as_function_callback  cb,
 648        /* Client data to be passed to the callback. */
 649        uint32_t                          client
 650        );
 651
 652
 653/* Summary
 654   This function returns the version number of the firmware running in
 655   the West Bridge device.
 656
 657   Description
 658   This function queries the West Bridge device and retreives the
 659   firmware version number.  If the firmware is not loaded an error is
 660   returned indicated no firmware has been loaded.
 661
 662   * Valid In Asynchronous Callback: YES (if cb supplied)
 663   * Nestable: YES
 664
 665   Returns
 666   * CY_AS_ERROR_SUCCESS - the firmware version number was retreived
 667   * CY_AS_ERROR_INVALID_HANDLE
 668   * CY_AS_ERROR_NOT_CONFIGURED
 669   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been downloaded
 670   *    to the device
 671   * CY_AS_ERROR_IN_STANDBY
 672   * CY_AS_ERROR_OUT_OF_MEMORY
 673   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
 674   *    from the West Bridge firmware
 675*/
 676EXTERN cy_as_return_status_t
 677cy_as_misc_get_firmware_version(
 678        /* Handle to the device to configure */
 679        cy_as_device_handle     handle,
 680        /* Return values indicating the firmware version. */
 681        cy_as_get_firmware_version_data *data,
 682        /* Callback to call when the operation is complete. */
 683        cy_as_function_callback cb,
 684        /* Client data to be passed to the callback. */
 685        uint32_t client
 686        );
 687
 688#if !defined(__doxygen__)
 689
 690/* Summary
 691   This function reads and returns the contents of an MCU accessible
 692   register on the West Bridge.
 693
 694   Description
 695   This function requests the firmware to read and return the contents
 696   of an MCU accessible register through the mailboxes.
 697
 698   * Valid In Asynchronous Callback: YES (if cb supplied)
 699   * Nestable: YES
 700
 701   Returns
 702   * CY_AS_ERROR_SUCCESS - the register content was retrieved.
 703   * CY_AS_ERROR_INVALID_HANDLE
 704   * CY_AS_ERROR_NOT_CONFIGURED
 705   * CY_AS_ERROR_NO_FIRMWARE
 706   * CY_AS_ERROR_OUT_OF_MEMORY
 707   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
 708   *    from the West Bridge firmware
 709   * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not
 710   *    support this command.
 711*/
 712EXTERN cy_as_return_status_t
 713cy_as_misc_read_m_c_u_register(
 714        /* Handle to the device to configure */
 715        cy_as_device_handle             handle,
 716        /* Address of the register to read */
 717        uint16_t                        address,
 718        /* Return value for the MCU register content */
 719        uint8_t                         *value,
 720        /* Callback to call when the operation is complete. */
 721        cy_as_function_callback         cb,
 722        /* Client data to be passed to the callback. */
 723        uint32_t                        client
 724        );
 725
 726/* Summary
 727   This function writes to an MCU accessible register on the West Bridge.
 728
 729   Description
 730   This function requests the firmware to write a specified value to an
 731   MCU accessible register through the mailboxes.
 732
 733   * Valid In Asynchronous Callback: YES (if cb supplied)
 734   * Nestable: YES
 735
 736   Notes
 737   This function is only for internal use by the West Bridge API layer.
 738   Calling this function directly can cause device malfunction.
 739
 740   Returns
 741   * CY_AS_ERROR_SUCCESS - the register content was updated.
 742   * CY_AS_ERROR_INVALID_HANDLE
 743   * CY_AS_ERROR_NOT_CONFIGURED
 744   * CY_AS_ERROR_NO_FIRMWARE
 745   * CY_AS_ERROR_OUT_OF_MEMORY
 746   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
 747   *    from the West Bridge firmware
 748   * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not support
 749   * this command.
 750*/
 751EXTERN cy_as_return_status_t
 752cy_as_misc_write_m_c_u_register(
 753        /* Handle to the device to configure */
 754        cy_as_device_handle     handle,
 755        /* Address of the register to write */
 756        uint16_t        address,
 757        /* Mask to be applied on the register contents. */
 758        uint8_t         mask,
 759        /* Data to be ORed with the register contents. */
 760        uint8_t         value,
 761        /* Callback to call when the operation is complete. */
 762        cy_as_function_callback cb,
 763        /* Client data to be passed to the callback. */
 764        uint32_t        client
 765        );
 766
 767#endif
 768
 769/* Summary
 770   This function will reset the West Bridge device and software API.
 771
 772   Description
 773   This function will reset the West Bridge device and software API.
 774   The reset operation can be a hard reset or a soft reset.  A hard
 775   reset will reset all aspects of the West Bridge device. The device
 776   will enter the configuration state and the firmware will have to be
 777   reloaded.  The device will also have to be re-initialized.  A soft
 778   reset just resets the West Bridge micro-controller.
 779
 780   * Valid In Asynchronous Callback: NO
 781
 782   Notes
 783   When a hard reset is issued, the firmware that may have been
 784   previously loaded will be lost and any configuration information set
 785   via CyAsMiscConfigureDevice() will be lost.  This will be reflected
 786   in the API maintained state of the device.  In order to re-establish
 787   communications with the West Bridge device, CyAsMiscConfigureDevice()
 788   and CyAsMiscDownloadFirmware() must be called again.
 789
 790   * Valid In Asynchronous Callback: YES (if cb supplied)
 791   * Nestable: YES
 792
 793   Returns
 794   * CY_AS_ERROR_SUCCESS - the device has been reset
 795   * CY_AS_ERROR_INVALID_HANDLE
 796   * CY_AS_ERROR_NOT_CONFIGURED
 797   * CY_AS_ERROR_NO_FIRMWARE
 798   * CY_AS_ERROR_NOT_YET_SUPPORTED - current soft reset is not supported
 799   * CY_AS_ERROR_ASYNC_PENDING - Reset is unable to flush pending async
 800   *    reads/writes in polling mode.
 801
 802
 803          See Also
 804   * CyAsMiscReset
 805*/
 806EXTERN cy_as_return_status_t
 807cy_as_misc_reset(
 808        /* Handle to the device to configure */
 809        cy_as_device_handle handle,
 810        /* The type of reset to perform */
 811        cy_as_reset_type type,
 812        /* If true, flush all pending writes to mass storage
 813         before performing the reset. */
 814        cy_bool flush,
 815        /* Callback to call when the operation is complete. */
 816        cy_as_function_callback cb,
 817        /* Client data to be passed to the callback. */
 818        uint32_t client
 819        );
 820
 821/* Summary
 822   This function acquires a given resource.
 823
 824   Description
 825   There are resources in the system that are shared between the
 826   West Bridge device and the processor attached to the P port of
 827   the West Bridge device.  This API provides a mechanism for the
 828   P port processor to acquire ownership of a resource.
 829
 830   Notes
 831   The ownership of the resources controlled by CyAsMiscAcquireResource()
 832   and CyAsMiscReleaseResource() defaults to a known state at hardware
 833   reset.  After the firmware is loaded and begins execution the state of
 834   these resources may change.  At any point if the P Port processor needs
 835   to acquire a resource it should do so explicitly to be sure of
 836   ownership.
 837
 838   Returns
 839   * CY_AS_ERROR_SUCCESS - the p port sucessfully acquired the
 840   *    resource of interest
 841   * CY_AS_ERROR_INVALID_HANDLE
 842   * CY_AS_ERROR_NOT_CONFIGURED
 843   * CY_AS_ERROR_NO_FIRMWARE
 844   * CY_AS_ERROR_INVALID_RESOURCE
 845   * CY_AS_ERROR_RESOURCE_ALREADY_OWNED - the p port already
 846   *    owns this resource
 847   * CY_AS_ERROR_NOT_ACQUIRED - the resource cannot be acquired
 848   * CY_AS_ERROR_OUT_OF_MEMORY
 849   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
 850   *    response from the West Bridge firmware
 851
 852   See Also
 853   * CyAsResourceType
 854*/
 855EXTERN cy_as_return_status_t
 856cy_as_misc_acquire_resource(
 857        /* Handle to the device to configure */
 858        cy_as_device_handle     handle,
 859        /* The resource to acquire */
 860        cy_as_resource_type     *resource,
 861        /* If true, force West Bridge to release the resource */
 862        cy_bool                         force,
 863        /* Callback to call when the operation is complete. */
 864        cy_as_function_callback cb,
 865        /* Client data to be passed to the callback. */
 866        uint32_t                        client
 867        );
 868
 869/* Summary
 870   This function releases a given resource.
 871
 872   Description
 873   There are resources in the system that are shared between the
 874   West Bridge device and the processor attached to the P port of
 875   the West Bridge device.  This API provides a mechanism for the
 876   P port processor to release a resource that has previously been
 877   acquired via the CyAsMiscAcquireResource() call.
 878
 879   * Valid In Asynchronous Callback: NO
 880
 881   Returns
 882   * CY_AS_ERROR_SUCCESS - the p port sucessfully released
 883   *    the resource of interest
 884   * CY_AS_ERROR_INVALID_HANDLE
 885   * CY_AS_ERROR_NOT_CONFIGURED
 886   * CY_AS_ERROR_NO_FIRMWARE
 887   * CY_AS_ERROR_INVALID_RESOURCE
 888   * CY_AS_ERROR_RESOURCE_NOT_OWNED - the p port does not own the
 889   *    resource of interest
 890
 891   See Also
 892   * CyAsResourceType
 893   * CyAsMiscAcquireResource
 894*/
 895EXTERN cy_as_return_status_t
 896cy_as_misc_release_resource(
 897        /* Handle to the device to configure */
 898        cy_as_device_handle             handle,
 899        /* The resource to release */
 900        cy_as_resource_type             resource
 901        );
 902
 903#ifndef __doxygen__
 904/* Summary
 905   This function sets the trace level for the West Bridge firmware.
 906
 907   Description
 908   The West Bridge firmware has the ability to store information
 909   about the state and execution path of the firmware on a mass storage
 910   device attached to the West Bridge device.  This function configures
 911   the specific mass storage device to be used and the type of information
 912   to be stored.  This state information is used for debugging purposes
 913   and must be interpreted by a Cypress provided tool.
 914
 915   *Trace Level*
 916   The trace level indicates the amount of information to output.
 917   * 0 = no trace information is output
 918   * 1 = state information is output
 919   * 2 = function call information is output
 920   * 3 = function call, arguments, and return value information is output
 921
 922   * Valid In Asynchronous Callback: NO
 923
 924   Notes
 925   The media device and unit specified in this call will be overwritten
 926   and any data currently stored on this device and unit will be lost.
 927
 928   * NOT IMPLEMENTED YET
 929
 930   Returns
 931   * CY_AS_ERROR_SUCCESS - the trace configuration has been
 932   *    sucessfully changed
 933   * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
 934   * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
 935   *    pair does not exist
 936   * CY_AS_ERROR_NO_SUCH_UNIT - the unit specified does not exist
 937   * CY_AS_ERROR_INVALID_TRACE_LEVEL - the trace level requested
 938   *    does not exist
 939   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
 940   *    response from the West Bridge firmware
 941*/
 942EXTERN cy_as_return_status_t
 943cy_as_misc_set_trace_level(
 944        /* Handle to the device to configure */
 945        cy_as_device_handle     handle,
 946        /* The trace level */
 947        uint8_t level,
 948        /* The bus for the output */
 949        cy_as_bus_number_t      bus,
 950        /* The device for the output */
 951        uint32_t device,
 952        /* The unit for the output */
 953        uint32_t unit,
 954        /* Callback to call when the operation is complete. */
 955        cy_as_function_callback         cb,
 956        /* Client data to be passed to the callback. */
 957        uint32_t                        client
 958        );
 959#endif
 960
 961/* Summary
 962   This function places West Bridge into the low power standby mode.
 963
 964   Description
 965   This function places West Bridge into a low power (sleep) mode, and
 966   cannot be called while the USB stack is active.  This function first
 967   instructs the West Bridge firmware that the device is about to be
 968   placed into sleep mode.  This allows West Bridge to complete any pending
 969   storage operations.  After the West Bridge device has responded that
 970   pending operations are complete, the device is placed in standby mode.
 971
 972   There are two methods of placing the device in standby mode.  If the
 973   WAKEUP pin of the West Bridge is connected to a GPIO on the processor,
 974   the pin is de-asserted (via the HAL layer) and West Bridge enters into
 975   a sleep mode.  If the WAKEUP pin is not accessible, the processor can
 976   write into the power management control/status register on the West
 977   Bridge to put the device into sleep mode.
 978
 979   * Valid In Asynchronous Callback: YES (if cb supplied)
 980   * Nestable: YES
 981
 982   Returns
 983   * CY_AS_ERROR_SUCCESS - the function completed and West Bridge
 984   *    is in sleep mode
 985   * CY_AS_ERROR_INVALID_HANDLE
 986   * CY_AS_ERROR_ALREADY_STANDBY - the West Bridge device is already
 987   *    in sleep mode
 988   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
 989   *    from the West Bridge firmware
 990   * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support changing
 991   *    the WAKEUP pin
 992   * CY_AS_ERROR_USB_RUNNING - The USB stack is still running when the
 993   *    EnterStandby call is made
 994   * CY_AS_ERROR_ASYNC_PENDING
 995   * CY_AS_ERROR_OUT_OF_MEMORY
 996   * CY_AS_ERROR_INVALID_RESPONSE
 997   * CY_AS_ERROR_SETTING_WAKEUP_PIN
 998   * CY_AS_ERROR_ASYNC_PENDING - In polling mode EnterStandby can not
 999   *    be called until all pending storage read/write requests have
1000   *    finished.
1001
1002   See Also
1003   * CyAsMiscLeaveStandby
1004*/
1005EXTERN cy_as_return_status_t
1006cy_as_misc_enter_standby_e_x_u(
1007        /* Handle to the device to configure */
1008        cy_as_device_handle             handle,
1009        /* If true, use the wakeup pin, otherwise use the register */
1010        cy_bool                         pin,
1011        /* Set true to enable specific usages of the
1012        UVALID signal, please refer to AN xx or ERRATA xx */
1013        cy_bool                         uvalid_special,
1014        /* Callback to call when the operation is complete. */
1015        cy_as_function_callback         cb,
1016        /* Client data to be passed to the callback. */
1017        uint32_t                        client
1018        );
1019
1020/* Summary
1021   This function is provided for backwards compatibility.
1022
1023   Description
1024   Calling this function is the same as calling CyAsMiscEnterStandbyEx
1025   with True for the lowpower parameter.
1026
1027   See Also
1028   * CyAsMiscEnterStandbyEx
1029*/
1030EXTERN cy_as_return_status_t
1031cy_as_misc_enter_standby(cy_as_device_handle handle,
1032                        cy_bool pin,
1033                        cy_as_function_callback cb,
1034                        uint32_t client
1035                        );
1036
1037/* Summary
1038   This function brings West Bridge out of sleep mode.
1039
1040   Description
1041   This function asserts the WAKEUP pin (via the HAL layer). This
1042   brings the West Bridge out of the sleep state and allows the
1043   West Bridge firmware to process the event causing the wakeup.
1044   When all processing associated with the wakeup is complete, a
1045   callback function is called to tell the P port software that
1046   the firmware processing associated with wakeup is complete.
1047
1048   * Valid In Asynchronous Callback: NO
1049
1050   Returns:
1051   * CY_AS_ERROR_SUCCESS - the function completed and West Bridge
1052   *    is in sleep mode
1053   * CY_AS_ERROR_INVALID_HANDLE
1054   * CY_AS_ERROR_SETTING_WAKEUP_PIN
1055   * CY_AS_ERROR_NOT_IN_STANDBY - the West Bridge device is not in
1056   *    the sleep state
1057   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
1058   *    response from the West Bridge firmware
1059   * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support
1060   *    changing the WAKEUP pin
1061
1062   See Also
1063   * CyAsMiscEnterStandby
1064*/
1065EXTERN cy_as_return_status_t
1066cy_as_misc_leave_standby(
1067        /* Handle to the device to configure */
1068        cy_as_device_handle             handle,
1069        /* The resource causing the wakeup */
1070        cy_as_resource_type             resource
1071        );
1072
1073/* Summary
1074   This function registers a callback function to be called when an
1075   asynchronous West Bridge MISC event occurs.
1076
1077   Description
1078   When asynchronous misc events occur, a callback function can be
1079   called to alert the calling program.  This functions allows the
1080   calling program to register a callback.
1081
1082   * Valid In Asynchronous Callback: NO
1083
1084   Returns:
1085   * CY_AS_ERROR_SUCCESS
1086   * CY_AS_ERROR_INVALID_HANDLE
1087*/
1088EXTERN cy_as_return_status_t
1089cy_as_misc_register_callback(
1090        /* Handle to the West Bridge device */
1091        cy_as_device_handle             handle,
1092        /* The function to call */
1093        cy_as_misc_event_callback               callback
1094        );
1095
1096/* Summary
1097   This function sets the logging level for log messages.
1098
1099   Description
1100   The API can print messages via the CyAsHalPrintMessage capability.
1101   This function sets the level of detail seen when printing messages
1102   from the API.
1103
1104   * Valid In Asynchronous Callback:NO
1105*/
1106EXTERN void
1107cy_as_misc_set_log_level(
1108        /* Level to set, 0 is fewer messages, 255 is all */
1109        uint8_t level
1110        );
1111
1112
1113/* Summary
1114   This function tells West Bridge that SD or MMC media has been
1115   inserted or removed.
1116
1117   Description
1118   In some hardware configurations, SD or MMC media detection is
1119   handled outside of the West Bridge device.  This function is called
1120   when a change is detected to inform the West Bridge firmware to check
1121   for storage media changes.
1122
1123   * Valid In Asynchronous Callback: NO
1124
1125   Returns:
1126   * CY_AS_ERROR_SUCCESS
1127   * CY_AS_ERROR_INVALID_HANDLE
1128   * CY_AS_ERROR_NOT_CONFIGURED
1129   * CY_AS_ERROR_NO_FIRMWARE
1130   * CY_AS_ERROR_IN_STANDBY
1131   * CY_AS_ERROR_OUT_OF_MEMORY
1132   * CY_AS_ERROR_INVALID_RESPONSE
1133
1134   See Also
1135   * CyAsMiscStorageChanged
1136
1137*/
1138EXTERN cy_as_return_status_t
1139cy_as_misc_storage_changed(
1140        /* Handle to the West Bridge device */
1141        cy_as_device_handle             handle,
1142        /* Callback to call when the operation is complete. */
1143        cy_as_function_callback         cb,
1144        /* Client data to be passed to the callback. */
1145        uint32_t                        client
1146        );
1147
1148/* Summary
1149   This function instructs the West Bridge firmware to start/stop
1150   sending periodic heartbeat messages to the processor.
1151
1152   Description
1153   The West Bridge firmware can send heartbeat messages through the
1154   mailbox register once every 500 ms. This message can be an overhead
1155   as it causes regular Mailbox interrupts to happen, and is turned
1156   off by default. The message can be used to test and verify that the
1157   West Bridge firmware is alive. This API can be used to enable or
1158   disable the heartbeat message.
1159
1160   * Valid In Asynchronous Callback: NO
1161
1162   Returns
1163   * CY_AS_ERROR_SUCCESS - the function completed successfully
1164   * CY_AS_ERROR_INVALID_HANDLE
1165   * CY_AS_ERROR_NOT_CONFIGURED
1166   * CY_AS_ERROR_NO_FIRMWARE
1167   * CY_AS_ERROR_OUT_OF_MEMORY
1168   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
1169   *    been configured yet
1170   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to
1171   *    the West Bridge device
1172
1173*/
1174EXTERN cy_as_return_status_t
1175cy_as_misc_heart_beat_control(
1176        /* Handle to the West Bridge device */
1177        cy_as_device_handle     handle,
1178        /* Message enable/disable selection */
1179        cy_bool enable,
1180         /* Callback to call when the operation is complete. */
1181        cy_as_function_callback         cb,
1182        /* Client data to be passed to the callback. */
1183        uint32_t                        client
1184                );
1185
1186/* Summary
1187   This function gets the current state of a GPIO pin on the
1188   West Bridge device.
1189
1190   Description
1191   The West Bridge device has GPIO pins that can be used for user
1192   defined functions. This function gets the current state of the
1193   specified GPIO pin. Calling this function will configure the
1194   corresponding pin as an input.
1195
1196   * Valid In Asynchronous Callback: NO
1197
1198   Notes
1199   Only GPIO[0], GPIO[1] and UVALID pins can be used as GP inputs.
1200   Of these pins, only the UVALID pin is supported by firmware images
1201   that include NAND storage support.
1202
1203   Returns
1204   * CY_AS_ERROR_SUCCESS - the function completed successfully
1205   * CY_AS_ERROR_INVALID_HANDLE
1206   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
1207   *    been configured yet
1208   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
1209   *    to the West Bridge device
1210   * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
1211   * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported
1212   *    by the firmware
1213
1214   See Also
1215   * CyAsMiscGpio
1216   * CyAsMiscSetGpioValue
1217 */
1218EXTERN cy_as_return_status_t
1219cy_as_misc_get_gpio_value(
1220        /* Handle to the West Bridge device */
1221        cy_as_device_handle     handle,
1222        /* Id of the GPIO pin to query */
1223        cy_as_misc_gpio pin,
1224        /* Current value of the GPIO pin */
1225        uint8_t *value,
1226        /* Callback to call when the operation is complete. */
1227        cy_as_function_callback cb,
1228        /* Client data to be passed to the callback. */
1229        uint32_t client
1230        );
1231
1232/* Summary
1233   This function updates the state of a GPIO pin on the West
1234   Bridge device.
1235
1236   Description
1237   The West Bridge device has GPIO pins that can be used for
1238   user defined functions. This function updates the output
1239   value driven on a specified GPIO pin. Calling this function
1240   will configure the corresponding pin as an output.
1241
1242   * Valid In Asynchronous Callback: NO
1243
1244   Notes
1245   All of the pins listed under CyAsMiscGpio can be used as GP
1246   outputs. This feature is note supported by firmware images
1247   that include NAND storage device support.
1248
1249   Returns
1250   * CY_AS_ERROR_SUCCESS - the function completed successfully
1251   * CY_AS_ERROR_INVALID_HANDLE
1252   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
1253   *    been configured yet
1254   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
1255   *    to the West Bridge device
1256   * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
1257   * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported
1258   *    by firmware.
1259
1260   See Also
1261   * CyAsMiscGpio
1262   * CyAsMiscGetGpioValue
1263 */
1264EXTERN cy_as_return_status_t
1265cy_as_misc_set_gpio_value(
1266        /* Handle to the West Bridge device */
1267        cy_as_device_handle     handle,
1268        /* Id of the GPIO pin to set */
1269        cy_as_misc_gpio pin,
1270        /* Value to be set on the GPIO pin */
1271        uint8_t  value,
1272        /* Callback to call when the operation is complete. */
1273        cy_as_function_callback cb,
1274        /* Client data to be passed to the callback. */
1275        uint32_t client
1276        );
1277
1278/* Summary
1279   Set the West Bridge device in the low power suspend mode.
1280
1281   Description
1282   The West Bridge device has a low power suspend mode where the USB
1283   core and the internal microcontroller are powered down. This
1284   function sets the West Bridge device into this low power mode.
1285   This mode can only be entered when there is no active USB
1286   connection; i.e., when USB has not been connected or is suspended;
1287   and there are no pending USB or storage asynchronous calls. The
1288   device will exit the suspend mode and resume handling USB and
1289   processor requests when any activity is detected on the CE#, D+/D-
1290   or GPIO[0] lines.
1291
1292   * Valid In Asynchronous Callback: NO
1293
1294   Notes
1295   The GPIO[0] pin needs to be configured as an input for the gpio
1296   wakeup to work. This flag should not be enabled if the pin is
1297   being used as a GP output.
1298
1299   Returns
1300   * CY_AS_ERROR_SUCCESS - the device was placed in suspend mode.
1301   * CY_AS_ERROR_INVALID_HANDLE - the West Bridge handle passed
1302   *    in is invalid.
1303   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
1304   *    yet been configured.
1305   * CY_AS_ERROR_NO_FIRMWARE - no firmware has been downloaded
1306   *    to the device.
1307   * CY_AS_ERROR_IN_STANDBY - the device is already in sleep mode.
1308   * CY_AS_ERROR_USB_CONNECTED - the USB connection is active.
1309   * CY_AS_ERROR_ASYNC_PENDING - asynchronous storage/USB calls
1310   *    are pending.
1311   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
1312   *    the operation.
1313   * CY_AS_ERROR_INVALID_RESPONSE - command not recognised by
1314   *    firmware.
1315
1316   See Also
1317   * CyAsMiscLeaveSuspend
1318 */
1319EXTERN cy_as_return_status_t
1320cy_as_misc_enter_suspend(
1321        /* Handle to the West Bridge device */
1322        cy_as_device_handle     handle,
1323        /* Control the USB wakeup source */
1324        cy_bool usb_wakeup_en,
1325        /* Control the GPIO[0] wakeup source */
1326        cy_bool gpio_wakeup_en,
1327        /* Callback to call when suspend mode entry is complete */
1328        cy_as_function_callback cb,
1329        /* Client data to be passed to the callback. */
1330        uint32_t client
1331        );
1332
1333/* Summary
1334   Wake up the West Bridge device from suspend mode.
1335
1336   Description
1337   This call wakes up the West Bridge device from suspend mode,
1338   and makes it ready for accepting other commands from the API.
1339   A CyAsEventMiscWakeup event will be delivered to the callback
1340   registered with CyAsMiscRegisterCallback to indicate that the
1341   wake up is complete.
1342
1343   The CyAsEventMiscWakeup event will also be delivered if the
1344   wakeup happens due to USB or GPIO activity.
1345
1346   * Valid In Asynchronous Callback: NO
1347
1348   Returns
1349   * CY_AS_ERROR_SUCCESS - the device was woken up from
1350   *    suspend mode.
1351   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle
1352   *    passed in.
1353   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has
1354   *    not been configured.
1355   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been
1356   *    downloaded to the device.
1357   * CY_AS_ERROR_NOT_IN_SUSPEND - the device is not in
1358   *    suspend mode.
1359   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory
1360   *    for the operation.
1361   * CY_AS_ERROR_TIMEOUT - failed to wake up the device.
1362
1363   See Also
1364   * CyAsMiscEnterSuspend
1365 */
1366EXTERN cy_as_return_status_t
1367cy_as_misc_leave_suspend(
1368        /* Handle to the West Bridge device */
1369        cy_as_device_handle     handle,
1370        /* Callback to call when device has resumed operation. */
1371        cy_as_function_callback cb,
1372        /* Client data to be passed to the callback. */
1373        uint32_t client
1374        );
1375
1376/* Summary
1377   Reserve first numzones zones of nand device for storing
1378   processor boot image. LNA firmware works  on the first
1379   numzones zones of nand to enable the processor to boot.
1380
1381   Description
1382   This function reserves first numzones zones of nand device
1383   for storing processor boot image. This fonction MUST be
1384   completed before starting the storage stack for the setting
1385   to be taken into account.
1386
1387   * Valid In Asynchronous Callback: YES
1388
1389   Returns
1390   * CY_AS_ERROR_SUCCESS- zones are reserved.
1391
1392*/
1393EXTERN cy_as_return_status_t
1394cy_as_misc_reserve_l_n_a_boot_area(
1395        /* Handle to the West Bridge device */
1396        cy_as_device_handle      handle,
1397        /* number of nand zones to reserve */
1398        uint8_t numzones,
1399        /* Callback to call when device has resumed operation. */
1400        cy_as_function_callback cb,
1401        /* Client data to be passed to the callback. */
1402        uint32_t client
1403        );
1404
1405/* Summary
1406   Select the clock frequency to be used when talking to low
1407   speed (non-high speed) SD media.
1408
1409   Description
1410   West Bridge firmware uses a clock frequency less than the
1411   maximum possible rate for low speed SD media.  This function
1412   selects the frequency setting from between the default speed
1413   and the maximum speed. This fonction MUST be completed before
1414   starting the storage stack for the setting to be taken into
1415   account.
1416
1417   * Valid in Asynchronous Callback: Yes (if cb is non-zero)
1418   * Nestable: Yes
1419
1420   Returns
1421   * CY_AS_ERROR_SUCCESS - the operation completed successfully.
1422   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
1423   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
1424   *    configured.
1425   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
1426   *    to the device.
1427   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
1428   *    the operation.
1429   * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend
1430   *    mode.
1431   * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting
1432   *    desired.
1433   * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to
1434   *    the operation.
1435   * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support
1436   *    the operation.
1437
1438   See Also
1439   * CyAsLowSpeedSDFreq
1440 */
1441EXTERN cy_as_return_status_t
1442cy_as_misc_set_low_speed_sd_freq(
1443        /* Handle to the West Bridge device */
1444        cy_as_device_handle     handle,
1445        /* Frequency setting desired for low speed SD cards */
1446        cy_as_low_speed_sd_freq setting,
1447        /* Callback to call on completion */
1448        cy_as_function_callback cb,
1449        /* Client data to be passed to the callback */
1450        uint32_t        client
1451        );
1452
1453/* Summary
1454   Select the clock frequency to be used when talking to high speed
1455   SD/MMC media.
1456
1457   Description
1458   West Bridge firmware uses a 48 MHz clock to interface with high
1459   speed SD/MMC media.  This clock rate can be restricted to 24 MHz
1460   if desired.  This function selects the frequency setting to be
1461   used. This fonction MUST be completed before starting the storage
1462   stack for the setting to be taken into account.
1463
1464   * Valid in Asynchronous Callback: Yes (if cb is non-zero)
1465   * Nestable: Yes
1466
1467   Returns
1468   * CY_AS_ERROR_SUCCESS - the operation completed successfully.
1469   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
1470   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
1471   *    configured.
1472   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to
1473   *    the device.
1474   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the
1475   *    operation.
1476   * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend mode.
1477   * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting desired.
1478   * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to the
1479   *    operation.
1480   * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support
1481   *    the operation.
1482
1483   See Also
1484   * CyAsLowSpeedSDFreq
1485 */
1486EXTERN cy_as_return_status_t
1487cy_as_misc_set_high_speed_sd_freq(
1488        /* Handle to the West Bridge device */
1489        cy_as_device_handle     handle,
1490        /* Frequency setting desired for high speed SD cards */
1491        cy_as_high_speed_sd_freq setting,
1492        /* Callback to call on completion */
1493        cy_as_function_callback cb,
1494        /* Client data to be passed to the callback */
1495        uint32_t client
1496        );
1497/* Summary
1498   Select the polarity of the SD_POW output driven by West Bridge.
1499
1500   Description
1501   The SD_POW signal driven by West Bridge can be used to control
1502   the supply of Vcc to the SD/MMC media connected to the device.
1503   This signal is driven as an active high signal by default. This
1504   function can be used to change the polarity of this signal if
1505   required. This fonction MUST be completed before starting the
1506   storage stack for the setting to be taken into account.
1507
1508   * Valid in Asynchronous Callback: Yes (if cb is non-zero)
1509   * Nestable: Yes
1510
1511   Returns
1512   * CY_AS_ERROR_SUCCESS - the operation completed successfully.
1513   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
1514   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
1515   *    configured.
1516   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
1517   *    to the device.
1518   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
1519   *    the operation.
1520   * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power
1521   *    suspend mode.
1522   * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting
1523   *    desired.
1524   * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to
1525   *    the operation.
1526   * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not
1527   *    support the operation.
1528
1529   See Also
1530   * CyAsMiscSignalPolarity
1531 */
1532EXTERN cy_as_return_status_t
1533cy_as_misc_set_sd_power_polarity(
1534        /* Handle to the West Bridge device */
1535        cy_as_device_handle handle,
1536        /* Desired polarity setting to the SD_POW signal. */
1537        cy_as_misc_signal_polarity polarity,
1538        /* Callback to call on completion. */
1539        cy_as_function_callback cb,
1540        /* Client data to be passed to the callback. */
1541        uint32_t client
1542        );
1543
1544/* For supporting deprecated functions */
1545#include "cyasmisc_dep.h"
1546
1547#include "cyas_cplus_end.h"
1548
1549#endif                          /* _INCLUDED_CYASMISC_H_ */
1550