blob: 51496e74b83eaf3521230421f3a07350c385e3d4 [file] [log] [blame]
Sujithfb9987d2010-03-17 14:25:25 +05301/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2010-2011 Atheros Communications Inc.
Sujithfb9987d2010-03-17 14:25:25 +05303 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef HTC_USB_H
18#define HTC_USB_H
19
Sujith Manoharan3a0593e2011-04-20 14:33:28 +053020#define MAJOR_VERSION_REQ 1
Sujith Manoharanc75197a2011-05-17 12:41:20 +053021#define MINOR_VERSION_REQ 3
Sujith Manoharan3a0593e2011-04-20 14:33:28 +053022
Sujith Manoharan0b5ead92010-12-07 16:31:38 +053023#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
24
Sujithfb9987d2010-03-17 14:25:25 +053025#define AR9271_FIRMWARE 0x501000
26#define AR9271_FIRMWARE_TEXT 0x903000
Sujithb1762862010-06-02 15:53:34 +053027#define AR7010_FIRMWARE_TEXT 0x906000
Sujithfb9987d2010-03-17 14:25:25 +053028
29#define FIRMWARE_DOWNLOAD 0x30
30#define FIRMWARE_DOWNLOAD_COMP 0x31
31
32#define ATH_USB_RX_STREAM_MODE_TAG 0x4e00
33#define ATH_USB_TX_STREAM_MODE_TAG 0x697e
34
35/* FIXME: Verify these numbers (with Windows) */
36#define MAX_TX_URB_NUM 8
Sujith Manoharan15f6d6d2011-04-13 11:25:06 +053037#define MAX_TX_BUF_NUM 256
Sujithfb9987d2010-03-17 14:25:25 +053038#define MAX_TX_BUF_SIZE 32768
39#define MAX_TX_AGGR_NUM 20
40
41#define MAX_RX_URB_NUM 8
42#define MAX_RX_BUF_SIZE 16384
Sujithc5032692010-04-06 15:28:15 +053043#define MAX_PKT_NUM_IN_TRANSFER 10
Sujithfb9987d2010-03-17 14:25:25 +053044
45#define MAX_REG_OUT_URB_NUM 1
Sujith Manoharan3deff762011-04-13 11:25:23 +053046#define MAX_REG_IN_URB_NUM 64
Sujithfb9987d2010-03-17 14:25:25 +053047
48#define MAX_REG_IN_BUF_SIZE 64
49
50/* USB Endpoint definition */
51#define USB_WLAN_TX_PIPE 1
52#define USB_WLAN_RX_PIPE 2
53#define USB_REG_IN_PIPE 3
54#define USB_REG_OUT_PIPE 4
55
56#define HIF_USB_MAX_RXPIPES 2
57#define HIF_USB_MAX_TXPIPES 4
58
59struct tx_buf {
60 u8 *buf;
61 u16 len;
62 u16 offset;
63 struct urb *urb;
64 struct sk_buff_head skb_queue;
65 struct hif_device_usb *hif_dev;
66 struct list_head list;
67};
68
69#define HIF_USB_TX_STOP BIT(0)
Sujith Manoharanff8f59b2010-12-28 14:28:05 +053070#define HIF_USB_TX_FLUSH BIT(1)
Sujithfb9987d2010-03-17 14:25:25 +053071
72struct hif_usb_tx {
73 u8 flags;
74 u8 tx_buf_cnt;
75 u16 tx_skb_cnt;
76 struct sk_buff_head tx_skb_queue;
77 struct list_head tx_buf;
78 struct list_head tx_pending;
79 spinlock_t tx_lock;
80};
81
82struct cmd_buf {
83 struct sk_buff *skb;
84 struct hif_device_usb *hif_dev;
85};
86
87#define HIF_USB_START BIT(0)
Ming Lei32e31de2012-08-21 16:04:27 +080088#define HIF_USB_READY BIT(1)
Sujithfb9987d2010-03-17 14:25:25 +053089
90struct hif_device_usb {
Sujithfb9987d2010-03-17 14:25:25 +053091 struct usb_device *udev;
92 struct usb_interface *interface;
Sujith Manoharan0ed7b932012-01-30 14:17:18 +053093 const struct usb_device_id *usb_device_id;
Ming Lei32e31de2012-08-21 16:04:27 +080094 const void *fw_data;
95 size_t fw_size;
Sujith Manoharan0ed7b932012-01-30 14:17:18 +053096 struct completion fw_done;
Sujithfb9987d2010-03-17 14:25:25 +053097 struct htc_target *htc_handle;
Sujithfb9987d2010-03-17 14:25:25 +053098 struct hif_usb_tx tx;
Sujith6f0f2662010-04-06 15:28:17 +053099 struct usb_anchor regout_submitted;
Sujith6335ed02010-03-29 16:07:15 +0530100 struct usb_anchor rx_submitted;
Sujith Manoharan3deff762011-04-13 11:25:23 +0530101 struct usb_anchor reg_in_submitted;
Sujith Manoharan2f801942011-04-13 11:26:46 +0530102 struct usb_anchor mgmt_submitted;
Sujithfb9987d2010-03-17 14:25:25 +0530103 struct sk_buff *remain_skb;
Sujithce43cee2010-06-02 15:53:30 +0530104 const char *fw_name;
Sujithfb9987d2010-03-17 14:25:25 +0530105 int rx_remain_len;
106 int rx_pkt_len;
107 int rx_transfer_len;
108 int rx_pad_len;
Sujith46baa1a2010-04-06 15:28:11 +0530109 spinlock_t rx_lock;
Sujith6335ed02010-03-29 16:07:15 +0530110 u8 flags; /* HIF_USB_* */
Sujithfb9987d2010-03-17 14:25:25 +0530111};
112
113int ath9k_hif_usb_init(void);
114void ath9k_hif_usb_exit(void);
115
116#endif /* HTC_USB_H */