162306a36Sopenharmony_ci/* SPDX-License-Identifier: ISC */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2015-2016 Qualcomm Atheros, Inc. 462306a36Sopenharmony_ci */ 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#ifndef _SWAP_H_ 762306a36Sopenharmony_ci#define _SWAP_H_ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define ATH10K_SWAP_CODE_SEG_BIN_LEN_MAX (512 * 1024) 1062306a36Sopenharmony_ci#define ATH10K_SWAP_CODE_SEG_MAGIC_BYTES_SZ 12 1162306a36Sopenharmony_ci#define ATH10K_SWAP_CODE_SEG_NUM_MAX 16 1262306a36Sopenharmony_ci/* Currently only one swap segment is supported */ 1362306a36Sopenharmony_ci#define ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED 1 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cistruct ath10k_fw_file; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct ath10k_swap_code_seg_tlv { 1862306a36Sopenharmony_ci __le32 address; 1962306a36Sopenharmony_ci __le32 length; 2062306a36Sopenharmony_ci u8 data[]; 2162306a36Sopenharmony_ci} __packed; 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_cistruct ath10k_swap_code_seg_tail { 2462306a36Sopenharmony_ci u8 magic_signature[ATH10K_SWAP_CODE_SEG_MAGIC_BYTES_SZ]; 2562306a36Sopenharmony_ci __le32 bmi_write_addr; 2662306a36Sopenharmony_ci} __packed; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ciunion ath10k_swap_code_seg_item { 2962306a36Sopenharmony_ci struct ath10k_swap_code_seg_tlv tlv; 3062306a36Sopenharmony_ci struct ath10k_swap_code_seg_tail tail; 3162306a36Sopenharmony_ci} __packed; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_cistruct ath10k_swap_code_seg_hw_info { 3462306a36Sopenharmony_ci /* Swap binary image size */ 3562306a36Sopenharmony_ci __le32 swap_size; 3662306a36Sopenharmony_ci __le32 num_segs; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci /* Swap data size */ 3962306a36Sopenharmony_ci __le32 size; 4062306a36Sopenharmony_ci __le32 size_log2; 4162306a36Sopenharmony_ci __le32 bus_addr[ATH10K_SWAP_CODE_SEG_NUM_MAX]; 4262306a36Sopenharmony_ci __le64 reserved[ATH10K_SWAP_CODE_SEG_NUM_MAX]; 4362306a36Sopenharmony_ci} __packed; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cistruct ath10k_swap_code_seg_info { 4662306a36Sopenharmony_ci struct ath10k_swap_code_seg_hw_info seg_hw_info; 4762306a36Sopenharmony_ci void *virt_address[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED]; 4862306a36Sopenharmony_ci u32 target_addr; 4962306a36Sopenharmony_ci dma_addr_t paddr[ATH10K_SWAP_CODE_SEG_NUM_SUPPORTED]; 5062306a36Sopenharmony_ci}; 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ciint ath10k_swap_code_seg_configure(struct ath10k *ar, 5362306a36Sopenharmony_ci const struct ath10k_fw_file *fw_file); 5462306a36Sopenharmony_civoid ath10k_swap_code_seg_release(struct ath10k *ar, 5562306a36Sopenharmony_ci struct ath10k_fw_file *fw_file); 5662306a36Sopenharmony_ciint ath10k_swap_code_seg_init(struct ath10k *ar, 5762306a36Sopenharmony_ci struct ath10k_fw_file *fw_file); 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci#endif 60