Skip to content

Commit 436e59e

Browse files
committed
brcmfmac: add support for WL_REG_ON regulator
This allows the wifi chipset to boot up. Unfortunately, with BCM4334 over SDIO at least, we have to enable the regulator during module init in order to get the chipset to show up over SDIO. Signed-off-by: Simon Shields <simon@lineageos.org>
1 parent b3d38ab commit 436e59e

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

Documentation/devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Optional properties:
1919
to "host-wake".
2020
- clocks : external 32khz clock
2121
- clock-names : name of the external 32khz clock, must be "32khz"
22+
- wlan-supply : regulator to enable when registering SDIO driver
2223

2324
Example:
2425

drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <linux/errno.h>
3434
#include <linux/module.h>
3535
#include <linux/acpi.h>
36+
#include <linux/regulator/consumer.h>
37+
#include <linux/of.h>
3638
#include <net/cfg80211.h>
3739

3840
#include <defs.h>
@@ -1302,19 +1304,57 @@ static struct sdio_driver brcmf_sdmmc_driver = {
13021304
},
13031305
};
13041306

1307+
static void brcmf_sdio_regulator_set(int enable)
1308+
{
1309+
struct device fake_dev = {
1310+
.of_node = NULL,
1311+
};
1312+
struct regulator *reg;
1313+
1314+
struct device_node *dn =
1315+
of_find_compatible_node(NULL, NULL, "brcm,bcm4329-fmac");
1316+
1317+
if (!dn) {
1318+
/* not using device tree */
1319+
return;
1320+
}
1321+
1322+
fake_dev.of_node = dn;
1323+
reg = regulator_get(&fake_dev, "wlan");
1324+
1325+
if (IS_ERR_OR_NULL(reg))
1326+
return;
1327+
1328+
if (enable) {
1329+
if (regulator_enable(reg) < 0)
1330+
pr_err("%s: regulator enable failed\n", __func__);
1331+
} else {
1332+
regulator_disable(reg);
1333+
}
1334+
1335+
regulator_put(reg);
1336+
}
1337+
13051338
void brcmf_sdio_register(void)
13061339
{
13071340
int ret;
13081341

13091342
ret = sdio_register_driver(&brcmf_sdmmc_driver);
13101343
if (ret)
13111344
brcmf_err("sdio_register_driver failed: %d\n", ret);
1345+
1346+
/* we might need to power on the WL_EN regulator to
1347+
* get the SDIO device to show up
1348+
*/
1349+
brcmf_sdio_regulator_set(1);
13121350
}
13131351

13141352
void brcmf_sdio_exit(void)
13151353
{
13161354
brcmf_dbg(SDIO, "Enter\n");
13171355

1356+
brcmf_sdio_regulator_set(0);
1357+
13181358
sdio_unregister_driver(&brcmf_sdmmc_driver);
13191359
}
13201360

0 commit comments

Comments
 (0)