1e4d6b7951812d98417feb10784e400e253caf633Michael Buesch/*
2e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
3e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  Broadcom B43 wireless driver
4e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
5e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
61f21ad2a4f7f66855dae600ddd635ff5fb299bbdStefano Brivio                     Stefano Brivio <stefano.brivio@polimi.it>
7eb032b9837a958e21ca000358a5bde5e17192ddbMichael Buesch                     Michael Buesch <m@bues.ch>
8e4d6b7951812d98417feb10784e400e253caf633Michael Buesch                     Danny van Dyk <kugelfang@gentoo.org>
9e4d6b7951812d98417feb10784e400e253caf633Michael Buesch                     Andreas Jaggi <andreas.jaggi@waterwave.ch>
10e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
11e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  Some parts of the code in this file are derived from the ipw2200
12e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  driver  Copyright(c) 2003 - 2004 Intel Corporation.
13e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
14e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  This program is free software; you can redistribute it and/or modify
15e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  it under the terms of the GNU General Public License as published by
16e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  the Free Software Foundation; either version 2 of the License, or
17e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  (at your option) any later version.
18e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
19e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  This program is distributed in the hope that it will be useful,
20e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  but WITHOUT ANY WARRANTY; without even the implied warranty of
21e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  GNU General Public License for more details.
23e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
24e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  You should have received a copy of the GNU General Public License
25e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  along with this program; see the file COPYING.  If not, write to
26e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
27e4d6b7951812d98417feb10784e400e253caf633Michael Buesch  Boston, MA 02110-1301, USA.
28e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
29e4d6b7951812d98417feb10784e400e253caf633Michael Buesch*/
30e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
31e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#ifndef B43_MAIN_H_
32e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_MAIN_H_
33e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
34e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#include "b43.h"
35e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
36e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define P4D_BYT3S(magic, nr_bytes)	u8 __p4dding##magic[nr_bytes]
37e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define P4D_BYTES(line, nr_bytes)	P4D_BYT3S(line, nr_bytes)
38e4d6b7951812d98417feb10784e400e253caf633Michael Buesch/* Magic helper macro to pad structures. Ignore those above. It's magic. */
39e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define PAD_BYTES(nr_bytes)		P4D_BYTES( __LINE__ , (nr_bytes))
40e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
41e6f5b934fba8c44c87c551e066aa7ca6fde2939eMichael Buesch
42060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Bueschextern int b43_modparam_verbose;
43060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch
44060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch/* Logmessage verbosity levels. Update the b43_modparam_verbose helptext, if
45060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch * you add or remove levels. */
46060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Bueschenum b43_verbosity {
47060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_ERROR,
48060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_WARN,
49060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_INFO,
50060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_DEBUG,
51060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	__B43_VERBOSITY_AFTERLAST, /* keep last */
52060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch
53060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_MAX = __B43_VERBOSITY_AFTERLAST - 1,
54060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch#if B43_DEBUG
55060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_DEFAULT = B43_VERBOSITY_DEBUG,
56060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch#else
57060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch	B43_VERBOSITY_DEFAULT = B43_VERBOSITY_INFO,
58060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch#endif
59060210f938d8aa0b9d795588a2274cd67ba9d6a4Michael Buesch};
60e6f5b934fba8c44c87c551e066aa7ca6fde2939eMichael Buesch
61e6f5b934fba8c44c87c551e066aa7ca6fde2939eMichael Buesch
62e4d6b7951812d98417feb10784e400e253caf633Michael Buesch/* Lightweight function to convert a frequency (in Mhz) to a channel number. */
63d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline u8 b43_freq_to_channel_5ghz(int freq)
64e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
65e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return ((freq - 5000) / 5);
66e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
67d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline u8 b43_freq_to_channel_2ghz(int freq)
68e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
69e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	u8 channel;
70e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
71e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	if (freq == 2484)
72e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		channel = 14;
73e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	else
74e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		channel = (freq - 2407) / 5;
75e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
76e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return channel;
77e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
78e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
79e4d6b7951812d98417feb10784e400e253caf633Michael Buesch/* Lightweight function to convert a channel number to a frequency (in Mhz). */
80d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline int b43_channel_to_freq_5ghz(u8 channel)
81e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
82e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return (5000 + (5 * channel));
83e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
84d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline int b43_channel_to_freq_2ghz(u8 channel)
85e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
86e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	int freq;
87e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
88e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	if (channel == 14)
89e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		freq = 2484;
90e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	else
91e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		freq = 2407 + (5 * channel);
92e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
93e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return freq;
94e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
95e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
96e4d6b7951812d98417feb10784e400e253caf633Michael Bueschstatic inline int b43_is_cck_rate(int rate)
97e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
98e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return (rate == B43_CCK_RATE_1MB ||
99e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		rate == B43_CCK_RATE_2MB ||
100e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		rate == B43_CCK_RATE_5MB || rate == B43_CCK_RATE_11MB);
101e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
102e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
103e4d6b7951812d98417feb10784e400e253caf633Michael Bueschstatic inline int b43_is_ofdm_rate(int rate)
104e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
105e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return !b43_is_cck_rate(rate);
106e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
107e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
1089db1f6d725921c413cc344beda5e7e7d011b02e7Michael Bueschu8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
1099db1f6d725921c413cc344beda5e7e7d011b02e7Michael Buesch				  u8 antenna_nr);
1109db1f6d725921c413cc344beda5e7e7d011b02e7Michael Buesch
111e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_tsf_read(struct b43_wldev *dev, u64 * tsf);
112e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_tsf_write(struct b43_wldev *dev, u64 tsf);
113e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
114e4d6b7951812d98417feb10784e400e253caf633Michael Bueschu32 b43_shm_read32(struct b43_wldev *dev, u16 routing, u16 offset);
115e4d6b7951812d98417feb10784e400e253caf633Michael Bueschu16 b43_shm_read16(struct b43_wldev *dev, u16 routing, u16 offset);
116e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_shm_write32(struct b43_wldev *dev, u16 routing, u16 offset, u32 value);
117e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_shm_write16(struct b43_wldev *dev, u16 routing, u16 offset, u16 value);
118e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
11935f0d354bf0b0c125ac814419202f8c551081fdaMichael Bueschu64 b43_hf_read(struct b43_wldev *dev);
12035f0d354bf0b0c125ac814419202f8c551081fdaMichael Bueschvoid b43_hf_write(struct b43_wldev *dev, u64 value);
121e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
1222f19c287fecb958eb68b1c2199b4dd6e00ba4276Gábor Stefanikvoid b43_dummy_transmission(struct b43_wldev *dev, bool ofdm, bool pa_on);
123e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
1244da909e7b572b561d8150f9d41b04bcfff386222Rafał Miłeckivoid b43_wireless_core_reset(struct b43_wldev *dev, bool gmode);
125e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
126e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_controller_restart(struct b43_wldev *dev, const char *reason);
127e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
128e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_ENABLED	(1 << 0)	/* Force enable hardware power saving */
129e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_DISABLED	(1 << 1)	/* Force disable hardware power saving */
130e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_AWAKE	(1 << 2)	/* Force device awake */
131e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_ASLEEP	(1 << 3)	/* Force device asleep */
132e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags);
133e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
134f5eda47f45e90dfa38e25d569b9ac84ba94f8301Michael Bueschvoid b43_mac_suspend(struct b43_wldev *dev);
135f5eda47f45e90dfa38e25d569b9ac84ba94f8301Michael Bueschvoid b43_mac_enable(struct b43_wldev *dev);
136858a16529cb4c6434d863740283e0dfeb93cd599Rafał Miłeckivoid b43_mac_phy_clock_set(struct b43_wldev *dev, bool on);
137f5eda47f45e90dfa38e25d569b9ac84ba94f8301Michael Buesch
1381a9f509368ceb24fc66be961be15c69966f5eb5dMichael Buesch
1391a9f509368ceb24fc66be961be15c69966f5eb5dMichael Bueschstruct b43_request_fw_context;
1401a9f509368ceb24fc66be961be15c69966f5eb5dMichael Bueschint b43_do_request_fw(struct b43_request_fw_context *ctx,
1411a9f509368ceb24fc66be961be15c69966f5eb5dMichael Buesch		      const char *name,
1421a9f509368ceb24fc66be961be15c69966f5eb5dMichael Buesch		      struct b43_firmware_file *fw);
1431a9f509368ceb24fc66be961be15c69966f5eb5dMichael Bueschvoid b43_do_release_fw(struct b43_firmware_file *fw);
1441a9f509368ceb24fc66be961be15c69966f5eb5dMichael Buesch
145e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#endif /* B43_MAIN_H_ */
146