rtl8187.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Definitions for RTL8187 hardware
  3. *
  4. * Copyright 2007 Michael Wu <flamingice@sourmilk.net>
  5. * Copyright 2007 Andrea Merello <andrea.merello@gmail.com>
  6. *
  7. * Based on the r8187 driver, which is:
  8. * Copyright 2005 Andrea Merello <andrea.merello@gmail.com>, et al.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef RTL8187_H
  15. #define RTL8187_H
  16. #include <linux/cache.h>
  17. #include "rtl818x.h"
  18. #include "leds.h"
  19. #define RTL8187_EEPROM_TXPWR_BASE 0x05
  20. #define RTL8187_EEPROM_MAC_ADDR 0x07
  21. #define RTL8187_EEPROM_TXPWR_CHAN_1 0x16 /* 3 channels */
  22. #define RTL8187_EEPROM_TXPWR_CHAN_6 0x1B /* 2 channels */
  23. #define RTL8187_EEPROM_TXPWR_CHAN_4 0x3D /* 2 channels */
  24. #define RTL8187_EEPROM_SELECT_GPIO 0x3B
  25. #define RTL8187_REQT_READ 0xC0
  26. #define RTL8187_REQT_WRITE 0x40
  27. #define RTL8187_REQ_GET_REG 0x05
  28. #define RTL8187_REQ_SET_REG 0x05
  29. #define RTL8187_MAX_RX 0x9C4
  30. #define RFKILL_MASK_8187_89_97 0x2
  31. #define RFKILL_MASK_8198 0x4
  32. #define RETRY_COUNT 7
  33. struct rtl8187_rx_info {
  34. struct urb *urb;
  35. struct ieee80211_hw *dev;
  36. };
  37. struct rtl8187_rx_hdr {
  38. __le32 flags;
  39. u8 noise;
  40. u8 signal;
  41. u8 agc;
  42. u8 reserved;
  43. __le64 mac_time;
  44. } __packed;
  45. struct rtl8187b_rx_hdr {
  46. __le32 flags;
  47. __le64 mac_time;
  48. u8 sq;
  49. u8 rssi;
  50. u8 agc;
  51. u8 flags2;
  52. __le16 snr_long2end;
  53. s8 pwdb_g12;
  54. u8 fot;
  55. } __packed;
  56. /* {rtl8187,rtl8187b}_tx_info is in skb */
  57. struct rtl8187_tx_hdr {
  58. __le32 flags;
  59. __le16 rts_duration;
  60. __le16 len;
  61. __le32 retry;
  62. } __packed;
  63. struct rtl8187b_tx_hdr {
  64. __le32 flags;
  65. __le16 rts_duration;
  66. __le16 len;
  67. __le32 unused_1;
  68. __le16 unused_2;
  69. __le16 tx_duration;
  70. __le32 unused_3;
  71. __le32 retry;
  72. __le32 unused_4[2];
  73. } __packed;
  74. enum {
  75. DEVICE_RTL8187,
  76. DEVICE_RTL8187B
  77. };
  78. struct rtl8187_vif {
  79. struct ieee80211_hw *dev;
  80. /* beaconing */
  81. struct delayed_work beacon_work;
  82. bool enable_beacon;
  83. };
  84. struct rtl8187_priv {
  85. /* common between rtl818x drivers */
  86. struct rtl818x_csr *map;
  87. const struct rtl818x_rf_ops *rf;
  88. struct ieee80211_vif *vif;
  89. /* The mutex protects the TX loopback state.
  90. * Any attempt to set channels concurrently locks the device.
  91. */
  92. struct mutex conf_mutex;
  93. /* rtl8187 specific */
  94. struct ieee80211_channel channels[14];
  95. struct ieee80211_rate rates[12];
  96. struct ieee80211_supported_band band;
  97. struct usb_device *udev;
  98. u32 rx_conf;
  99. struct usb_anchor anchored;
  100. struct delayed_work work;
  101. struct ieee80211_hw *dev;
  102. #ifdef CONFIG_RTL8187_LEDS
  103. struct rtl8187_led led_radio;
  104. struct rtl8187_led led_tx;
  105. struct rtl8187_led led_rx;
  106. struct delayed_work led_on;
  107. struct delayed_work led_off;
  108. #endif
  109. u16 txpwr_base;
  110. u8 asic_rev;
  111. u8 is_rtl8187b;
  112. enum {
  113. RTL8187BvB,
  114. RTL8187BvD,
  115. RTL8187BvE
  116. } hw_rev;
  117. struct sk_buff_head rx_queue;
  118. u8 signal;
  119. u8 noise;
  120. u8 slot_time;
  121. u8 aifsn[4];
  122. u8 rfkill_mask;
  123. struct {
  124. union {
  125. __le64 buf;
  126. u8 dummy1[L1_CACHE_BYTES];
  127. } ____cacheline_aligned;
  128. struct sk_buff_head queue;
  129. } b_tx_status; /* This queue is used by both -b and non-b devices */
  130. struct mutex io_mutex;
  131. union {
  132. u8 bits8;
  133. __le16 bits16;
  134. __le32 bits32;
  135. u8 dummy2[L1_CACHE_BYTES];
  136. } *io_dmabuf ____cacheline_aligned;
  137. bool rfkill_off;
  138. u16 seqno;
  139. };
  140. void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
  141. u8 rtl818x_ioread8_idx(struct rtl8187_priv *priv,
  142. u8 *addr, u8 idx);
  143. static inline u8 rtl818x_ioread8(struct rtl8187_priv *priv, u8 *addr)
  144. {
  145. return rtl818x_ioread8_idx(priv, addr, 0);
  146. }
  147. u16 rtl818x_ioread16_idx(struct rtl8187_priv *priv,
  148. __le16 *addr, u8 idx);
  149. static inline u16 rtl818x_ioread16(struct rtl8187_priv *priv, __le16 *addr)
  150. {
  151. return rtl818x_ioread16_idx(priv, addr, 0);
  152. }
  153. u32 rtl818x_ioread32_idx(struct rtl8187_priv *priv,
  154. __le32 *addr, u8 idx);
  155. static inline u32 rtl818x_ioread32(struct rtl8187_priv *priv, __le32 *addr)
  156. {
  157. return rtl818x_ioread32_idx(priv, addr, 0);
  158. }
  159. void rtl818x_iowrite8_idx(struct rtl8187_priv *priv,
  160. u8 *addr, u8 val, u8 idx);
  161. static inline void rtl818x_iowrite8(struct rtl8187_priv *priv, u8 *addr, u8 val)
  162. {
  163. rtl818x_iowrite8_idx(priv, addr, val, 0);
  164. }
  165. void rtl818x_iowrite16_idx(struct rtl8187_priv *priv,
  166. __le16 *addr, u16 val, u8 idx);
  167. static inline void rtl818x_iowrite16(struct rtl8187_priv *priv, __le16 *addr,
  168. u16 val)
  169. {
  170. rtl818x_iowrite16_idx(priv, addr, val, 0);
  171. }
  172. void rtl818x_iowrite32_idx(struct rtl8187_priv *priv,
  173. __le32 *addr, u32 val, u8 idx);
  174. static inline void rtl818x_iowrite32(struct rtl8187_priv *priv, __le32 *addr,
  175. u32 val)
  176. {
  177. rtl818x_iowrite32_idx(priv, addr, val, 0);
  178. }
  179. #endif /* RTL8187_H */