Loading...
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3
4 Broadcom B43legacy wireless driver
5
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>
12
13 Some parts of the code in this file are derived from the ipw2200
14 driver Copyright(c) 2003 - 2004 Intel Corporation.
15
16
17*/
18
19#ifndef B43legacy_MAIN_H_
20#define B43legacy_MAIN_H_
21
22#include "b43legacy.h"
23
24
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))
29
30
31/* Lightweight function to convert a frequency (in Mhz) to a channel number. */
32static inline
33u8 b43legacy_freq_to_channel_bg(int freq)
34{
35 u8 channel;
36
37 if (freq == 2484)
38 channel = 14;
39 else
40 channel = (freq - 2407) / 5;
41
42 return channel;
43}
44static inline
45u8 b43legacy_freq_to_channel(struct b43legacy_wldev *dev,
46 int freq)
47{
48 return b43legacy_freq_to_channel_bg(freq);
49}
50
51/* Lightweight function to convert a channel number to a frequency (in Mhz). */
52static inline
53int b43legacy_channel_to_freq_bg(u8 channel)
54{
55 int freq;
56
57 if (channel == 14)
58 freq = 2484;
59 else
60 freq = 2407 + (5 * channel);
61
62 return freq;
63}
64
65static inline
66int b43legacy_channel_to_freq(struct b43legacy_wldev *dev,
67 u8 channel)
68{
69 return b43legacy_channel_to_freq_bg(channel);
70}
71
72static inline
73int b43legacy_is_cck_rate(int rate)
74{
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);
79}
80
81static inline
82int b43legacy_is_ofdm_rate(int rate)
83{
84 return !b43legacy_is_cck_rate(rate);
85}
86
87void b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf);
88void b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf);
89
90u32 b43legacy_shm_read32(struct b43legacy_wldev *dev,
91 u16 routing, u16 offset);
92u16 b43legacy_shm_read16(struct b43legacy_wldev *dev,
93 u16 routing, u16 offset);
94void b43legacy_shm_write32(struct b43legacy_wldev *dev,
95 u16 routing, u16 offset,
96 u32 value);
97void b43legacy_shm_write16(struct b43legacy_wldev *dev,
98 u16 routing, u16 offset,
99 u16 value);
100
101u32 b43legacy_hf_read(struct b43legacy_wldev *dev);
102void b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value);
103
104void b43legacy_dummy_transmission(struct b43legacy_wldev *dev);
105
106void b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags);
107
108void b43legacy_mac_suspend(struct b43legacy_wldev *dev);
109void b43legacy_mac_enable(struct b43legacy_wldev *dev);
110
111void b43legacy_controller_restart(struct b43legacy_wldev *dev,
112 const char *reason);
113
114#endif /* B43legacy_MAIN_H_ */
1/*
2
3 Broadcom B43legacy wireless driver
4
5 Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6 Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
7 Copyright (c) 2005, 2006 Michael Buesch <m@bues.ch>
8 Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9 Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
10 Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net>
11
12 Some parts of the code in this file are derived from the ipw2200
13 driver Copyright(c) 2003 - 2004 Intel Corporation.
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
18 (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; see the file COPYING. If not, write to
27 the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
28 Boston, MA 02110-1301, USA.
29
30*/
31
32#ifndef B43legacy_MAIN_H_
33#define B43legacy_MAIN_H_
34
35#include "b43legacy.h"
36
37
38#define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes]
39#define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes)
40/* Magic helper macro to pad structures. Ignore those above. It's magic. */
41#define PAD_BYTES(nr_bytes) P4D_BYTES(__LINE__ , (nr_bytes))
42
43
44/* Lightweight function to convert a frequency (in Mhz) to a channel number. */
45static inline
46u8 b43legacy_freq_to_channel_bg(int freq)
47{
48 u8 channel;
49
50 if (freq == 2484)
51 channel = 14;
52 else
53 channel = (freq - 2407) / 5;
54
55 return channel;
56}
57static inline
58u8 b43legacy_freq_to_channel(struct b43legacy_wldev *dev,
59 int freq)
60{
61 return b43legacy_freq_to_channel_bg(freq);
62}
63
64/* Lightweight function to convert a channel number to a frequency (in Mhz). */
65static inline
66int b43legacy_channel_to_freq_bg(u8 channel)
67{
68 int freq;
69
70 if (channel == 14)
71 freq = 2484;
72 else
73 freq = 2407 + (5 * channel);
74
75 return freq;
76}
77
78static inline
79int b43legacy_channel_to_freq(struct b43legacy_wldev *dev,
80 u8 channel)
81{
82 return b43legacy_channel_to_freq_bg(channel);
83}
84
85static inline
86int b43legacy_is_cck_rate(int rate)
87{
88 return (rate == B43legacy_CCK_RATE_1MB ||
89 rate == B43legacy_CCK_RATE_2MB ||
90 rate == B43legacy_CCK_RATE_5MB ||
91 rate == B43legacy_CCK_RATE_11MB);
92}
93
94static inline
95int b43legacy_is_ofdm_rate(int rate)
96{
97 return !b43legacy_is_cck_rate(rate);
98}
99
100void b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf);
101void b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf);
102
103u32 b43legacy_shm_read32(struct b43legacy_wldev *dev,
104 u16 routing, u16 offset);
105u16 b43legacy_shm_read16(struct b43legacy_wldev *dev,
106 u16 routing, u16 offset);
107void b43legacy_shm_write32(struct b43legacy_wldev *dev,
108 u16 routing, u16 offset,
109 u32 value);
110void b43legacy_shm_write16(struct b43legacy_wldev *dev,
111 u16 routing, u16 offset,
112 u16 value);
113
114u32 b43legacy_hf_read(struct b43legacy_wldev *dev);
115void b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value);
116
117void b43legacy_dummy_transmission(struct b43legacy_wldev *dev);
118
119void b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags);
120
121void b43legacy_mac_suspend(struct b43legacy_wldev *dev);
122void b43legacy_mac_enable(struct b43legacy_wldev *dev);
123
124void b43legacy_controller_restart(struct b43legacy_wldev *dev,
125 const char *reason);
126
127#endif /* B43legacy_MAIN_H_ */