tables_lpphy.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. Broadcom B43 wireless driver
  3. IEEE 802.11g LP-PHY and radio device data tables
  4. Copyright (c) 2009 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 "tables_lpphy.h"
  20. #include "phy_common.h"
  21. #include "phy_lp.h"
  22. u32 b43_lptab_read(struct b43_wldev *dev, u32 offset)
  23. {
  24. u32 type, value;
  25. type = offset & B43_LPTAB_TYPEMASK;
  26. offset &= ~B43_LPTAB_TYPEMASK;
  27. B43_WARN_ON(offset > 0xFFFF);
  28. switch (type) {
  29. case B43_LPTAB_8BIT:
  30. b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
  31. value = b43_phy_read(dev, B43_LPPHY_TABLEDATALO) & 0xFF;
  32. break;
  33. case B43_LPTAB_16BIT:
  34. b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
  35. value = b43_phy_read(dev, B43_LPPHY_TABLEDATALO);
  36. break;
  37. case B43_LPTAB_32BIT:
  38. b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
  39. value = b43_phy_read(dev, B43_LPPHY_TABLEDATAHI);
  40. value <<= 16;
  41. value |= b43_phy_read(dev, B43_LPPHY_TABLEDATALO);
  42. break;
  43. default:
  44. B43_WARN_ON(1);
  45. value = 0;
  46. }
  47. return value;
  48. }
  49. void b43_lptab_write(struct b43_wldev *dev, u32 offset, u32 value)
  50. {
  51. u32 type;
  52. type = offset & B43_LPTAB_TYPEMASK;
  53. offset &= ~B43_LPTAB_TYPEMASK;
  54. B43_WARN_ON(offset > 0xFFFF);
  55. switch (type) {
  56. case B43_LPTAB_8BIT:
  57. B43_WARN_ON(value & ~0xFF);
  58. b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
  59. b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
  60. break;
  61. case B43_LPTAB_16BIT:
  62. B43_WARN_ON(value & ~0xFFFF);
  63. b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
  64. b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
  65. break;
  66. case B43_LPTAB_32BIT:
  67. b43_phy_write(dev, B43_LPPHY_TABLE_ADDR, offset);
  68. b43_phy_write(dev, B43_LPPHY_TABLEDATAHI, value >> 16);
  69. b43_phy_write(dev, B43_LPPHY_TABLEDATALO, value);
  70. break;
  71. default:
  72. B43_WARN_ON(1);
  73. }
  74. }