Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 1 | /* zd_rf.h |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 16 | */ |
| 17 | |
| 18 | #ifndef _ZD_RF_H |
| 19 | #define _ZD_RF_H |
| 20 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 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 |
Daniel Drake | f2a81a1 | 2007-03-11 19:54:28 +0000 | [diff] [blame] | 29 | #define UNKNOWN_A_RF 0xa |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 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 | |
| 36 | #define RF_CHANNEL(ch) [(ch)-1] |
| 37 | |
| 38 | /* Provides functions of the RF transceiver. */ |
| 39 | |
| 40 | enum { |
| 41 | RF_REG_BITS = 6, |
| 42 | RF_VALUE_BITS = 18, |
| 43 | RF_RV_BITS = RF_REG_BITS + RF_VALUE_BITS, |
| 44 | }; |
| 45 | |
| 46 | struct zd_rf { |
| 47 | u8 type; |
| 48 | |
| 49 | u8 channel; |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 50 | |
Daniel Drake | 9c8fc71 | 2007-05-24 01:06:41 +0100 | [diff] [blame] | 51 | /* whether channel integration and calibration should be updated |
| 52 | * defaults to 1 (yes) */ |
| 53 | u8 update_channel_int:1; |
| 54 | |
Daniel Drake | aaf83d4 | 2007-05-24 01:07:15 +0100 | [diff] [blame^] | 55 | /* whether CR47 should be patched from the EEPROM, if the appropriate |
| 56 | * flag is set in the POD. The vendor driver suggests that this should |
| 57 | * be done for all RF's, but a bug in their code prevents but their |
| 58 | * HW_OverWritePhyRegFromE2P() routine from ever taking effect. */ |
| 59 | u8 patch_cck_gain:1; |
| 60 | |
Daniel Drake | 9c8fc71 | 2007-05-24 01:06:41 +0100 | [diff] [blame] | 61 | /* private RF driver data */ |
| 62 | void *priv; |
| 63 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 64 | /* RF-specific functions */ |
| 65 | int (*init_hw)(struct zd_rf *rf); |
| 66 | int (*set_channel)(struct zd_rf *rf, u8 channel); |
| 67 | int (*switch_radio_on)(struct zd_rf *rf); |
| 68 | int (*switch_radio_off)(struct zd_rf *rf); |
Daniel Drake | 72018b22 | 2007-04-07 16:00:15 +0100 | [diff] [blame] | 69 | int (*patch_6m_band_edge)(struct zd_rf *rf, u8 channel); |
Daniel Drake | 9c8fc71 | 2007-05-24 01:06:41 +0100 | [diff] [blame] | 70 | void (*clear)(struct zd_rf *rf); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | const char *zd_rf_name(u8 type); |
| 74 | void zd_rf_init(struct zd_rf *rf); |
| 75 | void zd_rf_clear(struct zd_rf *rf); |
| 76 | int zd_rf_init_hw(struct zd_rf *rf, u8 type); |
| 77 | |
| 78 | int zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size); |
| 79 | |
| 80 | int zd_rf_set_channel(struct zd_rf *rf, u8 channel); |
| 81 | |
| 82 | int zd_switch_radio_on(struct zd_rf *rf); |
| 83 | int zd_switch_radio_off(struct zd_rf *rf); |
| 84 | |
Daniel Drake | 72018b22 | 2007-04-07 16:00:15 +0100 | [diff] [blame] | 85 | int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel); |
| 86 | int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel); |
| 87 | |
Daniel Drake | 9c8fc71 | 2007-05-24 01:06:41 +0100 | [diff] [blame] | 88 | static inline int zd_rf_should_update_pwr_int(struct zd_rf *rf) |
| 89 | { |
| 90 | return rf->update_channel_int; |
| 91 | } |
| 92 | |
Daniel Drake | aaf83d4 | 2007-05-24 01:07:15 +0100 | [diff] [blame^] | 93 | static inline int zd_rf_should_patch_cck_gain(struct zd_rf *rf) |
| 94 | { |
| 95 | return rf->patch_cck_gain; |
| 96 | } |
| 97 | |
| 98 | int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel); |
| 99 | int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel); |
| 100 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 101 | /* Functions for individual RF chips */ |
| 102 | |
| 103 | int zd_rf_init_rf2959(struct zd_rf *rf); |
| 104 | int zd_rf_init_al2230(struct zd_rf *rf); |
Daniel Drake | ec62bd9 | 2006-08-12 17:59:46 +0100 | [diff] [blame] | 105 | int zd_rf_init_al7230b(struct zd_rf *rf); |
Daniel Drake | 4481d60 | 2007-05-24 01:06:53 +0100 | [diff] [blame] | 106 | int zd_rf_init_uw2453(struct zd_rf *rf); |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 107 | |
| 108 | #endif /* _ZD_RF_H */ |