main.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. Broadcom B43legacy wireless driver
  4. Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
  5. Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
  6. Copyright (c) 2005, 2006 Michael Buesch <m@bues.ch>
  7. Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
  8. Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
  9. Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net>
  10. Some parts of the code in this file are derived from the ipw2200
  11. driver Copyright(c) 2003 - 2004 Intel Corporation.
  12. */
  13. #ifndef B43legacy_MAIN_H_
  14. #define B43legacy_MAIN_H_
  15. #include "b43legacy.h"
  16. #define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes]
  17. #define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes)
  18. /* Magic helper macro to pad structures. Ignore those above. It's magic. */
  19. #define PAD_BYTES(nr_bytes) P4D_BYTES(__LINE__ , (nr_bytes))
  20. /* Lightweight function to convert a frequency (in Mhz) to a channel number. */
  21. static inline
  22. u8 b43legacy_freq_to_channel_bg(int freq)
  23. {
  24. u8 channel;
  25. if (freq == 2484)
  26. channel = 14;
  27. else
  28. channel = (freq - 2407) / 5;
  29. return channel;
  30. }
  31. static inline
  32. u8 b43legacy_freq_to_channel(struct b43legacy_wldev *dev,
  33. int freq)
  34. {
  35. return b43legacy_freq_to_channel_bg(freq);
  36. }
  37. /* Lightweight function to convert a channel number to a frequency (in Mhz). */
  38. static inline
  39. int b43legacy_channel_to_freq_bg(u8 channel)
  40. {
  41. int freq;
  42. if (channel == 14)
  43. freq = 2484;
  44. else
  45. freq = 2407 + (5 * channel);
  46. return freq;
  47. }
  48. static inline
  49. int b43legacy_channel_to_freq(struct b43legacy_wldev *dev,
  50. u8 channel)
  51. {
  52. return b43legacy_channel_to_freq_bg(channel);
  53. }
  54. static inline
  55. int b43legacy_is_cck_rate(int rate)
  56. {
  57. return (rate == B43legacy_CCK_RATE_1MB ||
  58. rate == B43legacy_CCK_RATE_2MB ||
  59. rate == B43legacy_CCK_RATE_5MB ||
  60. rate == B43legacy_CCK_RATE_11MB);
  61. }
  62. static inline
  63. int b43legacy_is_ofdm_rate(int rate)
  64. {
  65. return !b43legacy_is_cck_rate(rate);
  66. }
  67. void b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf);
  68. void b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf);
  69. u32 b43legacy_shm_read32(struct b43legacy_wldev *dev,
  70. u16 routing, u16 offset);
  71. u16 b43legacy_shm_read16(struct b43legacy_wldev *dev,
  72. u16 routing, u16 offset);
  73. void b43legacy_shm_write32(struct b43legacy_wldev *dev,
  74. u16 routing, u16 offset,
  75. u32 value);
  76. void b43legacy_shm_write16(struct b43legacy_wldev *dev,
  77. u16 routing, u16 offset,
  78. u16 value);
  79. u32 b43legacy_hf_read(struct b43legacy_wldev *dev);
  80. void b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value);
  81. void b43legacy_dummy_transmission(struct b43legacy_wldev *dev);
  82. void b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags);
  83. void b43legacy_mac_suspend(struct b43legacy_wldev *dev);
  84. void b43legacy_mac_enable(struct b43legacy_wldev *dev);
  85. void b43legacy_controller_restart(struct b43legacy_wldev *dev,
  86. const char *reason);
  87. #endif /* B43legacy_MAIN_H_ */