|
@@ -923,13 +923,10 @@ static int iwl_prepare_card_hw(struct iwl_trans *trans)
|
|
|
/*
|
|
|
* ucode
|
|
|
*/
|
|
|
-static int iwl_load_section(struct iwl_trans *trans, u8 section_num,
|
|
|
- const struct fw_desc *section)
|
|
|
+static int iwl_load_firmware_chunk(struct iwl_trans *trans, u32 dst_addr,
|
|
|
+ dma_addr_t phy_addr, u32 byte_cnt)
|
|
|
{
|
|
|
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
|
|
|
- dma_addr_t phy_addr = section->p_addr;
|
|
|
- u32 byte_cnt = section->len;
|
|
|
- u32 dst_addr = section->offset;
|
|
|
int ret;
|
|
|
|
|
|
trans_pcie->ucode_write_complete = false;
|
|
@@ -943,8 +940,8 @@ static int iwl_load_section(struct iwl_trans *trans, u8 section_num,
|
|
|
dst_addr);
|
|
|
|
|
|
iwl_write_direct32(trans,
|
|
|
- FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
|
|
|
- phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
|
|
|
+ FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
|
|
|
+ phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
|
|
|
|
|
|
iwl_write_direct32(trans,
|
|
|
FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL),
|
|
@@ -963,26 +960,58 @@ static int iwl_load_section(struct iwl_trans *trans, u8 section_num,
|
|
|
FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
|
|
|
FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
|
|
|
|
|
|
- IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n",
|
|
|
- section_num);
|
|
|
ret = wait_event_timeout(trans_pcie->ucode_write_waitq,
|
|
|
trans_pcie->ucode_write_complete, 5 * HZ);
|
|
|
if (!ret) {
|
|
|
- IWL_ERR(trans, "Could not load the [%d] uCode section\n",
|
|
|
- section_num);
|
|
|
+ IWL_ERR(trans, "Failed to load firmware chunk!\n");
|
|
|
return -ETIMEDOUT;
|
|
|
}
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
+static int iwl_load_section(struct iwl_trans *trans, u8 section_num,
|
|
|
+ const struct fw_desc *section)
|
|
|
+{
|
|
|
+ u8 *v_addr;
|
|
|
+ dma_addr_t p_addr;
|
|
|
+ u32 offset;
|
|
|
+ int ret = 0;
|
|
|
+
|
|
|
+ IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n",
|
|
|
+ section_num);
|
|
|
+
|
|
|
+ v_addr = dma_alloc_coherent(trans->dev, PAGE_SIZE, &p_addr, GFP_KERNEL);
|
|
|
+ if (!v_addr)
|
|
|
+ return -ENOMEM;
|
|
|
+
|
|
|
+ for (offset = 0; offset < section->len; offset += PAGE_SIZE) {
|
|
|
+ u32 copy_size;
|
|
|
+
|
|
|
+ copy_size = min_t(u32, PAGE_SIZE, section->len - offset);
|
|
|
+
|
|
|
+ memcpy(v_addr, (u8 *)section->data + offset, copy_size);
|
|
|
+ ret = iwl_load_firmware_chunk(trans, section->offset + offset,
|
|
|
+ p_addr, copy_size);
|
|
|
+ if (ret) {
|
|
|
+ IWL_ERR(trans,
|
|
|
+ "Could not load the [%d] uCode section\n",
|
|
|
+ section_num);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dma_free_coherent(trans->dev, PAGE_SIZE, v_addr, p_addr);
|
|
|
+ return ret;
|
|
|
+}
|
|
|
+
|
|
|
static int iwl_load_given_ucode(struct iwl_trans *trans,
|
|
|
const struct fw_img *image)
|
|
|
{
|
|
|
int i, ret = 0;
|
|
|
|
|
|
for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) {
|
|
|
- if (!image->sec[i].p_addr)
|
|
|
+ if (!image->sec[i].data)
|
|
|
break;
|
|
|
|
|
|
ret = iwl_load_section(trans, i, &image->sec[i]);
|