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