GNU Linux-libre 4.19.245-gnu1
[releases.git] / drivers / net / wireless / broadcom / brcm80211 / brcmfmac / firmware.h
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
19 #define BRCMF_FW_REQF_OPTIONAL          0x0001
20
21 #define BRCMF_FW_NAME_LEN               320
22
23 #define BRCMF_FW_DEFAULT_PATH           /*(DEBLOBBED)*/
24
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).
29  *
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.
34  */
35 struct brcmf_firmware_mapping {
36         u32 chipid;
37         u32 revmask;
38         const char *fw_base;
39 };
40
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/*(DEBLOBBED)*/
44
45 #define BRCMF_FW_ENTRY(chipid, mask, name) \
46         { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
47
48 void brcmf_fw_nvram_free(void *nvram);
49
50 enum brcmf_fw_type {
51         BRCMF_FW_TYPE_BINARY,
52         BRCMF_FW_TYPE_NVRAM
53 };
54
55 struct brcmf_fw_item {
56         const char *path;
57         enum brcmf_fw_type type;
58         u16 flags;
59         union {
60                 const struct firmware *binary;
61                 struct {
62                         void *data;
63                         u32 len;
64                 } nv_data;
65         };
66 };
67
68 struct brcmf_fw_request {
69         u16 domain_nr;
70         u16 bus_nr;
71         u32 n_items;
72         struct brcmf_fw_item items[0];
73 };
74
75 struct brcmf_fw_name {
76         const char *extension;
77         char *path;
78 };
79
80 struct brcmf_fw_request *
81 brcmf_fw_alloc_request(u32 chip, u32 chiprev,
82                        const struct brcmf_firmware_mapping mapping_table[],
83                        u32 table_size, struct brcmf_fw_name *fwnames,
84                        u32 n_fwnames);
85
86 /*
87  * Request firmware(s) asynchronously. When the asynchronous request
88  * fails it will not use the callback, but call device_release_driver()
89  * instead which will call the driver .remove() callback.
90  */
91 int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
92                            void (*fw_cb)(struct device *dev, int err,
93                                          struct brcmf_fw_request *req));
94
95 #endif /* BRCMFMAC_FIRMWARE_H */