bcm43xx_main.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. Broadcom BCM43xx wireless driver
  3. Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
  4. Stefano Brivio <st3@riseup.net>
  5. Michael Buesch <mbuesch@freenet.de>
  6. Danny van Dyk <kugelfang@gentoo.org>
  7. Andreas Jaggi <andreas.jaggi@waterwave.ch>
  8. Some parts of the code in this file are derived from the ipw2200
  9. driver Copyright(c) 2003 - 2004 Intel Corporation.
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14. This program is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU General Public License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with this program; see the file COPYING. If not, write to
  20. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  21. Boston, MA 02110-1301, USA.
  22. */
  23. #ifndef BCM43xx_MAIN_H_
  24. #define BCM43xx_MAIN_H_
  25. #include "bcm43xx.h"
  26. #define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes]
  27. #define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes)
  28. /* Magic helper macro to pad structures. Ignore those above. It's magic. */
  29. #define PAD_BYTES(nr_bytes) P4D_BYTES( __LINE__ , (nr_bytes))
  30. /* Lightweight function to convert a frequency (in Mhz) to a channel number. */
  31. static inline
  32. u8 bcm43xx_freq_to_channel_a(int freq)
  33. {
  34. return ((freq - 5000) / 5);
  35. }
  36. static inline
  37. u8 bcm43xx_freq_to_channel_bg(int freq)
  38. {
  39. u8 channel;
  40. if (freq == 2484)
  41. channel = 14;
  42. else
  43. channel = (freq - 2407) / 5;
  44. return channel;
  45. }
  46. static inline
  47. u8 bcm43xx_freq_to_channel(struct bcm43xx_private *bcm,
  48. int freq)
  49. {
  50. if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
  51. return bcm43xx_freq_to_channel_a(freq);
  52. return bcm43xx_freq_to_channel_bg(freq);
  53. }
  54. /* Lightweight function to convert a channel number to a frequency (in Mhz). */
  55. static inline
  56. int bcm43xx_channel_to_freq_a(u8 channel)
  57. {
  58. return (5000 + (5 * channel));
  59. }
  60. static inline
  61. int bcm43xx_channel_to_freq_bg(u8 channel)
  62. {
  63. int freq;
  64. if (channel == 14)
  65. freq = 2484;
  66. else
  67. freq = 2407 + (5 * channel);
  68. return freq;
  69. }
  70. static inline
  71. int bcm43xx_channel_to_freq(struct bcm43xx_private *bcm,
  72. u8 channel)
  73. {
  74. if (bcm43xx_current_phy(bcm)->type == BCM43xx_PHYTYPE_A)
  75. return bcm43xx_channel_to_freq_a(channel);
  76. return bcm43xx_channel_to_freq_bg(channel);
  77. }
  78. void bcm43xx_tsf_read(struct bcm43xx_private *bcm, u64 *tsf);
  79. void bcm43xx_tsf_write(struct bcm43xx_private *bcm, u64 tsf);
  80. void bcm43xx_set_iwmode(struct bcm43xx_private *bcm,
  81. int iw_mode);
  82. u32 bcm43xx_shm_read32(struct bcm43xx_private *bcm,
  83. u16 routing, u16 offset);
  84. u16 bcm43xx_shm_read16(struct bcm43xx_private *bcm,
  85. u16 routing, u16 offset);
  86. void bcm43xx_shm_write32(struct bcm43xx_private *bcm,
  87. u16 routing, u16 offset,
  88. u32 value);
  89. void bcm43xx_shm_write16(struct bcm43xx_private *bcm,
  90. u16 routing, u16 offset,
  91. u16 value);
  92. void bcm43xx_dummy_transmission(struct bcm43xx_private *bcm);
  93. int bcm43xx_switch_core(struct bcm43xx_private *bcm, struct bcm43xx_coreinfo *new_core);
  94. int bcm43xx_select_wireless_core(struct bcm43xx_private *bcm,
  95. int phytype);
  96. void bcm43xx_wireless_core_reset(struct bcm43xx_private *bcm, int connect_phy);
  97. void bcm43xx_mac_suspend(struct bcm43xx_private *bcm);
  98. void bcm43xx_mac_enable(struct bcm43xx_private *bcm);
  99. void bcm43xx_periodic_tasks_delete(struct bcm43xx_private *bcm);
  100. void bcm43xx_periodic_tasks_setup(struct bcm43xx_private *bcm);
  101. void bcm43xx_controller_restart(struct bcm43xx_private *bcm, const char *reason);
  102. int bcm43xx_sprom_read(struct bcm43xx_private *bcm, u16 *sprom);
  103. int bcm43xx_sprom_write(struct bcm43xx_private *bcm, const u16 *sprom);
  104. #endif /* BCM43xx_MAIN_H_ */