2 * Copyright (c) 2013 Broadcom Corporation
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.
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.
16 #ifndef BRCMFMAC_FIRMWARE_H
17 #define BRCMFMAC_FIRMWARE_H
19 #define BRCMF_FW_REQUEST 0x000F
20 #define BRCMF_FW_REQUEST_NVRAM 0x0001
21 #define BRCMF_FW_REQ_FLAGS 0x00F0
22 #define BRCMF_FW_REQ_NV_OPTIONAL 0x0010
24 #define BRCMF_FW_NAME_LEN 320
26 #define BRCMF_FW_DEFAULT_PATH /*(DEBLOBBED)*/
29 * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware
30 * filename and nvram filename. Each bus type implementation should create
31 * a table of firmware mappings (using the macros defined below).
33 * @chipid: ID of chip.
34 * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3
35 * @fw: name of the firmware file.
36 * @nvram: name of nvram file.
38 struct brcmf_firmware_mapping {
45 #define BRCMF_FW_NVRAM_DEF(fw_nvram_name, fw, nvram) \
46 static const char BRCM_ ## fw_nvram_name ## _FIRMWARE_NAME[] = \
47 BRCMF_FW_DEFAULT_PATH fw; \
48 static const char BRCM_ ## fw_nvram_name ## _NVRAM_NAME[] = \
49 BRCMF_FW_DEFAULT_PATH nvram/*(DEBLOBBED)*/;
51 #define BRCMF_FW_DEF(fw_name, fw) \
52 static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
53 BRCMF_FW_DEFAULT_PATH fw/*(DEBLOBBED)*/ \
55 #define BRCMF_FW_NVRAM_ENTRY(chipid, mask, name) \
57 BRCM_ ## name ## _FIRMWARE_NAME, BRCM_ ## name ## _NVRAM_NAME }
59 #define BRCMF_FW_ENTRY(chipid, mask, name) \
60 { chipid, mask, BRCM_ ## name ## _FIRMWARE_NAME, NULL }
62 int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
63 struct brcmf_firmware_mapping mapping_table[],
64 u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
65 char nvram_name[BRCMF_FW_NAME_LEN]);
66 void brcmf_fw_nvram_free(void *nvram);
68 * Request firmware(s) asynchronously. When the asynchronous request
69 * fails it will not use the callback, but call device_release_driver()
70 * instead which will call the driver .remove() callback.
72 int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
73 const char *code, const char *nvram,
74 void (*fw_cb)(struct device *dev, int err,
75 const struct firmware *fw,
76 void *nvram_image, u32 nvram_len),
77 u16 domain_nr, u16 bus_nr);
78 int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
79 const char *code, const char *nvram,
80 void (*fw_cb)(struct device *dev, int err,
81 const struct firmware *fw,
82 void *nvram_image, u32 nvram_len));
84 #endif /* BRCMFMAC_FIRMWARE_H */