18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci Broadcom B43legacy wireless driver 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>, 78c2ecf20Sopenharmony_ci Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it> 88c2ecf20Sopenharmony_ci Copyright (c) 2005, 2006 Michael Buesch <m@bues.ch> 98c2ecf20Sopenharmony_ci Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org> 108c2ecf20Sopenharmony_ci Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch> 118c2ecf20Sopenharmony_ci Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci Some parts of the code in this file are derived from the ipw2200 148c2ecf20Sopenharmony_ci driver Copyright(c) 2003 - 2004 Intel Corporation. 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci*/ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#ifndef B43legacy_MAIN_H_ 208c2ecf20Sopenharmony_ci#define B43legacy_MAIN_H_ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci#include "b43legacy.h" 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define P4D_BYT3S(magic, nr_bytes) u8 __p4dding##magic[nr_bytes] 268c2ecf20Sopenharmony_ci#define P4D_BYTES(line, nr_bytes) P4D_BYT3S(line, nr_bytes) 278c2ecf20Sopenharmony_ci/* Magic helper macro to pad structures. Ignore those above. It's magic. */ 288c2ecf20Sopenharmony_ci#define PAD_BYTES(nr_bytes) P4D_BYTES(__LINE__ , (nr_bytes)) 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* Lightweight function to convert a frequency (in Mhz) to a channel number. */ 328c2ecf20Sopenharmony_cistatic inline 338c2ecf20Sopenharmony_ciu8 b43legacy_freq_to_channel_bg(int freq) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci u8 channel; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci if (freq == 2484) 388c2ecf20Sopenharmony_ci channel = 14; 398c2ecf20Sopenharmony_ci else 408c2ecf20Sopenharmony_ci channel = (freq - 2407) / 5; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci return channel; 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_cistatic inline 458c2ecf20Sopenharmony_ciu8 b43legacy_freq_to_channel(struct b43legacy_wldev *dev, 468c2ecf20Sopenharmony_ci int freq) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci return b43legacy_freq_to_channel_bg(freq); 498c2ecf20Sopenharmony_ci} 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci/* Lightweight function to convert a channel number to a frequency (in Mhz). */ 528c2ecf20Sopenharmony_cistatic inline 538c2ecf20Sopenharmony_ciint b43legacy_channel_to_freq_bg(u8 channel) 548c2ecf20Sopenharmony_ci{ 558c2ecf20Sopenharmony_ci int freq; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci if (channel == 14) 588c2ecf20Sopenharmony_ci freq = 2484; 598c2ecf20Sopenharmony_ci else 608c2ecf20Sopenharmony_ci freq = 2407 + (5 * channel); 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci return freq; 638c2ecf20Sopenharmony_ci} 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_cistatic inline 668c2ecf20Sopenharmony_ciint b43legacy_channel_to_freq(struct b43legacy_wldev *dev, 678c2ecf20Sopenharmony_ci u8 channel) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci return b43legacy_channel_to_freq_bg(channel); 708c2ecf20Sopenharmony_ci} 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistatic inline 738c2ecf20Sopenharmony_ciint b43legacy_is_cck_rate(int rate) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci return (rate == B43legacy_CCK_RATE_1MB || 768c2ecf20Sopenharmony_ci rate == B43legacy_CCK_RATE_2MB || 778c2ecf20Sopenharmony_ci rate == B43legacy_CCK_RATE_5MB || 788c2ecf20Sopenharmony_ci rate == B43legacy_CCK_RATE_11MB); 798c2ecf20Sopenharmony_ci} 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_cistatic inline 828c2ecf20Sopenharmony_ciint b43legacy_is_ofdm_rate(int rate) 838c2ecf20Sopenharmony_ci{ 848c2ecf20Sopenharmony_ci return !b43legacy_is_cck_rate(rate); 858c2ecf20Sopenharmony_ci} 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_civoid b43legacy_tsf_read(struct b43legacy_wldev *dev, u64 *tsf); 888c2ecf20Sopenharmony_civoid b43legacy_tsf_write(struct b43legacy_wldev *dev, u64 tsf); 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ciu32 b43legacy_shm_read32(struct b43legacy_wldev *dev, 918c2ecf20Sopenharmony_ci u16 routing, u16 offset); 928c2ecf20Sopenharmony_ciu16 b43legacy_shm_read16(struct b43legacy_wldev *dev, 938c2ecf20Sopenharmony_ci u16 routing, u16 offset); 948c2ecf20Sopenharmony_civoid b43legacy_shm_write32(struct b43legacy_wldev *dev, 958c2ecf20Sopenharmony_ci u16 routing, u16 offset, 968c2ecf20Sopenharmony_ci u32 value); 978c2ecf20Sopenharmony_civoid b43legacy_shm_write16(struct b43legacy_wldev *dev, 988c2ecf20Sopenharmony_ci u16 routing, u16 offset, 998c2ecf20Sopenharmony_ci u16 value); 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ciu32 b43legacy_hf_read(struct b43legacy_wldev *dev); 1028c2ecf20Sopenharmony_civoid b43legacy_hf_write(struct b43legacy_wldev *dev, u32 value); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_civoid b43legacy_dummy_transmission(struct b43legacy_wldev *dev); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_civoid b43legacy_wireless_core_reset(struct b43legacy_wldev *dev, u32 flags); 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_civoid b43legacy_mac_suspend(struct b43legacy_wldev *dev); 1098c2ecf20Sopenharmony_civoid b43legacy_mac_enable(struct b43legacy_wldev *dev); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_civoid b43legacy_controller_restart(struct b43legacy_wldev *dev, 1128c2ecf20Sopenharmony_ci const char *reason); 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#endif /* B43legacy_MAIN_H_ */ 115