blob: b427aeeaa1f28be8858d77019ecdff57e2836323 [file] [log] [blame]
Michael Buesch424047e2008-01-09 16:13:56 +01001/*
2
3 Broadcom B43 wireless driver
4 IEEE 802.11n PHY support
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 "nphy.h"
Michael Buesch53a6e232008-01-13 21:23:44 +010027#include "tables_nphy.h"
Michael Buesch424047e2008-01-09 16:13:56 +010028
29
Michael Buesch53a6e232008-01-13 21:23:44 +010030void b43_nphy_set_rxantenna(struct b43_wldev *dev, int antenna)
31{//TODO
32}
33
34void b43_nphy_xmitpower(struct b43_wldev *dev)
35{//TODO
36}
37
38/* Tune the hardware to a new channel. Don't call this directly.
39 * Use b43_radio_selectchannel() */
40void b43_nphy_selectchannel(struct b43_wldev *dev, u8 channel)
41{
42
43//TODO
44}
45
46static void b43_radio_init2055_pre(struct b43_wldev *dev)
47{
48 b43_phy_mask(dev, B43_NPHY_RFCTL_CMD,
49 ~B43_NPHY_RFCTL_CMD_PORFORCE);
50 b43_phy_set(dev, B43_NPHY_RFCTL_CMD,
51 B43_NPHY_RFCTL_CMD_CHIP0PU |
52 B43_NPHY_RFCTL_CMD_OEPORFORCE);
53 b43_phy_set(dev, B43_NPHY_RFCTL_CMD,
54 B43_NPHY_RFCTL_CMD_PORFORCE);
55}
56
57static void b43_radio_init2055_post(struct b43_wldev *dev)
58{
59 struct ssb_sprom *sprom = &(dev->dev->bus->sprom);
60 struct ssb_boardinfo *binfo = &(dev->dev->bus->boardinfo);
61 int i;
62 u16 val;
63
64 b43_radio_mask(dev, B2055_MASTER1, 0xFFF3);
65 msleep(1);
66 if ((sprom->revision != 4) || !(sprom->boardflags_hi & 0x0002)) {
67 if ((binfo->vendor != PCI_VENDOR_ID_BROADCOM) ||
68 (binfo->type != 0x46D) ||
69 (binfo->rev < 0x41)) {
70 b43_radio_mask(dev, B2055_C1_RX_BB_REG, 0x7F);
71 b43_radio_mask(dev, B2055_C1_RX_BB_REG, 0x7F);
72 msleep(1);
73 }
74 }
75 b43_radio_maskset(dev, B2055_RRCCAL_NOPTSEL, 0x3F, 0x2C);
76 msleep(1);
77 b43_radio_write16(dev, B2055_CAL_MISC, 0x3C);
78 msleep(1);
79 b43_radio_mask(dev, B2055_CAL_MISC, 0xFFBE);
80 msleep(1);
81 b43_radio_set(dev, B2055_CAL_LPOCTL, 0x80);
82 msleep(1);
83 b43_radio_set(dev, B2055_CAL_MISC, 0x1);
84 msleep(1);
85 b43_radio_set(dev, B2055_CAL_MISC, 0x40);
86 msleep(1);
87 for (i = 0; i < 100; i++) {
88 val = b43_radio_read16(dev, B2055_CAL_COUT2);
89 if (val & 0x80)
90 break;
91 udelay(10);
92 }
93 msleep(1);
94 b43_radio_mask(dev, B2055_CAL_LPOCTL, 0xFF7F);
95 msleep(1);
96 b43_radio_selectchannel(dev, dev->phy.channel, 0);
97 b43_radio_write16(dev, B2055_C1_RX_BB_LPF, 0x9);
98 b43_radio_write16(dev, B2055_C2_RX_BB_LPF, 0x9);
99 b43_radio_write16(dev, B2055_C1_RX_BB_MIDACHP, 0x83);
100 b43_radio_write16(dev, B2055_C2_RX_BB_MIDACHP, 0x83);
101}
102
103/* Initialize a Broadcom 2055 N-radio */
104static void b43_radio_init2055(struct b43_wldev *dev)
105{
106 b43_radio_init2055_pre(dev);
107 if (b43_status(dev) < B43_STAT_INITIALIZED)
108 b2055_upload_inittab(dev, 0, 1);
109 else
110 b2055_upload_inittab(dev, 0/*FIXME on 5ghz band*/, 0);
111 b43_radio_init2055_post(dev);
112}
113
114void b43_nphy_radio_turn_on(struct b43_wldev *dev)
115{
116 b43_radio_init2055(dev);
117}
118
119void b43_nphy_radio_turn_off(struct b43_wldev *dev)
120{
121 b43_phy_mask(dev, B43_NPHY_RFCTL_CMD,
122 ~B43_NPHY_RFCTL_CMD_EN);
123}
124
Michael Buesch424047e2008-01-09 16:13:56 +0100125int b43_phy_initn(struct b43_wldev *dev)
126{
127 b43err(dev->wl, "IEEE 802.11n devices are not supported, yet.\n");
128
Michael Buesch53a6e232008-01-13 21:23:44 +0100129 return 0;
Michael Buesch424047e2008-01-09 16:13:56 +0100130}