hif_usb.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (c) 2010-2011 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. #ifndef HTC_USB_H
  17. #define HTC_USB_H
  18. /* old firmware images */
  19. #define FIRMWARE_AR7010_1_1 "htc_7010.fw"
  20. #define FIRMWARE_AR9271 "htc_9271.fw"
  21. /* supported Major FW version */
  22. #define MAJOR_VERSION_REQ 1
  23. #define MINOR_VERSION_REQ 3
  24. /* minimal and maximal supported Minor FW version. */
  25. #define FIRMWARE_MINOR_IDX_MAX 4
  26. #define FIRMWARE_MINOR_IDX_MIN 3
  27. #define HTC_FW_PATH "ath9k_htc"
  28. #define HTC_9271_MODULE_FW HTC_FW_PATH "/htc_9271-" \
  29. __stringify(MAJOR_VERSION_REQ) \
  30. "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
  31. #define HTC_7010_MODULE_FW HTC_FW_PATH "/htc_7010-" \
  32. __stringify(MAJOR_VERSION_REQ) \
  33. "." __stringify(FIRMWARE_MINOR_IDX_MAX) ".0.fw"
  34. extern int htc_use_dev_fw;
  35. #define IS_AR7010_DEVICE(_v) (((_v) == AR9280_USB) || ((_v) == AR9287_USB))
  36. #define AR9271_FIRMWARE 0x501000
  37. #define AR9271_FIRMWARE_TEXT 0x903000
  38. #define AR7010_FIRMWARE_TEXT 0x906000
  39. #define FIRMWARE_DOWNLOAD 0x30
  40. #define FIRMWARE_DOWNLOAD_COMP 0x31
  41. #define ATH_USB_RX_STREAM_MODE_TAG 0x4e00
  42. #define ATH_USB_TX_STREAM_MODE_TAG 0x697e
  43. /* FIXME: Verify these numbers (with Windows) */
  44. #define MAX_TX_URB_NUM 8
  45. #define MAX_TX_BUF_NUM 256
  46. #define MAX_TX_BUF_SIZE 32768
  47. #define MAX_TX_AGGR_NUM 20
  48. #define MAX_RX_URB_NUM 8
  49. #define MAX_RX_BUF_SIZE 16384
  50. #define MAX_PKT_NUM_IN_TRANSFER 10
  51. #define MAX_REG_OUT_URB_NUM 1
  52. #define MAX_REG_IN_URB_NUM 64
  53. #define MAX_REG_IN_BUF_SIZE 64
  54. /* USB Endpoint definition */
  55. #define USB_WLAN_TX_PIPE 1
  56. #define USB_WLAN_RX_PIPE 2
  57. #define USB_REG_IN_PIPE 3
  58. #define USB_REG_OUT_PIPE 4
  59. #define USB_MSG_TIMEOUT 1000 /* (ms) */
  60. #define HIF_USB_MAX_RXPIPES 2
  61. #define HIF_USB_MAX_TXPIPES 4
  62. struct tx_buf {
  63. u8 *buf;
  64. u16 len;
  65. u16 offset;
  66. struct urb *urb;
  67. struct sk_buff_head skb_queue;
  68. struct hif_device_usb *hif_dev;
  69. struct list_head list;
  70. };
  71. #define HIF_USB_TX_STOP BIT(0)
  72. #define HIF_USB_TX_FLUSH BIT(1)
  73. struct hif_usb_tx {
  74. u8 flags;
  75. u8 tx_buf_cnt;
  76. u16 tx_skb_cnt;
  77. struct sk_buff_head tx_skb_queue;
  78. struct list_head tx_buf;
  79. struct list_head tx_pending;
  80. spinlock_t tx_lock;
  81. };
  82. struct cmd_buf {
  83. struct sk_buff *skb;
  84. struct hif_device_usb *hif_dev;
  85. };
  86. #define HIF_USB_START BIT(0)
  87. #define HIF_USB_READY BIT(1)
  88. struct hif_device_usb {
  89. struct usb_device *udev;
  90. struct usb_interface *interface;
  91. const struct usb_device_id *usb_device_id;
  92. const void *fw_data;
  93. size_t fw_size;
  94. struct completion fw_done;
  95. struct htc_target *htc_handle;
  96. struct hif_usb_tx tx;
  97. struct usb_anchor regout_submitted;
  98. struct usb_anchor rx_submitted;
  99. struct usb_anchor reg_in_submitted;
  100. struct usb_anchor mgmt_submitted;
  101. struct sk_buff *remain_skb;
  102. char fw_name[32];
  103. int fw_minor_index;
  104. int rx_remain_len;
  105. int rx_pkt_len;
  106. int rx_transfer_len;
  107. int rx_pad_len;
  108. spinlock_t rx_lock;
  109. u8 flags; /* HIF_USB_* */
  110. };
  111. int ath9k_hif_usb_init(void);
  112. void ath9k_hif_usb_exit(void);
  113. #endif /* HTC_USB_H */