phy_ac.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. #include "b43.h"
  13. #include "phy_ac.h"
  14. /**************************************************
  15. * Basic PHY ops
  16. **************************************************/
  17. static int b43_phy_ac_op_allocate(struct b43_wldev *dev)
  18. {
  19. 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;
  24. return 0;
  25. }
  26. static void b43_phy_ac_op_free(struct b43_wldev *dev)
  27. {
  28. struct b43_phy *phy = &dev->phy;
  29. struct b43_phy_ac *phy_ac = phy->ac;
  30. kfree(phy_ac);
  31. phy->ac = NULL;
  32. }
  33. static void b43_phy_ac_op_maskset(struct b43_wldev *dev, u16 reg, u16 mask,
  34. u16 set)
  35. {
  36. b43_write16f(dev, B43_MMIO_PHY_CONTROL, reg);
  37. b43_write16(dev, B43_MMIO_PHY_DATA,
  38. (b43_read16(dev, B43_MMIO_PHY_DATA) & mask) | set);
  39. }
  40. static u16 b43_phy_ac_op_radio_read(struct b43_wldev *dev, u16 reg)
  41. {
  42. b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
  43. return b43_read16(dev, B43_MMIO_RADIO24_DATA);
  44. }
  45. static void b43_phy_ac_op_radio_write(struct b43_wldev *dev, u16 reg,
  46. u16 value)
  47. {
  48. b43_write16f(dev, B43_MMIO_RADIO24_CONTROL, reg);
  49. b43_write16(dev, B43_MMIO_RADIO24_DATA, value);
  50. }
  51. static unsigned int b43_phy_ac_op_get_default_chan(struct b43_wldev *dev)
  52. {
  53. if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)
  54. return 11;
  55. return 36;
  56. }
  57. static enum b43_txpwr_result
  58. b43_phy_ac_op_recalc_txpower(struct b43_wldev *dev, bool ignore_tssi)
  59. {
  60. return B43_TXPWR_RES_DONE;
  61. }
  62. static void b43_phy_ac_op_adjust_txpower(struct b43_wldev *dev)
  63. {
  64. }
  65. /**************************************************
  66. * PHY ops struct
  67. **************************************************/
  68. const struct b43_phy_operations b43_phyops_ac = {
  69. .allocate = b43_phy_ac_op_allocate,
  70. .free = b43_phy_ac_op_free,
  71. .phy_maskset = b43_phy_ac_op_maskset,
  72. .radio_read = b43_phy_ac_op_radio_read,
  73. .radio_write = b43_phy_ac_op_radio_write,
  74. .get_default_chan = b43_phy_ac_op_get_default_chan,
  75. .recalc_txpower = b43_phy_ac_op_recalc_txpower,
  76. .adjust_txpower = b43_phy_ac_op_adjust_txpower,
  77. };