dbfb1585ec9c387eca4602bcd74b1ee3a51e4c1e
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 860-brcmfmac-use-bcm47xx-platform-NVRAM-as-fallback.patch
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
4 MIME-Version: 1.0
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
7
8 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
9 ---
10
11 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
12 +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
13 @@ -19,6 +19,9 @@
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>
19 +#endif
20
21 #include "debug.h"
22 #include "firmware.h"
23 @@ -424,17 +427,42 @@ struct brcmf_fw {
24 static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
25 {
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;
30 +#endif
31 + const u8 *data = NULL;
32 + size_t data_len;
33 u32 nvram_length = 0;
34 void *nvram = NULL;
35
36 brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(fwctx->dev));
37 - if (!fw && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
38 + if (fw) {
39 + data = fw->data;
40 + data_len = fw->size;
41 + }
42 +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
43 + else {
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);
49 + }
50 + }
51 +#endif
52 + if (!data && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
53 goto fail;
54
55 - if (fw) {
56 - nvram = brcmf_fw_nvram_strip(fw->data, fw->size, &nvram_length,
57 + if (data) {
58 + nvram = brcmf_fw_nvram_strip(data, data_len, &nvram_length,
59 fwctx->domain_nr, fwctx->bus_nr);
60 - release_firmware(fw);
61 + if (fw)
62 + release_firmware(fw);
63 +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
64 + if (bcm47xx_nvram)
65 + bcm47xx_nvram_release_contents(bcm47xx_nvram);
66 +#endif
67 if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
68 goto fail;
69 }
70 --- a/drivers/net/wireless/brcm80211/brcmfmac/debug.h
71 +++ b/drivers/net/wireless/brcm80211/brcmfmac/debug.h
72 @@ -17,6 +17,8 @@
73 #ifndef BRCMFMAC_DEBUG_H
74 #define BRCMFMAC_DEBUG_H
75
76 +#include <linux/net.h>
77 +
78 /* message levels */
79 #define BRCMF_TRACE_VAL 0x00000002
80 #define BRCMF_INFO_VAL 0x00000004