aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43/phy.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-01-13 15:23:44 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:53 -0500
commit53a6e2342d73d509318836e320f70cd286acd69c (patch)
tree835a25c8d48465840a8cdea8c363c58f567d921c /drivers/net/wireless/b43/phy.c
parentaf4b7450788426a113057ce2d85c25b4f4e440d1 (diff)
b43: Add NPHY radio init code
This adds some code to init the 2055 radio. This patch adds two files "tables_nphy.h" and "tables_nphy.c" Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/phy.c')
-rw-r--r--drivers/net/wireless/b43/phy.c81
1 files changed, 73 insertions, 8 deletions
diff --git a/drivers/net/wireless/b43/phy.c b/drivers/net/wireless/b43/phy.c
index 2abf125aa2cf..03cca61fdf84 100644
--- a/drivers/net/wireless/b43/phy.c
+++ b/drivers/net/wireless/b43/phy.c
@@ -308,6 +308,24 @@ void b43_phy_write(struct b43_wldev *dev, u16 offset, u16 val)
308 b43_write16(dev, B43_MMIO_PHY_DATA, val); 308 b43_write16(dev, B43_MMIO_PHY_DATA, val);
309} 309}
310 310
311void b43_phy_mask(struct b43_wldev *dev, u16 offset, u16 mask)
312{
313 b43_phy_write(dev, offset,
314 b43_phy_read(dev, offset) & mask);
315}
316
317void b43_phy_set(struct b43_wldev *dev, u16 offset, u16 set)
318{
319 b43_phy_write(dev, offset,
320 b43_phy_read(dev, offset) | set);
321}
322
323void b43_phy_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set)
324{
325 b43_phy_write(dev, offset,
326 (b43_phy_read(dev, offset) & mask) | set);
327}
328
311/* Adjust the transmission power output (G-PHY) */ 329/* Adjust the transmission power output (G-PHY) */
312void b43_set_txpower_g(struct b43_wldev *dev, 330void b43_set_txpower_g(struct b43_wldev *dev,
313 const struct b43_bbatt *bbatt, 331 const struct b43_bbatt *bbatt,
@@ -1857,6 +1875,9 @@ void b43_phy_xmitpower(struct b43_wldev *dev)
1857 b43_phy_unlock(dev); 1875 b43_phy_unlock(dev);
1858 break; 1876 break;
1859 } 1877 }
1878 case B43_PHYTYPE_N:
1879 b43_nphy_xmitpower(dev);
1880 break;
1860 default: 1881 default:
1861 B43_WARN_ON(1); 1882 B43_WARN_ON(1);
1862 } 1883 }
@@ -2116,6 +2137,9 @@ void b43_set_rx_antenna(struct b43_wldev *dev, int antenna)
2116 << B43_PHY_BBANDCFG_RXANT_SHIFT; 2137 << B43_PHY_BBANDCFG_RXANT_SHIFT;
2117 b43_phy_write(dev, B43_PHY_CCKBBANDCFG, tmp); 2138 b43_phy_write(dev, B43_PHY_CCKBBANDCFG, tmp);
2118 break; 2139 break;
2140 case B43_PHYTYPE_N:
2141 b43_nphy_set_rxantenna(dev, antenna);
2142 break;
2119 default: 2143 default:
2120 B43_WARN_ON(1); 2144 B43_WARN_ON(1);
2121 } 2145 }
@@ -2215,6 +2239,24 @@ void b43_radio_write16(struct b43_wldev *dev, u16 offset, u16 val)
2215 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, val); 2239 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, val);
2216} 2240}
2217 2241
2242void b43_radio_mask(struct b43_wldev *dev, u16 offset, u16 mask)
2243{
2244 b43_radio_write16(dev, offset,
2245 b43_radio_read16(dev, offset) & mask);
2246}
2247
2248void b43_radio_set(struct b43_wldev *dev, u16 offset, u16 set)
2249{
2250 b43_radio_write16(dev, offset,
2251 b43_radio_read16(dev, offset) | set);
2252}
2253
2254void b43_radio_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set)
2255{
2256 b43_radio_write16(dev, offset,
2257 (b43_radio_read16(dev, offset) & mask) | set);
2258}
2259
2218static void b43_set_all_gains(struct b43_wldev *dev, 2260static void b43_set_all_gains(struct b43_wldev *dev,
2219 s16 first, s16 second, s16 third) 2261 s16 first, s16 second, s16 third)
2220{ 2262{
@@ -3852,6 +3894,10 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
3852 case B43_PHYTYPE_G: 3894 case B43_PHYTYPE_G:
3853 channel = B43_DEFAULT_CHANNEL_BG; 3895 channel = B43_DEFAULT_CHANNEL_BG;
3854 break; 3896 break;
3897 case B43_PHYTYPE_N:
3898 //FIXME check if we are on 2.4GHz or 5GHz and set a default channel.
3899 channel = 1;
3900 break;
3855 default: 3901 default:
3856 B43_WARN_ON(1); 3902 B43_WARN_ON(1);
3857 } 3903 }
@@ -3861,11 +3907,13 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
3861 * firmware from sending ghost packets. 3907 * firmware from sending ghost packets.
3862 */ 3908 */
3863 channelcookie = channel; 3909 channelcookie = channel;
3864 if (phy->type == B43_PHYTYPE_A) 3910 if (0 /*FIXME on 5Ghz */)
3865 channelcookie |= 0x100; 3911 channelcookie |= 0x100;
3912 //FIXME set 40Mhz flag if required
3866 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_CHAN, channelcookie); 3913 b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_CHAN, channelcookie);
3867 3914
3868 if (phy->type == B43_PHYTYPE_A) { 3915 switch (phy->type) {
3916 case B43_PHYTYPE_A:
3869 if (channel > 200) 3917 if (channel > 200)
3870 return -EINVAL; 3918 return -EINVAL;
3871 freq = channel2freq_a(channel); 3919 freq = channel2freq_a(channel);
@@ -3914,7 +3962,8 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
3914 b43_radio_set_tx_iq(dev); 3962 b43_radio_set_tx_iq(dev);
3915 //TODO: TSSI2dbm workaround 3963 //TODO: TSSI2dbm workaround
3916 b43_phy_xmitpower(dev); //FIXME correct? 3964 b43_phy_xmitpower(dev); //FIXME correct?
3917 } else { 3965 break;
3966 case B43_PHYTYPE_G:
3918 if ((channel < 1) || (channel > 14)) 3967 if ((channel < 1) || (channel > 14))
3919 return -EINVAL; 3968 return -EINVAL;
3920 3969
@@ -3939,6 +3988,12 @@ int b43_radio_selectchannel(struct b43_wldev *dev,
3939 b43_read16(dev, B43_MMIO_CHANNEL_EXT) 3988 b43_read16(dev, B43_MMIO_CHANNEL_EXT)
3940 & 0xF7BF); 3989 & 0xF7BF);
3941 } 3990 }
3991 break;
3992 case B43_PHYTYPE_N:
3993 b43_nphy_selectchannel(dev, channel);
3994 break;
3995 default:
3996 B43_WARN_ON(1);
3942 } 3997 }
3943 3998
3944 phy->channel = channel; 3999 phy->channel = channel;
@@ -3985,6 +4040,9 @@ void b43_radio_turn_on(struct b43_wldev *dev)
3985 err |= b43_radio_selectchannel(dev, channel, 0); 4040 err |= b43_radio_selectchannel(dev, channel, 0);
3986 B43_WARN_ON(err); 4041 B43_WARN_ON(err);
3987 break; 4042 break;
4043 case B43_PHYTYPE_N:
4044 b43_nphy_radio_turn_on(dev);
4045 break;
3988 default: 4046 default:
3989 B43_WARN_ON(1); 4047 B43_WARN_ON(1);
3990 } 4048 }
@@ -3998,13 +4056,17 @@ void b43_radio_turn_off(struct b43_wldev *dev, bool force)
3998 if (!phy->radio_on && !force) 4056 if (!phy->radio_on && !force)
3999 return; 4057 return;
4000 4058
4001 if (phy->type == B43_PHYTYPE_A) { 4059 switch (phy->type) {
4060 case B43_PHYTYPE_N:
4061 b43_nphy_radio_turn_off(dev);
4062 break;
4063 case B43_PHYTYPE_A:
4002 b43_radio_write16(dev, 0x0004, 0x00FF); 4064 b43_radio_write16(dev, 0x0004, 0x00FF);
4003 b43_radio_write16(dev, 0x0005, 0x00FB); 4065 b43_radio_write16(dev, 0x0005, 0x00FB);
4004 b43_phy_write(dev, 0x0010, b43_phy_read(dev, 0x0010) | 0x0008); 4066 b43_phy_write(dev, 0x0010, b43_phy_read(dev, 0x0010) | 0x0008);
4005 b43_phy_write(dev, 0x0011, b43_phy_read(dev, 0x0011) | 0x0008); 4067 b43_phy_write(dev, 0x0011, b43_phy_read(dev, 0x0011) | 0x0008);
4006 } 4068 break;
4007 if (phy->type == B43_PHYTYPE_G && dev->dev->id.revision >= 5) { 4069 case B43_PHYTYPE_G: {
4008 u16 rfover, rfoverval; 4070 u16 rfover, rfoverval;
4009 4071
4010 rfover = b43_phy_read(dev, B43_PHY_RFOVER); 4072 rfover = b43_phy_read(dev, B43_PHY_RFOVER);
@@ -4016,7 +4078,10 @@ void b43_radio_turn_off(struct b43_wldev *dev, bool force)
4016 } 4078 }
4017 b43_phy_write(dev, B43_PHY_RFOVER, rfover | 0x008C); 4079 b43_phy_write(dev, B43_PHY_RFOVER, rfover | 0x008C);
4018 b43_phy_write(dev, B43_PHY_RFOVERVAL, rfoverval & 0xFF73); 4080 b43_phy_write(dev, B43_PHY_RFOVERVAL, rfoverval & 0xFF73);
4019 } else 4081 break;
4020 b43_phy_write(dev, 0x0015, 0xAA00); 4082 }
4083 default:
4084 B43_WARN_ON(1);
4085 }
4021 phy->radio_on = 0; 4086 phy->radio_on = 0;
4022} 4087}