svn commit: r298944 - in head/sys: conf dev/bwn modules/bwn

Adrian Chadd adrian at FreeBSD.org
Mon May 2 21:06:03 UTC 2016


Author: adrian
Date: Mon May  2 21:06:02 2016
New Revision: 298944
URL: https://svnweb.freebsd.org/changeset/base/298944

Log:
  [bwn] break out the LP PHY code into a separate file.
  
  This (and eventually migrating the other PHY code out) is in preparation
  for adding the 11n PHY.  No, the 11ac PHY (for the BCM4260 softmac part) isn't
  yet open source, so we can't grow that.  Yet.
  
  This trims ~3,700 lines of code from if_bwn.c, bringing it down to a slightly
  less crazy sounding 10,446 lines of code.

Added:
  head/sys/dev/bwn/if_bwn_misc.h   (contents, props changed)
  head/sys/dev/bwn/if_bwn_phy_lp.c   (contents, props changed)
  head/sys/dev/bwn/if_bwn_phy_lp.h   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/bwn/if_bwn.c
  head/sys/modules/bwn/Makefile

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Mon May  2 21:01:08 2016	(r298943)
+++ head/sys/conf/files	Mon May  2 21:06:02 2016	(r298944)
@@ -1132,6 +1132,8 @@ dev/bwi/if_bwi_pci.c		optional bwi pci
 # XXX Work around clang warning, until maintainer approves fix.
 dev/bwn/if_bwn.c		optional bwn siba_bwn \
 	compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
+dev/bwn/if_bwn_phy_lp.c		optional bwn siba_bwn \
+	compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}"
 dev/cardbus/cardbus.c		optional cardbus
 dev/cardbus/cardbus_cis.c	optional cardbus
 dev/cardbus/cardbus_device.c	optional cardbus

Modified: head/sys/dev/bwn/if_bwn.c
==============================================================================
--- head/sys/dev/bwn/if_bwn.c	Mon May  2 21:01:08 2016	(r298943)
+++ head/sys/dev/bwn/if_bwn.c	Mon May  2 21:06:02 2016	(r298944)
@@ -75,6 +75,9 @@ __FBSDID("$FreeBSD$");
 #include <dev/bwn/if_bwnreg.h>
 #include <dev/bwn/if_bwnvar.h>
 
+#include <dev/bwn/if_bwn_misc.h>
+#include <dev/bwn/if_bwn_phy_lp.h>
+
 static SYSCTL_NODE(_hw, OID_AUTO, bwn, CTLFLAG_RD, 0,
     "Broadcom driver parameters");
 
@@ -204,8 +207,6 @@ static void	bwn_core_start(struct bwn_ma
 static void	bwn_core_exit(struct bwn_mac *);
 static void	bwn_bt_disable(struct bwn_mac *);
 static int	bwn_chip_init(struct bwn_mac *);
-static uint64_t	bwn_hf_read(struct bwn_mac *);
-static void	bwn_hf_write(struct bwn_mac *, uint64_t);
 static void	bwn_set_txretry(struct bwn_mac *, int, int);
 static void	bwn_rate_init(struct bwn_mac *);
 static void	bwn_set_phytxctl(struct bwn_mac *);
@@ -350,8 +351,6 @@ static void	bwn_ofdmtab_write_4(struct b
 static void	bwn_gtab_write(struct bwn_mac *, uint16_t, uint16_t,
 		    uint16_t);
 static void	bwn_ram_write(struct bwn_mac *, uint16_t, uint32_t);
-static void	bwn_mac_suspend(struct bwn_mac *);
-static void	bwn_mac_enable(struct bwn_mac *);
 static void	bwn_psctl(struct bwn_mac *, uint32_t);
 static int16_t	bwn_nrssi_read(struct bwn_mac *, uint16_t);
 static void	bwn_nrssi_offset(struct bwn_mac *);
@@ -452,84 +451,6 @@ static void	bwn_led_blink_end(void *);
 static void	bwn_rfswitch(void *);
 static void	bwn_rf_turnon(struct bwn_mac *);
 static void	bwn_rf_turnoff(struct bwn_mac *);
-static void	bwn_phy_lp_init_pre(struct bwn_mac *);
-static int	bwn_phy_lp_init(struct bwn_mac *);
-static uint16_t	bwn_phy_lp_read(struct bwn_mac *, uint16_t);
-static void	bwn_phy_lp_write(struct bwn_mac *, uint16_t, uint16_t);
-static void	bwn_phy_lp_maskset(struct bwn_mac *, uint16_t, uint16_t,
-		    uint16_t);
-static uint16_t	bwn_phy_lp_rf_read(struct bwn_mac *, uint16_t);
-static void	bwn_phy_lp_rf_write(struct bwn_mac *, uint16_t, uint16_t);
-static void	bwn_phy_lp_rf_onoff(struct bwn_mac *, int);
-static int	bwn_phy_lp_switch_channel(struct bwn_mac *, uint32_t);
-static uint32_t	bwn_phy_lp_get_default_chan(struct bwn_mac *);
-static void	bwn_phy_lp_set_antenna(struct bwn_mac *, int);
-static void	bwn_phy_lp_task_60s(struct bwn_mac *);
-static void	bwn_phy_lp_readsprom(struct bwn_mac *);
-static void	bwn_phy_lp_bbinit(struct bwn_mac *);
-static void	bwn_phy_lp_txpctl_init(struct bwn_mac *);
-static void	bwn_phy_lp_calib(struct bwn_mac *);
-static void	bwn_phy_lp_switch_analog(struct bwn_mac *, int);
-static int	bwn_phy_lp_b2062_switch_channel(struct bwn_mac *, uint8_t);
-static int	bwn_phy_lp_b2063_switch_channel(struct bwn_mac *, uint8_t);
-static void	bwn_phy_lp_set_anafilter(struct bwn_mac *, uint8_t);
-static void	bwn_phy_lp_set_gaintbl(struct bwn_mac *, uint32_t);
-static void	bwn_phy_lp_digflt_save(struct bwn_mac *);
-static void	bwn_phy_lp_get_txpctlmode(struct bwn_mac *);
-static void	bwn_phy_lp_set_txpctlmode(struct bwn_mac *, uint8_t);
-static void	bwn_phy_lp_bugfix(struct bwn_mac *);
-static void	bwn_phy_lp_digflt_restore(struct bwn_mac *);
-static void	bwn_phy_lp_tblinit(struct bwn_mac *);
-static void	bwn_phy_lp_bbinit_r2(struct bwn_mac *);
-static void	bwn_phy_lp_bbinit_r01(struct bwn_mac *);
-static void	bwn_phy_lp_b2062_init(struct bwn_mac *);
-static void	bwn_phy_lp_b2063_init(struct bwn_mac *);
-static void	bwn_phy_lp_rxcal_r2(struct bwn_mac *);
-static void	bwn_phy_lp_rccal_r12(struct bwn_mac *);
-static void	bwn_phy_lp_set_rccap(struct bwn_mac *);
-static uint32_t	bwn_phy_lp_roundup(uint32_t, uint32_t, uint8_t);
-static void	bwn_phy_lp_b2062_reset_pllbias(struct bwn_mac *);
-static void	bwn_phy_lp_b2062_vco_calib(struct bwn_mac *);
-static void	bwn_tab_write_multi(struct bwn_mac *, uint32_t, int,
-		    const void *);
-static void	bwn_tab_read_multi(struct bwn_mac *, uint32_t, int, void *);
-static struct bwn_txgain
-		bwn_phy_lp_get_txgain(struct bwn_mac *);
-static uint8_t	bwn_phy_lp_get_bbmult(struct bwn_mac *);
-static void	bwn_phy_lp_set_txgain(struct bwn_mac *, struct bwn_txgain *);
-static void	bwn_phy_lp_set_bbmult(struct bwn_mac *, uint8_t);
-static void	bwn_phy_lp_set_trsw_over(struct bwn_mac *, uint8_t, uint8_t);
-static void	bwn_phy_lp_set_rxgain(struct bwn_mac *, uint32_t);
-static void	bwn_phy_lp_set_deaf(struct bwn_mac *, uint8_t);
-static int	bwn_phy_lp_calc_rx_iq_comp(struct bwn_mac *, uint16_t);
-static void	bwn_phy_lp_clear_deaf(struct bwn_mac *, uint8_t);
-static void	bwn_phy_lp_tblinit_r01(struct bwn_mac *);
-static void	bwn_phy_lp_tblinit_r2(struct bwn_mac *);
-static void	bwn_phy_lp_tblinit_txgain(struct bwn_mac *);
-static void	bwn_tab_write(struct bwn_mac *, uint32_t, uint32_t);
-static void	bwn_phy_lp_b2062_tblinit(struct bwn_mac *);
-static void	bwn_phy_lp_b2063_tblinit(struct bwn_mac *);
-static int	bwn_phy_lp_loopback(struct bwn_mac *);
-static void	bwn_phy_lp_set_rxgain_idx(struct bwn_mac *, uint16_t);
-static void	bwn_phy_lp_ddfs_turnon(struct bwn_mac *, int, int, int, int,
-		    int);
-static uint8_t	bwn_phy_lp_rx_iq_est(struct bwn_mac *, uint16_t, uint8_t,
-		    struct bwn_phy_lp_iq_est *);
-static void	bwn_phy_lp_ddfs_turnoff(struct bwn_mac *);
-static uint32_t	bwn_tab_read(struct bwn_mac *, uint32_t);
-static void	bwn_phy_lp_set_txgain_dac(struct bwn_mac *, uint16_t);
-static void	bwn_phy_lp_set_txgain_pa(struct bwn_mac *, uint16_t);
-static void	bwn_phy_lp_set_txgain_override(struct bwn_mac *);
-static uint16_t	bwn_phy_lp_get_pa_gain(struct bwn_mac *);
-static uint8_t	bwn_nbits(int32_t);
-static void	bwn_phy_lp_gaintbl_write_multi(struct bwn_mac *, int, int,
-		    struct bwn_txgain_entry *);
-static void	bwn_phy_lp_gaintbl_write(struct bwn_mac *, int,
-		    struct bwn_txgain_entry);
-static void	bwn_phy_lp_gaintbl_write_r2(struct bwn_mac *, int,
-		    struct bwn_txgain_entry);
-static void	bwn_phy_lp_gaintbl_write_r01(struct bwn_mac *, int,
-		    struct bwn_txgain_entry);
 static void	bwn_sysctl_node(struct bwn_softc *);
 
 static struct resource_spec bwn_res_spec_legacy[] = {
@@ -612,231 +533,6 @@ static const struct bwn_channelinfo bwn_
 	.nchannels = 110
 };
 
-static const uint8_t bwn_b2063_chantable_data[33][12] = {
-	{ 0x6f, 0x3c, 0x3c, 0x4, 0x5, 0x5, 0x5, 0x5, 0x77, 0x80, 0x80, 0x70 },
-	{ 0x6f, 0x2c, 0x2c, 0x4, 0x5, 0x5, 0x5, 0x5, 0x77, 0x80, 0x80, 0x70 },
-	{ 0x6f, 0x1c, 0x1c, 0x4, 0x5, 0x5, 0x5, 0x5, 0x77, 0x80, 0x80, 0x70 },
-	{ 0x6e, 0x1c, 0x1c, 0x4, 0x5, 0x5, 0x5, 0x5, 0x77, 0x80, 0x80, 0x70 },
-	{ 0x6e, 0xc, 0xc, 0x4, 0x5, 0x5, 0x5, 0x5, 0x77, 0x80, 0x80, 0x70 },
-	{ 0x6a, 0xc, 0xc, 0, 0x2, 0x5, 0xd, 0xd, 0x77, 0x80, 0x20, 0 },
-	{ 0x6a, 0xc, 0xc, 0, 0x1, 0x5, 0xd, 0xc, 0x77, 0x80, 0x20, 0 },
-	{ 0x6a, 0xc, 0xc, 0, 0x1, 0x4, 0xc, 0xc, 0x77, 0x80, 0x20, 0 },
-	{ 0x69, 0xc, 0xc, 0, 0x1, 0x4, 0xc, 0xc, 0x77, 0x70, 0x20, 0 },
-	{ 0x69, 0xc, 0xc, 0, 0x1, 0x4, 0xb, 0xc, 0x77, 0x70, 0x20, 0 },
-	{ 0x69, 0xc, 0xc, 0, 0, 0x4, 0xb, 0xb, 0x77, 0x60, 0x20, 0 },
-	{ 0x69, 0xc, 0xc, 0, 0, 0x3, 0xa, 0xb, 0x77, 0x60, 0x20, 0 },
-	{ 0x69, 0xc, 0xc, 0, 0, 0x3, 0xa, 0xa, 0x77, 0x60, 0x20, 0 },
-	{ 0x68, 0xc, 0xc, 0, 0, 0x2, 0x9, 0x9, 0x77, 0x60, 0x20, 0 },
-	{ 0x68, 0xc, 0xc, 0, 0, 0x1, 0x8, 0x8, 0x77, 0x50, 0x10, 0 },
-	{ 0x67, 0xc, 0xc, 0, 0, 0, 0x8, 0x8, 0x77, 0x50, 0x10, 0 },
-	{ 0x64, 0xc, 0xc, 0, 0, 0, 0x2, 0x1, 0x77, 0x20, 0, 0 },
-	{ 0x64, 0xc, 0xc, 0, 0, 0, 0x1, 0x1, 0x77, 0x20, 0, 0 },
-	{ 0x63, 0xc, 0xc, 0, 0, 0, 0x1, 0, 0x77, 0x10, 0, 0 },
-	{ 0x63, 0xc, 0xc, 0, 0, 0, 0, 0, 0x77, 0x10, 0, 0 },
-	{ 0x62, 0xc, 0xc, 0, 0, 0, 0, 0, 0x77, 0x10, 0, 0 },
-	{ 0x62, 0xc, 0xc, 0, 0, 0, 0, 0, 0x77, 0, 0, 0 },
-	{ 0x61, 0xc, 0xc, 0, 0, 0, 0, 0, 0x77, 0, 0, 0 },
-	{ 0x60, 0xc, 0xc, 0, 0, 0, 0, 0, 0x77, 0, 0, 0 },
-	{ 0x6e, 0xc, 0xc, 0, 0x9, 0xe, 0xf, 0xf, 0x77, 0xc0, 0x50, 0 },
-	{ 0x6e, 0xc, 0xc, 0, 0x9, 0xd, 0xf, 0xf, 0x77, 0xb0, 0x50, 0 },
-	{ 0x6e, 0xc, 0xc, 0, 0x8, 0xc, 0xf, 0xf, 0x77, 0xb0, 0x50, 0 },
-	{ 0x6d, 0xc, 0xc, 0, 0x8, 0xc, 0xf, 0xf, 0x77, 0xa0, 0x40, 0 },
-	{ 0x6d, 0xc, 0xc, 0, 0x8, 0xb, 0xf, 0xf, 0x77, 0xa0, 0x40, 0 },
-	{ 0x6d, 0xc, 0xc, 0, 0x8, 0xa, 0xf, 0xf, 0x77, 0xa0, 0x40, 0 },
-	{ 0x6c, 0xc, 0xc, 0, 0x7, 0x9, 0xf, 0xf, 0x77, 0x90, 0x40, 0 },
-	{ 0x6c, 0xc, 0xc, 0, 0x6, 0x8, 0xf, 0xf, 0x77, 0x90, 0x40, 0 },
-	{ 0x6c, 0xc, 0xc, 0, 0x5, 0x8, 0xf, 0xf, 0x77, 0x90, 0x40, 0 }
-};
-
-static const struct bwn_b206x_chan bwn_b2063_chantable[] = {
-	{ 1, 2412, bwn_b2063_chantable_data[0] },
-	{ 2, 2417, bwn_b2063_chantable_data[0] },
-	{ 3, 2422, bwn_b2063_chantable_data[0] },
-	{ 4, 2427, bwn_b2063_chantable_data[1] },
-	{ 5, 2432, bwn_b2063_chantable_data[1] },
-	{ 6, 2437, bwn_b2063_chantable_data[1] },
-	{ 7, 2442, bwn_b2063_chantable_data[1] },
-	{ 8, 2447, bwn_b2063_chantable_data[1] },
-	{ 9, 2452, bwn_b2063_chantable_data[2] },
-	{ 10, 2457, bwn_b2063_chantable_data[2] },
-	{ 11, 2462, bwn_b2063_chantable_data[3] },
-	{ 12, 2467, bwn_b2063_chantable_data[3] },
-	{ 13, 2472, bwn_b2063_chantable_data[3] },
-	{ 14, 2484, bwn_b2063_chantable_data[4] },
-	{ 34, 5170, bwn_b2063_chantable_data[5] },
-	{ 36, 5180, bwn_b2063_chantable_data[6] },
-	{ 38, 5190, bwn_b2063_chantable_data[7] },
-	{ 40, 5200, bwn_b2063_chantable_data[8] },
-	{ 42, 5210, bwn_b2063_chantable_data[9] },
-	{ 44, 5220, bwn_b2063_chantable_data[10] },
-	{ 46, 5230, bwn_b2063_chantable_data[11] },
-	{ 48, 5240, bwn_b2063_chantable_data[12] },
-	{ 52, 5260, bwn_b2063_chantable_data[13] },
-	{ 56, 5280, bwn_b2063_chantable_data[14] },
-	{ 60, 5300, bwn_b2063_chantable_data[14] },
-	{ 64, 5320, bwn_b2063_chantable_data[15] },
-	{ 100, 5500, bwn_b2063_chantable_data[16] },
-	{ 104, 5520, bwn_b2063_chantable_data[17] },
-	{ 108, 5540, bwn_b2063_chantable_data[18] },
-	{ 112, 5560, bwn_b2063_chantable_data[19] },
-	{ 116, 5580, bwn_b2063_chantable_data[20] },
-	{ 120, 5600, bwn_b2063_chantable_data[21] },
-	{ 124, 5620, bwn_b2063_chantable_data[21] },
-	{ 128, 5640, bwn_b2063_chantable_data[22] },
-	{ 132, 5660, bwn_b2063_chantable_data[22] },
-	{ 136, 5680, bwn_b2063_chantable_data[22] },
-	{ 140, 5700, bwn_b2063_chantable_data[23] },
-	{ 149, 5745, bwn_b2063_chantable_data[23] },
-	{ 153, 5765, bwn_b2063_chantable_data[23] },
-	{ 157, 5785, bwn_b2063_chantable_data[23] },
-	{ 161, 5805, bwn_b2063_chantable_data[23] },
-	{ 165, 5825, bwn_b2063_chantable_data[23] },
-	{ 184, 4920, bwn_b2063_chantable_data[24] },
-	{ 188, 4940, bwn_b2063_chantable_data[25] },
-	{ 192, 4960, bwn_b2063_chantable_data[26] },
-	{ 196, 4980, bwn_b2063_chantable_data[27] },
-	{ 200, 5000, bwn_b2063_chantable_data[28] },
-	{ 204, 5020, bwn_b2063_chantable_data[29] },
-	{ 208, 5040, bwn_b2063_chantable_data[30] },
-	{ 212, 5060, bwn_b2063_chantable_data[31] },
-	{ 216, 5080, bwn_b2063_chantable_data[32] }
-};
-
-static const uint8_t bwn_b2062_chantable_data[22][12] = {
-	{ 0xff, 0xff, 0xb5, 0x1b, 0x24, 0x32, 0x32, 0x88, 0x88, 0, 0, 0 },
-	{ 0, 0x22, 0x20, 0x84, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0x11, 0x10, 0x83, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0x83, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0x11, 0x20, 0x83, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0x11, 0x10, 0x84, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0x11, 0, 0x83, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0x63, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0x62, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0x30, 0x3c, 0x77, 0x37, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0x20, 0x3c, 0x77, 0x37, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0x10, 0x3c, 0x77, 0x37, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0, 0, 0, 0x3c, 0x77, 0x37, 0xff, 0x88, 0, 0, 0 },
-	{ 0x55, 0x77, 0x90, 0xf7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x44, 0x77, 0x80, 0xe7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x44, 0x66, 0x80, 0xe7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x33, 0x66, 0x70, 0xc7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x22, 0x55, 0x60, 0xd7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x22, 0x55, 0x60, 0xc7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x22, 0x44, 0x50, 0xc7, 0x3c, 0x77, 0x35, 0xff, 0xff, 0, 0, 0 },
-	{ 0x11, 0x44, 0x50, 0xa5, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 },
-	{ 0, 0x44, 0x40, 0xb6, 0x3c, 0x77, 0x35, 0xff, 0x88, 0, 0, 0 }
-};
-
-static const struct bwn_b206x_chan bwn_b2062_chantable[] = {
-	{ 1, 2412, bwn_b2062_chantable_data[0] },
-	{ 2, 2417, bwn_b2062_chantable_data[0] },
-	{ 3, 2422, bwn_b2062_chantable_data[0] },
-	{ 4, 2427, bwn_b2062_chantable_data[0] },
-	{ 5, 2432, bwn_b2062_chantable_data[0] },
-	{ 6, 2437, bwn_b2062_chantable_data[0] },
-	{ 7, 2442, bwn_b2062_chantable_data[0] },
-	{ 8, 2447, bwn_b2062_chantable_data[0] },
-	{ 9, 2452, bwn_b2062_chantable_data[0] },
-	{ 10, 2457, bwn_b2062_chantable_data[0] },
-	{ 11, 2462, bwn_b2062_chantable_data[0] },
-	{ 12, 2467, bwn_b2062_chantable_data[0] },
-	{ 13, 2472, bwn_b2062_chantable_data[0] },
-	{ 14, 2484, bwn_b2062_chantable_data[0] },
-	{ 34, 5170, bwn_b2062_chantable_data[1] },
-	{ 38, 5190, bwn_b2062_chantable_data[2] },
-	{ 42, 5210, bwn_b2062_chantable_data[2] },
-	{ 46, 5230, bwn_b2062_chantable_data[3] },
-	{ 36, 5180, bwn_b2062_chantable_data[4] },
-	{ 40, 5200, bwn_b2062_chantable_data[5] },
-	{ 44, 5220, bwn_b2062_chantable_data[6] },
-	{ 48, 5240, bwn_b2062_chantable_data[3] },
-	{ 52, 5260, bwn_b2062_chantable_data[3] },
-	{ 56, 5280, bwn_b2062_chantable_data[3] },
-	{ 60, 5300, bwn_b2062_chantable_data[7] },
-	{ 64, 5320, bwn_b2062_chantable_data[8] },
-	{ 100, 5500, bwn_b2062_chantable_data[9] },
-	{ 104, 5520, bwn_b2062_chantable_data[10] },
-	{ 108, 5540, bwn_b2062_chantable_data[10] },
-	{ 112, 5560, bwn_b2062_chantable_data[10] },
-	{ 116, 5580, bwn_b2062_chantable_data[11] },
-	{ 120, 5600, bwn_b2062_chantable_data[12] },
-	{ 124, 5620, bwn_b2062_chantable_data[12] },
-	{ 128, 5640, bwn_b2062_chantable_data[12] },
-	{ 132, 5660, bwn_b2062_chantable_data[12] },
-	{ 136, 5680, bwn_b2062_chantable_data[12] },
-	{ 140, 5700, bwn_b2062_chantable_data[12] },
-	{ 149, 5745, bwn_b2062_chantable_data[12] },
-	{ 153, 5765, bwn_b2062_chantable_data[12] },
-	{ 157, 5785, bwn_b2062_chantable_data[12] },
-	{ 161, 5805, bwn_b2062_chantable_data[12] },
-	{ 165, 5825, bwn_b2062_chantable_data[12] },
-	{ 184, 4920, bwn_b2062_chantable_data[13] },
-	{ 188, 4940, bwn_b2062_chantable_data[14] },
-	{ 192, 4960, bwn_b2062_chantable_data[15] },
-	{ 196, 4980, bwn_b2062_chantable_data[16] },
-	{ 200, 5000, bwn_b2062_chantable_data[17] },
-	{ 204, 5020, bwn_b2062_chantable_data[18] },
-	{ 208, 5040, bwn_b2062_chantable_data[19] },
-	{ 212, 5060, bwn_b2062_chantable_data[20] },
-	{ 216, 5080, bwn_b2062_chantable_data[21] }
-};
-
-/* for LP PHY */
-static const struct bwn_rxcompco bwn_rxcompco_5354[] = {
-	{  1, -66, 15 }, {  2, -66, 15 }, {  3, -66, 15 }, {  4, -66, 15 },
-	{  5, -66, 15 }, {  6, -66, 15 }, {  7, -66, 14 }, {  8, -66, 14 },
-	{  9, -66, 14 }, { 10, -66, 14 }, { 11, -66, 14 }, { 12, -66, 13 },
-	{ 13, -66, 13 }, { 14, -66, 13 },
-};
-
-/* for LP PHY */
-static const struct bwn_rxcompco bwn_rxcompco_r12[] = {
-	{   1, -64, 13 }, {   2, -64, 13 }, {   3, -64, 13 }, {   4, -64, 13 },
-	{   5, -64, 12 }, {   6, -64, 12 }, {   7, -64, 12 }, {   8, -64, 12 },
-	{   9, -64, 12 }, {  10, -64, 11 }, {  11, -64, 11 }, {  12, -64, 11 },
-	{  13, -64, 11 }, {  14, -64, 10 }, {  34, -62, 24 }, {  38, -62, 24 },
-	{  42, -62, 24 }, {  46, -62, 23 }, {  36, -62, 24 }, {  40, -62, 24 },
-	{  44, -62, 23 }, {  48, -62, 23 }, {  52, -62, 23 }, {  56, -62, 22 },
-	{  60, -62, 22 }, {  64, -62, 22 }, { 100, -62, 16 }, { 104, -62, 16 },
-	{ 108, -62, 15 }, { 112, -62, 14 }, { 116, -62, 14 }, { 120, -62, 13 },
-	{ 124, -62, 12 }, { 128, -62, 12 }, { 132, -62, 12 }, { 136, -62, 11 },
-	{ 140, -62, 10 }, { 149, -61,  9 }, { 153, -61,  9 }, { 157, -61,  9 },
-	{ 161, -61,  8 }, { 165, -61,  8 }, { 184, -62, 25 }, { 188, -62, 25 },
-	{ 192, -62, 25 }, { 196, -62, 25 }, { 200, -62, 25 }, { 204, -62, 25 },
-	{ 208, -62, 25 }, { 212, -62, 25 }, { 216, -62, 26 },
-};
-
-static const struct bwn_rxcompco bwn_rxcompco_r2 = { 0, -64, 0 };
-
-static const uint8_t bwn_tab_sigsq_tbl[] = {
-	0xde, 0xdc, 0xda, 0xd8, 0xd6, 0xd4, 0xd2, 0xcf, 0xcd,
-	0xca, 0xc7, 0xc4, 0xc1, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe,
-	0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0x00,
-	0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe, 0xbe,
-	0xbe, 0xbe, 0xbe, 0xbe, 0xc1, 0xc4, 0xc7, 0xca, 0xcd,
-	0xcf, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
-};
-
-static const uint8_t bwn_tab_pllfrac_tbl[] = {
-	0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80,
-	0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
-};
-
-static const uint16_t bwn_tabl_iqlocal_tbl[] = {
-	0x0200, 0x0300, 0x0400, 0x0600, 0x0800, 0x0b00, 0x1000, 0x1001, 0x1002,
-	0x1003, 0x1004, 0x1005, 0x1006, 0x1007, 0x1707, 0x2007, 0x2d07, 0x4007,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0200, 0x0300, 0x0400, 0x0600,
-	0x0800, 0x0b00, 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005, 0x1006,
-	0x1007, 0x1707, 0x2007, 0x2d07, 0x4007, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-};
-
 static const uint16_t bwn_tab_noise_g1[] = BWN_TAB_NOISE_G1;
 static const uint16_t bwn_tab_noise_g2[] = BWN_TAB_NOISE_G2;
 static const uint16_t bwn_tab_noisescale_g1[] = BWN_TAB_NOISESCALE_G1;
@@ -3273,7 +2969,7 @@ bwn_chip_init(struct bwn_mac *mac)
 }
 
 /* read hostflags */
-static uint64_t
+uint64_t
 bwn_hf_read(struct bwn_mac *mac)
 {
 	uint64_t ret;
@@ -3286,7 +2982,7 @@ bwn_hf_read(struct bwn_mac *mac)
 	return (ret);
 }
 
-static void
+void
 bwn_hf_write(struct bwn_mac *mac, uint64_t value)
 {
 
@@ -6528,7 +6224,7 @@ bwn_lo_g_init(struct bwn_mac *mac)
 	bwn_phy_g_dc_lookup_init(mac, 1);
 }
 
-static void
+void
 bwn_mac_suspend(struct bwn_mac *mac)
 {
 	struct bwn_softc *sc = mac->mac_sc;
@@ -6562,7 +6258,7 @@ out:
 	mac->mac_suspended++;
 }
 
-static void
+void
 bwn_mac_enable(struct bwn_mac *mac)
 {
 	struct bwn_softc *sc = mac->mac_sc;
@@ -10699,3343 +10395,6 @@ bwn_rfswitch(void *arg)
 }
 
 static void
-bwn_phy_lp_init_pre(struct bwn_mac *mac)
-{
-	struct bwn_phy *phy = &mac->mac_phy;
-	struct bwn_phy_lp *plp = &phy->phy_lp;
-
-	plp->plp_antenna = BWN_ANT_DEFAULT;
-}
-
-static int
-bwn_phy_lp_init(struct bwn_mac *mac)
-{
-	static const struct bwn_stxtable tables[] = {
-		{ 2,  6, 0x3d, 3, 0x01 }, { 1, 12, 0x4c, 1, 0x01 },
-		{ 1,  8, 0x50, 0, 0x7f }, { 0,  8, 0x44, 0, 0xff },
-		{ 1,  0, 0x4a, 0, 0xff }, { 0,  4, 0x4d, 0, 0xff },
-		{ 1,  4, 0x4e, 0, 0xff }, { 0, 12, 0x4f, 0, 0x0f },
-		{ 1,  0, 0x4f, 4, 0x0f }, { 3,  0, 0x49, 0, 0x0f },
-		{ 4,  3, 0x46, 4, 0x07 }, { 3, 15, 0x46, 0, 0x01 },
-		{ 4,  0, 0x46, 1, 0x07 }, { 3,  8, 0x48, 4, 0x07 },
-		{ 3, 11, 0x48, 0, 0x0f }, { 3,  4, 0x49, 4, 0x0f },
-		{ 2, 15, 0x45, 0, 0x01 }, { 5, 13, 0x52, 4, 0x07 },
-		{ 6,  0, 0x52, 7, 0x01 }, { 5,  3, 0x41, 5, 0x07 },
-		{ 5,  6, 0x41, 0, 0x0f }, { 5, 10, 0x42, 5, 0x07 },
-		{ 4, 15, 0x42, 0, 0x01 }, { 5,  0, 0x42, 1, 0x07 },
-		{ 4, 11, 0x43, 4, 0x0f }, { 4,  7, 0x43, 0, 0x0f },
-		{ 4,  6, 0x45, 1, 0x01 }, { 2,  7, 0x40, 4, 0x0f },
-		{ 2, 11, 0x40, 0, 0x0f }
-	};
-	struct bwn_phy_lp *plp = &mac->mac_phy.phy_lp;
-	struct bwn_softc *sc = mac->mac_sc;
-	const struct bwn_stxtable *st;
-	struct ieee80211com *ic = &sc->sc_ic;
-	int i, error;
-	uint16_t tmp;
-
-	bwn_phy_lp_readsprom(mac);	/* XXX bad place */
-	bwn_phy_lp_bbinit(mac);
-
-	/* initialize RF */
-	BWN_PHY_SET(mac, BWN_PHY_4WIRECTL, 0x2);
-	DELAY(1);
-	BWN_PHY_MASK(mac, BWN_PHY_4WIRECTL, 0xfffd);
-	DELAY(1);
-
-	if (mac->mac_phy.rf_ver == 0x2062)
-		bwn_phy_lp_b2062_init(mac);
-	else {
-		bwn_phy_lp_b2063_init(mac);
-
-		/* synchronize stx table. */
-		for (i = 0; i < N(tables); i++) {
-			st = &tables[i];
-			tmp = BWN_RF_READ(mac, st->st_rfaddr);
-			tmp >>= st->st_rfshift;
-			tmp <<= st->st_physhift;
-			BWN_PHY_SETMASK(mac,
-			    BWN_PHY_OFDM(0xf2 + st->st_phyoffset),
-			    ~(st->st_mask << st->st_physhift), tmp);
-		}
-
-		BWN_PHY_WRITE(mac, BWN_PHY_OFDM(0xf0), 0x5f80);
-		BWN_PHY_WRITE(mac, BWN_PHY_OFDM(0xf1), 0);
-	}
-
-	/* calibrate RC */
-	if (mac->mac_phy.rev >= 2)
-		bwn_phy_lp_rxcal_r2(mac);
-	else if (!plp->plp_rccap) {
-		if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan))
-			bwn_phy_lp_rccal_r12(mac);
-	} else
-		bwn_phy_lp_set_rccap(mac);
-
-	error = bwn_phy_lp_switch_channel(mac, 7);
-	if (error)
-		device_printf(sc->sc_dev,
-		    "failed to change channel 7 (%d)\n", error);
-	bwn_phy_lp_txpctl_init(mac);
-	bwn_phy_lp_calib(mac);
-	return (0);
-}
-
-static uint16_t
-bwn_phy_lp_read(struct bwn_mac *mac, uint16_t reg)
-{
-
-	BWN_WRITE_2(mac, BWN_PHYCTL, reg);
-	return (BWN_READ_2(mac, BWN_PHYDATA));
-}
-
-static void
-bwn_phy_lp_write(struct bwn_mac *mac, uint16_t reg, uint16_t value)
-{
-
-	BWN_WRITE_2(mac, BWN_PHYCTL, reg);
-	BWN_WRITE_2(mac, BWN_PHYDATA, value);
-}
-
-static void
-bwn_phy_lp_maskset(struct bwn_mac *mac, uint16_t reg, uint16_t mask,
-    uint16_t set)
-{
-
-	BWN_WRITE_2(mac, BWN_PHYCTL, reg);
-	BWN_WRITE_2(mac, BWN_PHYDATA,
-	    (BWN_READ_2(mac, BWN_PHYDATA) & mask) | set);
-}
-
-static uint16_t
-bwn_phy_lp_rf_read(struct bwn_mac *mac, uint16_t reg)
-{
-
-	KASSERT(reg != 1, ("unaccessible register %d", reg));
-	if (mac->mac_phy.rev < 2 && reg != 0x4001)
-		reg |= 0x100;
-	if (mac->mac_phy.rev >= 2)
-		reg |= 0x200;
-	BWN_WRITE_2(mac, BWN_RFCTL, reg);
-	return BWN_READ_2(mac, BWN_RFDATALO);
-}
-
-static void
-bwn_phy_lp_rf_write(struct bwn_mac *mac, uint16_t reg, uint16_t value)
-{
-
-	KASSERT(reg != 1, ("unaccessible register %d", reg));
-	BWN_WRITE_2(mac, BWN_RFCTL, reg);
-	BWN_WRITE_2(mac, BWN_RFDATALO, value);
-}
-
-static void
-bwn_phy_lp_rf_onoff(struct bwn_mac *mac, int on)
-{
-
-	if (on) {
-		BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xe0ff);
-		BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_2,
-		    (mac->mac_phy.rev >= 2) ? 0xf7f7 : 0xffe7);
-		return;
-	}
-
-	if (mac->mac_phy.rev >= 2) {
-		BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_VAL_0, 0x83ff);
-		BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_0, 0x1f00);
-		BWN_PHY_MASK(mac, BWN_PHY_AFE_DDFS, 0x80ff);
-		BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_2_VAL, 0xdfff);
-		BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_2, 0x0808);
-		return;
-	}
-
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_VAL_0, 0xe0ff);
-	BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_0, 0x1f00);
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_2_VAL, 0xfcff);
-	BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_2, 0x0018);
-}
-
-static int
-bwn_phy_lp_switch_channel(struct bwn_mac *mac, uint32_t chan)
-{
-	struct bwn_phy *phy = &mac->mac_phy;
-	struct bwn_phy_lp *plp = &phy->phy_lp;
-	int error;
-
-	if (phy->rf_ver == 0x2063) {
-		error = bwn_phy_lp_b2063_switch_channel(mac, chan);
-		if (error)
-			return (error);
-	} else {
-		error = bwn_phy_lp_b2062_switch_channel(mac, chan);
-		if (error)
-			return (error);
-		bwn_phy_lp_set_anafilter(mac, chan);
-		bwn_phy_lp_set_gaintbl(mac, ieee80211_ieee2mhz(chan, 0));
-	}
-
-	plp->plp_chan = chan;
-	BWN_WRITE_2(mac, BWN_CHANNEL, chan);
-	return (0);
-}
-
-static uint32_t
-bwn_phy_lp_get_default_chan(struct bwn_mac *mac)
-{
-	struct bwn_softc *sc = mac->mac_sc;
-	struct ieee80211com *ic = &sc->sc_ic;
-
-	return (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan) ? 1 : 36);
-}
-
-static void
-bwn_phy_lp_set_antenna(struct bwn_mac *mac, int antenna)
-{
-	struct bwn_phy *phy = &mac->mac_phy;
-	struct bwn_phy_lp *plp = &phy->phy_lp;
-
-	if (phy->rev >= 2 || antenna > BWN_ANTAUTO1)
-		return;
-
-	bwn_hf_write(mac, bwn_hf_read(mac) & ~BWN_HF_UCODE_ANTDIV_HELPER);
-	BWN_PHY_SETMASK(mac, BWN_PHY_CRSGAIN_CTL, 0xfffd, antenna & 0x2);
-	BWN_PHY_SETMASK(mac, BWN_PHY_CRSGAIN_CTL, 0xfffe, antenna & 0x1);
-	bwn_hf_write(mac, bwn_hf_read(mac) | BWN_HF_UCODE_ANTDIV_HELPER);
-	plp->plp_antenna = antenna;
-}
-
-static void
-bwn_phy_lp_task_60s(struct bwn_mac *mac)
-{
-
-	bwn_phy_lp_calib(mac);
-}
-
-static void
-bwn_phy_lp_readsprom(struct bwn_mac *mac)
-{
-	struct bwn_phy_lp *plp = &mac->mac_phy.phy_lp;
-	struct bwn_softc *sc = mac->mac_sc;
-	struct ieee80211com *ic = &sc->sc_ic;
-
-	if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) {
-		plp->plp_txisoband_m = siba_sprom_get_tri2g(sc->sc_dev);
-		plp->plp_bxarch = siba_sprom_get_bxa2g(sc->sc_dev);
-		plp->plp_rxpwroffset = siba_sprom_get_rxpo2g(sc->sc_dev);
-		plp->plp_rssivf = siba_sprom_get_rssismf2g(sc->sc_dev);
-		plp->plp_rssivc = siba_sprom_get_rssismc2g(sc->sc_dev);
-		plp->plp_rssigs = siba_sprom_get_rssisav2g(sc->sc_dev);
-		return;
-	}
-
-	plp->plp_txisoband_l = siba_sprom_get_tri5gl(sc->sc_dev);
-	plp->plp_txisoband_m = siba_sprom_get_tri5g(sc->sc_dev);
-	plp->plp_txisoband_h = siba_sprom_get_tri5gh(sc->sc_dev);
-	plp->plp_bxarch = siba_sprom_get_bxa5g(sc->sc_dev);
-	plp->plp_rxpwroffset = siba_sprom_get_rxpo5g(sc->sc_dev);
-	plp->plp_rssivf = siba_sprom_get_rssismf5g(sc->sc_dev);
-	plp->plp_rssivc = siba_sprom_get_rssismc5g(sc->sc_dev);
-	plp->plp_rssigs = siba_sprom_get_rssisav5g(sc->sc_dev);
-}
-
-static void
-bwn_phy_lp_bbinit(struct bwn_mac *mac)
-{
-
-	bwn_phy_lp_tblinit(mac);
-	if (mac->mac_phy.rev >= 2)
-		bwn_phy_lp_bbinit_r2(mac);
-	else
-		bwn_phy_lp_bbinit_r01(mac);
-}
-
-static void
-bwn_phy_lp_txpctl_init(struct bwn_mac *mac)
-{
-	struct bwn_txgain gain_2ghz = { 4, 12, 12, 0 };
-	struct bwn_txgain gain_5ghz = { 7, 15, 14, 0 };
-	struct bwn_softc *sc = mac->mac_sc;
-	struct ieee80211com *ic = &sc->sc_ic;
-
-	bwn_phy_lp_set_txgain(mac,
-	    IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan) ? &gain_2ghz : &gain_5ghz);
-	bwn_phy_lp_set_bbmult(mac, 150);
-}
-
-static void
-bwn_phy_lp_calib(struct bwn_mac *mac)
-{
-	struct bwn_phy_lp *plp = &mac->mac_phy.phy_lp;
-	struct bwn_softc *sc = mac->mac_sc;
-	struct ieee80211com *ic = &sc->sc_ic;
-	const struct bwn_rxcompco *rc = NULL;
-	struct bwn_txgain ogain;
-	int i, omode, oafeovr, orf, obbmult;
-	uint8_t mode, fc = 0;
-
-	if (plp->plp_chanfullcal != plp->plp_chan) {
-		plp->plp_chanfullcal = plp->plp_chan;
-		fc = 1;
-	}
-
-	bwn_mac_suspend(mac);
-
-	/* BlueTooth Coexistance Override */
-	BWN_WRITE_2(mac, BWN_BTCOEX_CTL, 0x3);
-	BWN_WRITE_2(mac, BWN_BTCOEX_TXCTL, 0xff);
-
-	if (mac->mac_phy.rev >= 2)
-		bwn_phy_lp_digflt_save(mac);
-	bwn_phy_lp_get_txpctlmode(mac);
-	mode = plp->plp_txpctlmode;
-	bwn_phy_lp_set_txpctlmode(mac, BWN_PHYLP_TXPCTL_OFF);
-	if (mac->mac_phy.rev == 0 && mode != BWN_PHYLP_TXPCTL_OFF)
-		bwn_phy_lp_bugfix(mac);
-	if (mac->mac_phy.rev >= 2 && fc == 1) {
-		bwn_phy_lp_get_txpctlmode(mac);
-		omode = plp->plp_txpctlmode;
-		oafeovr = BWN_PHY_READ(mac, BWN_PHY_AFE_CTL_OVR) & 0x40;
-		if (oafeovr)
-			ogain = bwn_phy_lp_get_txgain(mac);
-		orf = BWN_PHY_READ(mac, BWN_PHY_RF_PWR_OVERRIDE) & 0xff;
-		obbmult = bwn_phy_lp_get_bbmult(mac);
-		bwn_phy_lp_set_txpctlmode(mac, BWN_PHYLP_TXPCTL_OFF);
-		if (oafeovr)
-			bwn_phy_lp_set_txgain(mac, &ogain);
-		bwn_phy_lp_set_bbmult(mac, obbmult);
-		bwn_phy_lp_set_txpctlmode(mac, omode);
-		BWN_PHY_SETMASK(mac, BWN_PHY_RF_PWR_OVERRIDE, 0xff00, orf);
-	}
-	bwn_phy_lp_set_txpctlmode(mac, mode);
-	if (mac->mac_phy.rev >= 2)
-		bwn_phy_lp_digflt_restore(mac);
-
-	/* do RX IQ Calculation; assumes that noise is true. */
-	if (siba_get_chipid(sc->sc_dev) == 0x5354) {
-		for (i = 0; i < N(bwn_rxcompco_5354); i++) {
-			if (bwn_rxcompco_5354[i].rc_chan == plp->plp_chan)
-				rc = &bwn_rxcompco_5354[i];
-		}
-	} else if (mac->mac_phy.rev >= 2)
-		rc = &bwn_rxcompco_r2;
-	else {
-		for (i = 0; i < N(bwn_rxcompco_r12); i++) {
-			if (bwn_rxcompco_r12[i].rc_chan == plp->plp_chan)
-				rc = &bwn_rxcompco_r12[i];
-		}
-	}
-	if (rc == NULL)
-		goto fail;
-
-	BWN_PHY_SETMASK(mac, BWN_PHY_RX_COMP_COEFF_S, 0xff00, rc->rc_c1);
-	BWN_PHY_SETMASK(mac, BWN_PHY_RX_COMP_COEFF_S, 0x00ff, rc->rc_c0 << 8);
-
-	bwn_phy_lp_set_trsw_over(mac, 1 /* TX */, 0 /* RX */);
-
-	if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) {
-		BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_0, 0x8);
-		BWN_PHY_SETMASK(mac, BWN_PHY_RF_OVERRIDE_VAL_0, 0xfff7, 0);
-	} else {
-		BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_0, 0x20);
-		BWN_PHY_SETMASK(mac, BWN_PHY_RF_OVERRIDE_VAL_0, 0xffdf, 0);
-	}
-
-	bwn_phy_lp_set_rxgain(mac, 0x2d5d);
-	BWN_PHY_MASK(mac, BWN_PHY_AFE_CTL_OVR, 0xfffe);
-	BWN_PHY_MASK(mac, BWN_PHY_AFE_CTL_OVRVAL, 0xfffe);
-	BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_0, 0x800);
-	BWN_PHY_SET(mac, BWN_PHY_RF_OVERRIDE_VAL_0, 0x800);
-	bwn_phy_lp_set_deaf(mac, 0);
-	/* XXX no checking return value? */
-	(void)bwn_phy_lp_calc_rx_iq_comp(mac, 0xfff0);
-	bwn_phy_lp_clear_deaf(mac, 0);
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xfffc);
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xfff7);
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xffdf);
-
-	/* disable RX GAIN override. */
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xfffe);
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xffef);
-	BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_0, 0xffbf);
-	if (mac->mac_phy.rev >= 2) {
-		BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_2, 0xfeff);
-		if (IEEE80211_IS_CHAN_2GHZ(ic->ic_curchan)) {
-			BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_2, 0xfbff);
-			BWN_PHY_MASK(mac, BWN_PHY_OFDM(0xe5), 0xfff7);
-		}
-	} else {
-		BWN_PHY_MASK(mac, BWN_PHY_RF_OVERRIDE_2, 0xfdff);
-	}
-
-	BWN_PHY_MASK(mac, BWN_PHY_AFE_CTL_OVR, 0xfffe);
-	BWN_PHY_MASK(mac, BWN_PHY_AFE_CTL_OVRVAL, 0xf7ff);
-fail:
-	bwn_mac_enable(mac);
-}
-
-static void
-bwn_phy_lp_switch_analog(struct bwn_mac *mac, int on)
-{
-
-	if (on) {
-		BWN_PHY_MASK(mac, BWN_PHY_AFE_CTL_OVR, 0xfff8);
-		return;
-	}
-
-	BWN_PHY_SET(mac, BWN_PHY_AFE_CTL_OVRVAL, 0x0007);
-	BWN_PHY_SET(mac, BWN_PHY_AFE_CTL_OVR, 0x0007);
-}
-
-static int
-bwn_phy_lp_b2063_switch_channel(struct bwn_mac *mac, uint8_t chan)
-{
-	static const struct bwn_b206x_chan *bc = NULL;
-	struct bwn_softc *sc = mac->mac_sc;
-	uint32_t count, freqref, freqvco, freqxtal, val[3], timeout, timeoutref,
-	    tmp[6];
-	uint16_t old, scale, tmp16;
-	int i, div;
-
-	for (i = 0; i < N(bwn_b2063_chantable); i++) {
-		if (bwn_b2063_chantable[i].bc_chan == chan) {
-			bc = &bwn_b2063_chantable[i];
-			break;
-		}
-	}
-	if (bc == NULL)
-		return (EINVAL);
-
-	BWN_RF_WRITE(mac, BWN_B2063_LOGEN_VCOBUF1, bc->bc_data[0]);
-	BWN_RF_WRITE(mac, BWN_B2063_LOGEN_MIXER2, bc->bc_data[1]);
-	BWN_RF_WRITE(mac, BWN_B2063_LOGEN_BUF2, bc->bc_data[2]);
-	BWN_RF_WRITE(mac, BWN_B2063_LOGEN_RCCR1, bc->bc_data[3]);
-	BWN_RF_WRITE(mac, BWN_B2063_A_RX_1ST3, bc->bc_data[4]);
-	BWN_RF_WRITE(mac, BWN_B2063_A_RX_2ND1, bc->bc_data[5]);
-	BWN_RF_WRITE(mac, BWN_B2063_A_RX_2ND4, bc->bc_data[6]);
-	BWN_RF_WRITE(mac, BWN_B2063_A_RX_2ND7, bc->bc_data[7]);
-	BWN_RF_WRITE(mac, BWN_B2063_A_RX_PS6, bc->bc_data[8]);
-	BWN_RF_WRITE(mac, BWN_B2063_TX_RF_CTL2, bc->bc_data[9]);
-	BWN_RF_WRITE(mac, BWN_B2063_TX_RF_CTL5, bc->bc_data[10]);
-	BWN_RF_WRITE(mac, BWN_B2063_PA_CTL11, bc->bc_data[11]);
-
-	old = BWN_RF_READ(mac, BWN_B2063_COM15);
-	BWN_RF_SET(mac, BWN_B2063_COM15, 0x1e);
-
-	freqxtal = siba_get_cc_pmufreq(sc->sc_dev) * 1000;
-	freqvco = bc->bc_freq << ((bc->bc_freq > 4000) ? 1 : 2);
-	freqref = freqxtal * 3;
-	div = (freqxtal <= 26000000 ? 1 : 2);
-	timeout = ((((8 * freqxtal) / (div * 5000000)) + 1) >> 1) - 1;
-	timeoutref = ((((8 * freqxtal) / (div * (timeout + 1))) +
-		999999) / 1000000) + 1;
-
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_VCO_CALIB3, 0x2);
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_VCO_CALIB6,
-	    0xfff8, timeout >> 2);
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_VCO_CALIB7,
-	    0xff9f,timeout << 5);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_VCO_CALIB5, timeoutref);
-
-	val[0] = bwn_phy_lp_roundup(freqxtal, 1000000, 16);
-	val[1] = bwn_phy_lp_roundup(freqxtal, 1000000 * div, 16);
-	val[2] = bwn_phy_lp_roundup(freqvco, 3, 16);
-
-	count = (bwn_phy_lp_roundup(val[2], val[1] + 16, 16) * (timeout + 1) *
-	    (timeoutref + 1)) - 1;
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_VCO_CALIB7,
-	    0xf0, count >> 8);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_VCO_CALIB8, count & 0xff);
-
-	tmp[0] = ((val[2] * 62500) / freqref) << 4;
-	tmp[1] = ((val[2] * 62500) % freqref) << 4;
-	while (tmp[1] >= freqref) {
-		tmp[0]++;
-		tmp[1] -= freqref;
-	}
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_SG1, 0xffe0, tmp[0] >> 4);
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_SG2, 0xfe0f, tmp[0] << 4);
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_SG2, 0xfff0, tmp[0] >> 16);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_SG3, (tmp[1] >> 8) & 0xff);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_SG4, tmp[1] & 0xff);
-
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_LF1, 0xb9);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_LF2, 0x88);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_LF3, 0x28);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_LF4, 0x63);
-
-	tmp[2] = ((41 * (val[2] - 3000)) /1200) + 27;
-	tmp[3] = bwn_phy_lp_roundup(132000 * tmp[0], 8451, 16);
-
-	if (howmany(tmp[3], tmp[2]) > 60) {
-		scale = 1;
-		tmp[4] = ((tmp[3] + tmp[2]) / (tmp[2] << 1)) - 8;
-	} else {
-		scale = 0;
-		tmp[4] = ((tmp[3] + (tmp[2] >> 1)) / tmp[2]) - 8;
-	}
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_CP2, 0xffc0, tmp[4]);
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_CP2, 0xffbf, scale << 6);
-
-	tmp[5] = bwn_phy_lp_roundup(100 * val[0], val[2], 16) * (tmp[4] * 8) *
-	    (scale + 1);
-	if (tmp[5] > 150)
-		tmp[5] = 0;
-
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_CP3, 0xffe0, tmp[5]);
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_CP3, 0xffdf, scale << 5);
-
-	BWN_RF_SETMASK(mac, BWN_B2063_JTAG_XTAL_12, 0xfffb, 0x4);
-	if (freqxtal > 26000000)
-		BWN_RF_SET(mac, BWN_B2063_JTAG_XTAL_12, 0x2);
-	else
-		BWN_RF_MASK(mac, BWN_B2063_JTAG_XTAL_12, 0xfd);
-
-	if (val[0] == 45)
-		BWN_RF_SET(mac, BWN_B2063_JTAG_VCO1, 0x2);
-	else
-		BWN_RF_MASK(mac, BWN_B2063_JTAG_VCO1, 0xfd);
-
-	BWN_RF_SET(mac, BWN_B2063_PLL_SP2, 0x3);
-	DELAY(1);
-	BWN_RF_MASK(mac, BWN_B2063_PLL_SP2, 0xfffc);
-
-	/* VCO Calibration */
-	BWN_RF_MASK(mac, BWN_B2063_PLL_SP1, ~0x40);
-	tmp16 = BWN_RF_READ(mac, BWN_B2063_JTAG_CALNRST) & 0xf8;
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_CALNRST, tmp16);
-	DELAY(1);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_CALNRST, tmp16 | 0x4);
-	DELAY(1);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_CALNRST, tmp16 | 0x6);
-	DELAY(1);
-	BWN_RF_WRITE(mac, BWN_B2063_JTAG_CALNRST, tmp16 | 0x7);
-	DELAY(300);
-	BWN_RF_SET(mac, BWN_B2063_PLL_SP1, 0x40);
-
-	BWN_RF_WRITE(mac, BWN_B2063_COM15, old);
-	return (0);
-}
-
-static int
-bwn_phy_lp_b2062_switch_channel(struct bwn_mac *mac, uint8_t chan)
-{
-	struct bwn_softc *sc = mac->mac_sc;
-	struct bwn_phy_lp *plp = &mac->mac_phy.phy_lp;
-	const struct bwn_b206x_chan *bc = NULL;
-	uint32_t freqxtal = siba_get_cc_pmufreq(sc->sc_dev) * 1000;
-	uint32_t tmp[9];
-	int i;
-
-	for (i = 0; i < N(bwn_b2062_chantable); i++) {
-		if (bwn_b2062_chantable[i].bc_chan == chan) {
-			bc = &bwn_b2062_chantable[i];
-			break;
-		}
-	}
-
-	if (bc == NULL)
-		return (EINVAL);
-
-	BWN_RF_SET(mac, BWN_B2062_S_RFPLLCTL14, 0x04);
-	BWN_RF_WRITE(mac, BWN_B2062_N_LGENATUNE0, bc->bc_data[0]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_LGENATUNE2, bc->bc_data[1]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_LGENATUNE3, bc->bc_data[2]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_TX_TUNE, bc->bc_data[3]);
-	BWN_RF_WRITE(mac, BWN_B2062_S_LGENG_CTL1, bc->bc_data[4]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_LGENACTL5, bc->bc_data[5]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_LGENACTL6, bc->bc_data[6]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_TX_PGA, bc->bc_data[7]);
-	BWN_RF_WRITE(mac, BWN_B2062_N_TX_PAD, bc->bc_data[8]);
-
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL33, 0xcc);
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL34, 0x07);
-	bwn_phy_lp_b2062_reset_pllbias(mac);
-	tmp[0] = freqxtal / 1000;
-	tmp[1] = plp->plp_div * 1000;
-	tmp[2] = tmp[1] * ieee80211_ieee2mhz(chan, 0);
-	if (ieee80211_ieee2mhz(chan, 0) < 4000)
-		tmp[2] *= 2;
-	tmp[3] = 48 * tmp[0];
-	tmp[5] = tmp[2] / tmp[3];
-	tmp[6] = tmp[2] % tmp[3];
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL26, tmp[5]);
-	tmp[4] = tmp[6] * 0x100;
-	tmp[5] = tmp[4] / tmp[3];
-	tmp[6] = tmp[4] % tmp[3];
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL27, tmp[5]);
-	tmp[4] = tmp[6] * 0x100;
-	tmp[5] = tmp[4] / tmp[3];
-	tmp[6] = tmp[4] % tmp[3];
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL28, tmp[5]);
-	tmp[4] = tmp[6] * 0x100;
-	tmp[5] = tmp[4] / tmp[3];
-	tmp[6] = tmp[4] % tmp[3];
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL29,
-	    tmp[5] + ((2 * tmp[6]) / tmp[3]));
-	tmp[7] = BWN_RF_READ(mac, BWN_B2062_S_RFPLLCTL19);
-	tmp[8] = ((2 * tmp[2] * (tmp[7] + 1)) + (3 * tmp[0])) / (6 * tmp[0]);
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL23, (tmp[8] >> 8) + 16);
-	BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL24, tmp[8] & 0xff);
-
-	bwn_phy_lp_b2062_vco_calib(mac);
-	if (BWN_RF_READ(mac, BWN_B2062_S_RFPLLCTL3) & 0x10) {
-		BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL33, 0xfc);
-		BWN_RF_WRITE(mac, BWN_B2062_S_RFPLLCTL34, 0);
-		bwn_phy_lp_b2062_reset_pllbias(mac);
-		bwn_phy_lp_b2062_vco_calib(mac);
-		if (BWN_RF_READ(mac, BWN_B2062_S_RFPLLCTL3) & 0x10) {
-			BWN_RF_MASK(mac, BWN_B2062_S_RFPLLCTL14, ~0x04);
-			return (EIO);
-		}
-	}
-	BWN_RF_MASK(mac, BWN_B2062_S_RFPLLCTL14, ~0x04);
-	return (0);
-}
-
-static void
-bwn_phy_lp_set_anafilter(struct bwn_mac *mac, uint8_t channel)
-{
-	struct bwn_phy_lp *plp = &mac->mac_phy.phy_lp;
-	uint16_t tmp = (channel == 14);
-
-	if (mac->mac_phy.rev < 2) {
-		BWN_PHY_SETMASK(mac, BWN_PHY_LP_PHY_CTL, 0xfcff, tmp << 9);
-		if ((mac->mac_phy.rev == 1) && (plp->plp_rccap))

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list