blob: e4a5e2e795414754ee1c61c3eed2690ea34e2b47 [file] [log] [blame]
Sujithfb9987d2010-03-17 14:25:25 +05301/*
2 * Copyright (c) 2010 Atheros Communications Inc.
3 *
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 Manoharan0b5ead92010-12-07 16:31:38 +053020#define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
21
Sujithfb9987d2010-03-17 14:25:25 +053022#define AR9271_FIRMWARE 0x501000
23#define AR9271_FIRMWARE_TEXT 0x903000
Sujithb1762862010-06-02 15:53:34 +053024#define AR7010_FIRMWARE_TEXT 0x906000
Sujithfb9987d2010-03-17 14:25:25 +053025
26#define FIRMWARE_DOWNLOAD 0x30
27#define FIRMWARE_DOWNLOAD_COMP 0x31
28
29#define ATH_USB_RX_STREAM_MODE_TAG 0x4e00
30#define ATH_USB_TX_STREAM_MODE_TAG 0x697e
31
32/* FIXME: Verify these numbers (with Windows) */
33#define MAX_TX_URB_NUM 8
34#define MAX_TX_BUF_NUM 1024
35#define MAX_TX_BUF_SIZE 32768
36#define MAX_TX_AGGR_NUM 20
37
38#define MAX_RX_URB_NUM 8
39#define MAX_RX_BUF_SIZE 16384
Sujithc5032692010-04-06 15:28:15 +053040#define MAX_PKT_NUM_IN_TRANSFER 10
Sujithfb9987d2010-03-17 14:25:25 +053041
42#define MAX_REG_OUT_URB_NUM 1
43#define MAX_REG_OUT_BUF_NUM 8
44
45#define MAX_REG_IN_BUF_SIZE 64
46
47/* USB Endpoint definition */
48#define USB_WLAN_TX_PIPE 1
49#define USB_WLAN_RX_PIPE 2
50#define USB_REG_IN_PIPE 3
51#define USB_REG_OUT_PIPE 4
52
53#define HIF_USB_MAX_RXPIPES 2
54#define HIF_USB_MAX_TXPIPES 4
55
56struct tx_buf {
57 u8 *buf;
58 u16 len;
59 u16 offset;
60 struct urb *urb;
61 struct sk_buff_head skb_queue;
62 struct hif_device_usb *hif_dev;
63 struct list_head list;
64};
65
66#define HIF_USB_TX_STOP BIT(0)
Sujithfb9987d2010-03-17 14:25:25 +053067
68struct hif_usb_tx {
69 u8 flags;
70 u8 tx_buf_cnt;
71 u16 tx_skb_cnt;
72 struct sk_buff_head tx_skb_queue;
73 struct list_head tx_buf;
74 struct list_head tx_pending;
75 spinlock_t tx_lock;
76};
77
78struct cmd_buf {
79 struct sk_buff *skb;
80 struct hif_device_usb *hif_dev;
81};
82
83#define HIF_USB_START BIT(0)
84
85struct hif_device_usb {
86 u16 device_id;
87 struct usb_device *udev;
88 struct usb_interface *interface;
89 const struct firmware *firmware;
90 struct htc_target *htc_handle;
Sujithfb9987d2010-03-17 14:25:25 +053091 struct hif_usb_tx tx;
Sujithfb9987d2010-03-17 14:25:25 +053092 struct urb *reg_in_urb;
Sujith6f0f2662010-04-06 15:28:17 +053093 struct usb_anchor regout_submitted;
Sujith6335ed02010-03-29 16:07:15 +053094 struct usb_anchor rx_submitted;
Sujithfb9987d2010-03-17 14:25:25 +053095 struct sk_buff *remain_skb;
Sujithce43cee2010-06-02 15:53:30 +053096 const char *fw_name;
Sujithfb9987d2010-03-17 14:25:25 +053097 int rx_remain_len;
98 int rx_pkt_len;
99 int rx_transfer_len;
100 int rx_pad_len;
Sujith46baa1a2010-04-06 15:28:11 +0530101 spinlock_t rx_lock;
Sujith6335ed02010-03-29 16:07:15 +0530102 u8 flags; /* HIF_USB_* */
Sujithfb9987d2010-03-17 14:25:25 +0530103};
104
105int ath9k_hif_usb_init(void);
106void ath9k_hif_usb_exit(void);
107
108#endif /* HTC_USB_H */