Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 30 | static 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 | |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 39 | return 0; |
| 40 | } |
| 41 | |
Michael Buesch | fb11137 | 2008-09-02 13:00:34 +0200 | [diff] [blame] | 42 | static void b43_lpphy_op_prepare_structs(struct b43_wldev *dev) |
| 43 | { |
| 44 | struct b43_phy *phy = &dev->phy; |
| 45 | struct b43_phy_lp *lpphy = phy->lp; |
| 46 | |
| 47 | memset(lpphy, 0, sizeof(*lpphy)); |
| 48 | |
| 49 | //TODO |
| 50 | } |
| 51 | |
| 52 | static void b43_lpphy_op_free(struct b43_wldev *dev) |
| 53 | { |
| 54 | struct b43_phy_lp *lpphy = dev->phy.lp; |
| 55 | |
| 56 | kfree(lpphy); |
| 57 | dev->phy.lp = NULL; |
| 58 | } |
| 59 | |
Michael Buesch | a387cc7 | 2009-01-31 14:20:44 +0100 | [diff] [blame^] | 60 | static void lpphy_table_init(struct b43_wldev *dev) |
| 61 | { |
| 62 | //TODO |
| 63 | } |
| 64 | |
| 65 | static void lpphy_baseband_rev0_1_init(struct b43_wldev *dev) |
| 66 | { |
| 67 | B43_WARN_ON(1);//TODO rev < 2 not supported, yet. |
| 68 | } |
| 69 | |
| 70 | static void lpphy_baseband_rev2plus_init(struct b43_wldev *dev) |
| 71 | { |
| 72 | //TODO |
| 73 | } |
| 74 | |
| 75 | static void lpphy_baseband_init(struct b43_wldev *dev) |
| 76 | { |
| 77 | lpphy_table_init(dev); |
| 78 | if (dev->phy.rev >= 2) |
| 79 | lpphy_baseband_rev2plus_init(dev); |
| 80 | else |
| 81 | lpphy_baseband_rev0_1_init(dev); |
| 82 | } |
| 83 | |
| 84 | static void lpphy_radio_init(struct b43_wldev *dev) |
| 85 | { |
| 86 | //TODO |
| 87 | } |
| 88 | |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 89 | static int b43_lpphy_op_init(struct b43_wldev *dev) |
| 90 | { |
Michael Buesch | a387cc7 | 2009-01-31 14:20:44 +0100 | [diff] [blame^] | 91 | /* TODO: band SPROM */ |
| 92 | lpphy_baseband_init(dev); |
| 93 | lpphy_radio_init(dev); |
| 94 | |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 95 | //TODO |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 96 | |
| 97 | return 0; |
| 98 | } |
| 99 | |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 100 | static u16 b43_lpphy_op_read(struct b43_wldev *dev, u16 reg) |
| 101 | { |
Michael Buesch | 0888707 | 2008-08-30 11:49:45 +0200 | [diff] [blame] | 102 | b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); |
| 103 | return b43_read16(dev, B43_MMIO_PHY_DATA); |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value) |
| 107 | { |
Michael Buesch | 0888707 | 2008-08-30 11:49:45 +0200 | [diff] [blame] | 108 | b43_write16(dev, B43_MMIO_PHY_CONTROL, reg); |
| 109 | b43_write16(dev, B43_MMIO_PHY_DATA, value); |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg) |
| 113 | { |
Michael Buesch | 0888707 | 2008-08-30 11:49:45 +0200 | [diff] [blame] | 114 | /* Register 1 is a 32-bit register. */ |
| 115 | B43_WARN_ON(reg == 1); |
| 116 | /* LP-PHY needs a special bit set for read access */ |
| 117 | if (dev->phy.rev < 2) { |
| 118 | if (reg != 0x4001) |
| 119 | reg |= 0x100; |
| 120 | } else |
| 121 | reg |= 0x200; |
| 122 | |
| 123 | b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg); |
| 124 | return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW); |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value) |
| 128 | { |
| 129 | /* Register 1 is a 32-bit register. */ |
| 130 | B43_WARN_ON(reg == 1); |
| 131 | |
Michael Buesch | 0888707 | 2008-08-30 11:49:45 +0200 | [diff] [blame] | 132 | b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg); |
| 133 | b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value); |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | static void b43_lpphy_op_software_rfkill(struct b43_wldev *dev, |
| 137 | enum rfkill_state state) |
| 138 | { |
| 139 | //TODO |
| 140 | } |
| 141 | |
| 142 | static int b43_lpphy_op_switch_channel(struct b43_wldev *dev, |
| 143 | unsigned int new_channel) |
| 144 | { |
| 145 | //TODO |
| 146 | return 0; |
| 147 | } |
| 148 | |
| 149 | static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev) |
| 150 | { |
| 151 | return 1; /* Default to channel 1 */ |
| 152 | } |
| 153 | |
| 154 | static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna) |
| 155 | { |
| 156 | //TODO |
| 157 | } |
| 158 | |
| 159 | static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev) |
| 160 | { |
| 161 | //TODO |
| 162 | } |
| 163 | |
| 164 | static enum b43_txpwr_result b43_lpphy_op_recalc_txpower(struct b43_wldev *dev, |
| 165 | bool ignore_tssi) |
| 166 | { |
| 167 | //TODO |
| 168 | return B43_TXPWR_RES_DONE; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | const struct b43_phy_operations b43_phyops_lp = { |
| 173 | .allocate = b43_lpphy_op_allocate, |
Michael Buesch | fb11137 | 2008-09-02 13:00:34 +0200 | [diff] [blame] | 174 | .free = b43_lpphy_op_free, |
| 175 | .prepare_structs = b43_lpphy_op_prepare_structs, |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 176 | .init = b43_lpphy_op_init, |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 177 | .phy_read = b43_lpphy_op_read, |
| 178 | .phy_write = b43_lpphy_op_write, |
| 179 | .radio_read = b43_lpphy_op_radio_read, |
| 180 | .radio_write = b43_lpphy_op_radio_write, |
| 181 | .software_rfkill = b43_lpphy_op_software_rfkill, |
Michael Buesch | cb24f57 | 2008-09-03 12:12:20 +0200 | [diff] [blame] | 182 | .switch_analog = b43_phyop_switch_analog_generic, |
Michael Buesch | e63e436 | 2008-08-30 10:55:48 +0200 | [diff] [blame] | 183 | .switch_channel = b43_lpphy_op_switch_channel, |
| 184 | .get_default_chan = b43_lpphy_op_get_default_chan, |
| 185 | .set_rx_antenna = b43_lpphy_op_set_rx_antenna, |
| 186 | .recalc_txpower = b43_lpphy_op_recalc_txpower, |
| 187 | .adjust_txpower = b43_lpphy_op_adjust_txpower, |
| 188 | }; |