Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 278168
b: refs/heads/master
c: 862d32e
h: refs/heads/master
v: v3
  • Loading branch information
Stanislaw Gruszka committed Nov 15, 2011
1 parent 1bbc812 commit 32cd92f
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 168 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 56e7a8cca0fd9e096acd2233f0e9f95df6423071
refs/heads/master: 862d32e6db6183e5cb67fe465818578556196a94
125 changes: 125 additions & 0 deletions trunk/drivers/net/wireless/iwlegacy/4965.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,131 @@
#include "iwl-4965.h"
#include "iwl-4965-debugfs.h"

#define IL_AC_UNSET -1

/**
* il_verify_inst_sparse - verify runtime uCode image in card vs. host,
* using sample data 100 bytes apart. If these sample points are good,
* it's a pretty good bet that everything between them is good, too.
*/
static int
il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len)
{
u32 val;
int ret = 0;
u32 errcnt = 0;
u32 i;

D_INFO("ucode inst image size is %u\n", len);

for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
/* read data comes through single port, auto-incr addr */
/* NOTE: Use the debugless read so we don't flood kernel log
* if IL_DL_IO is set */
il_wr(il, HBUS_TARG_MEM_RADDR,
i + IL4965_RTC_INST_LOWER_BOUND);
val = _il_rd(il, HBUS_TARG_MEM_RDAT);
if (val != le32_to_cpu(*image)) {
ret = -EIO;
errcnt++;
if (errcnt >= 3)
break;
}
}

return ret;
}

/**
* il4965_verify_inst_full - verify runtime uCode image in card vs. host,
* looking at all data.
*/
static int il4965_verify_inst_full(struct il_priv *il, __le32 *image,
u32 len)
{
u32 val;
u32 save_len = len;
int ret = 0;
u32 errcnt;

D_INFO("ucode inst image size is %u\n", len);

il_wr(il, HBUS_TARG_MEM_RADDR,
IL4965_RTC_INST_LOWER_BOUND);

errcnt = 0;
for (; len > 0; len -= sizeof(u32), image++) {
/* read data comes through single port, auto-incr addr */
/* NOTE: Use the debugless read so we don't flood kernel log
* if IL_DL_IO is set */
val = _il_rd(il, HBUS_TARG_MEM_RDAT);
if (val != le32_to_cpu(*image)) {
IL_ERR("uCode INST section is invalid at "
"offset 0x%x, is 0x%x, s/b 0x%x\n",
save_len - len, val, le32_to_cpu(*image));
ret = -EIO;
errcnt++;
if (errcnt >= 20)
break;
}
}

if (!errcnt)
D_INFO(
"ucode image in INSTRUCTION memory is good\n");

return ret;
}

/**
* il4965_verify_ucode - determine which instruction image is in SRAM,
* and verify its contents
*/
int il4965_verify_ucode(struct il_priv *il)
{
__le32 *image;
u32 len;
int ret;

/* Try bootstrap */
image = (__le32 *)il->ucode_boot.v_addr;
len = il->ucode_boot.len;
ret = il4965_verify_inst_sparse(il, image, len);
if (!ret) {
D_INFO("Bootstrap uCode is good in inst SRAM\n");
return 0;
}

/* Try initialize */
image = (__le32 *)il->ucode_init.v_addr;
len = il->ucode_init.len;
ret = il4965_verify_inst_sparse(il, image, len);
if (!ret) {
D_INFO("Initialize uCode is good in inst SRAM\n");
return 0;
}

/* Try runtime/protocol */
image = (__le32 *)il->ucode_code.v_addr;
len = il->ucode_code.len;
ret = il4965_verify_inst_sparse(il, image, len);
if (!ret) {
D_INFO("Runtime uCode is good in inst SRAM\n");
return 0;
}

IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");

/* Since nothing seems to match, show first several data entries in
* instruction SRAM, so maybe visual inspection will give a clue.
* Selection of bootstrap image (vs. other images) is arbitrary. */
image = (__le32 *)il->ucode_boot.v_addr;
len = il->ucode_boot.len;
ret = il4965_verify_inst_full(il, image, len);

return ret;
}

/******************************************************************************
*
* EEPROM related functions
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/net/wireless/iwlegacy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m)
# 4965
obj-$(CONFIG_IWL4965) += iwl4965.o
iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o
iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o
iwl4965-objs += iwl-4965-tx.o
iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o
iwl4965-objs += iwl-4965-sta.o
iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o
Expand Down
166 changes: 0 additions & 166 deletions trunk/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c

This file was deleted.

0 comments on commit 32cd92f

Please sign in to comment.