20 #include <linux/slab.h>
26 #undef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
61 if (*pslut == 0xffffffff)
70 unifi_error(card->ospriv,
"Firmware hasn't started\n");
74 *pslut = slut_address;
91 slut_address = *pslut;
108 unifi_error(card->ospriv,
"Failed to read SLUT finger print\n");
115 unifi_error(card->ospriv,
"Failed to find SLUT fingerprint\n");
190 u32 slut_base = 0xffffffff;
200 "do_patch_convert_download: failed to re-init UniFi\n");
205 if (card->build_id == 0)
214 r = _find_in_slut(card, &sym, &slut_base);
217 unifi_error(card->ospriv,
"Failed to find CSR_SLT_BUILD_ID_NUMBER\n");
229 unifi_error(card->ospriv,
"Failed to read f/w id\n");
232 card->build_id =
ver;
239 unifi_error(card->ospriv,
"Failed to convert f/w to patch");
249 r = _find_in_slut(card, &sym, &slut_base);
252 unifi_error(card->ospriv,
"Failed to find BOOT_LOADER_CONTROL\n");
260 unifi_error(card->ospriv,
"Failed to wake UniFi\n");
274 unifi_info(card->ospriv,
"Downloading converted f/w as patch\n");
281 unifi_error(card->ospriv,
"Converted patch download failed\n");
294 unifi_error(card->ospriv,
"Failed to write loader restart cmd\n");
335 unifi_error(card->ospriv,
"Failed to allocate memory for firmware\n");
351 unifi_error(card->ospriv,
"File type is %s, expected firmware.\n",
366 unifi_info(card->ospriv,
"Must convert f/w to patch format\n");
367 r = do_patch_convert_download(card, dlpriv, fwinfo);
374 unifi_error(card->ospriv,
"Only patch downloading supported\n");
412 unifi_info(card->ospriv,
"unifi_dl_patch %p %08x\n", dlpriv, boot_ctrl);
417 unifi_error(card->ospriv,
"Failed to allocate memory for patches\n");
433 unifi_error(card->ospriv,
"Failed to read in patch file\n");
443 if (card->build_id != fwinfo->
build_id)
445 unifi_error(card->ospriv,
"Wrong patch file for chip (chip = %lu, file = %lu)\n",
448 #ifndef CSR_WIFI_IGNORE_PATCH_VERSION_MISMATCH
458 r = do_patch_download(card, dlpriv, fwinfo, boot_ctrl);
461 unifi_error(card->ospriv,
"Failed to patch image\n");
477 "id=%d, ver=0x%x, fw_build=%u, fw_hip=0x%x, block_size=%d\n",
562 #define OPERATION_TIMEOUT_LOOPS (100)
563 #define OPERATION_TIMEOUT_DELAY 1
570 unifi_trace(card->ospriv,
UDBG4,
"Loader cmd 0x%0x -> 0x%08x\n", opcode, op_addr);
576 unifi_error(card->ospriv,
"Failed to write loader copy command\n");
593 r = safe_read_shared_location(card, op_addr, &op);
596 unifi_error(card->ospriv,
"Failed to read loader status\n");
608 unifi_error(card->ospriv,
"Error reported by loader: 0x%X\n", op);
616 unifi_error(card->ospriv,
"Timeout waiting for loader to ack transfer\n");
621 unifi_error(card->ospriv,
"Failed to stop UniFi processors\n");
673 if (data_len > buf_size)
675 unifi_error(card->ospriv,
"PTDL block is too large (%u)\n",
683 unifi_error(card->ospriv,
"Failed to allocate transfer buffer for firmware download\n");
689 if (
unifi_fw_read(card->ospriv, dlpriv, offset, buf, data_len) != data_len)
691 unifi_error(card->ospriv,
"Failed to read from file\n");
696 if (card->sdio_io_block_pad)
698 write_len = (data_len + (card->sdio_io_block_size - 1)) &
699 ~(card->sdio_io_block_size - 1);
703 memset(buf + data_len, 0, write_len - data_len);
713 unifi_error(card->ospriv,
"CMD53 failed writing %d bytes to handle %ld\n",
730 unifi_error(card->ospriv,
"Failed to copy block of %u bytes to UniFi\n",
774 unifi_error(card->ospriv,
"Patch download: Failed to read loader version\n");
777 unifi_trace(card->ospriv,
UDBG2,
"Patch download: boot loader version 0x%04X\n", loader_version);
778 switch (loader_version)
784 unifi_error(card->ospriv,
"Patch loader version (0x%04X) is not supported by this driver\n",
793 unifi_error(card->ospriv,
"Patch download: Failed to read loader handle\n");
798 if (card->loader_led_mask)
801 (
u16)card->loader_led_mask);
804 unifi_error(card->ospriv,
"Patch download: Failed to write LED mask\n");
812 for (i = 0; i < pfwinfo->
num_ptdl; i++)
814 unifi_trace(card->ospriv,
UDBG3,
"Patch download: %d Downloading for %d from offset %d\n",
816 pfwinfo->
ptdl[i].dl_size,
817 pfwinfo->
ptdl[i].dl_offset);
819 r = send_ptdl_to_unifi(card, dlpriv, &pfwinfo->
ptdl[i],
820 handle, boot_ctrl_addr + 6);
827 unifi_error(card->ospriv,
"Patch failed after %u bytes\n",
831 total_bytes += pfwinfo->
ptdl[
i].dl_size;