162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef B43_LO_H_ 362306a36Sopenharmony_ci#define B43_LO_H_ 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci/* G-PHY Local Oscillator */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include "phy_g.h" 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct b43_wldev; 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci/* Local Oscillator control value-pair. */ 1262306a36Sopenharmony_cistruct b43_loctl { 1362306a36Sopenharmony_ci /* Control values. */ 1462306a36Sopenharmony_ci s8 i; 1562306a36Sopenharmony_ci s8 q; 1662306a36Sopenharmony_ci}; 1762306a36Sopenharmony_ci/* Debugging: Poison value for i and q values. */ 1862306a36Sopenharmony_ci#define B43_LOCTL_POISON 111 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* This struct holds calibrated LO settings for a set of 2162306a36Sopenharmony_ci * Baseband and RF attenuation settings. */ 2262306a36Sopenharmony_cistruct b43_lo_calib { 2362306a36Sopenharmony_ci /* The set of attenuation values this set of LO 2462306a36Sopenharmony_ci * control values is calibrated for. */ 2562306a36Sopenharmony_ci struct b43_bbatt bbatt; 2662306a36Sopenharmony_ci struct b43_rfatt rfatt; 2762306a36Sopenharmony_ci /* The set of control values for the LO. */ 2862306a36Sopenharmony_ci struct b43_loctl ctl; 2962306a36Sopenharmony_ci /* The time when these settings were calibrated (in jiffies) */ 3062306a36Sopenharmony_ci unsigned long calib_time; 3162306a36Sopenharmony_ci /* List. */ 3262306a36Sopenharmony_ci struct list_head list; 3362306a36Sopenharmony_ci}; 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* Size of the DC Lookup Table in 16bit words. */ 3662306a36Sopenharmony_ci#define B43_DC_LT_SIZE 32 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* Local Oscillator calibration information */ 3962306a36Sopenharmony_cistruct b43_txpower_lo_control { 4062306a36Sopenharmony_ci /* Lists of RF and BB attenuation values for this device. 4162306a36Sopenharmony_ci * Used for building hardware power control tables. */ 4262306a36Sopenharmony_ci struct b43_rfatt_list rfatt_list; 4362306a36Sopenharmony_ci struct b43_bbatt_list bbatt_list; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci /* The DC Lookup Table is cached in memory here. 4662306a36Sopenharmony_ci * Note that this is only used for Hardware Power Control. */ 4762306a36Sopenharmony_ci u16 dc_lt[B43_DC_LT_SIZE]; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci /* List of calibrated control values (struct b43_lo_calib). */ 5062306a36Sopenharmony_ci struct list_head calib_list; 5162306a36Sopenharmony_ci /* Last time the power vector was read (jiffies). */ 5262306a36Sopenharmony_ci unsigned long pwr_vec_read_time; 5362306a36Sopenharmony_ci /* Last time the txctl values were measured (jiffies). */ 5462306a36Sopenharmony_ci unsigned long txctl_measured_time; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci /* Current TX Bias value */ 5762306a36Sopenharmony_ci u8 tx_bias; 5862306a36Sopenharmony_ci /* Current TX Magnification Value (if used by the device) */ 5962306a36Sopenharmony_ci u8 tx_magn; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci /* Saved device PowerVector */ 6262306a36Sopenharmony_ci u64 power_vector; 6362306a36Sopenharmony_ci}; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* Calibration expire timeouts. 6662306a36Sopenharmony_ci * Timeouts must be multiple of 15 seconds. To make sure 6762306a36Sopenharmony_ci * the item really expired when the 15 second timer hits, we 6862306a36Sopenharmony_ci * subtract two additional seconds from the timeout. */ 6962306a36Sopenharmony_ci#define B43_LO_CALIB_EXPIRE (HZ * (30 - 2)) 7062306a36Sopenharmony_ci#define B43_LO_PWRVEC_EXPIRE (HZ * (30 - 2)) 7162306a36Sopenharmony_ci#define B43_LO_TXCTL_EXPIRE (HZ * (180 - 4)) 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* Adjust the Local Oscillator to the saved attenuation 7562306a36Sopenharmony_ci * and txctl values. 7662306a36Sopenharmony_ci */ 7762306a36Sopenharmony_civoid b43_lo_g_adjust(struct b43_wldev *dev); 7862306a36Sopenharmony_ci/* Adjust to specific values. */ 7962306a36Sopenharmony_civoid b43_lo_g_adjust_to(struct b43_wldev *dev, 8062306a36Sopenharmony_ci u16 rfatt, u16 bbatt, u16 tx_control); 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_civoid b43_gphy_dc_lt_init(struct b43_wldev *dev, bool update_all); 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_civoid b43_lo_g_maintenance_work(struct b43_wldev *dev); 8562306a36Sopenharmony_civoid b43_lo_g_cleanup(struct b43_wldev *dev); 8662306a36Sopenharmony_civoid b43_lo_g_init(struct b43_wldev *dev); 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#endif /* B43_LO_H_ */ 89