initvals_phy.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * (c) Copyright 2002-2010, Ralink Technology, Inc.
  3. * Copyright (C) 2015 Jakub Kicinski <kubakici@wp.pl>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation
  8. *
  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. */
  14. #ifndef __MT7601U_PHY_INITVALS_H
  15. #define __MT7601U_PHY_INITVALS_H
  16. #define RF_REG_PAIR(bank, reg, value) \
  17. { MT_MCU_MEMMAP_RF | (bank) << 16 | (reg), value }
  18. static const struct mt76_reg_pair rf_central[] = {
  19. /* Bank 0 - for central blocks: BG, PLL, XTAL, LO, ADC/DAC */
  20. RF_REG_PAIR(0, 0, 0x02),
  21. RF_REG_PAIR(0, 1, 0x01),
  22. RF_REG_PAIR(0, 2, 0x11),
  23. RF_REG_PAIR(0, 3, 0xff),
  24. RF_REG_PAIR(0, 4, 0x0a),
  25. RF_REG_PAIR(0, 5, 0x20),
  26. RF_REG_PAIR(0, 6, 0x00),
  27. /* B/G */
  28. RF_REG_PAIR(0, 7, 0x00),
  29. RF_REG_PAIR(0, 8, 0x00),
  30. RF_REG_PAIR(0, 9, 0x00),
  31. RF_REG_PAIR(0, 10, 0x00),
  32. RF_REG_PAIR(0, 11, 0x21),
  33. /* XO */
  34. RF_REG_PAIR(0, 13, 0x00), /* 40mhz xtal */
  35. /* RF_REG_PAIR(0, 13, 0x13), */ /* 20mhz xtal */
  36. RF_REG_PAIR(0, 14, 0x7c),
  37. RF_REG_PAIR(0, 15, 0x22),
  38. RF_REG_PAIR(0, 16, 0x80),
  39. /* PLL */
  40. RF_REG_PAIR(0, 17, 0x99),
  41. RF_REG_PAIR(0, 18, 0x99),
  42. RF_REG_PAIR(0, 19, 0x09),
  43. RF_REG_PAIR(0, 20, 0x50),
  44. RF_REG_PAIR(0, 21, 0xb0),
  45. RF_REG_PAIR(0, 22, 0x00),
  46. RF_REG_PAIR(0, 23, 0xc5),
  47. RF_REG_PAIR(0, 24, 0xfc),
  48. RF_REG_PAIR(0, 25, 0x40),
  49. RF_REG_PAIR(0, 26, 0x4d),
  50. RF_REG_PAIR(0, 27, 0x02),
  51. RF_REG_PAIR(0, 28, 0x72),
  52. RF_REG_PAIR(0, 29, 0x01),
  53. RF_REG_PAIR(0, 30, 0x00),
  54. RF_REG_PAIR(0, 31, 0x00),
  55. /* test ports */
  56. RF_REG_PAIR(0, 32, 0x00),
  57. RF_REG_PAIR(0, 33, 0x00),
  58. RF_REG_PAIR(0, 34, 0x23),
  59. RF_REG_PAIR(0, 35, 0x01), /* change setting to reduce spurs */
  60. RF_REG_PAIR(0, 36, 0x00),
  61. RF_REG_PAIR(0, 37, 0x00),
  62. /* ADC/DAC */
  63. RF_REG_PAIR(0, 38, 0x00),
  64. RF_REG_PAIR(0, 39, 0x20),
  65. RF_REG_PAIR(0, 40, 0x00),
  66. RF_REG_PAIR(0, 41, 0xd0),
  67. RF_REG_PAIR(0, 42, 0x1b),
  68. RF_REG_PAIR(0, 43, 0x02),
  69. RF_REG_PAIR(0, 44, 0x00),
  70. };
  71. static const struct mt76_reg_pair rf_channel[] = {
  72. RF_REG_PAIR(4, 0, 0x01),
  73. RF_REG_PAIR(4, 1, 0x00),
  74. RF_REG_PAIR(4, 2, 0x00),
  75. RF_REG_PAIR(4, 3, 0x00),
  76. /* LDO */
  77. RF_REG_PAIR(4, 4, 0x00),
  78. RF_REG_PAIR(4, 5, 0x08),
  79. RF_REG_PAIR(4, 6, 0x00),
  80. /* RX */
  81. RF_REG_PAIR(4, 7, 0x5b),
  82. RF_REG_PAIR(4, 8, 0x52),
  83. RF_REG_PAIR(4, 9, 0xb6),
  84. RF_REG_PAIR(4, 10, 0x57),
  85. RF_REG_PAIR(4, 11, 0x33),
  86. RF_REG_PAIR(4, 12, 0x22),
  87. RF_REG_PAIR(4, 13, 0x3d),
  88. RF_REG_PAIR(4, 14, 0x3e),
  89. RF_REG_PAIR(4, 15, 0x13),
  90. RF_REG_PAIR(4, 16, 0x22),
  91. RF_REG_PAIR(4, 17, 0x23),
  92. RF_REG_PAIR(4, 18, 0x02),
  93. RF_REG_PAIR(4, 19, 0xa4),
  94. RF_REG_PAIR(4, 20, 0x01),
  95. RF_REG_PAIR(4, 21, 0x12),
  96. RF_REG_PAIR(4, 22, 0x80),
  97. RF_REG_PAIR(4, 23, 0xb3),
  98. RF_REG_PAIR(4, 24, 0x00), /* reserved */
  99. RF_REG_PAIR(4, 25, 0x00), /* reserved */
  100. RF_REG_PAIR(4, 26, 0x00), /* reserved */
  101. RF_REG_PAIR(4, 27, 0x00), /* reserved */
  102. /* LOGEN */
  103. RF_REG_PAIR(4, 28, 0x18),
  104. RF_REG_PAIR(4, 29, 0xee),
  105. RF_REG_PAIR(4, 30, 0x6b),
  106. RF_REG_PAIR(4, 31, 0x31),
  107. RF_REG_PAIR(4, 32, 0x5d),
  108. RF_REG_PAIR(4, 33, 0x00), /* reserved */
  109. /* TX */
  110. RF_REG_PAIR(4, 34, 0x96),
  111. RF_REG_PAIR(4, 35, 0x55),
  112. RF_REG_PAIR(4, 36, 0x08),
  113. RF_REG_PAIR(4, 37, 0xbb),
  114. RF_REG_PAIR(4, 38, 0xb3),
  115. RF_REG_PAIR(4, 39, 0xb3),
  116. RF_REG_PAIR(4, 40, 0x03),
  117. RF_REG_PAIR(4, 41, 0x00), /* reserved */
  118. RF_REG_PAIR(4, 42, 0x00), /* reserved */
  119. RF_REG_PAIR(4, 43, 0xc5),
  120. RF_REG_PAIR(4, 44, 0xc5),
  121. RF_REG_PAIR(4, 45, 0xc5),
  122. RF_REG_PAIR(4, 46, 0x07),
  123. RF_REG_PAIR(4, 47, 0xa8),
  124. RF_REG_PAIR(4, 48, 0xef),
  125. RF_REG_PAIR(4, 49, 0x1a),
  126. /* PA */
  127. RF_REG_PAIR(4, 54, 0x07),
  128. RF_REG_PAIR(4, 55, 0xa7),
  129. RF_REG_PAIR(4, 56, 0xcc),
  130. RF_REG_PAIR(4, 57, 0x14),
  131. RF_REG_PAIR(4, 58, 0x07),
  132. RF_REG_PAIR(4, 59, 0xa8),
  133. RF_REG_PAIR(4, 60, 0xd7),
  134. RF_REG_PAIR(4, 61, 0x10),
  135. RF_REG_PAIR(4, 62, 0x1c),
  136. RF_REG_PAIR(4, 63, 0x00), /* reserved */
  137. };
  138. static const struct mt76_reg_pair rf_vga[] = {
  139. RF_REG_PAIR(5, 0, 0x47),
  140. RF_REG_PAIR(5, 1, 0x00),
  141. RF_REG_PAIR(5, 2, 0x00),
  142. RF_REG_PAIR(5, 3, 0x08),
  143. RF_REG_PAIR(5, 4, 0x04),
  144. RF_REG_PAIR(5, 5, 0x20),
  145. RF_REG_PAIR(5, 6, 0x3a),
  146. RF_REG_PAIR(5, 7, 0x3a),
  147. RF_REG_PAIR(5, 8, 0x00),
  148. RF_REG_PAIR(5, 9, 0x00),
  149. RF_REG_PAIR(5, 10, 0x10),
  150. RF_REG_PAIR(5, 11, 0x10),
  151. RF_REG_PAIR(5, 12, 0x10),
  152. RF_REG_PAIR(5, 13, 0x10),
  153. RF_REG_PAIR(5, 14, 0x10),
  154. RF_REG_PAIR(5, 15, 0x20),
  155. RF_REG_PAIR(5, 16, 0x22),
  156. RF_REG_PAIR(5, 17, 0x7c),
  157. RF_REG_PAIR(5, 18, 0x00),
  158. RF_REG_PAIR(5, 19, 0x00),
  159. RF_REG_PAIR(5, 20, 0x00),
  160. RF_REG_PAIR(5, 21, 0xf1),
  161. RF_REG_PAIR(5, 22, 0x11),
  162. RF_REG_PAIR(5, 23, 0x02),
  163. RF_REG_PAIR(5, 24, 0x41),
  164. RF_REG_PAIR(5, 25, 0x20),
  165. RF_REG_PAIR(5, 26, 0x00),
  166. RF_REG_PAIR(5, 27, 0xd7),
  167. RF_REG_PAIR(5, 28, 0xa2),
  168. RF_REG_PAIR(5, 29, 0x20),
  169. RF_REG_PAIR(5, 30, 0x49),
  170. RF_REG_PAIR(5, 31, 0x20),
  171. RF_REG_PAIR(5, 32, 0x04),
  172. RF_REG_PAIR(5, 33, 0xf1),
  173. RF_REG_PAIR(5, 34, 0xa1),
  174. RF_REG_PAIR(5, 35, 0x01),
  175. RF_REG_PAIR(5, 41, 0x00),
  176. RF_REG_PAIR(5, 42, 0x00),
  177. RF_REG_PAIR(5, 43, 0x00),
  178. RF_REG_PAIR(5, 44, 0x00),
  179. RF_REG_PAIR(5, 45, 0x00),
  180. RF_REG_PAIR(5, 46, 0x00),
  181. RF_REG_PAIR(5, 47, 0x00),
  182. RF_REG_PAIR(5, 48, 0x00),
  183. RF_REG_PAIR(5, 49, 0x00),
  184. RF_REG_PAIR(5, 50, 0x00),
  185. RF_REG_PAIR(5, 51, 0x00),
  186. RF_REG_PAIR(5, 52, 0x00),
  187. RF_REG_PAIR(5, 53, 0x00),
  188. RF_REG_PAIR(5, 54, 0x00),
  189. RF_REG_PAIR(5, 55, 0x00),
  190. RF_REG_PAIR(5, 56, 0x00),
  191. RF_REG_PAIR(5, 57, 0x00),
  192. RF_REG_PAIR(5, 58, 0x31),
  193. RF_REG_PAIR(5, 59, 0x31),
  194. RF_REG_PAIR(5, 60, 0x0a),
  195. RF_REG_PAIR(5, 61, 0x02),
  196. RF_REG_PAIR(5, 62, 0x00),
  197. RF_REG_PAIR(5, 63, 0x00),
  198. };
  199. /* TODO: BBP178 is set to 0xff for "CCK CH14 OBW" which overrides the settings
  200. * from channel switching. Seems stupid at best.
  201. */
  202. static const struct mt76_reg_pair bbp_high_temp[] = {
  203. { 75, 0x60 },
  204. { 92, 0x02 },
  205. { 178, 0xff }, /* For CCK CH14 OBW */
  206. { 195, 0x88 }, { 196, 0x60 },
  207. }, bbp_high_temp_bw20[] = {
  208. { 69, 0x12 },
  209. { 91, 0x07 },
  210. { 195, 0x23 }, { 196, 0x17 },
  211. { 195, 0x24 }, { 196, 0x06 },
  212. { 195, 0x81 }, { 196, 0x12 },
  213. { 195, 0x83 }, { 196, 0x17 },
  214. }, bbp_high_temp_bw40[] = {
  215. { 69, 0x15 },
  216. { 91, 0x04 },
  217. { 195, 0x23 }, { 196, 0x12 },
  218. { 195, 0x24 }, { 196, 0x08 },
  219. { 195, 0x81 }, { 196, 0x15 },
  220. { 195, 0x83 }, { 196, 0x16 },
  221. }, bbp_low_temp[] = {
  222. { 178, 0xff }, /* For CCK CH14 OBW */
  223. }, bbp_low_temp_bw20[] = {
  224. { 69, 0x12 },
  225. { 75, 0x5e },
  226. { 91, 0x07 },
  227. { 92, 0x02 },
  228. { 195, 0x23 }, { 196, 0x17 },
  229. { 195, 0x24 }, { 196, 0x06 },
  230. { 195, 0x81 }, { 196, 0x12 },
  231. { 195, 0x83 }, { 196, 0x17 },
  232. { 195, 0x88 }, { 196, 0x5e },
  233. }, bbp_low_temp_bw40[] = {
  234. { 69, 0x15 },
  235. { 75, 0x5c },
  236. { 91, 0x04 },
  237. { 92, 0x03 },
  238. { 195, 0x23 }, { 196, 0x10 },
  239. { 195, 0x24 }, { 196, 0x08 },
  240. { 195, 0x81 }, { 196, 0x15 },
  241. { 195, 0x83 }, { 196, 0x16 },
  242. { 195, 0x88 }, { 196, 0x5b },
  243. }, bbp_normal_temp[] = {
  244. { 75, 0x60 },
  245. { 92, 0x02 },
  246. { 178, 0xff }, /* For CCK CH14 OBW */
  247. { 195, 0x88 }, { 196, 0x60 },
  248. }, bbp_normal_temp_bw20[] = {
  249. { 69, 0x12 },
  250. { 91, 0x07 },
  251. { 195, 0x23 }, { 196, 0x17 },
  252. { 195, 0x24 }, { 196, 0x06 },
  253. { 195, 0x81 }, { 196, 0x12 },
  254. { 195, 0x83 }, { 196, 0x17 },
  255. }, bbp_normal_temp_bw40[] = {
  256. { 69, 0x15 },
  257. { 91, 0x04 },
  258. { 195, 0x23 }, { 196, 0x12 },
  259. { 195, 0x24 }, { 196, 0x08 },
  260. { 195, 0x81 }, { 196, 0x15 },
  261. { 195, 0x83 }, { 196, 0x16 },
  262. };
  263. #define BBP_TABLE(arr) { arr, ARRAY_SIZE(arr), }
  264. static const struct reg_table {
  265. const struct mt76_reg_pair *regs;
  266. size_t n;
  267. } bbp_mode_table[3][3] = {
  268. {
  269. BBP_TABLE(bbp_normal_temp_bw20),
  270. BBP_TABLE(bbp_normal_temp_bw40),
  271. BBP_TABLE(bbp_normal_temp),
  272. }, {
  273. BBP_TABLE(bbp_high_temp_bw20),
  274. BBP_TABLE(bbp_high_temp_bw40),
  275. BBP_TABLE(bbp_high_temp),
  276. }, {
  277. BBP_TABLE(bbp_low_temp_bw20),
  278. BBP_TABLE(bbp_low_temp_bw40),
  279. BBP_TABLE(bbp_low_temp),
  280. }
  281. };
  282. #endif