1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* ZD1211 USB-WLAN driver for Linux 3 * 4 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> 5 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> 6 */ 7 8 #ifndef _ZD_RF_H 9 #define _ZD_RF_H 10 11 #define UW2451_RF 0x2 12 #define UCHIP_RF 0x3 13 #define AL2230_RF 0x4 14 #define AL7230B_RF 0x5 /* a,b,g */ 15 #define THETA_RF 0x6 16 #define AL2210_RF 0x7 17 #define MAXIM_NEW_RF 0x8 18 #define UW2453_RF 0x9 19 #define AL2230S_RF 0xa 20 #define RALINK_RF 0xb 21 #define INTERSIL_RF 0xc 22 #define RF2959_RF 0xd 23 #define MAXIM_NEW2_RF 0xe 24 #define PHILIPS_RF 0xf 25 26 #define RF_CHANNEL(ch) [(ch)-1] 27 28 /* Provides functions of the RF transceiver. */ 29 30 enum { 31 RF_REG_BITS = 6, 32 RF_VALUE_BITS = 18, 33 RF_RV_BITS = RF_REG_BITS + RF_VALUE_BITS, 34 }; 35 36 struct zd_rf { 37 u8 type; 38 39 u8 channel; 40 41 /* whether channel integration and calibration should be updated 42 * defaults to 1 (yes) */ 43 u8 update_channel_int:1; 44 45 /* whether ZD_CR47 should be patched from the EEPROM, if the appropriate 46 * flag is set in the POD. The vendor driver suggests that this should 47 * be done for all RF's, but a bug in their code prevents but their 48 * HW_OverWritePhyRegFromE2P() routine from ever taking effect. */ 49 u8 patch_cck_gain:1; 50 51 /* private RF driver data */ 52 void *priv; 53 54 /* RF-specific functions */ 55 int (*init_hw)(struct zd_rf *rf); 56 int (*set_channel)(struct zd_rf *rf, u8 channel); 57 int (*switch_radio_on)(struct zd_rf *rf); 58 int (*switch_radio_off)(struct zd_rf *rf); 59 int (*patch_6m_band_edge)(struct zd_rf *rf, u8 channel); 60 void (*clear)(struct zd_rf *rf); 61 }; 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 68 int zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size); 69 70 int zd_rf_set_channel(struct zd_rf *rf, u8 channel); 71 72 int zd_switch_radio_on(struct zd_rf *rf); 73 int zd_switch_radio_off(struct zd_rf *rf); 74 75 int zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel); 76 int zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel); 77 78 static inline int zd_rf_should_update_pwr_int(struct zd_rf *rf) 79 { 80 return rf->update_channel_int; 81 } 82 83 static inline int zd_rf_should_patch_cck_gain(struct zd_rf *rf) 84 { 85 return rf->patch_cck_gain; 86 } 87 88 /* Functions for individual RF chips */ 89 90 int zd_rf_init_rf2959(struct zd_rf *rf); 91 int zd_rf_init_al2230(struct zd_rf *rf); 92 int zd_rf_init_al7230b(struct zd_rf *rf); 93 int zd_rf_init_uw2453(struct zd_rf *rf); 94 95 #endif /* _ZD_RF_H */ 96