Commit 2581b143 authored by Rafał Miłecki's avatar Rafał Miłecki Committed by John W. Linville

b43: N-PHY: implement and add multi-dimensional table writing

Signed-off-by: default avatarRafał Miłecki <zajec5@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d41a3552
...@@ -1699,8 +1699,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev) ...@@ -1699,8 +1699,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
loft = &nphy->cal_cache.txcal_coeffs_5G[5]; loft = &nphy->cal_cache.txcal_coeffs_5G[5];
} }
/* TODO: Write an N PHY table with ID 15, length 4, offset 80, b43_ntab_write_bulk(dev, B43_NTAB16(15, 80), 4, table);
width 16, and data from table */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (dev->phy.rev >= 3) if (dev->phy.rev >= 3)
...@@ -1709,12 +1708,9 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev) ...@@ -1709,12 +1708,9 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev)
coef[i] = 0; coef[i] = 0;
} }
/* TODO: Write an N PHY table with ID 15, length 4, offset 88, b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4, coef);
width 16, and data from coef */ b43_ntab_write_bulk(dev, B43_NTAB16(15, 85), 2, loft);
/* TODO: Write an N PHY table with ID 15, length 2, offset 85, b43_ntab_write_bulk(dev, B43_NTAB16(15, 93), 2, loft);
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 */
if (dev->phy.rev < 2) if (dev->phy.rev < 2)
b43_nphy_tx_iq_workaround(dev); b43_nphy_tx_iq_workaround(dev);
...@@ -1782,8 +1778,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *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]); b43_nphy_iq_cal_gain_params(dev, i, target, &params[i]);
gain[i] = params[i].cal_gain; 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_radio_setup(dev);
b43_nphy_tx_cal_phy_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, ...@@ -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, b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length, table);
offset 64, width 16, and the data pointer from above */
if (full) { if (full) {
if (dev->phy.rev >= 3) if (dev->phy.rev >= 3)
...@@ -1902,9 +1897,8 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev, ...@@ -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, /* TODO: Read an N PHY Table with ID 15,
length table_length, offset 96, width 16, length table_length, offset 96, width 16,
and data pointer buffer */ and data pointer buffer */
/* TODO: Write an N PHY Table with ID 15, b43_ntab_write_bulk(dev, B43_NTAB16(15, 64), length,
length table_length, offset 64, width 16, buffer);
and data pointer buffer */
if (type == 1 || type == 3 || type == 4) if (type == 1 || type == 3 || type == 4)
buffer[0] = diq_start; buffer[0] = diq_start;
...@@ -1916,8 +1910,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev, ...@@ -1916,8 +1910,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
last = (dev->phy.rev < 3) ? 6 : 7; last = (dev->phy.rev < 3) ? 6 : 7;
if (!mphase || nphy->mphase_cal_phase_id == last) { if (!mphase || nphy->mphase_cal_phase_id == last) {
/* TODO: Write an N PHY Table with ID 15, length 4, b43_ntab_write_bulk(dev, B43_NTAB16(15, 96), 4, buffer);
offset 96, width 16, and data pointer buffer */
/* TODO: Read an N PHY Table with ID 15, length 4, /* TODO: Read an N PHY Table with ID 15, length 4,
offset 80, width 16, and data pointer buffer */ offset 80, width 16, and data pointer buffer */
if (dev->phy.rev < 3) { if (dev->phy.rev < 3) {
...@@ -1926,14 +1919,14 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev, ...@@ -1926,14 +1919,14 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
buffer[2] = 0; buffer[2] = 0;
buffer[3] = 0; buffer[3] = 0;
} }
/* TODO: Write an N PHY Table with ID 15, length 4, b43_ntab_write_bulk(dev, B43_NTAB16(15, 88), 4,
offset 88, width 16, and data pointer buffer */ buffer);
/* TODO: Read an N PHY Table with ID 15, length 2, b43_ntab_write_bulk(dev, B43_NTAB16(15, 101), 2,
offset 101, width 16, and data pointer buffer*/ buffer);
/* TODO: Write an N PHY Table with ID 15, length 2, b43_ntab_write_bulk(dev, B43_NTAB16(15, 85), 2,
offset 85, width 16, and data pointer buffer */ buffer);
/* TODO: Write an N PHY Table with ID 15, length 2, b43_ntab_write_bulk(dev, B43_NTAB16(15, 93), 2,
offset 93, width 16, and data pointer buffer */ buffer);
length = 11; length = 11;
if (dev->phy.rev < 3) if (dev->phy.rev < 3)
length -= 2; length -= 2;
...@@ -1957,8 +1950,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev, ...@@ -1957,8 +1950,7 @@ static int b43_nphy_cal_tx_iq_lo(struct b43_wldev *dev,
} }
b43_nphy_tx_cal_phy_cleanup(dev); b43_nphy_tx_cal_phy_cleanup(dev);
/* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110, b43_ntab_write_bulk(dev, B43_NTAB16(7, 0x110), 2, save);
width 16, and data from save */
if (dev->phy.rev < 2 && (!mphase || nphy->mphase_cal_phase_id == last)) if (dev->phy.rev < 2 && (!mphase || nphy->mphase_cal_phase_id == last))
b43_nphy_tx_iq_workaround(dev); b43_nphy_tx_iq_workaround(dev);
...@@ -2008,8 +2000,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev, ...@@ -2008,8 +2000,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev,
b43_nphy_iq_cal_gain_params(dev, i, target, &cal_params[i]); b43_nphy_iq_cal_gain_params(dev, i, target, &cal_params[i]);
cal_gain[i] = cal_params[i].cal_gain; cal_gain[i] = cal_params[i].cal_gain;
} }
/* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110, b43_ntab_write_bulk(dev, B43_NTAB16(7, 0x110), 2, cal_gain);
width 16, and data from cal_gain */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (i == 0) { if (i == 0) {
...@@ -2147,8 +2138,7 @@ static int b43_nphy_rev2_cal_rx_iq(struct b43_wldev *dev, ...@@ -2147,8 +2138,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 RF Ctrl Override with 0x400, 0, 3, 1 as arguments*/
b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX); b43_nphy_force_rf_sequence(dev, B43_RFSEQ_RESET2RX);
/* TODO: Write an N PHY Table with ID 7, length 2, offset 0x110, b43_ntab_write_bulk(dev, B43_NTAB16(7, 0x110), 2, gain_save);
width 16, and data from gain_save */
b43_nphy_stay_in_carrier_search(dev, 0); b43_nphy_stay_in_carrier_search(dev, 0);
...@@ -2290,8 +2280,10 @@ int b43_phy_initn(struct b43_wldev *dev) ...@@ -2290,8 +2280,10 @@ int b43_phy_initn(struct b43_wldev *dev)
if (phy->rev >= 3) { if (phy->rev >= 3) {
/* TODO */ /* TODO */
} else { } else {
/* TODO Write an N PHY table with ID 26, length 128, offset 192, width 32, and the data from Rev 2 TX Power Control Table */ b43_ntab_write_bulk(dev, B43_NTAB32(26, 192), 128,
/* TODO Write an N PHY table with ID 27, length 128, offset 192, width 32, and the data from Rev 2 TX Power Control Table */ b43_ntab_tx_gain_rev0_1_2);
b43_ntab_write_bulk(dev, B43_NTAB32(27, 192), 128,
b43_ntab_tx_gain_rev0_1_2);
} }
if (nphy->phyrxchain != 3) if (nphy->phyrxchain != 3)
......
...@@ -2952,6 +2952,46 @@ void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value) ...@@ -2952,6 +2952,46 @@ void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value)
assert_ntab_array_sizes(); assert_ntab_array_sizes();
} }
void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset,
unsigned int nr_elements, const void *_data)
{
u32 type, value;
const u8 *data = _data;
unsigned int i;
type = offset & B43_NTAB_TYPEMASK;
offset &= ~B43_NTAB_TYPEMASK;
B43_WARN_ON(offset > 0xFFFF);
b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset);
for (i = 0; i < nr_elements; i++) {
switch (type) {
case B43_NTAB_8BIT:
value = *data;
data++;
B43_WARN_ON(value & ~0xFF);
b43_phy_write(dev, B43_NPHY_TABLE_DATALO, value);
break;
case B43_NTAB_16BIT:
value = *((u16 *)data);
data += 2;
B43_WARN_ON(value & ~0xFFFF);
b43_phy_write(dev, B43_NPHY_TABLE_DATALO, value);
break;
case B43_NTAB_32BIT:
value = *((u32 *)data);
data += 4;
b43_phy_write(dev, B43_NPHY_TABLE_DATAHI, value >> 16);
b43_phy_write(dev, B43_NPHY_TABLE_DATALO,
value & 0xFFFF);
break;
default:
B43_WARN_ON(1);
}
}
}
#define ntab_upload(dev, offset, data) do { \ #define ntab_upload(dev, offset, data) do { \
unsigned int i; \ unsigned int i; \
for (i = 0; i < (offset##_SIZE); i++) \ for (i = 0; i < (offset##_SIZE); i++) \
......
...@@ -143,6 +143,8 @@ b43_nphy_get_chantabent(struct b43_wldev *dev, u8 channel); ...@@ -143,6 +143,8 @@ b43_nphy_get_chantabent(struct b43_wldev *dev, u8 channel);
#define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV3 12 #define B43_NTAB_TX_IQLO_CAL_CMDS_FULLCAL_REV3 12
void b43_ntab_write(struct b43_wldev *dev, u32 offset, u32 value); 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);
void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev); void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev);
void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev); void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment