firmware.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2013 Broadcom Corporation
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  11. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  13. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  14. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef BRCMFMAC_FIRMWARE_H
  17. #define BRCMFMAC_FIRMWARE_H
  18. #define BRCMF_FW_REQUEST 0x000F
  19. #define BRCMF_FW_REQUEST_NVRAM 0x0001
  20. #define BRCMF_FW_REQ_FLAGS 0x00F0
  21. #define BRCMF_FW_REQ_NV_OPTIONAL 0x0010
  22. #define BRCMF_FW_NAME_LEN 320
  23. #define BRCMF_FW_DEFAULT_PATH "brcm/"
  24. /**
  25. * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware
  26. * filename and nvram filename. Each bus type implementation should create
  27. * a table of firmware mappings (using the macros defined below).
  28. *
  29. * @chipid: ID of chip.
  30. * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3
  31. * @fw: name of the firmware file.
  32. * @nvram: name of nvram file.
  33. */
  34. struct brcmf_firmware_mapping {
  35. u32 chipid;
  36. u32 revmask;
  37. const char *fw;
  38. const char *nvram;
  39. };
  40. #define BRCMF_FW_NVRAM_DEF(fw_nvram_name, fw, nvram) \
  41. static const char BRCM_ ## fw_nvram_name ## _FIRMWARE_NAME[] = \
  42. BRCMF_FW_DEFAULT_PATH fw; \
  43. static const char BRCM_ ## fw_nvram_name ## _NVRAM_NAME[] = \
  44. BRCMF_FW_DEFAULT_PATH nvram; \
  45. MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw);
  46. #define BRCMF_FW_DEF(fw_name, fw) \
  47. static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
  48. BRCMF_FW_DEFAULT_PATH fw; \
  49. MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw) \
  50. #define BRCMF_FW_NVRAM_ENTRY(chipid, mask, name) \
  51. { chipid, mask, \
  52. BRCM_ ## name ## _FIRMWARE_NAME, BRCM_ ## name ## _NVRAM_NAME }
  53. #define BRCMF_FW_ENTRY(chipid, mask, name) \
  54. { chipid, mask, BRCM_ ## name ## _FIRMWARE_NAME, NULL }
  55. int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
  56. struct brcmf_firmware_mapping mapping_table[],
  57. u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
  58. char nvram_name[BRCMF_FW_NAME_LEN]);
  59. void brcmf_fw_nvram_free(void *nvram);
  60. /*
  61. * Request firmware(s) asynchronously. When the asynchronous request
  62. * fails it will not use the callback, but call device_release_driver()
  63. * instead which will call the driver .remove() callback.
  64. */
  65. int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
  66. const char *code, const char *nvram,
  67. void (*fw_cb)(struct device *dev,
  68. const struct firmware *fw,
  69. void *nvram_image, u32 nvram_len),
  70. u16 domain_nr, u16 bus_nr);
  71. int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
  72. const char *code, const char *nvram,
  73. void (*fw_cb)(struct device *dev,
  74. const struct firmware *fw,
  75. void *nvram_image, u32 nvram_len));
  76. #endif /* BRCMFMAC_FIRMWARE_H */