Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Broadcom B43 wireless driver |
| 4 | IEEE 802.11n LCN-PHY support |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; see the file COPYING. If not, write to |
| 18 | the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, |
| 19 | Boston, MA 02110-1301, USA. |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | #include <linux/slab.h> |
| 24 | |
| 25 | #include "b43.h" |
| 26 | #include "phy_lcn.h" |
| 27 | #include "tables_phy_lcn.h" |
| 28 | #include "main.h" |
| 29 | |
| 30 | /************************************************** |
Rafał Miłecki | f928668 | 2011-08-14 23:27:28 +0200 | [diff] [blame] | 31 | * Basic PHY ops. |
| 32 | **************************************************/ |
| 33 | |
| 34 | static int b43_phy_lcn_op_allocate(struct b43_wldev *dev) |
| 35 | { |
| 36 | struct b43_phy_lcn *phy_lcn; |
| 37 | |
| 38 | phy_lcn = kzalloc(sizeof(*phy_lcn), GFP_KERNEL); |
| 39 | if (!phy_lcn) |
| 40 | return -ENOMEM; |
| 41 | dev->phy.lcn = phy_lcn; |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | static void b43_phy_lcn_op_free(struct b43_wldev *dev) |
| 47 | { |
| 48 | struct b43_phy *phy = &dev->phy; |
| 49 | struct b43_phy_lcn *phy_lcn = phy->lcn; |
| 50 | |
| 51 | kfree(phy_lcn); |
| 52 | phy->lcn = NULL; |
| 53 | } |
| 54 | |
| 55 | static void b43_phy_lcn_op_prepare_structs(struct b43_wldev *dev) |
| 56 | { |
| 57 | struct b43_phy *phy = &dev->phy; |
| 58 | struct b43_phy_lcn *phy_lcn = phy->lcn; |
| 59 | |
| 60 | memset(phy_lcn, 0, sizeof(*phy_lcn)); |
| 61 | } |
| 62 | |
Rafał Miłecki | ba356b5 | 2011-08-14 23:27:29 +0200 | [diff] [blame] | 63 | static void b43_phy_lcn_op_software_rfkill(struct b43_wldev *dev, |
| 64 | bool blocked) |
| 65 | { |
| 66 | if (b43_read32(dev, B43_MMIO_MACCTL) & B43_MACCTL_ENABLED) |
| 67 | b43err(dev->wl, "MAC not suspended\n"); |
| 68 | |
| 69 | if (blocked) { |
| 70 | b43_phy_mask(dev, B43_PHY_LCN_RF_CTL2, ~0x7c00); |
| 71 | b43_phy_set(dev, B43_PHY_LCN_RF_CTL1, 0x1f00); |
| 72 | |
| 73 | b43_phy_mask(dev, B43_PHY_LCN_RF_CTL5, ~0x7f00); |
| 74 | b43_phy_mask(dev, B43_PHY_LCN_RF_CTL4, ~0x2); |
| 75 | b43_phy_set(dev, B43_PHY_LCN_RF_CTL3, 0x808); |
| 76 | |
| 77 | b43_phy_mask(dev, B43_PHY_LCN_RF_CTL7, ~0x8); |
| 78 | b43_phy_set(dev, B43_PHY_LCN_RF_CTL6, 0x8); |
| 79 | } else { |
| 80 | /* TODO */ |
| 81 | } |
| 82 | } |
| 83 | |
Rafał Miłecki | 7ed8852 | 2011-08-14 23:27:30 +0200 | [diff] [blame^] | 84 | static void b43_phy_lcn_op_switch_analog(struct b43_wldev *dev, bool on) |
| 85 | { |
| 86 | if (on) { |
| 87 | b43_phy_mask(dev, B43_PHY_LCN_AFE_CTL1, ~0x7); |
| 88 | } else { |
| 89 | b43_phy_set(dev, B43_PHY_LCN_AFE_CTL2, 0x7); |
| 90 | b43_phy_set(dev, B43_PHY_LCN_AFE_CTL1, 0x7); |
| 91 | } |
| 92 | } |
| 93 | |
Rafał Miłecki | f928668 | 2011-08-14 23:27:28 +0200 | [diff] [blame] | 94 | static unsigned int b43_phy_lcn_op_get_default_chan(struct b43_wldev *dev) |
| 95 | { |
| 96 | if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) |
| 97 | return 1; |
| 98 | return 36; |
| 99 | } |
| 100 | |
| 101 | static enum b43_txpwr_result |
| 102 | b43_phy_lcn_op_recalc_txpower(struct b43_wldev *dev, bool ignore_tssi) |
| 103 | { |
| 104 | return B43_TXPWR_RES_DONE; |
| 105 | } |
| 106 | |
| 107 | static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev) |
| 108 | { |
| 109 | } |
| 110 | |
| 111 | /************************************************** |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 112 | * PHY ops struct. |
| 113 | **************************************************/ |
| 114 | |
| 115 | const struct b43_phy_operations b43_phyops_lcn = { |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 116 | .allocate = b43_phy_lcn_op_allocate, |
| 117 | .free = b43_phy_lcn_op_free, |
| 118 | .prepare_structs = b43_phy_lcn_op_prepare_structs, |
Rafał Miłecki | f928668 | 2011-08-14 23:27:28 +0200 | [diff] [blame] | 119 | /* |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 120 | .init = b43_phy_lcn_op_init, |
| 121 | .phy_read = b43_phy_lcn_op_read, |
| 122 | .phy_write = b43_phy_lcn_op_write, |
| 123 | .phy_maskset = b43_phy_lcn_op_maskset, |
| 124 | .radio_read = b43_phy_lcn_op_radio_read, |
| 125 | .radio_write = b43_phy_lcn_op_radio_write, |
Rafał Miłecki | ba356b5 | 2011-08-14 23:27:29 +0200 | [diff] [blame] | 126 | */ |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 127 | .software_rfkill = b43_phy_lcn_op_software_rfkill, |
| 128 | .switch_analog = b43_phy_lcn_op_switch_analog, |
Rafał Miłecki | 7ed8852 | 2011-08-14 23:27:30 +0200 | [diff] [blame^] | 129 | /* |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 130 | .switch_channel = b43_phy_lcn_op_switch_channel, |
Rafał Miłecki | f928668 | 2011-08-14 23:27:28 +0200 | [diff] [blame] | 131 | */ |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 132 | .get_default_chan = b43_phy_lcn_op_get_default_chan, |
| 133 | .recalc_txpower = b43_phy_lcn_op_recalc_txpower, |
| 134 | .adjust_txpower = b43_phy_lcn_op_adjust_txpower, |
Rafał Miłecki | 1d738e6 | 2011-07-07 15:25:27 +0200 | [diff] [blame] | 135 | }; |