WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / wireless / broadcom / b43 / rfkill.c
blobf0c9687036130e5fa9e7351ce3fe397a9636609e
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
4 Broadcom B43 wireless driver
5 RFKILL support
7 Copyright (c) 2007 Michael Buesch <m@bues.ch>
12 #include "b43.h"
15 /* Returns TRUE, if the radio is enabled in hardware. */
16 bool b43_is_hw_radio_enabled(struct b43_wldev *dev)
18 return !(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI)
19 & B43_MMIO_RADIO_HWENABLED_HI_MASK);
22 /* The poll callback for the hardware button. */
23 void b43_rfkill_poll(struct ieee80211_hw *hw)
25 struct b43_wl *wl = hw_to_b43_wl(hw);
26 struct b43_wldev *dev = wl->current_dev;
27 bool enabled;
28 bool brought_up = false;
30 mutex_lock(&wl->mutex);
31 if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) {
32 if (b43_bus_powerup(dev, 0)) {
33 mutex_unlock(&wl->mutex);
34 return;
36 b43_device_enable(dev, 0);
37 brought_up = true;
40 enabled = b43_is_hw_radio_enabled(dev);
42 if (unlikely(enabled != dev->radio_hw_enable)) {
43 dev->radio_hw_enable = enabled;
44 b43info(wl, "Radio hardware status changed to %s\n",
45 enabled ? "ENABLED" : "DISABLED");
46 wiphy_rfkill_set_hw_state(hw->wiphy, !enabled);
47 if (enabled != dev->phy.radio_on)
48 b43_software_rfkill(dev, !enabled);
51 if (brought_up) {
52 b43_device_disable(dev, 0);
53 b43_bus_may_powerdown(dev);
56 mutex_unlock(&wl->mutex);