0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include "radio.h"
0013 #include "b43legacy.h"
0014
0015
0016
0017 bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
0018 {
0019 if (dev->dev->id.revision >= 3) {
0020 if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI)
0021 & B43legacy_MMIO_RADIO_HWENABLED_HI_MASK))
0022 return true;
0023 } else {
0024
0025
0026
0027
0028
0029 if (b43legacy_status(dev) < B43legacy_STAT_STARTED)
0030 return true;
0031 if (b43legacy_read16(dev, B43legacy_MMIO_RADIO_HWENABLED_LO)
0032 & B43legacy_MMIO_RADIO_HWENABLED_LO_MASK)
0033 return true;
0034 }
0035 return false;
0036 }
0037
0038
0039 void b43legacy_rfkill_poll(struct ieee80211_hw *hw)
0040 {
0041 struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
0042 struct b43legacy_wldev *dev = wl->current_dev;
0043 struct ssb_bus *bus = dev->dev->bus;
0044 bool enabled;
0045 bool brought_up = false;
0046
0047 mutex_lock(&wl->mutex);
0048 if (unlikely(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED)) {
0049 if (ssb_bus_powerup(bus, 0)) {
0050 mutex_unlock(&wl->mutex);
0051 return;
0052 }
0053 ssb_device_enable(dev->dev, 0);
0054 brought_up = true;
0055 }
0056
0057 enabled = b43legacy_is_hw_radio_enabled(dev);
0058
0059 if (unlikely(enabled != dev->radio_hw_enable)) {
0060 dev->radio_hw_enable = enabled;
0061 b43legacyinfo(wl, "Radio hardware status changed to %s\n",
0062 enabled ? "ENABLED" : "DISABLED");
0063 wiphy_rfkill_set_hw_state(hw->wiphy, !enabled);
0064 if (enabled != dev->phy.radio_on) {
0065 if (enabled)
0066 b43legacy_radio_turn_on(dev);
0067 else
0068 b43legacy_radio_turn_off(dev, 0);
0069 }
0070 }
0071
0072 if (brought_up) {
0073 ssb_device_disable(dev->dev, 0);
0074 ssb_bus_may_powerdown(bus);
0075 }
0076
0077 mutex_unlock(&wl->mutex);
0078 }