Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / net / wireless / broadcom / b43legacy / main.h
blob85edbc8c121a1b2fcfbaf3cc50c7b3e5afe02d6d
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
4 Broadcom B43legacy wireless driver
6 Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
7 Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
8 Copyright (c) 2005, 2006 Michael Buesch <m@bues.ch>
9 Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
10 Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
11 Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net>
13 Some parts of the code in this file are derived from the ipw2200
14 driver Copyright(c) 2003 - 2004 Intel Corporation.
19 #ifndef B43legacy_MAIN_H_
20 #define B43legacy_MAIN_H_
22 #include "b43legacy.h"
25 #define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes]
26 #define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes)
27 /* Magic helper macro to pad structures. Ignore those above. It's magic. */
28 #define PAD_BYTES(nr_bytes) P4D_BYTES(__LINE__ , (nr_bytes))
31 /* Lightweight function to convert a frequency (in Mhz) to a channel number. */
32 static inline
33 u8 b43legacy_freq_to_channel_bg(int freq)
35 u8 channel;
37 if (freq == 2484)
38 channel = 14;
39 else
40 channel = (freq - 2407) / 5;
42 return channel;
44 static inline
45 u8 b43legacy_freq_to_channel(struct b43legacy_wldev *dev,
46 int freq)
48 return b43legacy_freq_to_channel_bg(freq);
51 /* Lightweight function to convert a channel number to a frequency (in Mhz). */
52 static inline
53 int b43legacy_channel_to_freq_bg(u8 channel)
55 int freq;
57 if (channel == 14)
58 freq = 2484;
59 else
60 freq = 2407 + (5 * channel);
62 return freq;
65 static inline
66 int b43legacy_channel_to_freq(struct b43legacy_wldev *dev,
67 u8 channel)
69 return b43legacy_channel_to_freq_bg(channel);
72 static inline
73 int b43legacy_is_cck_rate(int rate)
75 return (rate == B43legacy_CCK_RATE_1MB ||
76 rate == B43legacy_CCK_RATE_2MB ||
77 rate == B43legacy_CCK_RATE_5MB ||
78 rate == B43legacy_CCK_RATE_11MB);
81 static inline
82 int b43legacy_is_ofdm_rate(int rate)
84 return !b43legacy_is_cck_rate(rate);
87 void b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf);
88 void b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf);
90 u32 b43legacy_shm_read32(struct b43legacy_wldev *dev,
91 u16 routing, u16 offset);
92 u16 b43legacy_shm_read16(struct b43legacy_wldev *dev,
93 u16 routing, u16 offset);
94 void b43legacy_shm_write32(struct b43legacy_wldev *dev,
95 u16 routing, u16 offset,
96 u32 value);
97 void b43legacy_shm_write16(struct b43legacy_wldev *dev,
98 u16 routing, u16 offset,
99 u16 value);
101 u32 b43legacy_hf_read(struct b43legacy_wldev *dev);
102 void b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value);
104 void b43legacy_dummy_transmission(struct b43legacy_wldev *dev);
106 void b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags);
108 void b43legacy_mac_suspend(struct b43legacy_wldev *dev);
109 void b43legacy_mac_enable(struct b43legacy_wldev *dev);
111 void b43legacy_controller_restart(struct b43legacy_wldev *dev,
112 const char *reason);
114 #endif /* B43legacy_MAIN_H_ */