29 #include <linux/slab.h>
44 return (5000 + 5 * channel);
53 else if (frequency < 5321)
55 else if (frequency < 5806)
84 static const u8 data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 };
85 static const u8 data_low[5] = { 0x00, 0x01, 0x05, 0x06, 0x0A };
89 for (i = 0; i < 5; i++) {
90 for (j = 0; j < 5; j++) {
91 if (tmp == (data_high[i] << 4 | data_low[j])) {
93 (i - j) << 8 | 0x00C0);
100 static void aphy_channel_switch(
struct b43_wldev *dev,
unsigned int channel)
104 freq = channel2freq_a(channel);
107 b43_write16(dev, 0x03F0, freq);
116 if (freq >= 4920 && freq <= 5500) {
138 b43_radio_set_tx_iq(dev);
143 static void b43_radio_init2060(
struct b43_wldev *dev)
176 aphy_channel_switch(dev, dev->
phy.ops->get_default_chan(dev));
185 if (dev->
phy.rev < 3) {
212 static void b43_phy_ww(
struct b43_wldev *dev)
214 u16 b, curr_s, best_s = 0xFFFF;
227 for (i = 0x10; i <= 0x20; i++) {
233 }
else if (curr_s >= 0x0080)
234 curr_s = 0x0100 - curr_s;
252 for (i = 0; i < 6; i++)
261 static void hardware_pctl_init_aphy(
struct b43_wldev *dev)
292 b43_phy_rssiagc(dev, 0);
296 b43_radio_init2060(dev);
307 hardware_pctl_init_aphy(dev);
319 static int b43_aphy_init_tssi2dbm_table(
struct b43_wldev *dev)
323 s16 pab0, pab1, pab2;
325 pab0 = (
s16) (dev->
dev->bus_sprom->pa1b0);
326 pab1 = (
s16) (dev->
dev->bus_sprom->pa1b1);
327 pab2 = (
s16) (dev->
dev->bus_sprom->pa1b2);
329 if (pab0 != 0 && pab1 != 0 && pab2 != 0 &&
330 pab0 != -1 && pab1 != -1 && pab2 != -1) {
332 if ((
s8) dev->
dev->bus_sprom->itssi_a != 0 &&
333 (
s8) dev->
dev->bus_sprom->itssi_a != -1)
335 (
s8) (dev->
dev->bus_sprom->itssi_a);
346 b43err(dev->
wl,
"Could not generate tssi2dBm "
347 "table (wrong SPROM info)!\n");
354 static int b43_aphy_op_allocate(
struct b43_wldev *dev)
364 err = b43_aphy_init_tssi2dbm_table(dev);
377 static void b43_aphy_op_prepare_structs(
struct b43_wldev *dev)
390 memset(aphy, 0,
sizeof(*aphy));
399 static void b43_aphy_op_free(
struct b43_wldev *dev)
411 static int b43_aphy_op_init(
struct b43_wldev *dev)
422 offset &= ~B43_PHYROUTE;
429 b43err(dev->
wl,
"Invalid EXT-G PHY access at "
430 "0x%04X on A-PHY\n", offset);
435 b43err(dev->
wl,
"Invalid N-BMODE PHY access at "
436 "0x%04X on A-PHY\n", offset);
446 reg = adjust_phyreg(dev, reg);
453 reg = adjust_phyreg(dev, reg);
478 static bool b43_aphy_op_supports_hwpctl(
struct b43_wldev *dev)
480 return (dev->
phy.rev >= 5);
483 static void b43_aphy_op_software_rfkill(
struct b43_wldev *dev,
495 b43_radio_init2060(dev);
504 static int b43_aphy_op_switch_channel(
struct b43_wldev *dev,
505 unsigned int new_channel)
507 if (new_channel > 200)
509 aphy_channel_switch(dev, new_channel);
514 static unsigned int b43_aphy_op_get_default_chan(
struct b43_wldev *dev)
558 static void b43_aphy_op_adjust_txpower(
struct b43_wldev *dev)
568 static void b43_aphy_op_pwork_15sec(
struct b43_wldev *dev)
572 static void b43_aphy_op_pwork_60sec(
struct b43_wldev *dev)
577 .allocate = b43_aphy_op_allocate,
578 .free = b43_aphy_op_free,
579 .prepare_structs = b43_aphy_op_prepare_structs,
580 .init = b43_aphy_op_init,
581 .phy_read = b43_aphy_op_read,
582 .phy_write = b43_aphy_op_write,
583 .radio_read = b43_aphy_op_radio_read,
584 .radio_write = b43_aphy_op_radio_write,
585 .supports_hwpctl = b43_aphy_op_supports_hwpctl,
586 .software_rfkill = b43_aphy_op_software_rfkill,
588 .switch_channel = b43_aphy_op_switch_channel,
589 .get_default_chan = b43_aphy_op_get_default_chan,
590 .set_rx_antenna = b43_aphy_op_set_rx_antenna,
591 .recalc_txpower = b43_aphy_op_recalc_txpower,
592 .adjust_txpower = b43_aphy_op_adjust_txpower,
593 .pwork_15sec = b43_aphy_op_pwork_15sec,
594 .pwork_60sec = b43_aphy_op_pwork_60sec,