rtl8187.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Definitions for RTL8187 hardware
  3. *
  4. * Copyright 2007 Michael Wu <flamingice@sourmilk.net>
  5. * Copyright 2007 Andrea Merello <andreamrl@tiscali.it>
  6. *
  7. * Based on the r8187 driver, which is:
  8. * Copyright 2005 Andrea Merello <andreamrl@tiscali.it>, 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 "rtl818x.h"
  17. #define RTL8187_EEPROM_TXPWR_BASE 0x05
  18. #define RTL8187_EEPROM_MAC_ADDR 0x07
  19. #define RTL8187_EEPROM_TXPWR_CHAN_1 0x16 /* 3 channels */
  20. #define RTL8187_EEPROM_TXPWR_CHAN_6 0x1B /* 2 channels */
  21. #define RTL8187_EEPROM_TXPWR_CHAN_4 0x3D /* 2 channels */
  22. #define RTL8187_REQT_READ 0xC0
  23. #define RTL8187_REQT_WRITE 0x40
  24. #define RTL8187_REQ_GET_REG 0x05
  25. #define RTL8187_REQ_SET_REG 0x05
  26. #define RTL8187_MAX_RX 0x9C4
  27. struct rtl8187_rx_info {
  28. struct urb *urb;
  29. struct ieee80211_hw *dev;
  30. };
  31. struct rtl8187_rx_hdr {
  32. __le32 flags;
  33. u8 noise;
  34. u8 signal;
  35. u8 agc;
  36. u8 reserved;
  37. __le64 mac_time;
  38. } __attribute__((packed));
  39. struct rtl8187_tx_hdr {
  40. __le32 flags;
  41. #define RTL8187_TX_FLAG_NO_ENCRYPT (1 << 15)
  42. #define RTL8187_TX_FLAG_MORE_FRAG (1 << 17)
  43. #define RTL8187_TX_FLAG_CTS (1 << 18)
  44. #define RTL8187_TX_FLAG_RTS (1 << 23)
  45. __le16 rts_duration;
  46. __le16 len;
  47. __le32 retry;
  48. } __attribute__((packed));
  49. struct rtl8187_priv {
  50. /* common between rtl818x drivers */
  51. struct rtl818x_csr *map;
  52. const struct rtl818x_rf_ops *rf;
  53. struct ieee80211_vif *vif;
  54. int mode;
  55. /* rtl8187 specific */
  56. struct ieee80211_channel channels[14];
  57. struct ieee80211_rate rates[12];
  58. struct ieee80211_supported_band band;
  59. struct usb_device *udev;
  60. u32 rx_conf;
  61. u16 txpwr_base;
  62. u8 asic_rev;
  63. struct sk_buff_head rx_queue;
  64. };
  65. void rtl8187_write_phy(struct ieee80211_hw *dev, u8 addr, u32 data);
  66. static inline u8 rtl818x_ioread8(struct rtl8187_priv *priv, u8 *addr)
  67. {
  68. u8 val;
  69. usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
  70. RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
  71. (unsigned long)addr, 0, &val, sizeof(val), HZ / 2);
  72. return val;
  73. }
  74. static inline u16 rtl818x_ioread16(struct rtl8187_priv *priv, __le16 *addr)
  75. {
  76. __le16 val;
  77. usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
  78. RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
  79. (unsigned long)addr, 0, &val, sizeof(val), HZ / 2);
  80. return le16_to_cpu(val);
  81. }
  82. static inline u32 rtl818x_ioread32(struct rtl8187_priv *priv, __le32 *addr)
  83. {
  84. __le32 val;
  85. usb_control_msg(priv->udev, usb_rcvctrlpipe(priv->udev, 0),
  86. RTL8187_REQ_GET_REG, RTL8187_REQT_READ,
  87. (unsigned long)addr, 0, &val, sizeof(val), HZ / 2);
  88. return le32_to_cpu(val);
  89. }
  90. static inline void rtl818x_iowrite8(struct rtl8187_priv *priv,
  91. u8 *addr, u8 val)
  92. {
  93. usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
  94. RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
  95. (unsigned long)addr, 0, &val, sizeof(val), HZ / 2);
  96. }
  97. static inline void rtl818x_iowrite16(struct rtl8187_priv *priv,
  98. __le16 *addr, u16 val)
  99. {
  100. __le16 buf = cpu_to_le16(val);
  101. usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
  102. RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
  103. (unsigned long)addr, 0, &buf, sizeof(buf), HZ / 2);
  104. }
  105. static inline void rtl818x_iowrite32(struct rtl8187_priv *priv,
  106. __le32 *addr, u32 val)
  107. {
  108. __le32 buf = cpu_to_le32(val);
  109. usb_control_msg(priv->udev, usb_sndctrlpipe(priv->udev, 0),
  110. RTL8187_REQ_SET_REG, RTL8187_REQT_WRITE,
  111. (unsigned long)addr, 0, &buf, sizeof(buf), HZ / 2);
  112. }
  113. #endif /* RTL8187_H */