Skip to content

Commit

Permalink
brcmfmac: add support for external 32khz clock
Browse files Browse the repository at this point in the history
Some boards use an external 32khz clock for low-power
mode timing. Make sure the clock is powered on while the chipset
is active.

Signed-off-by: Simon Shields <simon@lineageos.org>
  • Loading branch information
fourkbomb committed Nov 4, 2017
1 parent 4ebe35e commit b3d38ab
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
Expand Up @@ -17,6 +17,8 @@ Optional properties:
When not specified the device will use in-band SDIO interrupts.
- interrupt-names : name of the out-of-band interrupt, which must be set
to "host-wake".
- clocks : external 32khz clock
- clock-names : name of the external 32khz clock, must be "32khz"

Example:

Expand Down
2 changes: 2 additions & 0 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
Expand Up @@ -51,6 +51,7 @@ extern struct brcmf_mp_global_t brcmf_mp_global;
* @roamoff: Firmware roaming off?
* @ignore_probe_fail: Ignore probe failure.
* @country_codes: If available, pointer to struct for translating country codes
* @clk: External 32khz clock, if present.
* @bus: Bus specific platform data. Only SDIO at the mmoment.
*/
struct brcmf_mp_device {
Expand All @@ -60,6 +61,7 @@ struct brcmf_mp_device {
bool roamoff;
bool ignore_probe_fail;
struct brcmfmac_pd_cc *country_codes;
struct clk *clk;
union {
struct brcmfmac_sdio_pd sdio;
} bus;
Expand Down
5 changes: 5 additions & 0 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
Expand Up @@ -13,6 +13,7 @@
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <linux/clk.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_irq.h>
Expand All @@ -39,6 +40,10 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
sdio->drive_strength = val;

settings->clk = devm_clk_get(dev, "32khz");
if (IS_ERR(settings->clk))
settings->clk = NULL;

/* make sure there are interrupts defined in the node */
if (!of_find_property(np, "interrupts", NULL))
return;
Expand Down
10 changes: 10 additions & 0 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
Expand Up @@ -14,6 +14,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#include <linux/clk.h>
#include <linux/types.h>
#include <linux/atomic.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -3853,6 +3854,11 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
brcmf_err("Failed to get device parameters\n");
goto fail;
}

/* enable external 32khz clock, if present */
if (sdiodev->settings->clk)
clk_prepare_enable(sdiodev->settings->clk);

/* platform specific configuration:
* alignments must be at least 4 bytes for ADMA
*/
Expand Down Expand Up @@ -4270,6 +4276,10 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
}
brcmf_chip_detach(bus->ci);
}

if (bus->sdiodev->settings->clk)
clk_disable_unprepare(bus->sdiodev->settings->clk);

if (bus->sdiodev->settings)
brcmf_release_module_param(bus->sdiodev->settings);

Expand Down

0 comments on commit b3d38ab

Please sign in to comment.