[PATCH 1/7] b43: N-PHY: implement RX PHY cleanup and setup

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |   82 ++
  1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 4a817e3..4a1853b 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -579,6 +579,88 @@ static void b43_nphy_calc_rx_iq_comp(struct b43_wldev 
*dev, u8 mask)
b43_nphy_rx_iq_coeffs(dev, true, new);
  }

+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhyCleanup */
+static void b43_nphy_rx_cal_phy_cleanup(struct b43_wldev *dev, u8 core)
+{
+   u16 *regs = dev-phy.n-tx_rx_cal_phy_saveregs;
+
+   b43_phy_write(dev, B43_NPHY_RFSEQCA, regs[0]);
+   if (core == 0) {
+   b43_phy_write(dev, B43_NPHY_AFECTL_C1, regs[1]);
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, regs[2]);
+   } else {
+   b43_phy_write(dev, B43_NPHY_AFECTL_C2, regs[1]);
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[2]);
+   }
+   b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[3]);
+   b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[4]);
+   b43_phy_write(dev, B43_NPHY_RFCTL_RSSIO1, regs[5]);
+   b43_phy_write(dev, B43_NPHY_RFCTL_RSSIO2, regs[6]);
+   b43_phy_write(dev, B43_NPHY_TXF_40CO_B1S1, regs[7]);
+   b43_phy_write(dev, B43_NPHY_RFCTL_OVER, regs[8]);
+   b43_phy_write(dev, B43_NPHY_PAPD_EN0, regs[9]);
+   b43_phy_write(dev, B43_NPHY_PAPD_EN1, regs[10]);
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxCalPhySetup */
+static void b43_nphy_rx_cal_phy_setup(struct b43_wldev *dev, u8 core)
+{
+   u8 rxval, txval;
+   u16 *regs = dev-phy.n-tx_rx_cal_phy_saveregs;
+
+   regs[0] = b43_phy_read(dev, B43_NPHY_RFSEQCA);
+   if (core == 0) {
+   regs[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
+   regs[2] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1);
+   } else {
+   regs[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
+   regs[2] = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
+   }
+   regs[3] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
+   regs[4] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);
+   regs[5] = b43_phy_read(dev, B43_NPHY_RFCTL_RSSIO1);
+   regs[6] = b43_phy_read(dev, B43_NPHY_RFCTL_RSSIO2);
+   regs[7] = b43_phy_read(dev, B43_NPHY_TXF_40CO_B1S1);
+   regs[8] = b43_phy_read(dev, B43_NPHY_RFCTL_OVER);
+   regs[9] = b43_phy_read(dev, B43_NPHY_PAPD_EN0);
+   regs[10] = b43_phy_read(dev, B43_NPHY_PAPD_EN1);
+
+   b43_phy_mask(dev, B43_NPHY_PAPD_EN0, ~0x0001);
+   b43_phy_mask(dev, B43_NPHY_PAPD_EN1, ~0x0001);
+
+   b43_phy_maskset(dev, B43_NPHY_RFSEQCA, (u16)~B43_NPHY_RFSEQCA_RXDIS,
+   ((1 - core)  B43_NPHY_RFSEQCA_RXDIS_SHIFT));
+   b43_phy_maskset(dev, B43_NPHY_RFSEQCA, ~B43_NPHY_RFSEQCA_TXEN,
+   ((1 - core)  B43_NPHY_RFSEQCA_TXEN_SHIFT));
+   b43_phy_maskset(dev, B43_NPHY_RFSEQCA, ~B43_NPHY_RFSEQCA_RXEN,
+   (core  B43_NPHY_RFSEQCA_RXEN_SHIFT));
+   b43_phy_maskset(dev, B43_NPHY_RFSEQCA, ~B43_NPHY_RFSEQCA_TXDIS,
+   (core  B43_NPHY_RFSEQCA_TXDIS_SHIFT));
+
+   if (core == 0) {
+   b43_phy_mask(dev, B43_NPHY_AFECTL_C1, ~0x0007);
+   b43_phy_set(dev, B43_NPHY_AFECTL_OVER1, 0x0007);
+   } else {
+   b43_phy_mask(dev, B43_NPHY_AFECTL_C2, ~0x0007);
+   b43_phy_set(dev, B43_NPHY_AFECTL_OVER, 0x0007);
+   }
+
+   /* TODO: Call N PHY RF Ctrl Intc Override with 2, 0, 3 as arguments */
+   /* TODO: Call N PHY RF Intc Override with 8, 0, 3, 0 as arguments */
+   /* TODO: Call N PHY RF Seq with 0 as argument */
+
+   if (core == 0) {
+   rxval = 1;
+   txval = 8;
+   } else {
+   rxval = 4;
+   txval = 2;
+   }
+
+   /* TODO: Call N PHY RF Ctrl Intc Override with 1, rxval, (core + 1) */
+   /* TODO: Call N PHY RF Ctrl Intc Override with 1, txval, (2 - core) */
+}
+
  /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxIqWar */
  static void b43_nphy_tx_iq_workaround(struct b43_wldev *dev)
  {
-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 2/7] b43: N-PHY: implement TX PHY cleanup and setup

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |  112 +-
  1 files changed, 110 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 4a1853b..34dd4a2 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1505,6 +1505,114 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct 
b43_wldev *dev)
return target;
  }

+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */
+static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev *dev)
+{
+   u16 *regs = dev-phy.n-tx_rx_cal_phy_saveregs;
+
+   if (dev-phy.rev = 3) {
+   b43_phy_write(dev, B43_NPHY_AFECTL_C1, regs[0]);
+   b43_phy_write(dev, B43_NPHY_AFECTL_C2, regs[1]);
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, regs[2]);
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[3]);
+   b43_phy_write(dev, B43_NPHY_BBCFG, regs[4]);
+   /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
+   width 16, and data from regs[5] */
+   /* TODO: Write an N PHY Table with ID 8, length 1, offset 19,
+   width 16, and data from regs[6] */
+   b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[7]);
+   b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[8]);
+   b43_phy_write(dev, B43_NPHY_PAPD_EN0, regs[9]);
+   b43_phy_write(dev, B43_NPHY_PAPD_EN1, regs[10]);
+   b43_nphy_reset_cca(dev);
+   } else {
+   b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, regs[0]);
+   b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, regs[1]);
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[2]);
+   /* TODO: Write an N PHY Table with ID 8, length 1, offset 2,
+   width 16, and data from regs[3] */
+   /* TODO: Write an N PHY Table with ID 8, length 1, offset 18,
+   width 16, and data from regs[4] */
+   b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[5]);
+   b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[6]);
+   }
+}
+
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */
+static void b43_nphy_tx_cal_phy_setup(struct b43_wldev *dev)
+{
+   u16 *regs = dev-phy.n-tx_rx_cal_phy_saveregs;
+   u16 tmp;
+
+   regs[0] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
+   regs[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
+   if (dev-phy.rev = 3) {
+   b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0xF0FF, 0x0A00);
+   b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0xF0FF, 0x0A00);
+
+   tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1);
+   regs[2] = tmp;
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, tmp | 0x0600);
+
+   tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
+   regs[3] = tmp;
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER, tmp | 0x0600);
+
+   regs[4] = b43_phy_read(dev, B43_NPHY_BBCFG);
+   b43_phy_mask(dev, B43_NPHY_BBCFG, ~B43_NPHY_BBCFG_RSTRX);
+
+   /* TODO: Read an N PHY Table with ID 8, length 1, offset 3,
+   width 16, and data pointing to tmp */
+   regs[5] = tmp;
+
+   /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
+   width 16, and data 0 */
+   /* TODO: Read an N PHY Table with ID 8, length 1, offset 19,
+   width 16, and data pointing to tmp */
+   regs[6] = tmp;
+
+   /* TODO: Write an N PHY Table with ID 8, length 1, offset 19,
+   width 16, and data 0 */
+   regs[7] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
+   regs[8] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);
+
+   /* TODO: Call N PHY RF Ctrl Intc Override with 2, 1, 3 */
+   /* TODO: Call N PHY RF Ctrl Intc Override with 1, 2, 1 */
+   /* TODO: Call N PHY RF Ctrl Intc Override with 1, 8, 2 */
+
+   regs[9] = b43_phy_read(dev, B43_NPHY_PAPD_EN0);
+   regs[10] = b43_phy_read(dev, B43_NPHY_PAPD_EN1);
+   b43_phy_mask(dev, B43_NPHY_PAPD_EN0, ~0x0001);
+   b43_phy_mask(dev, B43_NPHY_PAPD_EN1, ~0x0001);
+   } else {
+   b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, 0xA000);
+   b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, 0xA000);
+   tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
+   regs[2] = tmp;
+   b43_phy_write(dev, B43_NPHY_AFECTL_OVER, tmp | 0x3000);
+   /* TODO: Read an N PHY Table with ID 8, length 1, offset 2,
+   width 16, and data pointing to tmp */
+   regs[3] = tmp;
+   tmp |= 0x2000;
+ 

[PATCH 3/7] b43: N-PHY: implement MIMO config update

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |   16 +++-
  drivers/net/wireless/b43/phy_n.h |1 +
  2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 34dd4a2..582d6b0 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -424,6 +424,20 @@ static void b43_nphy_reset_cca(struct b43_wldev *dev)
/* TODO: N PHY Force RF Seq with argument 2 */
  }

+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */
+static void b43_nphy_update_mimo_config(struct b43_wldev *dev, s32 preamble)
+{
+   u16 mimocfg = b43_phy_read(dev, B43_NPHY_MIMOCFG);
+
+   mimocfg |= B43_NPHY_MIMOCFG_AUTO;
+   if (preamble == 1)
+   mimocfg |= B43_NPHY_MIMOCFG_GFMIX;
+   else
+   mimocfg = ~B43_NPHY_MIMOCFG_GFMIX;
+
+   b43_phy_write(dev, B43_NPHY_MIMOCFG, mimocfg);
+}
+
  /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */
  static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est,
u16 samps, u8 time, bool wait)
@@ -2180,7 +2194,7 @@ int b43_phy_initn(struct b43_wldev *dev)
b43_phy_write(dev, B43_NPHY_PLOAD_CSENSE_EXTLEN, 0x50);
b43_phy_write(dev, B43_NPHY_TXRIFS_FRDEL, 0x30);

-   /* TODO MIMO-Config */
+   b43_nphy_update_mimo_config(dev, nphy-preamble_override);
/* TODO Update TX/RX chain */

if (phy-rev  2) {
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index 4572866..ae00e3f 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -973,6 +973,7 @@ struct b43_phy_n {
bool hang_avoid;
bool mute;
u16 papd_epsilon_offset[2];
+   s32 preamble_override;

u8 mphase_cal_phase_id;
u16 mphase_txcal_cmdidx;
-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 4/7] b43: N-PHY: implement stopping playback

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |   34 +++---
  drivers/net/wireless/b43/phy_n.h |1 +
  2 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 582d6b0..c6d3d5a 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -749,6 +749,34 @@ static void b43_nphy_stay_in_carrier_search(struct 
b43_wldev *dev, bool enable)
}
  }

+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/stop-playback */
+static void b43_nphy_stop_playback(struct b43_wldev *dev)
+{
+   struct b43_phy_n *nphy = dev-phy.n;
+   u16 tmp;
+
+   if (nphy-hang_avoid)
+   b43_nphy_stay_in_carrier_search(dev, 1);
+
+   tmp = b43_phy_read(dev, B43_NPHY_SAMP_STAT);
+   if (tmp  0x1)
+   b43_phy_set(dev, B43_NPHY_SAMP_CMD, B43_NPHY_SAMP_CMD_STOP);
+   else if (tmp  0x2)
+   b43_phy_mask(dev, B43_NPHY_IQLOCAL_CMDGCTL, (u16)~0x8000);
+
+   b43_phy_mask(dev, B43_NPHY_SAMP_CMD, ~0x0004);
+
+   if (nphy-bb_mult_save  0x8000) {
+   tmp = nphy-bb_mult_save  0x;
+   /* TODO: Write an N PHY Table with ID 15, length 1, offset 87,
+   width 16 and data from tmp */
+   nphy-bb_mult_save = 0;
+   }
+
+   if (nphy-hang_avoid)
+   b43_nphy_stay_in_carrier_search(dev, 0);
+}
+
  /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxPwrCtrlCoefSetup */
  static void b43_nphy_tx_pwr_ctrl_coef_setup(struct b43_wldev *dev)
  {
@@ -1906,7 +1934,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
nphy-mphase_txcal_bestcoeffs */
}

-   /* TODO: Call N PHY Stop Playback */
+   b43_nphy_stop_playback(dev);
b43_phy_write(dev, B43_NPHY_IQLOCAL_CMDGCTL, 0);
}

@@ -2053,7 +2081,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
/* TODO:Call N PHY RF Ctrl Override with 0x400, tmp[0],
3, 0 as arguments */
/* TODO: Call N PHY Force RF Seq with 2 as argument */
-   /* TODO: Call N PHT Stop Playback */
+   b43_nphy_stop_playback(dev);

if (playtone) {
/* TODO: Call N PHY TX Tone with 4000,
@@ -2080,7 +2108,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
} else {
b43_nphy_calc_rx_iq_comp(dev, 1  i);
}
-   /* TODO: Call N PHY Stop Playback */
+   b43_nphy_stop_playback(dev);
}

if (ret != 0)
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index ae00e3f..d6c92a8 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -974,6 +974,7 @@ struct b43_phy_n {
bool mute;
u16 papd_epsilon_offset[2];
s32 preamble_override;
+   u32 bb_mult_save;

u8 mphase_cal_phase_id;
u16 mphase_txcal_cmdidx;
-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 5/7] b43: N-PHY: implement chain selection

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |   30 +-
  drivers/net/wireless/b43/phy_n.h |1 +
  2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index c6d3d5a..d24e2b4 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -438,6 +438,34 @@ static void b43_nphy_update_mimo_config(struct b43_wldev 
*dev, s32 preamble)
b43_phy_write(dev, B43_NPHY_MIMOCFG, mimocfg);
  }

+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/Chains */
+static void b43_nphy_update_txrx_chain(struct b43_wldev *dev)
+{
+   struct b43_phy_n *nphy = dev-phy.n;
+
+   bool override = false;
+   u16 chain = 0x33;
+
+   if (nphy-txrx_chain == 0) {
+   chain = 0x11;
+   override = true;
+   } else if (nphy-txrx_chain == 1) {
+   chain = 0x22;
+   override = true;
+   }
+
+   b43_phy_maskset(dev, B43_NPHY_RFSEQCA,
+   ~(B43_NPHY_RFSEQCA_TXEN | B43_NPHY_RFSEQCA_RXEN),
+   chain);
+
+   if (override)
+   b43_phy_set(dev, B43_NPHY_RFSEQMODE,
+   B43_NPHY_RFSEQMODE_CAOVER);
+   else
+   b43_phy_mask(dev, B43_NPHY_RFSEQMODE,
+   ~B43_NPHY_RFSEQMODE_CAOVER);
+}
+
  /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/RxIqEst */
  static void b43_nphy_rx_iq_est(struct b43_wldev *dev, struct nphy_iq_est *est,
u16 samps, u8 time, bool wait)
@@ -2223,7 +2251,7 @@ int b43_phy_initn(struct b43_wldev *dev)
b43_phy_write(dev, B43_NPHY_TXRIFS_FRDEL, 0x30);

b43_nphy_update_mimo_config(dev, nphy-preamble_override);
-   /* TODO Update TX/RX chain */
+   b43_nphy_update_txrx_chain(dev);

if (phy-rev  2) {
b43_phy_write(dev, B43_NPHY_DUP40_GFBL, 0xAA8);
diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h
index d6c92a8..f5a2766 100644
--- a/drivers/net/wireless/b43/phy_n.h
+++ b/drivers/net/wireless/b43/phy_n.h
@@ -987,6 +987,7 @@ struct b43_phy_n {
bool txiqlocal_coeffsvalid;
struct b43_phy_n_txpwrindex txpwrindex[2];

+   u8 txrx_chain;
u16 tx_rx_cal_phy_saveregs[11];
u16 tx_rx_cal_radio_saveregs[22];

-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 6/7] b43: N-PHY: move RF sequence declarations top, add missing calls

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |   28 
  1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index d24e2b4..34be98b 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -55,6 +55,18 @@ struct nphy_iq_est {
u32 q1_pwr;
  };

+enum b43_nphy_rf_sequence {
+   B43_RFSEQ_RX2TX,
+   B43_RFSEQ_TX2RX,
+   B43_RFSEQ_RESET2RX,
+   B43_RFSEQ_UPDATE_GAINH,
+   B43_RFSEQ_UPDATE_GAINL,
+   B43_RFSEQ_UPDATE_GAINU,
+};
+
+static void b43_nphy_force_rf_sequence(struct b43_wldev *dev,
+  enum b43_nphy_rf_sequence seq);
+
  void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
  {//TODO
  }
@@ -421,7 +433,7 @@ static void b43_nphy_reset_cca(struct b43_wldev *dev)
udelay(1);
b43_phy_write(dev, B43_NPHY_BBCFG, bbcfg  ~B43_NPHY_BBCFG_RSTCCA);
b43_nphy_bmac_clock_fgc(dev, 0);
-   /* TODO: N PHY Force RF Seq with argument 2 */
+   b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
  }

  /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/MIMOConfig */
@@ -689,7 +701,7 @@ static void b43_nphy_rx_cal_phy_setup(struct b43_wldev 
*dev, u8 core)

/* TODO: Call N PHY RF Ctrl Intc Override with 2, 0, 3 as arguments */
/* TODO: Call N PHY RF Intc Override with 8, 0, 3, 0 as arguments */
-   /* TODO: Call N PHY RF Seq with 0 as argument */
+   b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RX2TX);

if (core == 0) {
rxval = 1;
@@ -872,15 +884,7 @@ static void b43_nphy_tx_pwr_ctrl_coef_setup(struct 
b43_wldev *dev)
b43_nphy_stay_in_carrier_search(dev, false);
  }

-enum b43_nphy_rf_sequence {
-   B43_RFSEQ_RX2TX,
-   B43_RFSEQ_TX2RX,
-   B43_RFSEQ_RESET2RX,
-   B43_RFSEQ_UPDATE_GAINH,
-   B43_RFSEQ_UPDATE_GAINL,
-   B43_RFSEQ_UPDATE_GAINU,
-};
-
+/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ForceRFSeq */
  static void b43_nphy_force_rf_sequence(struct b43_wldev *dev,
   enum b43_nphy_rf_sequence seq)
  {
@@ -2156,7 +2160,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
}

/* TODO: Call N PHY RF Ctrl Override with 0x400, 0, 3, 1 as arguments*/
-   /* TODO: Call N PHY Force RF Seq with 2 as argument */
+   b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
/* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110,
width 16, and data from gain_save */

-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 7/7] b43: N-PHY: store seq mode for proper restoring (follow specs)

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 34be98b..141d4ed 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -897,6 +897,7 @@ static void b43_nphy_force_rf_sequence(struct b43_wldev 
*dev,
[B43_RFSEQ_UPDATE_GAINU]= B43_NPHY_RFSEQTR_UPGU,
};
int i;
+   u16 seq_mode = b43_phy_read(dev, B43_NPHY_RFSEQMODE);

B43_WARN_ON(seq = ARRAY_SIZE(trigger));

@@ -910,8 +911,7 @@ static void b43_nphy_force_rf_sequence(struct b43_wldev 
*dev,
}
b43err(dev-wl, RF sequence status timeout\n);
  ok:
-   b43_phy_mask(dev, B43_NPHY_RFSEQMODE,
-~(B43_NPHY_RFSEQMODE_CAOVER | B43_NPHY_RFSEQMODE_TROVER));
+   b43_phy_write(dev, B43_NPHY_RFSEQMODE, seq_mode);
  }

  static void b43_nphy_bphy_init(struct b43_wldev *dev)
-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: [PATCH 2/7] b43: N-PHY: implement TX PHY cleanup and setup

2010-01-17 Thread Gábor Stefanik
2010/1/17 Rafał Miłecki zaj...@gmail.com:

 Signed-off-by: Rafał Miłecki zaj...@gmail.com
 ---
  drivers/net/wireless/b43/phy_n.c |  112
 +-
  1 files changed, 110 insertions(+), 2 deletions(-)

 diff --git a/drivers/net/wireless/b43/phy_n.c
 b/drivers/net/wireless/b43/phy_n.c
 index 4a1853b..34dd4a2 100644
 --- a/drivers/net/wireless/b43/phy_n.c
 +++ b/drivers/net/wireless/b43/phy_n.c
 @@ -1505,6 +1505,114 @@ static struct nphy_txgains
 b43_nphy_get_tx_gains(struct b43_wldev *dev)
        return target;
  }

 +/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhyCleanup */
 +static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev *dev)
 +{
 +       u16 *regs = dev-phy.n-tx_rx_cal_phy_saveregs;
 +
 +       if (dev-phy.rev = 3) {
 +               b43_phy_write(dev, B43_NPHY_AFECTL_C1, regs[0]);
 +               b43_phy_write(dev, B43_NPHY_AFECTL_C2, regs[1]);
 +               b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, regs[2]);
 +               b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[3]);
 +               b43_phy_write(dev, B43_NPHY_BBCFG, regs[4]);
 +               /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
 +                       width 16, and data from regs[5] */
 +               /* TODO: Write an N PHY Table with ID 8, length 1, offset
 19,

While you are at it, why aren't you programming these table writes?
The table handling functions are AFAIK already in place...

 +                       width 16, and data from regs[6] */
 +               b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[7]);
 +               b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[8]);
 +               b43_phy_write(dev, B43_NPHY_PAPD_EN0, regs[9]);
 +               b43_phy_write(dev, B43_NPHY_PAPD_EN1, regs[10]);
 +               b43_nphy_reset_cca(dev);
 +       } else {
 +               b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, regs[0]);
 +               b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, regs[1]);
 +               b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[2]);
 +               /* TODO: Write an N PHY Table with ID 8, length 1, offset 2,
 +                       width 16, and data from regs[3] */
 +               /* TODO: Write an N PHY Table with ID 8, length 1, offset
 18,
 +                       width 16, and data from regs[4] */
 +               b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[5]);
 +               b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[6]);
 +       }
 +}
 +
 +/* http://bcm-v4.sipsolutions.net/802.11/PHY/N/TxCalPhySetup */
 +static void b43_nphy_tx_cal_phy_setup(struct b43_wldev *dev)
 +{
 +       u16 *regs = dev-phy.n-tx_rx_cal_phy_saveregs;
 +       u16 tmp;
 +
 +       regs[0] = b43_phy_read(dev, B43_NPHY_AFECTL_C1);
 +       regs[1] = b43_phy_read(dev, B43_NPHY_AFECTL_C2);
 +       if (dev-phy.rev = 3) {
 +               b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0xF0FF, 0x0A00);
 +               b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0xF0FF, 0x0A00);
 +
 +               tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER1);
 +               regs[2] = tmp;
 +               b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, tmp | 0x0600);
 +
 +               tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
 +               regs[3] = tmp;
 +               b43_phy_write(dev, B43_NPHY_AFECTL_OVER, tmp | 0x0600);
 +
 +               regs[4] = b43_phy_read(dev, B43_NPHY_BBCFG);
 +               b43_phy_mask(dev, B43_NPHY_BBCFG, ~B43_NPHY_BBCFG_RSTRX);
 +
 +               /* TODO: Read an N PHY Table with ID 8, length 1, offset 3,
 +                       width 16, and data pointing to tmp */
 +               regs[5] = tmp;
 +
 +               /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
 +                       width 16, and data 0 */
 +               /* TODO: Read an N PHY Table with ID 8, length 1, offset 19,
 +                       width 16, and data pointing to tmp */
 +               regs[6] = tmp;
 +
 +               /* TODO: Write an N PHY Table with ID 8, length 1, offset
 19,
 +                       width 16, and data 0 */
 +               regs[7] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
 +               regs[8] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);
 +
 +               /* TODO: Call N PHY RF Ctrl Intc Override with 2, 1, 3 */
 +               /* TODO: Call N PHY RF Ctrl Intc Override with 1, 2, 1 */
 +               /* TODO: Call N PHY RF Ctrl Intc Override with 1, 8, 2 */
 +
 +               regs[9] = b43_phy_read(dev, B43_NPHY_PAPD_EN0);
 +               regs[10] = b43_phy_read(dev, B43_NPHY_PAPD_EN1);
 +               b43_phy_mask(dev, B43_NPHY_PAPD_EN0, ~0x0001);
 +               b43_phy_mask(dev, B43_NPHY_PAPD_EN1, ~0x0001);
 +       } else {
 +               b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, 0xA000);
 +               b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, 0xA000);
 +               tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
 +               regs[2] = tmp;
 +         

Re: [PATCH 2/7] b43: N-PHY: implement TX PHY cleanup and setup

2010-01-17 Thread Michael Buesch
On Sunday 17 January 2010 17:37:29 Gábor Stefanik wrote:
 While you are at it, why aren't you programming these table writes?
 The table handling functions are AFAIK already in place...

Because we like small patches.
Please do _not_ increase the patchsize.

-- 
Greetings, Michael.
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: [PATCH 2/7] b43: N-PHY: implement TX PHY cleanup and setup

2010-01-17 Thread Rafał Miłecki
2010/1/17 Gábor Stefanik netrolller...@gmail.com:
 On Sun, Jan 17, 2010 at 5:41 PM, Michael Buesch m...@bu3sch.de wrote:
 On Sunday 17 January 2010 17:37:29 Gábor Stefanik wrote:
 While you are at it, why aren't you programming these table writes?
 The table handling functions are AFAIK already in place...

 Because we like small patches.
 Please do _not_ increase the patchsize.

 They do not increase patch size - table reads/writes are one-line (in
 fact, they are shorter than the placeholder comments in place of
 them).

Well, I just started implementing code without understanding of
tables... and got stick in implementing functions. There are some
crazy IDs, offsets and it's not only writing but also some
mysterious table reading... You know, it just sounds scary ;)

I'll have to finally read specs/existing code for tables, understand
it and implement.

-- 
Rafał
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 1/4] b43: N-PHY: add writing one element tables

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c |   51 -
  1 files changed, 17 insertions(+), 34 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 141d4ed..31eba7d 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -808,8 +808,7 @@ static void b43_nphy_stop_playback(struct b43_wldev *dev)

if (nphy-bb_mult_save  0x8000) {
tmp = nphy-bb_mult_save  0x;
-   /* TODO: Write an N PHY Table with ID 15, length 1, offset 87,
-   width 16 and data from tmp */
+   b43_ntab_write(dev, B43_NTAB16(15, 87), tmp);
nphy-bb_mult_save = 0;
}

@@ -1486,13 +1485,11 @@ static void b43_nphy_update_tx_cal_ladder(struct 
b43_wldev *dev, u16 core)
for (i = 0; i  18; i++) {
scale = (ladder_lo[i].percent * tmp) / 100;
entry = ((scale  0xFF)  8) | ladder_lo[i].g_env;
-   /* TODO: Write an N PHY Table with ID 15, length 1,
-   offset i, width 16, and data entry */
+   b43_ntab_write(dev, B43_NTAB16(15, i), entry);

scale = (ladder_iq[i].percent * tmp) / 100;
entry = ((scale  0xFF)  8) | ladder_iq[i].g_env;
-   /* TODO: Write an N PHY Table with ID 15, length 1,
-   offset i + 32, width 16, and data entry */
+   b43_ntab_write(dev, B43_NTAB16(15, i + 32), entry);
}
  }

@@ -1590,10 +1587,8 @@ static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev 
*dev)
b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, regs[2]);
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[3]);
b43_phy_write(dev, B43_NPHY_BBCFG, regs[4]);
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
-   width 16, and data from regs[5] */
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 19,
-   width 16, and data from regs[6] */
+   b43_ntab_write(dev, B43_NTAB16(8, 3), regs[5]);
+   b43_ntab_write(dev, B43_NTAB16(8, 19), regs[6]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[7]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[8]);
b43_phy_write(dev, B43_NPHY_PAPD_EN0, regs[9]);
@@ -1603,10 +1598,8 @@ static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev 
*dev)
b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, regs[0]);
b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, regs[1]);
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[2]);
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 2,
-   width 16, and data from regs[3] */
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 18,
-   width 16, and data from regs[4] */
+   b43_ntab_write(dev, B43_NTAB16(8, 2), regs[3]);
+   b43_ntab_write(dev, B43_NTAB16(8, 18), regs[4]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[5]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[6]);
}
@@ -1638,15 +1631,10 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
/* TODO: Read an N PHY Table with ID 8, length 1, offset 3,
width 16, and data pointing to tmp */
regs[5] = tmp;
-
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
-   width 16, and data 0 */
-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 19,
-   width 16, and data pointing to tmp */
+   b43_ntab_write(dev, B43_NTAB16(8, 3), 0);
+   b43_ntab_write(dev, B43_NTAB16(8, 19), tmp);
regs[6] = tmp;
-
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 19,
-   width 16, and data 0 */
+   b43_ntab_write(dev, B43_NTAB16(8, 19), 0);
regs[7] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
regs[8] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);

@@ -1668,14 +1656,11 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
width 16, and data pointing to tmp */
regs[3] = tmp;
tmp |= 0x2000;
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 2,
-   width 16, and data pointer tmp */
-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 18,
-   width 16, and data pointer tmp */
+   b43_ntab_write(dev, B43_NTAB16(8, 2), tmp);
+   b43_ntab_write(dev, B43_NTAB16(8, 18), tmp);
regs[4] = tmp;
tmp |= 0x2000;
-   /* 

[PATCH 2/4] b43: N-PHY: implement and add multi-dimensional table writing

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c   |   58 ++--
  drivers/net/wireless/b43/tables_nphy.c |   40 ++
  drivers/net/wireless/b43/tables_nphy.h |2 +
  3 files changed, 67 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 31eba7d..6fd48d0 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1697,8 +1697,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
loft = nphy-cal_cache.txcal_coeffs_5G[5];
}

-   /* TODO: Write an N PHY table with ID 15, length 4, offset 80,
-   width 16, and data from table */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 4, table);

for (i = 0; i  4; i++) {
if (dev-phy.rev = 3)
@@ -1707,12 +1706,9 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
coef[i] = 0;
}

-   /* TODO: Write an N PHY table with ID 15, length 4, offset 88,
-   width 16, and data from coef */
-   /* TODO: Write an N PHY table with ID 15, length 2, offset 85,
-   width 16 and data from loft */
-   /* TODO: Write an N PHY table with ID 15, length 2, offset 93,
-   width 16 and data from loft */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4, coef);
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 85), 2, loft);
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 93), 2, loft);

if (dev-phy.rev  2)
b43_nphy_tx_iq_workaround(dev);
@@ -1780,8 +1776,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
b43_nphy_iq_cal_gain_params(dev, i, target, params[i]);
gain[i] = params[i].cal_gain;
}
-   /* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110,
-   width 16, and data pointer gain */
+
+   b43_ntab_write_bulk(dev, B43_NTAB16(7, 0x110), 2, gain);

b43_nphy_tx_cal_radio_setup(dev);
b43_nphy_tx_cal_phy_setup(dev);
@@ -1831,8 +1827,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
}
}

-   /* TODO: Write an N PHY Table with ID 15, length from above,
-   offset 64, width 16, and the data pointer from above */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length, table);

if (full) {
if (dev-phy.rev = 3)
@@ -1899,9 +1894,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
/* TODO: Read an N PHY Table with ID 15,
length table_length, offset 96, width 16,
and data pointer buffer */
-   /* TODO: Write an N PHY Table with ID 15,
-   length table_length, offset 64, width 16,
-   and data pointer buffer */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length,
+   buffer);

if (type == 1 || type == 3 || type == 4)
buffer[0] = diq_start;
@@ -1913,8 +1907,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
last = (dev-phy.rev  3) ? 6 : 7;

if (!mphase || nphy-mphase_cal_phase_id == last) {
-   /* TODO: Write an N PHY Table with ID 15, length 4,
-   offset 96, width 16, and data pointer buffer */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 96), 4, buffer);
/* TODO: Read an N PHY Table with ID 15, length 4,
offset 80, width 16, and data pointer buffer */
if (dev-phy.rev  3) {
@@ -1923,14 +1916,14 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
buffer[2] = 0;
buffer[3] = 0;
}
-   /* TODO: Write an N PHY Table with ID 15, length 4,
-   offset 88, width 16, and data pointer buffer */
-   /* TODO: Read an N PHY Table with ID 15, length 2,
-   offset 101, width 16, and data pointer buffer*/
-   /* TODO: Write an N PHY Table with ID 15, length 2,
-   offset 85, width 16, and data pointer buffer */
-   /* TODO: Write an N PHY Table with ID 15, length 2,
-   offset 93, width 16, and data pointer buffer */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4,
+   buffer);
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 101), 2,
+   

[PATCH 3/4] b43: N-PHY: implement and add reading one element tables

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c   |6 ++
  drivers/net/wireless/b43/tables_nphy.c |   31 +++
  drivers/net/wireless/b43/tables_nphy.h |1 +
  3 files changed, 34 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 6fd48d0..298a30a 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1628,8 +1628,7 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
regs[4] = b43_phy_read(dev, B43_NPHY_BBCFG);
b43_phy_mask(dev, B43_NPHY_BBCFG, ~B43_NPHY_BBCFG_RSTRX);

-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 3,
-   width 16, and data pointing to tmp */
+   tmp = b43_ntab_read(dev, B43_NTAB16(8, 3));
regs[5] = tmp;
b43_ntab_write(dev, B43_NTAB16(8, 3), 0);
b43_ntab_write(dev, B43_NTAB16(8, 19), tmp);
@@ -1652,8 +1651,7 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
regs[2] = tmp;
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, tmp | 0x3000);
-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 2,
-   width 16, and data pointing to tmp */
+   tmp = b43_ntab_read(dev, B43_NTAB16(8, 3));
regs[3] = tmp;
tmp |= 0x2000;
b43_ntab_write(dev, B43_NTAB16(8, 2), tmp);
diff --git a/drivers/net/wireless/b43/tables_nphy.c 
b/drivers/net/wireless/b43/tables_nphy.c
index fc08be0..b8aed45 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2919,6 +2919,37 @@ static inline void assert_ntab_array_sizes(void)
  #undef check
  }

+u32 b43_ntab_read(struct b43_wldev *dev, u32 offset)
+{
+   u32 type, value;
+
+   type = offset  B43_NTAB_TYPEMASK;
+   offset = ~B43_NTAB_TYPEMASK;
+   B43_WARN_ON(offset  0x);
+
+   switch (type) {
+   case B43_NTAB_8BIT:
+   b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
+   value = b43_phy_read(dev, B43_NPHY_TABLE_DATALO)  0xFF;
+   break;
+   case B43_NTAB_16BIT:
+   b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
+   value = b43_phy_read(dev, B43_NPHY_TABLE_DATALO);
+   break;
+   case B43_NTAB_32BIT:
+   b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
+   value = b43_phy_read(dev, B43_NPHY_TABLE_DATAHI);
+   value = 16;
+   value |= b43_phy_read(dev, B43_NPHY_TABLE_DATALO);
+   break;
+   default:
+   B43_WARN_ON(1);
+   value = 0;
+   }
+
+   return value;
+}
+
  void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value)
  {
u32 type;
diff --git a/drivers/net/wireless/b43/tables_nphy.h 
b/drivers/net/wireless/b43/tables_nphy.h
index d5605df..64e990a 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -142,6 +142,7 @@ b43_nphy_get_chantabent(struct b43_wldev *dev, u8 channel);
  #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL 10
  #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV312

+u32 b43_ntab_read(struct b43_wldev *dev, u32 offset);
  void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value);
  void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
  unsigned int nr_elements, const void *_data);
-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 4/4] b43: N-PHY: implement and add multi-dimensional table reading

2010-01-17 Thread Rafał Miłecki

Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
  drivers/net/wireless/b43/phy_n.c   |   30 ++-
  drivers/net/wireless/b43/tables_nphy.c |   35 
  drivers/net/wireless/b43/tables_nphy.h |2 +
  3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 298a30a..abd99a0 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -829,8 +829,7 @@ static void b43_nphy_tx_pwr_ctrl_coef_setup(struct 
b43_wldev *dev)
if (nphy-hang_avoid)
b43_nphy_stay_in_carrier_search(dev, true);

-   /* TODO: Read an N PHY Table with ID 15, length 7, offset 80,
-   width 16, and data pointer buffer */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);

for (i = 0; i  2; i++) {
tmp = ((buffer[i * 2]  0x3FF)  10) |
@@ -1507,8 +1506,7 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct 
b43_wldev *dev)

if (nphy-hang_avoid)
b43_nphy_stay_in_carrier_search(dev, true);
-   /* TODO: Read an N PHY Table with ID 7, length 2,
-   offset 0x110, width 16, and curr_gain */
+   b43_ntab_read_bulk(dev, B43_NTAB16(7, 0x110), 2, curr_gain);
if (nphy-hang_avoid)
b43_nphy_stay_in_carrier_search(dev, false);

@@ -1767,8 +1765,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
nphy-hang_avoid = 0;
}

-   /* TODO: Read an N PHY Table with ID 7, length 2, offset 0x110,
-   width 16, and data pointer save */
+   b43_ntab_read_bulk(dev, B43_NTAB16(7, 0x110), 2, save);

for (i = 0; i  2; i++) {
b43_nphy_iq_cal_gain_params(dev, i, target, params[i]);
@@ -1889,9 +1886,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
udelay(10);
}

-   /* TODO: Read an N PHY Table with ID 15,
-   length table_length, offset 96, width 16,
-   and data pointer buffer */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
+   buffer);
b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length,
buffer);

@@ -1906,8 +1902,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,

if (!mphase || nphy-mphase_cal_phase_id == last) {
b43_ntab_write_bulk(dev, B43_NTAB16(15, 96), 4, buffer);
-   /* TODO: Read an N PHY Table with ID 15, length 4,
-   offset 80, width 16, and data pointer buffer */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 4, buffer);
if (dev-phy.rev  3) {
buffer[0] = 0;
buffer[1] = 0;
@@ -1925,9 +1920,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
length = 11;
if (dev-phy.rev  3)
length -= 2;
-   /* TODO: Read an N PHY Table with ID 15, length length,
-   offset 96, width 16, and data pointer
-   nphy-txiqlocal_bestc */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
+   nphy-txiqlocal_bestc);
nphy-txiqlocal_coeffsvalid = true;
/* TODO: Set nphy-txiqlocal_chanspec to
the current channel */
@@ -1935,9 +1929,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
length = 11;
if (dev-phy.rev  3)
length -= 2;
-   /* TODO: Read an N PHY Table with ID 5, length length,
-   offset 96, width 16, and data pointer
-   nphy-mphase_txcal_bestcoeffs */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
+   nphy-mphase_txcal_bestcoeffs);
}

b43_nphy_stop_playback(dev);
@@ -1989,8 +1982,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,

if (dev-phy.rev  2)
;/* TODO: Call N PHY Reapply TX Cal Coeffs */
-   /* TODO: Read an N PHY Table with ID 7, length 2, offset 0x110,
-   width 16, and data gain_save */
+   b43_ntab_read_bulk(dev, B43_NTAB16(7, 0x110), 2, gain_save);
for (i = 0; i  2; i++) {
b43_nphy_iq_cal_gain_params(dev, i, target, cal_params[i]);
cal_gain[i] = cal_params[i].cal_gain;

Re: [PATCH 1/4] b43: N-PHY: add writing one element tables

2010-01-17 Thread Michael Buesch
On Sunday 17 January 2010 23:37:50 Rafał Miłecki wrote:
 @@ -1895,14 +1880,12 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev 
 *dev,
   b43_phy_write(dev, B43_NPHY_IQLOCAL_CMDNNUM, tmp);
 
   if (type == 1 || type == 3 || type == 4) {
 - /* TODO: Read an N PHY Table with ID 15,
 - length 1, offset 69 + core,
 - width 16, and data pointer buffer */
 + b43_ntab_write(dev, B43_NTAB16(15, 69 + core),
 + buffer[0]);
   diq_start = buffer[0];
   buffer[0] = 0;
 - /* TODO: Write an N PHY Table with ID 15,
 - length 1, offset 69 + core, width 16,
 - and data of 0 */
 + b43_ntab_write(dev, B43_NTAB16(15, 69 + core),
 + 0);
   }
 
   b43_phy_write(dev, B43_NPHY_IQLOCAL_CMD, cmd);

What is this supposed to do? It writes a value to a table entry and immediately
clobbers the entry with 0. This doesn't make any sense.

-- 
Greetings, Michael.
___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


[PATCH 1/5 V2] b43: N-PHY: add writing one element tables

2010-01-17 Thread Rafał Miłecki
Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
V2: don't write instead of reading ;/ Thanks Michael
---
  drivers/net/wireless/b43/phy_n.c |   40 -
  1 files changed, 13 insertions(+), 27 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 141d4ed..16f1f9b 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -808,8 +808,7 @@ static void b43_nphy_stop_playback(struct b43_wldev *dev)

if (nphy-bb_mult_save  0x8000) {
tmp = nphy-bb_mult_save  0x;
-   /* TODO: Write an N PHY Table with ID 15, length 1, offset 87,
-   width 16 and data from tmp */
+   b43_ntab_write(dev, B43_NTAB16(15, 87), tmp);
nphy-bb_mult_save = 0;
}

@@ -1486,13 +1485,11 @@ static void b43_nphy_update_tx_cal_ladder(struct 
b43_wldev *dev, u16 core)
for (i = 0; i  18; i++) {
scale = (ladder_lo[i].percent * tmp) / 100;
entry = ((scale  0xFF)  8) | ladder_lo[i].g_env;
-   /* TODO: Write an N PHY Table with ID 15, length 1,
-   offset i, width 16, and data entry */
+   b43_ntab_write(dev, B43_NTAB16(15, i), entry);

scale = (ladder_iq[i].percent * tmp) / 100;
entry = ((scale  0xFF)  8) | ladder_iq[i].g_env;
-   /* TODO: Write an N PHY Table with ID 15, length 1,
-   offset i + 32, width 16, and data entry */
+   b43_ntab_write(dev, B43_NTAB16(15, i + 32), entry);
}
  }

@@ -1590,10 +1587,8 @@ static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev 
*dev)
b43_phy_write(dev, B43_NPHY_AFECTL_OVER1, regs[2]);
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[3]);
b43_phy_write(dev, B43_NPHY_BBCFG, regs[4]);
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
-   width 16, and data from regs[5] */
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 19,
-   width 16, and data from regs[6] */
+   b43_ntab_write(dev, B43_NTAB16(8, 3), regs[5]);
+   b43_ntab_write(dev, B43_NTAB16(8, 19), regs[6]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[7]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[8]);
b43_phy_write(dev, B43_NPHY_PAPD_EN0, regs[9]);
@@ -1603,10 +1598,8 @@ static void b43_nphy_tx_cal_phy_cleanup(struct b43_wldev 
*dev)
b43_phy_maskset(dev, B43_NPHY_AFECTL_C1, 0x0FFF, regs[0]);
b43_phy_maskset(dev, B43_NPHY_AFECTL_C2, 0x0FFF, regs[1]);
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, regs[2]);
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 2,
-   width 16, and data from regs[3] */
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 18,
-   width 16, and data from regs[4] */
+   b43_ntab_write(dev, B43_NTAB16(8, 2), regs[3]);
+   b43_ntab_write(dev, B43_NTAB16(8, 18), regs[4]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC1, regs[5]);
b43_phy_write(dev, B43_NPHY_RFCTL_INTC2, regs[6]);
}
@@ -1638,15 +1631,11 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
/* TODO: Read an N PHY Table with ID 8, length 1, offset 3,
width 16, and data pointing to tmp */
regs[5] = tmp;
-
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 3,
-   width 16, and data 0 */
+   b43_ntab_write(dev, B43_NTAB16(8, 3), 0);
/* TODO: Read an N PHY Table with ID 8, length 1, offset 19,
width 16, and data pointing to tmp */
regs[6] = tmp;
-
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 19,
-   width 16, and data 0 */
+   b43_ntab_write(dev, B43_NTAB16(8, 19), 0);
regs[7] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
regs[8] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC2);

@@ -1668,14 +1657,12 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
width 16, and data pointing to tmp */
regs[3] = tmp;
tmp |= 0x2000;
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 2,
-   width 16, and data pointer tmp */
+   b43_ntab_write(dev, B43_NTAB16(8, 2), tmp);
/* TODO: Read an N PHY Table with ID 8, length 1, offset 18,
width 16, and data pointer tmp */
regs[4] = tmp;
tmp |= 0x2000;
-   /* TODO: Write an N PHY Table with ID 8, length 1, offset 18,
- 

[PATCH 2/5 V2] b43: N-PHY: implement and add multi-dimensional table writing

2010-01-17 Thread Rafał Miłecki
Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
V2: updated to apply without fuzz
---
  drivers/net/wireless/b43/phy_n.c   |   58 ++--
  drivers/net/wireless/b43/tables_nphy.c |   40 ++
  drivers/net/wireless/b43/tables_nphy.h |2 +
  3 files changed, 67 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 16f1f9b..6b200e5 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1699,8 +1699,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
loft = nphy-cal_cache.txcal_coeffs_5G[5];
}

-   /* TODO: Write an N PHY table with ID 15, length 4, offset 80,
-   width 16, and data from table */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 4, table);

for (i = 0; i  4; i++) {
if (dev-phy.rev = 3)
@@ -1709,12 +1708,9 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
coef[i] = 0;
}

-   /* TODO: Write an N PHY table with ID 15, length 4, offset 88,
-   width 16, and data from coef */
-   /* TODO: Write an N PHY table with ID 15, length 2, offset 85,
-   width 16 and data from loft */
-   /* TODO: Write an N PHY table with ID 15, length 2, offset 93,
-   width 16 and data from loft */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4, coef);
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 85), 2, loft);
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 93), 2, loft);

if (dev-phy.rev  2)
b43_nphy_tx_iq_workaround(dev);
@@ -1782,8 +1778,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
b43_nphy_iq_cal_gain_params(dev, i, target, params[i]);
gain[i] = params[i].cal_gain;
}
-   /* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110,
-   width 16, and data pointer gain */
+
+   b43_ntab_write_bulk(dev, B43_NTAB16(7, 0x110), 2, gain);

b43_nphy_tx_cal_radio_setup(dev);
b43_nphy_tx_cal_phy_setup(dev);
@@ -1833,8 +1829,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
}
}

-   /* TODO: Write an N PHY Table with ID 15, length from above,
-   offset 64, width 16, and the data pointer from above */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length, table);

if (full) {
if (dev-phy.rev = 3)
@@ -1902,9 +1897,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
/* TODO: Read an N PHY Table with ID 15,
length table_length, offset 96, width 16,
and data pointer buffer */
-   /* TODO: Write an N PHY Table with ID 15,
-   length table_length, offset 64, width 16,
-   and data pointer buffer */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length,
+   buffer);

if (type == 1 || type == 3 || type == 4)
buffer[0] = diq_start;
@@ -1916,8 +1910,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
last = (dev-phy.rev  3) ? 6 : 7;

if (!mphase || nphy-mphase_cal_phase_id == last) {
-   /* TODO: Write an N PHY Table with ID 15, length 4,
-   offset 96, width 16, and data pointer buffer */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 96), 4, buffer);
/* TODO: Read an N PHY Table with ID 15, length 4,
offset 80, width 16, and data pointer buffer */
if (dev-phy.rev  3) {
@@ -1926,14 +1919,14 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
buffer[2] = 0;
buffer[3] = 0;
}
-   /* TODO: Write an N PHY Table with ID 15, length 4,
-   offset 88, width 16, and data pointer buffer */
-   /* TODO: Read an N PHY Table with ID 15, length 2,
-   offset 101, width 16, and data pointer buffer*/
-   /* TODO: Write an N PHY Table with ID 15, length 2,
-   offset 85, width 16, and data pointer buffer */
-   /* TODO: Write an N PHY Table with ID 15, length 2,
-   offset 93, width 16, and data pointer buffer */
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4,
+   buffer);
+   b43_ntab_write_bulk(dev, B43_NTAB16(15, 101), 2,
+

[PATCH 3/5 V2] b43: N-PHY: implement and add reading one element tables

2010-01-17 Thread Rafał Miłecki
Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
V2: added missing reads after modification of 1/5
---
  drivers/net/wireless/b43/phy_n.c   |   18 +++---
  drivers/net/wireless/b43/tables_nphy.c |   31 +++
  drivers/net/wireless/b43/tables_nphy.h |1 +
  3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 6b200e5..6398656 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1628,12 +1628,11 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
regs[4] = b43_phy_read(dev, B43_NPHY_BBCFG);
b43_phy_mask(dev, B43_NPHY_BBCFG, ~B43_NPHY_BBCFG_RSTRX);

-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 3,
-   width 16, and data pointing to tmp */
+   tmp = b43_ntab_read(dev, B43_NTAB16(8, 3));
regs[5] = tmp;
b43_ntab_write(dev, B43_NTAB16(8, 3), 0);
-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 19,
-   width 16, and data pointing to tmp */
+
+   tmp = b43_ntab_read(dev, B43_NTAB16(8, 19));
regs[6] = tmp;
b43_ntab_write(dev, B43_NTAB16(8, 19), 0);
regs[7] = b43_phy_read(dev, B43_NPHY_RFCTL_INTC1);
@@ -1653,13 +1652,11 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
tmp = b43_phy_read(dev, B43_NPHY_AFECTL_OVER);
regs[2] = tmp;
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, tmp | 0x3000);
-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 2,
-   width 16, and data pointing to tmp */
+   tmp = b43_ntab_read(dev, B43_NTAB16(8, 2));
regs[3] = tmp;
tmp |= 0x2000;
b43_ntab_write(dev, B43_NTAB16(8, 2), tmp);
-   /* TODO: Read an N PHY Table with ID 8, length 1, offset 18,
-   width 16, and data pointer tmp */
+   tmp = b43_ntab_read(dev, B43_NTAB16(8, 18));
regs[4] = tmp;
tmp |= 0x2000;
b43_ntab_write(dev, B43_NTAB16(8, 18), tmp);
@@ -1877,9 +1874,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
b43_phy_write(dev, B43_NPHY_IQLOCAL_CMDNNUM, tmp);

if (type == 1 || type == 3 || type == 4) {
-   /* TODO: Read an N PHY Table with ID 15,
-   length 1, offset 69 + core,
-   width 16, and data pointer buffer */
+   buffer[0] = b43_ntab_read(dev,
+   B43_NTAB16(15, 69 + core));
diq_start = buffer[0];
buffer[0] = 0;
b43_ntab_write(dev, B43_NTAB16(15, 69 + core),
diff --git a/drivers/net/wireless/b43/tables_nphy.c 
b/drivers/net/wireless/b43/tables_nphy.c
index fc08be0..b8aed45 100644
--- a/drivers/net/wireless/b43/tables_nphy.c
+++ b/drivers/net/wireless/b43/tables_nphy.c
@@ -2919,6 +2919,37 @@ static inline void assert_ntab_array_sizes(void)
  #undef check
  }

+u32 b43_ntab_read(struct b43_wldev *dev, u32 offset)
+{
+   u32 type, value;
+
+   type = offset  B43_NTAB_TYPEMASK;
+   offset = ~B43_NTAB_TYPEMASK;
+   B43_WARN_ON(offset  0x);
+
+   switch (type) {
+   case B43_NTAB_8BIT:
+   b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
+   value = b43_phy_read(dev, B43_NPHY_TABLE_DATALO)  0xFF;
+   break;
+   case B43_NTAB_16BIT:
+   b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
+   value = b43_phy_read(dev, B43_NPHY_TABLE_DATALO);
+   break;
+   case B43_NTAB_32BIT:
+   b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
+   value = b43_phy_read(dev, B43_NPHY_TABLE_DATAHI);
+   value = 16;
+   value |= b43_phy_read(dev, B43_NPHY_TABLE_DATALO);
+   break;
+   default:
+   B43_WARN_ON(1);
+   value = 0;
+   }
+
+   return value;
+}
+
  void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value)
  {
u32 type;
diff --git a/drivers/net/wireless/b43/tables_nphy.h 
b/drivers/net/wireless/b43/tables_nphy.h
index d5605df..64e990a 100644
--- a/drivers/net/wireless/b43/tables_nphy.h
+++ b/drivers/net/wireless/b43/tables_nphy.h
@@ -142,6 +142,7 @@ b43_nphy_get_chantabent(struct b43_wldev *dev, u8 channel);
  #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL 10
  #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV312

+u32 b43_ntab_read(struct b43_wldev *dev, u32 offset);
  void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value);
  

[PATCH 4/5 V2] b43: N-PHY: implement and add multi-dimensional table reading

2010-01-17 Thread Rafał Miłecki
Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
V2: updated to apply without offset
---
  drivers/net/wireless/b43/phy_n.c   |   30 ++-
  drivers/net/wireless/b43/tables_nphy.c |   35 
  drivers/net/wireless/b43/tables_nphy.h |2 +
  3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 6398656..2356d84 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -829,8 +829,7 @@ static void b43_nphy_tx_pwr_ctrl_coef_setup(struct 
b43_wldev *dev)
if (nphy-hang_avoid)
b43_nphy_stay_in_carrier_search(dev, true);

-   /* TODO: Read an N PHY Table with ID 15, length 7, offset 80,
-   width 16, and data pointer buffer */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 7, buffer);

for (i = 0; i  2; i++) {
tmp = ((buffer[i * 2]  0x3FF)  10) |
@@ -1507,8 +1506,7 @@ static struct nphy_txgains b43_nphy_get_tx_gains(struct 
b43_wldev *dev)

if (nphy-hang_avoid)
b43_nphy_stay_in_carrier_search(dev, true);
-   /* TODO: Read an N PHY Table with ID 7, length 2,
-   offset 0x110, width 16, and curr_gain */
+   b43_ntab_read_bulk(dev, B43_NTAB16(7, 0x110), 2, curr_gain);
if (nphy-hang_avoid)
b43_nphy_stay_in_carrier_search(dev, false);

@@ -1768,8 +1766,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
nphy-hang_avoid = 0;
}

-   /* TODO: Read an N PHY Table with ID 7, length 2, offset 0x110,
-   width 16, and data pointer save */
+   b43_ntab_read_bulk(dev, B43_NTAB16(7, 0x110), 2, save);

for (i = 0; i  2; i++) {
b43_nphy_iq_cal_gain_params(dev, i, target, params[i]);
@@ -1890,9 +1887,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
udelay(10);
}

-   /* TODO: Read an N PHY Table with ID 15,
-   length table_length, offset 96, width 16,
-   and data pointer buffer */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
+   buffer);
b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length,
buffer);

@@ -1907,8 +1903,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,

if (!mphase || nphy-mphase_cal_phase_id == last) {
b43_ntab_write_bulk(dev, B43_NTAB16(15, 96), 4, buffer);
-   /* TODO: Read an N PHY Table with ID 15, length 4,
-   offset 80, width 16, and data pointer buffer */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 80), 4, buffer);
if (dev-phy.rev  3) {
buffer[0] = 0;
buffer[1] = 0;
@@ -1926,9 +1921,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
length = 11;
if (dev-phy.rev  3)
length -= 2;
-   /* TODO: Read an N PHY Table with ID 15, length length,
-   offset 96, width 16, and data pointer
-   nphy-txiqlocal_bestc */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
+   nphy-txiqlocal_bestc);
nphy-txiqlocal_coeffsvalid = true;
/* TODO: Set nphy-txiqlocal_chanspec to
the current channel */
@@ -1936,9 +1930,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
length = 11;
if (dev-phy.rev  3)
length -= 2;
-   /* TODO: Read an N PHY Table with ID 5, length length,
-   offset 96, width 16, and data pointer
-   nphy-mphase_txcal_bestcoeffs */
+   b43_ntab_read_bulk(dev, B43_NTAB16(15, 96), length,
+   nphy-mphase_txcal_bestcoeffs);
}

b43_nphy_stop_playback(dev);
@@ -1990,8 +1983,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,

if (dev-phy.rev  2)
;/* TODO: Call N PHY Reapply TX Cal Coeffs */
-   /* TODO: Read an N PHY Table with ID 7, length 2, offset 0x110,
-   width 16, and data gain_save */
+   b43_ntab_read_bulk(dev, B43_NTAB16(7, 0x110), 2, gain_save);
for (i = 0; i  2; i++) {
b43_nphy_iq_cal_gain_params(dev, i, target, cal_params[i]);
   

[PATCH 5/5 V2] b43: N-PHY: silence warnings, add missing call

2010-01-17 Thread Rafał Miłecki
Signed-off-by: Rafał Miłecki zaj...@gmail.com
---
New patch I didn't include earlier.
---
  drivers/net/wireless/b43/phy_n.c |6 +++---
  1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c
index 2356d84..3a3cc2f 100644
--- a/drivers/net/wireless/b43/phy_n.c
+++ b/drivers/net/wireless/b43/phy_n.c
@@ -1624,7 +1624,7 @@ static void b43_nphy_tx_cal_phy_setup(struct b43_wldev 
*dev)
b43_phy_write(dev, B43_NPHY_AFECTL_OVER, tmp | 0x0600);

regs[4] = b43_phy_read(dev, B43_NPHY_BBCFG);
-   b43_phy_mask(dev, B43_NPHY_BBCFG, ~B43_NPHY_BBCFG_RSTRX);
+   b43_phy_mask(dev, B43_NPHY_BBCFG, (u16)~B43_NPHY_BBCFG_RSTRX);

tmp = b43_ntab_read(dev, B43_NTAB16(8, 3));
regs[5] = tmp;
@@ -1970,7 +1970,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
u16 lna[3] = { 3, 3, 1 };
u16 hpf1[3] = { 7, 2, 0 };
u16 hpf2[3] = { 2, 0, 0 };
-   u32 power[3];
+   u32 power[3] = { };
u16 gain_save[2];
u16 cal_gain[2];
struct nphy_iqcal_params cal_params[2];
@@ -2077,7 +2077,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
(cur_lna  2));
/* TODO:Call N PHY RF Ctrl Override with 0x400, tmp[0],
3, 0 as arguments */
-   /* TODO: Call N PHY Force RF Seq with 2 as argument */
+   b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
b43_nphy_stop_playback(dev);

if (playtone) {
-- 
1.6.4.2

___
Bcm43xx-dev mailing list
Bcm43xx-dev@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/bcm43xx-dev


Re: [PATCH 2/5 V2] b43: N-PHY: implement and add multi-dimensional table writing

2010-01-17 Thread Gábor Stefanik
2010/1/18 Rafał Miłecki zaj...@gmail.com:
 Signed-off-by: Rafał Miłecki zaj...@gmail.com
 ---
 V2: updated to apply without fuzz

Actually, you do not need to do that - offset or fuzzy patches will
still be applied cleanly AFAIK, without any intervention.
(John, correct me if I'm wrong here...)

 ---
  drivers/net/wireless/b43/phy_n.c       |   58
 ++--
  drivers/net/wireless/b43/tables_nphy.c |   40 ++
  drivers/net/wireless/b43/tables_nphy.h |    2 +
  3 files changed, 67 insertions(+), 33 deletions(-)

 diff --git a/drivers/net/wireless/b43/phy_n.c
 b/drivers/net/wireless/b43/phy_n.c
 index 16f1f9b..6b200e5 100644
 --- a/drivers/net/wireless/b43/phy_n.c
 +++ b/drivers/net/wireless/b43/phy_n.c
 @@ -1699,8 +1699,7 @@ static void b43_nphy_restore_cal(struct b43_wldev
 *dev)
                loft = nphy-cal_cache.txcal_coeffs_5G[5];
        }

 -       /* TODO: Write an N PHY table with ID 15, length 4, offset 80,
 -               width 16, and data from table */
 +       b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 4, table);

        for (i = 0; i  4; i++) {
                if (dev-phy.rev = 3)
 @@ -1709,12 +1708,9 @@ static void b43_nphy_restore_cal(struct b43_wldev
 *dev)
                        coef[i] = 0;
        }

 -       /* TODO: Write an N PHY table with ID 15, length 4, offset 88,
 -               width 16, and data from coef */
 -       /* TODO: Write an N PHY table with ID 15, length 2, offset 85,
 -               width 16 and data from loft */
 -       /* TODO: Write an N PHY table with ID 15, length 2, offset 93,
 -               width 16 and data from loft */
 +       b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4, coef);
 +       b43_ntab_write_bulk(dev, B43_NTAB16(15, 85), 2, loft);
 +       b43_ntab_write_bulk(dev, B43_NTAB16(15, 93), 2, loft);

        if (dev-phy.rev  2)
                b43_nphy_tx_iq_workaround(dev);
 @@ -1782,8 +1778,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev
 *dev,
                b43_nphy_iq_cal_gain_params(dev, i, target, params[i]);
                gain[i] = params[i].cal_gain;
        }
 -       /* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110,
 -               width 16, and data pointer gain */
 +
 +       b43_ntab_write_bulk(dev, B43_NTAB16(7, 0x110), 2, gain);

        b43_nphy_tx_cal_radio_setup(dev);
        b43_nphy_tx_cal_phy_setup(dev);
 @@ -1833,8 +1829,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev
 *dev,
                        }
                }

 -               /* TODO: Write an N PHY Table with ID 15, length from above,
 -                       offset 64, width 16, and the data pointer from above
 */
 +               b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length, table);

                if (full) {
                        if (dev-phy.rev = 3)
 @@ -1902,9 +1897,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev
 *dev,
                        /* TODO: Read an N PHY Table with ID 15,
                                length table_length, offset 96, width 16,
                                and data pointer buffer */
 -                       /* TODO: Write an N PHY Table with ID 15,
 -                               length table_length, offset 64, width 16,
 -                               and data pointer buffer */
 +                       b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length,
 +                                               buffer);

                        if (type == 1 || type == 3 || type == 4)
                                buffer[0] = diq_start;
 @@ -1916,8 +1910,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev
 *dev,
                last = (dev-phy.rev  3) ? 6 : 7;

                if (!mphase || nphy-mphase_cal_phase_id == last) {
 -                       /* TODO: Write an N PHY Table with ID 15, length 4,
 -                               offset 96, width 16, and data pointer buffer
 */
 +                       b43_ntab_write_bulk(dev, B43_NTAB16(15, 96), 4,
 buffer);
                        /* TODO: Read an N PHY Table with ID 15, length 4,
                                offset 80, width 16, and data pointer buffer
 */
                        if (dev-phy.rev  3) {
 @@ -1926,14 +1919,14 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev
 *dev,
                                buffer[2] = 0;
                                buffer[3] = 0;
                        }
 -                       /* TODO: Write an N PHY Table with ID 15, length 4,
 -                               offset 88, width 16, and data pointer buffer
 */
 -                       /* TODO: Read an N PHY Table with ID 15, length 2,
 -                               offset 101, width 16, and data pointer
 buffer*/
 -                       /* TODO: Write an N PHY Table with ID 15, length 2,
 -                               offset 85, width 16, and data pointer buffer
 */
 -                       /* TODO: Write an N PHY Table with ID 15, length 2,
 -