main.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. Broadcom B43legacy wireless driver
  3. Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
  4. Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
  5. Copyright (c) 2005, 2006 Michael Buesch <m@bues.ch>
  6. Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
  7. Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
  8. Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net>
  9. Some parts of the code in this file are derived from the ipw2200
  10. driver Copyright(c) 2003 - 2004 Intel Corporation.
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; see the file COPYING. If not, write to
  21. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  22. Boston, MA 02110-1301, USA.
  23. */
  24. #ifndef B43legacy_MAIN_H_
  25. #define B43legacy_MAIN_H_
  26. #include "b43legacy.h"
  27. #define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes]
  28. #define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes)
  29. /* Magic helper macro to pad structures. Ignore those above. It's magic. */
  30. #define PAD_BYTES(nr_bytes) P4D_BYTES(__LINE__ , (nr_bytes))
  31. /* Lightweight function to convert a frequency (in Mhz) to a channel number. */
  32. static inline
  33. u8 b43legacy_freq_to_channel_bg(int freq)
  34. {
  35. u8 channel;
  36. if (freq == 2484)
  37. channel = 14;
  38. else
  39. channel = (freq - 2407) / 5;
  40. return channel;
  41. }
  42. static inline
  43. u8 b43legacy_freq_to_channel(struct b43legacy_wldev *dev,
  44. int freq)
  45. {
  46. return b43legacy_freq_to_channel_bg(freq);
  47. }
  48. /* Lightweight function to convert a channel number to a frequency (in Mhz). */
  49. static inline
  50. int b43legacy_channel_to_freq_bg(u8 channel)
  51. {
  52. int freq;
  53. if (channel == 14)
  54. freq = 2484;
  55. else
  56. freq = 2407 + (5 * channel);
  57. return freq;
  58. }
  59. static inline
  60. int b43legacy_channel_to_freq(struct b43legacy_wldev *dev,
  61. u8 channel)
  62. {
  63. return b43legacy_channel_to_freq_bg(channel);
  64. }
  65. static inline
  66. int b43legacy_is_cck_rate(int rate)
  67. {
  68. return (rate == B43legacy_CCK_RATE_1MB ||
  69. rate == B43legacy_CCK_RATE_2MB ||
  70. rate == B43legacy_CCK_RATE_5MB ||
  71. rate == B43legacy_CCK_RATE_11MB);
  72. }
  73. static inline
  74. int b43legacy_is_ofdm_rate(int rate)
  75. {
  76. return !b43legacy_is_cck_rate(rate);
  77. }
  78. void b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf);
  79. void b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf);
  80. u32 b43legacy_shm_read32(struct b43legacy_wldev *dev,
  81. u16 routing, u16 offset);
  82. u16 b43legacy_shm_read16(struct b43legacy_wldev *dev,
  83. u16 routing, u16 offset);
  84. void b43legacy_shm_write32(struct b43legacy_wldev *dev,
  85. u16 routing, u16 offset,
  86. u32 value);
  87. void b43legacy_shm_write16(struct b43legacy_wldev *dev,
  88. u16 routing, u16 offset,
  89. u16 value);
  90. u32 b43legacy_hf_read(struct b43legacy_wldev *dev);
  91. void b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value);
  92. void b43legacy_dummy_transmission(struct b43legacy_wldev *dev);
  93. void b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags);
  94. void b43legacy_mac_suspend(struct b43legacy_wldev *dev);
  95. void b43legacy_mac_enable(struct b43legacy_wldev *dev);
  96. void b43legacy_controller_restart(struct b43legacy_wldev *dev,
  97. const char *reason);
  98. #endif /* B43legacy_MAIN_H_ */