Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2010-2011 Atheros Communications Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef HTC_USB_H
0018 #define HTC_USB_H
0019 
0020 /* old firmware images */
0021 #define FIRMWARE_AR7010_1_1     "htc_7010.fw"
0022 #define FIRMWARE_AR9271         "htc_9271.fw"
0023 
0024 /* supported Major FW version */
0025 #define MAJOR_VERSION_REQ 1
0026 #define MINOR_VERSION_REQ 3
0027 /* minimal and maximal supported Minor FW version. */
0028 #define FIRMWARE_MINOR_IDX_MAX  4
0029 #define FIRMWARE_MINOR_IDX_MIN  3
0030 #define HTC_FW_PATH "ath9k_htc"
0031 
0032 #define HTC_9271_MODULE_FW  HTC_FW_PATH "/htc_9271-" \
0033             __stringify(MAJOR_VERSION_REQ) \
0034             "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
0035 #define HTC_7010_MODULE_FW  HTC_FW_PATH "/htc_7010-" \
0036             __stringify(MAJOR_VERSION_REQ) \
0037             "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
0038 
0039 extern int htc_use_dev_fw;
0040 
0041 #define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
0042 
0043 #define AR9271_FIRMWARE       0x501000
0044 #define AR9271_FIRMWARE_TEXT  0x903000
0045 #define AR7010_FIRMWARE_TEXT  0x906000
0046 
0047 #define FIRMWARE_DOWNLOAD       0x30
0048 #define FIRMWARE_DOWNLOAD_COMP  0x31
0049 
0050 #define ATH_USB_RX_STREAM_MODE_TAG 0x4e00
0051 #define ATH_USB_TX_STREAM_MODE_TAG 0x697e
0052 
0053 /* FIXME: Verify these numbers (with Windows) */
0054 #define MAX_TX_URB_NUM  8
0055 #define MAX_TX_BUF_NUM  256
0056 #define MAX_TX_BUF_SIZE 32768
0057 #define MAX_TX_AGGR_NUM 20
0058 
0059 #define MAX_RX_URB_NUM  8
0060 #define MAX_RX_BUF_SIZE 16384
0061 #define MAX_PKT_NUM_IN_TRANSFER 10
0062 
0063 #define MAX_REG_OUT_URB_NUM  1
0064 #define MAX_REG_IN_URB_NUM   64
0065 
0066 #define MAX_REG_IN_BUF_SIZE 64
0067 
0068 /* USB Endpoint definition */
0069 #define USB_WLAN_TX_PIPE  1
0070 #define USB_WLAN_RX_PIPE  2
0071 #define USB_REG_IN_PIPE   3
0072 #define USB_REG_OUT_PIPE  4
0073 
0074 #define USB_MSG_TIMEOUT 1000 /* (ms) */
0075 
0076 #define HIF_USB_MAX_RXPIPES 2
0077 #define HIF_USB_MAX_TXPIPES 4
0078 
0079 struct tx_buf {
0080     u8 *buf;
0081     u16 len;
0082     u16 offset;
0083     struct urb *urb;
0084     struct sk_buff_head skb_queue;
0085     struct hif_device_usb *hif_dev;
0086     struct list_head list;
0087 };
0088 
0089 struct rx_buf {
0090     struct sk_buff *skb;
0091     struct hif_device_usb *hif_dev;
0092 };
0093 
0094 #define HIF_USB_TX_STOP  BIT(0)
0095 #define HIF_USB_TX_FLUSH BIT(1)
0096 
0097 struct hif_usb_tx {
0098     u8 flags;
0099     u8 tx_buf_cnt;
0100     u16 tx_skb_cnt;
0101     struct sk_buff_head tx_skb_queue;
0102     struct list_head tx_buf;
0103     struct list_head tx_pending;
0104     spinlock_t tx_lock;
0105 };
0106 
0107 struct cmd_buf {
0108     struct sk_buff *skb;
0109     struct hif_device_usb *hif_dev;
0110 };
0111 
0112 #define HIF_USB_START BIT(0)
0113 #define HIF_USB_READY BIT(1)
0114 
0115 struct hif_device_usb {
0116     struct usb_device *udev;
0117     struct usb_interface *interface;
0118     const struct usb_device_id *usb_device_id;
0119     const void *fw_data;
0120     size_t fw_size;
0121     struct completion fw_done;
0122     struct htc_target *htc_handle;
0123     struct hif_usb_tx tx;
0124     struct usb_anchor regout_submitted;
0125     struct usb_anchor rx_submitted;
0126     struct usb_anchor reg_in_submitted;
0127     struct usb_anchor mgmt_submitted;
0128     struct sk_buff *remain_skb;
0129     char fw_name[32];
0130     int fw_minor_index;
0131     int rx_remain_len;
0132     int rx_pkt_len;
0133     int rx_transfer_len;
0134     int rx_pad_len;
0135     spinlock_t rx_lock;
0136     u8 flags; /* HIF_USB_* */
0137 };
0138 
0139 int ath9k_hif_usb_init(void);
0140 void ath9k_hif_usb_exit(void);
0141 void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev);
0142 
0143 #endif /* HTC_USB_H */