WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / wireless / broadcom / b43 / phy_ac.c
blob756cd44a81041f8b6f810833709222be4113de59
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Broadcom B43 wireless driver
4 * IEEE 802.11ac AC-PHY support
6 * Copyright (c) 2015 Rafał Miłecki <zajec5@gmail.com>
7 */
9 #include "b43.h"
10 #include "phy_ac.h"
12 /**************************************************
13 * Basic PHY ops
14 **************************************************/
16 static int b43_phy_ac_op_allocate(struct b43_wldev *dev)
18 struct b43_phy_ac *phy_ac;
20 phy_ac = kzalloc(sizeof(*phy_ac), GFP_KERNEL);
21 if (!phy_ac)
22 return -ENOMEM;
23 dev->phy.ac = phy_ac;
25 return 0;
28 static void b43_phy_ac_op_free(struct b43_wldev *dev)
30 struct b43_phy *phy = &dev->phy;
31 struct b43_phy_ac *phy_ac = phy->ac;
33 kfree(phy_ac);
34 phy->ac = NULL;
37 static void b43_phy_ac_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
38 u16 set)
40 b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
41 b43_write16(dev, B43_MMIO_PHY_DATA,
42 (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
45 static u16 b43_phy_ac_op_radio_read(struct b43_wldev *dev, u16 reg)
47 b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
48 return b43_read16(dev, B43_MMIO_RADIO24_DATA);
51 static void b43_phy_ac_op_radio_write(struct b43_wldev *dev, u16 reg,
52 u16 value)
54 b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
55 b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
58 static unsigned int b43_phy_ac_op_get_default_chan(struct b43_wldev *dev)
60 if (b43_current_band(dev->wl) == NL80211_BAND_2GHZ)
61 return 11;
62 return 36;
65 static enum b43_txpwr_result
66 b43_phy_ac_op_recalc_txpower(struct b43_wldev *dev, bool ignore_tssi)
68 return B43_TXPWR_RES_DONE;
71 static void b43_phy_ac_op_adjust_txpower(struct b43_wldev *dev)
75 /**************************************************
76 * PHY ops struct
77 **************************************************/
79 const struct b43_phy_operations b43_phyops_ac = {
80 .allocate = b43_phy_ac_op_allocate,
81 .free = b43_phy_ac_op_free,
82 .phy_maskset = b43_phy_ac_op_maskset,
83 .radio_read = b43_phy_ac_op_radio_read,
84 .radio_write = b43_phy_ac_op_radio_write,
85 .get_default_chan = b43_phy_ac_op_get_default_chan,
86 .recalc_txpower = b43_phy_ac_op_recalc_txpower,
87 .adjust_txpower = b43_phy_ac_op_adjust_txpower,