860-brcmfmac-use-bcm47xx-platform-NVRAM-as-fallback.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <[email protected]>
  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. Signed-off-by: Rafał Miłecki <[email protected]>
  8. ---
  9. --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
  10. +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
  11. @@ -19,6 +19,9 @@
  12. #include <linux/device.h>
  13. #include <linux/firmware.h>
  14. #include <linux/module.h>
  15. +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
  16. +#include <linux/bcm47xx_nvram.h>
  17. +#endif
  18. #include "debug.h"
  19. #include "firmware.h"
  20. @@ -424,17 +427,42 @@ struct brcmf_fw {
  21. static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
  22. {
  23. struct brcmf_fw *fwctx = ctx;
  24. +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
  25. + const u8 *bcm47xx_nvram = NULL;
  26. + size_t bcm47xx_nvram_len;
  27. +#endif
  28. + const u8 *data = NULL;
  29. + size_t data_len;
  30. u32 nvram_length = 0;
  31. void *nvram = NULL;
  32. brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(fwctx->dev));
  33. - if (!fw && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
  34. + if (fw) {
  35. + data = fw->data;
  36. + data_len = fw->size;
  37. + }
  38. +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
  39. + else {
  40. + bcm47xx_nvram = bcm47xx_nvram_get_contents(&bcm47xx_nvram_len);
  41. + if (bcm47xx_nvram) {
  42. + data = bcm47xx_nvram;
  43. + data_len = bcm47xx_nvram_len;
  44. + brcmf_err("Found platform NVRAM (%zu B)\n", data_len);
  45. + }
  46. + }
  47. +#endif
  48. + if (!data && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
  49. goto fail;
  50. - if (fw) {
  51. - nvram = brcmf_fw_nvram_strip(fw->data, fw->size, &nvram_length,
  52. + if (data) {
  53. + nvram = brcmf_fw_nvram_strip(data, data_len, &nvram_length,
  54. fwctx->domain_nr, fwctx->bus_nr);
  55. - release_firmware(fw);
  56. + if (fw)
  57. + release_firmware(fw);
  58. +#if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
  59. + if (bcm47xx_nvram)
  60. + bcm47xx_nvram_release_contents(bcm47xx_nvram);
  61. +#endif
  62. if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
  63. goto fail;
  64. }
  65. --- a/drivers/net/wireless/brcm80211/brcmfmac/debug.h
  66. +++ b/drivers/net/wireless/brcm80211/brcmfmac/debug.h
  67. @@ -17,6 +17,8 @@
  68. #ifndef BRCMFMAC_DEBUG_H
  69. #define BRCMFMAC_DEBUG_H
  70. +#include <linux/net.h>
  71. +
  72. /* message levels */
  73. #define BRCMF_TRACE_VAL 0x00000002
  74. #define BRCMF_INFO_VAL 0x00000004