blob: 8f14e25e1041b875b25b8267829aac11542eb6c3 [file] [log] [blame]
Daniel Drake66bb42f2007-11-19 16:20:12 +00001/* 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>
Daniel Drakee85d0912006-06-02 17:11:32 +01005 *
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
Jeff Kirsherf47cdae2013-12-06 03:32:10 -080017 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Daniel Drakee85d0912006-06-02 17:11:32 +010018 */
19
20#ifndef _ZD_RF_H
21#define _ZD_RF_H
22
Daniel Drakee85d0912006-06-02 17:11:32 +010023#define UW2451_RF 0x2
24#define UCHIP_RF 0x3
25#define AL2230_RF 0x4
26#define AL7230B_RF 0x5 /* a,b,g */
27#define THETA_RF 0x6
28#define AL2210_RF 0x7
29#define MAXIM_NEW_RF 0x8
30#define UW2453_RF 0x9
Daniel Drake44185832007-07-01 18:22:04 +010031#define AL2230S_RF 0xa
Daniel Drakee85d0912006-06-02 17:11:32 +010032#define RALINK_RF 0xb
33#define INTERSIL_RF 0xc
34#define RF2959_RF 0xd
35#define MAXIM_NEW2_RF 0xe
36#define PHILIPS_RF 0xf
37
38#define RF_CHANNEL(ch) [(ch)-1]
39
40/* Provides functions of the RF transceiver. */
41
42enum {
43 RF_REG_BITS = 6,
44 RF_VALUE_BITS = 18,
45 RF_RV_BITS = RF_REG_BITS + RF_VALUE_BITS,
46};
47
48struct zd_rf {
49 u8 type;
50
51 u8 channel;
Daniel Drakee85d0912006-06-02 17:11:32 +010052
Daniel Drake9c8fc712007-05-24 01:06:41 +010053 /* whether channel integration and calibration should be updated
54 * defaults to 1 (yes) */
55 u8 update_channel_int:1;
56
Jussi Kivilinnafbd5d172011-04-02 11:25:54 +030057 /* whether ZD_CR47 should be patched from the EEPROM, if the appropriate
Daniel Drakeaaf83d42007-05-24 01:07:15 +010058 * flag is set in the POD. The vendor driver suggests that this should
59 * be done for all RF's, but a bug in their code prevents but their
60 * HW_OverWritePhyRegFromE2P() routine from ever taking effect. */
61 u8 patch_cck_gain:1;
62
Daniel Drake9c8fc712007-05-24 01:06:41 +010063 /* private RF driver data */
64 void *priv;
65
Daniel Drakee85d0912006-06-02 17:11:32 +010066 /* RF-specific functions */
67 int (*init_hw)(struct zd_rf *rf);
68 int (*set_channel)(struct zd_rf *rf, u8 channel);
69 int (*switch_radio_on)(struct zd_rf *rf);
70 int (*switch_radio_off)(struct zd_rf *rf);
Daniel Drake72018b222007-04-07 16:00:15 +010071 int (*patch_6m_band_edge)(struct zd_rf *rf, u8 channel);
Daniel Drake9c8fc712007-05-24 01:06:41 +010072 void (*clear)(struct zd_rf *rf);
Daniel Drakee85d0912006-06-02 17:11:32 +010073};
74
75const char *zd_rf_name(u8 type);
76void zd_rf_init(struct zd_rf *rf);
77void zd_rf_clear(struct zd_rf *rf);
78int zd_rf_init_hw(struct zd_rf *rf, u8 type);
79
80int zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size);
81
82int zd_rf_set_channel(struct zd_rf *rf, u8 channel);
83
84int zd_switch_radio_on(struct zd_rf *rf);
85int zd_switch_radio_off(struct zd_rf *rf);
86
Daniel Drake72018b222007-04-07 16:00:15 +010087int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel);
88int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel);
89
Daniel Drake9c8fc712007-05-24 01:06:41 +010090static inline int zd_rf_should_update_pwr_int(struct zd_rf *rf)
91{
92 return rf->update_channel_int;
93}
94
Daniel Drakeaaf83d42007-05-24 01:07:15 +010095static inline int zd_rf_should_patch_cck_gain(struct zd_rf *rf)
96{
97 return rf->patch_cck_gain;
98}
99
100int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel);
101int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel);
102
Daniel Drakee85d0912006-06-02 17:11:32 +0100103/* Functions for individual RF chips */
104
105int zd_rf_init_rf2959(struct zd_rf *rf);
106int zd_rf_init_al2230(struct zd_rf *rf);
Daniel Drakeec62bd92006-08-12 17:59:46 +0100107int zd_rf_init_al7230b(struct zd_rf *rf);
Daniel Drake4481d602007-05-24 01:06:53 +0100108int zd_rf_init_uw2453(struct zd_rf *rf);
Daniel Drakee85d0912006-06-02 17:11:32 +0100109
110#endif /* _ZD_RF_H */