18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef B43_LO_H_ 38c2ecf20Sopenharmony_ci#define B43_LO_H_ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* G-PHY Local Oscillator */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include "phy_g.h" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cistruct b43_wldev; 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* Local Oscillator control value-pair. */ 128c2ecf20Sopenharmony_cistruct b43_loctl { 138c2ecf20Sopenharmony_ci /* Control values. */ 148c2ecf20Sopenharmony_ci s8 i; 158c2ecf20Sopenharmony_ci s8 q; 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci/* Debugging: Poison value for i and q values. */ 188c2ecf20Sopenharmony_ci#define B43_LOCTL_POISON 111 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* This struct holds calibrated LO settings for a set of 218c2ecf20Sopenharmony_ci * Baseband and RF attenuation settings. */ 228c2ecf20Sopenharmony_cistruct b43_lo_calib { 238c2ecf20Sopenharmony_ci /* The set of attenuation values this set of LO 248c2ecf20Sopenharmony_ci * control values is calibrated for. */ 258c2ecf20Sopenharmony_ci struct b43_bbatt bbatt; 268c2ecf20Sopenharmony_ci struct b43_rfatt rfatt; 278c2ecf20Sopenharmony_ci /* The set of control values for the LO. */ 288c2ecf20Sopenharmony_ci struct b43_loctl ctl; 298c2ecf20Sopenharmony_ci /* The time when these settings were calibrated (in jiffies) */ 308c2ecf20Sopenharmony_ci unsigned long calib_time; 318c2ecf20Sopenharmony_ci /* List. */ 328c2ecf20Sopenharmony_ci struct list_head list; 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* Size of the DC Lookup Table in 16bit words. */ 368c2ecf20Sopenharmony_ci#define B43_DC_LT_SIZE 32 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* Local Oscillator calibration information */ 398c2ecf20Sopenharmony_cistruct b43_txpower_lo_control { 408c2ecf20Sopenharmony_ci /* Lists of RF and BB attenuation values for this device. 418c2ecf20Sopenharmony_ci * Used for building hardware power control tables. */ 428c2ecf20Sopenharmony_ci struct b43_rfatt_list rfatt_list; 438c2ecf20Sopenharmony_ci struct b43_bbatt_list bbatt_list; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci /* The DC Lookup Table is cached in memory here. 468c2ecf20Sopenharmony_ci * Note that this is only used for Hardware Power Control. */ 478c2ecf20Sopenharmony_ci u16 dc_lt[B43_DC_LT_SIZE]; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci /* List of calibrated control values (struct b43_lo_calib). */ 508c2ecf20Sopenharmony_ci struct list_head calib_list; 518c2ecf20Sopenharmony_ci /* Last time the power vector was read (jiffies). */ 528c2ecf20Sopenharmony_ci unsigned long pwr_vec_read_time; 538c2ecf20Sopenharmony_ci /* Last time the txctl values were measured (jiffies). */ 548c2ecf20Sopenharmony_ci unsigned long txctl_measured_time; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* Current TX Bias value */ 578c2ecf20Sopenharmony_ci u8 tx_bias; 588c2ecf20Sopenharmony_ci /* Current TX Magnification Value (if used by the device) */ 598c2ecf20Sopenharmony_ci u8 tx_magn; 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci /* Saved device PowerVector */ 628c2ecf20Sopenharmony_ci u64 power_vector; 638c2ecf20Sopenharmony_ci}; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* Calibration expire timeouts. 668c2ecf20Sopenharmony_ci * Timeouts must be multiple of 15 seconds. To make sure 678c2ecf20Sopenharmony_ci * the item really expired when the 15 second timer hits, we 688c2ecf20Sopenharmony_ci * subtract two additional seconds from the timeout. */ 698c2ecf20Sopenharmony_ci#define B43_LO_CALIB_EXPIRE (HZ * (30 - 2)) 708c2ecf20Sopenharmony_ci#define B43_LO_PWRVEC_EXPIRE (HZ * (30 - 2)) 718c2ecf20Sopenharmony_ci#define B43_LO_TXCTL_EXPIRE (HZ * (180 - 4)) 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* Adjust the Local Oscillator to the saved attenuation 758c2ecf20Sopenharmony_ci * and txctl values. 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_civoid b43_lo_g_adjust(struct b43_wldev *dev); 788c2ecf20Sopenharmony_ci/* Adjust to specific values. */ 798c2ecf20Sopenharmony_civoid b43_lo_g_adjust_to(struct b43_wldev *dev, 808c2ecf20Sopenharmony_ci u16 rfatt, u16 bbatt, u16 tx_control); 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_civoid b43_gphy_dc_lt_init(struct b43_wldev *dev, bool update_all); 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_civoid b43_lo_g_maintenance_work(struct b43_wldev *dev); 858c2ecf20Sopenharmony_civoid b43_lo_g_cleanup(struct b43_wldev *dev); 868c2ecf20Sopenharmony_civoid b43_lo_g_init(struct b43_wldev *dev); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#endif /* B43_LO_H_ */ 89