phy.c 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  1. /*
  2. * Copyright (c) 2008-2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. /**
  17. * DOC: Programming Atheros 802.11n analog front end radios
  18. *
  19. * AR5416 MAC based PCI devices and AR518 MAC based PCI-Express
  20. * devices have either an external AR2133 analog front end radio for single
  21. * band 2.4 GHz communication or an AR5133 analog front end radio for dual
  22. * band 2.4 GHz / 5 GHz communication.
  23. *
  24. * All devices after the AR5416 and AR5418 family starting with the AR9280
  25. * have their analog front radios, MAC/BB and host PCIe/USB interface embedded
  26. * into a single-chip and require less programming.
  27. *
  28. * The following single-chips exist with a respective embedded radio:
  29. *
  30. * AR9280 - 11n dual-band 2x2 MIMO for PCIe
  31. * AR9281 - 11n single-band 1x2 MIMO for PCIe
  32. * AR9285 - 11n single-band 1x1 for PCIe
  33. * AR9287 - 11n single-band 2x2 MIMO for PCIe
  34. *
  35. * AR9220 - 11n dual-band 2x2 MIMO for PCI
  36. * AR9223 - 11n single-band 2x2 MIMO for PCI
  37. *
  38. * AR9287 - 11n single-band 1x1 MIMO for USB
  39. */
  40. #include "hw.h"
  41. /**
  42. * ath9k_hw_write_regs - ??
  43. *
  44. * @ah: atheros hardware structure
  45. * @freqIndex:
  46. * @regWrites:
  47. *
  48. * Used for both the chipsets with an external AR2133/AR5133 radios and
  49. * single-chip devices.
  50. */
  51. void ath9k_hw_write_regs(struct ath_hw *ah, u32 freqIndex, int regWrites)
  52. {
  53. REG_WRITE_ARRAY(&ah->iniBB_RfGain, freqIndex, regWrites);
  54. }
  55. /**
  56. * ath9k_hw_ar9280_set_channel - set channel on single-chip device
  57. * @ah: atheros hardware structure
  58. * @chan:
  59. *
  60. * This is the function to change channel on single-chip devices, that is
  61. * all devices after ar9280.
  62. *
  63. * This function takes the channel value in MHz and sets
  64. * hardware channel value. Assumes writes have been enabled to analog bus.
  65. *
  66. * Actual Expression,
  67. *
  68. * For 2GHz channel,
  69. * Channel Frequency = (3/4) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^17)
  70. * (freq_ref = 40MHz)
  71. *
  72. * For 5GHz channel,
  73. * Channel Frequency = (3/2) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^10)
  74. * (freq_ref = 40MHz/(24>>amodeRefSel))
  75. */
  76. int ath9k_hw_ar9280_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
  77. {
  78. u16 bMode, fracMode, aModeRefSel = 0;
  79. u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0;
  80. struct chan_centers centers;
  81. u32 refDivA = 24;
  82. ath9k_hw_get_channel_centers(ah, chan, &centers);
  83. freq = centers.synth_center;
  84. reg32 = REG_READ(ah, AR_PHY_SYNTH_CONTROL);
  85. reg32 &= 0xc0000000;
  86. if (freq < 4800) { /* 2 GHz, fractional mode */
  87. u32 txctl;
  88. int regWrites = 0;
  89. bMode = 1;
  90. fracMode = 1;
  91. aModeRefSel = 0;
  92. channelSel = (freq * 0x10000) / 15;
  93. if (AR_SREV_9287_11_OR_LATER(ah)) {
  94. if (freq == 2484) {
  95. /* Enable channel spreading for channel 14 */
  96. REG_WRITE_ARRAY(&ah->iniCckfirJapan2484,
  97. 1, regWrites);
  98. } else {
  99. REG_WRITE_ARRAY(&ah->iniCckfirNormal,
  100. 1, regWrites);
  101. }
  102. } else {
  103. txctl = REG_READ(ah, AR_PHY_CCK_TX_CTRL);
  104. if (freq == 2484) {
  105. /* Enable channel spreading for channel 14 */
  106. REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
  107. txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
  108. } else {
  109. REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
  110. txctl &~ AR_PHY_CCK_TX_CTRL_JAPAN);
  111. }
  112. }
  113. } else {
  114. bMode = 0;
  115. fracMode = 0;
  116. switch(ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
  117. case 0:
  118. if ((freq % 20) == 0) {
  119. aModeRefSel = 3;
  120. } else if ((freq % 10) == 0) {
  121. aModeRefSel = 2;
  122. }
  123. if (aModeRefSel)
  124. break;
  125. case 1:
  126. default:
  127. aModeRefSel = 0;
  128. /*
  129. * Enable 2G (fractional) mode for channels
  130. * which are 5MHz spaced.
  131. */
  132. fracMode = 1;
  133. refDivA = 1;
  134. channelSel = (freq * 0x8000) / 15;
  135. /* RefDivA setting */
  136. REG_RMW_FIELD(ah, AR_AN_SYNTH9,
  137. AR_AN_SYNTH9_REFDIVA, refDivA);
  138. }
  139. if (!fracMode) {
  140. ndiv = (freq * (refDivA >> aModeRefSel)) / 60;
  141. channelSel = ndiv & 0x1ff;
  142. channelFrac = (ndiv & 0xfffffe00) * 2;
  143. channelSel = (channelSel << 17) | channelFrac;
  144. }
  145. }
  146. reg32 = reg32 |
  147. (bMode << 29) |
  148. (fracMode << 28) | (aModeRefSel << 26) | (channelSel);
  149. REG_WRITE(ah, AR_PHY_SYNTH_CONTROL, reg32);
  150. ah->curchan = chan;
  151. ah->curchan_rad_index = -1;
  152. return 0;
  153. }
  154. /**
  155. * ath9k_hw_9280_spur_mitigate - convert baseband spur frequency
  156. * @ah: atheros hardware structure
  157. * @chan:
  158. *
  159. * For single-chip solutions. Converts to baseband spur frequency given the
  160. * input channel frequency and compute register settings below.
  161. */
  162. void ath9k_hw_9280_spur_mitigate(struct ath_hw *ah, struct ath9k_channel *chan)
  163. {
  164. int bb_spur = AR_NO_SPUR;
  165. int freq;
  166. int bin, cur_bin;
  167. int bb_spur_off, spur_subchannel_sd;
  168. int spur_freq_sd;
  169. int spur_delta_phase;
  170. int denominator;
  171. int upper, lower, cur_vit_mask;
  172. int tmp, newVal;
  173. int i;
  174. int pilot_mask_reg[4] = { AR_PHY_TIMING7, AR_PHY_TIMING8,
  175. AR_PHY_PILOT_MASK_01_30, AR_PHY_PILOT_MASK_31_60
  176. };
  177. int chan_mask_reg[4] = { AR_PHY_TIMING9, AR_PHY_TIMING10,
  178. AR_PHY_CHANNEL_MASK_01_30, AR_PHY_CHANNEL_MASK_31_60
  179. };
  180. int inc[4] = { 0, 100, 0, 0 };
  181. struct chan_centers centers;
  182. int8_t mask_m[123];
  183. int8_t mask_p[123];
  184. int8_t mask_amt;
  185. int tmp_mask;
  186. int cur_bb_spur;
  187. bool is2GHz = IS_CHAN_2GHZ(chan);
  188. memset(&mask_m, 0, sizeof(int8_t) * 123);
  189. memset(&mask_p, 0, sizeof(int8_t) * 123);
  190. ath9k_hw_get_channel_centers(ah, chan, &centers);
  191. freq = centers.synth_center;
  192. ah->config.spurmode = SPUR_ENABLE_EEPROM;
  193. for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  194. cur_bb_spur = ah->eep_ops->get_spur_channel(ah, i, is2GHz);
  195. if (is2GHz)
  196. cur_bb_spur = (cur_bb_spur / 10) + AR_BASE_FREQ_2GHZ;
  197. else
  198. cur_bb_spur = (cur_bb_spur / 10) + AR_BASE_FREQ_5GHZ;
  199. if (AR_NO_SPUR == cur_bb_spur)
  200. break;
  201. cur_bb_spur = cur_bb_spur - freq;
  202. if (IS_CHAN_HT40(chan)) {
  203. if ((cur_bb_spur > -AR_SPUR_FEEQ_BOUND_HT40) &&
  204. (cur_bb_spur < AR_SPUR_FEEQ_BOUND_HT40)) {
  205. bb_spur = cur_bb_spur;
  206. break;
  207. }
  208. } else if ((cur_bb_spur > -AR_SPUR_FEEQ_BOUND_HT20) &&
  209. (cur_bb_spur < AR_SPUR_FEEQ_BOUND_HT20)) {
  210. bb_spur = cur_bb_spur;
  211. break;
  212. }
  213. }
  214. if (AR_NO_SPUR == bb_spur) {
  215. REG_CLR_BIT(ah, AR_PHY_FORCE_CLKEN_CCK,
  216. AR_PHY_FORCE_CLKEN_CCK_MRC_MUX);
  217. return;
  218. } else {
  219. REG_CLR_BIT(ah, AR_PHY_FORCE_CLKEN_CCK,
  220. AR_PHY_FORCE_CLKEN_CCK_MRC_MUX);
  221. }
  222. bin = bb_spur * 320;
  223. tmp = REG_READ(ah, AR_PHY_TIMING_CTRL4(0));
  224. newVal = tmp | (AR_PHY_TIMING_CTRL4_ENABLE_SPUR_RSSI |
  225. AR_PHY_TIMING_CTRL4_ENABLE_SPUR_FILTER |
  226. AR_PHY_TIMING_CTRL4_ENABLE_CHAN_MASK |
  227. AR_PHY_TIMING_CTRL4_ENABLE_PILOT_MASK);
  228. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0), newVal);
  229. newVal = (AR_PHY_SPUR_REG_MASK_RATE_CNTL |
  230. AR_PHY_SPUR_REG_ENABLE_MASK_PPM |
  231. AR_PHY_SPUR_REG_MASK_RATE_SELECT |
  232. AR_PHY_SPUR_REG_ENABLE_VIT_SPUR_RSSI |
  233. SM(SPUR_RSSI_THRESH, AR_PHY_SPUR_REG_SPUR_RSSI_THRESH));
  234. REG_WRITE(ah, AR_PHY_SPUR_REG, newVal);
  235. if (IS_CHAN_HT40(chan)) {
  236. if (bb_spur < 0) {
  237. spur_subchannel_sd = 1;
  238. bb_spur_off = bb_spur + 10;
  239. } else {
  240. spur_subchannel_sd = 0;
  241. bb_spur_off = bb_spur - 10;
  242. }
  243. } else {
  244. spur_subchannel_sd = 0;
  245. bb_spur_off = bb_spur;
  246. }
  247. if (IS_CHAN_HT40(chan))
  248. spur_delta_phase =
  249. ((bb_spur * 262144) /
  250. 10) & AR_PHY_TIMING11_SPUR_DELTA_PHASE;
  251. else
  252. spur_delta_phase =
  253. ((bb_spur * 524288) /
  254. 10) & AR_PHY_TIMING11_SPUR_DELTA_PHASE;
  255. denominator = IS_CHAN_2GHZ(chan) ? 44 : 40;
  256. spur_freq_sd = ((bb_spur_off * 2048) / denominator) & 0x3ff;
  257. newVal = (AR_PHY_TIMING11_USE_SPUR_IN_AGC |
  258. SM(spur_freq_sd, AR_PHY_TIMING11_SPUR_FREQ_SD) |
  259. SM(spur_delta_phase, AR_PHY_TIMING11_SPUR_DELTA_PHASE));
  260. REG_WRITE(ah, AR_PHY_TIMING11, newVal);
  261. newVal = spur_subchannel_sd << AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S;
  262. REG_WRITE(ah, AR_PHY_SFCORR_EXT, newVal);
  263. cur_bin = -6000;
  264. upper = bin + 100;
  265. lower = bin - 100;
  266. for (i = 0; i < 4; i++) {
  267. int pilot_mask = 0;
  268. int chan_mask = 0;
  269. int bp = 0;
  270. for (bp = 0; bp < 30; bp++) {
  271. if ((cur_bin > lower) && (cur_bin < upper)) {
  272. pilot_mask = pilot_mask | 0x1 << bp;
  273. chan_mask = chan_mask | 0x1 << bp;
  274. }
  275. cur_bin += 100;
  276. }
  277. cur_bin += inc[i];
  278. REG_WRITE(ah, pilot_mask_reg[i], pilot_mask);
  279. REG_WRITE(ah, chan_mask_reg[i], chan_mask);
  280. }
  281. cur_vit_mask = 6100;
  282. upper = bin + 120;
  283. lower = bin - 120;
  284. for (i = 0; i < 123; i++) {
  285. if ((cur_vit_mask > lower) && (cur_vit_mask < upper)) {
  286. /* workaround for gcc bug #37014 */
  287. volatile int tmp_v = abs(cur_vit_mask - bin);
  288. if (tmp_v < 75)
  289. mask_amt = 1;
  290. else
  291. mask_amt = 0;
  292. if (cur_vit_mask < 0)
  293. mask_m[abs(cur_vit_mask / 100)] = mask_amt;
  294. else
  295. mask_p[cur_vit_mask / 100] = mask_amt;
  296. }
  297. cur_vit_mask -= 100;
  298. }
  299. tmp_mask = (mask_m[46] << 30) | (mask_m[47] << 28)
  300. | (mask_m[48] << 26) | (mask_m[49] << 24)
  301. | (mask_m[50] << 22) | (mask_m[51] << 20)
  302. | (mask_m[52] << 18) | (mask_m[53] << 16)
  303. | (mask_m[54] << 14) | (mask_m[55] << 12)
  304. | (mask_m[56] << 10) | (mask_m[57] << 8)
  305. | (mask_m[58] << 6) | (mask_m[59] << 4)
  306. | (mask_m[60] << 2) | (mask_m[61] << 0);
  307. REG_WRITE(ah, AR_PHY_BIN_MASK_1, tmp_mask);
  308. REG_WRITE(ah, AR_PHY_VIT_MASK2_M_46_61, tmp_mask);
  309. tmp_mask = (mask_m[31] << 28)
  310. | (mask_m[32] << 26) | (mask_m[33] << 24)
  311. | (mask_m[34] << 22) | (mask_m[35] << 20)
  312. | (mask_m[36] << 18) | (mask_m[37] << 16)
  313. | (mask_m[48] << 14) | (mask_m[39] << 12)
  314. | (mask_m[40] << 10) | (mask_m[41] << 8)
  315. | (mask_m[42] << 6) | (mask_m[43] << 4)
  316. | (mask_m[44] << 2) | (mask_m[45] << 0);
  317. REG_WRITE(ah, AR_PHY_BIN_MASK_2, tmp_mask);
  318. REG_WRITE(ah, AR_PHY_MASK2_M_31_45, tmp_mask);
  319. tmp_mask = (mask_m[16] << 30) | (mask_m[16] << 28)
  320. | (mask_m[18] << 26) | (mask_m[18] << 24)
  321. | (mask_m[20] << 22) | (mask_m[20] << 20)
  322. | (mask_m[22] << 18) | (mask_m[22] << 16)
  323. | (mask_m[24] << 14) | (mask_m[24] << 12)
  324. | (mask_m[25] << 10) | (mask_m[26] << 8)
  325. | (mask_m[27] << 6) | (mask_m[28] << 4)
  326. | (mask_m[29] << 2) | (mask_m[30] << 0);
  327. REG_WRITE(ah, AR_PHY_BIN_MASK_3, tmp_mask);
  328. REG_WRITE(ah, AR_PHY_MASK2_M_16_30, tmp_mask);
  329. tmp_mask = (mask_m[0] << 30) | (mask_m[1] << 28)
  330. | (mask_m[2] << 26) | (mask_m[3] << 24)
  331. | (mask_m[4] << 22) | (mask_m[5] << 20)
  332. | (mask_m[6] << 18) | (mask_m[7] << 16)
  333. | (mask_m[8] << 14) | (mask_m[9] << 12)
  334. | (mask_m[10] << 10) | (mask_m[11] << 8)
  335. | (mask_m[12] << 6) | (mask_m[13] << 4)
  336. | (mask_m[14] << 2) | (mask_m[15] << 0);
  337. REG_WRITE(ah, AR_PHY_MASK_CTL, tmp_mask);
  338. REG_WRITE(ah, AR_PHY_MASK2_M_00_15, tmp_mask);
  339. tmp_mask = (mask_p[15] << 28)
  340. | (mask_p[14] << 26) | (mask_p[13] << 24)
  341. | (mask_p[12] << 22) | (mask_p[11] << 20)
  342. | (mask_p[10] << 18) | (mask_p[9] << 16)
  343. | (mask_p[8] << 14) | (mask_p[7] << 12)
  344. | (mask_p[6] << 10) | (mask_p[5] << 8)
  345. | (mask_p[4] << 6) | (mask_p[3] << 4)
  346. | (mask_p[2] << 2) | (mask_p[1] << 0);
  347. REG_WRITE(ah, AR_PHY_BIN_MASK2_1, tmp_mask);
  348. REG_WRITE(ah, AR_PHY_MASK2_P_15_01, tmp_mask);
  349. tmp_mask = (mask_p[30] << 28)
  350. | (mask_p[29] << 26) | (mask_p[28] << 24)
  351. | (mask_p[27] << 22) | (mask_p[26] << 20)
  352. | (mask_p[25] << 18) | (mask_p[24] << 16)
  353. | (mask_p[23] << 14) | (mask_p[22] << 12)
  354. | (mask_p[21] << 10) | (mask_p[20] << 8)
  355. | (mask_p[19] << 6) | (mask_p[18] << 4)
  356. | (mask_p[17] << 2) | (mask_p[16] << 0);
  357. REG_WRITE(ah, AR_PHY_BIN_MASK2_2, tmp_mask);
  358. REG_WRITE(ah, AR_PHY_MASK2_P_30_16, tmp_mask);
  359. tmp_mask = (mask_p[45] << 28)
  360. | (mask_p[44] << 26) | (mask_p[43] << 24)
  361. | (mask_p[42] << 22) | (mask_p[41] << 20)
  362. | (mask_p[40] << 18) | (mask_p[39] << 16)
  363. | (mask_p[38] << 14) | (mask_p[37] << 12)
  364. | (mask_p[36] << 10) | (mask_p[35] << 8)
  365. | (mask_p[34] << 6) | (mask_p[33] << 4)
  366. | (mask_p[32] << 2) | (mask_p[31] << 0);
  367. REG_WRITE(ah, AR_PHY_BIN_MASK2_3, tmp_mask);
  368. REG_WRITE(ah, AR_PHY_MASK2_P_45_31, tmp_mask);
  369. tmp_mask = (mask_p[61] << 30) | (mask_p[60] << 28)
  370. | (mask_p[59] << 26) | (mask_p[58] << 24)
  371. | (mask_p[57] << 22) | (mask_p[56] << 20)
  372. | (mask_p[55] << 18) | (mask_p[54] << 16)
  373. | (mask_p[53] << 14) | (mask_p[52] << 12)
  374. | (mask_p[51] << 10) | (mask_p[50] << 8)
  375. | (mask_p[49] << 6) | (mask_p[48] << 4)
  376. | (mask_p[47] << 2) | (mask_p[46] << 0);
  377. REG_WRITE(ah, AR_PHY_BIN_MASK2_4, tmp_mask);
  378. REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask);
  379. }
  380. /* All code below is for non single-chip solutions */
  381. /**
  382. * ath9k_phy_modify_rx_buffer() - perform analog swizzling of parameters
  383. * @rfbuf:
  384. * @reg32:
  385. * @numBits:
  386. * @firstBit:
  387. * @column:
  388. *
  389. * Performs analog "swizzling" of parameters into their location.
  390. * Used on external AR2133/AR5133 radios.
  391. */
  392. static void ath9k_phy_modify_rx_buffer(u32 *rfBuf, u32 reg32,
  393. u32 numBits, u32 firstBit,
  394. u32 column)
  395. {
  396. u32 tmp32, mask, arrayEntry, lastBit;
  397. int32_t bitPosition, bitsLeft;
  398. tmp32 = ath9k_hw_reverse_bits(reg32, numBits);
  399. arrayEntry = (firstBit - 1) / 8;
  400. bitPosition = (firstBit - 1) % 8;
  401. bitsLeft = numBits;
  402. while (bitsLeft > 0) {
  403. lastBit = (bitPosition + bitsLeft > 8) ?
  404. 8 : bitPosition + bitsLeft;
  405. mask = (((1 << lastBit) - 1) ^ ((1 << bitPosition) - 1)) <<
  406. (column * 8);
  407. rfBuf[arrayEntry] &= ~mask;
  408. rfBuf[arrayEntry] |= ((tmp32 << bitPosition) <<
  409. (column * 8)) & mask;
  410. bitsLeft -= 8 - bitPosition;
  411. tmp32 = tmp32 >> (8 - bitPosition);
  412. bitPosition = 0;
  413. arrayEntry++;
  414. }
  415. }
  416. /*
  417. * Fix on 2.4 GHz band for orientation sensitivity issue by increasing
  418. * rf_pwd_icsyndiv.
  419. *
  420. * Theoretical Rules:
  421. * if 2 GHz band
  422. * if forceBiasAuto
  423. * if synth_freq < 2412
  424. * bias = 0
  425. * else if 2412 <= synth_freq <= 2422
  426. * bias = 1
  427. * else // synth_freq > 2422
  428. * bias = 2
  429. * else if forceBias > 0
  430. * bias = forceBias & 7
  431. * else
  432. * no change, use value from ini file
  433. * else
  434. * no change, invalid band
  435. *
  436. * 1st Mod:
  437. * 2422 also uses value of 2
  438. * <approved>
  439. *
  440. * 2nd Mod:
  441. * Less than 2412 uses value of 0, 2412 and above uses value of 2
  442. */
  443. static void ath9k_hw_force_bias(struct ath_hw *ah, u16 synth_freq)
  444. {
  445. struct ath_common *common = ath9k_hw_common(ah);
  446. u32 tmp_reg;
  447. int reg_writes = 0;
  448. u32 new_bias = 0;
  449. if (!AR_SREV_5416(ah) || synth_freq >= 3000) {
  450. return;
  451. }
  452. BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
  453. if (synth_freq < 2412)
  454. new_bias = 0;
  455. else if (synth_freq < 2422)
  456. new_bias = 1;
  457. else
  458. new_bias = 2;
  459. /* pre-reverse this field */
  460. tmp_reg = ath9k_hw_reverse_bits(new_bias, 3);
  461. ath_print(common, ATH_DBG_CONFIG,
  462. "Force rf_pwd_icsyndiv to %1d on %4d\n",
  463. new_bias, synth_freq);
  464. /* swizzle rf_pwd_icsyndiv */
  465. ath9k_phy_modify_rx_buffer(ah->analogBank6Data, tmp_reg, 3, 181, 3);
  466. /* write Bank 6 with new params */
  467. REG_WRITE_RF_ARRAY(&ah->iniBank6, ah->analogBank6Data, reg_writes);
  468. }
  469. /**
  470. * ath9k_hw_set_channel - tune to a channel on the external AR2133/AR5133 radios
  471. * @ah: atheros hardware stucture
  472. * @chan:
  473. *
  474. * For the external AR2133/AR5133 radios, takes the MHz channel value and set
  475. * the channel value. Assumes writes enabled to analog bus and bank6 register
  476. * cache in ah->analogBank6Data.
  477. */
  478. int ath9k_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
  479. {
  480. struct ath_common *common = ath9k_hw_common(ah);
  481. u32 channelSel = 0;
  482. u32 bModeSynth = 0;
  483. u32 aModeRefSel = 0;
  484. u32 reg32 = 0;
  485. u16 freq;
  486. struct chan_centers centers;
  487. ath9k_hw_get_channel_centers(ah, chan, &centers);
  488. freq = centers.synth_center;
  489. if (freq < 4800) {
  490. u32 txctl;
  491. if (((freq - 2192) % 5) == 0) {
  492. channelSel = ((freq - 672) * 2 - 3040) / 10;
  493. bModeSynth = 0;
  494. } else if (((freq - 2224) % 5) == 0) {
  495. channelSel = ((freq - 704) * 2 - 3040) / 10;
  496. bModeSynth = 1;
  497. } else {
  498. ath_print(common, ATH_DBG_FATAL,
  499. "Invalid channel %u MHz\n", freq);
  500. return -EINVAL;
  501. }
  502. channelSel = (channelSel << 2) & 0xff;
  503. channelSel = ath9k_hw_reverse_bits(channelSel, 8);
  504. txctl = REG_READ(ah, AR_PHY_CCK_TX_CTRL);
  505. if (freq == 2484) {
  506. REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
  507. txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
  508. } else {
  509. REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
  510. txctl & ~AR_PHY_CCK_TX_CTRL_JAPAN);
  511. }
  512. } else if ((freq % 20) == 0 && freq >= 5120) {
  513. channelSel =
  514. ath9k_hw_reverse_bits(((freq - 4800) / 20 << 2), 8);
  515. aModeRefSel = ath9k_hw_reverse_bits(1, 2);
  516. } else if ((freq % 10) == 0) {
  517. channelSel =
  518. ath9k_hw_reverse_bits(((freq - 4800) / 10 << 1), 8);
  519. if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah))
  520. aModeRefSel = ath9k_hw_reverse_bits(2, 2);
  521. else
  522. aModeRefSel = ath9k_hw_reverse_bits(1, 2);
  523. } else if ((freq % 5) == 0) {
  524. channelSel = ath9k_hw_reverse_bits((freq - 4800) / 5, 8);
  525. aModeRefSel = ath9k_hw_reverse_bits(1, 2);
  526. } else {
  527. ath_print(common, ATH_DBG_FATAL,
  528. "Invalid channel %u MHz\n", freq);
  529. return -EINVAL;
  530. }
  531. ath9k_hw_force_bias(ah, freq);
  532. reg32 =
  533. (channelSel << 8) | (aModeRefSel << 2) | (bModeSynth << 1) |
  534. (1 << 5) | 0x1;
  535. REG_WRITE(ah, AR_PHY(0x37), reg32);
  536. ah->curchan = chan;
  537. ah->curchan_rad_index = -1;
  538. return 0;
  539. }
  540. /**
  541. * ath9k_hw_spur_mitigate - convert baseband spur frequency for external radios
  542. * @ah: atheros hardware structure
  543. * @chan:
  544. *
  545. * For non single-chip solutions. Converts to baseband spur frequency given the
  546. * input channel frequency and compute register settings below.
  547. */
  548. void ath9k_hw_spur_mitigate(struct ath_hw *ah, struct ath9k_channel *chan)
  549. {
  550. int bb_spur = AR_NO_SPUR;
  551. int bin, cur_bin;
  552. int spur_freq_sd;
  553. int spur_delta_phase;
  554. int denominator;
  555. int upper, lower, cur_vit_mask;
  556. int tmp, new;
  557. int i;
  558. int pilot_mask_reg[4] = { AR_PHY_TIMING7, AR_PHY_TIMING8,
  559. AR_PHY_PILOT_MASK_01_30, AR_PHY_PILOT_MASK_31_60
  560. };
  561. int chan_mask_reg[4] = { AR_PHY_TIMING9, AR_PHY_TIMING10,
  562. AR_PHY_CHANNEL_MASK_01_30, AR_PHY_CHANNEL_MASK_31_60
  563. };
  564. int inc[4] = { 0, 100, 0, 0 };
  565. int8_t mask_m[123];
  566. int8_t mask_p[123];
  567. int8_t mask_amt;
  568. int tmp_mask;
  569. int cur_bb_spur;
  570. bool is2GHz = IS_CHAN_2GHZ(chan);
  571. memset(&mask_m, 0, sizeof(int8_t) * 123);
  572. memset(&mask_p, 0, sizeof(int8_t) * 123);
  573. for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  574. cur_bb_spur = ah->eep_ops->get_spur_channel(ah, i, is2GHz);
  575. if (AR_NO_SPUR == cur_bb_spur)
  576. break;
  577. cur_bb_spur = cur_bb_spur - (chan->channel * 10);
  578. if ((cur_bb_spur > -95) && (cur_bb_spur < 95)) {
  579. bb_spur = cur_bb_spur;
  580. break;
  581. }
  582. }
  583. if (AR_NO_SPUR == bb_spur)
  584. return;
  585. bin = bb_spur * 32;
  586. tmp = REG_READ(ah, AR_PHY_TIMING_CTRL4(0));
  587. new = tmp | (AR_PHY_TIMING_CTRL4_ENABLE_SPUR_RSSI |
  588. AR_PHY_TIMING_CTRL4_ENABLE_SPUR_FILTER |
  589. AR_PHY_TIMING_CTRL4_ENABLE_CHAN_MASK |
  590. AR_PHY_TIMING_CTRL4_ENABLE_PILOT_MASK);
  591. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0), new);
  592. new = (AR_PHY_SPUR_REG_MASK_RATE_CNTL |
  593. AR_PHY_SPUR_REG_ENABLE_MASK_PPM |
  594. AR_PHY_SPUR_REG_MASK_RATE_SELECT |
  595. AR_PHY_SPUR_REG_ENABLE_VIT_SPUR_RSSI |
  596. SM(SPUR_RSSI_THRESH, AR_PHY_SPUR_REG_SPUR_RSSI_THRESH));
  597. REG_WRITE(ah, AR_PHY_SPUR_REG, new);
  598. spur_delta_phase = ((bb_spur * 524288) / 100) &
  599. AR_PHY_TIMING11_SPUR_DELTA_PHASE;
  600. denominator = IS_CHAN_2GHZ(chan) ? 440 : 400;
  601. spur_freq_sd = ((bb_spur * 2048) / denominator) & 0x3ff;
  602. new = (AR_PHY_TIMING11_USE_SPUR_IN_AGC |
  603. SM(spur_freq_sd, AR_PHY_TIMING11_SPUR_FREQ_SD) |
  604. SM(spur_delta_phase, AR_PHY_TIMING11_SPUR_DELTA_PHASE));
  605. REG_WRITE(ah, AR_PHY_TIMING11, new);
  606. cur_bin = -6000;
  607. upper = bin + 100;
  608. lower = bin - 100;
  609. for (i = 0; i < 4; i++) {
  610. int pilot_mask = 0;
  611. int chan_mask = 0;
  612. int bp = 0;
  613. for (bp = 0; bp < 30; bp++) {
  614. if ((cur_bin > lower) && (cur_bin < upper)) {
  615. pilot_mask = pilot_mask | 0x1 << bp;
  616. chan_mask = chan_mask | 0x1 << bp;
  617. }
  618. cur_bin += 100;
  619. }
  620. cur_bin += inc[i];
  621. REG_WRITE(ah, pilot_mask_reg[i], pilot_mask);
  622. REG_WRITE(ah, chan_mask_reg[i], chan_mask);
  623. }
  624. cur_vit_mask = 6100;
  625. upper = bin + 120;
  626. lower = bin - 120;
  627. for (i = 0; i < 123; i++) {
  628. if ((cur_vit_mask > lower) && (cur_vit_mask < upper)) {
  629. /* workaround for gcc bug #37014 */
  630. volatile int tmp_v = abs(cur_vit_mask - bin);
  631. if (tmp_v < 75)
  632. mask_amt = 1;
  633. else
  634. mask_amt = 0;
  635. if (cur_vit_mask < 0)
  636. mask_m[abs(cur_vit_mask / 100)] = mask_amt;
  637. else
  638. mask_p[cur_vit_mask / 100] = mask_amt;
  639. }
  640. cur_vit_mask -= 100;
  641. }
  642. tmp_mask = (mask_m[46] << 30) | (mask_m[47] << 28)
  643. | (mask_m[48] << 26) | (mask_m[49] << 24)
  644. | (mask_m[50] << 22) | (mask_m[51] << 20)
  645. | (mask_m[52] << 18) | (mask_m[53] << 16)
  646. | (mask_m[54] << 14) | (mask_m[55] << 12)
  647. | (mask_m[56] << 10) | (mask_m[57] << 8)
  648. | (mask_m[58] << 6) | (mask_m[59] << 4)
  649. | (mask_m[60] << 2) | (mask_m[61] << 0);
  650. REG_WRITE(ah, AR_PHY_BIN_MASK_1, tmp_mask);
  651. REG_WRITE(ah, AR_PHY_VIT_MASK2_M_46_61, tmp_mask);
  652. tmp_mask = (mask_m[31] << 28)
  653. | (mask_m[32] << 26) | (mask_m[33] << 24)
  654. | (mask_m[34] << 22) | (mask_m[35] << 20)
  655. | (mask_m[36] << 18) | (mask_m[37] << 16)
  656. | (mask_m[48] << 14) | (mask_m[39] << 12)
  657. | (mask_m[40] << 10) | (mask_m[41] << 8)
  658. | (mask_m[42] << 6) | (mask_m[43] << 4)
  659. | (mask_m[44] << 2) | (mask_m[45] << 0);
  660. REG_WRITE(ah, AR_PHY_BIN_MASK_2, tmp_mask);
  661. REG_WRITE(ah, AR_PHY_MASK2_M_31_45, tmp_mask);
  662. tmp_mask = (mask_m[16] << 30) | (mask_m[16] << 28)
  663. | (mask_m[18] << 26) | (mask_m[18] << 24)
  664. | (mask_m[20] << 22) | (mask_m[20] << 20)
  665. | (mask_m[22] << 18) | (mask_m[22] << 16)
  666. | (mask_m[24] << 14) | (mask_m[24] << 12)
  667. | (mask_m[25] << 10) | (mask_m[26] << 8)
  668. | (mask_m[27] << 6) | (mask_m[28] << 4)
  669. | (mask_m[29] << 2) | (mask_m[30] << 0);
  670. REG_WRITE(ah, AR_PHY_BIN_MASK_3, tmp_mask);
  671. REG_WRITE(ah, AR_PHY_MASK2_M_16_30, tmp_mask);
  672. tmp_mask = (mask_m[0] << 30) | (mask_m[1] << 28)
  673. | (mask_m[2] << 26) | (mask_m[3] << 24)
  674. | (mask_m[4] << 22) | (mask_m[5] << 20)
  675. | (mask_m[6] << 18) | (mask_m[7] << 16)
  676. | (mask_m[8] << 14) | (mask_m[9] << 12)
  677. | (mask_m[10] << 10) | (mask_m[11] << 8)
  678. | (mask_m[12] << 6) | (mask_m[13] << 4)
  679. | (mask_m[14] << 2) | (mask_m[15] << 0);
  680. REG_WRITE(ah, AR_PHY_MASK_CTL, tmp_mask);
  681. REG_WRITE(ah, AR_PHY_MASK2_M_00_15, tmp_mask);
  682. tmp_mask = (mask_p[15] << 28)
  683. | (mask_p[14] << 26) | (mask_p[13] << 24)
  684. | (mask_p[12] << 22) | (mask_p[11] << 20)
  685. | (mask_p[10] << 18) | (mask_p[9] << 16)
  686. | (mask_p[8] << 14) | (mask_p[7] << 12)
  687. | (mask_p[6] << 10) | (mask_p[5] << 8)
  688. | (mask_p[4] << 6) | (mask_p[3] << 4)
  689. | (mask_p[2] << 2) | (mask_p[1] << 0);
  690. REG_WRITE(ah, AR_PHY_BIN_MASK2_1, tmp_mask);
  691. REG_WRITE(ah, AR_PHY_MASK2_P_15_01, tmp_mask);
  692. tmp_mask = (mask_p[30] << 28)
  693. | (mask_p[29] << 26) | (mask_p[28] << 24)
  694. | (mask_p[27] << 22) | (mask_p[26] << 20)
  695. | (mask_p[25] << 18) | (mask_p[24] << 16)
  696. | (mask_p[23] << 14) | (mask_p[22] << 12)
  697. | (mask_p[21] << 10) | (mask_p[20] << 8)
  698. | (mask_p[19] << 6) | (mask_p[18] << 4)
  699. | (mask_p[17] << 2) | (mask_p[16] << 0);
  700. REG_WRITE(ah, AR_PHY_BIN_MASK2_2, tmp_mask);
  701. REG_WRITE(ah, AR_PHY_MASK2_P_30_16, tmp_mask);
  702. tmp_mask = (mask_p[45] << 28)
  703. | (mask_p[44] << 26) | (mask_p[43] << 24)
  704. | (mask_p[42] << 22) | (mask_p[41] << 20)
  705. | (mask_p[40] << 18) | (mask_p[39] << 16)
  706. | (mask_p[38] << 14) | (mask_p[37] << 12)
  707. | (mask_p[36] << 10) | (mask_p[35] << 8)
  708. | (mask_p[34] << 6) | (mask_p[33] << 4)
  709. | (mask_p[32] << 2) | (mask_p[31] << 0);
  710. REG_WRITE(ah, AR_PHY_BIN_MASK2_3, tmp_mask);
  711. REG_WRITE(ah, AR_PHY_MASK2_P_45_31, tmp_mask);
  712. tmp_mask = (mask_p[61] << 30) | (mask_p[60] << 28)
  713. | (mask_p[59] << 26) | (mask_p[58] << 24)
  714. | (mask_p[57] << 22) | (mask_p[56] << 20)
  715. | (mask_p[55] << 18) | (mask_p[54] << 16)
  716. | (mask_p[53] << 14) | (mask_p[52] << 12)
  717. | (mask_p[51] << 10) | (mask_p[50] << 8)
  718. | (mask_p[49] << 6) | (mask_p[48] << 4)
  719. | (mask_p[47] << 2) | (mask_p[46] << 0);
  720. REG_WRITE(ah, AR_PHY_BIN_MASK2_4, tmp_mask);
  721. REG_WRITE(ah, AR_PHY_MASK2_P_61_45, tmp_mask);
  722. }
  723. /**
  724. * ath9k_hw_rf_alloc_ext_banks - allocates banks for external radio programming
  725. * @ah: atheros hardware structure
  726. *
  727. * Only required for older devices with external AR2133/AR5133 radios.
  728. */
  729. int ath9k_hw_rf_alloc_ext_banks(struct ath_hw *ah)
  730. {
  731. #define ATH_ALLOC_BANK(bank, size) do { \
  732. bank = kzalloc((sizeof(u32) * size), GFP_KERNEL); \
  733. if (!bank) { \
  734. ath_print(common, ATH_DBG_FATAL, \
  735. "Cannot allocate RF banks\n"); \
  736. return -ENOMEM; \
  737. } \
  738. } while (0);
  739. struct ath_common *common = ath9k_hw_common(ah);
  740. BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
  741. ATH_ALLOC_BANK(ah->analogBank0Data, ah->iniBank0.ia_rows);
  742. ATH_ALLOC_BANK(ah->analogBank1Data, ah->iniBank1.ia_rows);
  743. ATH_ALLOC_BANK(ah->analogBank2Data, ah->iniBank2.ia_rows);
  744. ATH_ALLOC_BANK(ah->analogBank3Data, ah->iniBank3.ia_rows);
  745. ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
  746. ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
  747. ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
  748. ATH_ALLOC_BANK(ah->addac5416_21,
  749. ah->iniAddac.ia_rows * ah->iniAddac.ia_columns);
  750. ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
  751. return 0;
  752. #undef ATH_ALLOC_BANK
  753. }
  754. /**
  755. * ath9k_hw_rf_free_ext_banks - Free memory for analog bank scratch buffers
  756. * @ah: atheros hardware struture
  757. * For the external AR2133/AR5133 radios banks.
  758. */
  759. void
  760. ath9k_hw_rf_free_ext_banks(struct ath_hw *ah)
  761. {
  762. #define ATH_FREE_BANK(bank) do { \
  763. kfree(bank); \
  764. bank = NULL; \
  765. } while (0);
  766. BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
  767. ATH_FREE_BANK(ah->analogBank0Data);
  768. ATH_FREE_BANK(ah->analogBank1Data);
  769. ATH_FREE_BANK(ah->analogBank2Data);
  770. ATH_FREE_BANK(ah->analogBank3Data);
  771. ATH_FREE_BANK(ah->analogBank6Data);
  772. ATH_FREE_BANK(ah->analogBank6TPCData);
  773. ATH_FREE_BANK(ah->analogBank7Data);
  774. ATH_FREE_BANK(ah->addac5416_21);
  775. ATH_FREE_BANK(ah->bank6Temp);
  776. #undef ATH_FREE_BANK
  777. }
  778. /* *
  779. * ath9k_hw_set_rf_regs - programs rf registers based on EEPROM
  780. * @ah: atheros hardware structure
  781. * @chan:
  782. * @modesIndex:
  783. *
  784. * Used for the external AR2133/AR5133 radios.
  785. *
  786. * Reads the EEPROM header info from the device structure and programs
  787. * all rf registers. This routine requires access to the analog
  788. * rf device. This is not required for single-chip devices.
  789. */
  790. bool ath9k_hw_set_rf_regs(struct ath_hw *ah, struct ath9k_channel *chan,
  791. u16 modesIndex)
  792. {
  793. u32 eepMinorRev;
  794. u32 ob5GHz = 0, db5GHz = 0;
  795. u32 ob2GHz = 0, db2GHz = 0;
  796. int regWrites = 0;
  797. /*
  798. * Software does not need to program bank data
  799. * for single chip devices, that is AR9280 or anything
  800. * after that.
  801. */
  802. if (AR_SREV_9280_10_OR_LATER(ah))
  803. return true;
  804. /* Setup rf parameters */
  805. eepMinorRev = ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV);
  806. /* Setup Bank 0 Write */
  807. RF_BANK_SETUP(ah->analogBank0Data, &ah->iniBank0, 1);
  808. /* Setup Bank 1 Write */
  809. RF_BANK_SETUP(ah->analogBank1Data, &ah->iniBank1, 1);
  810. /* Setup Bank 2 Write */
  811. RF_BANK_SETUP(ah->analogBank2Data, &ah->iniBank2, 1);
  812. /* Setup Bank 6 Write */
  813. RF_BANK_SETUP(ah->analogBank3Data, &ah->iniBank3,
  814. modesIndex);
  815. {
  816. int i;
  817. for (i = 0; i < ah->iniBank6TPC.ia_rows; i++) {
  818. ah->analogBank6Data[i] =
  819. INI_RA(&ah->iniBank6TPC, i, modesIndex);
  820. }
  821. }
  822. /* Only the 5 or 2 GHz OB/DB need to be set for a mode */
  823. if (eepMinorRev >= 2) {
  824. if (IS_CHAN_2GHZ(chan)) {
  825. ob2GHz = ah->eep_ops->get_eeprom(ah, EEP_OB_2);
  826. db2GHz = ah->eep_ops->get_eeprom(ah, EEP_DB_2);
  827. ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
  828. ob2GHz, 3, 197, 0);
  829. ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
  830. db2GHz, 3, 194, 0);
  831. } else {
  832. ob5GHz = ah->eep_ops->get_eeprom(ah, EEP_OB_5);
  833. db5GHz = ah->eep_ops->get_eeprom(ah, EEP_DB_5);
  834. ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
  835. ob5GHz, 3, 203, 0);
  836. ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
  837. db5GHz, 3, 200, 0);
  838. }
  839. }
  840. /* Setup Bank 7 Setup */
  841. RF_BANK_SETUP(ah->analogBank7Data, &ah->iniBank7, 1);
  842. /* Write Analog registers */
  843. REG_WRITE_RF_ARRAY(&ah->iniBank0, ah->analogBank0Data,
  844. regWrites);
  845. REG_WRITE_RF_ARRAY(&ah->iniBank1, ah->analogBank1Data,
  846. regWrites);
  847. REG_WRITE_RF_ARRAY(&ah->iniBank2, ah->analogBank2Data,
  848. regWrites);
  849. REG_WRITE_RF_ARRAY(&ah->iniBank3, ah->analogBank3Data,
  850. regWrites);
  851. REG_WRITE_RF_ARRAY(&ah->iniBank6TPC, ah->analogBank6Data,
  852. regWrites);
  853. REG_WRITE_RF_ARRAY(&ah->iniBank7, ah->analogBank7Data,
  854. regWrites);
  855. return true;
  856. }