xref: /linux/drivers/net/wireless/broadcom/b43/lo.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
258619b14SKalle Valo #ifndef B43_LO_H_
358619b14SKalle Valo #define B43_LO_H_
458619b14SKalle Valo 
558619b14SKalle Valo /* G-PHY Local Oscillator */
658619b14SKalle Valo 
758619b14SKalle Valo #include "phy_g.h"
858619b14SKalle Valo 
958619b14SKalle Valo struct b43_wldev;
1058619b14SKalle Valo 
1158619b14SKalle Valo /* Local Oscillator control value-pair. */
1258619b14SKalle Valo struct b43_loctl {
1358619b14SKalle Valo 	/* Control values. */
1458619b14SKalle Valo 	s8 i;
1558619b14SKalle Valo 	s8 q;
1658619b14SKalle Valo };
1758619b14SKalle Valo /* Debugging: Poison value for i and q values. */
1858619b14SKalle Valo #define B43_LOCTL_POISON	111
1958619b14SKalle Valo 
2058619b14SKalle Valo /* This struct holds calibrated LO settings for a set of
2158619b14SKalle Valo  * Baseband and RF attenuation settings. */
2258619b14SKalle Valo struct b43_lo_calib {
2358619b14SKalle Valo 	/* The set of attenuation values this set of LO
2458619b14SKalle Valo 	 * control values is calibrated for. */
2558619b14SKalle Valo 	struct b43_bbatt bbatt;
2658619b14SKalle Valo 	struct b43_rfatt rfatt;
2758619b14SKalle Valo 	/* The set of control values for the LO. */
2858619b14SKalle Valo 	struct b43_loctl ctl;
2958619b14SKalle Valo 	/* The time when these settings were calibrated (in jiffies) */
3058619b14SKalle Valo 	unsigned long calib_time;
3158619b14SKalle Valo 	/* List. */
3258619b14SKalle Valo 	struct list_head list;
3358619b14SKalle Valo };
3458619b14SKalle Valo 
3558619b14SKalle Valo /* Size of the DC Lookup Table in 16bit words. */
3658619b14SKalle Valo #define B43_DC_LT_SIZE		32
3758619b14SKalle Valo 
3858619b14SKalle Valo /* Local Oscillator calibration information */
3958619b14SKalle Valo struct b43_txpower_lo_control {
4058619b14SKalle Valo 	/* Lists of RF and BB attenuation values for this device.
4158619b14SKalle Valo 	 * Used for building hardware power control tables. */
4258619b14SKalle Valo 	struct b43_rfatt_list rfatt_list;
4358619b14SKalle Valo 	struct b43_bbatt_list bbatt_list;
4458619b14SKalle Valo 
4558619b14SKalle Valo 	/* The DC Lookup Table is cached in memory here.
4658619b14SKalle Valo 	 * Note that this is only used for Hardware Power Control. */
4758619b14SKalle Valo 	u16 dc_lt[B43_DC_LT_SIZE];
4858619b14SKalle Valo 
4958619b14SKalle Valo 	/* List of calibrated control values (struct b43_lo_calib). */
5058619b14SKalle Valo 	struct list_head calib_list;
5158619b14SKalle Valo 	/* Last time the power vector was read (jiffies). */
5258619b14SKalle Valo 	unsigned long pwr_vec_read_time;
5358619b14SKalle Valo 	/* Last time the txctl values were measured (jiffies). */
5458619b14SKalle Valo 	unsigned long txctl_measured_time;
5558619b14SKalle Valo 
5658619b14SKalle Valo 	/* Current TX Bias value */
5758619b14SKalle Valo 	u8 tx_bias;
5858619b14SKalle Valo 	/* Current TX Magnification Value (if used by the device) */
5958619b14SKalle Valo 	u8 tx_magn;
6058619b14SKalle Valo 
6158619b14SKalle Valo 	/* Saved device PowerVector */
6258619b14SKalle Valo 	u64 power_vector;
6358619b14SKalle Valo };
6458619b14SKalle Valo 
6558619b14SKalle Valo /* Calibration expire timeouts.
6658619b14SKalle Valo  * Timeouts must be multiple of 15 seconds. To make sure
6758619b14SKalle Valo  * the item really expired when the 15 second timer hits, we
6858619b14SKalle Valo  * subtract two additional seconds from the timeout. */
6958619b14SKalle Valo #define B43_LO_CALIB_EXPIRE	(HZ * (30 - 2))
7058619b14SKalle Valo #define B43_LO_PWRVEC_EXPIRE	(HZ * (30 - 2))
7158619b14SKalle Valo #define B43_LO_TXCTL_EXPIRE	(HZ * (180 - 4))
7258619b14SKalle Valo 
7358619b14SKalle Valo 
7458619b14SKalle Valo /* Adjust the Local Oscillator to the saved attenuation
7558619b14SKalle Valo  * and txctl values.
7658619b14SKalle Valo  */
7758619b14SKalle Valo void b43_lo_g_adjust(struct b43_wldev *dev);
7858619b14SKalle Valo /* Adjust to specific values. */
7958619b14SKalle Valo void b43_lo_g_adjust_to(struct b43_wldev *dev,
8058619b14SKalle Valo 			u16 rfatt, u16 bbatt, u16 tx_control);
8158619b14SKalle Valo 
8258619b14SKalle Valo void b43_gphy_dc_lt_init(struct b43_wldev *dev, bool update_all);
8358619b14SKalle Valo 
8458619b14SKalle Valo void b43_lo_g_maintenance_work(struct b43_wldev *dev);
8558619b14SKalle Valo void b43_lo_g_cleanup(struct b43_wldev *dev);
8658619b14SKalle Valo void b43_lo_g_init(struct b43_wldev *dev);
8758619b14SKalle Valo 
8858619b14SKalle Valo #endif /* B43_LO_H_ */
89