phy_g.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #ifndef LINUX_B43_PHY_G_H_
  2. #define LINUX_B43_PHY_G_H_
  3. /* OFDM PHY registers are defined in the A-PHY header. */
  4. #include "phy_a.h"
  5. /* CCK (B) PHY Registers */
  6. #define B43_PHY_VERSION_CCK B43_PHY_CCK(0x00) /* Versioning register for B-PHY */
  7. #define B43_PHY_CCKBBANDCFG B43_PHY_CCK(0x01) /* Contains antenna 0/1 control bit */
  8. #define B43_PHY_PGACTL B43_PHY_CCK(0x15) /* PGA control */
  9. #define B43_PHY_PGACTL_LPF 0x1000 /* Low pass filter (?) */
  10. #define B43_PHY_PGACTL_LOWBANDW 0x0040 /* Low bandwidth flag */
  11. #define B43_PHY_PGACTL_UNKNOWN 0xEFA0
  12. #define B43_PHY_FBCTL1 B43_PHY_CCK(0x18) /* Frequency bandwidth control 1 */
  13. #define B43_PHY_ITSSI B43_PHY_CCK(0x29) /* Idle TSSI */
  14. #define B43_PHY_LO_LEAKAGE B43_PHY_CCK(0x2D) /* Measured LO leakage */
  15. #define B43_PHY_ENERGY B43_PHY_CCK(0x33) /* Energy */
  16. #define B43_PHY_SYNCCTL B43_PHY_CCK(0x35)
  17. #define B43_PHY_FBCTL2 B43_PHY_CCK(0x38) /* Frequency bandwidth control 2 */
  18. #define B43_PHY_DACCTL B43_PHY_CCK(0x60) /* DAC control */
  19. #define B43_PHY_RCCALOVER B43_PHY_CCK(0x78) /* RC calibration override */
  20. /* Extended G-PHY Registers */
  21. #define B43_PHY_CLASSCTL B43_PHY_EXTG(0x02) /* Classify control */
  22. #define B43_PHY_GTABCTL B43_PHY_EXTG(0x03) /* G-PHY table control (see below) */
  23. #define B43_PHY_GTABOFF 0x03FF /* G-PHY table offset (see below) */
  24. #define B43_PHY_GTABNR 0xFC00 /* G-PHY table number (see below) */
  25. #define B43_PHY_GTABNR_SHIFT 10
  26. #define B43_PHY_GTABDATA B43_PHY_EXTG(0x04) /* G-PHY table data */
  27. #define B43_PHY_LO_MASK B43_PHY_EXTG(0x0F) /* Local Oscillator control mask */
  28. #define B43_PHY_LO_CTL B43_PHY_EXTG(0x10) /* Local Oscillator control */
  29. #define B43_PHY_RFOVER B43_PHY_EXTG(0x11) /* RF override */
  30. #define B43_PHY_RFOVERVAL B43_PHY_EXTG(0x12) /* RF override value */
  31. #define B43_PHY_RFOVERVAL_EXTLNA 0x8000
  32. #define B43_PHY_RFOVERVAL_LNA 0x7000
  33. #define B43_PHY_RFOVERVAL_LNA_SHIFT 12
  34. #define B43_PHY_RFOVERVAL_PGA 0x0F00
  35. #define B43_PHY_RFOVERVAL_PGA_SHIFT 8
  36. #define B43_PHY_RFOVERVAL_UNK 0x0010 /* Unknown, always set. */
  37. #define B43_PHY_RFOVERVAL_TRSWRX 0x00E0
  38. #define B43_PHY_RFOVERVAL_BW 0x0003 /* Bandwidth flags */
  39. #define B43_PHY_RFOVERVAL_BW_LPF 0x0001 /* Low Pass Filter */
  40. #define B43_PHY_RFOVERVAL_BW_LBW 0x0002 /* Low Bandwidth (when set), high when unset */
  41. #define B43_PHY_ANALOGOVER B43_PHY_EXTG(0x14) /* Analog override */
  42. #define B43_PHY_ANALOGOVERVAL B43_PHY_EXTG(0x15) /* Analog override value */
  43. /*** G-PHY table numbers */
  44. #define B43_GTAB(number, offset) (((number) << B43_PHY_GTABNR_SHIFT) | (offset))
  45. #define B43_GTAB_NRSSI B43_GTAB(0x00, 0)
  46. #define B43_GTAB_TRFEMW B43_GTAB(0x0C, 0x120)
  47. #define B43_GTAB_ORIGTR B43_GTAB(0x2E, 0x298)
  48. u16 b43_gtab_read(struct b43_wldev *dev, u16 table, u16 offset);
  49. void b43_gtab_write(struct b43_wldev *dev, u16 table, u16 offset, u16 value);
  50. /* Returns the boolean whether "TX Magnification" is enabled. */
  51. #define has_tx_magnification(phy) \
  52. (((phy)->rev >= 2) && \
  53. ((phy)->radio_ver == 0x2050) && \
  54. ((phy)->radio_rev == 8))
  55. /* Card uses the loopback gain stuff */
  56. #define has_loopback_gain(phy) \
  57. (((phy)->rev > 1) || ((phy)->gmode))
  58. /* Radio Attenuation (RF Attenuation) */
  59. struct b43_rfatt {
  60. u8 att; /* Attenuation value */
  61. bool with_padmix; /* Flag, PAD Mixer enabled. */
  62. };
  63. struct b43_rfatt_list {
  64. /* Attenuation values list */
  65. const struct b43_rfatt *list;
  66. u8 len;
  67. /* Minimum/Maximum attenuation values */
  68. u8 min_val;
  69. u8 max_val;
  70. };
  71. /* Returns true, if the values are the same. */
  72. static inline bool b43_compare_rfatt(const struct b43_rfatt *a,
  73. const struct b43_rfatt *b)
  74. {
  75. return ((a->att == b->att) &&
  76. (a->with_padmix == b->with_padmix));
  77. }
  78. /* Baseband Attenuation */
  79. struct b43_bbatt {
  80. u8 att; /* Attenuation value */
  81. };
  82. struct b43_bbatt_list {
  83. /* Attenuation values list */
  84. const struct b43_bbatt *list;
  85. u8 len;
  86. /* Minimum/Maximum attenuation values */
  87. u8 min_val;
  88. u8 max_val;
  89. };
  90. /* Returns true, if the values are the same. */
  91. static inline bool b43_compare_bbatt(const struct b43_bbatt *a,
  92. const struct b43_bbatt *b)
  93. {
  94. return (a->att == b->att);
  95. }
  96. /* tx_control bits. */
  97. #define B43_TXCTL_PA3DB 0x40 /* PA Gain 3dB */
  98. #define B43_TXCTL_PA2DB 0x20 /* PA Gain 2dB */
  99. #define B43_TXCTL_TXMIX 0x10 /* TX Mixer Gain */
  100. struct b43_txpower_lo_control;
  101. struct b43_phy_g {
  102. /* ACI (adjacent channel interference) flags. */
  103. bool aci_enable;
  104. bool aci_wlan_automatic;
  105. bool aci_hw_rssi;
  106. /* Radio switched on/off */
  107. bool radio_on;
  108. struct {
  109. /* Values saved when turning the radio off.
  110. * They are needed when turning it on again. */
  111. bool valid;
  112. u16 rfover;
  113. u16 rfoverval;
  114. } radio_off_context;
  115. u16 minlowsig[2];
  116. u16 minlowsigpos[2];
  117. /* Pointer to the table used to convert a
  118. * TSSI value to dBm-Q5.2 */
  119. const s8 *tssi2dbm;
  120. /* tssi2dbm is kmalloc()ed. Only used for free()ing. */
  121. bool dyn_tssi_tbl;
  122. /* Target idle TSSI */
  123. int tgt_idle_tssi;
  124. /* Current idle TSSI */
  125. int cur_idle_tssi;
  126. /* The current average TSSI. */
  127. u8 average_tssi;
  128. /* Current TX power level attenuation control values */
  129. struct b43_bbatt bbatt;
  130. struct b43_rfatt rfatt;
  131. u8 tx_control; /* B43_TXCTL_XXX */
  132. /* The calculated attenuation deltas that are used later
  133. * when adjusting the actual power output. */
  134. int bbatt_delta;
  135. int rfatt_delta;
  136. /* LocalOscillator control values. */
  137. struct b43_txpower_lo_control *lo_control;
  138. /* Values from b43_calc_loopback_gain() */
  139. s16 max_lb_gain; /* Maximum Loopback gain in hdB */
  140. s16 trsw_rx_gain; /* TRSW RX gain in hdB */
  141. s16 lna_lod_gain; /* LNA lod */
  142. s16 lna_gain; /* LNA */
  143. s16 pga_gain; /* PGA */
  144. /* Current Interference Mitigation mode */
  145. int interfmode;
  146. /* Stack of saved values from the Interference Mitigation code.
  147. * Each value in the stack is laid out as follows:
  148. * bit 0-11: offset
  149. * bit 12-15: register ID
  150. * bit 16-32: value
  151. * register ID is: 0x1 PHY, 0x2 Radio, 0x3 ILT
  152. */
  153. #define B43_INTERFSTACK_SIZE 26
  154. u32 interfstack[B43_INTERFSTACK_SIZE]; //FIXME: use a data structure
  155. /* Saved values from the NRSSI Slope calculation */
  156. s16 nrssi[2];
  157. s32 nrssislope;
  158. /* In memory nrssi lookup table. */
  159. s8 nrssi_lt[64];
  160. u16 lofcal;
  161. u16 initval; //FIXME rename?
  162. /* The device does address auto increment for the OFDM tables.
  163. * We cache the previously used address here and omit the address
  164. * write on the next table access, if possible. */
  165. u16 ofdmtab_addr; /* The address currently set in hardware. */
  166. enum { /* The last data flow direction. */
  167. B43_OFDMTAB_DIRECTION_UNKNOWN = 0,
  168. B43_OFDMTAB_DIRECTION_READ,
  169. B43_OFDMTAB_DIRECTION_WRITE,
  170. } ofdmtab_addr_direction;
  171. };
  172. void b43_gphy_set_baseband_attenuation(struct b43_wldev *dev,
  173. u16 baseband_attenuation);
  174. void b43_gphy_channel_switch(struct b43_wldev *dev,
  175. unsigned int channel,
  176. bool synthetic_pu_workaround);
  177. u8 * b43_generate_dyn_tssi2dbm_tab(struct b43_wldev *dev,
  178. s16 pab0, s16 pab1, s16 pab2);
  179. struct b43_phy_operations;
  180. extern const struct b43_phy_operations b43_phyops_g;
  181. #endif /* LINUX_B43_PHY_G_H_ */