diff options
author | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-08-30 06:50:25 -0400 |
---|---|---|
committer | Stanislaw Gruszka <sgruszka@redhat.com> | 2011-11-15 06:41:53 -0500 |
commit | 862d32e6db6183e5cb67fe465818578556196a94 (patch) | |
tree | f693bc0dcaf396a7918c96c79509167ed1391771 /drivers/net/wireless/iwlegacy/4965.c | |
parent | 56e7a8cca0fd9e096acd2233f0e9f95df6423071 (diff) |
iwlegacy: merge iwl-4965-ucode.c into 4965.c
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
Diffstat (limited to 'drivers/net/wireless/iwlegacy/4965.c')
-rw-r--r-- | drivers/net/wireless/iwlegacy/4965.c | 125 |
1 files changed, 125 insertions, 0 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 | */ | ||
57 | static int | ||
58 | il4965_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 | */ | ||
89 | static 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 | */ | ||
130 | int 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 |