firmware.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_REQF_OPTIONAL 0x0001
  19. #define BRCMF_FW_NAME_LEN 320
  20. #define BRCMF_FW_DEFAULT_PATH "brcm/"
  21. /**
  22. * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware
  23. * filename and nvram filename. Each bus type implementation should create
  24. * a table of firmware mappings (using the macros defined below).
  25. *
  26. * @chipid: ID of chip.
  27. * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3
  28. * @fw: name of the firmware file.
  29. * @nvram: name of nvram file.
  30. */
  31. struct brcmf_firmware_mapping {
  32. u32 chipid;
  33. u32 revmask;
  34. const char *fw_base;
  35. };
  36. #define BRCMF_FW_DEF(fw_name, fw_base) \
  37. static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
  38. BRCMF_FW_DEFAULT_PATH fw_base; \
  39. MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin")
  40. #define BRCMF_FW_ENTRY(chipid, mask, name) \
  41. { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
  42. void brcmf_fw_nvram_free(void *nvram);
  43. enum brcmf_fw_type {
  44. BRCMF_FW_TYPE_BINARY,
  45. BRCMF_FW_TYPE_NVRAM
  46. };
  47. struct brcmf_fw_item {
  48. const char *path;
  49. enum brcmf_fw_type type;
  50. u16 flags;
  51. union {
  52. const struct firmware *binary;
  53. struct {
  54. void *data;
  55. u32 len;
  56. } nv_data;
  57. };
  58. };
  59. struct brcmf_fw_request {
  60. u16 domain_nr;
  61. u16 bus_nr;
  62. u32 n_items;
  63. struct brcmf_fw_item items[0];
  64. };
  65. struct brcmf_fw_name {
  66. const char *extension;
  67. char *path;
  68. };
  69. struct brcmf_fw_request *
  70. brcmf_fw_alloc_request(u32 chip, u32 chiprev,
  71. const struct brcmf_firmware_mapping mapping_table[],
  72. u32 table_size, struct brcmf_fw_name *fwnames,
  73. u32 n_fwnames);
  74. /*
  75. * Request firmware(s) asynchronously. When the asynchronous request
  76. * fails it will not use the callback, but call device_release_driver()
  77. * instead which will call the driver .remove() callback.
  78. */
  79. int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
  80. void (*fw_cb)(struct device *dev, int err,
  81. struct brcmf_fw_request *req));
  82. #endif /* BRCMFMAC_FIRMWARE_H */