rfkill.c 2.0 KB

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