blob: 9f2a593294faeb6887123b1ebe72dd991b5c8814 [file] [log] [blame]
/*
* Copyright (c) 2015 Qualcomm Atheros, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef GARNET_DRIVERS_WLAN_THIRD_PARTY_ATHEROS_ATH10K_SWAP_H_
#define GARNET_DRIVERS_WLAN_THIRD_PARTY_ATHEROS_ATH10K_SWAP_H_
#include <ddk/io-buffer.h>
// clang-format off
#define ATH10K_SWAP_CODE_SEG_BIN_LEN_MAX (512 * 1024)
#define ATH10K_SWAP_CODE_SEG_MAGIC_BYTES_SZ 12
#define ATH10K_SWAP_CODE_SEG_NUM_MAX 16
/* Currently only one swap segment is supported */
#define ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED 1
// clang-format on
struct ath10k_fw_file;
struct ath10k_swap_code_seg_tlv {
uint32_t address;
uint32_t length;
uint8_t data[0];
} __PACKED;
struct ath10k_swap_code_seg_tail {
uint8_t magic_signature[ATH10K_SWAP_CODE_SEG_MAGIC_BYTES_SZ];
uint32_t bmi_write_addr;
} __PACKED;
union ath10k_swap_code_seg_item {
struct ath10k_swap_code_seg_tlv tlv;
struct ath10k_swap_code_seg_tail tail;
} __PACKED;
struct ath10k_swap_code_seg_hw_info {
/* Swap binary image size */
uint32_t swap_size;
uint32_t num_segs;
/* Swap data size */
uint32_t size;
uint32_t size_log2;
uint32_t bus_addr[ATH10K_SWAP_CODE_SEG_NUM_MAX];
uint64_t reserved[ATH10K_SWAP_CODE_SEG_NUM_MAX];
} __PACKED;
struct ath10k_swap_code_seg_info {
struct ath10k_swap_code_seg_hw_info seg_hw_info;
io_buffer_t handles[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED];
void* virt_address[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED];
uint32_t target_addr;
zx_paddr_t paddr[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED];
};
zx_status_t ath10k_swap_code_seg_configure(struct ath10k* ar, const struct ath10k_fw_file* fw_file);
void ath10k_swap_code_seg_release(struct ath10k* ar, struct ath10k_fw_file* fw_file);
zx_status_t ath10k_swap_code_seg_init(struct ath10k* ar, struct ath10k_fw_file* fw_file);
#endif // GARNET_DRIVERS_WLAN_THIRD_PARTY_ATHEROS_ATH10K_SWAP_H_