1 /* 2 * Broadcom B43 wireless driver 3 * IEEE 802.11ac AC-PHY support 4 * 5 * Copyright (c) 2015 Rafał Miłecki <zajec5@gmail.com> 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the 9 * Free Software Foundation; either version 2 of the License, or (at your 10 * option) any later version. 11 */ 12 13 #include "b43.h" 14 #include "phy_ac.h" 15 16 /************************************************** 17 * Basic PHY ops 18 **************************************************/ 19 20 static int b43_phy_ac_op_allocate(struct b43_wldev *dev) 21 { 22 struct b43_phy_ac *phy_ac; 23 24 phy_ac = kzalloc(sizeof(*phy_ac), GFP_KERNEL); 25 if (!phy_ac) 26 return -ENOMEM; 27 dev->phy.ac = phy_ac; 28 29 return 0; 30 } 31 32 static void b43_phy_ac_op_free(struct b43_wldev *dev) 33 { 34 struct b43_phy *phy = &dev->phy; 35 struct b43_phy_ac *phy_ac = phy->ac; 36 37 kfree(phy_ac); 38 phy->ac = NULL; 39 } 40 41 static void b43_phy_ac_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask, 42 u16 set) 43 { 44 b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg); 45 b43_write16(dev, B43_MMIO_PHY_DATA, 46 (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set); 47 } 48 49 static u16 b43_phy_ac_op_radio_read(struct b43_wldev *dev, u16 reg) 50 { 51 b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg); 52 return b43_read16(dev, B43_MMIO_RADIO24_DATA); 53 } 54 55 static void b43_phy_ac_op_radio_write(struct b43_wldev *dev, u16 reg, 56 u16 value) 57 { 58 b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg); 59 b43_write16(dev, B43_MMIO_RADIO24_DATA, value); 60 } 61 62 static unsigned int b43_phy_ac_op_get_default_chan(struct b43_wldev *dev) 63 { 64 if (b43_current_band(dev->wl) == NL80211_BAND_2GHZ) 65 return 11; 66 return 36; 67 } 68 69 static enum b43_txpwr_result 70 b43_phy_ac_op_recalc_txpower(struct b43_wldev *dev, bool ignore_tssi) 71 { 72 return B43_TXPWR_RES_DONE; 73 } 74 75 static void b43_phy_ac_op_adjust_txpower(struct b43_wldev *dev) 76 { 77 } 78 79 /************************************************** 80 * PHY ops struct 81 **************************************************/ 82 83 const struct b43_phy_operations b43_phyops_ac = { 84 .allocate = b43_phy_ac_op_allocate, 85 .free = b43_phy_ac_op_free, 86 .phy_maskset = b43_phy_ac_op_maskset, 87 .radio_read = b43_phy_ac_op_radio_read, 88 .radio_write = b43_phy_ac_op_radio_write, 89 .get_default_chan = b43_phy_ac_op_get_default_chan, 90 .recalc_txpower = b43_phy_ac_op_recalc_txpower, 91 .adjust_txpower = b43_phy_ac_op_adjust_txpower, 92 }; 93