rfgain.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. /*
  2. * RF Gain optimization
  3. *
  4. * Copyright (c) 2004-2009 Reyk Floeter <reyk@openbsd.org>
  5. * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
  6. *
  7. * Permission to use, copy, modify, and distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. *
  19. */
  20. /**
  21. * struct ath5k_ini_rfgain - RF Gain table
  22. * @rfg_register: RF Gain register address
  23. * @rfg_value: Register value for 5 and 2GHz
  24. *
  25. * Mode-specific RF Gain table (64bytes) for RF5111/5112
  26. * (RF5110 only comes with AR5210 and only supports a/turbo a mode so initial
  27. * RF Gain values are included in AR5K_AR5210_INI)
  28. */
  29. struct ath5k_ini_rfgain {
  30. u16 rfg_register;
  31. u32 rfg_value[2]; /* [freq (see below)] */
  32. };
  33. /* Initial RF Gain settings for RF5111 */
  34. static const struct ath5k_ini_rfgain rfgain_5111[] = {
  35. /* 5GHz 2GHz */
  36. { AR5K_RF_GAIN(0), { 0x000001a9, 0x00000000 } },
  37. { AR5K_RF_GAIN(1), { 0x000001e9, 0x00000040 } },
  38. { AR5K_RF_GAIN(2), { 0x00000029, 0x00000080 } },
  39. { AR5K_RF_GAIN(3), { 0x00000069, 0x00000150 } },
  40. { AR5K_RF_GAIN(4), { 0x00000199, 0x00000190 } },
  41. { AR5K_RF_GAIN(5), { 0x000001d9, 0x000001d0 } },
  42. { AR5K_RF_GAIN(6), { 0x00000019, 0x00000010 } },
  43. { AR5K_RF_GAIN(7), { 0x00000059, 0x00000044 } },
  44. { AR5K_RF_GAIN(8), { 0x00000099, 0x00000084 } },
  45. { AR5K_RF_GAIN(9), { 0x000001a5, 0x00000148 } },
  46. { AR5K_RF_GAIN(10), { 0x000001e5, 0x00000188 } },
  47. { AR5K_RF_GAIN(11), { 0x00000025, 0x000001c8 } },
  48. { AR5K_RF_GAIN(12), { 0x000001c8, 0x00000014 } },
  49. { AR5K_RF_GAIN(13), { 0x00000008, 0x00000042 } },
  50. { AR5K_RF_GAIN(14), { 0x00000048, 0x00000082 } },
  51. { AR5K_RF_GAIN(15), { 0x00000088, 0x00000178 } },
  52. { AR5K_RF_GAIN(16), { 0x00000198, 0x000001b8 } },
  53. { AR5K_RF_GAIN(17), { 0x000001d8, 0x000001f8 } },
  54. { AR5K_RF_GAIN(18), { 0x00000018, 0x00000012 } },
  55. { AR5K_RF_GAIN(19), { 0x00000058, 0x00000052 } },
  56. { AR5K_RF_GAIN(20), { 0x00000098, 0x00000092 } },
  57. { AR5K_RF_GAIN(21), { 0x000001a4, 0x0000017c } },
  58. { AR5K_RF_GAIN(22), { 0x000001e4, 0x000001bc } },
  59. { AR5K_RF_GAIN(23), { 0x00000024, 0x000001fc } },
  60. { AR5K_RF_GAIN(24), { 0x00000064, 0x0000000a } },
  61. { AR5K_RF_GAIN(25), { 0x000000a4, 0x0000004a } },
  62. { AR5K_RF_GAIN(26), { 0x000000e4, 0x0000008a } },
  63. { AR5K_RF_GAIN(27), { 0x0000010a, 0x0000015a } },
  64. { AR5K_RF_GAIN(28), { 0x0000014a, 0x0000019a } },
  65. { AR5K_RF_GAIN(29), { 0x0000018a, 0x000001da } },
  66. { AR5K_RF_GAIN(30), { 0x000001ca, 0x0000000e } },
  67. { AR5K_RF_GAIN(31), { 0x0000000a, 0x0000004e } },
  68. { AR5K_RF_GAIN(32), { 0x0000004a, 0x0000008e } },
  69. { AR5K_RF_GAIN(33), { 0x0000008a, 0x0000015e } },
  70. { AR5K_RF_GAIN(34), { 0x000001ba, 0x0000019e } },
  71. { AR5K_RF_GAIN(35), { 0x000001fa, 0x000001de } },
  72. { AR5K_RF_GAIN(36), { 0x0000003a, 0x00000009 } },
  73. { AR5K_RF_GAIN(37), { 0x0000007a, 0x00000049 } },
  74. { AR5K_RF_GAIN(38), { 0x00000186, 0x00000089 } },
  75. { AR5K_RF_GAIN(39), { 0x000001c6, 0x00000179 } },
  76. { AR5K_RF_GAIN(40), { 0x00000006, 0x000001b9 } },
  77. { AR5K_RF_GAIN(41), { 0x00000046, 0x000001f9 } },
  78. { AR5K_RF_GAIN(42), { 0x00000086, 0x00000039 } },
  79. { AR5K_RF_GAIN(43), { 0x000000c6, 0x00000079 } },
  80. { AR5K_RF_GAIN(44), { 0x000000c6, 0x000000b9 } },
  81. { AR5K_RF_GAIN(45), { 0x000000c6, 0x000001bd } },
  82. { AR5K_RF_GAIN(46), { 0x000000c6, 0x000001fd } },
  83. { AR5K_RF_GAIN(47), { 0x000000c6, 0x0000003d } },
  84. { AR5K_RF_GAIN(48), { 0x000000c6, 0x0000007d } },
  85. { AR5K_RF_GAIN(49), { 0x000000c6, 0x000000bd } },
  86. { AR5K_RF_GAIN(50), { 0x000000c6, 0x000000fd } },
  87. { AR5K_RF_GAIN(51), { 0x000000c6, 0x000000fd } },
  88. { AR5K_RF_GAIN(52), { 0x000000c6, 0x000000fd } },
  89. { AR5K_RF_GAIN(53), { 0x000000c6, 0x000000fd } },
  90. { AR5K_RF_GAIN(54), { 0x000000c6, 0x000000fd } },
  91. { AR5K_RF_GAIN(55), { 0x000000c6, 0x000000fd } },
  92. { AR5K_RF_GAIN(56), { 0x000000c6, 0x000000fd } },
  93. { AR5K_RF_GAIN(57), { 0x000000c6, 0x000000fd } },
  94. { AR5K_RF_GAIN(58), { 0x000000c6, 0x000000fd } },
  95. { AR5K_RF_GAIN(59), { 0x000000c6, 0x000000fd } },
  96. { AR5K_RF_GAIN(60), { 0x000000c6, 0x000000fd } },
  97. { AR5K_RF_GAIN(61), { 0x000000c6, 0x000000fd } },
  98. { AR5K_RF_GAIN(62), { 0x000000c6, 0x000000fd } },
  99. { AR5K_RF_GAIN(63), { 0x000000c6, 0x000000fd } },
  100. };
  101. /* Initial RF Gain settings for RF5112 */
  102. static const struct ath5k_ini_rfgain rfgain_5112[] = {
  103. /* 5GHz 2GHz */
  104. { AR5K_RF_GAIN(0), { 0x00000007, 0x00000007 } },
  105. { AR5K_RF_GAIN(1), { 0x00000047, 0x00000047 } },
  106. { AR5K_RF_GAIN(2), { 0x00000087, 0x00000087 } },
  107. { AR5K_RF_GAIN(3), { 0x000001a0, 0x000001a0 } },
  108. { AR5K_RF_GAIN(4), { 0x000001e0, 0x000001e0 } },
  109. { AR5K_RF_GAIN(5), { 0x00000020, 0x00000020 } },
  110. { AR5K_RF_GAIN(6), { 0x00000060, 0x00000060 } },
  111. { AR5K_RF_GAIN(7), { 0x000001a1, 0x000001a1 } },
  112. { AR5K_RF_GAIN(8), { 0x000001e1, 0x000001e1 } },
  113. { AR5K_RF_GAIN(9), { 0x00000021, 0x00000021 } },
  114. { AR5K_RF_GAIN(10), { 0x00000061, 0x00000061 } },
  115. { AR5K_RF_GAIN(11), { 0x00000162, 0x00000162 } },
  116. { AR5K_RF_GAIN(12), { 0x000001a2, 0x000001a2 } },
  117. { AR5K_RF_GAIN(13), { 0x000001e2, 0x000001e2 } },
  118. { AR5K_RF_GAIN(14), { 0x00000022, 0x00000022 } },
  119. { AR5K_RF_GAIN(15), { 0x00000062, 0x00000062 } },
  120. { AR5K_RF_GAIN(16), { 0x00000163, 0x00000163 } },
  121. { AR5K_RF_GAIN(17), { 0x000001a3, 0x000001a3 } },
  122. { AR5K_RF_GAIN(18), { 0x000001e3, 0x000001e3 } },
  123. { AR5K_RF_GAIN(19), { 0x00000023, 0x00000023 } },
  124. { AR5K_RF_GAIN(20), { 0x00000063, 0x00000063 } },
  125. { AR5K_RF_GAIN(21), { 0x00000184, 0x00000184 } },
  126. { AR5K_RF_GAIN(22), { 0x000001c4, 0x000001c4 } },
  127. { AR5K_RF_GAIN(23), { 0x00000004, 0x00000004 } },
  128. { AR5K_RF_GAIN(24), { 0x000001ea, 0x0000000b } },
  129. { AR5K_RF_GAIN(25), { 0x0000002a, 0x0000004b } },
  130. { AR5K_RF_GAIN(26), { 0x0000006a, 0x0000008b } },
  131. { AR5K_RF_GAIN(27), { 0x000000aa, 0x000001ac } },
  132. { AR5K_RF_GAIN(28), { 0x000001ab, 0x000001ec } },
  133. { AR5K_RF_GAIN(29), { 0x000001eb, 0x0000002c } },
  134. { AR5K_RF_GAIN(30), { 0x0000002b, 0x00000012 } },
  135. { AR5K_RF_GAIN(31), { 0x0000006b, 0x00000052 } },
  136. { AR5K_RF_GAIN(32), { 0x000000ab, 0x00000092 } },
  137. { AR5K_RF_GAIN(33), { 0x000001ac, 0x00000193 } },
  138. { AR5K_RF_GAIN(34), { 0x000001ec, 0x000001d3 } },
  139. { AR5K_RF_GAIN(35), { 0x0000002c, 0x00000013 } },
  140. { AR5K_RF_GAIN(36), { 0x0000003a, 0x00000053 } },
  141. { AR5K_RF_GAIN(37), { 0x0000007a, 0x00000093 } },
  142. { AR5K_RF_GAIN(38), { 0x000000ba, 0x00000194 } },
  143. { AR5K_RF_GAIN(39), { 0x000001bb, 0x000001d4 } },
  144. { AR5K_RF_GAIN(40), { 0x000001fb, 0x00000014 } },
  145. { AR5K_RF_GAIN(41), { 0x0000003b, 0x0000003a } },
  146. { AR5K_RF_GAIN(42), { 0x0000007b, 0x0000007a } },
  147. { AR5K_RF_GAIN(43), { 0x000000bb, 0x000000ba } },
  148. { AR5K_RF_GAIN(44), { 0x000001bc, 0x000001bb } },
  149. { AR5K_RF_GAIN(45), { 0x000001fc, 0x000001fb } },
  150. { AR5K_RF_GAIN(46), { 0x0000003c, 0x0000003b } },
  151. { AR5K_RF_GAIN(47), { 0x0000007c, 0x0000007b } },
  152. { AR5K_RF_GAIN(48), { 0x000000bc, 0x000000bb } },
  153. { AR5K_RF_GAIN(49), { 0x000000fc, 0x000001bc } },
  154. { AR5K_RF_GAIN(50), { 0x000000fc, 0x000001fc } },
  155. { AR5K_RF_GAIN(51), { 0x000000fc, 0x0000003c } },
  156. { AR5K_RF_GAIN(52), { 0x000000fc, 0x0000007c } },
  157. { AR5K_RF_GAIN(53), { 0x000000fc, 0x000000bc } },
  158. { AR5K_RF_GAIN(54), { 0x000000fc, 0x000000fc } },
  159. { AR5K_RF_GAIN(55), { 0x000000fc, 0x000000fc } },
  160. { AR5K_RF_GAIN(56), { 0x000000fc, 0x000000fc } },
  161. { AR5K_RF_GAIN(57), { 0x000000fc, 0x000000fc } },
  162. { AR5K_RF_GAIN(58), { 0x000000fc, 0x000000fc } },
  163. { AR5K_RF_GAIN(59), { 0x000000fc, 0x000000fc } },
  164. { AR5K_RF_GAIN(60), { 0x000000fc, 0x000000fc } },
  165. { AR5K_RF_GAIN(61), { 0x000000fc, 0x000000fc } },
  166. { AR5K_RF_GAIN(62), { 0x000000fc, 0x000000fc } },
  167. { AR5K_RF_GAIN(63), { 0x000000fc, 0x000000fc } },
  168. };
  169. /* Initial RF Gain settings for RF2413 */
  170. static const struct ath5k_ini_rfgain rfgain_2413[] = {
  171. { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } },
  172. { AR5K_RF_GAIN(1), { 0x00000000, 0x00000040 } },
  173. { AR5K_RF_GAIN(2), { 0x00000000, 0x00000080 } },
  174. { AR5K_RF_GAIN(3), { 0x00000000, 0x00000181 } },
  175. { AR5K_RF_GAIN(4), { 0x00000000, 0x000001c1 } },
  176. { AR5K_RF_GAIN(5), { 0x00000000, 0x00000001 } },
  177. { AR5K_RF_GAIN(6), { 0x00000000, 0x00000041 } },
  178. { AR5K_RF_GAIN(7), { 0x00000000, 0x00000081 } },
  179. { AR5K_RF_GAIN(8), { 0x00000000, 0x00000168 } },
  180. { AR5K_RF_GAIN(9), { 0x00000000, 0x000001a8 } },
  181. { AR5K_RF_GAIN(10), { 0x00000000, 0x000001e8 } },
  182. { AR5K_RF_GAIN(11), { 0x00000000, 0x00000028 } },
  183. { AR5K_RF_GAIN(12), { 0x00000000, 0x00000068 } },
  184. { AR5K_RF_GAIN(13), { 0x00000000, 0x00000189 } },
  185. { AR5K_RF_GAIN(14), { 0x00000000, 0x000001c9 } },
  186. { AR5K_RF_GAIN(15), { 0x00000000, 0x00000009 } },
  187. { AR5K_RF_GAIN(16), { 0x00000000, 0x00000049 } },
  188. { AR5K_RF_GAIN(17), { 0x00000000, 0x00000089 } },
  189. { AR5K_RF_GAIN(18), { 0x00000000, 0x00000190 } },
  190. { AR5K_RF_GAIN(19), { 0x00000000, 0x000001d0 } },
  191. { AR5K_RF_GAIN(20), { 0x00000000, 0x00000010 } },
  192. { AR5K_RF_GAIN(21), { 0x00000000, 0x00000050 } },
  193. { AR5K_RF_GAIN(22), { 0x00000000, 0x00000090 } },
  194. { AR5K_RF_GAIN(23), { 0x00000000, 0x00000191 } },
  195. { AR5K_RF_GAIN(24), { 0x00000000, 0x000001d1 } },
  196. { AR5K_RF_GAIN(25), { 0x00000000, 0x00000011 } },
  197. { AR5K_RF_GAIN(26), { 0x00000000, 0x00000051 } },
  198. { AR5K_RF_GAIN(27), { 0x00000000, 0x00000091 } },
  199. { AR5K_RF_GAIN(28), { 0x00000000, 0x00000178 } },
  200. { AR5K_RF_GAIN(29), { 0x00000000, 0x000001b8 } },
  201. { AR5K_RF_GAIN(30), { 0x00000000, 0x000001f8 } },
  202. { AR5K_RF_GAIN(31), { 0x00000000, 0x00000038 } },
  203. { AR5K_RF_GAIN(32), { 0x00000000, 0x00000078 } },
  204. { AR5K_RF_GAIN(33), { 0x00000000, 0x00000199 } },
  205. { AR5K_RF_GAIN(34), { 0x00000000, 0x000001d9 } },
  206. { AR5K_RF_GAIN(35), { 0x00000000, 0x00000019 } },
  207. { AR5K_RF_GAIN(36), { 0x00000000, 0x00000059 } },
  208. { AR5K_RF_GAIN(37), { 0x00000000, 0x00000099 } },
  209. { AR5K_RF_GAIN(38), { 0x00000000, 0x000000d9 } },
  210. { AR5K_RF_GAIN(39), { 0x00000000, 0x000000f9 } },
  211. { AR5K_RF_GAIN(40), { 0x00000000, 0x000000f9 } },
  212. { AR5K_RF_GAIN(41), { 0x00000000, 0x000000f9 } },
  213. { AR5K_RF_GAIN(42), { 0x00000000, 0x000000f9 } },
  214. { AR5K_RF_GAIN(43), { 0x00000000, 0x000000f9 } },
  215. { AR5K_RF_GAIN(44), { 0x00000000, 0x000000f9 } },
  216. { AR5K_RF_GAIN(45), { 0x00000000, 0x000000f9 } },
  217. { AR5K_RF_GAIN(46), { 0x00000000, 0x000000f9 } },
  218. { AR5K_RF_GAIN(47), { 0x00000000, 0x000000f9 } },
  219. { AR5K_RF_GAIN(48), { 0x00000000, 0x000000f9 } },
  220. { AR5K_RF_GAIN(49), { 0x00000000, 0x000000f9 } },
  221. { AR5K_RF_GAIN(50), { 0x00000000, 0x000000f9 } },
  222. { AR5K_RF_GAIN(51), { 0x00000000, 0x000000f9 } },
  223. { AR5K_RF_GAIN(52), { 0x00000000, 0x000000f9 } },
  224. { AR5K_RF_GAIN(53), { 0x00000000, 0x000000f9 } },
  225. { AR5K_RF_GAIN(54), { 0x00000000, 0x000000f9 } },
  226. { AR5K_RF_GAIN(55), { 0x00000000, 0x000000f9 } },
  227. { AR5K_RF_GAIN(56), { 0x00000000, 0x000000f9 } },
  228. { AR5K_RF_GAIN(57), { 0x00000000, 0x000000f9 } },
  229. { AR5K_RF_GAIN(58), { 0x00000000, 0x000000f9 } },
  230. { AR5K_RF_GAIN(59), { 0x00000000, 0x000000f9 } },
  231. { AR5K_RF_GAIN(60), { 0x00000000, 0x000000f9 } },
  232. { AR5K_RF_GAIN(61), { 0x00000000, 0x000000f9 } },
  233. { AR5K_RF_GAIN(62), { 0x00000000, 0x000000f9 } },
  234. { AR5K_RF_GAIN(63), { 0x00000000, 0x000000f9 } },
  235. };
  236. /* Initial RF Gain settings for AR2316 */
  237. static const struct ath5k_ini_rfgain rfgain_2316[] = {
  238. { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } },
  239. { AR5K_RF_GAIN(1), { 0x00000000, 0x00000040 } },
  240. { AR5K_RF_GAIN(2), { 0x00000000, 0x00000080 } },
  241. { AR5K_RF_GAIN(3), { 0x00000000, 0x000000c0 } },
  242. { AR5K_RF_GAIN(4), { 0x00000000, 0x000000e0 } },
  243. { AR5K_RF_GAIN(5), { 0x00000000, 0x000000e0 } },
  244. { AR5K_RF_GAIN(6), { 0x00000000, 0x00000128 } },
  245. { AR5K_RF_GAIN(7), { 0x00000000, 0x00000128 } },
  246. { AR5K_RF_GAIN(8), { 0x00000000, 0x00000128 } },
  247. { AR5K_RF_GAIN(9), { 0x00000000, 0x00000168 } },
  248. { AR5K_RF_GAIN(10), { 0x00000000, 0x000001a8 } },
  249. { AR5K_RF_GAIN(11), { 0x00000000, 0x000001e8 } },
  250. { AR5K_RF_GAIN(12), { 0x00000000, 0x00000028 } },
  251. { AR5K_RF_GAIN(13), { 0x00000000, 0x00000068 } },
  252. { AR5K_RF_GAIN(14), { 0x00000000, 0x000000a8 } },
  253. { AR5K_RF_GAIN(15), { 0x00000000, 0x000000e8 } },
  254. { AR5K_RF_GAIN(16), { 0x00000000, 0x000000e8 } },
  255. { AR5K_RF_GAIN(17), { 0x00000000, 0x00000130 } },
  256. { AR5K_RF_GAIN(18), { 0x00000000, 0x00000130 } },
  257. { AR5K_RF_GAIN(19), { 0x00000000, 0x00000170 } },
  258. { AR5K_RF_GAIN(20), { 0x00000000, 0x000001b0 } },
  259. { AR5K_RF_GAIN(21), { 0x00000000, 0x000001f0 } },
  260. { AR5K_RF_GAIN(22), { 0x00000000, 0x00000030 } },
  261. { AR5K_RF_GAIN(23), { 0x00000000, 0x00000070 } },
  262. { AR5K_RF_GAIN(24), { 0x00000000, 0x000000b0 } },
  263. { AR5K_RF_GAIN(25), { 0x00000000, 0x000000f0 } },
  264. { AR5K_RF_GAIN(26), { 0x00000000, 0x000000f0 } },
  265. { AR5K_RF_GAIN(27), { 0x00000000, 0x000000f0 } },
  266. { AR5K_RF_GAIN(28), { 0x00000000, 0x000000f0 } },
  267. { AR5K_RF_GAIN(29), { 0x00000000, 0x000000f0 } },
  268. { AR5K_RF_GAIN(30), { 0x00000000, 0x000000f0 } },
  269. { AR5K_RF_GAIN(31), { 0x00000000, 0x000000f0 } },
  270. { AR5K_RF_GAIN(32), { 0x00000000, 0x000000f0 } },
  271. { AR5K_RF_GAIN(33), { 0x00000000, 0x000000f0 } },
  272. { AR5K_RF_GAIN(34), { 0x00000000, 0x000000f0 } },
  273. { AR5K_RF_GAIN(35), { 0x00000000, 0x000000f0 } },
  274. { AR5K_RF_GAIN(36), { 0x00000000, 0x000000f0 } },
  275. { AR5K_RF_GAIN(37), { 0x00000000, 0x000000f0 } },
  276. { AR5K_RF_GAIN(38), { 0x00000000, 0x000000f0 } },
  277. { AR5K_RF_GAIN(39), { 0x00000000, 0x000000f0 } },
  278. { AR5K_RF_GAIN(40), { 0x00000000, 0x000000f0 } },
  279. { AR5K_RF_GAIN(41), { 0x00000000, 0x000000f0 } },
  280. { AR5K_RF_GAIN(42), { 0x00000000, 0x000000f0 } },
  281. { AR5K_RF_GAIN(43), { 0x00000000, 0x000000f0 } },
  282. { AR5K_RF_GAIN(44), { 0x00000000, 0x000000f0 } },
  283. { AR5K_RF_GAIN(45), { 0x00000000, 0x000000f0 } },
  284. { AR5K_RF_GAIN(46), { 0x00000000, 0x000000f0 } },
  285. { AR5K_RF_GAIN(47), { 0x00000000, 0x000000f0 } },
  286. { AR5K_RF_GAIN(48), { 0x00000000, 0x000000f0 } },
  287. { AR5K_RF_GAIN(49), { 0x00000000, 0x000000f0 } },
  288. { AR5K_RF_GAIN(50), { 0x00000000, 0x000000f0 } },
  289. { AR5K_RF_GAIN(51), { 0x00000000, 0x000000f0 } },
  290. { AR5K_RF_GAIN(52), { 0x00000000, 0x000000f0 } },
  291. { AR5K_RF_GAIN(53), { 0x00000000, 0x000000f0 } },
  292. { AR5K_RF_GAIN(54), { 0x00000000, 0x000000f0 } },
  293. { AR5K_RF_GAIN(55), { 0x00000000, 0x000000f0 } },
  294. { AR5K_RF_GAIN(56), { 0x00000000, 0x000000f0 } },
  295. { AR5K_RF_GAIN(57), { 0x00000000, 0x000000f0 } },
  296. { AR5K_RF_GAIN(58), { 0x00000000, 0x000000f0 } },
  297. { AR5K_RF_GAIN(59), { 0x00000000, 0x000000f0 } },
  298. { AR5K_RF_GAIN(60), { 0x00000000, 0x000000f0 } },
  299. { AR5K_RF_GAIN(61), { 0x00000000, 0x000000f0 } },
  300. { AR5K_RF_GAIN(62), { 0x00000000, 0x000000f0 } },
  301. { AR5K_RF_GAIN(63), { 0x00000000, 0x000000f0 } },
  302. };
  303. /* Initial RF Gain settings for RF5413 */
  304. static const struct ath5k_ini_rfgain rfgain_5413[] = {
  305. /* 5GHz 2GHz */
  306. { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } },
  307. { AR5K_RF_GAIN(1), { 0x00000040, 0x00000040 } },
  308. { AR5K_RF_GAIN(2), { 0x00000080, 0x00000080 } },
  309. { AR5K_RF_GAIN(3), { 0x000001a1, 0x00000161 } },
  310. { AR5K_RF_GAIN(4), { 0x000001e1, 0x000001a1 } },
  311. { AR5K_RF_GAIN(5), { 0x00000021, 0x000001e1 } },
  312. { AR5K_RF_GAIN(6), { 0x00000061, 0x00000021 } },
  313. { AR5K_RF_GAIN(7), { 0x00000188, 0x00000061 } },
  314. { AR5K_RF_GAIN(8), { 0x000001c8, 0x00000188 } },
  315. { AR5K_RF_GAIN(9), { 0x00000008, 0x000001c8 } },
  316. { AR5K_RF_GAIN(10), { 0x00000048, 0x00000008 } },
  317. { AR5K_RF_GAIN(11), { 0x00000088, 0x00000048 } },
  318. { AR5K_RF_GAIN(12), { 0x000001a9, 0x00000088 } },
  319. { AR5K_RF_GAIN(13), { 0x000001e9, 0x00000169 } },
  320. { AR5K_RF_GAIN(14), { 0x00000029, 0x000001a9 } },
  321. { AR5K_RF_GAIN(15), { 0x00000069, 0x000001e9 } },
  322. { AR5K_RF_GAIN(16), { 0x000001d0, 0x00000029 } },
  323. { AR5K_RF_GAIN(17), { 0x00000010, 0x00000069 } },
  324. { AR5K_RF_GAIN(18), { 0x00000050, 0x00000190 } },
  325. { AR5K_RF_GAIN(19), { 0x00000090, 0x000001d0 } },
  326. { AR5K_RF_GAIN(20), { 0x000001b1, 0x00000010 } },
  327. { AR5K_RF_GAIN(21), { 0x000001f1, 0x00000050 } },
  328. { AR5K_RF_GAIN(22), { 0x00000031, 0x00000090 } },
  329. { AR5K_RF_GAIN(23), { 0x00000071, 0x00000171 } },
  330. { AR5K_RF_GAIN(24), { 0x000001b8, 0x000001b1 } },
  331. { AR5K_RF_GAIN(25), { 0x000001f8, 0x000001f1 } },
  332. { AR5K_RF_GAIN(26), { 0x00000038, 0x00000031 } },
  333. { AR5K_RF_GAIN(27), { 0x00000078, 0x00000071 } },
  334. { AR5K_RF_GAIN(28), { 0x00000199, 0x00000198 } },
  335. { AR5K_RF_GAIN(29), { 0x000001d9, 0x000001d8 } },
  336. { AR5K_RF_GAIN(30), { 0x00000019, 0x00000018 } },
  337. { AR5K_RF_GAIN(31), { 0x00000059, 0x00000058 } },
  338. { AR5K_RF_GAIN(32), { 0x00000099, 0x00000098 } },
  339. { AR5K_RF_GAIN(33), { 0x000000d9, 0x00000179 } },
  340. { AR5K_RF_GAIN(34), { 0x000000f9, 0x000001b9 } },
  341. { AR5K_RF_GAIN(35), { 0x000000f9, 0x000001f9 } },
  342. { AR5K_RF_GAIN(36), { 0x000000f9, 0x00000039 } },
  343. { AR5K_RF_GAIN(37), { 0x000000f9, 0x00000079 } },
  344. { AR5K_RF_GAIN(38), { 0x000000f9, 0x000000b9 } },
  345. { AR5K_RF_GAIN(39), { 0x000000f9, 0x000000f9 } },
  346. { AR5K_RF_GAIN(40), { 0x000000f9, 0x000000f9 } },
  347. { AR5K_RF_GAIN(41), { 0x000000f9, 0x000000f9 } },
  348. { AR5K_RF_GAIN(42), { 0x000000f9, 0x000000f9 } },
  349. { AR5K_RF_GAIN(43), { 0x000000f9, 0x000000f9 } },
  350. { AR5K_RF_GAIN(44), { 0x000000f9, 0x000000f9 } },
  351. { AR5K_RF_GAIN(45), { 0x000000f9, 0x000000f9 } },
  352. { AR5K_RF_GAIN(46), { 0x000000f9, 0x000000f9 } },
  353. { AR5K_RF_GAIN(47), { 0x000000f9, 0x000000f9 } },
  354. { AR5K_RF_GAIN(48), { 0x000000f9, 0x000000f9 } },
  355. { AR5K_RF_GAIN(49), { 0x000000f9, 0x000000f9 } },
  356. { AR5K_RF_GAIN(50), { 0x000000f9, 0x000000f9 } },
  357. { AR5K_RF_GAIN(51), { 0x000000f9, 0x000000f9 } },
  358. { AR5K_RF_GAIN(52), { 0x000000f9, 0x000000f9 } },
  359. { AR5K_RF_GAIN(53), { 0x000000f9, 0x000000f9 } },
  360. { AR5K_RF_GAIN(54), { 0x000000f9, 0x000000f9 } },
  361. { AR5K_RF_GAIN(55), { 0x000000f9, 0x000000f9 } },
  362. { AR5K_RF_GAIN(56), { 0x000000f9, 0x000000f9 } },
  363. { AR5K_RF_GAIN(57), { 0x000000f9, 0x000000f9 } },
  364. { AR5K_RF_GAIN(58), { 0x000000f9, 0x000000f9 } },
  365. { AR5K_RF_GAIN(59), { 0x000000f9, 0x000000f9 } },
  366. { AR5K_RF_GAIN(60), { 0x000000f9, 0x000000f9 } },
  367. { AR5K_RF_GAIN(61), { 0x000000f9, 0x000000f9 } },
  368. { AR5K_RF_GAIN(62), { 0x000000f9, 0x000000f9 } },
  369. { AR5K_RF_GAIN(63), { 0x000000f9, 0x000000f9 } },
  370. };
  371. /* Initial RF Gain settings for RF2425 */
  372. static const struct ath5k_ini_rfgain rfgain_2425[] = {
  373. { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } },
  374. { AR5K_RF_GAIN(1), { 0x00000000, 0x00000040 } },
  375. { AR5K_RF_GAIN(2), { 0x00000000, 0x00000080 } },
  376. { AR5K_RF_GAIN(3), { 0x00000000, 0x00000181 } },
  377. { AR5K_RF_GAIN(4), { 0x00000000, 0x000001c1 } },
  378. { AR5K_RF_GAIN(5), { 0x00000000, 0x00000001 } },
  379. { AR5K_RF_GAIN(6), { 0x00000000, 0x00000041 } },
  380. { AR5K_RF_GAIN(7), { 0x00000000, 0x00000081 } },
  381. { AR5K_RF_GAIN(8), { 0x00000000, 0x00000188 } },
  382. { AR5K_RF_GAIN(9), { 0x00000000, 0x000001c8 } },
  383. { AR5K_RF_GAIN(10), { 0x00000000, 0x00000008 } },
  384. { AR5K_RF_GAIN(11), { 0x00000000, 0x00000048 } },
  385. { AR5K_RF_GAIN(12), { 0x00000000, 0x00000088 } },
  386. { AR5K_RF_GAIN(13), { 0x00000000, 0x00000189 } },
  387. { AR5K_RF_GAIN(14), { 0x00000000, 0x000001c9 } },
  388. { AR5K_RF_GAIN(15), { 0x00000000, 0x00000009 } },
  389. { AR5K_RF_GAIN(16), { 0x00000000, 0x00000049 } },
  390. { AR5K_RF_GAIN(17), { 0x00000000, 0x00000089 } },
  391. { AR5K_RF_GAIN(18), { 0x00000000, 0x000001b0 } },
  392. { AR5K_RF_GAIN(19), { 0x00000000, 0x000001f0 } },
  393. { AR5K_RF_GAIN(20), { 0x00000000, 0x00000030 } },
  394. { AR5K_RF_GAIN(21), { 0x00000000, 0x00000070 } },
  395. { AR5K_RF_GAIN(22), { 0x00000000, 0x00000171 } },
  396. { AR5K_RF_GAIN(23), { 0x00000000, 0x000001b1 } },
  397. { AR5K_RF_GAIN(24), { 0x00000000, 0x000001f1 } },
  398. { AR5K_RF_GAIN(25), { 0x00000000, 0x00000031 } },
  399. { AR5K_RF_GAIN(26), { 0x00000000, 0x00000071 } },
  400. { AR5K_RF_GAIN(27), { 0x00000000, 0x000001b8 } },
  401. { AR5K_RF_GAIN(28), { 0x00000000, 0x000001f8 } },
  402. { AR5K_RF_GAIN(29), { 0x00000000, 0x00000038 } },
  403. { AR5K_RF_GAIN(30), { 0x00000000, 0x00000078 } },
  404. { AR5K_RF_GAIN(31), { 0x00000000, 0x000000b8 } },
  405. { AR5K_RF_GAIN(32), { 0x00000000, 0x000001b9 } },
  406. { AR5K_RF_GAIN(33), { 0x00000000, 0x000001f9 } },
  407. { AR5K_RF_GAIN(34), { 0x00000000, 0x00000039 } },
  408. { AR5K_RF_GAIN(35), { 0x00000000, 0x00000079 } },
  409. { AR5K_RF_GAIN(36), { 0x00000000, 0x000000b9 } },
  410. { AR5K_RF_GAIN(37), { 0x00000000, 0x000000f9 } },
  411. { AR5K_RF_GAIN(38), { 0x00000000, 0x000000f9 } },
  412. { AR5K_RF_GAIN(39), { 0x00000000, 0x000000f9 } },
  413. { AR5K_RF_GAIN(40), { 0x00000000, 0x000000f9 } },
  414. { AR5K_RF_GAIN(41), { 0x00000000, 0x000000f9 } },
  415. { AR5K_RF_GAIN(42), { 0x00000000, 0x000000f9 } },
  416. { AR5K_RF_GAIN(43), { 0x00000000, 0x000000f9 } },
  417. { AR5K_RF_GAIN(44), { 0x00000000, 0x000000f9 } },
  418. { AR5K_RF_GAIN(45), { 0x00000000, 0x000000f9 } },
  419. { AR5K_RF_GAIN(46), { 0x00000000, 0x000000f9 } },
  420. { AR5K_RF_GAIN(47), { 0x00000000, 0x000000f9 } },
  421. { AR5K_RF_GAIN(48), { 0x00000000, 0x000000f9 } },
  422. { AR5K_RF_GAIN(49), { 0x00000000, 0x000000f9 } },
  423. { AR5K_RF_GAIN(50), { 0x00000000, 0x000000f9 } },
  424. { AR5K_RF_GAIN(51), { 0x00000000, 0x000000f9 } },
  425. { AR5K_RF_GAIN(52), { 0x00000000, 0x000000f9 } },
  426. { AR5K_RF_GAIN(53), { 0x00000000, 0x000000f9 } },
  427. { AR5K_RF_GAIN(54), { 0x00000000, 0x000000f9 } },
  428. { AR5K_RF_GAIN(55), { 0x00000000, 0x000000f9 } },
  429. { AR5K_RF_GAIN(56), { 0x00000000, 0x000000f9 } },
  430. { AR5K_RF_GAIN(57), { 0x00000000, 0x000000f9 } },
  431. { AR5K_RF_GAIN(58), { 0x00000000, 0x000000f9 } },
  432. { AR5K_RF_GAIN(59), { 0x00000000, 0x000000f9 } },
  433. { AR5K_RF_GAIN(60), { 0x00000000, 0x000000f9 } },
  434. { AR5K_RF_GAIN(61), { 0x00000000, 0x000000f9 } },
  435. { AR5K_RF_GAIN(62), { 0x00000000, 0x000000f9 } },
  436. { AR5K_RF_GAIN(63), { 0x00000000, 0x000000f9 } },
  437. };
  438. #define AR5K_GAIN_CRN_FIX_BITS_5111 4
  439. #define AR5K_GAIN_CRN_FIX_BITS_5112 7
  440. #define AR5K_GAIN_CRN_MAX_FIX_BITS AR5K_GAIN_CRN_FIX_BITS_5112
  441. #define AR5K_GAIN_DYN_ADJUST_HI_MARGIN 15
  442. #define AR5K_GAIN_DYN_ADJUST_LO_MARGIN 20
  443. #define AR5K_GAIN_CCK_PROBE_CORR 5
  444. #define AR5K_GAIN_CCK_OFDM_GAIN_DELTA 15
  445. #define AR5K_GAIN_STEP_COUNT 10
  446. /* Check if our current measurement is inside our
  447. * current variable attenuation window */
  448. #define AR5K_GAIN_CHECK_ADJUST(_g) \
  449. ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high)
  450. /**
  451. * struct ath5k_gain_opt_step - An RF gain optimization step
  452. * @gos_param: Set of parameters
  453. * @gos_gain: Gain
  454. */
  455. struct ath5k_gain_opt_step {
  456. s8 gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS];
  457. s8 gos_gain;
  458. };
  459. /**
  460. * struct ath5k_gain_opt - RF Gain optimization ladder
  461. * @go_default: The default step
  462. * @go_steps_count: How many optimization steps
  463. * @go_step: Array of &struct ath5k_gain_opt_step
  464. */
  465. struct ath5k_gain_opt {
  466. u8 go_default;
  467. u8 go_steps_count;
  468. const struct ath5k_gain_opt_step go_step[AR5K_GAIN_STEP_COUNT];
  469. };
  470. /*
  471. * RF5111
  472. * Parameters on gos_param:
  473. * 1) Tx clip PHY register
  474. * 2) PWD 90 RF register
  475. * 3) PWD 84 RF register
  476. * 4) RFGainSel RF register
  477. */
  478. static const struct ath5k_gain_opt rfgain_opt_5111 = {
  479. 4,
  480. 9,
  481. {
  482. { { 4, 1, 1, 1 }, 6 },
  483. { { 4, 0, 1, 1 }, 4 },
  484. { { 3, 1, 1, 1 }, 3 },
  485. { { 4, 0, 0, 1 }, 1 },
  486. { { 4, 1, 1, 0 }, 0 },
  487. { { 4, 0, 1, 0 }, -2 },
  488. { { 3, 1, 1, 0 }, -3 },
  489. { { 4, 0, 0, 0 }, -4 },
  490. { { 2, 1, 1, 0 }, -6 }
  491. }
  492. };
  493. /*
  494. * RF5112
  495. * Parameters on gos_param:
  496. * 1) Mixgain ovr RF register
  497. * 2) PWD 138 RF register
  498. * 3) PWD 137 RF register
  499. * 4) PWD 136 RF register
  500. * 5) PWD 132 RF register
  501. * 6) PWD 131 RF register
  502. * 7) PWD 130 RF register
  503. */
  504. static const struct ath5k_gain_opt rfgain_opt_5112 = {
  505. 1,
  506. 8,
  507. {
  508. { { 3, 0, 0, 0, 0, 0, 0 }, 6 },
  509. { { 2, 0, 0, 0, 0, 0, 0 }, 0 },
  510. { { 1, 0, 0, 0, 0, 0, 0 }, -3 },
  511. { { 0, 0, 0, 0, 0, 0, 0 }, -6 },
  512. { { 0, 1, 1, 0, 0, 0, 0 }, -8 },
  513. { { 0, 1, 1, 0, 1, 1, 0 }, -10 },
  514. { { 0, 1, 0, 1, 1, 1, 0 }, -13 },
  515. { { 0, 1, 0, 1, 1, 0, 1 }, -16 },
  516. }
  517. };