aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-08-30 06:50:25 -0400
committerStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 06:41:53 -0500
commit862d32e6db6183e5cb67fe465818578556196a94 (patch)
treef693bc0dcaf396a7918c96c79509167ed1391771 /drivers/net
parent56e7a8cca0fd9e096acd2233f0e9f95df6423071 (diff)
iwlegacy: merge iwl-4965-ucode.c into 4965.c
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlegacy/4965.c125
-rw-r--r--drivers/net/wireless/iwlegacy/Makefile2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-ucode.c166
3 files changed, 126 insertions, 167 deletions
diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c
index a4b42cc4c4c7..752564d36c98 100644
--- a/drivers/net/wireless/iwlegacy/4965.c
+++ b/drivers/net/wireless/iwlegacy/4965.c
@@ -47,6 +47,131 @@
47#include "iwl-4965.h" 47#include "iwl-4965.h"
48#include "iwl-4965-debugfs.h" 48#include "iwl-4965-debugfs.h"
49 49
50#define IL_AC_UNSET -1
51
52/**
53 * il_verify_inst_sparse - verify runtime uCode image in card vs. host,
54 * using sample data 100 bytes apart. If these sample points are good,
55 * it's a pretty good bet that everything between them is good, too.
56 */
57static int
58il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len)
59{
60 u32 val;
61 int ret = 0;
62 u32 errcnt = 0;
63 u32 i;
64
65 D_INFO("ucode inst image size is %u\n", len);
66
67 for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) {
68 /* read data comes through single port, auto-incr addr */
69 /* NOTE: Use the debugless read so we don't flood kernel log
70 * if IL_DL_IO is set */
71 il_wr(il, HBUS_TARG_MEM_RADDR,
72 i + IL4965_RTC_INST_LOWER_BOUND);
73 val = _il_rd(il, HBUS_TARG_MEM_RDAT);
74 if (val != le32_to_cpu(*image)) {
75 ret = -EIO;
76 errcnt++;
77 if (errcnt >= 3)
78 break;
79 }
80 }
81
82 return ret;
83}
84
85/**
86 * il4965_verify_inst_full - verify runtime uCode image in card vs. host,
87 * looking at all data.
88 */
89static int il4965_verify_inst_full(struct il_priv *il, __le32 *image,
90 u32 len)
91{
92 u32 val;
93 u32 save_len = len;
94 int ret = 0;
95 u32 errcnt;
96
97 D_INFO("ucode inst image size is %u\n", len);
98
99 il_wr(il, HBUS_TARG_MEM_RADDR,
100 IL4965_RTC_INST_LOWER_BOUND);
101
102 errcnt = 0;
103 for (; len > 0; len -= sizeof(u32), image++) {
104 /* read data comes through single port, auto-incr addr */
105 /* NOTE: Use the debugless read so we don't flood kernel log
106 * if IL_DL_IO is set */
107 val = _il_rd(il, HBUS_TARG_MEM_RDAT);
108 if (val != le32_to_cpu(*image)) {
109 IL_ERR("uCode INST section is invalid at "
110 "offset 0x%x, is 0x%x, s/b 0x%x\n",
111 save_len - len, val, le32_to_cpu(*image));
112 ret = -EIO;
113 errcnt++;
114 if (errcnt >= 20)
115 break;
116 }
117 }
118
119 if (!errcnt)
120 D_INFO(
121 "ucode image in INSTRUCTION memory is good\n");
122
123 return ret;
124}
125
126/**
127 * il4965_verify_ucode - determine which instruction image is in SRAM,
128 * and verify its contents
129 */
130int il4965_verify_ucode(struct il_priv *il)
131{
132 __le32 *image;
133 u32 len;
134 int ret;
135
136 /* Try bootstrap */
137 image = (__le32 *)il->ucode_boot.v_addr;
138 len = il->ucode_boot.len;
139 ret = il4965_verify_inst_sparse(il, image, len);
140 if (!ret) {
141 D_INFO("Bootstrap uCode is good in inst SRAM\n");
142 return 0;
143 }
144
145 /* Try initialize */
146 image = (__le32 *)il->ucode_init.v_addr;
147 len = il->ucode_init.len;
148 ret = il4965_verify_inst_sparse(il, image, len);
149 if (!ret) {
150 D_INFO("Initialize uCode is good in inst SRAM\n");
151 return 0;
152 }
153
154 /* Try runtime/protocol */
155 image = (__le32 *)il->ucode_code.v_addr;
156 len = il->ucode_code.len;
157 ret = il4965_verify_inst_sparse(il, image, len);
158 if (!ret) {
159 D_INFO("Runtime uCode is good in inst SRAM\n");
160 return 0;
161 }
162
163 IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
164
165 /* Since nothing seems to match, show first several data entries in
166 * instruction SRAM, so maybe visual inspection will give a clue.
167 * Selection of bootstrap image (vs. other images) is arbitrary. */
168 image = (__le32 *)il->ucode_boot.v_addr;
169 len = il->ucode_boot.len;
170 ret = il4965_verify_inst_full(il, image, len);
171
172 return ret;
173}
174
50/****************************************************************************** 175/******************************************************************************
51 * 176 *
52 * EEPROM related functions 177 * EEPROM related functions
diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile
index 2776845be8d9..43daa07ac898 100644
--- a/drivers/net/wireless/iwlegacy/Makefile
+++ b/drivers/net/wireless/iwlegacy/Makefile
@@ -9,7 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m)
9# 4965 9# 4965
10obj-$(CONFIG_IWL4965) += iwl4965.o 10obj-$(CONFIG_IWL4965) += iwl4965.o
11iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o 11iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o
12iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o 12iwl4965-objs += iwl-4965-tx.o
13iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o 13iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o
14iwl4965-objs += iwl-4965-sta.o 14iwl4965-objs += iwl-4965-sta.o
15iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o 15iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c
deleted file mode 100644
index 633caf5f60fc..000000000000
--- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c
+++ /dev/null
@@ -1,166 +0,0 @@
1/******************************************************************************
2 *
3 * GPL LICENSE SUMMARY
4 *
5 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
6 *
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.
10 *
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.
15 *
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,
19 * USA
20 *
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
23 *
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *
28 *****************************************************************************/
29
30#include <linux/kernel.h>
31#include <linux/module.h>
32#include <linux/init.h>
33#include <linux/sched.h>
34
35#include "iwl-dev.h"
36#include "iwl-core.h"
37#include "iwl-io.h"
38#include "iwl-helpers.h"
39#include "iwl-4965-hw.h"
40#include "iwl-4965.h"
41#include "iwl-4965-calib.h"
42
43#define IL_AC_UNSET -1
44
45/**
46 * il_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.
49 */
50static int
51il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len)
52{
53 u32 val;
54 int ret = 0;
55 u32 errcnt = 0;
56 u32 i;
57
58 D_INFO("ucode inst image size is %u\n", len);
59
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 IL_DL_IO is set */
64 il_wr(il, HBUS_TARG_MEM_RADDR,
65 i + IL4965_RTC_INST_LOWER_BOUND);
66 val = _il_rd(il, HBUS_TARG_MEM_RDAT);
67 if (val != le32_to_cpu(*image)) {
68 ret = -EIO;
69 errcnt++;
70 if (errcnt >= 3)
71 break;
72 }
73 }
74
75 return ret;
76}
77
78/**
79 * il4965_verify_inst_full - verify runtime uCode image in card vs. host,
80 * looking at all data.
81 */
82static int il4965_verify_inst_full(struct il_priv *il, __le32 *image,
83 u32 len)
84{
85 u32 val;
86 u32 save_len = len;
87 int ret = 0;
88 u32 errcnt;
89
90 D_INFO("ucode inst image size is %u\n", len);
91
92 il_wr(il, HBUS_TARG_MEM_RADDR,
93 IL4965_RTC_INST_LOWER_BOUND);
94
95 errcnt = 0;
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 IL_DL_IO is set */
100 val = _il_rd(il, HBUS_TARG_MEM_RDAT);
101 if (val != le32_to_cpu(*image)) {
102 IL_ERR("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));
105 ret = -EIO;
106 errcnt++;
107 if (errcnt >= 20)
108 break;
109 }
110 }
111
112 if (!errcnt)
113 D_INFO(
114 "ucode image in INSTRUCTION memory is good\n");
115
116 return ret;
117}
118
119/**
120 * il4965_verify_ucode - determine which instruction image is in SRAM,
121 * and verify its contents
122 */
123int il4965_verify_ucode(struct il_priv *il)
124{
125 __le32 *image;
126 u32 len;
127 int ret;
128
129 /* Try bootstrap */
130 image = (__le32 *)il->ucode_boot.v_addr;
131 len = il->ucode_boot.len;
132 ret = il4965_verify_inst_sparse(il, image, len);
133 if (!ret) {
134 D_INFO("Bootstrap uCode is good in inst SRAM\n");
135 return 0;
136 }
137
138 /* Try initialize */
139 image = (__le32 *)il->ucode_init.v_addr;
140 len = il->ucode_init.len;
141 ret = il4965_verify_inst_sparse(il, image, len);
142 if (!ret) {
143 D_INFO("Initialize uCode is good in inst SRAM\n");
144 return 0;
145 }
146
147 /* Try runtime/protocol */
148 image = (__le32 *)il->ucode_code.v_addr;
149 len = il->ucode_code.len;
150 ret = il4965_verify_inst_sparse(il, image, len);
151 if (!ret) {
152 D_INFO("Runtime uCode is good in inst SRAM\n");
153 return 0;
154 }
155
156 IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
157
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 *)il->ucode_boot.v_addr;
162 len = il->ucode_boot.len;
163 ret = il4965_verify_inst_full(il, image, len);
164
165 return ret;
166}