tables_phy_lcn.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /*
  2. Broadcom B43 wireless driver
  3. IEEE 802.11n LCN-PHY data tables
  4. Copyright (c) 2011 Rafał Miłecki <zajec5@gmail.com>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; see the file COPYING. If not, write to
  15. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  16. Boston, MA 02110-1301, USA.
  17. */
  18. #include "b43.h"
  19. #include "tables_phy_lcn.h"
  20. #include "phy_common.h"
  21. #include "phy_lcn.h"
  22. struct b43_lcntab_tx_gain_tbl_entry {
  23. u8 gm;
  24. u8 pga;
  25. u8 pad;
  26. u8 dac;
  27. u8 bb_mult;
  28. };
  29. /**************************************************
  30. * Static tables.
  31. **************************************************/
  32. static const u16 b43_lcntab_0x02[] = {
  33. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  34. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  35. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  36. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  37. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  38. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  39. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  40. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  41. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  42. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  43. 0x014d, 0x014d, 0x014d, 0x014d,
  44. };
  45. static const u16 b43_lcntab_0x01[] = {
  46. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  47. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  48. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  49. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  50. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  51. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  52. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  53. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  54. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  55. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  56. 0x0000, 0x0000, 0x0000, 0x0000,
  57. };
  58. static const u32 b43_lcntab_0x0b[] = {
  59. 0x000141f8, 0x000021f8, 0x000021fb, 0x000041fb,
  60. 0x0001fedb, 0x0000217b, 0x00002133, 0x000040eb,
  61. 0x0001fea3, 0x0000024b,
  62. };
  63. static const u32 b43_lcntab_0x0c[] = {
  64. 0x00100001, 0x00200010, 0x00300001, 0x00400010,
  65. 0x00500022, 0x00600122, 0x00700222, 0x00800322,
  66. 0x00900422, 0x00a00522, 0x00b00622, 0x00c00722,
  67. 0x00d00822, 0x00f00922, 0x00100a22, 0x00200b22,
  68. 0x00300c22, 0x00400d22, 0x00500e22, 0x00600f22,
  69. };
  70. static const u32 b43_lcntab_0x0d[] = {
  71. 0x00000000, 0x00000000, 0x10000000, 0x00000000,
  72. 0x20000000, 0x00000000, 0x30000000, 0x00000000,
  73. 0x40000000, 0x00000000, 0x50000000, 0x00000000,
  74. 0x60000000, 0x00000000, 0x70000000, 0x00000000,
  75. 0x80000000, 0x00000000, 0x90000000, 0x00000008,
  76. 0xa0000000, 0x00000008, 0xb0000000, 0x00000008,
  77. 0xc0000000, 0x00000008, 0xd0000000, 0x00000008,
  78. 0xe0000000, 0x00000008, 0xf0000000, 0x00000008,
  79. 0x00000000, 0x00000009, 0x10000000, 0x00000009,
  80. 0x20000000, 0x00000019, 0x30000000, 0x00000019,
  81. 0x40000000, 0x00000019, 0x50000000, 0x00000019,
  82. 0x60000000, 0x00000019, 0x70000000, 0x00000019,
  83. 0x80000000, 0x00000019, 0x90000000, 0x00000019,
  84. 0xa0000000, 0x00000019, 0xb0000000, 0x00000019,
  85. 0xc0000000, 0x00000019, 0xd0000000, 0x00000019,
  86. 0xe0000000, 0x00000019, 0xf0000000, 0x00000019,
  87. 0x00000000, 0x0000001a, 0x10000000, 0x0000001a,
  88. 0x20000000, 0x0000001a, 0x30000000, 0x0000001a,
  89. 0x40000000, 0x0000001a, 0x50000000, 0x00000002,
  90. 0x60000000, 0x00000002, 0x70000000, 0x00000002,
  91. 0x80000000, 0x00000002, 0x90000000, 0x00000002,
  92. 0xa0000000, 0x00000002, 0xb0000000, 0x00000002,
  93. 0xc0000000, 0x0000000a, 0xd0000000, 0x0000000a,
  94. 0xe0000000, 0x0000000a, 0xf0000000, 0x0000000a,
  95. 0x00000000, 0x0000000b, 0x10000000, 0x0000000b,
  96. 0x20000000, 0x0000000b, 0x30000000, 0x0000000b,
  97. 0x40000000, 0x0000000b, 0x50000000, 0x0000001b,
  98. 0x60000000, 0x0000001b, 0x70000000, 0x0000001b,
  99. 0x80000000, 0x0000001b, 0x90000000, 0x0000001b,
  100. 0xa0000000, 0x0000001b, 0xb0000000, 0x0000001b,
  101. 0xc0000000, 0x0000001b, 0xd0000000, 0x0000001b,
  102. 0xe0000000, 0x0000001b, 0xf0000000, 0x0000001b,
  103. 0x00000000, 0x0000001c, 0x10000000, 0x0000001c,
  104. 0x20000000, 0x0000001c, 0x30000000, 0x0000001c,
  105. 0x40000000, 0x0000001c, 0x50000000, 0x0000001c,
  106. 0x60000000, 0x0000001c, 0x70000000, 0x0000001c,
  107. 0x80000000, 0x0000001c, 0x90000000, 0x0000001c,
  108. };
  109. static const u16 b43_lcntab_0x0e[] = {
  110. 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406,
  111. 0x0407, 0x0408, 0x0409, 0x040a, 0x058b, 0x058c,
  112. 0x058d, 0x058e, 0x058f, 0x0090, 0x0091, 0x0092,
  113. 0x0193, 0x0194, 0x0195, 0x0196, 0x0197, 0x0198,
  114. 0x0199, 0x019a, 0x019b, 0x019c, 0x019d, 0x019e,
  115. 0x019f, 0x01a0, 0x01a1, 0x01a2, 0x01a3, 0x01a4,
  116. 0x01a5, 0x0000,
  117. };
  118. static const u16 b43_lcntab_0x0f[] = {
  119. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  120. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  121. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  122. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  123. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  124. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  125. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  126. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  127. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  128. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  129. 0x000a, 0x0009, 0x0006, 0x0005,
  130. };
  131. static const u16 b43_lcntab_0x10[] = {
  132. 0x005f, 0x0036, 0x0029, 0x001f, 0x005f, 0x0036,
  133. 0x0029, 0x001f, 0x005f, 0x0036, 0x0029, 0x001f,
  134. 0x005f, 0x0036, 0x0029, 0x001f,
  135. };
  136. static const u16 b43_lcntab_0x11[] = {
  137. 0x0009, 0x000f, 0x0014, 0x0018, 0x00fe, 0x0007,
  138. 0x000b, 0x000f, 0x00fb, 0x00fe, 0x0001, 0x0005,
  139. 0x0008, 0x000b, 0x000e, 0x0011, 0x0014, 0x0017,
  140. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  141. 0x0000, 0x0003, 0x0006, 0x0009, 0x000c, 0x000f,
  142. 0x0012, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  143. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003,
  144. 0x0006, 0x0009, 0x000c, 0x000f, 0x0012, 0x0015,
  145. 0x0018, 0x001b, 0x0000, 0x0000, 0x0000, 0x0000,
  146. 0x0000, 0x0000, 0x0003, 0x00eb, 0x0000, 0x0000,
  147. };
  148. static const u32 b43_lcntab_0x12[] = {
  149. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  150. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  151. 0x00000004, 0x00000000, 0x00000004, 0x00000008,
  152. 0x00000001, 0x00000005, 0x00000009, 0x0000000d,
  153. 0x0000004d, 0x0000008d, 0x0000000d, 0x0000004d,
  154. 0x0000008d, 0x000000cd, 0x0000004f, 0x0000008f,
  155. 0x000000cf, 0x000000d3, 0x00000113, 0x00000513,
  156. 0x00000913, 0x00000953, 0x00000d53, 0x00001153,
  157. 0x00001193, 0x00005193, 0x00009193, 0x0000d193,
  158. 0x00011193, 0x00000000, 0x00000000, 0x00000000,
  159. 0x00000000, 0x00000000, 0x00000000, 0x00000004,
  160. 0x00000000, 0x00000004, 0x00000008, 0x00000001,
  161. 0x00000005, 0x00000009, 0x0000000d, 0x0000004d,
  162. 0x0000008d, 0x0000000d, 0x0000004d, 0x0000008d,
  163. 0x000000cd, 0x0000004f, 0x0000008f, 0x000000cf,
  164. 0x000000d3, 0x00000113, 0x00000513, 0x00000913,
  165. 0x00000953, 0x00000d53, 0x00001153, 0x00005153,
  166. 0x00009153, 0x0000d153, 0x00011153, 0x00015153,
  167. 0x00019153, 0x0001d153, 0x00000000, 0x00000000,
  168. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  169. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  170. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  171. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  172. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  173. };
  174. static const u16 b43_lcntab_0x14[] = {
  175. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  176. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  177. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  178. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  179. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  180. 0x0002, 0x0003, 0x0001, 0x0003, 0x0002, 0x0001,
  181. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  182. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  183. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  184. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  185. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  186. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  187. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  188. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  189. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  190. 0x0001, 0x0001, 0x0001, 0x0001, 0x0002, 0x0003,
  191. 0x0001, 0x0003, 0x0002, 0x0001, 0x0001, 0x0001,
  192. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  193. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  194. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  195. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  196. 0x0001, 0x0001,
  197. };
  198. static const u16 b43_lcntab_0x17[] = {
  199. 0x001a, 0x0034, 0x004e, 0x0068, 0x009c, 0x00d0,
  200. 0x00ea, 0x0104, 0x0034, 0x0068, 0x009c, 0x00d0,
  201. 0x0138, 0x01a0, 0x01d4, 0x0208, 0x004e, 0x009c,
  202. 0x00ea, 0x0138, 0x01d4, 0x0270, 0x02be, 0x030c,
  203. 0x0068, 0x00d0, 0x0138, 0x01a0, 0x0270, 0x0340,
  204. 0x03a8, 0x0410, 0x0018, 0x009c, 0x00d0, 0x0104,
  205. 0x00ea, 0x0138, 0x0186, 0x00d0, 0x0104, 0x0104,
  206. 0x0138, 0x016c, 0x016c, 0x01a0, 0x0138, 0x0186,
  207. 0x0186, 0x01d4, 0x0222, 0x0222, 0x0270, 0x0104,
  208. 0x0138, 0x016c, 0x0138, 0x016c, 0x01a0, 0x01d4,
  209. 0x01a0, 0x01d4, 0x0208, 0x0208, 0x023c, 0x0186,
  210. 0x01d4, 0x0222, 0x01d4, 0x0222, 0x0270, 0x02be,
  211. 0x0270, 0x02be, 0x030c, 0x030c, 0x035a, 0x0036,
  212. 0x006c, 0x00a2, 0x00d8, 0x0144, 0x01b0, 0x01e6,
  213. 0x021c, 0x006c, 0x00d8, 0x0144, 0x01b0, 0x0288,
  214. 0x0360, 0x03cc, 0x0438, 0x00a2, 0x0144, 0x01e6,
  215. 0x0288, 0x03cc, 0x0510, 0x05b2, 0x0654, 0x00d8,
  216. 0x01b0, 0x0288, 0x0360, 0x0510, 0x06c0, 0x0798,
  217. 0x0870, 0x0018, 0x0144, 0x01b0, 0x021c, 0x01e6,
  218. 0x0288, 0x032a, 0x01b0, 0x021c, 0x021c, 0x0288,
  219. 0x02f4, 0x02f4, 0x0360, 0x0288, 0x032a, 0x032a,
  220. 0x03cc, 0x046e, 0x046e, 0x0510, 0x021c, 0x0288,
  221. 0x02f4, 0x0288, 0x02f4, 0x0360, 0x03cc, 0x0360,
  222. 0x03cc, 0x0438, 0x0438, 0x04a4, 0x032a, 0x03cc,
  223. 0x046e, 0x03cc, 0x046e, 0x0510, 0x05b2, 0x0510,
  224. 0x05b2, 0x0654, 0x0654, 0x06f6,
  225. };
  226. static const u16 b43_lcntab_0x00[] = {
  227. 0x0200, 0x0300, 0x0400, 0x0600, 0x0800, 0x0b00,
  228. 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005,
  229. 0x1006, 0x1007, 0x1707, 0x2007, 0x2d07, 0x4007,
  230. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  231. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  232. 0x0000, 0x0000, 0x0200, 0x0300, 0x0400, 0x0600,
  233. 0x0800, 0x0b00, 0x1000, 0x1001, 0x1002, 0x1003,
  234. 0x1004, 0x1005, 0x1006, 0x1007, 0x1707, 0x2007,
  235. 0x2d07, 0x4007, 0x0000, 0x0000, 0x0000, 0x0000,
  236. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  237. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  238. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  239. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  240. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  241. 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000,
  242. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  243. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  244. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  245. };
  246. static const u32 b43_lcntab_0x18[] = {
  247. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  248. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  249. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  250. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  251. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  252. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  253. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  254. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  255. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  256. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  257. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  258. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  259. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  260. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  261. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  262. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  263. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  264. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  265. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  266. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  267. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  268. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  269. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  270. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  271. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  272. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  273. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  274. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  275. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  276. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  277. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  278. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  279. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  280. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  281. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  282. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  283. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  284. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  285. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  286. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  287. };
  288. /**************************************************
  289. * TX gain.
  290. **************************************************/
  291. static const struct b43_lcntab_tx_gain_tbl_entry
  292. b43_lcntab_tx_gain_tbl_2ghz_ext_pa_rev0[B43_LCNTAB_TX_GAIN_SIZE] = {
  293. { 0x03, 0x00, 0x1f, 0x0, 0x48 },
  294. { 0x03, 0x00, 0x1f, 0x0, 0x46 },
  295. { 0x03, 0x00, 0x1f, 0x0, 0x44 },
  296. { 0x03, 0x00, 0x1e, 0x0, 0x43 },
  297. { 0x03, 0x00, 0x1d, 0x0, 0x44 },
  298. { 0x03, 0x00, 0x1c, 0x0, 0x44 },
  299. { 0x03, 0x00, 0x1b, 0x0, 0x45 },
  300. { 0x03, 0x00, 0x1a, 0x0, 0x46 },
  301. { 0x03, 0x00, 0x19, 0x0, 0x46 },
  302. { 0x03, 0x00, 0x18, 0x0, 0x47 },
  303. { 0x03, 0x00, 0x17, 0x0, 0x48 },
  304. { 0x03, 0x00, 0x17, 0x0, 0x46 },
  305. { 0x03, 0x00, 0x16, 0x0, 0x47 },
  306. { 0x03, 0x00, 0x15, 0x0, 0x48 },
  307. { 0x03, 0x00, 0x15, 0x0, 0x46 },
  308. { 0x03, 0x00, 0x15, 0x0, 0x44 },
  309. { 0x03, 0x00, 0x15, 0x0, 0x42 },
  310. { 0x03, 0x00, 0x15, 0x0, 0x40 },
  311. { 0x03, 0x00, 0x15, 0x0, 0x3f },
  312. { 0x03, 0x00, 0x14, 0x0, 0x40 },
  313. { 0x03, 0x00, 0x13, 0x0, 0x41 },
  314. { 0x03, 0x00, 0x13, 0x0, 0x40 },
  315. { 0x03, 0x00, 0x12, 0x0, 0x41 },
  316. { 0x03, 0x00, 0x12, 0x0, 0x40 },
  317. { 0x03, 0x00, 0x11, 0x0, 0x41 },
  318. { 0x03, 0x00, 0x11, 0x0, 0x40 },
  319. { 0x03, 0x00, 0x10, 0x0, 0x41 },
  320. { 0x03, 0x00, 0x10, 0x0, 0x40 },
  321. { 0x03, 0x00, 0x10, 0x0, 0x3e },
  322. { 0x03, 0x00, 0x10, 0x0, 0x3c },
  323. { 0x03, 0x00, 0x10, 0x0, 0x3a },
  324. { 0x03, 0x00, 0x0f, 0x0, 0x3d },
  325. { 0x03, 0x00, 0x0f, 0x0, 0x3b },
  326. { 0x03, 0x00, 0x0e, 0x0, 0x3d },
  327. { 0x03, 0x00, 0x0e, 0x0, 0x3c },
  328. { 0x03, 0x00, 0x0e, 0x0, 0x3a },
  329. { 0x03, 0x00, 0x0d, 0x0, 0x3c },
  330. { 0x03, 0x00, 0x0d, 0x0, 0x3b },
  331. { 0x03, 0x00, 0x0c, 0x0, 0x3e },
  332. { 0x03, 0x00, 0x0c, 0x0, 0x3c },
  333. { 0x03, 0x00, 0x0c, 0x0, 0x3a },
  334. { 0x03, 0x00, 0x0b, 0x0, 0x3e },
  335. { 0x03, 0x00, 0x0b, 0x0, 0x3c },
  336. { 0x03, 0x00, 0x0b, 0x0, 0x3b },
  337. { 0x03, 0x00, 0x0b, 0x0, 0x39 },
  338. { 0x03, 0x00, 0x0a, 0x0, 0x3d },
  339. { 0x03, 0x00, 0x0a, 0x0, 0x3b },
  340. { 0x03, 0x00, 0x0a, 0x0, 0x39 },
  341. { 0x03, 0x00, 0x09, 0x0, 0x3e },
  342. { 0x03, 0x00, 0x09, 0x0, 0x3c },
  343. { 0x03, 0x00, 0x09, 0x0, 0x3a },
  344. { 0x03, 0x00, 0x09, 0x0, 0x39 },
  345. { 0x03, 0x00, 0x08, 0x0, 0x3e },
  346. { 0x03, 0x00, 0x08, 0x0, 0x3c },
  347. { 0x03, 0x00, 0x08, 0x0, 0x3a },
  348. { 0x03, 0x00, 0x08, 0x0, 0x39 },
  349. { 0x03, 0x00, 0x08, 0x0, 0x37 },
  350. { 0x03, 0x00, 0x07, 0x0, 0x3d },
  351. { 0x03, 0x00, 0x07, 0x0, 0x3c },
  352. { 0x03, 0x00, 0x07, 0x0, 0x3a },
  353. { 0x03, 0x00, 0x07, 0x0, 0x38 },
  354. { 0x03, 0x00, 0x07, 0x0, 0x37 },
  355. { 0x03, 0x00, 0x06, 0x0, 0x3e },
  356. { 0x03, 0x00, 0x06, 0x0, 0x3c },
  357. { 0x03, 0x00, 0x06, 0x0, 0x3a },
  358. { 0x03, 0x00, 0x06, 0x0, 0x39 },
  359. { 0x03, 0x00, 0x06, 0x0, 0x37 },
  360. { 0x03, 0x00, 0x06, 0x0, 0x36 },
  361. { 0x03, 0x00, 0x06, 0x0, 0x34 },
  362. { 0x03, 0x00, 0x05, 0x0, 0x3d },
  363. { 0x03, 0x00, 0x05, 0x0, 0x3b },
  364. { 0x03, 0x00, 0x05, 0x0, 0x39 },
  365. { 0x03, 0x00, 0x05, 0x0, 0x38 },
  366. { 0x03, 0x00, 0x05, 0x0, 0x36 },
  367. { 0x03, 0x00, 0x05, 0x0, 0x35 },
  368. { 0x03, 0x00, 0x05, 0x0, 0x33 },
  369. { 0x03, 0x00, 0x04, 0x0, 0x3e },
  370. { 0x03, 0x00, 0x04, 0x0, 0x3c },
  371. { 0x03, 0x00, 0x04, 0x0, 0x3a },
  372. { 0x03, 0x00, 0x04, 0x0, 0x39 },
  373. { 0x03, 0x00, 0x04, 0x0, 0x37 },
  374. { 0x03, 0x00, 0x04, 0x0, 0x36 },
  375. { 0x03, 0x00, 0x04, 0x0, 0x34 },
  376. { 0x03, 0x00, 0x04, 0x0, 0x33 },
  377. { 0x03, 0x00, 0x04, 0x0, 0x31 },
  378. { 0x03, 0x00, 0x04, 0x0, 0x30 },
  379. { 0x03, 0x00, 0x04, 0x0, 0x2e },
  380. { 0x03, 0x00, 0x03, 0x0, 0x3c },
  381. { 0x03, 0x00, 0x03, 0x0, 0x3a },
  382. { 0x03, 0x00, 0x03, 0x0, 0x39 },
  383. { 0x03, 0x00, 0x03, 0x0, 0x37 },
  384. { 0x03, 0x00, 0x03, 0x0, 0x36 },
  385. { 0x03, 0x00, 0x03, 0x0, 0x34 },
  386. { 0x03, 0x00, 0x03, 0x0, 0x33 },
  387. { 0x03, 0x00, 0x03, 0x0, 0x31 },
  388. { 0x03, 0x00, 0x03, 0x0, 0x30 },
  389. { 0x03, 0x00, 0x03, 0x0, 0x2e },
  390. { 0x03, 0x00, 0x03, 0x0, 0x2d },
  391. { 0x03, 0x00, 0x03, 0x0, 0x2c },
  392. { 0x03, 0x00, 0x03, 0x0, 0x2b },
  393. { 0x03, 0x00, 0x03, 0x0, 0x29 },
  394. { 0x03, 0x00, 0x02, 0x0, 0x3d },
  395. { 0x03, 0x00, 0x02, 0x0, 0x3b },
  396. { 0x03, 0x00, 0x02, 0x0, 0x39 },
  397. { 0x03, 0x00, 0x02, 0x0, 0x38 },
  398. { 0x03, 0x00, 0x02, 0x0, 0x36 },
  399. { 0x03, 0x00, 0x02, 0x0, 0x35 },
  400. { 0x03, 0x00, 0x02, 0x0, 0x33 },
  401. { 0x03, 0x00, 0x02, 0x0, 0x32 },
  402. { 0x03, 0x00, 0x02, 0x0, 0x30 },
  403. { 0x03, 0x00, 0x02, 0x0, 0x2f },
  404. { 0x03, 0x00, 0x02, 0x0, 0x2e },
  405. { 0x03, 0x00, 0x02, 0x0, 0x2c },
  406. { 0x03, 0x00, 0x02, 0x0, 0x2b },
  407. { 0x03, 0x00, 0x02, 0x0, 0x2a },
  408. { 0x03, 0x00, 0x02, 0x0, 0x29 },
  409. { 0x03, 0x00, 0x02, 0x0, 0x27 },
  410. { 0x03, 0x00, 0x02, 0x0, 0x26 },
  411. { 0x03, 0x00, 0x02, 0x0, 0x25 },
  412. { 0x03, 0x00, 0x02, 0x0, 0x24 },
  413. { 0x03, 0x00, 0x02, 0x0, 0x23 },
  414. { 0x03, 0x00, 0x02, 0x0, 0x22 },
  415. { 0x03, 0x00, 0x02, 0x0, 0x21 },
  416. { 0x03, 0x00, 0x02, 0x0, 0x20 },
  417. { 0x03, 0x00, 0x01, 0x0, 0x3f },
  418. { 0x03, 0x00, 0x01, 0x0, 0x3d },
  419. { 0x03, 0x00, 0x01, 0x0, 0x3b },
  420. { 0x03, 0x00, 0x01, 0x0, 0x39 },
  421. };
  422. /**************************************************
  423. * SW control.
  424. **************************************************/
  425. static const u16 b43_lcntab_sw_ctl_4313_epa_rev0[] = {
  426. 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008,
  427. 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001,
  428. 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008,
  429. 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001,
  430. 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008,
  431. 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001,
  432. 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008,
  433. 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001,
  434. 0x0002, 0x0008, 0x0004, 0x0001, 0x0002, 0x0008,
  435. 0x0004, 0x0001, 0x0002, 0x0008, 0x0004, 0x0001,
  436. 0x0002, 0x0008, 0x0004, 0x0001,
  437. };
  438. /**************************************************
  439. * R/W ops.
  440. **************************************************/
  441. u32 b43_lcntab_read(struct b43_wldev *dev, u32 offset)
  442. {
  443. u32 type, value;
  444. type = offset & B43_LCNTAB_TYPEMASK;
  445. offset &= ~B43_LCNTAB_TYPEMASK;
  446. B43_WARN_ON(offset > 0xFFFF);
  447. switch (type) {
  448. case B43_LCNTAB_8BIT:
  449. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  450. value = b43_phy_read(dev, B43_PHY_LCN_TABLE_DATALO) & 0xFF;
  451. break;
  452. case B43_LCNTAB_16BIT:
  453. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  454. value = b43_phy_read(dev, B43_PHY_LCN_TABLE_DATALO);
  455. break;
  456. case B43_LCNTAB_32BIT:
  457. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  458. value = b43_phy_read(dev, B43_PHY_LCN_TABLE_DATALO);
  459. value |= (b43_phy_read(dev, B43_PHY_LCN_TABLE_DATAHI) << 16);
  460. break;
  461. default:
  462. B43_WARN_ON(1);
  463. value = 0;
  464. }
  465. return value;
  466. }
  467. void b43_lcntab_read_bulk(struct b43_wldev *dev, u32 offset,
  468. unsigned int nr_elements, void *_data)
  469. {
  470. u32 type;
  471. u8 *data = _data;
  472. unsigned int i;
  473. type = offset & B43_LCNTAB_TYPEMASK;
  474. offset &= ~B43_LCNTAB_TYPEMASK;
  475. B43_WARN_ON(offset > 0xFFFF);
  476. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  477. for (i = 0; i < nr_elements; i++) {
  478. switch (type) {
  479. case B43_LCNTAB_8BIT:
  480. *data = b43_phy_read(dev,
  481. B43_PHY_LCN_TABLE_DATALO) & 0xFF;
  482. data++;
  483. break;
  484. case B43_LCNTAB_16BIT:
  485. *((u16 *)data) = b43_phy_read(dev,
  486. B43_PHY_LCN_TABLE_DATALO);
  487. data += 2;
  488. break;
  489. case B43_LCNTAB_32BIT:
  490. *((u32 *)data) = b43_phy_read(dev,
  491. B43_PHY_LCN_TABLE_DATALO);
  492. *((u32 *)data) |= (b43_phy_read(dev,
  493. B43_PHY_LCN_TABLE_DATAHI) << 16);
  494. data += 4;
  495. break;
  496. default:
  497. B43_WARN_ON(1);
  498. }
  499. }
  500. }
  501. void b43_lcntab_write(struct b43_wldev *dev, u32 offset, u32 value)
  502. {
  503. u32 type;
  504. type = offset & B43_LCNTAB_TYPEMASK;
  505. offset &= 0xFFFF;
  506. switch (type) {
  507. case B43_LCNTAB_8BIT:
  508. B43_WARN_ON(value & ~0xFF);
  509. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  510. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  511. break;
  512. case B43_LCNTAB_16BIT:
  513. B43_WARN_ON(value & ~0xFFFF);
  514. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  515. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  516. break;
  517. case B43_LCNTAB_32BIT:
  518. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  519. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATAHI, value >> 16);
  520. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value & 0xFFFF);
  521. break;
  522. default:
  523. B43_WARN_ON(1);
  524. }
  525. return;
  526. }
  527. void b43_lcntab_write_bulk(struct b43_wldev *dev, u32 offset,
  528. unsigned int nr_elements, const void *_data)
  529. {
  530. u32 type, value;
  531. const u8 *data = _data;
  532. unsigned int i;
  533. type = offset & B43_LCNTAB_TYPEMASK;
  534. offset &= ~B43_LCNTAB_TYPEMASK;
  535. B43_WARN_ON(offset > 0xFFFF);
  536. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  537. for (i = 0; i < nr_elements; i++) {
  538. switch (type) {
  539. case B43_LCNTAB_8BIT:
  540. value = *data;
  541. data++;
  542. B43_WARN_ON(value & ~0xFF);
  543. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  544. break;
  545. case B43_LCNTAB_16BIT:
  546. value = *((u16 *)data);
  547. data += 2;
  548. B43_WARN_ON(value & ~0xFFFF);
  549. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  550. break;
  551. case B43_LCNTAB_32BIT:
  552. value = *((u32 *)data);
  553. data += 4;
  554. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATAHI,
  555. value >> 16);
  556. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO,
  557. value & 0xFFFF);
  558. break;
  559. default:
  560. B43_WARN_ON(1);
  561. }
  562. }
  563. }
  564. /**************************************************
  565. * Tables ops.
  566. **************************************************/
  567. #define lcntab_upload(dev, offset, data) do { \
  568. b43_lcntab_write_bulk(dev, offset, ARRAY_SIZE(data), data); \
  569. } while (0)
  570. static void b43_phy_lcn_upload_static_tables(struct b43_wldev *dev)
  571. {
  572. lcntab_upload(dev, B43_LCNTAB16(0x02, 0), b43_lcntab_0x02);
  573. lcntab_upload(dev, B43_LCNTAB16(0x01, 0), b43_lcntab_0x01);
  574. lcntab_upload(dev, B43_LCNTAB32(0x0b, 0), b43_lcntab_0x0b);
  575. lcntab_upload(dev, B43_LCNTAB32(0x0c, 0), b43_lcntab_0x0c);
  576. lcntab_upload(dev, B43_LCNTAB32(0x0d, 0), b43_lcntab_0x0d);
  577. lcntab_upload(dev, B43_LCNTAB16(0x0e, 0), b43_lcntab_0x0e);
  578. lcntab_upload(dev, B43_LCNTAB16(0x0f, 0), b43_lcntab_0x0f);
  579. lcntab_upload(dev, B43_LCNTAB16(0x10, 0), b43_lcntab_0x10);
  580. lcntab_upload(dev, B43_LCNTAB16(0x11, 0), b43_lcntab_0x11);
  581. lcntab_upload(dev, B43_LCNTAB32(0x12, 0), b43_lcntab_0x12);
  582. lcntab_upload(dev, B43_LCNTAB16(0x14, 0), b43_lcntab_0x14);
  583. lcntab_upload(dev, B43_LCNTAB16(0x17, 0), b43_lcntab_0x17);
  584. lcntab_upload(dev, B43_LCNTAB16(0x00, 0), b43_lcntab_0x00);
  585. lcntab_upload(dev, B43_LCNTAB32(0x18, 0), b43_lcntab_0x18);
  586. }
  587. static void b43_phy_lcn_load_tx_gain_tab(struct b43_wldev *dev,
  588. const struct b43_lcntab_tx_gain_tbl_entry *gain_table)
  589. {
  590. u32 i;
  591. u32 val;
  592. u16 pa_gain = 0x70;
  593. if (dev->dev->bus_sprom->boardflags_lo & B43_BFL_FEM)
  594. pa_gain = 0x10;
  595. for (i = 0; i < B43_LCNTAB_TX_GAIN_SIZE; i++) {
  596. val = ((pa_gain << 24) |
  597. (gain_table[i].pad << 16) |
  598. (gain_table[i].pga << 8) |
  599. gain_table[i].gm);
  600. b43_lcntab_write(dev, B43_LCNTAB32(0x7, 0xc0 + i), val);
  601. /* brcmsmac doesn't maskset, we follow newer wl here */
  602. val = b43_lcntab_read(dev, B43_LCNTAB32(0x7, 0x140 + i));
  603. val &= 0x000fffff;
  604. val |= ((gain_table[i].dac << 28) |
  605. (gain_table[i].bb_mult << 20));
  606. b43_lcntab_write(dev, B43_LCNTAB32(0x7, 0x140 + i), val);
  607. }
  608. }
  609. /* wlc_lcnphy_load_rfpower */
  610. static void b43_phy_lcn_load_rfpower(struct b43_wldev *dev)
  611. {
  612. u32 bbmult, rfgain;
  613. u8 i;
  614. for (i = 0; i < 128; i++) {
  615. bbmult = b43_lcntab_read(dev, B43_LCNTAB32(0x7, 0x140 + i));
  616. bbmult >>= 20;
  617. rfgain = b43_lcntab_read(dev, B43_LCNTAB32(0x7, 0xc0 + i));
  618. /* TODO: calculate value for 0x240 + i table offset
  619. * b43_lcntab_write(dev, B43_LCNTAB32(0x7, 0x240 + i), val);
  620. */
  621. }
  622. }
  623. /* Not implemented in brcmsmac, noticed in wl in MMIO dump */
  624. static void b43_phy_lcn_rewrite_rfpower_table(struct b43_wldev *dev)
  625. {
  626. int i;
  627. u32 tmp;
  628. for (i = 0; i < 128; i++) {
  629. tmp = b43_lcntab_read(dev, B43_LCNTAB32(0x7, 0x240 + i));
  630. b43_lcntab_write(dev, B43_LCNTAB32(0x7, 0x240 + i), tmp);
  631. }
  632. }
  633. /* wlc_lcnphy_clear_papd_comptable */
  634. static void b43_phy_lcn_clean_papd_comp_table(struct b43_wldev *dev)
  635. {
  636. u8 i;
  637. for (i = 0; i < 0x80; i++)
  638. b43_lcntab_write(dev, B43_LCNTAB32(0x18, i), 0x80000);
  639. }
  640. /* wlc_lcnphy_tbl_init */
  641. void b43_phy_lcn_tables_init(struct b43_wldev *dev)
  642. {
  643. struct ssb_sprom *sprom = dev->dev->bus_sprom;
  644. b43_phy_lcn_upload_static_tables(dev);
  645. if (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) {
  646. if (sprom->boardflags_lo & B43_BFL_FEM)
  647. b43_phy_lcn_load_tx_gain_tab(dev,
  648. b43_lcntab_tx_gain_tbl_2ghz_ext_pa_rev0);
  649. else
  650. b43err(dev->wl,
  651. "TX gain table unknown for this card\n");
  652. }
  653. if (sprom->boardflags_lo & B43_BFL_FEM &&
  654. !(sprom->boardflags_hi & B43_BFH_FEM_BT))
  655. b43_lcntab_write_bulk(dev, B43_LCNTAB16(0xf, 0),
  656. ARRAY_SIZE(b43_lcntab_sw_ctl_4313_epa_rev0),
  657. b43_lcntab_sw_ctl_4313_epa_rev0);
  658. else
  659. b43err(dev->wl, "SW ctl table is unknown for this card\n");
  660. b43_phy_lcn_load_rfpower(dev);
  661. b43_phy_lcn_rewrite_rfpower_table(dev);
  662. b43_phy_lcn_clean_papd_comp_table(dev);
  663. }