block: fix warning with calling smp_processor_id() in preemptible section
[pandora-kernel.git] / drivers / staging / westbridge / astoria / include / linux / westbridge / cyasdevice.h
1 /* Cypress West Bridge API header file (cyasdevice.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, Fifth Floor
18 ##Boston, MA  02110-1301, USA.
19 ## ===========================
20 */
21
22 #ifndef __INCLUDED_CYASDEVICE_H__
23 #define __INCLUDED_CYASDEVICE_H__
24
25 #include "cyashal.h"
26 #include "cyasprotocol.h"
27 #include "cyasusb.h"
28 #include "cyasstorage.h"
29 #include "cyasmtp.h"
30 #include "cyas_cplus_start.h"
31
32 /***********************************
33  * West Bridge Constants
34  ***********************************/
35
36 /* The endpoints used by West Bridge for the P port to S port path */
37 #define CY_AS_P2S_WRITE_ENDPOINT (0x04)
38 #define CY_AS_P2S_READ_ENDPOINT (0x08)
39
40 /* The endpoint to use for firmware download */
41 #define CY_AS_FIRMWARE_ENDPOINT (0x02)
42
43 /* The maximum size of the firmware image West Bridge can accept */
44 #define CY_AS_MAXIMUM_FIRMWARE_SIZE     (24 * 1024)
45
46 /* The maximum size of a write for EP0 and EP1 */
47 #define CY_AS_EP0_MAX_WRITE_SIZE (128)
48 #define CY_AS_EP1_MAX_WRITE_SIZE (64)
49
50 /* The bitfields for the device state value */
51
52 /* The device is in StandBy mode */
53 #define CY_AS_DEVICE_STATE_PIN_STANDBY (0x00000001)
54 /* The device has been configured */
55 #define CY_AS_DEVICE_STATE_CONFIGURED (0x00000002)
56 /* The firmware has been loaded into the device */
57 #define CY_AS_DEVICE_STATE_FIRMWARE_LOADED (0x00000004)
58 /* The interrupt module has been initialized */
59 #define CY_AS_DEVICE_STATE_LOWLEVEL_MODULE (0x00000008)
60 /* The DMA module has been initialized */
61 #define CY_AS_DEVICE_STATE_DMA_MODULE (0x00000010)
62 /* The interrupt module has been initialized */
63 #define CY_AS_DEVICE_STATE_INTR_MODULE (0x00000020)
64 /* The storage module has been initialized */
65 #define CY_AS_DEVICE_STATE_STORAGE_MODULE (0x00000040)
66 /* The USB module has been initialized */
67 #define CY_AS_DEVICE_STATE_USB_MODULE (0x00000080)
68 /* If set, the API wants SCSI messages */
69 #define CY_AS_DEVICE_STATE_STORAGE_SCSIMSG (0x00000100)
70 /* If set, an ASYNC storage operation is pending */
71 #define CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING (0x00000200)
72 /* If set, the USB port is connected */
73 #define CY_AS_DEVICE_STATE_USB_CONNECTED (0x00000400)
74 /* If set and USB is connected, it is high speed */
75 #define CY_AS_DEVICE_STATE_USB_HIGHSPEED (0x00000800)
76 /* If set, we are in a callback */
77 #define CY_AS_DEVICE_STATE_IN_CALLBACK (0x00001000)
78 /* If set, we are processing a setup packet */
79 #define CY_AS_DEVICE_STATE_IN_SETUP_PACKET (0x00004000)
80 /* The device was placed in standby via register */
81 #define CY_AS_DEVICE_STATE_REGISTER_STANDBY (0x00008000)
82 /* If set, the device is using a crystal */
83 #define CY_AS_DEVICE_STATE_CRYSTAL (0x00010000)
84 /* If set, wakeup has been called */
85 #define CY_AS_DEVICE_STATE_WAKING (0x00020000)
86 /* If set, EP0 has been stalled. */
87 #define CY_AS_DEVICE_STATE_EP0_STALLED (0x00040000)
88 /* If set, device is in suspend mode. */
89 #define CY_AS_DEVICE_STATE_SUSPEND (0x00080000)
90 /* If set, device is a reset is pending. */
91 #define CY_AS_DEVICE_STATE_RESETP (0x00100000)
92 /* If set, device is a standby is pending. */
93 #define CY_AS_DEVICE_STATE_STANDP (0x00200000)
94 /* If set, device has a storage start or stop pending. */
95 #define CY_AS_DEVICE_STATE_SSSP (0x00400000)
96 /* If set, device has a usb start or stop pending. */
97 #define CY_AS_DEVICE_STATE_USSP (0x00800000)
98 /* If set, device has a mtp start or stop pending. */
99 #define CY_AS_DEVICE_STATE_MSSP (0x01000000)
100 /* If set, P2S DMA transfer can be started. */
101 #define CY_AS_DEVICE_STATE_P2SDMA_START (0x02000000)
102
103 /* The bitfields for the endpoint state value */
104 /* DMA requests are accepted into the queue */
105 #define CY_AS_DMA_ENDPOINT_STATE_ENABLED (0x0001)
106 /* The endpoint has a sleeping client, waiting on a queue drain */
107 #define CY_AS_DMA_ENDPOINT_STATE_SLEEPING (0x0002)
108 /* The DMA backend to hardware is running */
109 #define CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING (0x0004)
110 /* There is an outstanding DMA entry deployed to the HAL */
111 #define CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT (0x0008)
112 /* 0 = OUT (West Bridge -> P Port), 1 = IN (P Port -> West Bridge) */
113 #define CY_AS_DMA_ENDPOINT_STATE_DIRECTION (0x0010)
114
115 /* The state values for the request list */
116 /* Mask for getting the state information */
117 #define CY_AS_REQUEST_LIST_STATE_MASK (0x0f)
118 /* The request is queued, nothing further */
119 #define CY_AS_REQUEST_LIST_STATE_QUEUED (0x00)
120 /* The request is sent, waiting for response */
121 #define CY_AS_REQUEST_LIST_STATE_WAITING (0x01)
122 /* The response has been received, processing response */
123 #define CY_AS_REQUEST_LIST_STATE_RECEIVED (0x02)
124 /* The request/response is being canceled */
125 #define CY_AS_REQUEST_LIST_STATE_CANCELING (0x03)
126 /* The request is synchronous */
127 #define CY_AS_REQUEST_LIST_STATE_SYNC (0x80)
128
129 /* The flag values for a LL RequestResponse */
130 /* This request requires an ACK to be sent after it is completed */
131 #define CY_AS_REQUEST_RESPONSE_DELAY_ACK (0x01)
132 /* This request originated from a version V1.1 function call */
133 #define CY_AS_REQUEST_RESPONSE_EX (0x02)
134 /* This request originated from a version V1.2 function call */
135 #define CY_AS_REQUEST_RESPONSE_MS (0x04)
136
137
138 #define CY_AS_DEVICE_HANDLE_SIGNATURE (0x01211219)
139
140 /*
141  * This macro returns the endpoint pointer given the
142  * device pointer and an endpoint number
143  */
144 #define CY_AS_NUM_EP(dev_p, num) ((dev_p)->endp[(num)])
145
146 /****************************************
147  * West Bridge Data Structures
148  ****************************************/
149
150 typedef struct cy_as_device cy_as_device;
151
152 /* Summary
153    This type defines a callback function that will be called
154    on completion of a DMA operation.
155
156    Description
157    This function definition is for a function that is called when
158    the DMA operation is complete. This function is called with the
159    endpoint number, operation type, buffer pointer and size.
160
161    See Also
162    * CyAsDmaOper
163    * CyAsDmaQueueWrite
164  */
165 typedef void (*cy_as_dma_callback)(
166         /* The device that completed DMA */
167         cy_as_device *dev_p,
168         /* The endpoint that completed DMA */
169         cy_as_end_point_number_t ep,
170         /* The pointer to the buffer that completed DMA */
171         void *mem_p,
172         /* The amount of data transferred */
173         uint32_t size,
174         /* The error code for this DMA xfer */
175         cy_as_return_status_t error
176         );
177
178 /* Summary
179    This structure defines a DMA request that is queued
180
181    Description
182    This structure contains the information about a DMA
183    request that is queued and is to be sent when possible.
184 */
185 typedef struct cy_as_dma_queue_entry {
186         /* Pointer to memory buffer for this request */
187         void *buf_p;
188         /* Size of the memory buffer for DMA operation */
189         uint32_t size;
190         /* Offset into memory buffer for next DMA operation */
191         uint32_t offset;
192         /* If TRUE and IN request */
193         cy_bool packet;
194         /* If TRUE, this is a read request */
195         cy_bool readreq;
196         /* Callback function for when DMA is complete */
197         cy_as_dma_callback      cb;
198         /* Pointer to next entry in queue */
199         struct cy_as_dma_queue_entry *next_p;
200 } cy_as_dma_queue_entry;
201
202 /* Summary
203    This structure defines the endpoint data for a given
204
205    Description
206    This structure defines all of the information required
207    to manage DMA for a given endpoint.
208 */
209 typedef struct cy_as_dma_end_point {
210         /* The endpoint number */
211         cy_as_end_point_number_t ep;
212         /* The state of this endpoint */
213         uint8_t state;
214         /* The maximum amount of data accepted in a packet by the hw */
215         uint16_t maxhwdata;
216         /* The maximum amount of data accepted by the HAL layer */
217         uint32_t maxhaldata;
218         /* The queue for DMA operations */
219         cy_as_dma_queue_entry *queue_p;
220         /* The last entry in the DMA queue */
221         cy_as_dma_queue_entry *last_p;
222         /* This sleep channel is used to wait while the DMA queue
223          * drains for a given endpoint */
224         cy_as_hal_sleep_channel                  channel;
225 } cy_as_dma_end_point;
226
227 #define cy_as_end_point_number_is_usb(n) \
228         ((n) != 2 && (n) != 4 && (n) != 6 && (n) != 8)
229 #define cy_as_end_point_number_is_storage(n) \
230         ((n) == 2 || (n) == 4 || (n) == 6 || (n) == 8)
231
232 #define cy_as_dma_end_point_is_enabled(ep) \
233         ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_ENABLED)
234 #define cy_as_dma_end_point_enable(ep) \
235         ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_ENABLED)
236 #define cy_as_dma_end_point_disable(ep) \
237         ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_ENABLED)
238
239 #define cy_as_dma_end_point_is_sleeping(ep) \
240         ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_SLEEPING)
241 #define cy_as_dma_end_point_set_sleep_state(ep) \
242         ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_SLEEPING)
243 #define cy_as_dma_end_point_set_wake_state(ep) \
244         ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_SLEEPING)
245
246 #define cy_as_dma_end_point_is_running(ep) \
247         ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING)
248 #define cy_as_dma_end_point_set_running(ep) \
249         ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING)
250 #define cy_as_dma_end_point_set_stopped(ep) \
251         ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_DMA_RUNNING)
252
253 #define cy_as_dma_end_point_in_transit(ep) \
254         ((ep)->state & CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT)
255 #define cy_as_dma_end_point_set_in_transit(ep) \
256         ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT)
257 #define cy_as_dma_end_point_clear_in_transit(ep) \
258         ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_IN_TRANSIT)
259
260 #define cy_as_dma_end_point_is_direction_in(ep) \
261         (((ep)->state & CY_AS_DMA_ENDPOINT_STATE_DIRECTION) == \
262                 CY_AS_DMA_ENDPOINT_STATE_DIRECTION)
263 #define cy_as_dma_end_point_is_direction_out(ep) \
264         (((ep)->state & CY_AS_DMA_ENDPOINT_STATE_DIRECTION) == 0)
265 #define cy_as_dma_end_point_set_direction_in(ep) \
266         ((ep)->state |= CY_AS_DMA_ENDPOINT_STATE_DIRECTION)
267 #define cy_as_dma_end_point_set_direction_out(ep) \
268         ((ep)->state &= ~CY_AS_DMA_ENDPOINT_STATE_DIRECTION)
269
270 #define cy_as_dma_end_point_is_usb(p) \
271         cy_as_end_point_number_is_usb((p)->ep)
272 #define cy_as_dma_end_point_is_storage(p) \
273         cy_as_end_point_number_is_storage((p)->ep)
274
275 typedef struct cy_as_ll_request_response {
276         /* The mbox[0] contents - see low level comm section of API doc */
277         uint16_t        box0;
278         /* The amount of data stored in this request/response in bytes */
279         uint16_t        stored;
280         /* Length of this request in words */
281         uint16_t        length;
282         /* Additional status information about the request */
283         uint16_t        flags;
284         /* Note: This is over indexed and contains the request/response data */
285         uint16_t        data[1];
286 } cy_as_ll_request_response;
287
288 /*
289  * The callback function for responses
290  */
291 typedef void (*cy_as_response_callback)(
292         /* The device that had the response */
293         cy_as_device *dev_p,
294         /* The context receiving a response */
295         uint8_t                                          context,
296         /* The request data */
297         cy_as_ll_request_response *rqt,
298         /* The response data */
299         cy_as_ll_request_response *resp,
300         /* The status of the request */
301         cy_as_return_status_t status
302         );
303
304 typedef struct cy_as_ll_request_list_node {
305         /* The request to send */
306         cy_as_ll_request_response *rqt;
307         /* The associated response for the request */
308         cy_as_ll_request_response *resp;
309         /* Length of the response */
310         uint16_t                                                length;
311         /* The callback to call when done */
312         cy_as_response_callback                 callback;
313         /* The state of the request */
314         uint8_t                                          state;
315         /* The next request in the list */
316         struct cy_as_ll_request_list_node *next;
317 } cy_as_ll_request_list_node;
318
319 #define cy_as_request_get_node_state(node_p) \
320         ((node_p)->state & CY_AS_REQUEST_LIST_STATE_MASK)
321 #define cy_as_request_set_node_state(node_p, st) \
322         ((node_p)->state = \
323         ((node_p)->state & ~CY_AS_REQUEST_LIST_STATE_MASK) | (st))
324
325 #define cy_as_request_node_is_sync(node_p) \
326         ((node_p)->state & CY_AS_REQUEST_LIST_STATE_SYNC)
327 #define cy_as_request_node_set_sync(node_p) \
328         ((node_p)->state |= CY_AS_REQUEST_LIST_STATE_SYNC)
329 #define cy_as_request_node_clear_sync(node_p) \
330         ((node_p)->state &= ~CY_AS_REQUEST_LIST_STATE_SYNC)
331
332 #ifndef __doxygen__
333 typedef enum cy_as_c_b_node_type {
334         CYAS_INVALID,
335         CYAS_USB_FUNC_CB,
336         CYAS_USB_IO_CB,
337         CYAS_STORAGE_IO_CB,
338         CYAS_FUNC_CB
339 } cy_as_c_b_node_type;
340
341 typedef struct cy_as_func_c_b_node {
342         cy_as_c_b_node_type                       node_type;
343         cy_as_function_callback         cb_p;
344         uint32_t                                        client_data;
345         cy_as_funct_c_b_type                     data_type;
346         void    *data;
347         struct cy_as_func_c_b_node *next_p;
348 } cy_as_func_c_b_node;
349
350 extern cy_as_func_c_b_node*
351 cy_as_create_func_c_b_node_data(cy_as_function_callback
352         cb, uint32_t client, cy_as_funct_c_b_type type, void *data);
353
354 extern cy_as_func_c_b_node*
355 cy_as_create_func_c_b_node(cy_as_function_callback cb,
356         uint32_t client);
357
358 extern void
359 cy_as_destroy_func_c_b_node(cy_as_func_c_b_node *node);
360
361 typedef struct cy_as_mtp_func_c_b_node {
362         cy_as_c_b_node_type                       type;
363         cy_as_mtp_function_callback      cb_p;
364         uint32_t                                        client_data;
365         struct cy_as_mtp_func_c_b_node *next_p;
366 } cy_as_mtp_func_c_b_node;
367
368 extern cy_as_mtp_func_c_b_node*
369 cy_as_create_mtp_func_c_b_node(cy_as_mtp_function_callback cb,
370         uint32_t client);
371
372 extern void
373 cy_as_destroy_mtp_func_c_b_node(cy_as_mtp_func_c_b_node *node);
374
375 typedef struct cy_as_usb_func_c_b_node {
376         cy_as_c_b_node_type     type;
377         cy_as_usb_function_callback      cb_p;
378         uint32_t client_data;
379         struct cy_as_usb_func_c_b_node *next_p;
380 } cy_as_usb_func_c_b_node;
381
382 extern cy_as_usb_func_c_b_node*
383 cy_as_create_usb_func_c_b_node(cy_as_usb_function_callback cb,
384         uint32_t client);
385
386 extern void
387 cy_as_destroy_usb_func_c_b_node(cy_as_usb_func_c_b_node *node);
388
389 typedef struct cy_as_usb_io_c_b_node {
390         cy_as_c_b_node_type                       type;
391         cy_as_usb_io_callback              cb_p;
392         struct cy_as_usb_io_c_b_node *next_p;
393 } cy_as_usb_io_c_b_node;
394
395 extern cy_as_usb_io_c_b_node*
396 cy_as_create_usb_io_c_b_node(cy_as_usb_io_callback cb);
397
398 extern void
399 cy_as_destroy_usb_io_c_b_node(cy_as_usb_io_c_b_node *node);
400
401 typedef struct cy_as_storage_io_c_b_node {
402         cy_as_c_b_node_type                       type;
403         cy_as_storage_callback           cb_p;
404         /* The media for the currently outstanding async storage request */
405         cy_as_media_type                           media;
406         /* The device index for the currently outstanding async storage
407          * request */
408         uint32_t                                        device_index;
409         /* The unit index for the currently outstanding async storage
410          * request */
411         uint32_t                                        unit;
412         /* The block address for the currently outstanding async storage
413          * request */
414         uint32_t                                        block_addr;
415         /* The operation for the currently outstanding async storage
416          * request */
417         cy_as_oper_type                         oper;
418         cy_as_ll_request_response *req_p;
419         cy_as_ll_request_response *reply_p;
420         struct cy_as_storage_io_c_b_node *next_p;
421 } cy_as_storage_io_c_b_node;
422
423 extern cy_as_storage_io_c_b_node*
424 cy_as_create_storage_io_c_b_node(cy_as_storage_callback cb,
425         cy_as_media_type media, uint32_t device_index,
426         uint32_t unit, uint32_t block_addr, cy_as_oper_type oper,
427         cy_as_ll_request_response *req_p,
428         cy_as_ll_request_response *reply_p);
429
430 extern void
431 cy_as_destroy_storage_io_c_b_node(cy_as_storage_io_c_b_node *node);
432
433 typedef struct cy_as_c_b_queue {
434         void *head_p;
435         void *tail_p;
436         uint32_t count;
437         cy_as_c_b_node_type type;
438 } cy_as_c_b_queue;
439
440 extern cy_as_c_b_queue *
441 cy_as_create_c_b_queue(cy_as_c_b_node_type type);
442
443 extern void
444 cy_as_destroy_c_b_queue(cy_as_c_b_queue *queue);
445
446 /* Allocates a new CyAsCBNode */
447 extern void
448 cy_as_insert_c_b_node(cy_as_c_b_queue *queue_p, void *cbnode);
449
450 /* Removes the first CyAsCBNode from the queue and frees it */
451 extern void
452 cy_as_remove_c_b_node(cy_as_c_b_queue *queue_p);
453
454 /* Remove the last CyAsCBNode from the queue and frees it */
455 extern void
456 cy_as_remove_c_b_tail_node(cy_as_c_b_queue *queue_p);
457
458 /* Removes and frees all pending callbacks */
459 extern void
460 cy_as_clear_c_b_queue(cy_as_c_b_queue *queue_p);
461
462 extern cy_as_return_status_t
463 cy_as_misc_send_request(cy_as_device *dev_p,
464                                           cy_as_function_callback cb,
465                                           uint32_t client,
466                                           cy_as_funct_c_b_type type,
467                                           void *data,
468                                           cy_as_c_b_queue *queue,
469                                           uint16_t req_type,
470                                           cy_as_ll_request_response *req_p,
471                                           cy_as_ll_request_response *reply_p,
472                                           cy_as_response_callback rcb);
473
474 extern void
475 cy_as_misc_cancel_ex_requests(cy_as_device *dev_p);
476
477 /* Summary
478    Free all memory allocated by and zero all
479    structures initialized by CyAsUsbStart.
480  */
481 extern void
482 cy_as_usb_cleanup(
483                 cy_as_device *dev_p);
484
485 /* Summary
486    Free all memory allocated and zero all structures initialized
487    by CyAsStorageStart.
488  */
489 extern void
490 cy_as_storage_cleanup(
491                 cy_as_device *dev_p);
492 #endif
493
494 /* Summary
495    This structure defines the data structure to support a
496    given command context
497
498    Description
499    All commands send to the West Bridge device via the mailbox
500    registers are sent via a context.Each context is independent
501    and there can be a parallel stream of requests and responses on
502    each context.  This structure is used to manage a single context.
503 */
504 typedef struct cy_as_context {
505         /* The context number for this context */
506         uint8_t                                          number;
507         /* This sleep channel is used to sleep while waiting on a
508          * response from the west bridge device for a request. */
509         cy_as_hal_sleep_channel                  channel;
510         /* The buffer for received requests */
511         cy_as_ll_request_response *req_p;
512         /* The length of the request being received */
513         uint16_t request_length;
514         /* The callback for the next request received */
515         cy_as_response_callback request_callback;
516         /* A list of low level requests to go to the firmware */
517         cy_as_ll_request_list_node *request_queue_p;
518         /* The list node in the request queue */
519         cy_as_ll_request_list_node *last_node_p;
520         /* Index up to which data is stored. */
521         uint16_t queue_index;
522         /* Index to the next request in the queue. */
523         uint16_t rqt_index;
524         /* Queue of data stored */
525         uint16_t data_queue[128];
526
527 } cy_as_context;
528
529 #define cy_as_context_is_waiting(ctxt) \
530         ((ctxt)->state & CY_AS_CTXT_STATE_WAITING_RESPONSE)
531 #define cy_as_context_set_waiting(ctxt) \
532         ((ctxt)->state |= CY_AS_CTXT_STATE_WAITING_RESPONSE)
533 #define cy_as_context_clear_waiting(ctxt) \
534         ((ctxt)->state &= ~CY_AS_CTXT_STATE_WAITING_RESPONSE)
535
536
537
538 /* Summary
539    This data structure stores SDIO function
540    parameters for a SDIO card
541
542    Description
543 */
544 typedef struct cy_as_sdio_device {
545         /* Keeps track of IO functions initialized*/
546         uint8_t  function_init_map;
547         uint8_t  function_suspended_map;
548         /* Function 0 (Card Common) properties*/
549         cy_as_sdio_card card;
550         /* Function 1-7 (Mapped to array element 0-6) properties.*/
551         cy_as_sdio_func function[7];
552
553 } cy_as_sdio_device;
554
555 /* Summary
556 Macros to access the SDIO card properties
557 */
558
559 #define cy_as_sdio_get_function_code(handle, bus, i) \
560         (((cy_as_device *)handle)->sdiocard[bus].function[i-1].function_code)
561
562 #define cy_as_sdio_get_function_ext_code(handle, bus, i)        \
563         (((cy_as_device *)handle)->sdiocard[bus].\
564                 function[i-1].extended_func_code)
565
566 #define cy_as_sdio_get_function_p_s_n(handle, bus, i) \
567         (((cy_as_device *)handle)->sdiocard[bus].function[i-1].card_psn)
568
569 #define cy_as_sdio_get_function_blocksize(handle, bus, i)  \
570         (((cy_as_device *)handle)->sdiocard[bus].function[i-1].blocksize)
571
572 #define cy_as_sdio_get_function_max_blocksize(handle, bus, i) \
573         (((cy_as_device *)handle)->sdiocard[bus].function[i-1].maxblocksize)
574
575 #define cy_as_sdio_get_function_csa_support(handle, bus, i) \
576         (((cy_as_device *)handle)->sdiocard[bus].function[i-1].csa_bits)
577
578 #define cy_as_sdio_get_function_wakeup_support(handle, bus, i) \
579         (((cy_as_device *)handle)->sdiocard[bus].function[i-1]. wakeup_support)
580
581 #define cy_as_sdio_set_function_block_size(handle, bus, i, blocksize) \
582         (((cy_as_device *)handle)->sdiocard[bus].function[i-1].blocksize = \
583         blocksize)
584
585 #define cy_as_sdio_get_card_num_functions(handle, bus) \
586         (((cy_as_device *)handle)->sdiocard[bus].card.num_functions)
587
588 #define cy_as_sdio_get_card_mem_present(handle, bus) \
589         (((cy_as_device *)handle)->sdiocard[bus].card.memory_present)
590
591 #define cy_as_sdio_get_card_manf_id(handle, bus)        \
592         (((cy_as_device *)handle)->sdiocard[bus].card.manufacturer__id)
593
594 #define cy_as_sdio_get_card_manf_info(handle, bus) \
595         (((cy_as_device *)handle)->sdiocard[bus].card.manufacturer_info)
596
597 #define cy_as_sdio_get_card_blocksize(handle, bus) \
598         (((cy_as_device *)handle)->sdiocard[bus].card.blocksize)
599
600 #define cy_as_sdio_get_card_max_blocksize(handle, bus) \
601         (((cy_as_device *)handle)->sdiocard[bus].card.maxblocksize)
602
603 #define cy_as_sdio_get_card_sdio_version(handle, bus) \
604         (((cy_as_device *)handle)->sdiocard[bus].card.sdio_version)
605
606 #define cy_as_sdio_get_card_capability(handle, bus) \
607         (((cy_as_device *)handle)->sdiocard[bus].card.card_capability)
608
609 #define cy_as_sdio_get_function_init_map(handle, bus) \
610         (((cy_as_device *)handle)->sdiocard[bus].function_init_map)
611
612 #define cy_as_sdio_check_function_initialized(handle, bus, i) \
613         (((cy_as_sdio_get_function_init_map(handle, bus)) & (0x01<<i)) ? 1 : 0)
614
615 #define cy_as_sdio_set_card_block_size(handle, bus, blocksize) \
616         (((cy_as_device *)handle)->sdiocard[bus].card.blocksize = blocksize)
617
618 #define cy_as_sdio_check_support_bus_suspend(handle, bus) \
619         ((cy_as_sdio_get_card_capability(handle, bus) & CY_SDIO_SBS) ? 1 : 0)
620
621 #define cy_as_sdio_check_function_suspended(handle, bus, i) \
622         ((((cy_as_device *)handle)->sdiocard[bus].function_suspended_map & \
623                 (0x01<<i)) ? 1 : 0)
624
625 #define cy_as_sdio_set_function_suspended(handle, bus, i) \
626         ((((cy_as_device *)handle)->sdiocard[bus].function_suspended_map) \
627         |= (0x01<<i))
628
629 #define cy_as_sdio_clear_function_suspended(handle, bus, i) \
630         ((((cy_as_device *)handle)->sdiocard[bus].function_suspended_map) \
631         &= (~(0x01<<i)))
632
633 /* Summary
634    This data structure represents a single device.
635
636    Description
637 */
638 struct cy_as_device {
639         /* General stuff */
640         /* A signature to insure we have a valid handle */
641         uint32_t sig;
642         /* The ID of the silicon */
643         uint16_t silicon_id;
644         /* Pointer to the next device */
645         struct cy_as_device *next_p;
646         /* This is the client specific tag for this device */
647         cy_as_hal_device_tag tag;
648         /* This contains various state information about the device */
649         uint32_t state;
650         /* Flag indicating whether INT# pin is used for DRQ */
651         cy_bool use_int_drq;
652
653         /* DMA related */
654         /* The endpoint pointers associated with this device */
655         cy_as_dma_end_point      *endp[16];
656         /* List of queue entries that can be used for xfers */
657         cy_as_dma_queue_entry *dma_freelist_p;
658
659         /* Low level comm related */
660         /* The contexts available in this device */
661         cy_as_context *context[CY_RQT_CONTEXT_COUNT];
662         /* The low level error returned from sending an async request */
663         cy_as_return_status_t ll_error;
664         /* A request is currently being sent to West Bridge. */
665         cy_bool ll_sending_rqt;
666         /* The current mailbox request should be aborted. */
667         cy_bool ll_abort_curr_rqt;
668         /* Indicates that the LL layer has queued mailbox data. */
669         cy_bool ll_queued_data;
670
671         /* MISC API related */
672         /* Misc callback */
673         cy_as_misc_event_callback misc_event_cb;
674
675         /* Storage Related */
676         /* The reference count for the Storage API */
677         uint32_t storage_count;
678         /* Callback for storage events */
679         cy_as_storage_event_callback_dep        storage_event_cb;
680         /* V1.2+ callback for storage events */
681         cy_as_storage_event_callback  storage_event_cb_ms;
682         /* The error for a sleeping storage operation */
683         cy_as_return_status_t             storage_error;
684         /* Flag indicating that the storage stack is waiting for an operation */
685         cy_bool                                   storage_wait;
686         /* Request used for storage read/writes. */
687         cy_as_ll_request_response *storage_rw_req_p;
688         /* Response used for storage read/writes. */
689         cy_as_ll_request_response *storage_rw_resp_p;
690         /* The storage callback */
691         cy_as_storage_callback_dep storage_cb;
692         /* The V1.2+ storage callback */
693         cy_as_storage_callback storage_cb_ms;
694         /* The bus index for the currently outstanding async storage request */
695         cy_as_bus_number_t storage_bus_index;
696         /* The device index for the currently outstanding async storage
697          * request */
698         uint32_t storage_device_index;
699         /* The unit index for the currently outstanding async storage request */
700         uint32_t storage_unit;
701         /* The block address for the currently outstanding async storage
702          * request */
703         uint32_t storage_block_addr;
704         /* The operation for the currently outstanding async storage request */
705         cy_as_oper_type storage_oper;
706         /* The endpoint used to read Storage data */
707         cy_as_end_point_number_t storage_read_endpoint;
708         /* The endpoint used to write endpoint data */
709         cy_as_end_point_number_t storage_write_endpoint;
710         cy_as_device_desc storage_device_info
711                 [CY_AS_MAX_BUSES][CY_AS_MAX_STORAGE_DEVICES];
712         /* The information on each device on each bus */
713
714         /* USB Related */
715         /* This conatins the endpoint async state */
716         uint16_t epasync;
717         /* The reference count for the USB API */
718         uint32_t usb_count;
719         /* The physical endpoint configuration */
720         uint8_t usb_phy_config;
721         /* The callbacks for async func calls */
722         cy_as_c_b_queue *usb_func_cbs;
723         /* Endpoint configuration information */
724         cy_as_usb_end_point_config usb_config[16];
725         /* The USB callback */
726         cy_as_usb_event_callback_dep usb_event_cb;
727         /* The V1.2+ USB callback */
728         cy_as_usb_event_callback usb_event_cb_ms;
729         /* The error for a sleeping usb operation */
730         cy_as_return_status_t usb_error;
731         /* The USB callback for a pending storage operation */
732         cy_as_usb_io_callback usb_cb[16];
733         /* The buffer pending from a USB operation */
734         void *usb_pending_buffer;
735         /* The size of the buffer pending from a USB operation */
736         uint32_t usb_pending_size;
737         /* If true, send a short packet */
738         cy_bool usb_spacket[16];
739         /* The amount of data actually xferred */
740         uint32_t usb_actual_cnt;
741         /* EP1OUT and EP1IN config register contents */
742         uint8_t usb_ep1cfg[2];
743         /* LEP config register contents */
744         uint16_t usb_lepcfg[10];
745         /* PEP config register contents */
746         uint16_t usb_pepcfg[4];
747         /* Buffer for EP0 and EP1 data sent via mailboxes */
748         uint8_t *usb_ep_data;
749         /* Used to track how many ack requests are pending */
750         uint32_t usb_delay_ack_count;
751         /* Maximum transfer size for USB endpoints. */
752         uint32_t usb_max_tx_size;
753
754         /* Request for sending EP0 data to West Bridge */
755         cy_as_ll_request_response *usb_ep0_dma_req;
756         /* Response for EP0 data sent to West Bridge */
757         cy_as_ll_request_response *usb_ep0_dma_resp;
758         /* Request for sending EP1 data to West Bridge */
759         cy_as_ll_request_response *usb_ep1_dma_req;
760         /* Response for EP1 data sent to West Bridge */
761         cy_as_ll_request_response *usb_ep1_dma_resp;
762
763         cy_as_ll_request_response *usb_ep0_dma_req_save;
764         cy_as_ll_request_response *usb_ep0_dma_resp_save;
765
766         /* MTP Related */
767         /* The reference count for the MTP API */
768         uint32_t mtp_count;
769         /* The MTP event callback supplied by the client */
770         cy_as_mtp_event_callback mtp_event_cb;
771         /* The current block table to be transferred */
772         cy_as_mtp_block_table *tp_blk_tbl;
773
774         cy_as_c_b_queue *func_cbs_mtp;
775         cy_as_c_b_queue *func_cbs_usb;
776         cy_as_c_b_queue *func_cbs_stor;
777         cy_as_c_b_queue *func_cbs_misc;
778         cy_as_c_b_queue *func_cbs_res;
779
780         /* The last USB event that was received */
781         cy_as_usb_event usb_last_event;
782         /* Types of storage media supported by the firmware */
783         uint8_t media_supported[CY_AS_MAX_BUSES];
784
785         /* SDIO card parameters*/
786         cy_as_sdio_device   sdiocard[CY_AS_MAX_BUSES];
787         /* if true, MTP enabled Firmware. */
788         cy_bool is_mtp_firmware;
789         /* if true, mailbox message has come already */
790         cy_bool is_mtp_data_pending;
791         /* True between the time an Init was called and
792          * the complete event is generated */
793         cy_bool mtp_turbo_active;
794         /* mbox reported EP 2 data len */
795         uint16_t mtp_data_len;
796         /* The error for mtp EP4 write operation */
797         cy_as_return_status_t mtp_error;
798         /* mtp send/get operation callback */
799         cy_as_function_callback mtp_cb;
800         /* mtp send/get operation client id */
801         uint32_t mtp_client;
802         /* mtp operation type. To be used in callback */
803         cy_as_funct_c_b_type mtp_op;
804
805         /* Firmware is running in P2S only mode. */
806         cy_bool is_storage_only_mode;
807         /* Interrupt mask value during device standby. */
808         uint32_t stby_int_mask;
809 };
810
811 #define cy_as_device_is_configured(dp) \
812         ((dp)->state & CY_AS_DEVICE_STATE_CONFIGURED)
813 #define cy_as_device_set_configured(dp) \
814         ((dp)->state |= CY_AS_DEVICE_STATE_CONFIGURED)
815 #define cy_as_device_set_unconfigured(dp) \
816         ((dp)->state &= ~CY_AS_DEVICE_STATE_CONFIGURED)
817
818 #define cy_as_device_is_dma_running(dp) \
819         ((dp)->state & CY_AS_DEVICE_STATE_DMA_MODULE)
820 #define cy_as_device_set_dma_running(dp) \
821         ((dp)->state |= CY_AS_DEVICE_STATE_DMA_MODULE)
822 #define cy_as_device_set_dma_stopped(dp) \
823         ((dp)->state &= ~CY_AS_DEVICE_STATE_DMA_MODULE)
824
825 #define cy_as_device_is_low_level_running(dp) \
826         ((dp)->state & CY_AS_DEVICE_STATE_LOWLEVEL_MODULE)
827 #define cy_as_device_set_low_level_running(dp) \
828         ((dp)->state |= CY_AS_DEVICE_STATE_LOWLEVEL_MODULE)
829 #define cy_as_device_set_low_level_stopped(dp) \
830         ((dp)->state &= ~CY_AS_DEVICE_STATE_LOWLEVEL_MODULE)
831
832 #define cy_as_device_is_intr_running(dp) \
833         ((dp)->state & CY_AS_DEVICE_STATE_INTR_MODULE)
834 #define cy_as_device_set_intr_running(dp) \
835         ((dp)->state |= CY_AS_DEVICE_STATE_INTR_MODULE)
836 #define cy_as_device_set_intr_stopped(dp) \
837         ((dp)->state &= ~CY_AS_DEVICE_STATE_INTR_MODULE)
838
839 #define cy_as_device_is_firmware_loaded(dp) \
840         ((dp)->state & CY_AS_DEVICE_STATE_FIRMWARE_LOADED)
841 #define cy_as_device_set_firmware_loaded(dp) \
842         ((dp)->state |= CY_AS_DEVICE_STATE_FIRMWARE_LOADED)
843 #define cy_as_device_set_firmware_not_loaded(dp) \
844         ((dp)->state &= ~CY_AS_DEVICE_STATE_FIRMWARE_LOADED)
845
846 #define cy_as_device_is_storage_running(dp) \
847         ((dp)->state & CY_AS_DEVICE_STATE_STORAGE_MODULE)
848 #define cy_as_device_set_storage_running(dp) \
849         ((dp)->state |= CY_AS_DEVICE_STATE_STORAGE_MODULE)
850 #define cy_as_device_set_storage_stopped(dp) \
851         ((dp)->state &= ~CY_AS_DEVICE_STATE_STORAGE_MODULE)
852
853 #define cy_as_device_is_usb_running(dp) \
854         ((dp)->state & CY_AS_DEVICE_STATE_USB_MODULE)
855 #define cy_as_device_set_usb_running(dp) \
856         ((dp)->state |= CY_AS_DEVICE_STATE_USB_MODULE)
857 #define cy_as_device_set_usb_stopped(dp) \
858         ((dp)->state &= ~CY_AS_DEVICE_STATE_USB_MODULE)
859
860 #define cy_as_device_wants_scsi_messages(dp) \
861         (((dp)->state & CY_AS_DEVICE_STATE_STORAGE_SCSIMSG) \
862         ? cy_true : cy_false)
863 #define cy_as_device_set_scsi_messages(dp) \
864         ((dp)->state |= CY_AS_DEVICE_STATE_STORAGE_SCSIMSG)
865 #define cy_as_device_clear_scsi_messages(dp) \
866         ((dp)->state &= ~CY_AS_DEVICE_STATE_STORAGE_SCSIMSG)
867
868 #define cy_as_device_is_storage_async_pending(dp) \
869         ((dp)->state & CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING)
870 #define cy_as_device_set_storage_async_pending(dp) \
871         ((dp)->state |= CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING)
872 #define cy_as_device_clear_storage_async_pending(dp) \
873         ((dp)->state &= ~CY_AS_DEVICE_STATE_STORAGE_ASYNC_PENDING)
874
875 #define cy_as_device_is_usb_connected(dp) \
876         ((dp)->state & CY_AS_DEVICE_STATE_USB_CONNECTED)
877 #define cy_as_device_set_usb_connected(dp) \
878         ((dp)->state |= CY_AS_DEVICE_STATE_USB_CONNECTED)
879 #define cy_as_device_clear_usb_connected(dp) \
880         ((dp)->state &= ~CY_AS_DEVICE_STATE_USB_CONNECTED)
881
882 #define cy_as_device_is_usb_high_speed(dp) \
883         ((dp)->state & CY_AS_DEVICE_STATE_USB_HIGHSPEED)
884 #define cy_as_device_set_usb_high_speed(dp) \
885         ((dp)->state |= CY_AS_DEVICE_STATE_USB_HIGHSPEED)
886 #define cy_as_device_clear_usb_high_speed(dp) \
887         ((dp)->state &= ~CY_AS_DEVICE_STATE_USB_HIGHSPEED)
888
889 #define cy_as_device_is_in_callback(dp) \
890         ((dp)->state & CY_AS_DEVICE_STATE_IN_CALLBACK)
891 #define cy_as_device_set_in_callback(dp) \
892         ((dp)->state |= CY_AS_DEVICE_STATE_IN_CALLBACK)
893 #define cy_as_device_clear_in_callback(dp) \
894         ((dp)->state &= ~CY_AS_DEVICE_STATE_IN_CALLBACK)
895
896 #define cy_as_device_is_setup_i_o_performed(dp) \
897         ((dp)->state & CY_AS_DEVICE_STATE_SETUP_IO_PERFORMED)
898 #define cy_as_device_set_setup_i_o_performed(dp) \
899         ((dp)->state |= CY_AS_DEVICE_STATE_SETUP_IO_PERFORMED)
900 #define cy_as_device_clear_setup_i_o_performed(dp) \
901         ((dp)->state &= ~CY_AS_DEVICE_STATE_SETUP_IO_PERFORMED)
902
903 #define cy_as_device_is_ack_delayed(dp) \
904         ((dp)->usb_delay_ack_count > 0)
905 #define cy_as_device_set_ack_delayed(dp) \
906         ((dp)->usb_delay_ack_count++)
907 #define cy_as_device_rem_ack_delayed(dp) \
908         ((dp)->usb_delay_ack_count--)
909 #define cy_as_device_clear_ack_delayed(dp) \
910         ((dp)->usb_delay_ack_count = 0)
911
912 #define cy_as_device_is_setup_packet(dp) \
913         ((dp)->state & CY_AS_DEVICE_STATE_IN_SETUP_PACKET)
914 #define cy_as_device_set_setup_packet(dp) \
915         ((dp)->state |= CY_AS_DEVICE_STATE_IN_SETUP_PACKET)
916 #define cy_as_device_clear_setup_packet(dp) \
917         ((dp)->state &= ~CY_AS_DEVICE_STATE_IN_SETUP_PACKET)
918
919 #define cy_as_device_is_ep0_stalled(dp) \
920         ((dp)->state & CY_AS_DEVICE_STATE_EP0_STALLED)
921 #define cy_as_device_set_ep0_stalled(dp) \
922         ((dp)->state |= CY_AS_DEVICE_STATE_EP0_STALLED)
923 #define cy_as_device_clear_ep0_stalled(dp) \
924         ((dp)->state &= ~CY_AS_DEVICE_STATE_EP0_STALLED)
925
926 #define cy_as_device_is_register_standby(dp) \
927         ((dp)->state & CY_AS_DEVICE_STATE_REGISTER_STANDBY)
928 #define cy_as_device_set_register_standby(dp) \
929         ((dp)->state |= CY_AS_DEVICE_STATE_REGISTER_STANDBY)
930 #define cy_as_device_clear_register_standby(dp) \
931         ((dp)->state &= ~CY_AS_DEVICE_STATE_REGISTER_STANDBY)
932
933 #define cy_as_device_is_pin_standby(dp) \
934         ((dp)->state & CY_AS_DEVICE_STATE_PIN_STANDBY)
935 #define cy_as_device_set_pin_standby(dp) \
936         ((dp)->state |= CY_AS_DEVICE_STATE_PIN_STANDBY)
937 #define cy_as_device_clear_pin_standby(dp) \
938         ((dp)->state &= ~CY_AS_DEVICE_STATE_PIN_STANDBY)
939
940 #define cy_as_device_is_crystal(dp) \
941         ((dp)->state & CY_AS_DEVICE_STATE_CRYSTAL)
942 #define cy_as_device_is_external_clock(dp) \
943         (!((dp)->state & CY_AS_DEVICE_STATE_CRYSTAL))
944 #define cy_as_device_set_crystal(dp) \
945         ((dp)->state |= CY_AS_DEVICE_STATE_CRYSTAL)
946 #define cy_as_device_set_external_clock(dp) \
947         ((dp)->state &= ~CY_AS_DEVICE_STATE_CRYSTAL)
948
949 #define cy_as_device_is_waking(dp) \
950         ((dp)->state & CY_AS_DEVICE_STATE_WAKING)
951 #define cy_as_device_set_waking(dp) \
952         ((dp)->state |= CY_AS_DEVICE_STATE_WAKING)
953 #define cy_as_device_clear_waking(dp) \
954         ((dp)->state &= ~CY_AS_DEVICE_STATE_WAKING)
955
956 #define cy_as_device_is_in_suspend_mode(dp) \
957         ((dp)->state & CY_AS_DEVICE_STATE_SUSPEND)
958 #define cy_as_device_set_suspend_mode(dp) \
959         ((dp)->state |= CY_AS_DEVICE_STATE_SUSPEND)
960 #define cy_as_device_clear_suspend_mode(dp) \
961         ((dp)->state &= ~CY_AS_DEVICE_STATE_SUSPEND)
962
963 #define cy_as_device_is_reset_pending(dp) \
964         ((dp)->state & CY_AS_DEVICE_STATE_RESETP)
965 #define cy_as_device_set_reset_pending(dp) \
966         ((dp)->state |= CY_AS_DEVICE_STATE_RESETP)
967 #define cy_as_device_clear_reset_pending(dp) \
968         ((dp)->state &= ~CY_AS_DEVICE_STATE_RESETP)
969
970 #define cy_as_device_is_standby_pending(dp) \
971         ((dp)->state & CY_AS_DEVICE_STATE_STANDP)
972 #define cy_as_device_set_standby_pending(dp) \
973         ((dp)->state |= CY_AS_DEVICE_STATE_STANDP)
974 #define cy_as_device_clear_standby_pending(dp) \
975         ((dp)->state &= ~CY_AS_DEVICE_STATE_STANDP)
976
977 #define cy_as_device_is_s_s_s_pending(dp) \
978         ((dp)->state & CY_AS_DEVICE_STATE_SSSP)
979 #define cy_as_device_set_s_s_s_pending(dp) \
980         ((dp)->state |= CY_AS_DEVICE_STATE_SSSP)
981 #define cy_as_device_clear_s_s_s_pending(dp) \
982         ((dp)->state &= ~CY_AS_DEVICE_STATE_SSSP)
983
984 #define cy_as_device_is_u_s_s_pending(dp) \
985         ((dp)->state & CY_AS_DEVICE_STATE_USSP)
986 #define cy_as_device_set_u_s_s_pending(dp) \
987         ((dp)->state |= CY_AS_DEVICE_STATE_USSP)
988 #define cy_as_device_clear_u_s_s_pending(dp) \
989         ((dp)->state &= ~CY_AS_DEVICE_STATE_USSP)
990
991 #define cy_as_device_is_m_s_s_pending(dp) \
992         ((dp)->state & CY_AS_DEVICE_STATE_MSSP)
993 #define cy_as_device_set_m_s_s_pending(dp) \
994         ((dp)->state |= CY_AS_DEVICE_STATE_MSSP)
995 #define cy_as_device_clear_m_s_s_pending(dp) \
996         ((dp)->state &= ~CY_AS_DEVICE_STATE_MSSP)
997
998 #define cy_as_device_is_p2s_dma_start_recvd(dp) \
999         ((dp)->state & CY_AS_DEVICE_STATE_P2SDMA_START)
1000 #define cy_as_device_set_p2s_dma_start_recvd(dp) \
1001         ((dp)->state |= CY_AS_DEVICE_STATE_P2SDMA_START)
1002 #define cy_as_device_clear_p2s_dma_start_recvd(dp) \
1003         ((dp)->state &= ~CY_AS_DEVICE_STATE_P2SDMA_START)
1004
1005 #define cy_as_device_is_usb_async_pending(dp, ep) \
1006         ((dp)->epasync & (1 << ep))
1007 #define cy_as_device_set_usb_async_pending(dp, ep) \
1008         ((dp)->epasync |= (1 << ep))
1009 #define cy_as_device_clear_usb_async_pending(dp, ep) \
1010         ((dp)->epasync &= ~(1 << ep))
1011
1012 #define cy_as_device_is_nand_storage_supported(dp) \
1013         ((dp)->media_supported[0] & 1)
1014
1015 /* Macros to check the type of West Bridge device. */
1016 #define cy_as_device_is_astoria_dev(dp) \
1017         (((dp)->silicon_id == CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_VALUE) || \
1018          ((dp)->silicon_id == CY_AS_MEM_CM_WB_CFG_ID_HDID_ASTORIA_FPGA_VALUE))
1019 #define cy_as_device_is_antioch_dev(dp) \
1020         ((dp)->silicon_id == CY_AS_MEM_CM_WB_CFG_ID_HDID_ANTIOCH_VALUE)
1021
1022 #ifdef CY_AS_LOG_SUPPORT
1023 extern void cy_as_log_debug_message(int value, const char *msg);
1024 #else
1025 #define cy_as_log_debug_message(value, msg)
1026 #endif
1027
1028 /* Summary
1029    This function finds the device object given the HAL tag
1030
1031    Description
1032    The user associats a device TAG with each West Bridge device
1033    created.  This tag is passed from the  API functions to and HAL
1034    functions that need to ID a specific West Bridge device.  This
1035    tag is also passed in from the user back into the API via
1036    interrupt functions.  This function allows the API to find the
1037    device structure associated with a given tag.
1038
1039    Notes
1040    This function does a simple linear search for the device based
1041    on the TAG.  This function is called each time an West Bridge
1042    interrupt handler is called.  Therefore this works fine for a
1043    small number of West Bridge devices (e.g. less than five).
1044    Anything more than this and this methodology will need to be
1045    updated.
1046
1047    Returns
1048    Pointer to a CyAsDevice associated with the tag
1049 */
1050 extern cy_as_device *
1051 cy_as_device_find_from_tag(
1052                 cy_as_hal_device_tag tag
1053                 );
1054
1055 #include "cyas_cplus_end.h"
1056
1057 #endif            /* __INCLUDED_CYASDEVICE_H__ */