ath5k: annotate reg in ath5k_hw_nic_reset() as __iomem
[linux-2.6-block.git] / drivers / net / wireless / b43 / phy_ht.c
CommitLineData
d7520b1d
RM
1/*
2
3 Broadcom B43 wireless driver
4 IEEE 802.11n HT-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_ht.h"
27#include "main.h"
28
29/**************************************************
30 * Basic PHY ops.
31 **************************************************/
32
33static int b43_phy_ht_op_allocate(struct b43_wldev *dev)
34{
35 struct b43_phy_ht *phy_ht;
36
37 phy_ht = kzalloc(sizeof(*phy_ht), GFP_KERNEL);
38 if (!phy_ht)
39 return -ENOMEM;
40 dev->phy.ht = phy_ht;
41
42 return 0;
43}
44
45static void b43_phy_ht_op_prepare_structs(struct b43_wldev *dev)
46{
47 struct b43_phy *phy = &dev->phy;
48 struct b43_phy_ht *phy_ht = phy->ht;
49
50 memset(phy_ht, 0, sizeof(*phy_ht));
51}
52
53static void b43_phy_ht_op_free(struct b43_wldev *dev)
54{
55 struct b43_phy *phy = &dev->phy;
56 struct b43_phy_ht *phy_ht = phy->ht;
57
58 kfree(phy_ht);
59 phy->ht = NULL;
60}
61
62static unsigned int b43_phy_ht_op_get_default_chan(struct b43_wldev *dev)
63{
64 if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
65 return 1;
66 return 36;
67}
68
69/**************************************************
70 * R/W ops.
71 **************************************************/
72
73static u16 b43_phy_ht_op_read(struct b43_wldev *dev, u16 reg)
74{
75 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
76 return b43_read16(dev, B43_MMIO_PHY_DATA);
77}
78
79static void b43_phy_ht_op_write(struct b43_wldev *dev, u16 reg, u16 value)
80{
81 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
82 b43_write16(dev, B43_MMIO_PHY_DATA, value);
83}
84
85static void b43_phy_ht_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
86 u16 set)
87{
88 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
89 b43_write16(dev, B43_MMIO_PHY_DATA,
90 (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
91}
92
93/**************************************************
94 * PHY ops struct.
95 **************************************************/
96
97const struct b43_phy_operations b43_phyops_ht = {
98 .allocate = b43_phy_ht_op_allocate,
99 .free = b43_phy_ht_op_free,
100 .prepare_structs = b43_phy_ht_op_prepare_structs,
101 /*
102 .init = b43_phy_ht_op_init,
103 */
104 .phy_read = b43_phy_ht_op_read,
105 .phy_write = b43_phy_ht_op_write,
106 .phy_maskset = b43_phy_ht_op_maskset,
107 /*
108 .radio_read = b43_phy_ht_op_radio_read,
109 .radio_write = b43_phy_ht_op_radio_write,
110 .software_rfkill = b43_phy_ht_op_software_rfkill,
111 .switch_analog = b43_phy_ht_op_switch_analog,
112 .switch_channel = b43_phy_ht_op_switch_channel,
113 */
114 .get_default_chan = b43_phy_ht_op_get_default_chan,
115 /*
116 .recalc_txpower = b43_phy_ht_op_recalc_txpower,
117 .adjust_txpower = b43_phy_ht_op_adjust_txpower,
118 */
119};