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