summaryrefslogtreecommitdiffstats
path: root/drivers/staging/westbridge/astoria/include/linux/westbridge/cyasstorage.h
blob: 64f078cf202c08b9e7ecd7bddbabdea71410e6b6 (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
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
/* Cypress West Bridge API header file (cyasstorage.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_CYASSTORAGE_H_
#define _INCLUDED_CYASSTORAGE_H_

#include "cyasmedia.h"
#include "cyasmisc.h"
#include "cyas_cplus_start.h"


/*@@Storage APIs
  Summary
  This section documents the storage APIs supported by the
  West Bridge API.

  Description
  The storage API is based on some specific concepts which
  are referenced here.
  * <LINK Storage API Overview>
  * Addressing
  * Ownership
  * <LINK Asynchronous Versus Synchronous Operation>
*/

/*@@Storage API Overview
  Summary
  Storage devices are identified by media type. Each media
  type is considered a  single logical device.

  Description
  Each media type has a consistent block size and consists
  of a set of logical blocks numbered from 0 to N - 1 where
  N is the size of the
  media type in blocks. The mass storage APIs defined below
  provide the
  capability to query for devices that are present, and
  read/write data to/from
  these devices.
*/

/*@@Addressing
  Summary
  Blocks within a storage device are address by a hierarchal
  block address.  This
  address consists of the bus number, physical device,
   logical unit, and finally
  block address.

  Description
  While currently only a single device of each media type
  is supported, the address
  space reserves space in the future for multiple devices
  of each type.  Therefore
  the second element of the address is the specific device
  being addressed within
  a given device type.  For this release of the software,
  this value will always be
  zero to address the first device.

  The third element of the address is the logical unit.
  A device being managed
  by West Bridge can be partitioned into multiple logical
  units.  This partition
  information is stored on each device itself.  Currently,
  one of the storage devices
  managed by West Bridge can be partitioned into two
  logical units.

  Finally a logical block address is given within the
  logical unit to address an
  individual block.
*/

/*@@Ownership
  Summary
  While West Bridge supports concurrent block level
  operations from both the USB port and
  the processor port, this is not desirable in most
  situations as the file system
  contained on the storage media cannot be accessed
  concurrently.  To insure access
  by only one of USB and the processor, the West Bridge
  API provides for ownership of storage
  devices based on media type.

  Description
  The processor requests ownership of a given media type
  by calling CyAsStorageClaim().
  The firmware in West Bridge releases control of the
  media and signals the processor through
  the event callback registered with
  CyAsStorageRegisterCallback().  The specific event is
  the CyAsStorageProcessor. The processor can later
  release the media via a call to
  CyAsStorageRelease().  This call is immediate and
  no callback is required.

  If the processor has claimed storage and the USB port
  is connected, West Bridge will need to
  claim the storage to manage the mass storage device.
  West Bridge requests the storage through
  the event callback registered with
  CyAsStorageRegisterCallback().  The specific event is
  CyAsStorageAntioch and is named as such to reflect
  the USB view of storage.  This callback
  is a request for the processor to release storage.
  The storage is not actually released
  until the processor calls CyAsStorageRelease().

  Note that the CyAsStorageAntioch is only sent when the
  USB storage device is enumerated and
  NOT at every USB operation.  The ownership of a given
  storage media type is assumed to belong
  to the processor until the USB connection is established.
  At that point, the storage ownership
  is transferred to West Bridge.  After the USB connection
  is broken, ownership can be transferred
  back to the processor.
*/

/*@@Asynchronous Versus Synchronous Operation
  Summary
  When read or write operations are performed to the
  storage devices, these operations may be
  synchronous or asynchronous.  A synchronous operation
  is an operation where the read or write
  operation is requested and the function does not return
  until the operation is complete.  This
  type of function is the easiest to use but does not
  provide for optimal usage of the P port processor time.

  Description
  An asynchronous operation is one where the function returns
  as soon as the request is started.
  The specific read and write request will complete at some
  time in the future and the P port
  processor will be notified via a callback function.  While
  asynchronous functions provide for
  much better usage of the CPU, these function have more
  stringent requirements for use.  First,
  any buffer use for data transfer must be valid from the
  function call to request the operation
  through when the callback function is called.  This basically
  implies that stack based buffers
  are not acceptable for asynchronous calls.  Second, error
  handling must be deferred until the
  callback function is called indicating any kind of error
  that may have occurred.
*/

/*@@Partitioning
  Summary
  West Bridge API and firmware support the creation of up to
  two logical partitions on one
  of the storage devices that are managed by West Bridge.  The
  partitions are managed through
  the CyAsStorageCreatePPartition and CyAsStorageRemovePPartition
  APIs.

  Description
  The CyAsStorageCreatePPartition API is used to divide the total
  storage on a storage
  device into two logical units or partitions.  Since the partition
  information is stored
  on the storage device in a custom format, partitions should
  only be created on fixed
  storage devices (i.e., no removable SD/MMC cards).  Any data
  stored on the device
  before the creation of the partition, is liable to be lost when
  a partition is created.

  The CyAsStorageRemovePPartition API is used to remove the
  stored partition information,
  so that all of the device's capacity is treated as a single
  partition again.

  When a storage device with two partitions (units) is being
  enumerated as a mass storage
  device through the West Bridge, it is possible to select the
  partitions to be made
  visible to the USB host.  This is done through the
  CyAsUsbSelectMSPartitions API.
*/

/*********************************
 * West Bridge Constants
 **********************************/

/* Summary
   This constants indicates a raw device access to the read/write
   functions

   Description
   When performing reading and writing operations on the
   storage devices attached
   to West Bridge, there are cases where writes need to
   happen to raw devices, versus
   the units contained within a device.  This is
   specifically required to manage
   the partitions within physical devices.  This constant
   is used in calls to
   CyAsStorageRead(), CyAsStorageReadAsync(),
   CyAsStorageWrite() and
   CyAsStorageWriteAsync(), to indicate that the raw
   physical device is being
   accessed and not any specific unit on the device.

   See Also
   * CyAsStorageRead
   * CyAsStorageReadAsync
   * CyAsStorageWrite
   * CyAsStorageWriteAsync
*/
#define CY_AS_LUN_PHYSICAL_DEVICE (0xffffffff)

/* Summary
   This constant represents the maximum DMA burst length
   supported on a storage endpoint

   Description
   West Bridge reserves separate endpoints for accessing
   storage media through the
   CyAsStorageRead() and CyAsStorageWrite() calls. The
   maximum size of these
   endpoints is always 512 bytes, regardless of status
   and speed of the USB
   connection.
*/
#define CY_AS_STORAGE_EP_SIZE (512)

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

/* Summary
   This type indicates the type of event in an event
   callback from West Bridge

   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 indicates the resonse for
   the call to the callback function.

   See Also
   * CyAsStorageEventCallback
   * CyAsStorageRegisterCallback
*/
typedef enum cy_as_storage_event {
	/*  This event occurs when the West Bridge device has
	detected a USB connect and has enumerated the
	storage controlled by west bridge to the USB port.
	this event is the signal that the processor
	needs to release the storage media. west bridge will
	not have control of the storage media until the
	processor calls cy_as_release_storage() to release
	the specific media. */
	cy_as_storage_antioch,

	/*  This event occurs when the processor has requested
	ownership of a given media type and west bridge has
	released the media.  this event is an indicator
	that the transfer of ownership is complete and the
	processor now owns the given media type. */
	cy_as_storage_processor,

	/*  This event occurs when a removable media type has
	been removed. */
	cy_as_storage_removed,

	/*  This event occurs when a removable media type has
		been inserted. */
	cy_as_storage_inserted,

	/* This event occurs when the West Bridge device
	 * percieves an interrrupt from an SDIO card */
	cy_as_sdio_interrupt

} cy_as_storage_event;

/* Summary
   This type gives the type of the operation in a storage
   operation callback

   Description
   This type is used in the callback function for asynchronous
   operation.  This type indicates whether it is a
   CyAsStorageRead() or CyAsStorageWrite() operation that
   has completed.

   See Also
   * <LINK Asynchronous Versus Synchronous Operation>
   * CyAsStorageRead
   * CyAsStorageWrite
*/
typedef enum cy_as_oper_type {
	/* A data read operation */
	cy_as_op_read,
	/* A data write operation */
	cy_as_op_write
} cy_as_oper_type;

/* Summary
   This data structure describes a specific type of media

   Description
   This data structure is the return value from the
   CyAsStorageQueryDevice function.  This structure provides
   information about the specific storage device being queried.

   See Also
   * CyAsStorageQueryDevice
*/
typedef struct cy_as_device_desc {
	/* Type of device */
	cy_as_media_type   type;
	/* Is the device removable */
	cy_bool		removable;
	/* Is the device writeable */
	cy_bool		writeable;
	/* Basic block size for device */
	uint16_t		block_size;
	/* Number of LUNs on the device */
	uint32_t		number_units;
	/* Is the device password locked */
	cy_bool		locked;
	 /* Size in bytes of an Erase Unit. Block erase operation
	is only supported for SD storage, and the erase_unit_size
	is invalid for all other kinds of storage. */
	uint32_t		erase_unit_size;
} cy_as_device_desc;

/* Summary
   This data structure describes a specific unit on a
   specific type of media

   Description
   This data structure is the return value from the
   CyAsStorageQueryUnit function. This structure provides
   information about the specific unit.

   See Also
   * CyAsStorageQueryUnit
*/
typedef struct cy_as_unit_desc {
	/* Type of device */
	cy_as_media_type type;
	/* Basic block size for device */
	uint16_t block_size;
	/* Physical start block for LUN */
	uint32_t start_block;
	/* Number of blocks in the LUN */
	uint32_t unit_size;
} cy_as_unit_desc;

/* Summary
   This function type defines a callback to be called after an
   asynchronous operation

   Description
   This function type defines a callback function that is called
   at the completion of any asynchronous read or write operation.

   See Also
   * CyAsStorageReadAsync()
   * CyAsStorageWriteAsync()
*/
typedef void (*cy_as_storage_callback)(
	/* Handle to the device completing the storage operation */
	cy_as_device_handle handle,
	/* The bus completing the operation */
	cy_as_bus_number_t bus,
	/* The device completing the operation */
	uint32_t device,
	/* The unit completing the operation */
	uint32_t unit,
	/* The block number of the completed operation */
	uint32_t block_number,
	/* The type of operation */
	cy_as_oper_type op,
	/* The error status */
	cy_as_return_status_t status
	);

/* Summary
   This function type defines a callback to be called in the
   event of a storage related event

   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.

   See Also
   * CyAsStorageEvent
   * CyAsStorageRegisterCallback
*/
typedef void (*cy_as_storage_event_callback)(
	/* Handle to the device sending the event notification */
	cy_as_device_handle handle,
	/* The bus where the event happened */
	cy_as_bus_number_t  bus,
	/* The device where the event happened */
	uint32_t device,
	/* The event type */
	cy_as_storage_event evtype,
	/* Event related data */
	void *evdata
	);

/* Summary
   This function type defines a callback to be called after
   an asynchronous sdio operation

   Description
   The Callback function is called at the completion of an
   asynchronous sdio read or write operation.

   See Also
   * CyAsSdioExtendedRead()
   * CyAsSdioExtendedWrite()
*/
typedef void (*cy_as_sdio_callback)(
	/* Handle to the device completing the storage operation */
	cy_as_device_handle handle,
	/* The bus completing the operation */
	cy_as_bus_number_t bus,
	/* The device completing the operation */
	uint32_t device,
	/* The function number of the completing the operation.
	if the status of the operation is either CY_AS_ERROR_IO_ABORTED
	or CY_AS_IO_SUSPENDED then the most significant word parameter will
	contain the number of blocks still pending. */
	uint32_t function,
	/* The base address of the completed operation */
	uint32_t address,
	/* The type of operation */
	cy_as_oper_type op,
	/* The status of the operation */
	cy_as_return_status_t status
	);

/* Summary
   Enumeration of SD/MMC card registers that can be read
   through the API.

   Description
   Some of the registers on the SD/MMC card(s) attached to the
   West Bridge can be read through the API layers. This type
   enumerates the registers that can be read.

   See Also
   * CyAsStorageSDRegisterRead
 */
typedef enum cy_as_sd_card_reg_type {
	cy_as_sd_reg_OCR = 0,
	cy_as_sd_reg_CID,
	cy_as_sd_reg_CSD
} cy_as_sd_card_reg_type;

/* Summary
   Struct encapsulating parameters and return values for a
   CyAsStorageQueryDevice call.

   Description
   This struct holds the input parameters and the return values
   for an asynchronous CyAsStorageQueryDevice call.

   See Also
   * CyAsStorageQueryDevice
 */
typedef struct cy_as_storage_query_device_data {
	/* The bus with the device to query */
	cy_as_bus_number_t	bus;
	/* The logical device number to query */
	uint32_t		device;
	/* The return value for the device descriptor */
	cy_as_device_desc	 desc_p;
} cy_as_storage_query_device_data;


/* Summary
   Struct encapsulating parameters and return values
   for a CyAsStorageQueryUnit call.

   Description
   This struct holds the input parameters and the return
   values for an asynchronous CyAsStorageQueryUnit call.

   See Also
   * CyAsStorageQueryUnit
 */
typedef struct cy_as_storage_query_unit_data {
	/* The bus with the device to query */
	cy_as_bus_number_t	bus;
	/* The logical device number to query */
	uint32_t			device;
	/* The unit to query on the device */
	uint32_t			unit;
	/* The return value for the unit descriptor */
	cy_as_unit_desc	 desc_p;
} cy_as_storage_query_unit_data;

/* Summary
   Struct encapsulating the input parameter and return
   values for a CyAsStorageSDRegisterRead call.

   Description
   This struct holds the input parameter and return
   values for an asynchronous CyAsStorageSDRegisterRead
   call.

   See Also
   * CyAsStorageSDRegisterRead
 */
typedef struct cy_as_storage_sd_reg_read_data {
	/* Pointer to the result buffer. */
	uint8_t *buf_p;
	/* Length of data to be copied in bytes. */
	uint8_t  length;
} cy_as_storage_sd_reg_read_data;

/* Summary
   Controls which pins are used for card detection

   Description
   When a StorageDeviceControl call is made to enable or
   disable card detection this enum is passed in to
   control which pin is used for the detection.

   See Also
   * CyAsStorageDeviceControl
*/
typedef enum cy_as_storage_card_detect {
	cy_as_storage_detect_GPIO,
	cy_as_storage_detect_SDAT_3
} cy_as_storage_card_detect;

#ifndef __doxygen__
#define cy_as_storage_detect_GPIO_0 cy_as_storage_detect_GPIO

/* Length of OCR value in bytes. */
#define CY_AS_SD_REG_OCR_LENGTH		 (4)
/* Length of CID value in bytes. */
#define CY_AS_SD_REG_CID_LENGTH		 (16)
/* Length of CSD value in bytes. */
#define CY_AS_SD_REG_CSD_LENGTH		 (16)
/* Max. length of register response in words. */
#define CY_AS_SD_REG_MAX_RESP_LENGTH	(10)

#endif

/* Summary
   This data structure is the data passed via the evdata
   paramater on a usb event callback for the mass storage
   device progress event.

   Description
   This data structure reports the number of sectors that have
   been written and read on the USB mass storage device since
   the last event report.  The corresponding event is only sent
   when either the number of writes, or the number of reads has
   crossed a pre-set threshold.

   See Also
   * CyAsUsbEventCallback
   * CyAsUsbRegisterCallback
*/
typedef struct cy_as_m_s_c_progress_data {
	/* Number of sectors written since the last event. */
	uint32_t wr_count;
	/* Number of sectors read since the last event. */
	uint32_t rd_count;
} cy_as_m_s_c_progress_data;

/* Summary
Flag to set Direct Write operation to read back from the
address written to.


 See Also
 *CyAsSdioDirectWrite()
*/
#define CY_SDIO_RAW	(0x01)


/* Summary
Flag to set Extended Read and Write to perform IO
using a FIFO i.e. read or write from the specified
address only.

 See Also
 *CyAsSdioExtendedRead()
 *CyAsSdioExtendedWrite()
*/
#define CY_SDIO_OP_FIFO (0x00)

/* Summary
Flag to set Extended Read and Write to perform incremental
IO using the address provided as the base address.


 See Also
 *CyAsSdioExtendedRead()
 *CyAsSdioExtendedWrite()
*/
#define CY_SDIO_OP_INCR		 (0x02)

/* Summary
Flag to set Extended Read and Write to Block Mode operation

 See Also
 *CyAsSdioExtendedRead()
 *CyAsSdioExtendedWrite()
*/
#define CY_SDIO_BLOCKMODE	   (0x04)

/* Summary
Flag to set Extended Read and Write to Byte Mode operation

 See Also
 *CyAsSdioExtendedRead()
 *CyAsSdioExtendedWrite()
*/
#define CY_SDIO_BYTEMODE		(0x00)

/* Summary
Flag to force re/initialization of a function.

Description
If not set a call to CyAsSdioInitFunction()
will not initialize a function that has been previously
initialized.
 See Also
 *CyAsSdioInitFunction()
 */
#define CY_SDIO_FORCE_INIT	  (0x40)

/* Summary
Flag to re-enable the SDIO interrupts.

Description
Used with a direct read or direct write
after the Interrupt triggerred by SDIO has been serviced
and cleared to reset the West Bridge Sdio Interrupt.
 See Also
 *CyAsSdioDirectRead()
 *CyAsSdioDirectWrite()
*/

#define CY_SDIO_REARM_INT	   (0x80)


/* Summary
   Flag to check if 4 bit support is enabled on a
   low speed card
   See Also
   <link CyAsSDIOCard::card_capability>*/
#define CY_SDIO_4BLS	(0x80)

/* Summary
   Flag to check if card is a low speed card
   See Also
   <link CyAsSDIOCard::card_capability>	  */
#define CY_SDIO_LSC	 (0x40)

/* Summary
   Flag to check if interrupt during multiblock data
   transfer is enabled
   See Also
   <link CyAsSDIOCard::card_capability>*/
#define CY_SDIO_E4MI	(0x20)

/* Summary
   Flag to check if interrupt during multiblock data
   transfer is supported
   See Also
   <link CyAsSDIOCard::card_capability>	*/
#define CY_SDIO_S4MI	(0x10)

/* Summary
   Flag to check if card supports function suspending.
   See Also
   <link CyAsSDIOCard::card_capability>	 */
#define CY_SDIO_SBS	 (0x08)

/* Summary
   Flag to check if card supports SDIO Read-Wait
   See Also
   <link CyAsSDIOCard::card_capability>	 */
#define CY_SDIO_SRW	 (0x04)

/* Summary
   Flag to check if card supports multi-block transfers
   See Also
   <link CyAsSDIOCard::card_capability>	*/
#define CY_SDIO_SMB	 (0x02)

/* Summary
   Flag to check if card supports Direct IO commands
   during execution of an Extended
   IO function
   See Also
   <link CyAsSDIOCard::card_capability>*/
#define CY_SDIO_SDC	 (0x01)

/* Summary
   Flag to check if function has a CSA area.
   See Also
   <link CyAsSDIOFunc::csa_bits> */
#define CY_SDIO_CSA_SUP		 (0x40)

/* Summary
   Flag to check if CSA access is enabled.
   See Also
   <link CyAsSDIOFunc::csa_bits> */
#define CY_SDIO_CSA_EN		  (0x80)

/* Summary
   Flag to check if CSA is Write protected.
   See Also
   <link CyAsSDIOFunc::csa_bits> */
#define CY_SDIO_CSA_WP		  (0x01)

/* Summary
   Flag to check if CSA formatting is prohibited.
   See Also
   <link CyAsSDIOFunc::csa_bits>*/
#define CY_SDIO_CSA_NF		  (0x02)

/* Summary
   Flag to check if the function allows wake-up from low
   power mode using some vendor specific method.
   See Also
   <link CyAsSDIOFunc::wakeup_support>*/
#define CY_SDIO_FN_WUS		  (0x01)


/* Summary
   This data structure stores SDIO function 0
   parameters for a SDIO card
*/
typedef struct cy_as_sdio_card {
	/* Number of functions present on the card. */
	uint8_t	 num_functions;
	/* Memory present(Combo card) or not */
	uint8_t	 memory_present;
	/* 16 bit manufacturer ID */
	uint16_t	manufacturer__id;
	/* Additional vendor specific info */
	uint16_t	manufacturer_info;
	/* Max Block size for function 0 */
	uint16_t	maxblocksize;
	/* Block size used for function 0 */
	uint16_t	blocksize;
	/* SDIO version supported by the card */
	uint8_t	 sdio_version;
	/* Card capability flags */
	uint8_t	 card_capability;
} cy_as_sdio_card;

/* Summary
   This data structure stores SDIO function 1-7 parameters
   for a SDIO card
*/
typedef struct cy_as_sdio_func {
	/* SDIO function code. 0 if non standard function */
	uint8_t	 function_code;
	/* Extended function type code for non-standard function */
	uint8_t	 extended_func_code;
	/* Max IO Blocksize supported by the function */
	uint16_t	maxblocksize;
	/* IO Blocksize used by the function */
	uint16_t	blocksize;
	/* 32 bit product serial number for the function */
	uint32_t	card_psn;
	/* Code storage area variables */
	uint8_t	 csa_bits;
	/* Function wake-up support */
	uint8_t	 wakeup_support;
} cy_as_sdio_func;

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

/* Summary
   This function starts the West Bridge storage module.

   Description
   This function initializes the West Bridge storage software
   stack and readies this module to service storage related
   requests.  If the stack is already running, the reference
   count for the stack is incremented.

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

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
   * CY_AS_ERROR_SUCCESS - the module started sucessfully
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE

   See Also
   * CyAsStorageStop
*/
EXTERN cy_as_return_status_t
cy_as_storage_start(
	/* Handle to the device */
	cy_as_device_handle	handle,
	/* Callback to be called when the operation is complete */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback */
	uint32_t		client
	);

/* Summary
   This function stops the West Bridge storage module.

   Description
   This function decrements the reference count for the
   storage stack and if this count is zero, the storage
   stack is shut down.  The shutdown frees all resources
   associated with the storage stack.

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

   Notes
   While all resources associated with the storage stack
   will be freed is a shutdown occurs,
   resources associated with underlying layers of the
   software will not be freed if they
   are shared by the USB stack and the USB stack is
   active.  Specifically the DMA manager,
   the interrupt manager, and the West Bridge
   communications module are all shared by both the
   USB stack and the storage stack.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge
   *	device has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not
   *	been loaded into West Bridge
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - this module was shut
   *	down sucessfully
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING
   * CY_AS_ERROR_ASYNC_PENDING
   * CY_AS_ERROR_OUT_OF_MEMORY

   See Also
   * CyAsStorageStart
*/
EXTERN cy_as_return_status_t
cy_as_storage_stop(
	/* Handle to the device to configure */
	cy_as_device_handle	handle,
	/* Callback to be called 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 used to register a callback function
   for the storage API.

   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 function
   registers the callback
   function that is called when an event occurs.  Each call
   to this function
   replaces any old callback function with a new callback
   function supplied on
   the most recent call.  This function can also be called
   with a callback function
   of NULL in order to remove any existing callback function

   * Valid In Asynchronous Callback:YES

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has
   *	not been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
   *	was passed in
   * CY_AS_ERROR_SUCCESS - the function was registered
   *	sucessfully
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running

   See Also
   * CyAsStorageEventCallback
   * CyAsStorageEvent
*/
EXTERN cy_as_return_status_t
cy_as_storage_register_callback(
	/* Handle to the device of interest */
	cy_as_device_handle			handle,
	/* The callback function to call for async storage events */
	cy_as_storage_event_callback	callback
	);

/* Summary
   This function claims a given media type.

   Description
   This function communicates to West Bridge that the
   processor wants control of the
   given storage media type.  Each media type can be
   claimed or released by the
   processor independently.  As the processor is the
   master for the storage,
   West Bridge should release control of the requested
   media as soon as possible and
   signal the processor via the CyAsStorageProcessor event.

   * Valid In Asynchronous Callback: NO

   Notes
   This function just notifies West Bridge that the storage
   is desired.  The storage
   has not actually been released by West Bridge until the
   registered callback function
   is called with the CyAsStorageProcessor event

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - this request was sucessfully
   *	transmitted to the West Bridge device
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_NO_SUCH_MEDIA
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE
   * CY_AS_ERROR_NOT_ACQUIRED

   See Also:
   * CyAsStorageClaim
   * CyAsStorageRelease
*/
EXTERN cy_as_return_status_t
cy_as_storage_claim(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The bus to claim */
	cy_as_bus_number_t	 bus,
	/* The device to claim */
	uint32_t		 device,
	/* Callback to be called 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 media type.

   Description
   This function communicates to West Bridge that the
   processor has released control of
   the given storage media type.  Each media type can
   be claimed or released by the
   processor independently.  As the processor is the
   master for the storage, West Bridge
   can now assume ownership of the media type.  No callback
   or event is generated.

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

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
   *	was passed in
   * CY_AS_ERROR_SUCCESS - the media was sucessfully
   *	released
   * CY_AS_ERROR_MEDIA_NOT_CLAIMED - the media was not
   *	claimed by the P port
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_NO_SUCH_MEDIA
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE

   See Also
   * CyAsStorageClaim
*/
EXTERN cy_as_return_status_t
cy_as_storage_release(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The bus to release */
	cy_as_bus_number_t	 bus,
	/* The device to release */
	uint32_t		 device,
	/* Callback to be called when the operation is complete */
	cy_as_function_callback	cb,
	/* Client data to be passed to the callback */
	uint32_t		client
	);

/* Summary
   This function information about the number of devices present
   on a given bus

   Description
   This function retrieves information about how many devices on
   on the given
   West Bridge bus.

   * Valid In Asynchronous Callback: NO

   Notes
   While the current implementation of West Bridge only
   supports one of logical device of
   each media type, future versions WestBridge/Antioch may
   support multiple devices.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE

   See Also
   * CyAsStorageQueryDevice
   * CyAsStorageQueryUnit
*/
EXTERN cy_as_return_status_t
cy_as_storage_query_bus(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The bus to query */
	cy_as_bus_number_t		bus,
	/* The return value containing the number of
	devices present for this media type */
	uint32_t *count,
	/* Callback to be called when the operation is complete */
	cy_as_function_callback	 cb,
	/* Client data to be passed to the callback */
	uint32_t client
	);

/* Summary
   This function information about the number of devices
   present for a given media type

   Description
   This function retrieves information about how many
   devices of a given media type are attached to West Bridge.

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

   Notes
   While the current implementation of West Bridge only
   supports one of logical device of each media type, future
   versions West Bridge may support multiple devices.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE

   See Also
   * CyAsStorageQueryMedia
   * CyAsMediaType
   * CyAsStorageQueryDevice
   * CyAsStorageQueryUnit
*/
EXTERN cy_as_return_status_t
cy_as_storage_query_media(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The type of media to query */
	cy_as_media_type		type,
	/* The return value containing the number of
	devices present for this media type */
	uint32_t *count,
	/* Callback to be called 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 information about a given device
   of a specific media type

   Description
   This function retrieves information about a device of a
   given type of media.  The function is called with a given
   media type and device and a pointer to a media descriptor
   (CyAsDeviceDesc).  This function fills in the data in the
   media descriptor to provide information about the
   attributes of the device of the given device.

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

   Notes
   Currently this API only supports a single logical device
   of each media type.  Therefore the only acceptable value
   for the parameter device is zero (0).

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_NO_SUCH_MEDIA
   * CY_AS_ERROR_NO_SUCH_DEVICE
   * CY_AS_ERROR_INVALID_RESPONSE

   See Also
   * CyAsMediaType
   * CyAsStorageQueryMedia
   * CyAsStorageQueryUnit
   * CyAsDeviceDesc
*/
EXTERN cy_as_return_status_t
cy_as_storage_query_device(
	/* Handle to the device of interest */
	cy_as_device_handle		handle,
	/* Parameters and return value for the query call */
	cy_as_storage_query_device_data *data,
	/* Callback to be called 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 information about a given unit on a
   specific device

   Description
   This function retrieves information about a device of a
   given logical unit.  The function is called with a given
   media type, device address, unit address,  and a pointer
   to a unit descriptor (CyAsUnitDesc).  This function fills
   in the data in the unit descriptor to provide information
   about the attributes of the device of the given logical
   unit.

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

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_NO_SUCH_DEVICE
   * CY_AS_ERROR_NO_SUCH_UNIT
   * CY_AS_ERROR_INVALID_RESPONSE


   See Also
   * CyAsMediaType
   * CyAsStorageQueryMedia
   * CyAsStorageQueryDevice
   * CyAsUnitDesc
*/
EXTERN cy_as_return_status_t
cy_as_storage_query_unit(
	/* Handle to the device of interest */
	cy_as_device_handle		handle,
	/* Parameters and return value for the query call */
	cy_as_storage_query_unit_data *data_p,
	/* Callback to be called when the operation is complete */
	cy_as_function_callback		cb,
	/* Client data to be passed to the callback */
	uint32_t			client
	);

/* Summary
   This function enables/disables the handling of SD/MMC card
   detection and SD/MMC write protection in West Bridge Firmware.

   Description
   If the detection of SD/MMC card insertion or removal is being
   done by the Processor directly, the West Bridge firmware needs
   to be instructed to disable the card detect feature. Also, if
   the hardware design does not use the SD_WP GPIO of the West
   Bridge to handle SD card's write protect notch, the handling
   of write protection if firmware should be disabled. This API
   is used to enable/disable the card detect and write protect
   support in West Bridge firmware.

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

   Returns
   * CY_AS_ERROR_SUCCESS - the feature controls were
   *	set successfully
   * CY_AS_ERROR_NO_SUCH_BUS - the specified bus is invalid
   * CY_AS_ERROR_NOT_SUPPORTED - function not supported on
   *	the device in the specified bus
   * CY_AS_ERROR_IN_SUSPEND - the West Brdige device is in
   *	suspended mode
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_INVALID_HANDLE
   * CY_AS_ERROR_OUT_OF_MEMORY
   * CY_AS_ERROR_INVALID_RESPONSE

*/
EXTERN cy_as_return_status_t
cy_as_storage_device_control(
	/* Handle to the West Bridge device */
	cy_as_device_handle	handle,
	/* The bus to control */
	cy_as_bus_number_t	 bus,
	/* The device to control */
	uint32_t		 device,
	/* Enable/disable control for card detection */
	cy_bool		card_detect_en,
	/* Enable/disable control for write protect handling */
	cy_bool		write_prot_en,
	/* Control which pin is used for card detection */
	cy_as_storage_card_detect	config_detect,
	 /* Callback to be called when the operation is complete */
	cy_as_function_callback	 cb,
	/* Client data to be passed to the callback */
	uint32_t		client
		);

/* Summary
   This function reads one or more blocks of data from
   the storage system.

   Description
   This function synchronously reads one or more blocks
   of data from the given media
   type/device and places the data into the data buffer
   given.  This function does not
   return until the data is read and placed into the buffer.

   * Valid In Asynchronous Callback: NO

   Notes
   If the Samsung CEATA drive is the target for a
   read/write operation, the maximum
   number of sectors that can be accessed through a
   single API call is limited to 2047.
   Longer accesses addressed to a Samsung CEATA drive
   can result in time-out errors.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
   *	was passed in
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_ASYNC_PENDING - an async operation
   *	is pending
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was
   *	error in reading from the media
   * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is
   *	write protected
   * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
   *	than 4095 logic blocks are not allowed

   See Also
   * CyAsStorageReadAsync
   * CyAsStorageWrite
   * CyAsStorageWriteAsync
   * CyAsStorageCancelAsync
   * <LINK Asynchronous Versus Synchronous Operation>
*/
EXTERN cy_as_return_status_t
cy_as_storage_read(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The bus to access */
	cy_as_bus_number_t		bus,
	/* The device to access */
	uint32_t		device,
	/* The unit to access */
	uint32_t		unit,
	/* The first block to access */
	uint32_t		block,
	/* The buffer where data will be placed */
	void *data_p,
	/* The number of blocks to be read */
	uint16_t		num_blocks
	);

/* Summary
   This function asynchronously reads one or more blocks of data
   from the storage system.

   Description
   This function asynchronously reads one or more blocks of
   data from the given media
   type/device and places the data into the data buffer given.
   This function returns
   as soon as the request is transmitted to the West Bridge
   device but before the data is
   available.  When the read is complete, the callback function
   is called to indicate the
   data has been placed into the data buffer.  Note that the
   data buffer must remain
   valid from when the read is requested until the callback
   function is called.

   * Valid In Asynchronous Callback: YES

   Notes
   If the Samsung CEATA drive is the target for a read/write
   operation, the maximum
   number of sectors that can be accessed through a single API
   call is limited to 2047.
   Longer accesses addressed to a Samsung CEATA drive can
   result in time-out errors.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle
   *	was passed in
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_ASYNC_PENDING - an async operation
   *	is pending
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error
   *	in reading from the media
   * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is
   *	write protected
   * CY_AS_ERROR_QUERY_DEVICE_NEEDED - Before an
   *	asynchronous read can be issue a call to
   * CyAsStorageQueryDevice must be made
   * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
   * than 4095 logic blocks are not allowed

   See Also
   * CyAsStorageRead
   * CyAsStorageWrite
   * CyAsStorageWriteAsync
   * CyAsStorageCancelAsync
   * CyAsStorageQueryDevice
   * <LINK Asynchronous Versus Synchronous Operation>
*/
EXTERN cy_as_return_status_t
cy_as_storage_read_async(
	/* Handle to the device of interest */
	cy_as_device_handle handle,
	/* The bus to access */
	cy_as_bus_number_t	bus,
	/* The device to access */
	uint32_t device,
	/* The unit to access */
	uint32_t unit,
	/* The first block to access */
	uint32_t block,
	/* The buffer where data will be placed */
	void *data_p,
	/* The number of blocks to be read */
	uint16_t num_blocks,
	/* The function to call when the read is complete
	or an error occurs */
	cy_as_storage_callback		callback
	);

/* Summary
   This function writes one or more blocks of data
   to the storage system.

   Description
   This function synchronously writes one or more blocks of
   data to the given media/device.
   This function does not return until the data is written
   into the media.

   * Valid In Asynchronous Callback: NO

   Notes
   If the Samsung CEATA drive is the target for a read/write
   operation, the maximum
   number of sectors that can be accessed through a single
   API call is limited to 2047.
   Longer accesses addressed to a Samsung CEATA drive can
   result in time-out errors.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_ASYNC_PENDING - an async operation
   *	is pending
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error
   *	in reading from the media
   * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is
   *	write protected
   * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
   *	than 4095 logic blocks are not allowed

   See Also
   * CyAsStorageRead
   * CyAsStorageReadAsync
   * CyAsStorageWriteAsync
   * CyAsStorageCancelAsync
   * <LINK Asynchronous Versus Synchronous Operation>
*/
EXTERN cy_as_return_status_t
cy_as_storage_write(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The bus to access */
	cy_as_bus_number_t bus,
	/* The device to access */
	uint32_t device,
	/* The unit to access */
	uint32_t unit,
	/* The first block to access */
	uint32_t block,
	/* The buffer containing the data to be written */
	void *data_p,
	/* The number of blocks to be written */
	uint16_t num_blocks
	);

/* Summary
   This function asynchronously writes one or more blocks
   of data to the storage system

   Description
   This function asynchronously writes one or more blocks of
   data to the given media type/device.
   This function returns as soon as the request is transmitted
   to the West Bridge device
   but before the data is actually written.  When the write is
   complete, the callback
   function is called to indicate the data has been physically
   written into the media.

   * Valid In Asynchronous Callback: YES

   Notes
   If the Samsung CEATA drive is the target for a read/write
   operation, the maximum
   number of sectors that can be accessed through a single API
   call is limited to 2047.
   Longer accesses addressed to a Samsung CEATA drive can
   result in time-out errors.

   Notes
   The data buffer must remain valid from when the write is
   requested until the callback function is called.

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has
   *	not been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_ASYNC_PENDING - an async operation is
   *	pending
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   *	reading from the media
   * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is write
   *	protected
   * CY_AS_ERROR_QUERY_DEVICE_NEEDED - A query device call is
   *	required before async writes are allowed
   * CY_AS_ERROR_INVALID_PARAMETER - Reads/Writes greater
   *	than 4095 logic blocks are not allowed

   See Also
   * CyAsStorageRead
   * CyAsStorageWrite
   * CyAsStorageReadAsync
   * CyAsStorageCancelAsync
   * CyAsStorageQueryDevice
   * <LINK Asynchronous Versus Synchronous Operation>
*/
EXTERN cy_as_return_status_t
cy_as_storage_write_async(
	/* Handle to the device of interest */
	cy_as_device_handle	handle,
	/* The bus to access */
	cy_as_bus_number_t	bus,
	/* The device to access */
	uint32_t	device,
	/* The unit to access */
	uint32_t	unit,
	/* The first block to access */
	uint32_t	block,
	/* The buffer where the data to be written is stored */
	void *data_p,
	/* The number of blocks to be written */
	uint16_t num_blocks,
	/* The function to call when the write is complete
		or an error occurs */
	cy_as_storage_callback	callback
	);

/* Summary
   This function aborts any outstanding asynchronous operation

   Description
   This function aborts any asynchronous block read or block
   write operation.  As only a single asynchronous block read
   or write operation is possible at one time, this aborts
   the single operation in progress.

   * Valid In Asynchronous Callback: YES

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_NO_OPERATION_PENDING - no asynchronous
   *	operation is pending

   See Also
   * CyAsStorageRead
   * CyAsStorageReadAsync
   * CyAsStorageWrite
   * CyAsStorageWriteAsync
   * <LINK Asynchronous Versus Synchronous Operation>
*/
EXTERN cy_as_return_status_t
cy_as_storage_cancel_async(
	/* Handle to the device with outstanding async request */
	cy_as_device_handle		handle
	);

/* Summary
   This function is used to read the content of SD registers

   Description
   This function is used to read the contents of CSD, CID and
   CSD registers of the SD Card.

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

   Returns
   * CY_AS_ERROR_SUCCESS - the read operation was successful
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   *	started
   * CY_AS_ERROR_IN_SUSPEND - The West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device pair
   *	does not exist
   * CY_AS_ERROR_INVALID_PARAMETER - The register type is invalid
   *	or the media is not supported on the bus
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to process
   *	request
   * CY_AS_ERROR_INVALID_RESPONSE - communication failure with
   *	West Bridge firmware

   See Also
   * CyAsStorageSDRegReadData
 */
EXTERN cy_as_return_status_t
cy_as_storage_sd_register_read(
	/* Handle to the West Bridge device. */
	cy_as_device_handle	handle,
	/* The bus to query */
	cy_as_bus_number_t	bus,
	/* The device to query */
	uint8_t	device,
	/* The type of register to read. */
	cy_as_sd_card_reg_type reg_type,
	/* Output data buffer and length. */
	cy_as_storage_sd_reg_read_data	 *data_p,
	/* Callback function to call when done. */
	cy_as_function_callback		cb,
	/* Call context to send to the cb function. */
	uint32_t client
	);

/* Summary
   Creates a partition starting at the given block and using the
   remaining blocks on the card.

   Description
   Storage devices attached to West Bridge can be partitioned
   into two units.
   The visibility of these units through the mass storage
   interface can be
   individually controlled.  This API is used to partition
   a device into two.

   * Valid in Asynchronous Callback: Yes (if cb supplied)
   * Nestable: Yes

   Returns
   * CY_AS_ERROR_SUCCESS - the partition was successfully created
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   *	started
   * CY_AS_ERROR_IN_SUSPEND - The West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_USB_RUNNING - Partition cannot be created while
   *	USB stack is active
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to
   *	process request
   * CY_AS_ERROR_INVALID_REQUEST - feature not supported by
   *	active device or firmware
   * CY_AS_ERROR_INVALID_RESPONSE - communication failure with
   *	West Bridge firmware
   * CY_AS_ERROR_ALREADY_PARTITIONED - the storage device already
   *	has been partitioned
   * CY_AS_ERROR_INVALID_BLOCK - Size specified for the partition
   *	exceeds the actual device capacity

   See Also
   * <LINK Partitioning>
   * CyAsStorageRemovePPartition
 */
EXTERN cy_as_return_status_t
cy_as_storage_create_p_partition(
	/* Handle to the device of interest */
	cy_as_device_handle handle,
	/* Bus on which the device to be partitioned is connected */
	cy_as_bus_number_t bus,
	/* Device number to be partitioned */
	uint32_t device,
	/* Size of partition number 0 in blocks */
	uint32_t size,
	/* Callback in case of async call */
	cy_as_function_callback cb,
	/* Client context to pass to the callback */
	uint32_t client
	);

/* Summary
   Removes the partition table on a storage device connected
   to the West Bridge.

   Description
   Storage devices attached to West Bridge can be partitioned
   into two units.This partition information is stored on the
   device and is non-volatile.  This API is used to remove the
   stored partition information and make the entire device
   visible as a single partition (unit).

   * Valid in Asynchronous Callback: Yes (if cb supplied)
   * Nestable: Yes

   Returns
   * CY_AS_ERROR_SUCCESS - the partition was successfully
   *	deleted
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_IN_SUSPEND - The West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_USB_RUNNING - Partition cannot be created
   *	while USB stack is active
   * CY_AS_ERROR_OUT_OF_MEMORY - failed to get memory to
   *	process request
   * CY_AS_ERROR_INVALID_REQUEST - operation not supported
   *	by active device/firmware
   * CY_AS_ERROR_NO_SUCH_UNIT - the addressed device is
   *	not partitioned

   See Also
   * <LINK Partitioning>
   * CyAsStorageCreatePPartition
 */
EXTERN cy_as_return_status_t
cy_as_storage_remove_p_partition(
	/* Handle to the device of interest */
	cy_as_device_handle handle,
	/* Bus on which device of interest is connected */
	cy_as_bus_number_t  bus,
	/* Device number of interest */
	uint32_t device,
	/* Callback in case of async call */
	cy_as_function_callback cb,
	/* Client context to pass to the callback */
	uint32_t client
	);

/* Summary
   Returns the amount of data read/written to the given
   device from the USB host.

   Description

   * Valid in Asynchronous Callback: Yes (if cb supplied)
   * Nestable: Yes

   Returns
   * CY_AS_ERROR_SUCCESS - API call completed successfully
   * CY_AS_ERROR_INVALID_HANDLE - Invalid West Bridge device
   *	handle
   * CY_AS_ERROR_NOT_CONFIGURED - West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - No firmware image has been
   * loaded on West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - Storage stack has not been
   *	started
   * CY_AS_ERROR_NOT_SUPPORTED - This function is not
   *	supported by active firmware version
   * CY_AS_ERROR_OUT_OF_MEMORY - Failed to get memory to
   *	process the request
   * CY_AS_ERROR_TIMEOUT - West Bridge firmware did not
   *	respond to request
   * CY_AS_ERROR_INVALID_RESPONSE - Unexpected reply from
   *	West Bridge firmware

   See Also
   * CyAsUsbSetMSReportThreshold
*/
EXTERN cy_as_return_status_t
cy_as_storage_get_transfer_amount(
	/* Handle to the device of interest */
	cy_as_device_handle handle,
	/* Bus on which device of interest is connected */
	cy_as_bus_number_t  bus,
	/* Device number of interest */
	uint32_t device,
	/* Return value containing read/write sector counts. */
	cy_as_m_s_c_progress_data *data_p,
	/* Callback in case of async call */
	cy_as_function_callback cb,
	/* Client context to pass to the callback */
	uint32_t client
	);

/* Summary
   Performs a Sector Erase on an attached SD Card

   Description
   This allows you to erase an attached SD card. The area to erase
   is specified in terms of a starting Erase Unit and a number of
   Erase Units. The size of each Erase Unit is defined in the
   DeviceDesc returned from a StorageQueryDevice call and it can
   differ between SD cards.

   A large erase can take a while to complete depending on the SD
   card. In such a case it is reccomended that an async call is made.

   Returns
   * CY_AS_ERROR_SUCCESS - API call completed successfully
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   *	started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed in
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
   *	the West Bridge device
   * CY_AS_ERROR_ASYNC_PENDING - an async operation is pending
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   * reading from the media
   * CY_AS_ERROR_MEDIA_WRITE_PROTECTED - the media is write protected
   * CY_AS_ERROR_QUERY_DEVICE_NEEDED - A query device call is
   *	required before erase is allowed
   * CY_AS_ERROR_NO_SUCH_BUS
   * CY_AS_ERROR_NO_SUCH_DEVICE
   * CY_AS_ERROR_NOT_SUPPORTED - Erase is currenly only supported
   *	on SD and using SD only firmware
   * CY_AS_ERROR_OUT_OF_MEMORY

   See Also
   * CyAsStorageSDRegisterRead
*/
EXTERN cy_as_return_status_t
cy_as_storage_erase(
	/* Handle to the device of interest */
	cy_as_device_handle	 handle,
	/* Bus on which device of interest is connected */
	cy_as_bus_number_t	bus,
	/* Device number of interest */
	uint32_t device,
	/* Erase Unit to start the erase */
	uint32_t erase_unit,
	/* Number of Erase Units to erase */
	uint16_t num_erase_units,
	/* Callback in case of async call */
	cy_as_function_callback cb,
	/* Client context to pass to the callback */
	uint32_t client
	);

/* Summary
   This function is used to read a Tuple from the SDIO CIS area.

   Description
   This function is used to read a Tuple from the SDIO CIS area.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device
   *	is in suspend mode
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * 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_ASYNC_PENDING - an async operation is pending
   * CY_AS_ERROR_INVALID_REQUEST - an invalid IO request
   *	type was made
   * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   *	reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to
   *	an invalid function
   * CY_AS_ERROR_INVALID_ENDPOINT - A DMA request was made to
   * an invalid endpoint
   * CY_AS_ERROR_ENDPOINT_DISABLED - A DMA request was made to
   *	a disabled endpoint

*/
cy_as_return_status_t
cy_as_sdio_get_c_i_s_info(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t		bus,
	/* Device number */
	uint32_t		device,
	 /* IO function Number */
	uint8_t			n_function_no,
	/* Id of tuple to be fetched */
	uint16_t		tuple_id,
	/* Buffer to hold tuple read from card.
	 should be at least 256 bytes in size */
	uint8_t *data_p
	);


/* Summary
   This function is used to read properties of the SDIO card.

   Description
   This function is used to read properties of the SDIO card
   into a CyAsSDIOCard structure.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   * loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   *	started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_SUCCESS - the card information was returned
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   * suspend mode
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware

*/
cy_as_return_status_t
cy_as_sdio_query_card(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	 bus,
	/* Device number */
	uint32_t		device,
	/* Buffer to store card properties */
	cy_as_sdio_card		*data_p
		);

/* Summary
   This function is used to reset a SDIO card.

   Description
   This function is used to reset a SDIO card by writing to
   the reset bit in the CCCR and reinitializing the card. This
   function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware
   */
cy_as_return_status_t
cy_as_sdio_reset_card(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t device
	);

/* Summary
   This function performs a Synchronous 1 byte read from the sdio
   device function.

   Description
   This function is used to perform a synchronous 1 byte read
   from an SDIO card function. This function is to be used only
   for IO to an SDIO card as other media will not respond to the
   SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed
   *	in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
   *	the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was recieved
   *	from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in reading
   *	from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to an
   *	invalid function
   * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which read
   *	was attempted is in suspend
*/
cy_as_return_status_t
cy_as_sdio_direct_read(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t		 bus,
	/* Device number */
	uint32_t		device,
	/* IO function Number */
	uint8_t			n_function_no,
	/* Address for IO */
	uint32_t		address,
	/* Set to CY_SDIO_REARM_INT to reinitialize SDIO interrupt */
	uint8_t			misc_buf,
	/* Buffer to hold byte read from card */
	uint8_t *data_p
		);

/* Summary
   This function performs a Synchronous 1 byte write to the
   sdio device function.

   Description
   This function is used to perform a synchronous 1 byte write
   to an SDIO card function.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   * not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   * loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   * started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   * passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   * suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   * with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was recieved
   * from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   * reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to
   * an invalid function
   * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
   * write was attempted is in suspend
*/
cy_as_return_status_t
cy_as_sdio_direct_write(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t		device,
	/* IO function Number */
	uint8_t			n_function_no,
	/* Address for IO */
	uint32_t		address,
	/* Set to CY_SDIO_REARM_INT to reinitialize SDIO interrupt,
	set to CY_SDIO_RAW for read after write */
	uint8_t			misc_buf,
	/* Byte to write */
	uint16_t		argument,
	/* Buffer to hold byte read from card in Read after write mode */
	uint8_t *data_p
	);

/* Summary
   This function is used to set the blocksize of an SDIO function.

   Description
   This function is used to set the blocksize of an SDIO function.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory
   *	available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   *	reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
   * to an invalid function
   * CY_AS_ERROR_INVALID_BLOCKSIZE - An incorrect blocksize
   * was passed to the function.
   * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
   * write was attempted is in suspend
*/
cy_as_return_status_t
cy_as_sdio_set_blocksize(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no,
	/* Block size to set. */
	uint16_t blocksize
	);

/* Summary
   This function is used to read Multibyte/Block data from a
   IO function.

   Description
   This function is used to read Multibyte/Block data from a
   IO function. This function is to be used only for IO to an
   SDIO card as other media will not respond to the SDIO
   command set.

   * Valid in Asynchronous Callback: YES
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating with
   *	the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_ASYNC_PENDING - an async operation is pending
   * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was recieved
   *	from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   *	reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made to
   *	an invalid function
   * CY_AS_ERROR_INVALID_BLOCKSIZE - An incorrect blocksize or
   *	block count was passed to the function.
   * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
   *	write was attempted is in suspend
   * CY_AS_ERROR_IO_ABORTED - The IO operation was aborted
   * CY_AS_ERROR_IO_SUSPENDED - The IO operation was suspended
   * CY_AS_ERROR_INVALID_REQUEST - An invalid request was
   *	passed to the card.

*/
cy_as_return_status_t
cy_as_sdio_extended_read(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no,
	/* Base Address for IO */
	uint32_t address,
	/* Set to CY_SDIO_BLOCKMODE for block IO,
	CY_SDIO_BYTEMODE for multibyte IO,
	CY_SDIO_OP_FIFO to read multiple bytes from the
	same address, CY_SDIO_OP_INCR to read bytes from
	the incrementing addresses */
	uint8_t			misc_buf,
	/* Block/Byte count to read */
	uint16_t		argument,
	/* Buffer to hold data read from card */
	uint8_t *data_p,
	/* Callback in case of Asyncronous call. 0 if Synchronous */
	cy_as_sdio_callback		callback
	);

/* Summary
   This function is used to write Multibyte/Block data
   to a IO function.

   Description
   This function is used to write Multibyte/Block data
   to a IO function. This function is to be used only
   for IO to an SDIO card as other media will not respond
   to the SDIO command set.

   * Valid in Asynchronous Callback: YES
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_ASYNC_PENDING - an async operation is pending
   * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   *	reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
   *	to an invalid function
   * CY_AS_ERROR_INVALID_BLOCKSIZE - An incorrect blocksize or
   *	block count was passed to the function.
   * CY_AS_ERROR_FUNCTION_SUSPENDED - The function to which
   *	write was attempted is in suspend
   * CY_AS_ERROR_IO_ABORTED - The IO operation was aborted
   * CY_AS_ERROR_IO_SUSPENDED - The IO operation was suspended
   * CY_AS_ERROR_INVALID_REQUEST - An invalid request was
   *	passed to the card.
*/
cy_as_return_status_t
cy_as_sdio_extended_write(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no,
	/* Base Address for IO */
	uint32_t address,
	/* Set to CY_SDIO_BLOCKMODE for block IO,
	CY_SDIO_BYTEMODE for multibyte IO,
	CY_SDIO_OP_FIFO to write multiple bytes to the same address,
	CY_SDIO_OP_INCR to write multiple bytes to incrementing
	addresses */
	uint8_t	 misc_buf,
	/* Block/Byte count to write
	in case of byte mode the count should not exceed the block size
	or 512, whichever is smaller.
	in case of block mode, maximum number of blocks is 511. */
	uint16_t		argument,
	/* Buffer to hold data to be written to card. */
	uint8_t *data_p,
	/* Callback in case of Asyncronous call. 0 if Synchronous */
	cy_as_sdio_callback		callback
	);

/* Summary
   This function is used to initialize a SDIO card function.

   Description
   This function is used to initialize a SDIO card function
   (1 - 7). This function is to be used only for IO to an
   SDIO card as other media will not respond to the SDIO
   command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   *	started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed
   *	in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error in
   *	reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
   *	to an invalid function
*/
cy_as_return_status_t
cy_as_sdio_init_function(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no,
	/* Set to CY_SDIO_FORCE_INIT to reinitialize function */
	uint8_t	misc_buf
	);

/* Summary
   This function is used to get properties of a SDIO card function.

   Description
   This function is used to get properties of a SDIO card functio
   (1 - 7) into a CyAsSDIOFunc structure. This function is to be
   used only for IO to an SDIO card as other media will not respond
   to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has not
   *	been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been loaded
   *	into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not been
   *	started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was passed
   *	in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * CY_AS_ERROR_NO_SUCH_BUS - the media specified does
   *	not exist
   * CY_AS_ERROR_NO_SUCH_DEVICE - the specified media/device pair
   *	does not exist
   * CY_AS_ERROR_INVALID_FUNCTION - An IO request was made to
   *	an invalid function
*/
cy_as_return_status_t
cy_as_sdio_query_function(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no,
	/* Buffer to store function properties */
	cy_as_sdio_func *data_p
	);

/* Summary
   This function is used to Abort the current IO function.

   Description
   This function is used to Abort the current IO function.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory
   *	available
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
   *	to an invalid function
*/
cy_as_return_status_t
cy_as_sdio_abort_function(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t  bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no
		);

/* Summary
   This function is used to Disable IO to an SDIO function.

   Description
   This function is used to Disable IO to an SDIO function.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is
   *	in suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_INVALID_FUNCTION - An IO attempt was made
   *	to an invalid function
*/
cy_as_return_status_t
cy_as_sdio_de_init_function(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no
	);

/* Summary
   This function is used to Suspend the current IO function.

   Description
   This function is used to Suspend the current IO function.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device has
   *	not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is in
   *	suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred communicating
   *	with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_OUT_OF_MEMORY - insufficient memory
   *	available
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was made
   *	to an invalid function
*/
cy_as_return_status_t
cy_as_sdio_suspend(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t  bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no
	);

/* Summary
   This function is used to resume a Suspended IO function.

   Description
   This function is used to resume a Suspended IO function.
   This function is to be used only for IO to an SDIO card as
   other media will not respond to the SDIO command set.

   * Valid in Asynchronous Callback: NO
   * Valid on Antioch device: NO

   Returns
   * CY_AS_ERROR_NOT_CONFIGURED - the West Bridge device
   *	has not been configured
   * CY_AS_ERROR_NO_FIRMWARE - the firmware has not been
   *	loaded into West Bridge
   * CY_AS_ERROR_NOT_RUNNING - the storage stack has not
   *	been started
   * CY_AS_ERROR_INVALID_HANDLE - an invalid handle was
   *	passed in
   * CY_AS_ERROR_IN_SUSPEND - the West Bridge device is
   *	in suspend mode
   * CY_AS_ERROR_SUCCESS - the media information was
   *	returned
   * CY_AS_ERROR_TIMEOUT - a timeout occurred
   *	communicating with the West Bridge device
   * CY_AS_ERROR_NOT_RUNNING - the stack is not running
   * 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_ASYNC_PENDING - an async operation
   *	is pending
   * CY_AS_ERROR_OUT_OF_MEMORY - insufficient memory
   *	available
   * CY_AS_ERROR_INVALID_RESPONSE - an error message was
   *	recieved from the firmware
   * CY_AS_ERROR_MEDIA_ACCESS_FAILURE - there was error
   *	in reading from the media
   * CY_AS_ERROR_INVALID_FUNCTION - An IO attempt was
   *	made to an invalid function
   * CY_AS_ERROR_IO_ABORTED - The IO operation was
   *	aborted
   * CY_AS_ERROR_IO_SUSPENDED - The IO operation was
   *	suspended
   * CY_AS_ERROR_INVALID_REQUEST - An invalid request was
   *	passed to the card.

*/
cy_as_return_status_t
cy_as_sdio_resume(
	/* Handle to the Westbridge device */
	cy_as_device_handle	handle,
	/* Bus to use */
	cy_as_bus_number_t	bus,
	/* Device number */
	uint32_t device,
	/* IO function Number */
	uint8_t	n_function_no,
	/* Operation to resume (Read or Write) */
	cy_as_oper_type	op,
	/* Micellaneous buffer same as for Extended read and Write */
	uint8_t	misc_buf,
	/* Number of pending blocks for IO. Should be less
	than or equal to the maximum defined for extended
	read and write */
	uint16_t pendingblockcount,
	 /* Buffer to continue the Suspended IO operation */
	uint8_t		 *data_p
	);



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

#include "cyas_cplus_end.h"

#endif				/* _INCLUDED_CYASSTORAGE_H_ */
OpenPOWER on IntegriCloud