Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fourkbomb committed Nov 4, 2017
1 parent b3d38ab commit 436e59e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
Expand Up @@ -19,6 +19,7 @@ Optional properties:
to "host-wake".
- clocks : external 32khz clock
- clock-names : name of the external 32khz clock, must be "32khz"
- wlan-supply : regulator to enable when registering SDIO driver

Example:

Expand Down
40 changes: 40 additions & 0 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
Expand Up @@ -33,6 +33,8 @@
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/acpi.h>
#include <linux/regulator/consumer.h>
#include <linux/of.h>
#include <net/cfg80211.h>

#include <defs.h>
Expand Down Expand Up @@ -1302,19 +1304,57 @@ static struct sdio_driver brcmf_sdmmc_driver = {
},
};

static void brcmf_sdio_regulator_set(int enable)
{
struct device fake_dev = {
.of_node = NULL,
};
struct regulator *reg;

struct device_node *dn =
of_find_compatible_node(NULL, NULL, "brcm,bcm4329-fmac");

if (!dn) {
/* not using device tree */
return;
}

fake_dev.of_node = dn;
reg = regulator_get(&fake_dev, "wlan");

if (IS_ERR_OR_NULL(reg))
return;

if (enable) {
if (regulator_enable(reg) < 0)
pr_err("%s: regulator enable failed\n", __func__);
} else {
regulator_disable(reg);
}

regulator_put(reg);
}

void brcmf_sdio_register(void)
{
int ret;

ret = sdio_register_driver(&brcmf_sdmmc_driver);
if (ret)
brcmf_err("sdio_register_driver failed: %d\n", ret);

/* we might need to power on the WL_EN regulator to
* get the SDIO device to show up
*/
brcmf_sdio_regulator_set(1);
}

void brcmf_sdio_exit(void)
{
brcmf_dbg(SDIO, "Enter\n");

brcmf_sdio_regulator_set(0);

sdio_unregister_driver(&brcmf_sdmmc_driver);
}

0 comments on commit 436e59e

Please sign in to comment.