phy.h 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /*
  2. Broadcom B43legacy wireless driver
  3. Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
  4. Stefano Brivio <stefano.brivio@polimi.it>
  5. Michael Buesch <m@bues.ch>
  6. Danny van Dyk <kugelfang@gentoo.org>
  7. Andreas Jaggi <andreas.jaggi@waterwave.ch>
  8. Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net>
  9. Some parts of the code in this file are derived from the ipw2200
  10. driver Copyright(c) 2003 - 2004 Intel Corporation.
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; see the file COPYING. If not, write to
  21. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  22. Boston, MA 02110-1301, USA.
  23. */
  24. #ifndef B43legacy_PHY_H_
  25. #define B43legacy_PHY_H_
  26. #include <linux/types.h>
  27. enum {
  28. B43legacy_ANTENNA0, /* Antenna 0 */
  29. B43legacy_ANTENNA1, /* Antenna 0 */
  30. B43legacy_ANTENNA_AUTO1, /* Automatic, starting with antenna 1 */
  31. B43legacy_ANTENNA_AUTO0, /* Automatic, starting with antenna 0 */
  32. B43legacy_ANTENNA_AUTO = B43legacy_ANTENNA_AUTO0,
  33. B43legacy_ANTENNA_DEFAULT = B43legacy_ANTENNA_AUTO,
  34. };
  35. enum {
  36. B43legacy_INTERFMODE_NONE,
  37. B43legacy_INTERFMODE_NONWLAN,
  38. B43legacy_INTERFMODE_MANUALWLAN,
  39. B43legacy_INTERFMODE_AUTOWLAN,
  40. };
  41. /*** PHY Registers ***/
  42. /* Routing */
  43. #define B43legacy_PHYROUTE_OFDM_GPHY 0x400
  44. #define B43legacy_PHYROUTE_EXT_GPHY 0x800
  45. /* Base registers. */
  46. #define B43legacy_PHY_BASE(reg) (reg)
  47. /* OFDM (A) registers of a G-PHY */
  48. #define B43legacy_PHY_OFDM(reg) ((reg) | B43legacy_PHYROUTE_OFDM_GPHY)
  49. /* Extended G-PHY registers */
  50. #define B43legacy_PHY_EXTG(reg) ((reg) | B43legacy_PHYROUTE_EXT_GPHY)
  51. /* Extended G-PHY Registers */
  52. #define B43legacy_PHY_CLASSCTL B43legacy_PHY_EXTG(0x02) /* Classify control */
  53. #define B43legacy_PHY_GTABCTL B43legacy_PHY_EXTG(0x03) /* G-PHY table control (see below) */
  54. #define B43legacy_PHY_GTABOFF 0x03FF /* G-PHY table offset (see below) */
  55. #define B43legacy_PHY_GTABNR 0xFC00 /* G-PHY table number (see below) */
  56. #define B43legacy_PHY_GTABNR_SHIFT 10
  57. #define B43legacy_PHY_GTABDATA B43legacy_PHY_EXTG(0x04) /* G-PHY table data */
  58. #define B43legacy_PHY_LO_MASK B43legacy_PHY_EXTG(0x0F) /* Local Oscillator control mask */
  59. #define B43legacy_PHY_LO_CTL B43legacy_PHY_EXTG(0x10) /* Local Oscillator control */
  60. #define B43legacy_PHY_RFOVER B43legacy_PHY_EXTG(0x11) /* RF override */
  61. #define B43legacy_PHY_RFOVERVAL B43legacy_PHY_EXTG(0x12) /* RF override value */
  62. /*** OFDM table numbers ***/
  63. #define B43legacy_OFDMTAB(number, offset) \
  64. (((number) << B43legacy_PHY_OTABLENR_SHIFT) \
  65. | (offset))
  66. #define B43legacy_OFDMTAB_AGC1 B43legacy_OFDMTAB(0x00, 0)
  67. #define B43legacy_OFDMTAB_GAIN0 B43legacy_OFDMTAB(0x00, 0)
  68. #define B43legacy_OFDMTAB_GAINX B43legacy_OFDMTAB(0x01, 0)
  69. #define B43legacy_OFDMTAB_GAIN1 B43legacy_OFDMTAB(0x01, 4)
  70. #define B43legacy_OFDMTAB_AGC3 B43legacy_OFDMTAB(0x02, 0)
  71. #define B43legacy_OFDMTAB_GAIN2 B43legacy_OFDMTAB(0x02, 3)
  72. #define B43legacy_OFDMTAB_LNAHPFGAIN1 B43legacy_OFDMTAB(0x03, 0)
  73. #define B43legacy_OFDMTAB_WRSSI B43legacy_OFDMTAB(0x04, 0)
  74. #define B43legacy_OFDMTAB_LNAHPFGAIN2 B43legacy_OFDMTAB(0x04, 0)
  75. #define B43legacy_OFDMTAB_NOISESCALE B43legacy_OFDMTAB(0x05, 0)
  76. #define B43legacy_OFDMTAB_AGC2 B43legacy_OFDMTAB(0x06, 0)
  77. #define B43legacy_OFDMTAB_ROTOR B43legacy_OFDMTAB(0x08, 0)
  78. #define B43legacy_OFDMTAB_ADVRETARD B43legacy_OFDMTAB(0x09, 0)
  79. #define B43legacy_OFDMTAB_DAC B43legacy_OFDMTAB(0x0C, 0)
  80. #define B43legacy_OFDMTAB_DC B43legacy_OFDMTAB(0x0E, 7)
  81. #define B43legacy_OFDMTAB_PWRDYN2 B43legacy_OFDMTAB(0x0E, 12)
  82. #define B43legacy_OFDMTAB_LNAGAIN B43legacy_OFDMTAB(0x0E, 13)
  83. #define B43legacy_OFDMTAB_LPFGAIN B43legacy_OFDMTAB(0x0F, 12)
  84. #define B43legacy_OFDMTAB_RSSI B43legacy_OFDMTAB(0x10, 0)
  85. #define B43legacy_OFDMTAB_AGC1_R1 B43legacy_OFDMTAB(0x13, 0)
  86. #define B43legacy_OFDMTAB_GAINX_R1 B43legacy_OFDMTAB(0x14, 0)
  87. #define B43legacy_OFDMTAB_MINSIGSQ B43legacy_OFDMTAB(0x14, 1)
  88. #define B43legacy_OFDMTAB_AGC3_R1 B43legacy_OFDMTAB(0x15, 0)
  89. #define B43legacy_OFDMTAB_WRSSI_R1 B43legacy_OFDMTAB(0x15, 4)
  90. #define B43legacy_OFDMTAB_TSSI B43legacy_OFDMTAB(0x15, 0)
  91. #define B43legacy_OFDMTAB_DACRFPABB B43legacy_OFDMTAB(0x16, 0)
  92. #define B43legacy_OFDMTAB_DACOFF B43legacy_OFDMTAB(0x17, 0)
  93. #define B43legacy_OFDMTAB_DCBIAS B43legacy_OFDMTAB(0x18, 0)
  94. void b43legacy_put_attenuation_into_ranges(int *_bbatt, int *_rfatt);
  95. /* OFDM (A) PHY Registers */
  96. #define B43legacy_PHY_VERSION_OFDM B43legacy_PHY_OFDM(0x00) /* Versioning register for A-PHY */
  97. #define B43legacy_PHY_BBANDCFG B43legacy_PHY_OFDM(0x01) /* Baseband config */
  98. #define B43legacy_PHY_BBANDCFG_RXANT 0x180 /* RX Antenna selection */
  99. #define B43legacy_PHY_BBANDCFG_RXANT_SHIFT 7
  100. #define B43legacy_PHY_PWRDOWN B43legacy_PHY_OFDM(0x03) /* Powerdown */
  101. #define B43legacy_PHY_CRSTHRES1 B43legacy_PHY_OFDM(0x06) /* CRS Threshold 1 */
  102. #define B43legacy_PHY_LNAHPFCTL B43legacy_PHY_OFDM(0x1C) /* LNA/HPF control */
  103. #define B43legacy_PHY_ADIVRELATED B43legacy_PHY_OFDM(0x27) /* FIXME rename */
  104. #define B43legacy_PHY_CRS0 B43legacy_PHY_OFDM(0x29)
  105. #define B43legacy_PHY_ANTDWELL B43legacy_PHY_OFDM(0x2B) /* Antenna dwell */
  106. #define B43legacy_PHY_ANTDWELL_AUTODIV1 0x0100 /* Automatic RX diversity start antenna */
  107. #define B43legacy_PHY_ENCORE B43legacy_PHY_OFDM(0x49) /* "Encore" (RangeMax / BroadRange) */
  108. #define B43legacy_PHY_ENCORE_EN 0x0200 /* Encore enable */
  109. #define B43legacy_PHY_LMS B43legacy_PHY_OFDM(0x55)
  110. #define B43legacy_PHY_OFDM61 B43legacy_PHY_OFDM(0x61) /* FIXME rename */
  111. #define B43legacy_PHY_OFDM61_10 0x0010 /* FIXME rename */
  112. #define B43legacy_PHY_IQBAL B43legacy_PHY_OFDM(0x69) /* I/Q balance */
  113. #define B43legacy_PHY_OTABLECTL B43legacy_PHY_OFDM(0x72) /* OFDM table control (see below) */
  114. #define B43legacy_PHY_OTABLEOFF 0x03FF /* OFDM table offset (see below) */
  115. #define B43legacy_PHY_OTABLENR 0xFC00 /* OFDM table number (see below) */
  116. #define B43legacy_PHY_OTABLENR_SHIFT 10
  117. #define B43legacy_PHY_OTABLEI B43legacy_PHY_OFDM(0x73) /* OFDM table data I */
  118. #define B43legacy_PHY_OTABLEQ B43legacy_PHY_OFDM(0x74) /* OFDM table data Q */
  119. #define B43legacy_PHY_HPWR_TSSICTL B43legacy_PHY_OFDM(0x78) /* Hardware power TSSI control */
  120. #define B43legacy_PHY_NRSSITHRES B43legacy_PHY_OFDM(0x8A) /* NRSSI threshold */
  121. #define B43legacy_PHY_ANTWRSETT B43legacy_PHY_OFDM(0x8C) /* Antenna WR settle */
  122. #define B43legacy_PHY_ANTWRSETT_ARXDIV 0x2000 /* Automatic RX diversity enabled */
  123. #define B43legacy_PHY_CLIPPWRDOWNT B43legacy_PHY_OFDM(0x93) /* Clip powerdown threshold */
  124. #define B43legacy_PHY_OFDM9B B43legacy_PHY_OFDM(0x9B) /* FIXME rename */
  125. #define B43legacy_PHY_N1P1GAIN B43legacy_PHY_OFDM(0xA0)
  126. #define B43legacy_PHY_P1P2GAIN B43legacy_PHY_OFDM(0xA1)
  127. #define B43legacy_PHY_N1N2GAIN B43legacy_PHY_OFDM(0xA2)
  128. #define B43legacy_PHY_CLIPTHRES B43legacy_PHY_OFDM(0xA3)
  129. #define B43legacy_PHY_CLIPN1P2THRES B43legacy_PHY_OFDM(0xA4)
  130. #define B43legacy_PHY_DIVSRCHIDX B43legacy_PHY_OFDM(0xA8) /* Divider search gain/index */
  131. #define B43legacy_PHY_CLIPP2THRES B43legacy_PHY_OFDM(0xA9)
  132. #define B43legacy_PHY_CLIPP3THRES B43legacy_PHY_OFDM(0xAA)
  133. #define B43legacy_PHY_DIVP1P2GAIN B43legacy_PHY_OFDM(0xAB)
  134. #define B43legacy_PHY_DIVSRCHGAINBACK B43legacy_PHY_OFDM(0xAD) /* Divider search gain back */
  135. #define B43legacy_PHY_DIVSRCHGAINCHNG B43legacy_PHY_OFDM(0xAE) /* Divider search gain change */
  136. #define B43legacy_PHY_CRSTHRES1_R1 B43legacy_PHY_OFDM(0xC0) /* CRS Threshold 1 (rev 1 only) */
  137. #define B43legacy_PHY_CRSTHRES2_R1 B43legacy_PHY_OFDM(0xC1) /* CRS Threshold 2 (rev 1 only) */
  138. #define B43legacy_PHY_TSSIP_LTBASE B43legacy_PHY_OFDM(0x380) /* TSSI power lookup table base */
  139. #define B43legacy_PHY_DC_LTBASE B43legacy_PHY_OFDM(0x3A0) /* DC lookup table base */
  140. #define B43legacy_PHY_GAIN_LTBASE B43legacy_PHY_OFDM(0x3C0) /* Gain lookup table base */
  141. void b43legacy_put_attenuation_into_ranges(int *_bbatt, int *_rfatt);
  142. /* Masks for the different PHY versioning registers. */
  143. #define B43legacy_PHYVER_ANALOG 0xF000
  144. #define B43legacy_PHYVER_ANALOG_SHIFT 12
  145. #define B43legacy_PHYVER_TYPE 0x0F00
  146. #define B43legacy_PHYVER_TYPE_SHIFT 8
  147. #define B43legacy_PHYVER_VERSION 0x00FF
  148. struct b43legacy_wldev;
  149. void b43legacy_phy_lock(struct b43legacy_wldev *dev);
  150. void b43legacy_phy_unlock(struct b43legacy_wldev *dev);
  151. /* Card uses the loopback gain stuff */
  152. #define has_loopback_gain(phy) \
  153. (((phy)->rev > 1) || ((phy)->gmode))
  154. u16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset);
  155. void b43legacy_phy_write(struct b43legacy_wldev *dev, u16 offset, u16 val);
  156. int b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev);
  157. int b43legacy_phy_init(struct b43legacy_wldev *dev);
  158. void b43legacy_set_rx_antenna(struct b43legacy_wldev *dev, int antenna);
  159. void b43legacy_phy_set_antenna_diversity(struct b43legacy_wldev *dev);
  160. void b43legacy_phy_calibrate(struct b43legacy_wldev *dev);
  161. int b43legacy_phy_connect(struct b43legacy_wldev *dev, int connect);
  162. void b43legacy_phy_lo_b_measure(struct b43legacy_wldev *dev);
  163. void b43legacy_phy_lo_g_measure(struct b43legacy_wldev *dev);
  164. void b43legacy_phy_xmitpower(struct b43legacy_wldev *dev);
  165. /* Adjust the LocalOscillator to the saved values.
  166. * "fixed" is only set to 1 once in initialization. Set to 0 otherwise.
  167. */
  168. void b43legacy_phy_lo_adjust(struct b43legacy_wldev *dev, int fixed);
  169. void b43legacy_phy_lo_mark_all_unused(struct b43legacy_wldev *dev);
  170. void b43legacy_phy_set_baseband_attenuation(struct b43legacy_wldev *dev,
  171. u16 baseband_attenuation);
  172. void b43legacy_power_saving_ctl_bits(struct b43legacy_wldev *dev,
  173. int bit25, int bit26);
  174. #endif /* B43legacy_PHY_H_ */