Skip to content

Commit b3d38ab

Browse files
committed
brcmfmac: add support for external 32khz clock
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>
1 parent 4ebe35e commit b3d38ab

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Optional properties:
1717
When not specified the device will use in-band SDIO interrupts.
1818
- interrupt-names : name of the out-of-band interrupt, which must be set
1919
to "host-wake".
20+
- clocks : external 32khz clock
21+
- clock-names : name of the external 32khz clock, must be "32khz"
2022

2123
Example:
2224

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern struct brcmf_mp_global_t brcmf_mp_global;
5151
* @roamoff: Firmware roaming off?
5252
* @ignore_probe_fail: Ignore probe failure.
5353
* @country_codes: If available, pointer to struct for translating country codes
54+
* @clk: External 32khz clock, if present.
5455
* @bus: Bus specific platform data. Only SDIO at the mmoment.
5556
*/
5657
struct brcmf_mp_device {
@@ -60,6 +61,7 @@ struct brcmf_mp_device {
6061
bool roamoff;
6162
bool ignore_probe_fail;
6263
struct brcmfmac_pd_cc *country_codes;
64+
struct clk *clk;
6365
union {
6466
struct brcmfmac_sdio_pd sdio;
6567
} bus;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
1414
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*/
16+
#include <linux/clk.h>
1617
#include <linux/init.h>
1718
#include <linux/of.h>
1819
#include <linux/of_irq.h>
@@ -39,6 +40,10 @@ void brcmf_of_probe(struct device *dev, enum brcmf_bus_type bus_type,
3940
if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
4041
sdio->drive_strength = val;
4142

43+
settings->clk = devm_clk_get(dev, "32khz");
44+
if (IS_ERR(settings->clk))
45+
settings->clk = NULL;
46+
4247
/* make sure there are interrupts defined in the node */
4348
if (!of_find_property(np, "interrupts", NULL))
4449
return;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*/
1616

17+
#include <linux/clk.h>
1718
#include <linux/types.h>
1819
#include <linux/atomic.h>
1920
#include <linux/kernel.h>
@@ -3853,6 +3854,11 @@ brcmf_sdio_probe_attach(struct brcmf_sdio *bus)
38533854
brcmf_err("Failed to get device parameters\n");
38543855
goto fail;
38553856
}
3857+
3858+
/* enable external 32khz clock, if present */
3859+
if (sdiodev->settings->clk)
3860+
clk_prepare_enable(sdiodev->settings->clk);
3861+
38563862
/* platform specific configuration:
38573863
* alignments must be at least 4 bytes for ADMA
38583864
*/
@@ -4270,6 +4276,10 @@ void brcmf_sdio_remove(struct brcmf_sdio *bus)
42704276
}
42714277
brcmf_chip_detach(bus->ci);
42724278
}
4279+
4280+
if (bus->sdiodev->settings->clk)
4281+
clk_disable_unprepare(bus->sdiodev->settings->clk);
4282+
42734283
if (bus->sdiodev->settings)
42744284
brcmf_release_module_param(bus->sdiodev->settings);
42754285

0 commit comments

Comments
 (0)