zd_rf.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* ZD1211 USB-WLAN driver for Linux
  2. *
  3. * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
  4. * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _ZD_RF_H
  20. #define _ZD_RF_H
  21. #define UW2451_RF 0x2
  22. #define UCHIP_RF 0x3
  23. #define AL2230_RF 0x4
  24. #define AL7230B_RF 0x5 /* a,b,g */
  25. #define THETA_RF 0x6
  26. #define AL2210_RF 0x7
  27. #define MAXIM_NEW_RF 0x8
  28. #define UW2453_RF 0x9
  29. #define AL2230S_RF 0xa
  30. #define RALINK_RF 0xb
  31. #define INTERSIL_RF 0xc
  32. #define RF2959_RF 0xd
  33. #define MAXIM_NEW2_RF 0xe
  34. #define PHILIPS_RF 0xf
  35. #define RF_CHANNEL(ch) [(ch)-1]
  36. /* Provides functions of the RF transceiver. */
  37. enum {
  38. RF_REG_BITS = 6,
  39. RF_VALUE_BITS = 18,
  40. RF_RV_BITS = RF_REG_BITS + RF_VALUE_BITS,
  41. };
  42. struct zd_rf {
  43. u8 type;
  44. u8 channel;
  45. /* whether channel integration and calibration should be updated
  46. * defaults to 1 (yes) */
  47. u8 update_channel_int:1;
  48. /* whether ZD_CR47 should be patched from the EEPROM, if the appropriate
  49. * flag is set in the POD. The vendor driver suggests that this should
  50. * be done for all RF's, but a bug in their code prevents but their
  51. * HW_OverWritePhyRegFromE2P() routine from ever taking effect. */
  52. u8 patch_cck_gain:1;
  53. /* private RF driver data */
  54. void *priv;
  55. /* RF-specific functions */
  56. int (*init_hw)(struct zd_rf *rf);
  57. int (*set_channel)(struct zd_rf *rf, u8 channel);
  58. int (*switch_radio_on)(struct zd_rf *rf);
  59. int (*switch_radio_off)(struct zd_rf *rf);
  60. int (*patch_6m_band_edge)(struct zd_rf *rf, u8 channel);
  61. void (*clear)(struct zd_rf *rf);
  62. };
  63. const char *zd_rf_name(u8 type);
  64. void zd_rf_init(struct zd_rf *rf);
  65. void zd_rf_clear(struct zd_rf *rf);
  66. int zd_rf_init_hw(struct zd_rf *rf, u8 type);
  67. int zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size);
  68. int zd_rf_set_channel(struct zd_rf *rf, u8 channel);
  69. int zd_switch_radio_on(struct zd_rf *rf);
  70. int zd_switch_radio_off(struct zd_rf *rf);
  71. int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel);
  72. int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel);
  73. static inline int zd_rf_should_update_pwr_int(struct zd_rf *rf)
  74. {
  75. return rf->update_channel_int;
  76. }
  77. static inline int zd_rf_should_patch_cck_gain(struct zd_rf *rf)
  78. {
  79. return rf->patch_cck_gain;
  80. }
  81. int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel);
  82. int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel);
  83. /* Functions for individual RF chips */
  84. int zd_rf_init_rf2959(struct zd_rf *rf);
  85. int zd_rf_init_al2230(struct zd_rf *rf);
  86. int zd_rf_init_al7230b(struct zd_rf *rf);
  87. int zd_rf_init_uw2453(struct zd_rf *rf);
  88. #endif /* _ZD_RF_H */