main.h revision 9db1f6d725921c413cc344beda5e7e7d011b02e7
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>
7e4d6b7951812d98417feb10784e400e253caf633Michael Buesch                     Michael Buesch <mb@bu3sch.de>
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
41e4d6b7951812d98417feb10784e400e253caf633Michael Buesch/* Lightweight function to convert a frequency (in Mhz) to a channel number. */
42d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline u8 b43_freq_to_channel_5ghz(int freq)
43e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
44e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return ((freq - 5000) / 5);
45e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
46d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline u8 b43_freq_to_channel_2ghz(int freq)
47e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
48e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	u8 channel;
49e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
50e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	if (freq == 2484)
51e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		channel = 14;
52e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	else
53e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		channel = (freq - 2407) / 5;
54e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
55e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return channel;
56e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
57e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
58e4d6b7951812d98417feb10784e400e253caf633Michael Buesch/* Lightweight function to convert a channel number to a frequency (in Mhz). */
59d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline int b43_channel_to_freq_5ghz(u8 channel)
60e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
61e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return (5000 + (5 * channel));
62e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
63d987160b710c98997015832422a05e18d9f0f925Michael Bueschstatic inline int b43_channel_to_freq_2ghz(u8 channel)
64e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
65e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	int freq;
66e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
67e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	if (channel == 14)
68e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		freq = 2484;
69e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	else
70e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		freq = 2407 + (5 * channel);
71e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
72e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return freq;
73e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
74e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
75e4d6b7951812d98417feb10784e400e253caf633Michael Bueschstatic inline int b43_is_cck_rate(int rate)
76e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
77e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return (rate == B43_CCK_RATE_1MB ||
78e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		rate == B43_CCK_RATE_2MB ||
79e4d6b7951812d98417feb10784e400e253caf633Michael Buesch		rate == B43_CCK_RATE_5MB || rate == B43_CCK_RATE_11MB);
80e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
81e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
82e4d6b7951812d98417feb10784e400e253caf633Michael Bueschstatic inline int b43_is_ofdm_rate(int rate)
83e4d6b7951812d98417feb10784e400e253caf633Michael Buesch{
84e4d6b7951812d98417feb10784e400e253caf633Michael Buesch	return !b43_is_cck_rate(rate);
85e4d6b7951812d98417feb10784e400e253caf633Michael Buesch}
86e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
879db1f6d725921c413cc344beda5e7e7d011b02e7Michael Bueschu8 b43_ieee80211_antenna_sanitize(struct b43_wldev *dev,
889db1f6d725921c413cc344beda5e7e7d011b02e7Michael Buesch				  u8 antenna_nr);
899db1f6d725921c413cc344beda5e7e7d011b02e7Michael Buesch
90e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_tsf_read(struct b43_wldev *dev, u64 * tsf);
91e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_tsf_write(struct b43_wldev *dev, u64 tsf);
92e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
93e4d6b7951812d98417feb10784e400e253caf633Michael Bueschu32 b43_shm_read32(struct b43_wldev *dev, u16 routing, u16 offset);
94e4d6b7951812d98417feb10784e400e253caf633Michael Bueschu16 b43_shm_read16(struct b43_wldev *dev, u16 routing, u16 offset);
95e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_shm_write32(struct b43_wldev *dev, u16 routing, u16 offset, u32 value);
96e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_shm_write16(struct b43_wldev *dev, u16 routing, u16 offset, u16 value);
97e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
98e4d6b7951812d98417feb10784e400e253caf633Michael Bueschu32 b43_hf_read(struct b43_wldev *dev);
99e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_hf_write(struct b43_wldev *dev, u32 value);
100e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
101e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_dummy_transmission(struct b43_wldev *dev);
102e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
103e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_wireless_core_reset(struct b43_wldev *dev, u32 flags);
104e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
105e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_mac_suspend(struct b43_wldev *dev);
106e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_mac_enable(struct b43_wldev *dev);
107e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
108e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_controller_restart(struct b43_wldev *dev, const char *reason);
109e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
110e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_ENABLED	(1 << 0)	/* Force enable hardware power saving */
111e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_DISABLED	(1 << 1)	/* Force disable hardware power saving */
112e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_AWAKE	(1 << 2)	/* Force device awake */
113e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#define B43_PS_ASLEEP	(1 << 3)	/* Force device asleep */
114e4d6b7951812d98417feb10784e400e253caf633Michael Bueschvoid b43_power_saving_ctl_bits(struct b43_wldev *dev, unsigned int ps_flags);
115e4d6b7951812d98417feb10784e400e253caf633Michael Buesch
116e4d6b7951812d98417feb10784e400e253caf633Michael Buesch#endif /* B43_MAIN_H_ */
117