1 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
2 Date: Mon, 8 Jun 2015 16:59:31 +0200
3 Subject: [PATCH] brcmfmac: use bcm47xx platform NVRAM as fallback
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
11 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
12 +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
14 #include <linux/device.h>
15 #include <linux/firmware.h>
16 #include <linux/module.h>
17 +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
18 +#include <linux/bcm47xx_nvram.h>
23 @@ -424,17 +427,42 @@ struct brcmf_fw {
24 static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
26 struct brcmf_fw *fwctx = ctx;
27 +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
28 + const u8 *bcm47xx_nvram = NULL;
29 + size_t bcm47xx_nvram_len;
31 + const u8 *data = NULL;
36 brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(fwctx->dev));
37 - if (!fw && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
40 + data_len = fw->size;
42 +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
44 + bcm47xx_nvram = bcm47xx_nvram_get_contents(&bcm47xx_nvram_len);
45 + if (bcm47xx_nvram) {
46 + data = bcm47xx_nvram;
47 + data_len = bcm47xx_nvram_len;
48 + brcmf_err("Found platform NVRAM (%zu B)\n", data_len);
52 + if (!data && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
56 - nvram = brcmf_fw_nvram_strip(fw->data, fw->size, &nvram_length,
58 + nvram = brcmf_fw_nvram_strip(data, data_len, &nvram_length,
59 fwctx->domain_nr, fwctx->bus_nr);
60 - release_firmware(fw);
62 + release_firmware(fw);
63 +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
65 + bcm47xx_nvram_release_contents(bcm47xx_nvram);
67 if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
70 --- a/drivers/net/wireless/brcm80211/brcmfmac/debug.h
71 +++ b/drivers/net/wireless/brcm80211/brcmfmac/debug.h
73 #ifndef BRCMFMAC_DEBUG_H
74 #define BRCMFMAC_DEBUG_H
76 +#include <linux/net.h>
79 #define BRCMF_TRACE_VAL 0x00000002
80 #define BRCMF_INFO_VAL 0x00000004