blob: 69a93b5586c8b72afc737a846197c2740bccbbd2 [file] [log] [blame]
Rafał Miłecki1d738e62011-07-07 15:25:27 +02001/*
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łeckif9286682011-08-14 23:27:28 +020031 * Basic PHY ops.
32 **************************************************/
33
34static 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
46static 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
55static 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łeckiba356b52011-08-14 23:27:29 +020063static 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łeckif9286682011-08-14 23:27:28 +020084static unsigned int b43_phy_lcn_op_get_default_chan(struct b43_wldev *dev)
85{
86 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
87 return 1;
88 return 36;
89}
90
91static enum b43_txpwr_result
92b43_phy_lcn_op_recalc_txpower(struct b43_wldev *dev, bool ignore_tssi)
93{
94 return B43_TXPWR_RES_DONE;
95}
96
97static void b43_phy_lcn_op_adjust_txpower(struct b43_wldev *dev)
98{
99}
100
101/**************************************************
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200102 * PHY ops struct.
103 **************************************************/
104
105const struct b43_phy_operations b43_phyops_lcn = {
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200106 .allocate = b43_phy_lcn_op_allocate,
107 .free = b43_phy_lcn_op_free,
108 .prepare_structs = b43_phy_lcn_op_prepare_structs,
Rafał Miłeckif9286682011-08-14 23:27:28 +0200109 /*
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200110 .init = b43_phy_lcn_op_init,
111 .phy_read = b43_phy_lcn_op_read,
112 .phy_write = b43_phy_lcn_op_write,
113 .phy_maskset = b43_phy_lcn_op_maskset,
114 .radio_read = b43_phy_lcn_op_radio_read,
115 .radio_write = b43_phy_lcn_op_radio_write,
Rafał Miłeckiba356b52011-08-14 23:27:29 +0200116 */
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200117 .software_rfkill = b43_phy_lcn_op_software_rfkill,
Rafał Miłeckiba356b52011-08-14 23:27:29 +0200118 /*
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200119 .switch_analog = b43_phy_lcn_op_switch_analog,
120 .switch_channel = b43_phy_lcn_op_switch_channel,
Rafał Miłeckif9286682011-08-14 23:27:28 +0200121 */
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200122 .get_default_chan = b43_phy_lcn_op_get_default_chan,
123 .recalc_txpower = b43_phy_lcn_op_recalc_txpower,
124 .adjust_txpower = b43_phy_lcn_op_adjust_txpower,
Rafał Miłecki1d738e62011-07-07 15:25:27 +0200125};