162306a36Sopenharmony_ci// SPDX-License-Identifier: ISC 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2013 Broadcom Corporation 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci#ifndef BRCMFMAC_FIRMWARE_H 662306a36Sopenharmony_ci#define BRCMFMAC_FIRMWARE_H 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#define BRCMF_FW_REQF_OPTIONAL 0x0001 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#define BRCMF_FW_NAME_LEN 320 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define BRCMF_FW_DEFAULT_PATH "brcm/" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#define BRCMF_FW_MAX_BOARD_TYPES 8 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci/** 1762306a36Sopenharmony_ci * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware 1862306a36Sopenharmony_ci * filename and nvram filename. Each bus type implementation should create 1962306a36Sopenharmony_ci * a table of firmware mappings (using the macros defined below). 2062306a36Sopenharmony_ci * 2162306a36Sopenharmony_ci * @chipid: ID of chip. 2262306a36Sopenharmony_ci * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3 2362306a36Sopenharmony_ci * @fw: name of the firmware file. 2462306a36Sopenharmony_ci * @nvram: name of nvram file. 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_cistruct brcmf_firmware_mapping { 2762306a36Sopenharmony_ci u32 chipid; 2862306a36Sopenharmony_ci u32 revmask; 2962306a36Sopenharmony_ci const char *fw_base; 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define BRCMF_FW_DEF(fw_name, fw_base) \ 3362306a36Sopenharmony_cistatic const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \ 3462306a36Sopenharmony_ci BRCMF_FW_DEFAULT_PATH fw_base; \ 3562306a36Sopenharmony_ciMODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin") 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci/* Firmware and Country Local Matrix files */ 3862306a36Sopenharmony_ci#define BRCMF_FW_CLM_DEF(fw_name, fw_base) \ 3962306a36Sopenharmony_cistatic const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \ 4062306a36Sopenharmony_ci BRCMF_FW_DEFAULT_PATH fw_base; \ 4162306a36Sopenharmony_ciMODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin"); \ 4262306a36Sopenharmony_ciMODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".clm_blob") 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define BRCMF_FW_ENTRY(chipid, mask, name) \ 4562306a36Sopenharmony_ci { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME } 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_civoid brcmf_fw_nvram_free(void *nvram); 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_cienum brcmf_fw_type { 5062306a36Sopenharmony_ci BRCMF_FW_TYPE_BINARY, 5162306a36Sopenharmony_ci BRCMF_FW_TYPE_NVRAM 5262306a36Sopenharmony_ci}; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistruct brcmf_fw_item { 5562306a36Sopenharmony_ci const char *path; 5662306a36Sopenharmony_ci enum brcmf_fw_type type; 5762306a36Sopenharmony_ci u16 flags; 5862306a36Sopenharmony_ci union { 5962306a36Sopenharmony_ci const struct firmware *binary; 6062306a36Sopenharmony_ci struct { 6162306a36Sopenharmony_ci void *data; 6262306a36Sopenharmony_ci u32 len; 6362306a36Sopenharmony_ci } nv_data; 6462306a36Sopenharmony_ci }; 6562306a36Sopenharmony_ci}; 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_cistruct brcmf_fw_request { 6862306a36Sopenharmony_ci u16 domain_nr; 6962306a36Sopenharmony_ci u16 bus_nr; 7062306a36Sopenharmony_ci u32 n_items; 7162306a36Sopenharmony_ci const char *board_types[BRCMF_FW_MAX_BOARD_TYPES]; 7262306a36Sopenharmony_ci struct brcmf_fw_item items[]; 7362306a36Sopenharmony_ci}; 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_cistruct brcmf_fw_name { 7662306a36Sopenharmony_ci const char *extension; 7762306a36Sopenharmony_ci char *path; 7862306a36Sopenharmony_ci}; 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistruct brcmf_fw_request * 8162306a36Sopenharmony_cibrcmf_fw_alloc_request(u32 chip, u32 chiprev, 8262306a36Sopenharmony_ci const struct brcmf_firmware_mapping mapping_table[], 8362306a36Sopenharmony_ci u32 table_size, struct brcmf_fw_name *fwnames, 8462306a36Sopenharmony_ci u32 n_fwnames); 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci/* 8762306a36Sopenharmony_ci * Request firmware(s) asynchronously. When the asynchronous request 8862306a36Sopenharmony_ci * fails it will not use the callback, but call device_release_driver() 8962306a36Sopenharmony_ci * instead which will call the driver .remove() callback. 9062306a36Sopenharmony_ci */ 9162306a36Sopenharmony_ciint brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req, 9262306a36Sopenharmony_ci void (*fw_cb)(struct device *dev, int err, 9362306a36Sopenharmony_ci struct brcmf_fw_request *req)); 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_ci#endif /* BRCMFMAC_FIRMWARE_H */ 96