GNU Linux-libre 4.9.337-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_REQUEST                0x000F
20 #define  BRCMF_FW_REQUEST_NVRAM         0x0001
21 #define BRCMF_FW_REQ_FLAGS              0x00F0
22 #define  BRCMF_FW_REQ_NV_OPTIONAL       0x0010
23
24 #define BRCMF_FW_NAME_LEN               320
25
26 #define BRCMF_FW_DEFAULT_PATH           /*(DEBLOBBED)*/
27
28 /**
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).
32  *
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.
37  */
38 struct brcmf_firmware_mapping {
39         u32 chipid;
40         u32 revmask;
41         const char *fw;
42         const char *nvram;
43 };
44
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)*/;
50
51 #define BRCMF_FW_DEF(fw_name, fw) \
52 static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
53         BRCMF_FW_DEFAULT_PATH fw/*(DEBLOBBED)*/ \
54
55 #define BRCMF_FW_NVRAM_ENTRY(chipid, mask, name) \
56         { chipid, mask, \
57           BRCM_ ## name ## _FIRMWARE_NAME, BRCM_ ## name ## _NVRAM_NAME }
58
59 #define BRCMF_FW_ENTRY(chipid, mask, name) \
60         { chipid, mask, BRCM_ ## name ## _FIRMWARE_NAME, NULL }
61
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);
67 /*
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.
71  */
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));
83
84 #endif /* BRCMFMAC_FIRMWARE_H */