Commit 99c4a780 authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville

b43: Move remaining code from phy.c to phy_a.c

This moves the remaining code from phy.c to phy_a.c
phy.c is removed.
No functional change. Just moving code and removing dead code.
Signed-off-by: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent f59ac048
This diff is collapsed.
...@@ -58,6 +58,25 @@ static inline u16 freq_r3A_value(u16 frequency) ...@@ -58,6 +58,25 @@ static inline u16 freq_r3A_value(u16 frequency)
return value; return value;
} }
#if 0
/* This function converts a TSSI value to dBm in Q5.2 */
static s8 b43_aphy_estimate_power_out(struct b43_wldev *dev, s8 tssi)
{
struct b43_phy *phy = &dev->phy;
struct b43_phy_a *aphy = phy->a;
s8 dbm = 0;
s32 tmp;
tmp = (aphy->tgt_idle_tssi - aphy->cur_idle_tssi + tssi);
tmp += 0x80;
tmp = clamp_val(tmp, 0x00, 0xFF);
dbm = aphy->tssi2dbm[tmp];
//TODO: There's a FIXME on the specs
return dbm;
}
#endif
void b43_radio_set_tx_iq(struct b43_wldev *dev) void b43_radio_set_tx_iq(struct b43_wldev *dev)
{ {
static const u8 data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 }; static const u8 data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 };
...@@ -326,9 +345,46 @@ void b43_phy_inita(struct b43_wldev *dev) ...@@ -326,9 +345,46 @@ void b43_phy_inita(struct b43_wldev *dev)
} }
} }
/* Initialise the TSSI->dBm lookup table */
static int b43_aphy_init_tssi2dbm_table(struct b43_wldev *dev)
{
struct b43_phy *phy = &dev->phy;
struct b43_phy_a *aphy = phy->a;
s16 pab0, pab1, pab2;
pab0 = (s16) (dev->dev->bus->sprom.pa1b0);
pab1 = (s16) (dev->dev->bus->sprom.pa1b1);
pab2 = (s16) (dev->dev->bus->sprom.pa1b2);
if (pab0 != 0 && pab1 != 0 && pab2 != 0 &&
pab0 != -1 && pab1 != -1 && pab2 != -1) {
/* The pabX values are set in SPROM. Use them. */
if ((s8) dev->dev->bus->sprom.itssi_a != 0 &&
(s8) dev->dev->bus->sprom.itssi_a != -1)
aphy->tgt_idle_tssi =
(s8) (dev->dev->bus->sprom.itssi_a);
else
aphy->tgt_idle_tssi = 62;
aphy->tssi2dbm = b43_generate_dyn_tssi2dbm_tab(dev, pab0,
pab1, pab2);
if (!aphy->tssi2dbm)
return -ENOMEM;
} else {
/* pabX values not set in SPROM,
* but APHY needs a generated table. */
aphy->tssi2dbm = NULL;
b43err(dev->wl, "Could not generate tssi2dBm "
"table (wrong SPROM info)!\n");
return -ENODEV;
}
return 0;
}
static int b43_aphy_op_allocate(struct b43_wldev *dev) static int b43_aphy_op_allocate(struct b43_wldev *dev)
{ {
struct b43_phy_a *aphy; struct b43_phy_a *aphy;
int err;
aphy = kzalloc(sizeof(*aphy), GFP_KERNEL); aphy = kzalloc(sizeof(*aphy), GFP_KERNEL);
if (!aphy) if (!aphy)
...@@ -337,7 +393,17 @@ static int b43_aphy_op_allocate(struct b43_wldev *dev) ...@@ -337,7 +393,17 @@ static int b43_aphy_op_allocate(struct b43_wldev *dev)
//TODO init struct b43_phy_a //TODO init struct b43_phy_a
err = b43_aphy_init_tssi2dbm_table(dev);
if (err)
goto err_free_aphy;
return 0; return 0;
err_free_aphy:
kfree(aphy);
dev->phy.a = NULL;
return err;
} }
static int b43_aphy_op_init(struct b43_wldev *dev) static int b43_aphy_op_init(struct b43_wldev *dev)
...@@ -359,6 +425,7 @@ static void b43_aphy_op_exit(struct b43_wldev *dev) ...@@ -359,6 +425,7 @@ static void b43_aphy_op_exit(struct b43_wldev *dev)
aphy->initialised = 0; aphy->initialised = 0;
} }
//TODO //TODO
kfree(aphy->tssi2dbm);
kfree(aphy); kfree(aphy);
dev->phy.a = NULL; dev->phy.a = NULL;
} }
...@@ -430,7 +497,23 @@ static bool b43_aphy_op_supports_hwpctl(struct b43_wldev *dev) ...@@ -430,7 +497,23 @@ static bool b43_aphy_op_supports_hwpctl(struct b43_wldev *dev)
static void b43_aphy_op_software_rfkill(struct b43_wldev *dev, static void b43_aphy_op_software_rfkill(struct b43_wldev *dev,
enum rfkill_state state) enum rfkill_state state)
{//TODO {
struct b43_phy *phy = &dev->phy;
if (state == RFKILL_STATE_UNBLOCKED) {
if (phy->radio_on)
return;
b43_radio_write16(dev, 0x0004, 0x00C0);
b43_radio_write16(dev, 0x0005, 0x0008);
b43_phy_write(dev, 0x0010, b43_phy_read(dev, 0x0010) & 0xFFF7);
b43_phy_write(dev, 0x0011, b43_phy_read(dev, 0x0011) & 0xFFF7);
b43_radio_init2060(dev);
} else {
b43_radio_write16(dev, 0x0004, 0x00FF);
b43_radio_write16(dev, 0x0005, 0x00FB);
b43_phy_write(dev, 0x0010, b43_phy_read(dev, 0x0010) | 0x0008);
b43_phy_write(dev, 0x0011, b43_phy_read(dev, 0x0011) | 0x0008);
}
} }
static int b43_aphy_op_switch_channel(struct b43_wldev *dev, static int b43_aphy_op_switch_channel(struct b43_wldev *dev,
......
...@@ -105,6 +105,14 @@ void b43_ofdmtab_write32(struct b43_wldev *dev, u16 table, ...@@ -105,6 +105,14 @@ void b43_ofdmtab_write32(struct b43_wldev *dev, u16 table,
struct b43_phy_a { struct b43_phy_a {
bool initialised; bool initialised;
/* Pointer to the table used to convert a
* TSSI value to dBm-Q5.2 */
const s8 *tssi2dbm;
/* Target idle TSSI */
int tgt_idle_tssi;
/* Current idle TSSI */
int cur_idle_tssi;//FIXME value currently not set
/* A-PHY TX Power control value. */ /* A-PHY TX Power control value. */
u16 txpwr_offset; u16 txpwr_offset;
......
...@@ -202,6 +202,8 @@ void b43_gphy_set_baseband_attenuation(struct b43_wldev *dev, ...@@ -202,6 +202,8 @@ void b43_gphy_set_baseband_attenuation(struct b43_wldev *dev,
void b43_gphy_channel_switch(struct b43_wldev *dev, void b43_gphy_channel_switch(struct b43_wldev *dev,
unsigned int channel, unsigned int channel,
bool synthetic_pu_workaround); bool synthetic_pu_workaround);
u8 * b43_generate_dyn_tssi2dbm_tab(struct b43_wldev *dev,
s16 pab0, s16 pab1, s16 pab2);
struct b43_phy_operations; struct b43_phy_operations;
extern const struct b43_phy_operations b43_phyops_g; extern const struct b43_phy_operations b43_phyops_g;
......
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