]>
Commit | Line | Data |
---|---|---|
8e9f7529 MB |
1 | /* |
2 | ||
3 | Broadcom B43 wireless driver | |
4 | RFKILL support | |
5 | ||
6 | Copyright (c) 2007 Michael Buesch <mb@bu3sch.de> | |
7 | ||
8 | This program is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2 of the License, or | |
11 | (at your option) any later version. | |
12 | ||
13 | This program is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with this program; see the file COPYING. If not, write to | |
20 | the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, | |
21 | Boston, MA 02110-1301, USA. | |
22 | ||
23 | */ | |
24 | ||
8e9f7529 | 25 | #include "b43.h" |
1a8d1227 | 26 | |
8e9f7529 | 27 | |
42bb4cd5 | 28 | /* Returns TRUE, if the radio is enabled in hardware. */ |
f41f3f37 | 29 | bool b43_is_hw_radio_enabled(struct b43_wldev *dev) |
8e9f7529 | 30 | { |
8ce46999 RM |
31 | return !(b43_read32(dev, B43_MMIO_RADIO_HWENABLED_HI) |
32 | & B43_MMIO_RADIO_HWENABLED_HI_MASK); | |
8e9f7529 MB |
33 | } |
34 | ||
42bb4cd5 | 35 | /* The poll callback for the hardware button. */ |
f41f3f37 | 36 | void b43_rfkill_poll(struct ieee80211_hw *hw) |
8e9f7529 | 37 | { |
f41f3f37 JB |
38 | struct b43_wl *wl = hw_to_b43_wl(hw); |
39 | struct b43_wldev *dev = wl->current_dev; | |
dedb1eb9 | 40 | struct ssb_bus *bus = dev->sdev->bus; |
42bb4cd5 | 41 | bool enabled; |
f41f3f37 | 42 | bool brought_up = false; |
8e9f7529 | 43 | |
42bb4cd5 | 44 | mutex_lock(&wl->mutex); |
1a8d1227 | 45 | if (unlikely(b43_status(dev) < B43_STAT_INITIALIZED)) { |
f41f3f37 JB |
46 | if (ssb_bus_powerup(bus, 0)) { |
47 | mutex_unlock(&wl->mutex); | |
48 | return; | |
49 | } | |
dedb1eb9 | 50 | ssb_device_enable(dev->sdev, 0); |
f41f3f37 | 51 | brought_up = true; |
1a8d1227 | 52 | } |
f41f3f37 | 53 | |
42bb4cd5 | 54 | enabled = b43_is_hw_radio_enabled(dev); |
f41f3f37 | 55 | |
42bb4cd5 MB |
56 | if (unlikely(enabled != dev->radio_hw_enable)) { |
57 | dev->radio_hw_enable = enabled; | |
58 | b43info(wl, "Radio hardware status changed to %s\n", | |
59 | enabled ? "ENABLED" : "DISABLED"); | |
f41f3f37 | 60 | wiphy_rfkill_set_hw_state(hw->wiphy, !enabled); |
19d337df JB |
61 | if (enabled != dev->phy.radio_on) |
62 | b43_software_rfkill(dev, !enabled); | |
35c7e660 | 63 | } |
8e9f7529 | 64 | |
f41f3f37 | 65 | if (brought_up) { |
dedb1eb9 | 66 | ssb_device_disable(dev->sdev, 0); |
f41f3f37 JB |
67 | ssb_bus_may_powerdown(bus); |
68 | } | |
19d337df | 69 | |
8e9f7529 | 70 | mutex_unlock(&wl->mutex); |
8e9f7529 | 71 | } |