|
1 /* |
|
2 * sdioadapter.cpp |
|
3 * |
|
4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved. |
|
5 * All rights reserved. |
|
6 * |
|
7 * This program and the accompanying materials are made available under the |
|
8 * terms of the Eclipse Public License v1.0 or BSD License which accompanies |
|
9 * this distribution. The Eclipse Public License is available at |
|
10 * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below. |
|
11 * |
|
12 * Redistribution and use in source and binary forms, with or without |
|
13 * modification, are permitted provided that the following conditions |
|
14 * are met: |
|
15 * |
|
16 * * Redistributions of source code must retain the above copyright |
|
17 * notice, this list of conditions and the following disclaimer. |
|
18 * * Redistributions in binary form must reproduce the above copyright |
|
19 * notice, this list of conditions and the following disclaimer in |
|
20 * the documentation and/or other materials provided with the |
|
21 * distribution. |
|
22 * * Neither the name Texas Instruments nor the names of its |
|
23 * contributors may be used to endorse or promote products derived |
|
24 * from this software without specific prior written permission. |
|
25 * |
|
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
37 */ |
|
38 |
|
39 |
|
40 /** \file SdioAdapter.c |
|
41 * \brief The SDIO driver adapter. Platform dependent. |
|
42 * |
|
43 * An adaptation layer between the lower SDIO driver (in BSP) and the upper SdioBusDrv. |
|
44 * Used for issuing all SDIO transaction types towards the lower SDIO-driver. |
|
45 * Makes the decision whether to use Sync or Async transaction, and reflects it to the caller |
|
46 * by the return value and calling its callback in case of Async. |
|
47 * |
|
48 * \see SdioAdapter.h, SdioDrv.c & h |
|
49 */ |
|
50 |
|
51 #include "TxnDefs.h" |
|
52 extern "C" |
|
53 { |
|
54 #include "SdioAdapter.h" |
|
55 } |
|
56 |
|
57 #include "SdioDrv.h" |
|
58 #include <stdio.h> |
|
59 #include "SDioClient.h" |
|
60 |
|
61 void* wsdioAdapt_Open(void* hOs) |
|
62 { |
|
63 return (void*)SDioClient::Create(); |
|
64 |
|
65 } |
|
66 |
|
67 void* wSdioAdapt_Close(void* hOs) |
|
68 { |
|
69 return KErrNone; |
|
70 } |
|
71 |
|
72 /** |
|
73 * \fn wsdioAdapt_ConnectBus |
|
74 * \brief |
|
75 * |
|
76 * Initialize HW. |
|
77 * |
|
78 * \note |
|
79 * \param |
|
80 * \return KErrNone if success otherwise error. |
|
81 * \sa |
|
82 */ |
|
83 int wsdioAdapt_ConnectBus(TAny* hSdio, |
|
84 TAny* fCbFunc, |
|
85 TAny* hCbArg, |
|
86 unsigned int uBlkSizeShift, |
|
87 unsigned int uSdioThreadPriority) |
|
88 { |
|
89 SDioClient* pSdioClient = reinterpret_cast<SDioClient*>(hSdio); |
|
90 |
|
91 pSdioClient->sdioAdapt_ConnectBus(fCbFunc, hCbArg, uBlkSizeShift, uSdioThreadPriority); |
|
92 return KErrNone; |
|
93 } |
|
94 |
|
95 /** |
|
96 * \fn wsdioAdapt_DisconnectBus |
|
97 * \brief |
|
98 * |
|
99 * DeInitialize HW. |
|
100 * |
|
101 * \note |
|
102 * \param |
|
103 * \return KErrNone if success otherwise error. |
|
104 * \sa |
|
105 */ |
|
106 int wsdioAdapt_DisconnectBus (TAny* hSdio) |
|
107 { |
|
108 SDioClient* pSdioClient = reinterpret_cast<SDioClient*>(hSdio); |
|
109 pSdioClient->sdioAdapt_DisconnectBus(); |
|
110 return KErrNone; |
|
111 } |
|
112 |
|
113 /** |
|
114 * \fn wsdioAdapt_Transact |
|
115 * \brief |
|
116 * |
|
117 * Transaction of multiple bytes. |
|
118 * |
|
119 * \note |
|
120 * \param |
|
121 * \return TXN_STATUS_OK if success, |
|
122 * TXN_STATUS_ERROR if error. |
|
123 * \sa |
|
124 */ |
|
125 ETxnStatus wsdioAdapt_Transact (TAny* hSdio, |
|
126 unsigned int uFuncId, |
|
127 unsigned int uHwAddr, |
|
128 void * pHostAddr, |
|
129 unsigned int uLength, |
|
130 unsigned int bDirection, |
|
131 unsigned int bBlkMode, |
|
132 unsigned int bFixedAddr, |
|
133 unsigned int bMore) |
|
134 { |
|
135 ETxnStatus iStatus = TXN_STATUS_OK; |
|
136 SDioClient* pSdioClient = reinterpret_cast<SDioClient*>(hSdio); |
|
137 iStatus = pSdioClient->sdioAdapt_Transact(uFuncId, uHwAddr, pHostAddr, uLength, bDirection, bBlkMode, bFixedAddr, bMore ); |
|
138 |
|
139 if(iStatus == TXN_STATUS_ERROR) |
|
140 return TXN_STATUS_ERROR; |
|
141 else |
|
142 return iStatus; |
|
143 } |
|
144 |
|
145 /** |
|
146 * \fn wsdioAdapt_TransactBytes |
|
147 * \brief |
|
148 * |
|
149 * Transaction of bytes. |
|
150 * |
|
151 * \note |
|
152 * \param |
|
153 * \return TXN_STATUS_OK if success, |
|
154 * TXN_STATUS_ERROR if error. |
|
155 * \sa |
|
156 */ |
|
157 ETxnStatus wsdioAdapt_TransactBytes (TAny* hSdio, |
|
158 unsigned int uFuncId, |
|
159 unsigned int uHwAddr, |
|
160 void * pHostAddr, |
|
161 unsigned int uLength, |
|
162 unsigned int bDirection, |
|
163 unsigned int bMore) |
|
164 { |
|
165 int iStatus = TXN_STATUS_OK; |
|
166 |
|
167 SDioClient* pSdioClient = reinterpret_cast<SDioClient*>(hSdio); |
|
168 iStatus = pSdioClient->sdioAdapt_TransactBytes(uFuncId, uHwAddr, pHostAddr, uLength, bDirection, bMore); |
|
169 |
|
170 if(iStatus == TXN_STATUS_ERROR) |
|
171 return TXN_STATUS_ERROR; |
|
172 else |
|
173 return TXN_STATUS_OK; |
|
174 } |