| OLD | NEW |
| 1 //------------------------------------------------------------------------------ | 1 //------------------------------------------------------------------------------ |
| 2 // <copyright file="hif_scatter.c" company="Atheros"> | 2 // Copyright (c) 2009-2010 Atheros Corporation. All rights reserved. |
| 3 // Copyright (c) 2009 Atheros Corporation. All rights reserved. | |
| 4 // | 3 // |
| 5 // This program is free software; you can redistribute it and/or modify | |
| 6 // it under the terms of the GNU General Public License version 2 as | |
| 7 // published by the Free Software Foundation; | |
| 8 // | 4 // |
| 9 // Software distributed under the License is distributed on an "AS | 5 // Permission to use, copy, modify, and/or distribute this software for any |
| 10 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | 6 // purpose with or without fee is hereby granted, provided that the above |
| 11 // implied. See the License for the specific language governing | 7 // copyright notice and this permission notice appear in all copies. |
| 12 // rights and limitations under the License. | 8 // |
| 9 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 15 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 13 // | 16 // |
| 14 // | 17 // |
| 15 //------------------------------------------------------------------------------ | 18 //------------------------------------------------------------------------------ |
| 16 //============================================================================== | 19 //============================================================================== |
| 17 // HIF scatter implementation | 20 // HIF scatter implementation |
| 18 // | 21 // |
| 19 // Author(s): ="Atheros" | 22 // Author(s): ="Atheros" |
| 20 //============================================================================== | 23 //============================================================================== |
| 21 | 24 |
| 22 #include <linux/mmc/card.h> | 25 #include <linux/mmc/card.h> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 opcode = _CMD53_ARG_INCR_ADDRESS; | 123 opcode = _CMD53_ARG_INCR_ADDRESS; |
| 121 } | 124 } |
| 122 | 125 |
| 123 /* fill SG entries */ | 126 /* fill SG entries */ |
| 124 pSg = pReqPriv->sgentries; | 127 pSg = pReqPriv->sgentries; |
| 125 sg_init_table(pSg, pReq->ValidScatterEntries); | 128 sg_init_table(pSg, pReq->ValidScatterEntries); |
| 126 | 129 |
| 127 /* assemble SG list */ | 130 /* assemble SG list */ |
| 128 for (i = 0 ; i < pReq->ValidScatterEntries ; i++, pSg++) { | 131 for (i = 0 ; i < pReq->ValidScatterEntries ; i++, pSg++) { |
| 129 /* setup each sg entry */ | 132 /* setup each sg entry */ |
| 130 if ((A_UINT32)pReq->ScatterList[i].pBuffer & 0x3) { | 133 if ((unsigned long)pReq->ScatterList[i].pBuffer & 0x3) { |
| 131 /* note some scatter engines can handle unaligned buffers, print
this | 134 /* note some scatter engines can handle unaligned buffers, print
this |
| 132 * as informational only */ | 135 * as informational only */ |
| 133 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, | 136 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, |
| 134 ("HIF: (%s) Scatter Buffer is unaligned 0x%08x\n", | 137 ("HIF: (%s) Scatter Buffer is unaligned 0x%lx\n", |
| 135 pReq->Request & HIF_WRITE ? "WRITE":"READ", | 138 pReq->Request & HIF_WRITE ? "WRITE":"READ", |
| 136 (A_UINT32)pReq->ScatterList[i].pBuffer)); | 139 (unsigned long)pReq->ScatterList[i].pBuffer)); |
| 137 } | 140 } |
| 138 | 141 |
| 139 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, (" %d: Addr:0x%X, Len:%d \n", | 142 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, (" %d: Addr:0x%lX, Len:%d \n", |
| 140 i,(A_UINT32)pReq->ScatterList[i].pBuffer,pReq->ScatterList[i].Length
)); | 143 i,(unsigned long)pReq->ScatterList[i].pBuffer,pReq->ScatterList[i].L
ength)); |
| 141 | 144 |
| 142 sg_set_buf(pSg, pReq->ScatterList[i].pBuffer, pReq->ScatterList[i].Lengt
h); | 145 sg_set_buf(pSg, pReq->ScatterList[i].pBuffer, pReq->ScatterList[i].Lengt
h); |
| 143 } | 146 } |
| 144 /* set scatter-gather table for request */ | 147 /* set scatter-gather table for request */ |
| 145 data.sg = pReqPriv->sgentries; | 148 data.sg = pReqPriv->sgentries; |
| 146 data.sg_len = pReq->ValidScatterEntries; | 149 data.sg_len = pReq->ValidScatterEntries; |
| 147 /* set command argument */ | 150 /* set command argument */ |
| 148 SDIO_SET_CMD53_ARG(cmd.arg, | 151 SDIO_SET_CMD53_ARG(cmd.arg, |
| 149 rw, | 152 rw, |
| 150 device->func->num, | 153 device->func->num, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 175 | 178 |
| 176 if (A_FAILED(status)) { | 179 if (A_FAILED(status)) { |
| 177 AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("HIF-SCATTER: FAILED!!! (%s) Address:
0x%X, Block mode (BlockLen: %d, BlockCount: %d)\n", | 180 AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("HIF-SCATTER: FAILED!!! (%s) Address:
0x%X, Block mode (BlockLen: %d, BlockCount: %d)\n", |
| 178 (pReq->Request & HIF_WRITE) ? "WRITE":"READ",pReq->Address, data.b
lksz, data.blocks)); | 181 (pReq->Request & HIF_WRITE) ? "WRITE":"READ",pReq->Address, data.b
lksz, data.blocks)); |
| 179 } | 182 } |
| 180 | 183 |
| 181 /* set completion status, fail or success */ | 184 /* set completion status, fail or success */ |
| 182 pReq->CompletionStatus = status; | 185 pReq->CompletionStatus = status; |
| 183 | 186 |
| 184 if (pReq->Request & HIF_ASYNCHRONOUS) { | 187 if (pReq->Request & HIF_ASYNCHRONOUS) { |
| 185 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: async_task completion
routine req: 0x%X (%d)\n",(unsigned int)busrequest, status)); | 188 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: async_task completion
routine req: 0x%lX (%d)\n",(unsigned long)busrequest, status)); |
| 186 /* complete the request */ | 189 /* complete the request */ |
| 187 A_ASSERT(pReq->CompletionRoutine != NULL); | 190 A_ASSERT(pReq->CompletionRoutine != NULL); |
| 188 pReq->CompletionRoutine(pReq); | 191 pReq->CompletionRoutine(pReq); |
| 189 } else { | 192 } else { |
| 190 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER async_task upping busre
quest : 0x%X (%d)\n", (unsigned int)busrequest,status)); | 193 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER async_task upping busre
quest : 0x%lX (%d)\n", (unsigned long)busrequest,status)); |
| 191 /* signal wait */ | 194 /* signal wait */ |
| 192 up(&busrequest->sem_req); | 195 up(&busrequest->sem_req); |
| 193 } | 196 } |
| 194 | 197 |
| 195 return status; | 198 return status; |
| 196 } | 199 } |
| 197 | 200 |
| 198 /* callback to issue a read-write scatter request */ | 201 /* callback to issue a read-write scatter request */ |
| 199 static A_STATUS HifReadWriteScatter(HIF_DEVICE *device, HIF_SCATTER_REQ *pReq) | 202 static A_STATUS HifReadWriteScatter(HIF_DEVICE *device, HIF_SCATTER_REQ *pReq) |
| 200 { | 203 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 238 |
| 236 if (pReq->TotalLength == 0) { | 239 if (pReq->TotalLength == 0) { |
| 237 A_ASSERT(FALSE); | 240 A_ASSERT(FALSE); |
| 238 break; | 241 break; |
| 239 } | 242 } |
| 240 | 243 |
| 241 /* add bus request to the async list for the async I/O thread to pro
cess */ | 244 /* add bus request to the async list for the async I/O thread to pro
cess */ |
| 242 AddToAsyncList(device, pReqPriv->busrequest); | 245 AddToAsyncList(device, pReqPriv->busrequest); |
| 243 | 246 |
| 244 if (request & HIF_SYNCHRONOUS) { | 247 if (request & HIF_SYNCHRONOUS) { |
| 245 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: queued sync req: 0
x%X\n", (unsigned int)pReqPriv->busrequest)); | 248 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: queued sync req: 0
x%lX\n", (unsigned long)pReqPriv->busrequest)); |
| 246 /* signal thread and wait */ | 249 /* signal thread and wait */ |
| 247 up(&device->sem_async); | 250 up(&device->sem_async); |
| 248 if (down_interruptible(&pReqPriv->busrequest->sem_req) != 0) { | 251 if (down_interruptible(&pReqPriv->busrequest->sem_req) != 0) { |
| 249 AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,("HIF-SCATTER: interrupted! \n")
); | 252 AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,("HIF-SCATTER: interrupted! \n")
); |
| 250 /* interrupted, exit */ | 253 /* interrupted, exit */ |
| 251 status = A_ERROR; | 254 status = A_ERROR; |
| 252 break; | 255 break; |
| 253 } else { | 256 } else { |
| 254 status = pReq->CompletionStatus; | 257 status = pReq->CompletionStatus; |
| 255 } | 258 } |
| 256 } else { | 259 } else { |
| 257 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: queued async req:
0x%X\n", (unsigned int)pReqPriv->busrequest)); | 260 AR_DEBUG_PRINTF(ATH_DEBUG_SCATTER, ("HIF-SCATTER: queued async req:
0x%lX\n", (unsigned long)pReqPriv->busrequest)); |
| 258 /* wake thread, it will process and then take care of the async
callback */ | 261 /* wake thread, it will process and then take care of the async
callback */ |
| 259 up(&device->sem_async); | 262 up(&device->sem_async); |
| 260 status = A_OK; | 263 status = A_OK; |
| 261 } | 264 } |
| 262 | 265 |
| 263 } while (FALSE); | 266 } while (FALSE); |
| 264 | 267 |
| 265 if (A_FAILED(status) && (request & HIF_ASYNCHRONOUS)) { | 268 if (A_FAILED(status) && (request & HIF_ASYNCHRONOUS)) { |
| 266 pReq->CompletionStatus = status; | 269 pReq->CompletionStatus = status; |
| 267 pReq->CompletionRoutine(pReq); | 270 pReq->CompletionRoutine(pReq); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (pReqPriv->pHifScatterReq != NULL) { | 384 if (pReqPriv->pHifScatterReq != NULL) { |
| 382 A_FREE(pReqPriv->pHifScatterReq); | 385 A_FREE(pReqPriv->pHifScatterReq); |
| 383 pReqPriv->pHifScatterReq = NULL; | 386 pReqPriv->pHifScatterReq = NULL; |
| 384 } | 387 } |
| 385 | 388 |
| 386 A_FREE(pReqPriv); | 389 A_FREE(pReqPriv); |
| 387 } | 390 } |
| 388 } | 391 } |
| 389 | 392 |
| 390 #endif // HIF_LINUX_MMC_SCATTER_SUPPORT | 393 #endif // HIF_LINUX_MMC_SCATTER_SUPPORT |
| OLD | NEW |