Lines Matching +full:fw +full:- +full:cfg
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
4 * Copyright (C) 2018-2024 Intel Corporation
6 #include "iwl-trans.h"
7 #include "iwl-fh.h"
8 #include "iwl-context-info.h"
10 #include "iwl-prph.h"
23 result = dma_alloc_coherent(trans->dev, size, phys, GFP_KERNEL); in _iwl_pcie_ctxt_info_dma_alloc_coherent()
35 dma_free_coherent(trans->dev, size, old, oldphys); in _iwl_pcie_ctxt_info_dma_alloc_coherent()
52 dram->block = iwl_pcie_ctxt_info_dma_alloc_coherent(trans, len, in iwl_pcie_ctxt_info_alloc_dma()
53 &dram->physical); in iwl_pcie_ctxt_info_alloc_dma()
54 if (!dram->block) in iwl_pcie_ctxt_info_alloc_dma()
55 return -ENOMEM; in iwl_pcie_ctxt_info_alloc_dma()
57 dram->size = len; in iwl_pcie_ctxt_info_alloc_dma()
58 memcpy(dram->block, data, len); in iwl_pcie_ctxt_info_alloc_dma()
65 struct iwl_self_init_dram *dram = &trans->init_dram; in iwl_pcie_ctxt_info_free_paging()
68 if (!dram->paging) { in iwl_pcie_ctxt_info_free_paging()
69 WARN_ON(dram->paging_cnt); in iwl_pcie_ctxt_info_free_paging()
74 for (i = 0; i < dram->paging_cnt; i++) in iwl_pcie_ctxt_info_free_paging()
75 dma_free_coherent(trans->dev, dram->paging[i].size, in iwl_pcie_ctxt_info_free_paging()
76 dram->paging[i].block, in iwl_pcie_ctxt_info_free_paging()
77 dram->paging[i].physical); in iwl_pcie_ctxt_info_free_paging()
79 kfree(dram->paging); in iwl_pcie_ctxt_info_free_paging()
80 dram->paging_cnt = 0; in iwl_pcie_ctxt_info_free_paging()
81 dram->paging = NULL; in iwl_pcie_ctxt_info_free_paging()
85 const struct fw_img *fw, in iwl_pcie_init_fw_sec() argument
88 struct iwl_self_init_dram *dram = &trans->init_dram; in iwl_pcie_init_fw_sec()
91 if (WARN(dram->paging, in iwl_pcie_init_fw_sec()
93 dram->paging_cnt)) in iwl_pcie_init_fw_sec()
96 lmac_cnt = iwl_pcie_get_num_sections(fw, 0); in iwl_pcie_init_fw_sec()
98 umac_cnt = iwl_pcie_get_num_sections(fw, lmac_cnt + 1); in iwl_pcie_init_fw_sec()
100 paging_cnt = iwl_pcie_get_num_sections(fw, lmac_cnt + umac_cnt + 2); in iwl_pcie_init_fw_sec()
102 dram->fw = kcalloc(umac_cnt + lmac_cnt, sizeof(*dram->fw), GFP_KERNEL); in iwl_pcie_init_fw_sec()
103 if (!dram->fw) in iwl_pcie_init_fw_sec()
104 return -ENOMEM; in iwl_pcie_init_fw_sec()
105 dram->paging = kcalloc(paging_cnt, sizeof(*dram->paging), GFP_KERNEL); in iwl_pcie_init_fw_sec()
106 if (!dram->paging) in iwl_pcie_init_fw_sec()
107 return -ENOMEM; in iwl_pcie_init_fw_sec()
111 ret = iwl_pcie_ctxt_info_alloc_dma(trans, fw->sec[i].data, in iwl_pcie_init_fw_sec()
112 fw->sec[i].len, in iwl_pcie_init_fw_sec()
113 &dram->fw[dram->fw_cnt]); in iwl_pcie_init_fw_sec()
116 ctxt_dram->lmac_img[i] = in iwl_pcie_init_fw_sec()
117 cpu_to_le64(dram->fw[dram->fw_cnt].physical); in iwl_pcie_init_fw_sec()
118 dram->fw_cnt++; in iwl_pcie_init_fw_sec()
123 /* access FW with +1 to make up for lmac separator */ in iwl_pcie_init_fw_sec()
125 fw->sec[dram->fw_cnt + 1].data, in iwl_pcie_init_fw_sec()
126 fw->sec[dram->fw_cnt + 1].len, in iwl_pcie_init_fw_sec()
127 &dram->fw[dram->fw_cnt]); in iwl_pcie_init_fw_sec()
130 ctxt_dram->umac_img[i] = in iwl_pcie_init_fw_sec()
131 cpu_to_le64(dram->fw[dram->fw_cnt].physical); in iwl_pcie_init_fw_sec()
132 dram->fw_cnt++; in iwl_pcie_init_fw_sec()
137 * Paging memory isn't stored in dram->fw as the umac and lmac - it is in iwl_pcie_init_fw_sec()
139 * This is since the timing of its release is different - in iwl_pcie_init_fw_sec()
140 * while fw memory can be released on alive, the paging memory can be in iwl_pcie_init_fw_sec()
142 * Given that, the logic here in accessing the fw image is a bit in iwl_pcie_init_fw_sec()
143 * different - fw_cnt isn't changing so loop counter is added to it. in iwl_pcie_init_fw_sec()
146 /* access FW with +2 to make up for lmac & umac separators */ in iwl_pcie_init_fw_sec()
147 int fw_idx = dram->fw_cnt + i + 2; in iwl_pcie_init_fw_sec()
149 ret = iwl_pcie_ctxt_info_alloc_dma(trans, fw->sec[fw_idx].data, in iwl_pcie_init_fw_sec()
150 fw->sec[fw_idx].len, in iwl_pcie_init_fw_sec()
151 &dram->paging[i]); in iwl_pcie_init_fw_sec()
155 ctxt_dram->virtual_img[i] = in iwl_pcie_init_fw_sec()
156 cpu_to_le64(dram->paging[i].physical); in iwl_pcie_init_fw_sec()
157 dram->paging_cnt++; in iwl_pcie_init_fw_sec()
164 const struct fw_img *fw) in iwl_pcie_ctxt_info_init() argument
177 return -ENOMEM; in iwl_pcie_ctxt_info_init()
179 trans_pcie->ctxt_info_dma_addr = phys; in iwl_pcie_ctxt_info_init()
181 ctxt_info->version.version = 0; in iwl_pcie_ctxt_info_init()
182 ctxt_info->version.mac_id = in iwl_pcie_ctxt_info_init()
183 cpu_to_le16((u16)trans->hw_rev); in iwl_pcie_ctxt_info_init()
185 ctxt_info->version.size = cpu_to_le16(sizeof(*ctxt_info) / 4); in iwl_pcie_ctxt_info_init()
187 switch (trans_pcie->rx_buf_size) { in iwl_pcie_ctxt_info_init()
205 WARN_ON(RX_QUEUE_CB_SIZE(trans->cfg->num_rbds) > 12); in iwl_pcie_ctxt_info_init()
208 u32_encode_bits(RX_QUEUE_CB_SIZE(trans->cfg->num_rbds), in iwl_pcie_ctxt_info_init()
211 ctxt_info->control.control_flags = cpu_to_le32(control_flags); in iwl_pcie_ctxt_info_init()
214 rx_cfg = &ctxt_info->rbd_cfg; in iwl_pcie_ctxt_info_init()
215 rx_cfg->free_rbd_addr = cpu_to_le64(trans_pcie->rxq->bd_dma); in iwl_pcie_ctxt_info_init()
216 rx_cfg->used_rbd_addr = cpu_to_le64(trans_pcie->rxq->used_bd_dma); in iwl_pcie_ctxt_info_init()
217 rx_cfg->status_wr_ptr = cpu_to_le64(trans_pcie->rxq->rb_stts_dma); in iwl_pcie_ctxt_info_init()
220 ctxt_info->hcmd_cfg.cmd_queue_addr = in iwl_pcie_ctxt_info_init()
221 cpu_to_le64(trans_pcie->txqs.txq[trans_pcie->txqs.cmd.q_id]->dma_addr); in iwl_pcie_ctxt_info_init()
222 ctxt_info->hcmd_cfg.cmd_queue_size = in iwl_pcie_ctxt_info_init()
226 ret = iwl_pcie_init_fw_sec(trans, fw, &ctxt_info->dram); in iwl_pcie_ctxt_info_init()
228 dma_free_coherent(trans->dev, sizeof(*trans_pcie->ctxt_info), in iwl_pcie_ctxt_info_init()
229 ctxt_info, trans_pcie->ctxt_info_dma_addr); in iwl_pcie_ctxt_info_init()
233 trans_pcie->ctxt_info = ctxt_info; in iwl_pcie_ctxt_info_init()
241 /* kick FW self load */ in iwl_pcie_ctxt_info_init()
242 iwl_write64(trans, CSR_CTXT_INFO_BA, trans_pcie->ctxt_info_dma_addr); in iwl_pcie_ctxt_info_init()
253 if (!trans_pcie->ctxt_info) in iwl_pcie_ctxt_info_free()
256 dma_free_coherent(trans->dev, sizeof(*trans_pcie->ctxt_info), in iwl_pcie_ctxt_info_free()
257 trans_pcie->ctxt_info, in iwl_pcie_ctxt_info_free()
258 trans_pcie->ctxt_info_dma_addr); in iwl_pcie_ctxt_info_free()
259 trans_pcie->ctxt_info_dma_addr = 0; in iwl_pcie_ctxt_info_free()
260 trans_pcie->ctxt_info = NULL; in iwl_pcie_ctxt_info_free()