18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/* ZD1211 USB-WLAN driver for Linux
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
58c2ecf20Sopenharmony_ci * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ZD_RF_H
98c2ecf20Sopenharmony_ci#define _ZD_RF_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#define UW2451_RF			0x2
128c2ecf20Sopenharmony_ci#define UCHIP_RF			0x3
138c2ecf20Sopenharmony_ci#define AL2230_RF			0x4
148c2ecf20Sopenharmony_ci#define AL7230B_RF			0x5	/* a,b,g */
158c2ecf20Sopenharmony_ci#define THETA_RF			0x6
168c2ecf20Sopenharmony_ci#define AL2210_RF			0x7
178c2ecf20Sopenharmony_ci#define MAXIM_NEW_RF			0x8
188c2ecf20Sopenharmony_ci#define UW2453_RF			0x9
198c2ecf20Sopenharmony_ci#define AL2230S_RF			0xa
208c2ecf20Sopenharmony_ci#define RALINK_RF			0xb
218c2ecf20Sopenharmony_ci#define INTERSIL_RF			0xc
228c2ecf20Sopenharmony_ci#define RF2959_RF			0xd
238c2ecf20Sopenharmony_ci#define MAXIM_NEW2_RF			0xe
248c2ecf20Sopenharmony_ci#define PHILIPS_RF			0xf
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#define RF_CHANNEL(ch) [(ch)-1]
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci/* Provides functions of the RF transceiver. */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cienum {
318c2ecf20Sopenharmony_ci	RF_REG_BITS = 6,
328c2ecf20Sopenharmony_ci	RF_VALUE_BITS = 18,
338c2ecf20Sopenharmony_ci	RF_RV_BITS = RF_REG_BITS + RF_VALUE_BITS,
348c2ecf20Sopenharmony_ci};
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistruct zd_rf {
378c2ecf20Sopenharmony_ci	u8 type;
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci	u8 channel;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	/* whether channel integration and calibration should be updated
428c2ecf20Sopenharmony_ci	 * defaults to 1 (yes) */
438c2ecf20Sopenharmony_ci	u8 update_channel_int:1;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	/* whether ZD_CR47 should be patched from the EEPROM, if the appropriate
468c2ecf20Sopenharmony_ci	 * flag is set in the POD. The vendor driver suggests that this should
478c2ecf20Sopenharmony_ci	 * be done for all RF's, but a bug in their code prevents but their
488c2ecf20Sopenharmony_ci	 * HW_OverWritePhyRegFromE2P() routine from ever taking effect. */
498c2ecf20Sopenharmony_ci	u8 patch_cck_gain:1;
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	/* private RF driver data */
528c2ecf20Sopenharmony_ci	void *priv;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	/* RF-specific functions */
558c2ecf20Sopenharmony_ci	int (*init_hw)(struct zd_rf *rf);
568c2ecf20Sopenharmony_ci	int (*set_channel)(struct zd_rf *rf, u8 channel);
578c2ecf20Sopenharmony_ci	int (*switch_radio_on)(struct zd_rf *rf);
588c2ecf20Sopenharmony_ci	int (*switch_radio_off)(struct zd_rf *rf);
598c2ecf20Sopenharmony_ci	int (*patch_6m_band_edge)(struct zd_rf *rf, u8 channel);
608c2ecf20Sopenharmony_ci	void (*clear)(struct zd_rf *rf);
618c2ecf20Sopenharmony_ci};
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ciconst char *zd_rf_name(u8 type);
648c2ecf20Sopenharmony_civoid zd_rf_init(struct zd_rf *rf);
658c2ecf20Sopenharmony_civoid zd_rf_clear(struct zd_rf *rf);
668c2ecf20Sopenharmony_ciint zd_rf_init_hw(struct zd_rf *rf, u8 type);
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ciint zd_rf_scnprint_id(struct zd_rf *rf, char *buffer, size_t size);
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ciint zd_rf_set_channel(struct zd_rf *rf, u8 channel);
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciint zd_switch_radio_on(struct zd_rf *rf);
738c2ecf20Sopenharmony_ciint zd_switch_radio_off(struct zd_rf *rf);
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ciint zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel);
768c2ecf20Sopenharmony_ciint zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel);
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_cistatic inline int zd_rf_should_update_pwr_int(struct zd_rf *rf)
798c2ecf20Sopenharmony_ci{
808c2ecf20Sopenharmony_ci	return rf->update_channel_int;
818c2ecf20Sopenharmony_ci}
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic inline int zd_rf_should_patch_cck_gain(struct zd_rf *rf)
848c2ecf20Sopenharmony_ci{
858c2ecf20Sopenharmony_ci	return rf->patch_cck_gain;
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciint zd_rf_patch_6m_band_edge(struct zd_rf *rf, u8 channel);
898c2ecf20Sopenharmony_ciint zd_rf_generic_patch_6m(struct zd_rf *rf, u8 channel);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci/* Functions for individual RF chips */
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ciint zd_rf_init_rf2959(struct zd_rf *rf);
948c2ecf20Sopenharmony_ciint zd_rf_init_al2230(struct zd_rf *rf);
958c2ecf20Sopenharmony_ciint zd_rf_init_al7230b(struct zd_rf *rf);
968c2ecf20Sopenharmony_ciint zd_rf_init_uw2453(struct zd_rf *rf);
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci#endif /* _ZD_RF_H */
99