linux/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c

// SPDX-License-Identifier: ISC
/*
 * Copyright (c) 2013 Broadcom Corporation
 */

#include <linux/efi.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/module.h>
#include <linux/bcm47xx_nvram.h>

#include "debug.h"
#include "firmware.h"
#include "core.h"
#include "common.h"
#include "chip.h"

#define BRCMF_FW_MAX_NVRAM_SIZE
#define BRCMF_FW_NVRAM_DEVPATH_LEN
#define BRCMF_FW_NVRAM_PCIEDEV_LEN
#define BRCMF_FW_DEFAULT_BOARDREV
#define BRCMF_FW_MACADDR_FMT
#define BRCMF_FW_MACADDR_LEN

enum nvram_parser_state {};

/**
 * struct nvram_parser - internal info for parser.
 *
 * @state: current parser state.
 * @data: input buffer being parsed.
 * @nvram: output buffer with parse result.
 * @nvram_len: length of parse result.
 * @line: current line.
 * @column: current column in line.
 * @pos: byte offset in input buffer.
 * @entry: start position of key,value entry.
 * @multi_dev_v1: detect pcie multi device v1 (compressed).
 * @multi_dev_v2: detect pcie multi device v2.
 * @boardrev_found: nvram contains boardrev information.
 * @strip_mac: strip the MAC address.
 */
struct nvram_parser {};

/*
 * is_nvram_char() - check if char is a valid one for NVRAM entry
 *
 * It accepts all printable ASCII chars except for '#' which opens a comment.
 * Please note that ' ' (space) while accepted is not a valid key name char.
 */
static bool is_nvram_char(char c)
{}

static bool is_whitespace(char c)
{}

static enum nvram_parser_state brcmf_nvram_handle_idle(struct nvram_parser *nvp)
{}

static enum nvram_parser_state brcmf_nvram_handle_key(struct nvram_parser *nvp)
{}

static enum nvram_parser_state
brcmf_nvram_handle_value(struct nvram_parser *nvp)
{}

static enum nvram_parser_state
brcmf_nvram_handle_comment(struct nvram_parser *nvp)
{}

static enum nvram_parser_state brcmf_nvram_handle_end(struct nvram_parser *nvp)
{}

static enum nvram_parser_state
(*nv_parser_states[])(struct nvram_parser *nvp) =;

static int brcmf_init_nvram_parser(struct nvram_parser *nvp,
				   const u8 *data, size_t data_len)
{}

/* brcmf_fw_strip_multi_v1 :Some nvram files contain settings for multiple
 * devices. Strip it down for one device, use domain_nr/bus_nr to determine
 * which data is to be returned. v1 is the version where nvram is stored
 * compressed and "devpath" maps to index for valid entries.
 */
static void brcmf_fw_strip_multi_v1(struct nvram_parser *nvp, u16 domain_nr,
				    u16 bus_nr)
{}

/* brcmf_fw_strip_multi_v2 :Some nvram files contain settings for multiple
 * devices. Strip it down for one device, use domain_nr/bus_nr to determine
 * which data is to be returned. v2 is the version where nvram is stored
 * uncompressed, all relevant valid entries are identified by
 * pcie/domain_nr/bus_nr:
 */
static void brcmf_fw_strip_multi_v2(struct nvram_parser *nvp, u16 domain_nr,
				    u16 bus_nr)
{}

static void brcmf_fw_add_defaults(struct nvram_parser *nvp)
{}

static void brcmf_fw_add_macaddr(struct nvram_parser *nvp, u8 *mac)
{}

/* brcmf_nvram_strip :Takes a buffer of "<var>=<value>\n" lines read from a fil
 * and ending in a NUL. Removes carriage returns, empty lines, comment lines,
 * and converts newlines to NULs. Shortens buffer as needed and pads with NULs.
 * End of buffer is completed with token identifying length of buffer.
 */
static void *brcmf_fw_nvram_strip(const u8 *data, size_t data_len,
				  u32 *new_length, u16 domain_nr, u16 bus_nr,
				  struct device *dev)
{}

void brcmf_fw_nvram_free(void *nvram)
{}

struct brcmf_fw {};

#ifdef CONFIG_EFI
/* In some cases the EFI-var stored nvram contains "ccode=ALL" or "ccode=XV"
 * to specify "worldwide" compatible settings, but these 2 ccode-s do not work
 * properly. "ccode=ALL" causes channels 12 and 13 to not be available,
 * "ccode=XV" causes all 5GHz channels to not be available. So we replace both
 * with "ccode=X2" which allows channels 12+13 and 5Ghz channels in
 * no-Initiate-Radiation mode. This means that we will never send on these
 * channels without first having received valid wifi traffic on the channel.
 */
static void brcmf_fw_fix_efi_nvram_ccode(char *data, unsigned long data_len)
{}

static u8 *brcmf_fw_nvram_from_efi(size_t *data_len_ret)
{}
#else
static inline u8 *brcmf_fw_nvram_from_efi(size_t *data_len) { return NULL; }
#endif

static void brcmf_fw_free_request(struct brcmf_fw_request *req)
{}

static int brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
{}

static int brcmf_fw_complete_request(const struct firmware *fw,
				     struct brcmf_fw *fwctx)
{}

static char *brcm_alt_fw_path(const char *path, const char *board_type)
{}

static int brcmf_fw_request_firmware(const struct firmware **fw,
				     struct brcmf_fw *fwctx)
{}

static void brcmf_fw_request_done(const struct firmware *fw, void *ctx)
{}

static void brcmf_fw_request_done_alt_path(const struct firmware *fw, void *ctx)
{}

static bool brcmf_fw_request_is_valid(struct brcmf_fw_request *req)
{}

int brcmf_fw_get_firmwares(struct device *dev, struct brcmf_fw_request *req,
			   void (*fw_cb)(struct device *dev, int err,
					 struct brcmf_fw_request *req))
{}

struct brcmf_fw_request *
brcmf_fw_alloc_request(u32 chip, u32 chiprev,
		       const struct brcmf_firmware_mapping mapping_table[],
		       u32 table_size, struct brcmf_fw_name *fwnames,
		       u32 n_fwnames)
{}