1daeccac2SArend van Spriel // SPDX-License-Identifier: ISC 205491d2cSKalle Valo /* 305491d2cSKalle Valo * Copyright (c) 2013 Broadcom Corporation 405491d2cSKalle Valo */ 505491d2cSKalle Valo #ifndef BRCMFMAC_FIRMWARE_H 605491d2cSKalle Valo #define BRCMFMAC_FIRMWARE_H 705491d2cSKalle Valo 8d09ae51aSArend Van Spriel #define BRCMF_FW_REQF_OPTIONAL 0x0001 905491d2cSKalle Valo 1046d703a7SHante Meuleman #define BRCMF_FW_NAME_LEN 320 1105491d2cSKalle Valo 1246d703a7SHante Meuleman #define BRCMF_FW_DEFAULT_PATH "brcm/" 1305491d2cSKalle Valo 14*7cb46e72SHector Martin #define BRCMF_FW_MAX_BOARD_TYPES 8 15*7cb46e72SHector Martin 1646d703a7SHante Meuleman /** 1746d703a7SHante Meuleman * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware 1846d703a7SHante Meuleman * filename and nvram filename. Each bus type implementation should create 1946d703a7SHante Meuleman * a table of firmware mappings (using the macros defined below). 2046d703a7SHante Meuleman * 2146d703a7SHante Meuleman * @chipid: ID of chip. 2246d703a7SHante Meuleman * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3 2346d703a7SHante Meuleman * @fw: name of the firmware file. 2446d703a7SHante Meuleman * @nvram: name of nvram file. 2546d703a7SHante Meuleman */ 2646d703a7SHante Meuleman struct brcmf_firmware_mapping { 2746d703a7SHante Meuleman u32 chipid; 2846d703a7SHante Meuleman u32 revmask; 2941f573dbSArend Van Spriel const char *fw_base; 3046d703a7SHante Meuleman }; 3146d703a7SHante Meuleman 3241f573dbSArend Van Spriel #define BRCMF_FW_DEF(fw_name, fw_base) \ 3341f573dbSArend Van Spriel static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \ 3441f573dbSArend Van Spriel BRCMF_FW_DEFAULT_PATH fw_base; \ 3541f573dbSArend Van Spriel MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin") 3646d703a7SHante Meuleman 37885f256fSMatthias Brugger /* Firmware and Country Local Matrix files */ 38885f256fSMatthias Brugger #define BRCMF_FW_CLM_DEF(fw_name, fw_base) \ 39885f256fSMatthias Brugger static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \ 40885f256fSMatthias Brugger BRCMF_FW_DEFAULT_PATH fw_base; \ 41885f256fSMatthias Brugger MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin"); \ 42885f256fSMatthias Brugger MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".clm_blob") 43885f256fSMatthias Brugger 4446d703a7SHante Meuleman #define BRCMF_FW_ENTRY(chipid, mask, name) \ 4541f573dbSArend Van Spriel { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME } 4646d703a7SHante Meuleman 4705491d2cSKalle Valo void brcmf_fw_nvram_free(void *nvram); 48d09ae51aSArend Van Spriel 49d09ae51aSArend Van Spriel enum brcmf_fw_type { 50d09ae51aSArend Van Spriel BRCMF_FW_TYPE_BINARY, 51d09ae51aSArend Van Spriel BRCMF_FW_TYPE_NVRAM 52d09ae51aSArend Van Spriel }; 53d09ae51aSArend Van Spriel 54d09ae51aSArend Van Spriel struct brcmf_fw_item { 55d09ae51aSArend Van Spriel const char *path; 56d09ae51aSArend Van Spriel enum brcmf_fw_type type; 57d09ae51aSArend Van Spriel u16 flags; 58d09ae51aSArend Van Spriel union { 59d09ae51aSArend Van Spriel const struct firmware *binary; 60d09ae51aSArend Van Spriel struct { 61d09ae51aSArend Van Spriel void *data; 62d09ae51aSArend Van Spriel u32 len; 63d09ae51aSArend Van Spriel } nv_data; 64d09ae51aSArend Van Spriel }; 65d09ae51aSArend Van Spriel }; 66d09ae51aSArend Van Spriel 67d09ae51aSArend Van Spriel struct brcmf_fw_request { 68d09ae51aSArend Van Spriel u16 domain_nr; 69d09ae51aSArend Van Spriel u16 bus_nr; 70d09ae51aSArend Van Spriel u32 n_items; 71*7cb46e72SHector Martin const char *board_types[BRCMF_FW_MAX_BOARD_TYPES]; 72232c897eSGustavo A. R. Silva struct brcmf_fw_item items[]; 73d09ae51aSArend Van Spriel }; 74d09ae51aSArend Van Spriel 752baa3aaeSArend Van Spriel struct brcmf_fw_name { 762baa3aaeSArend Van Spriel const char *extension; 772baa3aaeSArend Van Spriel char *path; 782baa3aaeSArend Van Spriel }; 792baa3aaeSArend Van Spriel 802baa3aaeSArend Van Spriel struct brcmf_fw_request * 812baa3aaeSArend Van Spriel brcmf_fw_alloc_request(u32 chip, u32 chiprev, 82ff68c9f9SArend Van Spriel const struct brcmf_firmware_mapping mapping_table[], 832baa3aaeSArend Van Spriel u32 table_size, struct brcmf_fw_name *fwnames, 842baa3aaeSArend Van Spriel u32 n_fwnames); 852baa3aaeSArend Van Spriel 8605491d2cSKalle Valo /* 8705491d2cSKalle Valo * Request firmware(s) asynchronously. When the asynchronous request 8805491d2cSKalle Valo * fails it will not use the callback, but call device_release_driver() 8905491d2cSKalle Valo * instead which will call the driver .remove() callback. 9005491d2cSKalle Valo */ 91d09ae51aSArend Van Spriel int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req, 926d0507a7SArend Van Spriel void (*fw_cb)(struct device *dev, int err, 93d09ae51aSArend Van Spriel struct brcmf_fw_request *req)); 9405491d2cSKalle Valo 9505491d2cSKalle Valo #endif /* BRCMFMAC_FIRMWARE_H */ 96