On a MacBookPro14,3 with a BCM43602 (14e4:43ba, subsystem 106b:0173), 5 GHz stops working once the chip has been reset to its power-on state, which happens over S3 while running on battery. Scans still report 5 GHz networks, but every attempt to join one fails: the firmware ends the join with a SET_SSID event with status BRCMF_E_STATUS_FAIL and no LINK event, which brcmfmac reports as WLAN_STATUS_AUTH_TIMEOUT, seen in wpa_supplicant as "CTRL-EVENT-ASSOC-REJECT ... status_code=16". A 2.4 GHz network could still be joined in that state. Reloading the driver, power cycling the slot or a secondary bus reset do not help; only a reboot of the machine does. On this board 5 GHz depends on bit 4 of the ChipCommon chipcontrol register, which Broadcom's sbchipc.h calls CCTRL4360_DISCRETE_FEMCTRL_MODE (front-end module control through the discrete FEM control pins). After a reboot the bit is set. brcmfmac never writes it and firmware 7.35.177.61 does not set it after a power-on reset, so presumably the platform firmware sets it at boot. The watchdog reset brcmfmac does on probe and remove preserves the bit, but a power-on reset clears it: power cycling the slot of a working system breaks 5 GHz the same way. Read with the driver unbound after the firmware has run, chipcontrol is 0x01400010 after a reboot and 0x01000000 after S3 on battery. Bit 22 is lost as well, but setting bit 4 alone before the firmware is downloaded is enough to make 5 GHz work again. Set the bit, if it is clear, before downloading the firmware on BCM43602 boards with Apple's subsystem vendor ID. When the firmware is lost over a resume, brcmfmac removes and probes the device again, so this covers S3 as well as a driver reload. This was only seen on a MacBookPro14,3; the check covers all Apple BCM43602 boards on the assumption that their platform firmware sets the bit the same way. Tested on a MacBookPro14,3 with firmware 7.35.177.61: after power cycling the slot and after S3 on battery the driver sets the bit and 5 GHz associates again; after a normal boot the bit is already set and nothing is written. Signed-off-by: Sergey Armodin --- .../broadcom/brcm80211/brcmfmac/pcie.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 17bae04c1..a97a597e7 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -726,9 +726,39 @@ static void brcmf_pcie_attach(struct brcmf_pciedev_info *devinfo) } +/* ChipCommon chipcontrol bit selecting the discrete FEM control pin mode */ +#define BRCMF_CC_CHIPCTL_4360_DISCRETE_FEMCTRL_MODE BIT(4) + +/* On a MacBookPro14,3 with a BCM43602, 5 GHz only works with the discrete + * FEM control pin mode selected in the ChipCommon chipcontrol register. The + * bit is set after a reboot, but a power-on reset of the chip (e.g. over S3 + * on battery) clears it and the firmware does not set it again. Other Apple + * BCM43602 boards are assumed to be set up the same way. Restore the bit + * before the firmware is started. + */ +static void brcmf_pcie_43602_apple_femctrl(struct brcmf_pciedev_info *devinfo) +{ + u32 val; + + if (devinfo->pdev->subsystem_vendor != PCI_VENDOR_ID_APPLE) + return; + + brcmf_pcie_select_core(devinfo, BCMA_CORE_CHIPCOMMON); + val = READCC32(devinfo, chipcontrol); + if (val & BRCMF_CC_CHIPCTL_4360_DISCRETE_FEMCTRL_MODE) + return; + + brcmf_dbg(PCIE, "chipcontrol 0x%08x, setting discrete FEM control mode\n", + val); + WRITECC32(devinfo, chipcontrol, + val | BRCMF_CC_CHIPCTL_4360_DISCRETE_FEMCTRL_MODE); +} + static int brcmf_pcie_enter_download_state(struct brcmf_pciedev_info *devinfo) { if (devinfo->ci->chip == BRCM_CC_43602_CHIP_ID) { + brcmf_pcie_43602_apple_femctrl(devinfo); + brcmf_pcie_select_core(devinfo, BCMA_CORE_ARM_CR4); brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_ARMCR4REG_BANKIDX, 5); -- 2.55.0