tables_phy_lcn.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. /*
  2. Broadcom B43 wireless driver
  3. IEEE 802.11n LCN-PHY data tables
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING. If not, write to
  14. the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. #include "b43.h"
  18. #include "tables_phy_lcn.h"
  19. #include "phy_common.h"
  20. #include "phy_lcn.h"
  21. static const u16 b43_lcntab_0x02[] = {
  22. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  23. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  24. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  25. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  26. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  27. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  28. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  29. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  30. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  31. 0x014d, 0x014d, 0x014d, 0x014d, 0x014d, 0x014d,
  32. 0x014d, 0x014d, 0x014d, 0x014d,
  33. };
  34. static const u16 b43_lcntab_0x01[] = {
  35. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  36. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  37. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  38. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  39. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  40. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  41. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  42. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  43. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  44. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  45. 0x0000, 0x0000, 0x0000, 0x0000,
  46. };
  47. static const u32 b43_lcntab_0x0b[] = {
  48. 0x000141f8, 0x000021f8, 0x000021fb, 0x000041fb,
  49. 0x0001fedb, 0x0000217b, 0x00002133, 0x000040eb,
  50. 0x0001fea3, 0x0000024b,
  51. };
  52. static const u32 b43_lcntab_0x0c[] = {
  53. 0x00100001, 0x00200010, 0x00300001, 0x00400010,
  54. 0x00500022, 0x00600122, 0x00700222, 0x00800322,
  55. 0x00900422, 0x00a00522, 0x00b00622, 0x00c00722,
  56. 0x00d00822, 0x00f00922, 0x00100a22, 0x00200b22,
  57. 0x00300c22, 0x00400d22, 0x00500e22, 0x00600f22,
  58. };
  59. static const u32 b43_lcntab_0x0d[] = {
  60. 0x00000000, 0x00000000, 0x10000000, 0x00000000,
  61. 0x20000000, 0x00000000, 0x30000000, 0x00000000,
  62. 0x40000000, 0x00000000, 0x50000000, 0x00000000,
  63. 0x60000000, 0x00000000, 0x70000000, 0x00000000,
  64. 0x80000000, 0x00000000, 0x90000000, 0x00000008,
  65. 0xa0000000, 0x00000008, 0xb0000000, 0x00000008,
  66. 0xc0000000, 0x00000008, 0xd0000000, 0x00000008,
  67. 0xe0000000, 0x00000008, 0xf0000000, 0x00000008,
  68. 0x00000000, 0x00000009, 0x10000000, 0x00000009,
  69. 0x20000000, 0x00000019, 0x30000000, 0x00000019,
  70. 0x40000000, 0x00000019, 0x50000000, 0x00000019,
  71. 0x60000000, 0x00000019, 0x70000000, 0x00000019,
  72. 0x80000000, 0x00000019, 0x90000000, 0x00000019,
  73. 0xa0000000, 0x00000019, 0xb0000000, 0x00000019,
  74. 0xc0000000, 0x00000019, 0xd0000000, 0x00000019,
  75. 0xe0000000, 0x00000019, 0xf0000000, 0x00000019,
  76. 0x00000000, 0x0000001a, 0x10000000, 0x0000001a,
  77. 0x20000000, 0x0000001a, 0x30000000, 0x0000001a,
  78. 0x40000000, 0x0000001a, 0x50000000, 0x00000002,
  79. 0x60000000, 0x00000002, 0x70000000, 0x00000002,
  80. 0x80000000, 0x00000002, 0x90000000, 0x00000002,
  81. 0xa0000000, 0x00000002, 0xb0000000, 0x00000002,
  82. 0xc0000000, 0x0000000a, 0xd0000000, 0x0000000a,
  83. 0xe0000000, 0x0000000a, 0xf0000000, 0x0000000a,
  84. 0x00000000, 0x0000000b, 0x10000000, 0x0000000b,
  85. 0x20000000, 0x0000000b, 0x30000000, 0x0000000b,
  86. 0x40000000, 0x0000000b, 0x50000000, 0x0000001b,
  87. 0x60000000, 0x0000001b, 0x70000000, 0x0000001b,
  88. 0x80000000, 0x0000001b, 0x90000000, 0x0000001b,
  89. 0xa0000000, 0x0000001b, 0xb0000000, 0x0000001b,
  90. 0xc0000000, 0x0000001b, 0xd0000000, 0x0000001b,
  91. 0xe0000000, 0x0000001b, 0xf0000000, 0x0000001b,
  92. 0x00000000, 0x0000001c, 0x10000000, 0x0000001c,
  93. 0x20000000, 0x0000001c, 0x30000000, 0x0000001c,
  94. 0x40000000, 0x0000001c, 0x50000000, 0x0000001c,
  95. 0x60000000, 0x0000001c, 0x70000000, 0x0000001c,
  96. 0x80000000, 0x0000001c, 0x90000000, 0x0000001c,
  97. };
  98. static const u16 b43_lcntab_0x0e[] = {
  99. 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406,
  100. 0x0407, 0x0408, 0x0409, 0x040a, 0x058b, 0x058c,
  101. 0x058d, 0x058e, 0x058f, 0x0090, 0x0091, 0x0092,
  102. 0x0193, 0x0194, 0x0195, 0x0196, 0x0197, 0x0198,
  103. 0x0199, 0x019a, 0x019b, 0x019c, 0x019d, 0x019e,
  104. 0x019f, 0x01a0, 0x01a1, 0x01a2, 0x01a3, 0x01a4,
  105. 0x01a5, 0x0000,
  106. };
  107. static const u16 b43_lcntab_0x0f[] = {
  108. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  109. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  110. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  111. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  112. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  113. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  114. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  115. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  116. 0x000a, 0x0009, 0x0006, 0x0005, 0x000a, 0x0009,
  117. 0x0006, 0x0005, 0x000a, 0x0009, 0x0006, 0x0005,
  118. 0x000a, 0x0009, 0x0006, 0x0005,
  119. };
  120. static const u16 b43_lcntab_0x10[] = {
  121. 0x005f, 0x0036, 0x0029, 0x001f, 0x005f, 0x0036,
  122. 0x0029, 0x001f, 0x005f, 0x0036, 0x0029, 0x001f,
  123. 0x005f, 0x0036, 0x0029, 0x001f,
  124. };
  125. static const u16 b43_lcntab_0x11[] = {
  126. 0x0009, 0x000f, 0x0014, 0x0018, 0x00fe, 0x0007,
  127. 0x000b, 0x000f, 0x00fb, 0x00fe, 0x0001, 0x0005,
  128. 0x0008, 0x000b, 0x000e, 0x0011, 0x0014, 0x0017,
  129. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  130. 0x0000, 0x0003, 0x0006, 0x0009, 0x000c, 0x000f,
  131. 0x0012, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  132. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0003,
  133. 0x0006, 0x0009, 0x000c, 0x000f, 0x0012, 0x0015,
  134. 0x0018, 0x001b, 0x0000, 0x0000, 0x0000, 0x0000,
  135. 0x0000, 0x0000, 0x0003, 0x00eb, 0x0000, 0x0000,
  136. };
  137. static const u32 b43_lcntab_0x12[] = {
  138. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  139. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  140. 0x00000004, 0x00000000, 0x00000004, 0x00000008,
  141. 0x00000001, 0x00000005, 0x00000009, 0x0000000d,
  142. 0x0000004d, 0x0000008d, 0x0000000d, 0x0000004d,
  143. 0x0000008d, 0x000000cd, 0x0000004f, 0x0000008f,
  144. 0x000000cf, 0x000000d3, 0x00000113, 0x00000513,
  145. 0x00000913, 0x00000953, 0x00000d53, 0x00001153,
  146. 0x00001193, 0x00005193, 0x00009193, 0x0000d193,
  147. 0x00011193, 0x00000000, 0x00000000, 0x00000000,
  148. 0x00000000, 0x00000000, 0x00000000, 0x00000004,
  149. 0x00000000, 0x00000004, 0x00000008, 0x00000001,
  150. 0x00000005, 0x00000009, 0x0000000d, 0x0000004d,
  151. 0x0000008d, 0x0000000d, 0x0000004d, 0x0000008d,
  152. 0x000000cd, 0x0000004f, 0x0000008f, 0x000000cf,
  153. 0x000000d3, 0x00000113, 0x00000513, 0x00000913,
  154. 0x00000953, 0x00000d53, 0x00001153, 0x00005153,
  155. 0x00009153, 0x0000d153, 0x00011153, 0x00015153,
  156. 0x00019153, 0x0001d153, 0x00000000, 0x00000000,
  157. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  158. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  159. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  160. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  161. 0x00000000, 0x00000000, 0x00000000, 0x00000000,
  162. };
  163. static const u16 b43_lcntab_0x14[] = {
  164. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  165. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  166. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  167. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  168. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  169. 0x0002, 0x0003, 0x0001, 0x0003, 0x0002, 0x0001,
  170. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  171. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  172. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  173. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  174. 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
  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, 0x0002, 0x0003,
  180. 0x0001, 0x0003, 0x0002, 0x0001, 0x0001, 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,
  186. };
  187. static const u16 b43_lcntab_0x17[] = {
  188. 0x001a, 0x0034, 0x004e, 0x0068, 0x009c, 0x00d0,
  189. 0x00ea, 0x0104, 0x0034, 0x0068, 0x009c, 0x00d0,
  190. 0x0138, 0x01a0, 0x01d4, 0x0208, 0x004e, 0x009c,
  191. 0x00ea, 0x0138, 0x01d4, 0x0270, 0x02be, 0x030c,
  192. 0x0068, 0x00d0, 0x0138, 0x01a0, 0x0270, 0x0340,
  193. 0x03a8, 0x0410, 0x0018, 0x009c, 0x00d0, 0x0104,
  194. 0x00ea, 0x0138, 0x0186, 0x00d0, 0x0104, 0x0104,
  195. 0x0138, 0x016c, 0x016c, 0x01a0, 0x0138, 0x0186,
  196. 0x0186, 0x01d4, 0x0222, 0x0222, 0x0270, 0x0104,
  197. 0x0138, 0x016c, 0x0138, 0x016c, 0x01a0, 0x01d4,
  198. 0x01a0, 0x01d4, 0x0208, 0x0208, 0x023c, 0x0186,
  199. 0x01d4, 0x0222, 0x01d4, 0x0222, 0x0270, 0x02be,
  200. 0x0270, 0x02be, 0x030c, 0x030c, 0x035a, 0x0036,
  201. 0x006c, 0x00a2, 0x00d8, 0x0144, 0x01b0, 0x01e6,
  202. 0x021c, 0x006c, 0x00d8, 0x0144, 0x01b0, 0x0288,
  203. 0x0360, 0x03cc, 0x0438, 0x00a2, 0x0144, 0x01e6,
  204. 0x0288, 0x03cc, 0x0510, 0x05b2, 0x0654, 0x00d8,
  205. 0x01b0, 0x0288, 0x0360, 0x0510, 0x06c0, 0x0798,
  206. 0x0870, 0x0018, 0x0144, 0x01b0, 0x021c, 0x01e6,
  207. 0x0288, 0x032a, 0x01b0, 0x021c, 0x021c, 0x0288,
  208. 0x02f4, 0x02f4, 0x0360, 0x0288, 0x032a, 0x032a,
  209. 0x03cc, 0x046e, 0x046e, 0x0510, 0x021c, 0x0288,
  210. 0x02f4, 0x0288, 0x02f4, 0x0360, 0x03cc, 0x0360,
  211. 0x03cc, 0x0438, 0x0438, 0x04a4, 0x032a, 0x03cc,
  212. 0x046e, 0x03cc, 0x046e, 0x0510, 0x05b2, 0x0510,
  213. 0x05b2, 0x0654, 0x0654, 0x06f6,
  214. };
  215. static const u16 b43_lcntab_0x00[] = {
  216. 0x0200, 0x0300, 0x0400, 0x0600, 0x0800, 0x0b00,
  217. 0x1000, 0x1001, 0x1002, 0x1003, 0x1004, 0x1005,
  218. 0x1006, 0x1007, 0x1707, 0x2007, 0x2d07, 0x4007,
  219. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  220. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  221. 0x0000, 0x0000, 0x0200, 0x0300, 0x0400, 0x0600,
  222. 0x0800, 0x0b00, 0x1000, 0x1001, 0x1002, 0x1003,
  223. 0x1004, 0x1005, 0x1006, 0x1007, 0x1707, 0x2007,
  224. 0x2d07, 0x4007, 0x0000, 0x0000, 0x0000, 0x0000,
  225. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  226. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  227. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  228. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  229. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  230. 0x0000, 0x0000, 0x0000, 0x4000, 0x0000, 0x0000,
  231. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  232. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  233. 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  234. };
  235. static const u32 b43_lcntab_0x18[] = {
  236. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  237. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  238. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  239. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  240. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  241. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  242. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  243. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  244. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  245. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  246. 0x00080000, 0x00080000, 0x00080000, 0x00080000,
  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. };
  277. /**************************************************
  278. * R/W ops.
  279. **************************************************/
  280. u32 b43_lcntab_read(struct b43_wldev *dev, u32 offset)
  281. {
  282. u32 type, value;
  283. type = offset & B43_LCNTAB_TYPEMASK;
  284. offset &= ~B43_LCNTAB_TYPEMASK;
  285. B43_WARN_ON(offset > 0xFFFF);
  286. switch (type) {
  287. case B43_LCNTAB_8BIT:
  288. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  289. value = b43_phy_read(dev, B43_PHY_LCN_TABLE_DATALO) & 0xFF;
  290. break;
  291. case B43_LCNTAB_16BIT:
  292. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  293. value = b43_phy_read(dev, B43_PHY_LCN_TABLE_DATALO);
  294. break;
  295. case B43_LCNTAB_32BIT:
  296. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  297. value = b43_phy_read(dev, B43_PHY_LCN_TABLE_DATAHI);
  298. value <<= 16;
  299. value |= b43_phy_read(dev, B43_PHY_LCN_TABLE_DATALO);
  300. break;
  301. default:
  302. B43_WARN_ON(1);
  303. value = 0;
  304. }
  305. return value;
  306. }
  307. void b43_lcntab_read_bulk(struct b43_wldev *dev, u32 offset,
  308. unsigned int nr_elements, void *_data)
  309. {
  310. u32 type;
  311. u8 *data = _data;
  312. unsigned int i;
  313. type = offset & B43_LCNTAB_TYPEMASK;
  314. offset &= ~B43_LCNTAB_TYPEMASK;
  315. B43_WARN_ON(offset > 0xFFFF);
  316. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  317. for (i = 0; i < nr_elements; i++) {
  318. switch (type) {
  319. case B43_LCNTAB_8BIT:
  320. *data = b43_phy_read(dev,
  321. B43_PHY_LCN_TABLE_DATALO) & 0xFF;
  322. data++;
  323. break;
  324. case B43_LCNTAB_16BIT:
  325. *((u16 *)data) = b43_phy_read(dev,
  326. B43_PHY_LCN_TABLE_DATALO);
  327. data += 2;
  328. break;
  329. case B43_LCNTAB_32BIT:
  330. *((u32 *)data) = b43_phy_read(dev,
  331. B43_PHY_LCN_TABLE_DATAHI);
  332. *((u32 *)data) <<= 16;
  333. *((u32 *)data) |= b43_phy_read(dev,
  334. B43_PHY_LCN_TABLE_DATALO);
  335. data += 4;
  336. break;
  337. default:
  338. B43_WARN_ON(1);
  339. }
  340. }
  341. }
  342. void b43_lcntab_write(struct b43_wldev *dev, u32 offset, u32 value)
  343. {
  344. u32 type;
  345. type = offset & B43_LCNTAB_TYPEMASK;
  346. offset &= 0xFFFF;
  347. switch (type) {
  348. case B43_LCNTAB_8BIT:
  349. B43_WARN_ON(value & ~0xFF);
  350. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  351. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  352. break;
  353. case B43_LCNTAB_16BIT:
  354. B43_WARN_ON(value & ~0xFFFF);
  355. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  356. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  357. break;
  358. case B43_LCNTAB_32BIT:
  359. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  360. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATAHI, value >> 16);
  361. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value & 0xFFFF);
  362. break;
  363. default:
  364. B43_WARN_ON(1);
  365. }
  366. return;
  367. }
  368. void b43_lcntab_write_bulk(struct b43_wldev *dev, u32 offset,
  369. unsigned int nr_elements, const void *_data)
  370. {
  371. u32 type, value;
  372. const u8 *data = _data;
  373. unsigned int i;
  374. type = offset & B43_LCNTAB_TYPEMASK;
  375. offset &= ~B43_LCNTAB_TYPEMASK;
  376. B43_WARN_ON(offset > 0xFFFF);
  377. b43_phy_write(dev, B43_PHY_LCN_TABLE_ADDR, offset);
  378. for (i = 0; i < nr_elements; i++) {
  379. switch (type) {
  380. case B43_LCNTAB_8BIT:
  381. value = *data;
  382. data++;
  383. B43_WARN_ON(value & ~0xFF);
  384. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  385. break;
  386. case B43_LCNTAB_16BIT:
  387. value = *((u16 *)data);
  388. data += 2;
  389. B43_WARN_ON(value & ~0xFFFF);
  390. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO, value);
  391. break;
  392. case B43_LCNTAB_32BIT:
  393. value = *((u32 *)data);
  394. data += 4;
  395. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATAHI,
  396. value >> 16);
  397. b43_phy_write(dev, B43_PHY_LCN_TABLE_DATALO,
  398. value & 0xFFFF);
  399. break;
  400. default:
  401. B43_WARN_ON(1);
  402. }
  403. }
  404. }
  405. /**************************************************
  406. * Tables ops.
  407. **************************************************/
  408. #define lcntab_upload(dev, offset, data) do { \
  409. b43_lcntab_write_bulk(dev, offset, ARRAY_SIZE(data), data); \
  410. } while (0)
  411. void b43_phy_lcn_tables_init(struct b43_wldev *dev)
  412. {
  413. lcntab_upload(dev, B43_LCNTAB16(0x02, 0), b43_lcntab_0x02);
  414. lcntab_upload(dev, B43_LCNTAB16(0x01, 0), b43_lcntab_0x01);
  415. lcntab_upload(dev, B43_LCNTAB32(0x0b, 0), b43_lcntab_0x0b);
  416. lcntab_upload(dev, B43_LCNTAB32(0x0c, 0), b43_lcntab_0x0c);
  417. lcntab_upload(dev, B43_LCNTAB32(0x0d, 0), b43_lcntab_0x0d);
  418. lcntab_upload(dev, B43_LCNTAB16(0x0e, 0), b43_lcntab_0x0e);
  419. lcntab_upload(dev, B43_LCNTAB16(0x0f, 0), b43_lcntab_0x0f);
  420. lcntab_upload(dev, B43_LCNTAB16(0x10, 0), b43_lcntab_0x10);
  421. lcntab_upload(dev, B43_LCNTAB16(0x11, 0), b43_lcntab_0x11);
  422. lcntab_upload(dev, B43_LCNTAB32(0x12, 0), b43_lcntab_0x12);
  423. lcntab_upload(dev, B43_LCNTAB16(0x14, 0), b43_lcntab_0x14);
  424. lcntab_upload(dev, B43_LCNTAB16(0x17, 0), b43_lcntab_0x17);
  425. lcntab_upload(dev, B43_LCNTAB16(0x00, 0), b43_lcntab_0x00);
  426. lcntab_upload(dev, B43_LCNTAB32(0x18, 0), b43_lcntab_0x18);
  427. }