00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef SDIOEMB_SDIO_BT_A_H
00010 #define SDIOEMB_SDIO_BT_A_H
00011
00012 #include <sdioemb/sdio_csr.h>
00013 #include <csr_sdio.h>
00014
00015
00016
00017
00018 #define SDIO_BT_A_RD 0x00
00019 #define SDIO_BT_A_TD 0x00
00020
00021 #define SDIO_BT_A_RX_PKT_CTRL 0x10
00022 # define PC_RRT 0x01
00023
00024 #define SDIO_BT_A_TX_PKT_CTRL 0x11
00025 # define PC_WRT 0x01
00026
00027 #define SDIO_BT_A_RETRY_CTRL 0x12
00028 # define RTC_STAT 0x01
00029 # define RTC_SET 0x01
00030
00031 #define SDIO_BT_A_INTRD 0x13
00032 # define INTRD 0x01
00033 # define CL_INTRD 0x01
00034
00035 #define SDIO_BT_A_INT_EN 0x14
00036 # define EN_INTRD 0x01
00037
00038 #define SDIO_BT_A_BT_MODE 0x20
00039 # define MD_STAT 0x01
00040
00041
00042
00043
00044
00045
00046 #define SDIO_BT_A_HEADER_LEN 4
00047
00048
00049
00050
00051
00052
00053
00054 #define SDIO_BT_A_PACKET_LEN_MAX 65543
00055
00056 enum sdioemb_bt_a_service_id {
00057 SDIO_BT_A_SID_CMD = 0x01,
00058 SDIO_BT_A_SID_ACL = 0x02,
00059 SDIO_BT_A_SID_SCO = 0x03,
00060 SDIO_BT_A_SID_EVT = 0x04,
00061 SDIO_BT_A_SID_VENDOR = 0xfe,
00062 };
00063
00064 static __inline int sdioemb_bt_a_packet_len(const char *p)
00065 {
00066 return (p[0] & 0xff) | ((p[1] & 0xff) << 8) | ((p[2] & 0xff) << 16);
00067 }
00068
00069 static __inline int sdioemb_bt_a_service_id(const char *p)
00070 {
00071 return p[3];
00072 }
00073
00074
00075
00076
00077
00078
00079 #define SDIO_BT_A_MIN_READ 32
00080
00081 #define SDIO_BT_A_NAME_LEN 16
00082
00083 struct sdioemb_bt_a_dev {
00084 CsrSdioFunction *func;
00085 char name[SDIO_BT_A_NAME_LEN];
00086 void *drv_data;
00087
00109 int (*get_rx_buffer)(struct sdioemb_bt_a_dev *bt, const uint8_t *header,
00110 size_t buffer_min_len, uint8_t **buffer, void **buffer_handle);
00111 void (*receive)(struct sdioemb_bt_a_dev *bt, void *buffer_handle, int status);
00112 void (*sleep_state_changed)(struct sdioemb_bt_a_dev *bt);
00113
00114 enum sdio_sleep_state sleep_state;
00115
00116 uint8_t max_tx_retries;
00117 uint8_t max_rx_retries;
00118 unsigned needs_read_ack:1;
00119 unsigned wait_for_firmware:1;
00120
00121 unsigned rx_off:1;
00122
00129 uint8_t *header;
00130 };
00131
00132 int sdioemb_bt_a_setup(struct sdioemb_bt_a_dev *bt, CsrSdioFunction *func);
00133 void sdioemb_bt_a_cleanup(struct sdioemb_bt_a_dev *bt);
00134 int sdioemb_bt_a_send(struct sdioemb_bt_a_dev *bt, const uint8_t *packet, size_t len);
00135 void sdioemb_bt_a_handle_interrupt(struct sdioemb_bt_a_dev *bt);
00136 void sdioemb_bt_a_set_sleep_state(struct sdioemb_bt_a_dev *bt, enum sdio_sleep_state state);
00137 int sdioemb_bt_a_check_for_reset(struct sdioemb_bt_a_dev *bt);
00138 void sdioemb_bt_a_start(struct sdioemb_bt_a_dev *bt);
00139 void sdioemb_bt_a_stop(struct sdioemb_bt_a_dev *bt);
00140 void sdioemb_bt_a_rx_on(struct sdioemb_bt_a_dev *bt);
00141 void sdioemb_bt_a_rx_off(struct sdioemb_bt_a_dev *bt);
00142
00143 #endif