phy_lp.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /*
  2. Broadcom B43 wireless driver
  3. IEEE 802.11g LP-PHY driver
  4. Copyright (c) 2008 Michael Buesch <mb@bu3sch.de>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; see the file COPYING. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #include "b43.h"
  19. #include "phy_lp.h"
  20. #include "phy_common.h"
  21. static int b43_lpphy_op_allocate(struct b43_wldev *dev)
  22. {
  23. struct b43_phy_lp *lpphy;
  24. lpphy = kzalloc(sizeof(*lpphy), GFP_KERNEL);
  25. if (!lpphy)
  26. return -ENOMEM;
  27. dev->phy.lp = lpphy;
  28. return 0;
  29. }
  30. static void b43_lpphy_op_prepare_structs(struct b43_wldev *dev)
  31. {
  32. struct b43_phy *phy = &dev->phy;
  33. struct b43_phy_lp *lpphy = phy->lp;
  34. memset(lpphy, 0, sizeof(*lpphy));
  35. //TODO
  36. }
  37. static void b43_lpphy_op_free(struct b43_wldev *dev)
  38. {
  39. struct b43_phy_lp *lpphy = dev->phy.lp;
  40. kfree(lpphy);
  41. dev->phy.lp = NULL;
  42. }
  43. static int b43_lpphy_op_init(struct b43_wldev *dev)
  44. {
  45. //TODO
  46. return 0;
  47. }
  48. static u16 b43_lpphy_op_read(struct b43_wldev *dev, u16 reg)
  49. {
  50. b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
  51. return b43_read16(dev, B43_MMIO_PHY_DATA);
  52. }
  53. static void b43_lpphy_op_write(struct b43_wldev *dev, u16 reg, u16 value)
  54. {
  55. b43_write16(dev, B43_MMIO_PHY_CONTROL, reg);
  56. b43_write16(dev, B43_MMIO_PHY_DATA, value);
  57. }
  58. static u16 b43_lpphy_op_radio_read(struct b43_wldev *dev, u16 reg)
  59. {
  60. /* Register 1 is a 32-bit register. */
  61. B43_WARN_ON(reg == 1);
  62. /* LP-PHY needs a special bit set for read access */
  63. if (dev->phy.rev < 2) {
  64. if (reg != 0x4001)
  65. reg |= 0x100;
  66. } else
  67. reg |= 0x200;
  68. b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
  69. return b43_read16(dev, B43_MMIO_RADIO_DATA_LOW);
  70. }
  71. static void b43_lpphy_op_radio_write(struct b43_wldev *dev, u16 reg, u16 value)
  72. {
  73. /* Register 1 is a 32-bit register. */
  74. B43_WARN_ON(reg == 1);
  75. b43_write16(dev, B43_MMIO_RADIO_CONTROL, reg);
  76. b43_write16(dev, B43_MMIO_RADIO_DATA_LOW, value);
  77. }
  78. static void b43_lpphy_op_software_rfkill(struct b43_wldev *dev,
  79. enum rfkill_state state)
  80. {
  81. //TODO
  82. }
  83. static int b43_lpphy_op_switch_channel(struct b43_wldev *dev,
  84. unsigned int new_channel)
  85. {
  86. //TODO
  87. return 0;
  88. }
  89. static unsigned int b43_lpphy_op_get_default_chan(struct b43_wldev *dev)
  90. {
  91. return 1; /* Default to channel 1 */
  92. }
  93. static void b43_lpphy_op_set_rx_antenna(struct b43_wldev *dev, int antenna)
  94. {
  95. //TODO
  96. }
  97. static void b43_lpphy_op_adjust_txpower(struct b43_wldev *dev)
  98. {
  99. //TODO
  100. }
  101. static enum b43_txpwr_result b43_lpphy_op_recalc_txpower(struct b43_wldev *dev,
  102. bool ignore_tssi)
  103. {
  104. //TODO
  105. return B43_TXPWR_RES_DONE;
  106. }
  107. const struct b43_phy_operations b43_phyops_lp = {
  108. .allocate = b43_lpphy_op_allocate,
  109. .free = b43_lpphy_op_free,
  110. .prepare_structs = b43_lpphy_op_prepare_structs,
  111. .init = b43_lpphy_op_init,
  112. .phy_read = b43_lpphy_op_read,
  113. .phy_write = b43_lpphy_op_write,
  114. .radio_read = b43_lpphy_op_radio_read,
  115. .radio_write = b43_lpphy_op_radio_write,
  116. .software_rfkill = b43_lpphy_op_software_rfkill,
  117. .switch_analog = b43_phyop_switch_analog_generic,
  118. .switch_channel = b43_lpphy_op_switch_channel,
  119. .get_default_chan = b43_lpphy_op_get_default_chan,
  120. .set_rx_antenna = b43_lpphy_op_set_rx_antenna,
  121. .recalc_txpower = b43_lpphy_op_recalc_txpower,
  122. .adjust_txpower = b43_lpphy_op_adjust_txpower,
  123. };