aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/eeprom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/eeprom.c')
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index cc81482c934d..f8c5065e5f5f 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -138,6 +138,80 @@ bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data)
138 return ret; 138 return ret;
139} 139}
140 140
141int ath9k_hw_nvram_swap_data(struct ath_hw *ah, bool *swap_needed, int size)
142{
143 u16 magic;
144 u16 *eepdata;
145 int i;
146 struct ath_common *common = ath9k_hw_common(ah);
147
148 if (!ath9k_hw_nvram_read(ah, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
149 ath_err(common, "Reading Magic # failed\n");
150 return -EIO;
151 }
152
153 if (magic == AR5416_EEPROM_MAGIC) {
154 *swap_needed = false;
155 } else if (swab16(magic) == AR5416_EEPROM_MAGIC) {
156 if (ah->ah_flags & AH_NO_EEP_SWAP) {
157 ath_info(common,
158 "Ignoring endianness difference in EEPROM magic bytes.\n");
159
160 *swap_needed = false;
161 } else {
162 *swap_needed = true;
163 }
164 } else {
165 ath_err(common,
166 "Invalid EEPROM Magic (0x%04x).\n", magic);
167 return -EINVAL;
168 }
169
170 eepdata = (u16 *)(&ah->eeprom);
171
172 if (*swap_needed) {
173 ath_dbg(common, EEPROM,
174 "EEPROM Endianness is not native.. Changing.\n");
175
176 for (i = 0; i < size; i++)
177 eepdata[i] = swab16(eepdata[i]);
178 }
179
180 return 0;
181}
182
183bool ath9k_hw_nvram_validate_checksum(struct ath_hw *ah, int size)
184{
185 u32 i, sum = 0;
186 u16 *eepdata = (u16 *)(&ah->eeprom);
187 struct ath_common *common = ath9k_hw_common(ah);
188
189 for (i = 0; i < size; i++)
190 sum ^= eepdata[i];
191
192 if (sum != 0xffff) {
193 ath_err(common, "Bad EEPROM checksum 0x%x\n", sum);
194 return false;
195 }
196
197 return true;
198}
199
200bool ath9k_hw_nvram_check_version(struct ath_hw *ah, int version, int minrev)
201{
202 struct ath_common *common = ath9k_hw_common(ah);
203
204 if (ah->eep_ops->get_eeprom_ver(ah) != version ||
205 ah->eep_ops->get_eeprom_rev(ah) < minrev) {
206 ath_err(common, "Bad EEPROM VER 0x%04x or REV 0x%04x\n",
207 ah->eep_ops->get_eeprom_ver(ah),
208 ah->eep_ops->get_eeprom_rev(ah));
209 return -EINVAL;
210 }
211
212 return true;
213}
214
141void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, 215void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
142 u8 *pVpdList, u16 numIntercepts, 216 u8 *pVpdList, u16 numIntercepts,
143 u8 *pRetVpdList) 217 u8 *pRetVpdList)