1 /******************************************************************************
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28 *****************************************************************************/
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/init.h>
33 #include <linux/sched.h>
38 #include "iwl-helpers.h"
39 #include "iwl-4965-hw.h"
41 #include "iwl-4965-calib.h"
43 #define IWL_AC_UNSET -1
46 * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host,
47 * using sample data 100 bytes apart. If these sample points are good,
48 * it's a pretty good bet that everything between them is good, too.
51 iwl4965_verify_inst_sparse(struct iwl_priv
*priv
, __le32
*image
, u32 len
)
58 IWL_DEBUG_INFO(priv
, "ucode inst image size is %u\n", len
);
60 for (i
= 0; i
< len
; i
+= 100, image
+= 100/sizeof(u32
)) {
61 /* read data comes through single port, auto-incr addr */
62 /* NOTE: Use the debugless read so we don't flood kernel log
63 * if IWL_DL_IO is set */
64 iwl_legacy_write_direct32(priv
, HBUS_TARG_MEM_RADDR
,
65 i
+ IWL4965_RTC_INST_LOWER_BOUND
);
66 val
= _iwl_legacy_read_direct32(priv
, HBUS_TARG_MEM_RDAT
);
67 if (val
!= le32_to_cpu(*image
)) {
79 * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host,
80 * looking at all data.
82 static int iwl4965_verify_inst_full(struct iwl_priv
*priv
, __le32
*image
,
90 IWL_DEBUG_INFO(priv
, "ucode inst image size is %u\n", len
);
92 iwl_legacy_write_direct32(priv
, HBUS_TARG_MEM_RADDR
,
93 IWL4965_RTC_INST_LOWER_BOUND
);
96 for (; len
> 0; len
-= sizeof(u32
), image
++) {
97 /* read data comes through single port, auto-incr addr */
98 /* NOTE: Use the debugless read so we don't flood kernel log
99 * if IWL_DL_IO is set */
100 val
= _iwl_legacy_read_direct32(priv
, HBUS_TARG_MEM_RDAT
);
101 if (val
!= le32_to_cpu(*image
)) {
102 IWL_ERR(priv
, "uCode INST section is invalid at "
103 "offset 0x%x, is 0x%x, s/b 0x%x\n",
104 save_len
- len
, val
, le32_to_cpu(*image
));
114 "ucode image in INSTRUCTION memory is good\n");
120 * iwl4965_verify_ucode - determine which instruction image is in SRAM,
121 * and verify its contents
123 int iwl4965_verify_ucode(struct iwl_priv
*priv
)
130 image
= (__le32
*)priv
->ucode_boot
.v_addr
;
131 len
= priv
->ucode_boot
.len
;
132 ret
= iwl4965_verify_inst_sparse(priv
, image
, len
);
134 IWL_DEBUG_INFO(priv
, "Bootstrap uCode is good in inst SRAM\n");
139 image
= (__le32
*)priv
->ucode_init
.v_addr
;
140 len
= priv
->ucode_init
.len
;
141 ret
= iwl4965_verify_inst_sparse(priv
, image
, len
);
143 IWL_DEBUG_INFO(priv
, "Initialize uCode is good in inst SRAM\n");
147 /* Try runtime/protocol */
148 image
= (__le32
*)priv
->ucode_code
.v_addr
;
149 len
= priv
->ucode_code
.len
;
150 ret
= iwl4965_verify_inst_sparse(priv
, image
, len
);
152 IWL_DEBUG_INFO(priv
, "Runtime uCode is good in inst SRAM\n");
156 IWL_ERR(priv
, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
158 /* Since nothing seems to match, show first several data entries in
159 * instruction SRAM, so maybe visual inspection will give a clue.
160 * Selection of bootstrap image (vs. other images) is arbitrary. */
161 image
= (__le32
*)priv
->ucode_boot
.v_addr
;
162 len
= priv
->ucode_boot
.len
;
163 ret
= iwl4965_verify_inst_full(priv
, image
, len
);