www.pudn.com > sdio-2.6.18-full.rar > sdio_bt.h
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@file: sdio_bt.h
@abstract: OS independent include Bluetooth function driver
#notes:
@notice: Copyright (c), 2005-2006 Atheros Communications, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* Portions o this code were developed with information supplied from the
* SD Card Association Simplified Specifications. The following conditions and disclaimers may apply:
*
* The following conditions apply to the release of the SD simplified specification (“Simplified
* Specification”) by the SD Card Association. The Simplified Specification is a subset of the complete
* SD Specification which is owned by the SD Card Association. This Simplified Specification is provided
* on a non-confidential basis subject to the disclaimers below. Any implementation of the Simplified
* Specification may require a license from the SD Card Association or other third parties.
* Disclaimers:
* The information contained in the Simplified Specification is presented only as a standard
* specification for SD Cards and SD Host/Ancillary products and is provided "AS-IS" without any
* representations or warranties of any kind. No responsibility is assumed by the SD Card Association for
* any damages, any infringements of patents or other right of the SD Card Association or any third
* parties, which may result from its use. No license is granted by implication, estoppel or otherwise
* under any patent or other rights of the SD Card Association or any third party. Nothing herein shall
* be construed as an obligation by the SD Card Association to disclose or distribute any technical
* information, know-how or other confidential information to any third party.
*
*
* The initial developers of the original code are Seung Yi and Paul Lever
*
* sdio@atheros.com
*
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
#ifndef __SDIO_BT_H___
#define __SDIO_BT_H___
#include "sdio_bt_linux.h"
#define SDBT_DBG_TRANSMIT (SDDBG_TRACE + 1)
#define SDBT_DBG_RECEIVE (SDDBG_TRACE + 2)
#define FLAGS_RTC_SUPPORTED 0x01 /* re-try control protocol supported */
#define FLAGS_BYTE_BASIS 0x02 /* byte basis transfer of packets */
#define FLAGS_READ_ACK 0x04 /* requires read acknowledgements */
#define FLAGS_CARD_ENAB 0x08
#define FLAGS_CARD_IRQ_UNMSK 0x10
#define SDBT_ENABLE_DISABLE_TIMEOUT 2000
#define SDBT_PKT_RETRIES 3
typedef enum _BTHCI_TX_STATES {
TX_BLOCK_PROCESSING = 0,
TX_PACKET_RETRY = 1
}BTHCI_TX_STATES, *PBTHCI_TX_STATES;
typedef struct _BT_HCI_INSTANCE {
SDLIST SDList; /* hcd list entry */
PSDDEVICE pDevice; /* bus driver's device we are supporting */
UINT8 FuncNo; /* function number we are on */
SDBT_CONFIG Config; /* devices local data */
UINT8 Flags; /* operational flags */
UINT16 MaxBlockSize; /* max block size for transfers */
UINT16 MaxBlocks; /* max blocks for transfers (multi-block) */
PSDBT_HCI_PACKET pCurrentTxPacket;
PUINT8 pTxBufferPosition;
UINT32 TxRemaining;
UINT32 RxRemaining;
UINT32 TxBytesToTransfer;
UINT8 TxRetry;
BTHCI_TX_STATES TxState;
UINT8 RxRetry;
BOOL BlockTransferFix;
}BT_HCI_INSTANCE, *PBT_HCI_INSTANCE;
typedef struct _BT_FUNCTION_CONTEXT {
SDFUNCTION Function; /* function description for bus driver */
OS_SEMAPHORE InstanceSem; /* instance lock */
SDLIST InstanceList; /* list of instances */
}BT_FUNCTION_CONTEXT, *PBT_FUNCTION_CONTEXT;
#define SDIO_BT_TYPE_A_HCI_CMD 0x01
#define SDIO_BT_TYPE_A_HCI_ACL 0x02
#define SDIO_BT_TYPE_A_HCI_SCO 0x03
#define SDIO_BT_TYPE_A_HCI_EVT 0x04
#define MAX_RX_RETRY 3
#define SDIO_BT_TRANSPORT_HEADER_LENGTH 4
#define SDIO_BT_SET_HEADER(pBuf,ServiceID,Length) \
{ \
(pBuf)[0] = (UINT8)(Length); \
(pBuf)[1] = (UINT8)((Length) >> 8); \
(pBuf)[2] = (UINT8)((Length) >> 16); \
(pBuf)[3] = (UINT8)(ServiceID); \
}
#define SDIO_BT_GET_LENGTH(pHdr) \
((UINT32)((pHdr)[0]) | ((UINT32)((pHdr)[1]) << 8) | ((UINT32)((pHdr)[2]) << 16))
#define SDIO_BT_GET_SERVICEID(pHdr) (pHdr)[3]
/* register offsets */
#define RECV_DATA_REG 0x00
#define XMIT_DATA_REG 0x00
#define RECV_PACKET_CONTROL_REG 0x10
#define XMIT_PACKET_CONTROL_REG 0x11
#define RETRY_CONTROL_STATUS_REG 0x12
#define INTERRUPT_STATUS_CLEAR_REG 0x13
#define INTERRUPT_ENABLE_REG 0x14
#define MODE_STATUS_REG 0x20
/* bit masks */
#define RCV_PKT_PENDING (1 << 0)
#define RETRY_STATUS_BIT_MASK (1 << 0)
#define RCV_PKT_PENDING_ENABLE (1 << 0)
#define RCV_PKT_CONTROL_RETRY (1 << 0)
#define XMIT_PKT_CONTROL_RETRY (1 << 0)
#define MODE_STATUS_TYPE_A 0x00
#define RECV_PACKET_CONTROL_ACK 0x00
#define RETRY_CONTROL_STATUS_USE_ACKS 0x00
struct PKT_RETRY_CONTROL_TUPLE {
UINT8 SDIO_Interface; /* interface code */
UINT8 Class; /* standard function class */
#define RTC_READ_ACK_REQUIRED 0x00
#define RTC_READ_ACK_NOT_REQUIRED 0x01
UINT8 SDIO_RetryControl; /* retry control */
}CT_PACK_STRUCT;
#define ReadRegister(pHci,reg,pData) \
SDLIB_IssueCMD52((pHci)->pDevice,(pHci)->FuncNo,\
(reg),(pData),1,CMD52_DO_READ)
static INLINE SDIO_STATUS WriteRegister(PBT_HCI_INSTANCE pHci, UINT reg, UINT8 Data)
{
return SDLIB_IssueCMD52((pHci)->pDevice,(pHci)->FuncNo,
(reg),&Data,1,CMD52_DO_WRITE);
}
PBT_HCI_INSTANCE CreateHciInstance(PBT_FUNCTION_CONTEXT pFuncContext,
PSDDEVICE pDevice);
void DeleteHciInstance(PBT_FUNCTION_CONTEXT pFuncContext,
PBT_HCI_INSTANCE pHci);
SDIO_STATUS AddHciInstance(PBT_FUNCTION_CONTEXT pFuncContext,
PBT_HCI_INSTANCE pHci);
PBT_HCI_INSTANCE FindHciInstance(PBT_FUNCTION_CONTEXT pFuncContext,
PSDDEVICE pDevice);
SDIO_STATUS SendHciPacket(PBT_HCI_INSTANCE pHci);
PSDBT_HCI_PACKET OSAllocHCIRcvPacket(PBT_HCI_INSTANCE pHci,
UINT32 HCIPacketLength,
UINT8 Type);
void OSFreeHciRcvPacket(PBT_HCI_INSTANCE pHci, PSDBT_HCI_PACKET pPkt);
SDIO_STATUS OSIndicateHCIPacketReceived(PBT_HCI_INSTANCE pHci,
PSDBT_HCI_PACKET pPacket,
UINT32 HCIPacketLength,
UINT8 ServiceID);
void OSIndicateHCIPacketTransmitDone(PBT_HCI_INSTANCE pHci,
SDIO_STATUS status);
void OSFreeSDRequest(PBT_HCI_INSTANCE pHci, PSDREQUEST pReq);
PSDREQUEST OSAllocSDRequest(PBT_HCI_INSTANCE pHci);
#endif /* __SDIO_BT_H___*/