summaryrefslogtreecommitdiffstats
path: root/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasmisc.h
blob: b555c6c245249957762fb531c7205b8ea4575b7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
/* Cypress West Bridge API header file (cyasmisc.h)
## ===========================
## Copyright (C) 2010  Cypress Semiconductor
##
## This program is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License
## as published by the Free Software Foundation; either version 2
## of the License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street
## Fifth Floor, Boston, MA  02110-1301, USA.
## ===========================
*/

#ifndef _INCLUDED_CYASMISC_H_
#define _INCLUDED_CYASMISC_H_

#include "cyashal.h"
#include "cyastypes.h"
#include "cyasmedia.h"

#include "cyas_cplus_start.h"

#define CY_AS_LEAVE_STANDBY_DELAY_CLOCK	(1)
#define CY_AS_RESET_DELAY_CLOCK	(1)

#define CY_AS_LEAVE_STANDBY_DELAY_CRYSTAL (5)
#define CY_AS_RESET_DELAY_CRYSTAL (5)

/* The maximum number of buses supported */
#define	CY_AS_MAX_BUSES	(2)

/* The maximum number of storage devices supported per bus */
#define	CY_AS_MAX_STORAGE_DEVICES (1)

#define CY_AS_FUNCTCBTYPE_DATA_MASK (0x60000000U)
#define CY_AS_FUNCTCBTYPE_TYPE_MASK (0x1FFFFFFFU)

#define cy_as_funct_c_b_type_get_type(t) \
	((cy_as_funct_c_b_type)((t) & CY_AS_FUNCTCBTYPE_TYPE_MASK))
#define cy_as_funct_c_b_type_contains_data(t) \
	(((cy_as_funct_c_b_type)((t) & \
		CY_AS_FUNCTCBTYPE_DATA_MASK)) == CY_FUNCT_CB_DATA)

/**************************************
 * West Bridge Types
 **************************************/

/* Summary
   Specifies a handle to an West Bridge device

   Description
   This type represents an opaque handle to an West Bridge device.
   This handle is created via the CyAsMiscCreateDevice() function
   and is used in all subsequent calls that communicate to the West
   Bridge device.

   See Also
   * CyAsMiscCreateDevice
   * CyAsMiscDestroyDevice
*/
typedef void *cy_as_device_handle;

/* Summary
   This data type gives the mode for the DACK# signal
*/
typedef enum cy_as_device_dack_mode {
	cy_as_device_dack_ack, /* Operate in the ACK mode */
	cy_as_device_dack_eob /* Operate in the EOB mode */
} cy_as_device_dack_mode;

/* Summary
   This data structure gives the options for all hardware features.

   Description
   This structure contains the information required to initialize the
   West Bridge hardware. Any features of the device that can be
   configured by the caller are specified here.

   See Also
   * CyAsMiscConfigure
*/
typedef struct cy_as_device_config {
	/* If TRUE, the P port is running in SRAM mode. */
	cy_bool	srammode;
	/* If TRUE, the P port is synchronous, otherwise async */
	cy_bool	sync;
	/* If TRUE, DMA req will be delivered via the interrupt signal */
	cy_bool	dmaintr;
	/* Mode for the DACK# signal */
	cy_as_device_dack_mode dackmode;
	/* If TRUE, the DRQ line is active high, otherwise active low */
	cy_bool	drqpol;
	/* If TRUE, the DACK line is active high, otherwise active low */
	cy_bool	dackpol;
	/* If TRUE, the clock is connected to a crystal, otherwise it is
			connected to a clock */
	cy_bool	crystal;
} cy_as_device_config;


/* Summary
   Specifies a resource that can be owned by either the West Bridge
   device or by the processor.

   Description
   This enumerated type identifies a resource that can be owned
   either by the West Bridge device, or by the processor attached to
   the P port of the West Bridge device.

   See Also
   * CyAsMiscAcquireResource
   * CyAsMiscReleaseResource
*/
typedef enum cy_as_resource_type {
	cy_as_bus_u_s_b = 0, /* The USB D+ and D- pins */
	cy_as_bus_1  = 1, /* The SDIO bus */
	cy_as_bus_0  = 2	/* The NAND bus (not implemented) */
} cy_as_resource_type;

/* Summary
   Specifies the reset type for a software reset operation.

   Description
   When the West Bridge device is reset, there are two types of
   reset that arE possible.  This type indicates the type of reset
   requested.

   Notes
   Both of these reset types are software based resets; and are
   distinct from a chip level HARD reset that is applied through
   the reset pin on the West Bridge.

   The CyAsResetSoft type resets only the on-chip micro-controller
   in the West Bridge. In this case, the previously loaded firmware
   will continue running. However, the Storage and USB stack
   operations will need to be restarted, as any state relating to
   these would have been lost.

   The CyAsResetHard type resets the entire West Bridge chip, and will
   need a fresh configuration and firmware download.

   See Also
   * <LINK CyAsMiscReset>
 */

typedef enum cy_as_reset_type {
	/* Just resets the West Bridge micro-controller */
	cy_as_reset_soft,
	/* Resets entire device, firmware must be reloaded and
	the west bridge device must be re-initialized */
	cy_as_reset_hard
} cy_as_reset_type;



/* Summary
   This type specifies the polarity of the SD power pin.

   Description
   Sets the SD power pin ( port C, bit 6) to active low or
   active high.

*/

typedef enum cy_as_misc_signal_polarity {
	cy_as_misc_active_high,
	cy_as_misc_active_low

} cy_as_misc_signal_polarity;



/* Summary
	This type specifies the type of the data returned by a Function
	Callback.

	Description
	CY_FUNCT_CB_NODATA - This callback does not return any additional
	information in the data field.
	CY_FUNCT_CB_DATA   - The data field is used, and the CyAsFunctCBType
	will also contain the type of this data.

	See Also
	CyAsFunctionCallback
*/
typedef enum cy_as_funct_c_b_type {
	CY_FUNCT_CB_INVALID = 0x0U,
	/* Data from a CyAsMiscGetFirmwareVersion call. */
	CY_FUNCT_CB_MISC_GETFIRMWAREVERSION,
	/* Data from a CyAsMiscHeartBeatControl call. */
	CY_FUNCT_CB_MISC_HEARTBEATCONTROL,
	/* Data from a CyAsMiscAcquireResource call. */
	CY_FUNCT_CB_MISC_ACQUIRERESOURCE,
	/* Data from a CyAsMiscReadMCURegister call. */
	CY_FUNCT_CB_MISC_READMCUREGISTER,
	/* Data from a CyAsMiscWriteMCURegister call. */
	CY_FUNCT_CB_MISC_WRITEMCUREGISTER,
	/* Data from a CyAsMiscSetTraceLevel call. */
	CY_FUNCT_CB_MISC_SETTRACELEVEL,
	/* Data from a CyAsMiscStorageChanged call. */
	CY_FUNCT_CB_MISC_STORAGECHANGED,
	/* Data from a CyAsMiscGetGpioValue call. */
	CY_FUNCT_CB_MISC_GETGPIOVALUE,
	/* Data from a CyAsMiscSetGpioValue call. */
	CY_FUNCT_CB_MISC_SETGPIOVALUE,
	/* Data from a CyAsMiscDownloadFirmware call. */
	CY_FUNCT_CB_MISC_DOWNLOADFIRMWARE,
	/* Data from a CyAsMiscEnterStandby call. */
	CY_FUNCT_CB_MISC_ENTERSTANDBY,
	/* Data from a CyAsMiscEnterSuspend call. */
	CY_FUNCT_CB_MISC_ENTERSUSPEND,
	/* Data from a CyAsMiscLeaveSuspend call. */
	CY_FUNCT_CB_MISC_LEAVESUSPEND,
	/* Data from a CyAsMiscReset call. */
	CY_FUNCT_CB_MISC_RESET,
	/* Data from a CyAsMiscSetLowSpeedSDFreq or
	 * CyAsMiscSetHighSpeedSDFreq call. */
	CY_FUNCT_CB_MISC_SETSDFREQ,
	/* Data from a CyAsMiscSwitchPnandMode call */
	CY_FUNCT_CB_MISC_RESERVELNABOOTAREA,
	/* Data from a CyAsMiscSetSDPowerPolarity call */
	CY_FUNCT_CB_MISC_SETSDPOLARITY,

	/* Data from a CyAsStorageStart call. */
	CY_FUNCT_CB_STOR_START,
	/* Data from a CyAsStorageStop call. */
	CY_FUNCT_CB_STOR_STOP,
	/* Data from a CyAsStorageClaim call. */
	CY_FUNCT_CB_STOR_CLAIM,
	/* Data from a CyAsStorageRelease call. */
	CY_FUNCT_CB_STOR_RELEASE,
	/* Data from a CyAsStorageQueryMedia call. */
	CY_FUNCT_CB_STOR_QUERYMEDIA,
	/* Data from a CyAsStorageQueryBus call. */
	CY_FUNCT_CB_STOR_QUERYBUS,
	/* Data from a CyAsStorageQueryDevice call. */
	CY_FUNCT_CB_STOR_QUERYDEVICE,
	/* Data from a CyAsStorageQueryUnit call. */
	CY_FUNCT_CB_STOR_QUERYUNIT,
	/* Data from a CyAsStorageDeviceControl call. */
	CY_FUNCT_CB_STOR_DEVICECONTROL,
	/* Data from a CyAsStorageSDRegisterRead call. */
	CY_FUNCT_CB_STOR_SDREGISTERREAD,
	/* Data from a CyAsStorageCreatePartition call. */
	CY_FUNCT_CB_STOR_PARTITION,
	/* Data from a CyAsStorageGetTransferAmount call. */
	CY_FUNCT_CB_STOR_GETTRANSFERAMOUNT,
	/* Data from a CyAsStorageErase call. */
	CY_FUNCT_CB_STOR_ERASE,
	/* Data from a CyAsStorageCancelAsync call. */
	CY_FUNCT_CB_ABORT_P2S_XFER,
	/* Data from a CyAsUsbStart call. */
	CY_FUNCT_CB_USB_START,
	/* Data from a CyAsUsbStop call. */
	CY_FUNCT_CB_USB_STOP,
	/* Data from a CyAsUsbConnect call. */
	CY_FUNCT_CB_USB_CONNECT,
	/* Data from a CyAsUsbDisconnect call. */
	CY_FUNCT_CB_USB_DISCONNECT,
	/* Data from a CyAsUsbSetEnumConfig call. */
	CY_FUNCT_CB_USB_SETENUMCONFIG,
	/* Data from a CyAsUsbGetEnumConfig call. */
	CY_FUNCT_CB_USB_GETENUMCONFIG,
	/* Data from a CyAsUsbSetDescriptor call. */
	CY_FUNCT_CB_USB_SETDESCRIPTOR,
	/* Data from a CyAsUsbGetDescriptor call. */
	CY_FUNCT_CB_USB_GETDESCRIPTOR,
	/* Data from a CyAsUsbCommitConfig call. */
	CY_FUNCT_CB_USB_COMMITCONFIG,
	/* Data from a CyAsUsbGetNak call. */
	CY_FUNCT_CB_USB_GETNAK,
	/* Data from a CyAsUsbGetStall call. */
	CY_FUNCT_CB_USB_GETSTALL,
	/* Data from a CyAsUsbSignalRemoteWakeup call. */
	CY_FUNCT_CB_USB_SIGNALREMOTEWAKEUP,
	/* Data from a CyAnUsbClearDescriptors call. */
	CY_FUNCT_CB_USB_CLEARDESCRIPTORS,
	/* Data from a CyAnUsbSetMSReportThreshold call. */
	CY_FUNCT_CB_USB_SET_MSREPORT_THRESHOLD,
	/* Data from a CyAsMTPStart call. */
	CY_FUNCT_CB_MTP_START,
	/* Data from a CyAsMTPStop call. */
	CY_FUNCT_CB_MTP_STOP,
	/* Data from a CyAsMTPInitSendObject call. */
	CY_FUNCT_CB_MTP_INIT_SEND_OBJECT,
	/* Data from a CyAsMTPCancelSendObject call. */
	CY_FUNCT_CB_MTP_CANCEL_SEND_OBJECT,
	/* Data from a CyAsMTPInitGetObject call. */
	CY_FUNCT_CB_MTP_INIT_GET_OBJECT,
	/* Data from a CyAsMTPCancelGetObject call. */
	CY_FUNCT_CB_MTP_CANCEL_GET_OBJECT,
	/* Data from a CyAsMTPSendBlockTable call. */
	CY_FUNCT_CB_MTP_SEND_BLOCK_TABLE,
	/* Data from a CyAsMTPStopStorageOnly call. */
	CY_FUNCT_CB_MTP_STOP_STORAGE_ONLY,
	CY_FUNCT_CB_NODATA = 0x40000000U,
	CY_FUNCT_CB_DATA =   0x20000000U
} cy_as_funct_c_b_type;

/* Summary
   This type specifies the general West Bridge function callback.

   Description
   This callback is supplied as an argument to all asynchronous
   functions in the API. It iS called after the asynchronous function
   has completed.

   See Also
   CyAsFunctCBType
*/
typedef void (*cy_as_function_callback)(
	cy_as_device_handle	handle,
	cy_as_return_status_t	status,
	uint32_t		client,
	cy_as_funct_c_b_type	type,
	void	*data);

/* Summary
   This type specifies the general West Bridge event that has
   occurred.

   Description
   This type is used in the West Bridge misc callback function to
   indicate the type of callback.

   See Also
*/
typedef enum cy_as_misc_event_type {
	/* This event is sent when West Bridge has finished
	initialization and is ready to respond to API calls. */
	cy_as_event_misc_initialized = 0,

	/* This event is sent when West Bridge has left the
	standby state and is ready to respond to commands again. */
	cy_as_event_misc_awake,

	/* This event is sent periodically from the firmware
	to the processor. */
	cy_as_event_misc_heart_beat,

	/* This event is sent when the West Bridge has left the
	suspend mode and is ready to respond to commands
	again. */
	cy_as_event_misc_wakeup,

	 /* This event is sent when the firmware image downloaded
	cannot run on the active west bridge device. */
	cy_as_event_misc_device_mismatch
} cy_as_misc_event_type;

/* Summary
   This type is the type of a callback function that is called when a
   West Bridge misc event occurs.

   Description
   At times West Bridge needs to inform the P port processor of events
   that have occurred. These events are asynchronous to the thread of
   control on the P port processor and as such are generally delivered
   via a callback function that is called as part of an interrupt
   handler. This type defines the type of function that must be provided
   as a callback function for West Bridge misc events.

   See Also
   * CyAsMiscEventType
*/
typedef void (*cy_as_misc_event_callback)(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* The event type being reported */
	cy_as_misc_event_type		ev,
	/* The data assocaited with the event being reported */
	void *evdata
);

#ifndef __doxygen__
/* Summary
   This enum provides info of various firmware trace levels.

   Description

   See Also
   * CyAsMiscSetTraceLevel
*/
enum {
	CYAS_FW_TRACE_LOG_NONE = 0,	/* Log nothing. */
	CYAS_FW_TRACE_LOG_STATE,	/* Log state information. */
	CYAS_FW_TRACE_LOG_CALLS,	/* Log function calls. */
	CYAS_FW_TRACE_LOG_STACK_TRACE,	/* Log function calls with args. */
	CYAS_FW_TRACE_MAX_LEVEL		/* Max trace level sentinel. */
};
#endif

/* Summary
   This enum lists the controllable GPIOs of the West Bridge device.

   Description
   The West Bridge device has GPIOs that can be used for user defined functions.
   This enumeration lists the GPIOs that are available on the device.

   Notes
   All of the GPIOs except UVALID can only be accessed when using West Bridge
   firmware images that support only SD/MMC/MMC+ storage devices. This
   functionality is not supported in firmware images that support NAND
   storage.

   See Also
   * CyAsMiscGetGpioValue
   * CyAsMiscSetGpioValue
 */
typedef enum {
	cy_as_misc_gpio_0 = 0,	/* GPIO[0] pin */
	cy_as_misc_gpio_1, /* GPIO[1] pin */
	cy_as_misc_gpio__nand_CE, /* NAND_CE pin, output only */
	cy_as_misc_gpio__nand_CE2, /* NAND_CE2 pin, output only */
	cy_as_misc_gpio__nand_WP, /* NAND_WP pin, output only */
	cy_as_misc_gpio__nand_CLE, /* NAND_CLE pin, output only */
	cy_as_misc_gpio__nand_ALE, /* NAND_ALE pin, output only */
	/* SD_POW pin, output only, do not drive low while storage is active */
	cy_as_misc_gpio_SD_POW,
	cy_as_misc_gpio_U_valid				 /* UVALID pin */
} cy_as_misc_gpio;

/* Summary
   This enum lists the set of clock frequencies that are supported for
   working with low speed SD media.

   Description
   West Bridge firmware uses a clock frequency less than the maximum
   possible rate for low speed SD media.  This can be changed to a
   setting equal to the maximum frequency as desired by the user. This
   enumeration lists the different frequency settings that are
   supported.

   See Also
   * CyAsMiscSetLowSpeedSDFreq
 */
typedef enum cy_as_low_speed_sd_freq {
	/* Approx. 21.82 MHz, default value */
	CY_AS_SD_DEFAULT_FREQ = 0,
	/* 24 MHz */
	CY_AS_SD_RATED_FREQ
} cy_as_low_speed_sd_freq;

/* Summary
   This enum lists the set of clock frequencies that are supported
   for working with high speed SD media.

   Description
   West Bridge firmware uses a 48 MHz clock by default to interface
   with high speed SD/MMC media.  This can be changed to 24 MHz if
   so desired by the user. This enum lists the different frequencies
   that are supported.

   See Also
   * CyAsMiscSetHighSpeedSDFreq
 */
typedef enum cy_as_high_speed_sd_freq {
	CY_AS_HS_SD_FREQ_48, /* 48 MHz, default value */
	CY_AS_HS_SD_FREQ_24	/* 24 MHz */
} cy_as_high_speed_sd_freq;

/* Summary
   Struct encapsulating all information returned by the
   CyAsMiscGetFirmwareVersion call.

   Description
   This struct encapsulates all return values from the asynchronous
   CyAsMiscGetFirmwareVersion call, so that a single data argument
   can be passed to the user provided callback function.

   See Also
   * CyAsMiscGetFirmwareVersion
 */
typedef struct cy_as_get_firmware_version_data {
	/* Return value for major version number for the firmware */
	uint16_t	 major;
	/* Return value for minor version number for the firmware */
	uint16_t	 minor;
	/* Return value for build version number for the firmware */
	uint16_t	 build;
	/* Return value for media types supported in the current firmware */
	uint8_t	 media_type;
	/* Return value to indicate the release or debug mode of firmware */
	cy_bool	is_debug_mode;
} cy_as_get_firmware_version_data;


/*****************************
 * West Bridge Functions
 *****************************/

/* Summary
   This function creates a new West Bridge device and returns a
   handle to the device.

   Description
   This function initializes the API object that represents the West
   Bridge device and returns a handle to this device.  This handle is
   required for all West Bridge related functions to identify the
   specific West Bridge device.

   * Valid In Asynchronous Callback: NO

   Returns
   * CY_AS_ERROR_SUCCESS
   * CY_AS_ERROR_OUT_OF_MEMORY
*/
EXTERN cy_as_return_status_t
cy_as_misc_create_device(
	/* Return value for handle to created device */
	cy_as_device_handle *handle_p,
	/* The HAL specific tag for this device */
	cy_as_hal_device_tag		tag
	);

/* Summary
   This functions destroys a previously created West Bridge device.

   Description
   When an West Bridge device is created, an opaque handle is returned
   that represents the device.  This function destroys that handle and
   frees all resources associated with the handle.

   * Valid In Asynchronous Callback: NO

   Returns
   * CY_AS_ERROR_SUCCESS
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_STILL_RUNNING - The USB or STORAGE stacks are still
   *	running, they must be stopped before the device can be destroyed
   * CY_AS_ERROR_DESTROY_SLEEP_CHANNEL_FAILED - the HAL layer failed to
   *	destroy a sleep channel
*/
EXTERN cy_as_return_status_t
cy_as_misc_destroy_device(
	/* Handle to the device to destroy */
	cy_as_device_handle		handle
	);

/* Summary
   This function initializes the hardware for basic communication with
   West Bridge.

   Description
   This function intializes the hardware to establish basic
   communication with the West Bridge device.  This is always the first
   function called to initialize communication with the West Bridge
   device.

   * Valid In Asynchronous Callback: NO

   Returns
   * CY_AS_ERROR_SUCCESS - the basic initialization was completed
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_IN_STANDBY
   * CY_AS_ERROR_ALREADY_RUNNING
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_NO_ANTIOCH - cannot find the West Bridge device
   * CY_AS_ERROR_CREATE_SLEEP_CHANNEL_FAILED -
   *	the HAL layer falied to create a sleep channel

   See Also
   * CyAsDeviceConfig
*/
EXTERN cy_as_return_status_t
cy_as_misc_configure_device(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* Configuration information */
	cy_as_device_config		*config_p
	);

/* Summary
   This function returns non-zero if West Bridge is in standby and
   zero otherwise.

   Description
   West Bridge supports a standby mode.  This function is used to
   query West Bridge to determine if West Bridge is in a standby
   mode.

   * Valid In Asynchronous Callback: YES

   Returns
   * CY_AS_ERROR_SUCCESS
   * CY_AS_ERROR_INVALID_HANDLE
*/
EXTERN cy_as_return_status_t
cy_as_misc_in_standby(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* Return value for standby state */
	cy_bool					*standby
	);

/* Summary
   This function downloads the firmware to West Bridge device.

   Description
   This function downloads firmware from a given location and with a
   given size to the West Bridge device.  After the firmware is
   downloaded the West Bridge device is moved out of configuration
   mode causing the firmware to be executed.  It is an error to call
   this function when the device is not in configuration mode.  The
   device is in configuration mode on power up and may be placed in
   configuration mode after power up with a hard reset.

   Notes
   The firmware must be on a word align boundary.

   * Valid In Asynchronous Callback: YES (if cb supplied)
   * Nestable: YES

   Returns
   * CY_AS_ERROR_SUCCESS - the firmware was sucessfully downloaded
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	was not configured
   * CY_AS_ERROR_NOT_IN_CONFIG_MODE
   * CY_AS_ERROR_INVALID_SIZE - the size of the firmware
   *	exceeded 32768 bytes
   * CY_AS_ERROR_ALIGNMENT_ERROR
   * CY_AS_ERROR_IN_STANDBY - trying to download
   *	while in standby mode
   * CY_AS_ERROR_TIMEOUT

   See Also
   * CyAsMiscReset
*/
EXTERN cy_as_return_status_t
cy_as_misc_download_firmware(
	/* Handle to the device to configure */
	cy_as_device_handle	  handle,
	/* Pointer to the firmware to be downloaded */
	const void			   *fw_p,
	/* The size of the firmware in bytes */
	uint16_t			  size,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback  cb,
	/* Client data to be passed to the callback. */
	uint32_t			  client
	);


/* Summary
   This function returns the version number of the firmware running in
   the West Bridge device.

   Description
   This function queries the West Bridge device and retreives the
   firmware version number.  If the firmware is not loaded an error is
   returned indicated no firmware has been loaded.

   * Valid In Asynchronous Callback: YES (if cb supplied)
   * Nestable: YES

   Returns
   * CY_AS_ERROR_SUCCESS - the firmware version number was retreived
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been downloaded
   *	to the device
   * CY_AS_ERROR_IN_STANDBY
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
   *	from the West Bridge firmware
*/
EXTERN cy_as_return_status_t
cy_as_misc_get_firmware_version(
	/* Handle to the device to configure */
	cy_as_device_handle	handle,
	/* Return values indicating the firmware version. */
	cy_as_get_firmware_version_data	*data,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

#if !defined(__doxygen__)

/* Summary
   This function reads and returns the contents of an MCU accessible
   register on the West Bridge.

   Description
   This function requests the firmware to read and return the contents
   of an MCU accessible register through the mailboxes.

   * Valid In Asynchronous Callback: YES (if cb supplied)
   * Nestable: YES

   Returns
   * CY_AS_ERROR_SUCCESS - the register content was retrieved.
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
   *	from the West Bridge firmware
   * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not
   *	support this command.
*/
EXTERN cy_as_return_status_t
cy_as_misc_read_m_c_u_register(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* Address of the register to read */
	uint16_t			address,
	/* Return value for the MCU register content */
	uint8_t				*value,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback		cb,
	/* Client data to be passed to the callback. */
	uint32_t			client
	);

/* Summary
   This function writes to an MCU accessible register on the West Bridge.

   Description
   This function requests the firmware to write a specified value to an
   MCU accessible register through the mailboxes.

   * Valid In Asynchronous Callback: YES (if cb supplied)
   * Nestable: YES

   Notes
   This function is only for internal use by the West Bridge API layer.
   Calling this function directly can cause device malfunction.

   Returns
   * CY_AS_ERROR_SUCCESS - the register content was updated.
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
   *	from the West Bridge firmware
   * CY_AS_ERROR_INVALID_RESPONSE - the firmware build does not support
   * this command.
*/
EXTERN cy_as_return_status_t
cy_as_misc_write_m_c_u_register(
	/* Handle to the device to configure */
	cy_as_device_handle	handle,
	/* Address of the register to write */
	uint16_t	address,
	/* Mask to be applied on the register contents. */
	uint8_t		mask,
	/* Data to be ORed with the register contents. */
	uint8_t		value,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback. */
	uint32_t	client
	);

#endif

/* Summary
   This function will reset the West Bridge device and software API.

   Description
   This function will reset the West Bridge device and software API.
   The reset operation can be a hard reset or a soft reset.  A hard
   reset will reset all aspects of the West Bridge device. The device
   will enter the configuration state and the firmware will have to be
   reloaded.  The device will also have to be re-initialized.  A soft
   reset just resets the West Bridge micro-controller.

   * Valid In Asynchronous Callback: NO

   Notes
   When a hard reset is issued, the firmware that may have been
   previously loaded will be lost and any configuration information set
   via CyAsMiscConfigureDevice() will be lost.  This will be reflected
   in the API maintained state of the device.  In order to re-establish
   communications with the West Bridge device, CyAsMiscConfigureDevice()
   and CyAsMiscDownloadFirmware() must be called again.

   * Valid In Asynchronous Callback: YES (if cb supplied)
   * Nestable: YES

   Returns
   * CY_AS_ERROR_SUCCESS - the device has been reset
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_NOT_YET_SUPPORTED - current soft reset is not supported
   * CY_AS_ERROR_ASYNC_PENDING - Reset is unable to flush pending async
   *	reads/writes in polling mode.


	  See Also
   * CyAsMiscReset
*/
EXTERN cy_as_return_status_t
cy_as_misc_reset(
	/* Handle to the device to configure */
	cy_as_device_handle handle,
	/* The type of reset to perform */
	cy_as_reset_type type,
	/* If true, flush all pending writes to mass storage
	 before performing the reset. */
	cy_bool flush,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* Summary
   This function acquires a given resource.

   Description
   There are resources in the system that are shared between the
   West Bridge device and the processor attached to the P port of
   the West Bridge device.  This API provides a mechanism for the
   P port processor to acquire ownership of a resource.

   Notes
   The ownership of the resources controlled by CyAsMiscAcquireResource()
   and CyAsMiscReleaseResource() defaults to a known state at hardware
   reset.  After the firmware is loaded and begins execution the state of
   these resources may change.  At any point if the P Port processor needs
   to acquire a resource it should do so explicitly to be sure of
   ownership.

   Returns
   * CY_AS_ERROR_SUCCESS - the p port sucessfully acquired the
   * 	resource of interest
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_INVALID_RESOURCE
   * CY_AS_ERROR_RESOURCE_ALREADY_OWNED - the p port already
   *	owns this resource
   * CY_AS_ERROR_NOT_ACQUIRED - the resource cannot be acquired
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
   *	response from the West Bridge firmware

   See Also
   * CyAsResourceType
*/
EXTERN cy_as_return_status_t
cy_as_misc_acquire_resource(
	/* Handle to the device to configure */
	cy_as_device_handle	handle,
	/* The resource to acquire */
	cy_as_resource_type	*resource,
	/* If true, force West Bridge to release the resource */
	cy_bool				force,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback cb,
	/* Client data to be passed to the callback. */
	uint32_t			client
	);

/* Summary
   This function releases a given resource.

   Description
   There are resources in the system that are shared between the
   West Bridge device and the processor attached to the P port of
   the West Bridge device.  This API provides a mechanism for the
   P port processor to release a resource that has previously been
   acquired via the CyAsMiscAcquireResource() call.

   * Valid In Asynchronous Callback: NO

   Returns
   * CY_AS_ERROR_SUCCESS - the p port sucessfully released
   *	the resource of interest
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_INVALID_RESOURCE
   * CY_AS_ERROR_RESOURCE_NOT_OWNED - the p port does not own the
   *	resource of interest

   See Also
   * CyAsResourceType
   * CyAsMiscAcquireResource
*/
EXTERN cy_as_return_status_t
cy_as_misc_release_resource(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* The resource to release */
	cy_as_resource_type		resource
	);

#ifndef __doxygen__
/* Summary
   This function sets the trace level for the West Bridge firmware.

   Description
   The West Bridge firmware has the ability to store information
   about the state and execution path of the firmware on a mass storage
   device attached to the West Bridge device.  This function configures
   the specific mass storage device to be used and the type of information
   to be stored.  This state information is used for debugging purposes
   and must be interpreted by a Cypress provided tool.

   *Trace Level*
   The trace level indicates the amount of information to output.
   * 0 = no trace information is output
   * 1 = state information is output
   * 2 = function call information is output
   * 3 = function call, arguments, and return value information is output

   * Valid In Asynchronous Callback: NO

   Notes
   The media device and unit specified in this call will be overwritten
   and any data currently stored on this device and unit will be lost.

   * NOT IMPLEMENTED YET

   Returns
   * CY_AS_ERROR_SUCCESS - the trace configuration has been
   *	sucessfully changed
   * CY_AS_ERROR_NO_SUCH_BUS - the bus specified does not exist
   * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device
   *	pair does not exist
   * CY_AS_ERROR_NO_SUCH_UNIT - the unit specified does not exist
   * CY_AS_ERROR_INVALID_TRACE_LEVEL - the trace level requested
   *	does not exist
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
   *	response from the West Bridge firmware
*/
EXTERN cy_as_return_status_t
cy_as_misc_set_trace_level(
	/* Handle to the device to configure */
	cy_as_device_handle	handle,
	/* The trace level */
	uint8_t	level,
	/* The bus for the output */
	cy_as_bus_number_t	bus,
	/* The device for the output */
	uint32_t device,
	/* The unit for the output */
	uint32_t unit,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback		cb,
	/* Client data to be passed to the callback. */
	uint32_t			client
	);
#endif

/* Summary
   This function places West Bridge into the low power standby mode.

   Description
   This function places West Bridge into a low power (sleep) mode, and
   cannot be called while the USB stack is active.  This function first
   instructs the West Bridge firmware that the device is about to be
   placed into sleep mode.  This allows West Bridge to complete any pending
   storage operations.  After the West Bridge device has responded that
   pending operations are complete, the device is placed in standby mode.

   There are two methods of placing the device in standby mode.  If the
   WAKEUP pin of the West Bridge is connected to a GPIO on the processor,
   the pin is de-asserted (via the HAL layer) and West Bridge enters into
   a sleep mode.  If the WAKEUP pin is not accessible, the processor can
   write into the power management control/status register on the West
   Bridge to put the device into sleep mode.

   * Valid In Asynchronous Callback: YES (if cb supplied)
   * Nestable: YES

   Returns
   * CY_AS_ERROR_SUCCESS - the function completed and West Bridge
   *	is in sleep mode
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_ALREADY_STANDBY - the West Bridge device is already
   *	in sleep mode
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a response
   *	from the West Bridge firmware
   * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support changing
   *	the WAKEUP pin
   * CY_AS_ERROR_USB_RUNNING - The USB stack is still running when the
   *	EnterStandby call is made
   * CY_AS_ERROR_ASYNC_PENDING
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE
   * CY_AS_ERROR_SETTING_WAKEUP_PIN
   * CY_AS_ERROR_ASYNC_PENDING - In polling mode EnterStandby can not
   *	be called until all pending storage read/write requests have
   *	finished.

   See Also
   * CyAsMiscLeaveStandby
*/
EXTERN cy_as_return_status_t
cy_as_misc_enter_standby_e_x_u(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* If true, use the wakeup pin, otherwise use the register */
	cy_bool				pin,
	/* Set true to enable specific usages of the
	UVALID signal, please refer to AN xx or ERRATA xx */
	cy_bool				uvalid_special,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback		cb,
	/* Client data to be passed to the callback. */
	uint32_t			client
	);

/* Summary
   This function is provided for backwards compatibility.

   Description
   Calling this function is the same as calling CyAsMiscEnterStandbyEx
   with True for the lowpower parameter.

   See Also
   * CyAsMiscEnterStandbyEx
*/
EXTERN cy_as_return_status_t
cy_as_misc_enter_standby(cy_as_device_handle handle,
			cy_bool pin,
			cy_as_function_callback cb,
			uint32_t client
			);

/* Summary
   This function brings West Bridge out of sleep mode.

   Description
   This function asserts the WAKEUP pin (via the HAL layer). This
   brings the West Bridge out of the sleep state and allows the
   West Bridge firmware to process the event causing the wakeup.
   When all processing associated with the wakeup is complete, a
   callback function is called to tell the P port software that
   the firmware processing associated with wakeup is complete.

   * Valid In Asynchronous Callback: NO

   Returns:
   * CY_AS_ERROR_SUCCESS - the function completed and West Bridge
   *	is in sleep mode
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_SETTING_WAKEUP_PIN
   * CY_AS_ERROR_NOT_IN_STANDBY - the West Bridge device is not in
   *	the sleep state
   * CY_AS_ERROR_TIMEOUT - there was a timeout waiting for a
   *	response from the West Bridge firmware
   * CY_AS_ERROR_NOT_SUPPORTED - the HAL layer does not support
   *	changing the WAKEUP pin

   See Also
   * CyAsMiscEnterStandby
*/
EXTERN cy_as_return_status_t
cy_as_misc_leave_standby(
	/* Handle to the device to configure */
	cy_as_device_handle		handle,
	/* The resource causing the wakeup */
	cy_as_resource_type		resource
	);

/* Summary
   This function registers a callback function to be called when an
   asynchronous West Bridge MISC event occurs.

   Description
   When asynchronous misc events occur, a callback function can be
   called to alert the calling program.  This functions allows the
   calling program to register a callback.

   * Valid In Asynchronous Callback: NO

   Returns:
   * CY_AS_ERROR_SUCCESS
   * CY_AS_ERROR_INVALID_HANDLE
*/
EXTERN cy_as_return_status_t
cy_as_misc_register_callback(
	/* Handle to the West Bridge device */
	cy_as_device_handle		handle,
	/* The function to call */
	cy_as_misc_event_callback		callback
	);

/* Summary
   This function sets the logging level for log messages.

   Description
   The API can print messages via the CyAsHalPrintMessage capability.
   This function sets the level of detail seen when printing messages
   from the API.

   * Valid In Asynchronous Callback:NO
*/
EXTERN void
cy_as_misc_set_log_level(
	/* Level to set, 0 is fewer messages, 255 is all */
	uint8_t	level
	);


/* Summary
   This function tells West Bridge that SD or MMC media has been
   inserted or removed.

   Description
   In some hardware configurations, SD or MMC media detection is
   handled outside of the West Bridge device.  This function is called
   when a change is detected to inform the West Bridge firmware to check
   for storage media changes.

   * Valid In Asynchronous Callback: NO

   Returns:
   * CY_AS_ERROR_SUCCESS
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_IN_STANDBY
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE

   See Also
   * CyAsMiscStorageChanged

*/
EXTERN cy_as_return_status_t
cy_as_misc_storage_changed(
	/* Handle to the West Bridge device */
	cy_as_device_handle		handle,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback		cb,
	/* Client data to be passed to the callback. */
	uint32_t			client
	);

/* Summary
   This function instructs the West Bridge firmware to start/stop
   sending periodic heartbeat messages to the processor.

   Description
   The West Bridge firmware can send heartbeat messages through the
   mailbox register once every 500 ms. This message can be an overhead
   as it causes regular Mailbox interrupts to happen, and is turned
   off by default. The message can be used to test and verify that the
   West Bridge firmware is alive. This API can be used to enable or
   disable the heartbeat message.

   * Valid In Asynchronous Callback: NO

   Returns
   * CY_AS_ERROR_SUCCESS - the function completed successfully
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED
   * CY_AS_ERROR_NO_FIRMWARE
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured yet
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to
   *	the West Bridge device

*/
EXTERN cy_as_return_status_t
cy_as_misc_heart_beat_control(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Message enable/disable selection */
	cy_bool	enable,
	 /* Callback to call when the operation is complete. */
	cy_as_function_callback		cb,
	/* Client data to be passed to the callback. */
	uint32_t			client
		);

/* Summary
   This function gets the current state of a GPIO pin on the
   West Bridge device.

   Description
   The West Bridge device has GPIO pins that can be used for user
   defined functions. This function gets the current state of the
   specified GPIO pin. Calling this function will configure the
   corresponding pin as an input.

   * Valid In Asynchronous Callback: NO

   Notes
   Only GPIO[0], GPIO[1] and UVALID pins can be used as GP inputs.
   Of these pins, only the UVALID pin is supported by firmware images
   that include NAND storage support.

   Returns
   * CY_AS_ERROR_SUCCESS - the function completed successfully
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured yet
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
   *	to the West Bridge device
   * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
   * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported
   *	by the firmware

   See Also
   * CyAsMiscGpio
   * CyAsMiscSetGpioValue
 */
EXTERN cy_as_return_status_t
cy_as_misc_get_gpio_value(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Id of the GPIO pin to query */
	cy_as_misc_gpio	pin,
	/* Current value of the GPIO pin */
	uint8_t	*value,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* Summary
   This function updates the state of a GPIO pin on the West
   Bridge device.

   Description
   The West Bridge device has GPIO pins that can be used for
   user defined functions. This function updates the output
   value driven on a specified GPIO pin. Calling this function
   will configure the corresponding pin as an output.

   * Valid In Asynchronous Callback: NO

   Notes
   All of the pins listed under CyAsMiscGpio can be used as GP
   outputs. This feature is note supported by firmware images
   that include NAND storage device support.

   Returns
   * CY_AS_ERROR_SUCCESS - the function completed successfully
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured yet
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
   *	to the West Bridge device
   * CY_AS_ERROR_BAD_INDEX - an invalid GPIO was specified
   * CY_AS_ERROR_NOT_SUPPORTED - this feature is not supported
   *	by firmware.

   See Also
   * CyAsMiscGpio
   * CyAsMiscGetGpioValue
 */
EXTERN cy_as_return_status_t
cy_as_misc_set_gpio_value(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Id of the GPIO pin to set */
	cy_as_misc_gpio	pin,
	/* Value to be set on the GPIO pin */
	uint8_t	 value,
	/* Callback to call when the operation is complete. */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* Summary
   Set the West Bridge device in the low power suspend mode.

   Description
   The West Bridge device has a low power suspend mode where the USB
   core and the internal microcontroller are powered down. This
   function sets the West Bridge device into this low power mode.
   This mode can only be entered when there is no active USB
   connection; i.e., when USB has not been connected or is suspended;
   and there are no pending USB or storage asynchronous calls. The
   device will exit the suspend mode and resume handling USB and
   processor requests when any activity is detected on the CE#, D+/D-
   or GPIO[0] lines.

   * Valid In Asynchronous Callback: NO

   Notes
   The GPIO[0] pin needs to be configured as an input for the gpio
   wakeup to work. This flag should not be enabled if the pin is
   being used as a GP output.

   Returns
   * CY_AS_ERROR_SUCCESS - the device was placed in suspend mode.
   * CY_AS_ERROR_INVALID_HANDLE - the West Bridge handle passed
   *	in is invalid.
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	yet been configured.
   * CY_AS_ERROR_NO_FIRMWARE - no firmware has been downloaded
   *	to the device.
   * CY_AS_ERROR_IN_STANDBY - the device is already in sleep mode.
   * CY_AS_ERROR_USB_CONNECTED - the USB connection is active.
   * CY_AS_ERROR_ASYNC_PENDING - asynchronous storage/USB calls
   *	are pending.
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
   *	the operation.
   * CY_AS_ERROR_INVALID_RESPONSE - command not recognised by
   *	firmware.

   See Also
   * CyAsMiscLeaveSuspend
 */
EXTERN cy_as_return_status_t
cy_as_misc_enter_suspend(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Control the USB wakeup source */
	cy_bool	usb_wakeup_en,
	/* Control the GPIO[0] wakeup source */
	cy_bool gpio_wakeup_en,
	/* Callback to call when suspend mode entry is complete */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* Summary
   Wake up the West Bridge device from suspend mode.

   Description
   This call wakes up the West Bridge device from suspend mode,
   and makes it ready for accepting other commands from the API.
   A CyAsEventMiscWakeup event will be delivered to the callback
   registered with CyAsMiscRegisterCallback to indicate that the
   wake up is complete.

   The CyAsEventMiscWakeup event will also be delivered if the
   wakeup happens due to USB or GPIO activity.

   * Valid In Asynchronous Callback: NO

   Returns
   * CY_AS_ERROR_SUCCESS - the device was woken up from
   *	suspend mode.
   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle
   *	passed in.
   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has
   *	not been configured.
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been
   *	downloaded to the device.
   * CY_AS_ERROR_NOT_IN_SUSPEND - the device is not in
   *	suspend mode.
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory
   *	for the operation.
   * CY_AS_ERROR_TIMEOUT - failed to wake up the device.

   See Also
   * CyAsMiscEnterSuspend
 */
EXTERN cy_as_return_status_t
cy_as_misc_leave_suspend(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Callback to call when device has resumed operation. */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* Summary
   Reserve first numzones zones of nand device for storing
   processor boot image. LNA firmware works  on the first
   numzones zones of nand to enable the processor to boot.

   Description
   This function reserves first numzones zones of nand device
   for storing processor boot image. This fonction MUST be
   completed before starting the storage stack for the setting
   to be taken into account.

   * Valid In Asynchronous Callback: YES

   Returns
   * CY_AS_ERROR_SUCCESS- zones are reserved.

*/
EXTERN cy_as_return_status_t
cy_as_misc_reserve_l_n_a_boot_area(
	/* Handle to the West Bridge device */
	cy_as_device_handle	 handle,
	/* number of nand zones to reserve */
	uint8_t numzones,
	/* Callback to call when device has resumed operation. */
	cy_as_function_callback cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* Summary
   Select the clock frequency to be used when talking to low
   speed (non-high speed) SD media.

   Description
   West Bridge firmware uses a clock frequency less than the
   maximum possible rate for low speed SD media.  This function
   selects the frequency setting from between the default speed
   and the maximum speed. This fonction MUST be completed before
   starting the storage stack for the setting to be taken into
   account.

   * Valid in Asynchronous Callback: Yes (if cb is non-zero)
   * Nestable: Yes

   Returns
   * CY_AS_ERROR_SUCCESS - the operation completed successfully.
   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
   *	configured.
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
   *	to the device.
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
   *	the operation.
   * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend
   *	mode.
   * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting
   *	desired.
   * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to
   *	the operation.
   * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support
   *	the operation.

   See Also
   * CyAsLowSpeedSDFreq
 */
EXTERN cy_as_return_status_t
cy_as_misc_set_low_speed_sd_freq(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Frequency setting desired for low speed SD cards */
	cy_as_low_speed_sd_freq	setting,
	/* Callback to call on completion */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback */
	uint32_t	client
	);

/* Summary
   Select the clock frequency to be used when talking to high speed
   SD/MMC media.

   Description
   West Bridge firmware uses a 48 MHz clock to interface with high
   speed SD/MMC media.  This clock rate can be restricted to 24 MHz
   if desired.  This function selects the frequency setting to be
   used. This fonction MUST be completed before starting the storage
   stack for the setting to be taken into account.

   * Valid in Asynchronous Callback: Yes (if cb is non-zero)
   * Nestable: Yes

   Returns
   * CY_AS_ERROR_SUCCESS - the operation completed successfully.
   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
   *	configured.
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded to
   *	the device.
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for the
   *	operation.
   * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power suspend mode.
   * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting desired.
   * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to the
   *	operation.
   * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not support
   *	the operation.

   See Also
   * CyAsLowSpeedSDFreq
 */
EXTERN cy_as_return_status_t
cy_as_misc_set_high_speed_sd_freq(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* Frequency setting desired for high speed SD cards */
	cy_as_high_speed_sd_freq setting,
	/* Callback to call on completion */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback */
	uint32_t client
	);
/* Summary
   Select the polarity of the SD_POW output driven by West Bridge.

   Description
   The SD_POW signal driven by West Bridge can be used to control
   the supply of Vcc to the SD/MMC media connected to the device.
   This signal is driven as an active high signal by default. This
   function can be used to change the polarity of this signal if
   required. This fonction MUST be completed before starting the
   storage stack for the setting to be taken into account.

   * Valid in Asynchronous Callback: Yes (if cb is non-zero)
   * Nestable: Yes

   Returns
   * CY_AS_ERROR_SUCCESS - the operation completed successfully.
   * CY_AS_ERROR_INVALID_HANDLE - invalid device handle passed in.
   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has not been
   *	configured.
   * CY_AS_ERROR_NO_FIRMWARE - firmware has not been downloaded
   *	to the device.
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to allocate memory for
   *	the operation.
   * CY_AS_ERROR_IN_SUSPEND - West Bridge is in low power
   *	suspend mode.
   * CY_AS_ERROR_INVALID_PARAMETER - invalid frequency setting
   *	desired.
   * CY_AS_ERROR_TIMEOUT - West Bridge device did not respond to
   *	the operation.
   * CY_AS_ERROR_INVALID_RESPONSE - active firmware does not
   *	support the operation.

   See Also
   * CyAsMiscSignalPolarity
 */
EXTERN cy_as_return_status_t
cy_as_misc_set_sd_power_polarity(
	/* Handle to the West Bridge device */
	cy_as_device_handle handle,
	/* Desired polarity setting to the SD_POW signal. */
	cy_as_misc_signal_polarity polarity,
	/* Callback to call on completion. */
	cy_as_function_callback cb,
	/* Client data to be passed to the callback. */
	uint32_t client
	);

/* For supporting deprecated functions */
#include "cyasmisc_dep.h"

#include "cyas_cplus_end.h"

#endif				/* _INCLUDED_CYASMISC_H_ */
OpenPOWER on IntegriCloud