Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chromeos/drivers/ath6kl/htc2/AR6000/ar6k_gmbox_hciuart.c

Issue 3579004: ath6kl: Bringing in the upstream version (Closed) Base URL: http://git.chromium.org/git/kernel.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 //------------------------------------------------------------------------------ 1 //------------------------------------------------------------------------------
2 // <copyright file="ar6k_prot_hciUart.c" company="Atheros"> 2 // <copyright file="ar6k_prot_hciUart.c" company="Atheros">
3 // Copyright (c) 2007-2008 Atheros Corporation. All rights reserved. 3 // Copyright (c) 2007-2010 Atheros Corporation. All rights reserved.
4 // 4 //
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 // 5 //
9 // Software distributed under the License is distributed on an "AS 6 // Permission to use, copy, modify, and/or distribute this software for any
10 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or 7 // purpose with or without fee is hereby granted, provided that the above
11 // implied. See the License for the specific language governing 8 // copyright notice and this permission notice appear in all copies.
12 // rights and limitations under the License. 9 //
10 // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
13 // 17 //
14 // 18 //
15 //------------------------------------------------------------------------------ 19 //------------------------------------------------------------------------------
16 //============================================================================== 20 //==============================================================================
17 // Protocol module for use in bridging HCI-UART packets over the GMBOX interface 21 // Protocol module for use in bridging HCI-UART packets over the GMBOX interface
18 // 22 //
19 // Author(s): ="Atheros" 23 // Author(s): ="Atheros"
20 //============================================================================== 24 //==============================================================================
21 #include "a_config.h" 25 #include "a_config.h"
22 #include "athdefs.h" 26 #include "athdefs.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 int CreditsCurrentSeek; 76 int CreditsCurrentSeek;
73 int SendProcessCount; 77 int SendProcessCount;
74 } GMBOX_PROTO_HCI_UART; 78 } GMBOX_PROTO_HCI_UART;
75 79
76 #define LOCK_HCI_RX(t) A_MUTEX_LOCK(&(t)->HCIRxLock); 80 #define LOCK_HCI_RX(t) A_MUTEX_LOCK(&(t)->HCIRxLock);
77 #define UNLOCK_HCI_RX(t) A_MUTEX_UNLOCK(&(t)->HCIRxLock); 81 #define UNLOCK_HCI_RX(t) A_MUTEX_UNLOCK(&(t)->HCIRxLock);
78 #define LOCK_HCI_TX(t) A_MUTEX_LOCK(&(t)->HCITxLock); 82 #define LOCK_HCI_TX(t) A_MUTEX_LOCK(&(t)->HCITxLock);
79 #define UNLOCK_HCI_TX(t) A_MUTEX_UNLOCK(&(t)->HCITxLock); 83 #define UNLOCK_HCI_TX(t) A_MUTEX_UNLOCK(&(t)->HCITxLock);
80 84
81 #define DO_HCI_RECV_INDICATION(p,pt) \ 85 #define DO_HCI_RECV_INDICATION(p,pt) \
82 { AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI: Indicate Recv on packet:0x%X status:%d len:%d type:%d \n", \ 86 { AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("HCI: Indicate Recv on packet:0x%lX status:% d len:%d type:%d \n", \
83 (A_UINT32)(pt),(pt)->Status, A_SUCCESS((pt)->Status) ? (pt)->ActualLength : 0, HCI_GET_PACKET_TYPE(pt))); \ 87 (unsigned long)(pt),(pt)->Status, A_SUCCESS((pt)->Status) ? (pt)->ActualLe ngth : 0, HCI_GET_PACKET_TYPE(pt))); \
84 (p)->HCIConfig.pHCIPktRecv((p)->HCIConfig.pContext, (pt)); \ 88 (p)->HCIConfig.pHCIPktRecv((p)->HCIConfig.pContext, (pt)); \
85 } 89 }
86 90
87 #define DO_HCI_SEND_INDICATION(p,pt) \ 91 #define DO_HCI_SEND_INDICATION(p,pt) \
88 { AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Indicate Send on packet:0x%X status:%d type:%d \n", \ 92 { AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Indicate Send on packet:0x%lX status:% d type:%d \n", \
89 (A_UINT32)(pt),(pt)->Status,HCI_GET_PACKET_TYPE(pt))); \ 93 (unsigned long)(pt),(pt)->Status,HCI_GET_PACKET_TYPE(pt))); \
90 (p)->HCIConfig.pHCISendComplete((p)->HCIConfig.pContext, (pt)); \ 94 (p)->HCIConfig.pHCISendComplete((p)->HCIConfig.pContext, (pt)); \
91 } 95 }
92 96
93 static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B OOL Synchronous); 97 static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B OOL Synchronous);
94 98
95 static void HCIUartCleanup(GMBOX_PROTO_HCI_UART *pProtocol) 99 static void HCIUartCleanup(GMBOX_PROTO_HCI_UART *pProtocol)
96 { 100 {
97 A_ASSERT(pProtocol != NULL); 101 A_ASSERT(pProtocol != NULL);
98 102
99 A_MUTEX_DELETE(&pProtocol->HCIRxLock); 103 A_MUTEX_DELETE(&pProtocol->HCIRxLock);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 523
520 524
521 AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HCIUartMessagePending \n")); 525 AR_DEBUG_PRINTF(ATH_DEBUG_RECV,("-HCIUartMessagePending \n"));
522 526
523 return status; 527 return status;
524 } 528 }
525 529
526 static void HCISendPacketCompletion(void *Context, HTC_PACKET *pPacket) 530 static void HCISendPacketCompletion(void *Context, HTC_PACKET *pPacket)
527 { 531 {
528 GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)Context; 532 GMBOX_PROTO_HCI_UART *pProt = (GMBOX_PROTO_HCI_UART *)Context;
529 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion (pPacket:0x%X) \n" ,(A_UINT32)pPacket)); 533 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion (pPacket:0x%lX) \n ",(unsigned long)pPacket));
530 534
531 if (A_FAILED(pPacket->Status)) { 535 if (A_FAILED(pPacket->Status)) {
532 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Send Packet (0x%X) failed: %d , len:%d \n", 536 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" Send Packet (0x%lX) failed: %d , len:%d \n",
533 (A_UINT32)pPacket, pPacket->Status, pPacket->ActualLength)); 537 (unsigned long)pPacket, pPacket->Status, pPacket->ActualLength));
534 } 538 }
535 539
536 DO_HCI_SEND_INDICATION(pProt,pPacket); 540 DO_HCI_SEND_INDICATION(pProt,pPacket);
537 541
538 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion \n")); 542 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCISendPacketCompletion \n"));
539 } 543 }
540 544
541 static A_STATUS SeekCreditsSynch(GMBOX_PROTO_HCI_UART *pProt) 545 static A_STATUS SeekCreditsSynch(GMBOX_PROTO_HCI_UART *pProt)
542 { 546 {
543 A_STATUS status = A_OK; 547 A_STATUS status = A_OK;
(...skipping 27 matching lines...) Expand all
571 } 575 }
572 576
573 static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B OOL Synchronous) 577 static A_STATUS HCITrySend(GMBOX_PROTO_HCI_UART *pProt, HTC_PACKET *pPacket, A_B OOL Synchronous)
574 { 578 {
575 A_STATUS status = A_OK; 579 A_STATUS status = A_OK;
576 int transferLength; 580 int transferLength;
577 int creditsRequired, remainder; 581 int creditsRequired, remainder;
578 A_UINT8 hciUartType; 582 A_UINT8 hciUartType;
579 A_BOOL synchSendComplete = FALSE; 583 A_BOOL synchSendComplete = FALSE;
580 584
581 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCITrySend (pPacket:0x%X) %s \n",(A_UINT32 )pPacket, 585 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("+HCITrySend (pPacket:0x%lX) %s \n",(unsigne d long)pPacket,
582 Synchronous ? "SYNC" :"ASYNC")); 586 Synchronous ? "SYNC" :"ASYNC"));
583 587
584 LOCK_HCI_TX(pProt); 588 LOCK_HCI_TX(pProt);
585 589
586 /* increment write processing count on entry */ 590 /* increment write processing count on entry */
587 pProt->SendProcessCount++; 591 pProt->SendProcessCount++;
588 592
589 do { 593 do {
590 594
591 if (pProt->HCIStopped) { 595 if (pProt->HCIStopped) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 default: 668 default:
665 status = A_EINVAL; 669 status = A_EINVAL;
666 A_ASSERT(FALSE); 670 A_ASSERT(FALSE);
667 break; 671 break;
668 } 672 }
669 673
670 if (A_FAILED(status)) { 674 if (A_FAILED(status)) {
671 break; 675 break;
672 } 676 }
673 677
674 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Got head packet:0x%X , Type:%d Length: %d Remaining Queue Depth: %d\n", 678 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: Got head packet:0x%lX , Type:% d Length: %d Remaining Queue Depth: %d\n",
675 (A_UINT32)pPacket, HCI_GET_PACKET_TYPE(pPacket), pPacket->Actual Length, 679 (unsigned long)pPacket, HCI_GET_PACKET_TYPE(pPacket), pPacket->A ctualLength,
676 HTC_PACKET_QUEUE_DEPTH(&pProt->SendQueue))); 680 HTC_PACKET_QUEUE_DEPTH(&pProt->SendQueue)));
677 681
678 transferLength = 1; /* UART type header is 1 byte */ 682 transferLength = 1; /* UART type header is 1 byte */
679 transferLength += pPacket->ActualLength; 683 transferLength += pPacket->ActualLength;
680 transferLength = DEV_CALC_SEND_PADDED_LEN(pProt->pDev, transferLengt h); 684 transferLength = DEV_CALC_SEND_PADDED_LEN(pProt->pDev, transferLengt h);
681 685
682 /* figure out how many credits this message requires */ 686 /* figure out how many credits this message requires */
683 creditsRequired = transferLength / pProt->CreditSize; 687 creditsRequired = transferLength / pProt->CreditSize;
684 remainder = transferLength % pProt->CreditSize; 688 remainder = transferLength % pProt->CreditSize;
685 689
(...skipping 16 matching lines...) Expand all
702 } 706 }
703 /* fall through and continue processing this send op */ 707 /* fall through and continue processing this send op */
704 } else { 708 } else {
705 /* not enough credits, queue back to the head */ 709 /* not enough credits, queue back to the head */
706 HTC_PACKET_ENQUEUE_TO_HEAD(&pProt->SendQueue,pPacket); 710 HTC_PACKET_ENQUEUE_TO_HEAD(&pProt->SendQueue,pPacket);
707 /* waiting for credits */ 711 /* waiting for credits */
708 pProt->SendStateFlags |= HCI_SEND_WAIT_CREDITS; 712 pProt->SendStateFlags |= HCI_SEND_WAIT_CREDITS;
709 /* provide a hint to reduce attempts to re-send if credi ts are dribbling back 713 /* provide a hint to reduce attempts to re-send if credi ts are dribbling back
710 * this hint is the short fall of credits */ 714 * this hint is the short fall of credits */
711 pProt->CreditsCurrentSeek = creditsRequired; 715 pProt->CreditsCurrentSeek = creditsRequired;
712 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: packet:0x%X placed bac k in queue. head packet needs: %d credits \n", 716 AR_DEBUG_PRINTF(ATH_DEBUG_SEND,("HCI: packet:0x%lX placed ba ck in queue. head packet needs: %d credits \n",
713 (A_UINT32)pPacket, pProt->CreditsCurrent Seek)); 717 (unsigned long)pPacket, pProt->CreditsCu rrentSeek));
714 pPacket = NULL; 718 pPacket = NULL;
715 UNLOCK_HCI_TX(pProt); 719 UNLOCK_HCI_TX(pProt);
716 720
717 /* schedule a credit counter read, our CreditsAvailableC allback callback will be called 721 /* schedule a credit counter read, our CreditsAvailableC allback callback will be called
718 * with the result */ 722 * with the result */
719 DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_ASYNC, NULL); 723 DevGMboxReadCreditCounter(pProt->pDev, PROC_IO_ASYNC, NULL);
720 724
721 LOCK_HCI_TX(pProt); 725 LOCK_HCI_TX(pProt);
722 break; 726 break;
723 } 727 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
961 965
962 } while (FALSE); 966 } while (FALSE);
963 967
964 UNLOCK_AR6K(pDev); 968 UNLOCK_AR6K(pDev);
965 969
966 if (pProtocol != NULL) { 970 if (pProtocol != NULL) {
967 /* TODO ... should we use a worker? */ 971 /* TODO ... should we use a worker? */
968 NotifyTransportReady(pProtocol); 972 NotifyTransportReady(pProtocol);
969 } 973 }
970 974
971 AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportAttach (0x%X) \n",(A_UINT32)pP rotocol)); 975 AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("-HCI_TransportAttach (0x%lX) \n",(unsigned l ong)pProtocol));
972 return (HCI_TRANSPORT_HANDLE)pProtocol; 976 return (HCI_TRANSPORT_HANDLE)pProtocol;
973 } 977 }
974 978
975 void HCI_TransportDetach(HCI_TRANSPORT_HANDLE HciTrans) 979 void HCI_TransportDetach(HCI_TRANSPORT_HANDLE HciTrans)
976 { 980 {
977 GMBOX_PROTO_HCI_UART *pProtocol = (GMBOX_PROTO_HCI_UART *)HciTrans; 981 GMBOX_PROTO_HCI_UART *pProtocol = (GMBOX_PROTO_HCI_UART *)HciTrans;
978 AR6K_DEVICE *pDev = pProtocol->pDev; 982 AR6K_DEVICE *pDev = pProtocol->pDev;
979 983
980 AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportDetach \n")); 984 AR_DEBUG_PRINTF(ATH_DEBUG_TRC,("+HCI_TransportDetach \n"));
981 985
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to enable/disable HCI power manag ement!\n")); 1271 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Failed to enable/disable HCI power manag ement!\n"));
1268 } else { 1272 } else {
1269 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI power management enabled/disabled!\n ")); 1273 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("HCI power management enabled/disabled!\n "));
1270 } 1274 }
1271 1275
1272 return status; 1276 return status;
1273 } 1277 }
1274 1278
1275 #endif //ATH_AR6K_ENABLE_GMBOX 1279 #endif //ATH_AR6K_ENABLE_GMBOX
1276 1280
OLDNEW
« no previous file with comments | « chromeos/drivers/ath6kl/htc2/AR6000/ar6k_gmbox.c ('k') | chromeos/drivers/ath6kl/htc2/AR6000/makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698