Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: ISC
0002 /*
0003  * Copyright (c) 2013 Broadcom Corporation
0004  */
0005 #ifndef BRCMFMAC_FIRMWARE_H
0006 #define BRCMFMAC_FIRMWARE_H
0007 
0008 #define BRCMF_FW_REQF_OPTIONAL      0x0001
0009 
0010 #define BRCMF_FW_NAME_LEN       320
0011 
0012 #define BRCMF_FW_DEFAULT_PATH       "brcm/"
0013 
0014 /**
0015  * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware
0016  *  filename and nvram filename. Each bus type implementation should create
0017  *  a table of firmware mappings (using the macros defined below).
0018  *
0019  * @chipid: ID of chip.
0020  * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3
0021  * @fw: name of the firmware file.
0022  * @nvram: name of nvram file.
0023  */
0024 struct brcmf_firmware_mapping {
0025     u32 chipid;
0026     u32 revmask;
0027     const char *fw_base;
0028 };
0029 
0030 #define BRCMF_FW_DEF(fw_name, fw_base) \
0031 static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
0032     BRCMF_FW_DEFAULT_PATH fw_base; \
0033 MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin")
0034 
0035 /* Firmware and Country Local Matrix files */
0036 #define BRCMF_FW_CLM_DEF(fw_name, fw_base) \
0037 static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
0038     BRCMF_FW_DEFAULT_PATH fw_base; \
0039 MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin"); \
0040 MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".clm_blob")
0041 
0042 #define BRCMF_FW_ENTRY(chipid, mask, name) \
0043     { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
0044 
0045 void brcmf_fw_nvram_free(void *nvram);
0046 
0047 enum brcmf_fw_type {
0048     BRCMF_FW_TYPE_BINARY,
0049     BRCMF_FW_TYPE_NVRAM
0050 };
0051 
0052 struct brcmf_fw_item {
0053     const char *path;
0054     enum brcmf_fw_type type;
0055     u16 flags;
0056     union {
0057         const struct firmware *binary;
0058         struct {
0059             void *data;
0060             u32 len;
0061         } nv_data;
0062     };
0063 };
0064 
0065 struct brcmf_fw_request {
0066     u16 domain_nr;
0067     u16 bus_nr;
0068     u32 n_items;
0069     const char *board_type;
0070     struct brcmf_fw_item items[];
0071 };
0072 
0073 struct brcmf_fw_name {
0074     const char *extension;
0075     char *path;
0076 };
0077 
0078 struct brcmf_fw_request *
0079 brcmf_fw_alloc_request(u32 chip, u32 chiprev,
0080                const struct brcmf_firmware_mapping mapping_table[],
0081                u32 table_size, struct brcmf_fw_name *fwnames,
0082                u32 n_fwnames);
0083 
0084 /*
0085  * Request firmware(s) asynchronously. When the asynchronous request
0086  * fails it will not use the callback, but call device_release_driver()
0087  * instead which will call the driver .remove() callback.
0088  */
0089 int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
0090                void (*fw_cb)(struct device *dev, int err,
0091                      struct brcmf_fw_request *req));
0092 
0093 #endif /* BRCMFMAC_FIRMWARE_H */