blob: e769ca0b29a2d43af1e03b6811d0c740dfb362d2 [file] [log] [blame]
Michael Buesche63e4362008-08-30 10:55:48 +02001/*
2
3 Broadcom B43 wireless driver
4 IEEE 802.11g LP-PHY driver
5
6 Copyright (c) 2008 Michael Buesch <mb@bu3sch.de>
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; see the file COPYING. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22
23*/
24
25#include "b43.h"
26#include "phy_lp.h"
27#include "phy_common.h"
28
29
30static int b43_lpphy_op_allocate(struct b43_wldev *dev)
31{
32 struct b43_phy_lp *lpphy;
33
34 lpphy = kzalloc(sizeof(*lpphy), GFP_KERNEL);
35 if (!lpphy)
36 return -ENOMEM;
37 dev->phy.lp = lpphy;
38
39 //TODO
40
41 return 0;
42}
43
44static int b43_lpphy_op_init(struct b43_wldev *dev)
45{
46 struct b43_phy_lp *lpphy = dev->phy.lp;
47
48 //TODO
49 lpphy->initialised = 1;
50
51 return 0;
52}
53
54static void b43_lpphy_op_exit(struct b43_wldev *dev)
55{
56 struct b43_phy_lp *lpphy = dev->phy.lp;
57
58 if (lpphy->initialised) {
59 //TODO
60 lpphy->initialised = 0;
61 }
62
63 kfree(lpphy);
64 dev->phy.lp = NULL;
65}
66
67static u16 b43_lpphy_op_read(struct b43_wldev *dev, u16 reg)
68{
Michael Buesch08887072008-08-30 11:49:45 +020069 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
70 return b43_read16(dev, B43_MMIO_PHY_DATA);
Michael Buesche63e4362008-08-30 10:55:48 +020071}
72
73static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
74{
Michael Buesch08887072008-08-30 11:49:45 +020075 b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
76 b43_write16(dev, B43_MMIO_PHY_DATA, value);
Michael Buesche63e4362008-08-30 10:55:48 +020077}
78
79static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg)
80{
Michael Buesch08887072008-08-30 11:49:45 +020081 /* Register 1 is a 32-bit register. */
82 B43_WARN_ON(reg == 1);
83 /* LP-PHY needs a special bit set for read access */
84 if (dev->phy.rev < 2) {
85 if (reg != 0x4001)
86 reg |= 0x100;
87 } else
88 reg |= 0x200;
89
90 b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
91 return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
Michael Buesche63e4362008-08-30 10:55:48 +020092}
93
94static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
95{
96 /* Register 1 is a 32-bit register. */
97 B43_WARN_ON(reg == 1);
98
Michael Buesch08887072008-08-30 11:49:45 +020099 b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
100 b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
Michael Buesche63e4362008-08-30 10:55:48 +0200101}
102
103static void b43_lpphy_op_software_rfkill(struct b43_wldev *dev,
104 enum rfkill_state state)
105{
106 //TODO
107}
108
109static int b43_lpphy_op_switch_channel(struct b43_wldev *dev,
110 unsigned int new_channel)
111{
112 //TODO
113 return 0;
114}
115
116static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev)
117{
118 return 1; /* Default to channel 1 */
119}
120
121static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
122{
123 //TODO
124}
125
126static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev)
127{
128 //TODO
129}
130
131static enum b43_txpwr_result b43_lpphy_op_recalc_txpower(struct b43_wldev *dev,
132 bool ignore_tssi)
133{
134 //TODO
135 return B43_TXPWR_RES_DONE;
136}
137
138
139const struct b43_phy_operations b43_phyops_lp = {
140 .allocate = b43_lpphy_op_allocate,
141 .init = b43_lpphy_op_init,
142 .exit = b43_lpphy_op_exit,
143 .phy_read = b43_lpphy_op_read,
144 .phy_write = b43_lpphy_op_write,
145 .radio_read = b43_lpphy_op_radio_read,
146 .radio_write = b43_lpphy_op_radio_write,
147 .software_rfkill = b43_lpphy_op_software_rfkill,
148 .switch_channel = b43_lpphy_op_switch_channel,
149 .get_default_chan = b43_lpphy_op_get_default_chan,
150 .set_rx_antenna = b43_lpphy_op_set_rx_antenna,
151 .recalc_txpower = b43_lpphy_op_recalc_txpower,
152 .adjust_txpower = b43_lpphy_op_adjust_txpower,
153};