18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci Broadcom B43legacy wireless driver 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>, 78c2ecf20Sopenharmony_ci Stefano Brivio <stefano.brivio@polimi.it> 88c2ecf20Sopenharmony_ci Michael Buesch <m@bues.ch> 98c2ecf20Sopenharmony_ci Danny van Dyk <kugelfang@gentoo.org> 108c2ecf20Sopenharmony_ci Andreas Jaggi <andreas.jaggi@waterwave.ch> 118c2ecf20Sopenharmony_ci Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci Some parts of the code in this file are derived from the ipw2200 148c2ecf20Sopenharmony_ci driver Copyright(c) 2003 - 2004 Intel Corporation. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci*/ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifndef B43legacy_PHY_H_ 208c2ecf20Sopenharmony_ci#define B43legacy_PHY_H_ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include <linux/types.h> 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_cienum { 258c2ecf20Sopenharmony_ci B43legacy_ANTENNA0, /* Antenna 0 */ 268c2ecf20Sopenharmony_ci B43legacy_ANTENNA1, /* Antenna 0 */ 278c2ecf20Sopenharmony_ci B43legacy_ANTENNA_AUTO1, /* Automatic, starting with antenna 1 */ 288c2ecf20Sopenharmony_ci B43legacy_ANTENNA_AUTO0, /* Automatic, starting with antenna 0 */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci B43legacy_ANTENNA_AUTO = B43legacy_ANTENNA_AUTO0, 318c2ecf20Sopenharmony_ci B43legacy_ANTENNA_DEFAULT = B43legacy_ANTENNA_AUTO, 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cienum { 358c2ecf20Sopenharmony_ci B43legacy_INTERFMODE_NONE, 368c2ecf20Sopenharmony_ci B43legacy_INTERFMODE_NONWLAN, 378c2ecf20Sopenharmony_ci B43legacy_INTERFMODE_MANUALWLAN, 388c2ecf20Sopenharmony_ci B43legacy_INTERFMODE_AUTOWLAN, 398c2ecf20Sopenharmony_ci}; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/*** PHY Registers ***/ 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Routing */ 448c2ecf20Sopenharmony_ci#define B43legacy_PHYROUTE_OFDM_GPHY 0x400 458c2ecf20Sopenharmony_ci#define B43legacy_PHYROUTE_EXT_GPHY 0x800 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* Base registers. */ 488c2ecf20Sopenharmony_ci#define B43legacy_PHY_BASE(reg) (reg) 498c2ecf20Sopenharmony_ci/* OFDM (A) registers of a G-PHY */ 508c2ecf20Sopenharmony_ci#define B43legacy_PHY_OFDM(reg) ((reg) | B43legacy_PHYROUTE_OFDM_GPHY) 518c2ecf20Sopenharmony_ci/* Extended G-PHY registers */ 528c2ecf20Sopenharmony_ci#define B43legacy_PHY_EXTG(reg) ((reg) | B43legacy_PHYROUTE_EXT_GPHY) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* Extended G-PHY Registers */ 568c2ecf20Sopenharmony_ci#define B43legacy_PHY_CLASSCTL B43legacy_PHY_EXTG(0x02) /* Classify control */ 578c2ecf20Sopenharmony_ci#define B43legacy_PHY_GTABCTL B43legacy_PHY_EXTG(0x03) /* G-PHY table control (see below) */ 588c2ecf20Sopenharmony_ci#define B43legacy_PHY_GTABOFF 0x03FF /* G-PHY table offset (see below) */ 598c2ecf20Sopenharmony_ci#define B43legacy_PHY_GTABNR 0xFC00 /* G-PHY table number (see below) */ 608c2ecf20Sopenharmony_ci#define B43legacy_PHY_GTABNR_SHIFT 10 618c2ecf20Sopenharmony_ci#define B43legacy_PHY_GTABDATA B43legacy_PHY_EXTG(0x04) /* G-PHY table data */ 628c2ecf20Sopenharmony_ci#define B43legacy_PHY_LO_MASK B43legacy_PHY_EXTG(0x0F) /* Local Oscillator control mask */ 638c2ecf20Sopenharmony_ci#define B43legacy_PHY_LO_CTL B43legacy_PHY_EXTG(0x10) /* Local Oscillator control */ 648c2ecf20Sopenharmony_ci#define B43legacy_PHY_RFOVER B43legacy_PHY_EXTG(0x11) /* RF override */ 658c2ecf20Sopenharmony_ci#define B43legacy_PHY_RFOVERVAL B43legacy_PHY_EXTG(0x12) /* RF override value */ 668c2ecf20Sopenharmony_ci/*** OFDM table numbers ***/ 678c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB(number, offset) \ 688c2ecf20Sopenharmony_ci (((number) << B43legacy_PHY_OTABLENR_SHIFT) \ 698c2ecf20Sopenharmony_ci | (offset)) 708c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_AGC1 B43legacy_OFDMTAB(0x00, 0) 718c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_GAIN0 B43legacy_OFDMTAB(0x00, 0) 728c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_GAINX B43legacy_OFDMTAB(0x01, 0) 738c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_GAIN1 B43legacy_OFDMTAB(0x01, 4) 748c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_AGC3 B43legacy_OFDMTAB(0x02, 0) 758c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_GAIN2 B43legacy_OFDMTAB(0x02, 3) 768c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_LNAHPFGAIN1 B43legacy_OFDMTAB(0x03, 0) 778c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_WRSSI B43legacy_OFDMTAB(0x04, 0) 788c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_LNAHPFGAIN2 B43legacy_OFDMTAB(0x04, 0) 798c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_NOISESCALE B43legacy_OFDMTAB(0x05, 0) 808c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_AGC2 B43legacy_OFDMTAB(0x06, 0) 818c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_ROTOR B43legacy_OFDMTAB(0x08, 0) 828c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_ADVRETARD B43legacy_OFDMTAB(0x09, 0) 838c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_DAC B43legacy_OFDMTAB(0x0C, 0) 848c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_DC B43legacy_OFDMTAB(0x0E, 7) 858c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_PWRDYN2 B43legacy_OFDMTAB(0x0E, 12) 868c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_LNAGAIN B43legacy_OFDMTAB(0x0E, 13) 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_LPFGAIN B43legacy_OFDMTAB(0x0F, 12) 898c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_RSSI B43legacy_OFDMTAB(0x10, 0) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_AGC1_R1 B43legacy_OFDMTAB(0x13, 0) 928c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_GAINX_R1 B43legacy_OFDMTAB(0x14, 0) 938c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_MINSIGSQ B43legacy_OFDMTAB(0x14, 1) 948c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_AGC3_R1 B43legacy_OFDMTAB(0x15, 0) 958c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_WRSSI_R1 B43legacy_OFDMTAB(0x15, 4) 968c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_TSSI B43legacy_OFDMTAB(0x15, 0) 978c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_DACRFPABB B43legacy_OFDMTAB(0x16, 0) 988c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_DACOFF B43legacy_OFDMTAB(0x17, 0) 998c2ecf20Sopenharmony_ci#define B43legacy_OFDMTAB_DCBIAS B43legacy_OFDMTAB(0x18, 0) 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_civoid b43legacy_put_attenuation_into_ranges(int *_bbatt, int *_rfatt); 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci/* OFDM (A) PHY Registers */ 1048c2ecf20Sopenharmony_ci#define B43legacy_PHY_VERSION_OFDM B43legacy_PHY_OFDM(0x00) /* Versioning register for A-PHY */ 1058c2ecf20Sopenharmony_ci#define B43legacy_PHY_BBANDCFG B43legacy_PHY_OFDM(0x01) /* Baseband config */ 1068c2ecf20Sopenharmony_ci#define B43legacy_PHY_BBANDCFG_RXANT 0x180 /* RX Antenna selection */ 1078c2ecf20Sopenharmony_ci#define B43legacy_PHY_BBANDCFG_RXANT_SHIFT 7 1088c2ecf20Sopenharmony_ci#define B43legacy_PHY_PWRDOWN B43legacy_PHY_OFDM(0x03) /* Powerdown */ 1098c2ecf20Sopenharmony_ci#define B43legacy_PHY_CRSTHRES1 B43legacy_PHY_OFDM(0x06) /* CRS Threshold 1 */ 1108c2ecf20Sopenharmony_ci#define B43legacy_PHY_LNAHPFCTL B43legacy_PHY_OFDM(0x1C) /* LNA/HPF control */ 1118c2ecf20Sopenharmony_ci#define B43legacy_PHY_ADIVRELATED B43legacy_PHY_OFDM(0x27) /* FIXME rename */ 1128c2ecf20Sopenharmony_ci#define B43legacy_PHY_CRS0 B43legacy_PHY_OFDM(0x29) 1138c2ecf20Sopenharmony_ci#define B43legacy_PHY_ANTDWELL B43legacy_PHY_OFDM(0x2B) /* Antenna dwell */ 1148c2ecf20Sopenharmony_ci#define B43legacy_PHY_ANTDWELL_AUTODIV1 0x0100 /* Automatic RX diversity start antenna */ 1158c2ecf20Sopenharmony_ci#define B43legacy_PHY_ENCORE B43legacy_PHY_OFDM(0x49) /* "Encore" (RangeMax / BroadRange) */ 1168c2ecf20Sopenharmony_ci#define B43legacy_PHY_ENCORE_EN 0x0200 /* Encore enable */ 1178c2ecf20Sopenharmony_ci#define B43legacy_PHY_LMS B43legacy_PHY_OFDM(0x55) 1188c2ecf20Sopenharmony_ci#define B43legacy_PHY_OFDM61 B43legacy_PHY_OFDM(0x61) /* FIXME rename */ 1198c2ecf20Sopenharmony_ci#define B43legacy_PHY_OFDM61_10 0x0010 /* FIXME rename */ 1208c2ecf20Sopenharmony_ci#define B43legacy_PHY_IQBAL B43legacy_PHY_OFDM(0x69) /* I/Q balance */ 1218c2ecf20Sopenharmony_ci#define B43legacy_PHY_OTABLECTL B43legacy_PHY_OFDM(0x72) /* OFDM table control (see below) */ 1228c2ecf20Sopenharmony_ci#define B43legacy_PHY_OTABLEOFF 0x03FF /* OFDM table offset (see below) */ 1238c2ecf20Sopenharmony_ci#define B43legacy_PHY_OTABLENR 0xFC00 /* OFDM table number (see below) */ 1248c2ecf20Sopenharmony_ci#define B43legacy_PHY_OTABLENR_SHIFT 10 1258c2ecf20Sopenharmony_ci#define B43legacy_PHY_OTABLEI B43legacy_PHY_OFDM(0x73) /* OFDM table data I */ 1268c2ecf20Sopenharmony_ci#define B43legacy_PHY_OTABLEQ B43legacy_PHY_OFDM(0x74) /* OFDM table data Q */ 1278c2ecf20Sopenharmony_ci#define B43legacy_PHY_HPWR_TSSICTL B43legacy_PHY_OFDM(0x78) /* Hardware power TSSI control */ 1288c2ecf20Sopenharmony_ci#define B43legacy_PHY_NRSSITHRES B43legacy_PHY_OFDM(0x8A) /* NRSSI threshold */ 1298c2ecf20Sopenharmony_ci#define B43legacy_PHY_ANTWRSETT B43legacy_PHY_OFDM(0x8C) /* Antenna WR settle */ 1308c2ecf20Sopenharmony_ci#define B43legacy_PHY_ANTWRSETT_ARXDIV 0x2000 /* Automatic RX diversity enabled */ 1318c2ecf20Sopenharmony_ci#define B43legacy_PHY_CLIPPWRDOWNT B43legacy_PHY_OFDM(0x93) /* Clip powerdown threshold */ 1328c2ecf20Sopenharmony_ci#define B43legacy_PHY_OFDM9B B43legacy_PHY_OFDM(0x9B) /* FIXME rename */ 1338c2ecf20Sopenharmony_ci#define B43legacy_PHY_N1P1GAIN B43legacy_PHY_OFDM(0xA0) 1348c2ecf20Sopenharmony_ci#define B43legacy_PHY_P1P2GAIN B43legacy_PHY_OFDM(0xA1) 1358c2ecf20Sopenharmony_ci#define B43legacy_PHY_N1N2GAIN B43legacy_PHY_OFDM(0xA2) 1368c2ecf20Sopenharmony_ci#define B43legacy_PHY_CLIPTHRES B43legacy_PHY_OFDM(0xA3) 1378c2ecf20Sopenharmony_ci#define B43legacy_PHY_CLIPN1P2THRES B43legacy_PHY_OFDM(0xA4) 1388c2ecf20Sopenharmony_ci#define B43legacy_PHY_DIVSRCHIDX B43legacy_PHY_OFDM(0xA8) /* Divider search gain/index */ 1398c2ecf20Sopenharmony_ci#define B43legacy_PHY_CLIPP2THRES B43legacy_PHY_OFDM(0xA9) 1408c2ecf20Sopenharmony_ci#define B43legacy_PHY_CLIPP3THRES B43legacy_PHY_OFDM(0xAA) 1418c2ecf20Sopenharmony_ci#define B43legacy_PHY_DIVP1P2GAIN B43legacy_PHY_OFDM(0xAB) 1428c2ecf20Sopenharmony_ci#define B43legacy_PHY_DIVSRCHGAINBACK B43legacy_PHY_OFDM(0xAD) /* Divider search gain back */ 1438c2ecf20Sopenharmony_ci#define B43legacy_PHY_DIVSRCHGAINCHNG B43legacy_PHY_OFDM(0xAE) /* Divider search gain change */ 1448c2ecf20Sopenharmony_ci#define B43legacy_PHY_CRSTHRES1_R1 B43legacy_PHY_OFDM(0xC0) /* CRS Threshold 1 (rev 1 only) */ 1458c2ecf20Sopenharmony_ci#define B43legacy_PHY_CRSTHRES2_R1 B43legacy_PHY_OFDM(0xC1) /* CRS Threshold 2 (rev 1 only) */ 1468c2ecf20Sopenharmony_ci#define B43legacy_PHY_TSSIP_LTBASE B43legacy_PHY_OFDM(0x380) /* TSSI power lookup table base */ 1478c2ecf20Sopenharmony_ci#define B43legacy_PHY_DC_LTBASE B43legacy_PHY_OFDM(0x3A0) /* DC lookup table base */ 1488c2ecf20Sopenharmony_ci#define B43legacy_PHY_GAIN_LTBASE B43legacy_PHY_OFDM(0x3C0) /* Gain lookup table base */ 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_civoid b43legacy_put_attenuation_into_ranges(int *_bbatt, int *_rfatt); 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci/* Masks for the different PHY versioning registers. */ 1538c2ecf20Sopenharmony_ci#define B43legacy_PHYVER_ANALOG 0xF000 1548c2ecf20Sopenharmony_ci#define B43legacy_PHYVER_ANALOG_SHIFT 12 1558c2ecf20Sopenharmony_ci#define B43legacy_PHYVER_TYPE 0x0F00 1568c2ecf20Sopenharmony_ci#define B43legacy_PHYVER_TYPE_SHIFT 8 1578c2ecf20Sopenharmony_ci#define B43legacy_PHYVER_VERSION 0x00FF 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistruct b43legacy_wldev; 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_civoid b43legacy_phy_lock(struct b43legacy_wldev *dev); 1628c2ecf20Sopenharmony_civoid b43legacy_phy_unlock(struct b43legacy_wldev *dev); 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ci/* Card uses the loopback gain stuff */ 1658c2ecf20Sopenharmony_ci#define has_loopback_gain(phy) \ 1668c2ecf20Sopenharmony_ci (((phy)->rev > 1) || ((phy)->gmode)) 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ciu16 b43legacy_phy_read(struct b43legacy_wldev *dev, u16 offset); 1698c2ecf20Sopenharmony_civoid b43legacy_phy_write(struct b43legacy_wldev *dev, u16 offset, u16 val); 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_ciint b43legacy_phy_init_tssi2dbm_table(struct b43legacy_wldev *dev); 1728c2ecf20Sopenharmony_ciint b43legacy_phy_init(struct b43legacy_wldev *dev); 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_civoid b43legacy_set_rx_antenna(struct b43legacy_wldev *dev, int antenna); 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_civoid b43legacy_phy_set_antenna_diversity(struct b43legacy_wldev *dev); 1778c2ecf20Sopenharmony_civoid b43legacy_phy_calibrate(struct b43legacy_wldev *dev); 1788c2ecf20Sopenharmony_ciint b43legacy_phy_connect(struct b43legacy_wldev *dev, int connect); 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_civoid b43legacy_phy_lo_b_measure(struct b43legacy_wldev *dev); 1818c2ecf20Sopenharmony_civoid b43legacy_phy_lo_g_measure(struct b43legacy_wldev *dev); 1828c2ecf20Sopenharmony_civoid b43legacy_phy_xmitpower(struct b43legacy_wldev *dev); 1838c2ecf20Sopenharmony_ci 1848c2ecf20Sopenharmony_ci/* Adjust the LocalOscillator to the saved values. 1858c2ecf20Sopenharmony_ci * "fixed" is only set to 1 once in initialization. Set to 0 otherwise. 1868c2ecf20Sopenharmony_ci */ 1878c2ecf20Sopenharmony_civoid b43legacy_phy_lo_adjust(struct b43legacy_wldev *dev, int fixed); 1888c2ecf20Sopenharmony_civoid b43legacy_phy_lo_mark_all_unused(struct b43legacy_wldev *dev); 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_civoid b43legacy_phy_set_baseband_attenuation(struct b43legacy_wldev *dev, 1918c2ecf20Sopenharmony_ci u16 baseband_attenuation); 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_civoid b43legacy_power_saving_ctl_bits(struct b43legacy_wldev *dev, 1948c2ecf20Sopenharmony_ci int bit25, int bit26); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ci#endif /* B43legacy_PHY_H_ */ 197