1 // SPDX-License-Identifier: GPL-2.0-or-later
4 Broadcom B43 wireless driver
7 Copyright (c) 2007 Michael Buesch <m@bues.ch>
13 #include "b43legacy.h"
16 /* Returns TRUE, if the radio is enabled in hardware. */
17 bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev
*dev
)
19 if (dev
->dev
->id
.revision
>= 3) {
20 if (!(b43legacy_read32(dev
, B43legacy_MMIO_RADIO_HWENABLED_HI
)
21 & B43legacy_MMIO_RADIO_HWENABLED_HI_MASK
))
24 /* To prevent CPU fault on PPC, do not read a register
25 * unless the interface is started; however, on resume
26 * for hibernation, this routine is entered early. When
27 * that happens, unconditionally return TRUE.
29 if (b43legacy_status(dev
) < B43legacy_STAT_STARTED
)
31 if (b43legacy_read16(dev
, B43legacy_MMIO_RADIO_HWENABLED_LO
)
32 & B43legacy_MMIO_RADIO_HWENABLED_LO_MASK
)
38 /* The poll callback for the hardware button. */
39 void b43legacy_rfkill_poll(struct ieee80211_hw
*hw
)
41 struct b43legacy_wl
*wl
= hw_to_b43legacy_wl(hw
);
42 struct b43legacy_wldev
*dev
= wl
->current_dev
;
43 struct ssb_bus
*bus
= dev
->dev
->bus
;
45 bool brought_up
= false;
47 mutex_lock(&wl
->mutex
);
48 if (unlikely(b43legacy_status(dev
) < B43legacy_STAT_INITIALIZED
)) {
49 if (ssb_bus_powerup(bus
, 0)) {
50 mutex_unlock(&wl
->mutex
);
53 ssb_device_enable(dev
->dev
, 0);
57 enabled
= b43legacy_is_hw_radio_enabled(dev
);
59 if (unlikely(enabled
!= dev
->radio_hw_enable
)) {
60 dev
->radio_hw_enable
= enabled
;
61 b43legacyinfo(wl
, "Radio hardware status changed to %s\n",
62 enabled
? "ENABLED" : "DISABLED");
63 wiphy_rfkill_set_hw_state(hw
->wiphy
, !enabled
);
64 if (enabled
!= dev
->phy
.radio_on
) {
66 b43legacy_radio_turn_on(dev
);
68 b43legacy_radio_turn_off(dev
, 0);
73 ssb_device_disable(dev
->dev
, 0);
74 ssb_bus_may_powerdown(bus
);
77 mutex_unlock(&wl
->mutex
);