linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
<<
>>
Prefs
   1// SPDX-License-Identifier: ISC
   2/*
   3 * Copyright (c) 2013 Broadcom Corporation
   4 */
   5#ifndef BRCMFMAC_FIRMWARE_H
   6#define BRCMFMAC_FIRMWARE_H
   7
   8#define BRCMF_FW_REQF_OPTIONAL          0x0001
   9
  10#define BRCMF_FW_NAME_LEN               320
  11
  12#define BRCMF_FW_DEFAULT_PATH           "brcm/"
  13
  14/**
  15 * struct brcmf_firmware_mapping - Used to map chipid/revmask to firmware
  16 *      filename and nvram filename. Each bus type implementation should create
  17 *      a table of firmware mappings (using the macros defined below).
  18 *
  19 * @chipid: ID of chip.
  20 * @revmask: bitmask of revisions, e.g. 0x10 means rev 4 only, 0xf means rev 0-3
  21 * @fw: name of the firmware file.
  22 * @nvram: name of nvram file.
  23 */
  24struct brcmf_firmware_mapping {
  25        u32 chipid;
  26        u32 revmask;
  27        const char *fw_base;
  28};
  29
  30#define BRCMF_FW_DEF(fw_name, fw_base) \
  31static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
  32        BRCMF_FW_DEFAULT_PATH fw_base; \
  33MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin")
  34
  35/* Firmware and Country Local Matrix files */
  36#define BRCMF_FW_CLM_DEF(fw_name, fw_base) \
  37static const char BRCM_ ## fw_name ## _FIRMWARE_BASENAME[] = \
  38        BRCMF_FW_DEFAULT_PATH fw_base; \
  39MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".bin"); \
  40MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw_base ".clm_blob")
  41
  42#define BRCMF_FW_ENTRY(chipid, mask, name) \
  43        { chipid, mask, BRCM_ ## name ## _FIRMWARE_BASENAME }
  44
  45void brcmf_fw_nvram_free(void *nvram);
  46
  47enum brcmf_fw_type {
  48        BRCMF_FW_TYPE_BINARY,
  49        BRCMF_FW_TYPE_NVRAM
  50};
  51
  52struct brcmf_fw_item {
  53        const char *path;
  54        enum brcmf_fw_type type;
  55        u16 flags;
  56        union {
  57                const struct firmware *binary;
  58                struct {
  59                        void *data;
  60                        u32 len;
  61                } nv_data;
  62        };
  63};
  64
  65struct brcmf_fw_request {
  66        u16 domain_nr;
  67        u16 bus_nr;
  68        u32 n_items;
  69        const char *board_type;
  70        struct brcmf_fw_item items[];
  71};
  72
  73struct brcmf_fw_name {
  74        const char *extension;
  75        char *path;
  76};
  77
  78struct brcmf_fw_request *
  79brcmf_fw_alloc_request(u32 chip, u32 chiprev,
  80                       const struct brcmf_firmware_mapping mapping_table[],
  81                       u32 table_size, struct brcmf_fw_name *fwnames,
  82                       u32 n_fwnames);
  83
  84/*
  85 * Request firmware(s) asynchronously. When the asynchronous request
  86 * fails it will not use the callback, but call device_release_driver()
  87 * instead which will call the driver .remove() callback.
  88 */
  89int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
  90                           void (*fw_cb)(struct device *dev, int err,
  91                                         struct brcmf_fw_request *req));
  92
  93#endif /* BRCMFMAC_FIRMWARE_H */
  94