blob: d3c9f0d52ae3326eb18a76aaf735bb602a211a35 [file] [log] [blame]
Hante Meulemana74d0362014-01-13 22:20:22 +01001/*
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 */
Arend van Sprieldabedab2014-05-27 12:56:17 +020016#ifndef BRCMFMAC_FIRMWARE_H
17#define BRCMFMAC_FIRMWARE_H
Hante Meulemana74d0362014-01-13 22:20:22 +010018
Arend van Sprielc1416e72014-05-27 12:56:21 +020019#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
Hante Meulemana74d0362014-01-13 22:20:22 +010023
Hante Meuleman46d703a2015-11-25 11:32:46 +010024#define BRCMF_FW_NAME_LEN 320
Daniel Kimc1b20532014-07-12 08:49:37 +020025
Hante Meuleman46d703a2015-11-25 11:32:46 +010026#define BRCMF_FW_DEFAULT_PATH "brcm/"
Daniel Kimc1b20532014-07-12 08:49:37 +020027
Hante Meuleman46d703a2015-11-25 11:32:46 +010028/**
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 */
38struct 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) \
46static const char BRCM_ ## fw_nvram_name ## _FIRMWARE_NAME[] = \
47 BRCMF_FW_DEFAULT_PATH fw; \
48static const char BRCM_ ## fw_nvram_name ## _NVRAM_NAME[] = \
49 BRCMF_FW_DEFAULT_PATH nvram; \
Arend van Spriel23195ec2016-01-16 16:39:13 +010050MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw);
Hante Meuleman46d703a2015-11-25 11:32:46 +010051
52#define BRCMF_FW_DEF(fw_name, fw) \
53static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
54 BRCMF_FW_DEFAULT_PATH fw; \
55MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw) \
56
57#define BRCMF_FW_NVRAM_ENTRY(chipid, mask, name) \
58 { chipid, mask, \
59 BRCM_ ## name ## _FIRMWARE_NAME, BRCM_ ## name ## _NVRAM_NAME }
60
61#define BRCMF_FW_ENTRY(chipid, mask, name) \
62 { chipid, mask, BRCM_ ## name ## _FIRMWARE_NAME, NULL }
63
64int brcmf_fw_map_chip_to_name(u32 chip, u32 chiprev,
65 struct brcmf_firmware_mapping mapping_table[],
66 u32 table_size, char fw_name[BRCMF_FW_NAME_LEN],
67 char nvram_name[BRCMF_FW_NAME_LEN]);
Arend van Sprieldabedab2014-05-27 12:56:17 +020068void brcmf_fw_nvram_free(void *nvram);
Arend van Sprielc1416e72014-05-27 12:56:21 +020069/*
70 * Request firmware(s) asynchronously. When the asynchronous request
71 * fails it will not use the callback, but call device_release_driver()
72 * instead which will call the driver .remove() callback.
73 */
Hante Meulemanc4365532015-04-14 20:10:33 +020074int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
75 const char *code, const char *nvram,
76 void (*fw_cb)(struct device *dev,
77 const struct firmware *fw,
78 void *nvram_image, u32 nvram_len),
79 u16 domain_nr, u16 bus_nr);
Arend van Sprielc1416e72014-05-27 12:56:21 +020080int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
81 const char *code, const char *nvram,
82 void (*fw_cb)(struct device *dev,
83 const struct firmware *fw,
84 void *nvram_image, u32 nvram_len));
Hante Meulemana74d0362014-01-13 22:20:22 +010085
Arend van Sprieldabedab2014-05-27 12:56:17 +020086#endif /* BRCMFMAC_FIRMWARE_H */