Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 1 | /* |
Sujith Manoharan | 5b68138 | 2011-05-17 13:36:18 +0530 | [diff] [blame] | 2 | * Copyright (c) 2010-2011 Atheros Communications Inc. |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 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 | |
Oleksij Rempel | e904cf6 | 2015-09-06 13:09:01 +0200 | [diff] [blame] | 20 | /* old firmware images */ |
| 21 | #define FIRMWARE_AR7010_1_1 "htc_7010.fw" |
| 22 | #define FIRMWARE_AR9271 "htc_9271.fw" |
| 23 | |
| 24 | /* supported Major FW version */ |
Sujith Manoharan | 3a0593e | 2011-04-20 14:33:28 +0530 | [diff] [blame] | 25 | #define MAJOR_VERSION_REQ 1 |
Sujith Manoharan | c75197a | 2011-05-17 12:41:20 +0530 | [diff] [blame] | 26 | #define MINOR_VERSION_REQ 3 |
Oleksij Rempel | e904cf6 | 2015-09-06 13:09:01 +0200 | [diff] [blame] | 27 | /* minimal and maximal supported Minor FW version. */ |
| 28 | #define FIRMWARE_MINOR_IDX_MAX 4 |
| 29 | #define FIRMWARE_MINOR_IDX_MIN 3 |
| 30 | #define HTC_FW_PATH "ath9k_htc" |
| 31 | |
| 32 | #define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \ |
| 33 | __stringify(MAJOR_VERSION_REQ) \ |
| 34 | "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw" |
| 35 | #define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \ |
| 36 | __stringify(MAJOR_VERSION_REQ) \ |
| 37 | "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw" |
| 38 | |
| 39 | extern int htc_use_dev_fw; |
Sujith Manoharan | 3a0593e | 2011-04-20 14:33:28 +0530 | [diff] [blame] | 40 | |
Sujith Manoharan | 0b5ead9 | 2010-12-07 16:31:38 +0530 | [diff] [blame] | 41 | #define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB)) |
| 42 | |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 43 | #define AR9271_FIRMWARE 0x501000 |
| 44 | #define AR9271_FIRMWARE_TEXT 0x903000 |
Sujith | b176286 | 2010-06-02 15:53:34 +0530 | [diff] [blame] | 45 | #define AR7010_FIRMWARE_TEXT 0x906000 |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 46 | |
| 47 | #define FIRMWARE_DOWNLOAD 0x30 |
| 48 | #define FIRMWARE_DOWNLOAD_COMP 0x31 |
| 49 | |
| 50 | #define ATH_USB_RX_STREAM_MODE_TAG 0x4e00 |
| 51 | #define ATH_USB_TX_STREAM_MODE_TAG 0x697e |
| 52 | |
| 53 | /* FIXME: Verify these numbers (with Windows) */ |
| 54 | #define MAX_TX_URB_NUM 8 |
Sujith Manoharan | 15f6d6d | 2011-04-13 11:25:06 +0530 | [diff] [blame] | 55 | #define MAX_TX_BUF_NUM 256 |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 56 | #define MAX_TX_BUF_SIZE 32768 |
| 57 | #define MAX_TX_AGGR_NUM 20 |
| 58 | |
| 59 | #define MAX_RX_URB_NUM 8 |
| 60 | #define MAX_RX_BUF_SIZE 16384 |
Sujith | c503269 | 2010-04-06 15:28:15 +0530 | [diff] [blame] | 61 | #define MAX_PKT_NUM_IN_TRANSFER 10 |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 62 | |
| 63 | #define MAX_REG_OUT_URB_NUM 1 |
Sujith Manoharan | 3deff76 | 2011-04-13 11:25:23 +0530 | [diff] [blame] | 64 | #define MAX_REG_IN_URB_NUM 64 |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 65 | |
| 66 | #define MAX_REG_IN_BUF_SIZE 64 |
| 67 | |
| 68 | /* USB Endpoint definition */ |
| 69 | #define USB_WLAN_TX_PIPE 1 |
| 70 | #define USB_WLAN_RX_PIPE 2 |
| 71 | #define USB_REG_IN_PIPE 3 |
| 72 | #define USB_REG_OUT_PIPE 4 |
| 73 | |
| 74 | #define HIF_USB_MAX_RXPIPES 2 |
| 75 | #define HIF_USB_MAX_TXPIPES 4 |
| 76 | |
| 77 | struct tx_buf { |
| 78 | u8 *buf; |
| 79 | u16 len; |
| 80 | u16 offset; |
| 81 | struct urb *urb; |
| 82 | struct sk_buff_head skb_queue; |
| 83 | struct hif_device_usb *hif_dev; |
| 84 | struct list_head list; |
| 85 | }; |
| 86 | |
| 87 | #define HIF_USB_TX_STOP BIT(0) |
Sujith Manoharan | ff8f59b | 2010-12-28 14:28:05 +0530 | [diff] [blame] | 88 | #define HIF_USB_TX_FLUSH BIT(1) |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 89 | |
| 90 | struct hif_usb_tx { |
| 91 | u8 flags; |
| 92 | u8 tx_buf_cnt; |
| 93 | u16 tx_skb_cnt; |
| 94 | struct sk_buff_head tx_skb_queue; |
| 95 | struct list_head tx_buf; |
| 96 | struct list_head tx_pending; |
| 97 | spinlock_t tx_lock; |
| 98 | }; |
| 99 | |
| 100 | struct cmd_buf { |
| 101 | struct sk_buff *skb; |
| 102 | struct hif_device_usb *hif_dev; |
| 103 | }; |
| 104 | |
| 105 | #define HIF_USB_START BIT(0) |
Ming Lei | 32e31de | 2012-08-21 16:04:27 +0800 | [diff] [blame] | 106 | #define HIF_USB_READY BIT(1) |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 107 | |
| 108 | struct hif_device_usb { |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 109 | struct usb_device *udev; |
| 110 | struct usb_interface *interface; |
Sujith Manoharan | 0ed7b93 | 2012-01-30 14:17:18 +0530 | [diff] [blame] | 111 | const struct usb_device_id *usb_device_id; |
Ming Lei | 32e31de | 2012-08-21 16:04:27 +0800 | [diff] [blame] | 112 | const void *fw_data; |
| 113 | size_t fw_size; |
Sujith Manoharan | 0ed7b93 | 2012-01-30 14:17:18 +0530 | [diff] [blame] | 114 | struct completion fw_done; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 115 | struct htc_target *htc_handle; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 116 | struct hif_usb_tx tx; |
Sujith | 6f0f266 | 2010-04-06 15:28:17 +0530 | [diff] [blame] | 117 | struct usb_anchor regout_submitted; |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 118 | struct usb_anchor rx_submitted; |
Sujith Manoharan | 3deff76 | 2011-04-13 11:25:23 +0530 | [diff] [blame] | 119 | struct usb_anchor reg_in_submitted; |
Sujith Manoharan | 2f80194 | 2011-04-13 11:26:46 +0530 | [diff] [blame] | 120 | struct usb_anchor mgmt_submitted; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 121 | struct sk_buff *remain_skb; |
Oleksij Rempel | e904cf6 | 2015-09-06 13:09:01 +0200 | [diff] [blame] | 122 | char fw_name[32]; |
| 123 | int fw_minor_index; |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 124 | int rx_remain_len; |
| 125 | int rx_pkt_len; |
| 126 | int rx_transfer_len; |
| 127 | int rx_pad_len; |
Sujith | 46baa1a | 2010-04-06 15:28:11 +0530 | [diff] [blame] | 128 | spinlock_t rx_lock; |
Sujith | 6335ed0 | 2010-03-29 16:07:15 +0530 | [diff] [blame] | 129 | u8 flags; /* HIF_USB_* */ |
Sujith | fb9987d | 2010-03-17 14:25:25 +0530 | [diff] [blame] | 130 | }; |
| 131 | |
| 132 | int ath9k_hif_usb_init(void); |
| 133 | void ath9k_hif_usb_exit(void); |
| 134 | |
| 135 | #endif /* HTC_USB_H */ |