162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2017 Intel Deutschland GmbH 462306a36Sopenharmony_ci * Copyright (C) 2018-2020, 2022 Intel Corporation 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __iwl_context_info_file_h__ 762306a36Sopenharmony_ci#define __iwl_context_info_file_h__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* maximmum number of DRAM map entries supported by FW */ 1062306a36Sopenharmony_ci#define IWL_MAX_DRAM_ENTRY 64 1162306a36Sopenharmony_ci#define CSR_CTXT_INFO_BA 0x40 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/** 1462306a36Sopenharmony_ci * enum iwl_context_info_flags - Context information control flags 1562306a36Sopenharmony_ci * @IWL_CTXT_INFO_AUTO_FUNC_INIT: If set, FW will not wait before interrupting 1662306a36Sopenharmony_ci * the init done for driver command that configures several system modes 1762306a36Sopenharmony_ci * @IWL_CTXT_INFO_EARLY_DEBUG: enable early debug 1862306a36Sopenharmony_ci * @IWL_CTXT_INFO_ENABLE_CDMP: enable core dump 1962306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_CB_SIZE: mask of the RBD Cyclic Buffer Size 2062306a36Sopenharmony_ci * exponent, the actual size is 2**value, valid sizes are 8-2048. 2162306a36Sopenharmony_ci * The value is four bits long. Maximum valid exponent is 12 2262306a36Sopenharmony_ci * @IWL_CTXT_INFO_TFD_FORMAT_LONG: use long TFD Format (the 2362306a36Sopenharmony_ci * default is short format - not supported by the driver) 2462306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE: RB size mask 2562306a36Sopenharmony_ci * (values are IWL_CTXT_INFO_RB_SIZE_*K) 2662306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_1K: Value for 1K RB size 2762306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_2K: Value for 2K RB size 2862306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_4K: Value for 4K RB size 2962306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_8K: Value for 8K RB size 3062306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_12K: Value for 12K RB size 3162306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_16K: Value for 16K RB size 3262306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_20K: Value for 20K RB size 3362306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_24K: Value for 24K RB size 3462306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_28K: Value for 28K RB size 3562306a36Sopenharmony_ci * @IWL_CTXT_INFO_RB_SIZE_32K: Value for 32K RB size 3662306a36Sopenharmony_ci */ 3762306a36Sopenharmony_cienum iwl_context_info_flags { 3862306a36Sopenharmony_ci IWL_CTXT_INFO_AUTO_FUNC_INIT = 0x0001, 3962306a36Sopenharmony_ci IWL_CTXT_INFO_EARLY_DEBUG = 0x0002, 4062306a36Sopenharmony_ci IWL_CTXT_INFO_ENABLE_CDMP = 0x0004, 4162306a36Sopenharmony_ci IWL_CTXT_INFO_RB_CB_SIZE = 0x00f0, 4262306a36Sopenharmony_ci IWL_CTXT_INFO_TFD_FORMAT_LONG = 0x0100, 4362306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE = 0x1e00, 4462306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_1K = 0x1, 4562306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_2K = 0x2, 4662306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_4K = 0x4, 4762306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_8K = 0x8, 4862306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_12K = 0x9, 4962306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_16K = 0xa, 5062306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_20K = 0xb, 5162306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_24K = 0xc, 5262306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_28K = 0xd, 5362306a36Sopenharmony_ci IWL_CTXT_INFO_RB_SIZE_32K = 0xe, 5462306a36Sopenharmony_ci}; 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci/* 5762306a36Sopenharmony_ci * struct iwl_context_info_version - version structure 5862306a36Sopenharmony_ci * @mac_id: SKU and revision id 5962306a36Sopenharmony_ci * @version: context information version id 6062306a36Sopenharmony_ci * @size: the size of the context information in DWs 6162306a36Sopenharmony_ci */ 6262306a36Sopenharmony_cistruct iwl_context_info_version { 6362306a36Sopenharmony_ci __le16 mac_id; 6462306a36Sopenharmony_ci __le16 version; 6562306a36Sopenharmony_ci __le16 size; 6662306a36Sopenharmony_ci __le16 reserved; 6762306a36Sopenharmony_ci} __packed; 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci/* 7062306a36Sopenharmony_ci * struct iwl_context_info_control - version structure 7162306a36Sopenharmony_ci * @control_flags: context information flags see &enum iwl_context_info_flags 7262306a36Sopenharmony_ci */ 7362306a36Sopenharmony_cistruct iwl_context_info_control { 7462306a36Sopenharmony_ci __le32 control_flags; 7562306a36Sopenharmony_ci __le32 reserved; 7662306a36Sopenharmony_ci} __packed; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * struct iwl_context_info_dram - images DRAM map 8062306a36Sopenharmony_ci * each entry in the map represents a DRAM chunk of up to 32 KB 8162306a36Sopenharmony_ci * @umac_img: UMAC image DRAM map 8262306a36Sopenharmony_ci * @lmac_img: LMAC image DRAM map 8362306a36Sopenharmony_ci * @virtual_img: paged image DRAM map 8462306a36Sopenharmony_ci */ 8562306a36Sopenharmony_cistruct iwl_context_info_dram { 8662306a36Sopenharmony_ci __le64 umac_img[IWL_MAX_DRAM_ENTRY]; 8762306a36Sopenharmony_ci __le64 lmac_img[IWL_MAX_DRAM_ENTRY]; 8862306a36Sopenharmony_ci __le64 virtual_img[IWL_MAX_DRAM_ENTRY]; 8962306a36Sopenharmony_ci} __packed; 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci/* 9262306a36Sopenharmony_ci * struct iwl_context_info_rbd_cfg - RBDs configuration 9362306a36Sopenharmony_ci * @free_rbd_addr: default queue free RB CB base address 9462306a36Sopenharmony_ci * @used_rbd_addr: default queue used RB CB base address 9562306a36Sopenharmony_ci * @status_wr_ptr: default queue used RB status write pointer 9662306a36Sopenharmony_ci */ 9762306a36Sopenharmony_cistruct iwl_context_info_rbd_cfg { 9862306a36Sopenharmony_ci __le64 free_rbd_addr; 9962306a36Sopenharmony_ci __le64 used_rbd_addr; 10062306a36Sopenharmony_ci __le64 status_wr_ptr; 10162306a36Sopenharmony_ci} __packed; 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci/* 10462306a36Sopenharmony_ci * struct iwl_context_info_hcmd_cfg - command queue configuration 10562306a36Sopenharmony_ci * @cmd_queue_addr: address of command queue 10662306a36Sopenharmony_ci * @cmd_queue_size: number of entries 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_cistruct iwl_context_info_hcmd_cfg { 10962306a36Sopenharmony_ci __le64 cmd_queue_addr; 11062306a36Sopenharmony_ci u8 cmd_queue_size; 11162306a36Sopenharmony_ci u8 reserved[7]; 11262306a36Sopenharmony_ci} __packed; 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci/* 11562306a36Sopenharmony_ci * struct iwl_context_info_dump_cfg - Core Dump configuration 11662306a36Sopenharmony_ci * @core_dump_addr: core dump (debug DRAM address) start address 11762306a36Sopenharmony_ci * @core_dump_size: size, in DWs 11862306a36Sopenharmony_ci */ 11962306a36Sopenharmony_cistruct iwl_context_info_dump_cfg { 12062306a36Sopenharmony_ci __le64 core_dump_addr; 12162306a36Sopenharmony_ci __le32 core_dump_size; 12262306a36Sopenharmony_ci __le32 reserved; 12362306a36Sopenharmony_ci} __packed; 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* 12662306a36Sopenharmony_ci * struct iwl_context_info_pnvm_cfg - platform NVM data configuration 12762306a36Sopenharmony_ci * @platform_nvm_addr: Platform NVM data start address 12862306a36Sopenharmony_ci * @platform_nvm_size: size in DWs 12962306a36Sopenharmony_ci */ 13062306a36Sopenharmony_cistruct iwl_context_info_pnvm_cfg { 13162306a36Sopenharmony_ci __le64 platform_nvm_addr; 13262306a36Sopenharmony_ci __le32 platform_nvm_size; 13362306a36Sopenharmony_ci __le32 reserved; 13462306a36Sopenharmony_ci} __packed; 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci/* 13762306a36Sopenharmony_ci * struct iwl_context_info_early_dbg_cfg - early debug configuration for 13862306a36Sopenharmony_ci * dumping DRAM addresses 13962306a36Sopenharmony_ci * @early_debug_addr: early debug start address 14062306a36Sopenharmony_ci * @early_debug_size: size in DWs 14162306a36Sopenharmony_ci */ 14262306a36Sopenharmony_cistruct iwl_context_info_early_dbg_cfg { 14362306a36Sopenharmony_ci __le64 early_debug_addr; 14462306a36Sopenharmony_ci __le32 early_debug_size; 14562306a36Sopenharmony_ci __le32 reserved; 14662306a36Sopenharmony_ci} __packed; 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ci/* 14962306a36Sopenharmony_ci * struct iwl_context_info - device INIT configuration 15062306a36Sopenharmony_ci * @version: version information of context info and HW 15162306a36Sopenharmony_ci * @control: control flags of FH configurations 15262306a36Sopenharmony_ci * @rbd_cfg: default RX queue configuration 15362306a36Sopenharmony_ci * @hcmd_cfg: command queue configuration 15462306a36Sopenharmony_ci * @dump_cfg: core dump data 15562306a36Sopenharmony_ci * @edbg_cfg: early debug configuration 15662306a36Sopenharmony_ci * @pnvm_cfg: platform nvm configuration 15762306a36Sopenharmony_ci * @dram: firmware image addresses in DRAM 15862306a36Sopenharmony_ci */ 15962306a36Sopenharmony_cistruct iwl_context_info { 16062306a36Sopenharmony_ci struct iwl_context_info_version version; 16162306a36Sopenharmony_ci struct iwl_context_info_control control; 16262306a36Sopenharmony_ci __le64 reserved0; 16362306a36Sopenharmony_ci struct iwl_context_info_rbd_cfg rbd_cfg; 16462306a36Sopenharmony_ci struct iwl_context_info_hcmd_cfg hcmd_cfg; 16562306a36Sopenharmony_ci __le32 reserved1[4]; 16662306a36Sopenharmony_ci struct iwl_context_info_dump_cfg dump_cfg; 16762306a36Sopenharmony_ci struct iwl_context_info_early_dbg_cfg edbg_cfg; 16862306a36Sopenharmony_ci struct iwl_context_info_pnvm_cfg pnvm_cfg; 16962306a36Sopenharmony_ci __le32 reserved2[16]; 17062306a36Sopenharmony_ci struct iwl_context_info_dram dram; 17162306a36Sopenharmony_ci __le32 reserved3[16]; 17262306a36Sopenharmony_ci} __packed; 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ciint iwl_pcie_ctxt_info_init(struct iwl_trans *trans, const struct fw_img *fw); 17562306a36Sopenharmony_civoid iwl_pcie_ctxt_info_free(struct iwl_trans *trans); 17662306a36Sopenharmony_civoid iwl_pcie_ctxt_info_free_paging(struct iwl_trans *trans); 17762306a36Sopenharmony_ciint iwl_pcie_init_fw_sec(struct iwl_trans *trans, 17862306a36Sopenharmony_ci const struct fw_img *fw, 17962306a36Sopenharmony_ci struct iwl_context_info_dram *ctxt_dram); 18062306a36Sopenharmony_civoid *iwl_pcie_ctxt_info_dma_alloc_coherent(struct iwl_trans *trans, 18162306a36Sopenharmony_ci size_t size, 18262306a36Sopenharmony_ci dma_addr_t *phys); 18362306a36Sopenharmony_ciint iwl_pcie_ctxt_info_alloc_dma(struct iwl_trans *trans, 18462306a36Sopenharmony_ci const void *data, u32 len, 18562306a36Sopenharmony_ci struct iwl_dram_data *dram); 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci#endif /* __iwl_context_info_file_h__ */ 188