1
0

621-rt2x00-add-support-for-mt7620.patch 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  1. From: Roman Yeryomin <roman@advem.lv>
  2. Date: Tue, 1 Jul 2014 10:26:18 +0000
  3. Subject: [PATCH] mac80211: rt2x00: add support for mt7620
  4. Support for MT7620 was added to OpenWrt in r41441 and heavily reworked
  5. since in order to match the Kernel's code quality standards.
  6. Signed-off-by: Roman Yeryomin <roman@advem.lv>
  7. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  8. ---
  9. --- a/drivers/net/wireless/ralink/rt2x00/rt2800.h
  10. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800.h
  11. @@ -81,6 +81,7 @@
  12. #define RF5372 0x5372
  13. #define RF5390 0x5390
  14. #define RF5392 0x5392
  15. +#define RF7620 0x7620
  16. /*
  17. * Chipset revisions.
  18. @@ -641,6 +642,14 @@
  19. #define RF_CSR_CFG_BUSY FIELD32(0x00020000)
  20. /*
  21. + * mt7620 RF registers (reversed order)
  22. + */
  23. +#define RF_CSR_CFG_DATA_MT7620 FIELD32(0x0000ff00)
  24. +#define RF_CSR_CFG_REGNUM_MT7620 FIELD32(0x03ff0000)
  25. +#define RF_CSR_CFG_WRITE_MT7620 FIELD32(0x00000010)
  26. +#define RF_CSR_CFG_BUSY_MT7620 FIELD32(0x00000001)
  27. +
  28. +/*
  29. * EFUSE_CSR: RT30x0 EEPROM
  30. */
  31. #define EFUSE_CTRL 0x0580
  32. @@ -1024,6 +1033,11 @@
  33. #define AUTOWAKEUP_CFG_AUTOWAKE FIELD32(0x00008000)
  34. /*
  35. + * mt7620
  36. + */
  37. +#define MIMO_PS_CFG 0x1210
  38. +
  39. +/*
  40. * EDCA_AC0_CFG:
  41. */
  42. #define EDCA_AC0_CFG 0x1300
  43. @@ -1203,6 +1217,8 @@
  44. #define TX_PIN_CFG_RFTR_POL FIELD32(0x00020000)
  45. #define TX_PIN_CFG_TRSW_EN FIELD32(0x00040000)
  46. #define TX_PIN_CFG_TRSW_POL FIELD32(0x00080000)
  47. +#define TX_PIN_CFG_RFRX_EN FIELD32(0x00100000) /* mt7620 */
  48. +#define TX_PIN_CFG_RFRX_POL FIELD32(0x00200000) /* mt7620 */
  49. #define TX_PIN_CFG_PA_PE_A2_EN FIELD32(0x01000000)
  50. #define TX_PIN_CFG_PA_PE_G2_EN FIELD32(0x02000000)
  51. #define TX_PIN_CFG_PA_PE_A2_POL FIELD32(0x04000000)
  52. @@ -1549,6 +1565,17 @@
  53. #define TX_PWR_CFG_4_EXT_STBC4_CH2 FIELD32(0x0000000f)
  54. #define TX_PWR_CFG_4_EXT_STBC6_CH2 FIELD32(0x00000f00)
  55. +/* mt7620 */
  56. +#define TX0_RF_GAIN_CORRECT 0x13a0
  57. +#define TX1_RF_GAIN_CORRECT 0x13a4
  58. +#define TX0_RF_GAIN_ATTEN 0x13a8
  59. +#define TX1_RF_GAIN_ATTEN 0x13ac
  60. +#define TX_ALG_CFG_0 0x13b0
  61. +#define TX_ALG_CFG_1 0x13b4
  62. +#define TX0_BB_GAIN_ATTEN 0x13c0
  63. +#define TX1_BB_GAIN_ATTEN 0x13c4
  64. +#define TX_ALC_VGA3 0x13c8
  65. +
  66. /* TX_PWR_CFG_7 */
  67. #define TX_PWR_CFG_7 0x13d4
  68. #define TX_PWR_CFG_7_OFDM54_CH0 FIELD32(0x0000000f)
  69. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  70. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  71. @@ -60,6 +60,9 @@
  72. rt2800_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg))
  73. #define WAIT_FOR_RFCSR(__dev, __reg) \
  74. rt2800_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY, (__reg))
  75. +#define WAIT_FOR_RFCSR_MT7620(__dev, __reg) \
  76. + rt2800_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY_MT7620, \
  77. + (__reg))
  78. #define WAIT_FOR_RF(__dev, __reg) \
  79. rt2800_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg))
  80. #define WAIT_FOR_MCU(__dev, __reg) \
  81. @@ -151,19 +154,56 @@ static void rt2800_rfcsr_write(struct rt
  82. * Wait until the RFCSR becomes available, afterwards we
  83. * can safely write the new data into the register.
  84. */
  85. - if (WAIT_FOR_RFCSR(rt2x00dev, &reg)) {
  86. - reg = 0;
  87. - rt2x00_set_field32(&reg, RF_CSR_CFG_DATA, value);
  88. - rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM, word);
  89. - rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE, 1);
  90. - rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY, 1);
  91. + switch (rt2x00dev->chip.rf) {
  92. + case RF7620:
  93. + if (WAIT_FOR_RFCSR_MT7620(rt2x00dev, &reg)) {
  94. + reg = 0;
  95. + rt2x00_set_field32(&reg, RF_CSR_CFG_DATA_MT7620, value);
  96. + rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM_MT7620,
  97. + word);
  98. + rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE_MT7620, 1);
  99. + rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY_MT7620, 1);
  100. +
  101. + rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
  102. + }
  103. + break;
  104. +
  105. + default:
  106. + if (WAIT_FOR_RFCSR(rt2x00dev, &reg)) {
  107. + reg = 0;
  108. + rt2x00_set_field32(&reg, RF_CSR_CFG_DATA, value);
  109. + rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM, word);
  110. + rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE, 1);
  111. + rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY, 1);
  112. - rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
  113. + rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
  114. + }
  115. + break;
  116. }
  117. mutex_unlock(&rt2x00dev->csr_mutex);
  118. }
  119. +static void rt2800_rfcsr_write_bank(struct rt2x00_dev *rt2x00dev, const u8 bank,
  120. + const unsigned int reg, const u8 value)
  121. +{
  122. + rt2800_rfcsr_write(rt2x00dev, (reg | (bank << 6)), value);
  123. +}
  124. +
  125. +static void rt2800_rfcsr_write_chanreg(struct rt2x00_dev *rt2x00dev,
  126. + const unsigned int reg, const u8 value)
  127. +{
  128. + rt2800_rfcsr_write_bank(rt2x00dev, 4, reg, value);
  129. + rt2800_rfcsr_write_bank(rt2x00dev, 6, reg, value);
  130. +}
  131. +
  132. +static void rt2800_rfcsr_write_dccal(struct rt2x00_dev *rt2x00dev,
  133. + const unsigned int reg, const u8 value)
  134. +{
  135. + rt2800_rfcsr_write_bank(rt2x00dev, 5, reg, value);
  136. + rt2800_rfcsr_write_bank(rt2x00dev, 7, reg, value);
  137. +}
  138. +
  139. static void rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev,
  140. const unsigned int word, u8 *value)
  141. {
  142. @@ -179,22 +219,48 @@ static void rt2800_rfcsr_read(struct rt2
  143. * doesn't become available in time, reg will be 0xffffffff
  144. * which means we return 0xff to the caller.
  145. */
  146. - if (WAIT_FOR_RFCSR(rt2x00dev, &reg)) {
  147. - reg = 0;
  148. - rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM, word);
  149. - rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE, 0);
  150. - rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY, 1);
  151. + switch (rt2x00dev->chip.rf) {
  152. + case RF7620:
  153. + if (WAIT_FOR_RFCSR_MT7620(rt2x00dev, &reg)) {
  154. + reg = 0;
  155. + rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM_MT7620,
  156. + word);
  157. + rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE_MT7620, 0);
  158. + rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY_MT7620, 1);
  159. - rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
  160. + rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
  161. - WAIT_FOR_RFCSR(rt2x00dev, &reg);
  162. - }
  163. + WAIT_FOR_RFCSR_MT7620(rt2x00dev, &reg);
  164. + }
  165. +
  166. + *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA_MT7620);
  167. + break;
  168. +
  169. + default:
  170. + if (WAIT_FOR_RFCSR(rt2x00dev, &reg)) {
  171. + reg = 0;
  172. + rt2x00_set_field32(&reg, RF_CSR_CFG_REGNUM, word);
  173. + rt2x00_set_field32(&reg, RF_CSR_CFG_WRITE, 0);
  174. + rt2x00_set_field32(&reg, RF_CSR_CFG_BUSY, 1);
  175. - *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA);
  176. + rt2800_register_write_lock(rt2x00dev, RF_CSR_CFG, reg);
  177. +
  178. + WAIT_FOR_RFCSR(rt2x00dev, &reg);
  179. + }
  180. +
  181. + *value = rt2x00_get_field32(reg, RF_CSR_CFG_DATA);
  182. + break;
  183. + }
  184. mutex_unlock(&rt2x00dev->csr_mutex);
  185. }
  186. +static void rt2800_rfcsr_read_bank(struct rt2x00_dev *rt2x00dev, const u8 bank,
  187. + const unsigned int reg, u8 *value)
  188. +{
  189. + rt2800_rfcsr_read(rt2x00dev, (reg | (bank << 6)), value);
  190. +}
  191. +
  192. static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev,
  193. const unsigned int word, const u32 value)
  194. {
  195. @@ -526,6 +592,16 @@ void rt2800_get_txwi_rxwi_size(struct rt
  196. *rxwi_size = RXWI_DESC_SIZE_5WORDS;
  197. break;
  198. + case RT5390:
  199. + if (rt2x00dev->chip.rf == RF7620) {
  200. + *txwi_size = TXWI_DESC_SIZE_5WORDS;
  201. + *rxwi_size = RXWI_DESC_SIZE_6WORDS;
  202. + } else {
  203. + *txwi_size = TXWI_DESC_SIZE_4WORDS;
  204. + *rxwi_size = RXWI_DESC_SIZE_4WORDS;
  205. + }
  206. + break;
  207. +
  208. case RT5592:
  209. *txwi_size = TXWI_DESC_SIZE_5WORDS;
  210. *rxwi_size = RXWI_DESC_SIZE_6WORDS;
  211. @@ -3258,6 +3334,296 @@ static void rt2800_config_channel_rf55xx
  212. rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F);
  213. }
  214. +static void rt2800_config_channel_rf7620(struct rt2x00_dev *rt2x00dev,
  215. + struct ieee80211_conf *conf,
  216. + struct rf_channel *rf,
  217. + struct channel_info *info)
  218. +{
  219. + struct rt2800_drv_data *drv_data = rt2x00dev->drv_data;
  220. + u32 mac_sys_ctrl, mac_status;
  221. + u16 eeprom, target_power;
  222. + u32 tx_pin = 0x00150F0F;
  223. + u8 txrx_agc_fc;
  224. + u8 rfcsr;
  225. + u32 reg;
  226. + u8 bbp;
  227. + int i;
  228. +
  229. + /* Frequeny plan setting */
  230. + /* Rdiv setting (stored in rf->rf1)
  231. + * R13[1:0]
  232. + */
  233. + rt2800_rfcsr_read(rt2x00dev, 13, &rfcsr);
  234. + rfcsr = rfcsr & (~0x03);
  235. + if (rt2800_clk_is_20mhz(rt2x00dev))
  236. + rfcsr |= (rf->rf1 & 0x03);
  237. +
  238. + rt2800_rfcsr_write(rt2x00dev, 13, rfcsr);
  239. +
  240. + /* N setting (stored in rf->rf2)
  241. + * R21[0], R20[7:0]
  242. + */
  243. + rt2800_rfcsr_read(rt2x00dev, 20, &rfcsr);
  244. + rfcsr = (rf->rf2 & 0x00ff);
  245. + rt2800_rfcsr_write(rt2x00dev, 20, rfcsr);
  246. +
  247. + rt2800_rfcsr_read(rt2x00dev, 21, &rfcsr);
  248. + rfcsr = rfcsr & (~0x01);
  249. + rfcsr |= ((rf->rf2 & 0x0100) >> 8);
  250. + rt2800_rfcsr_write(rt2x00dev, 21, rfcsr);
  251. +
  252. + /* K setting (stored in rf->rf3[0:7])
  253. + * R16[3:0] (RF PLL freq selection)
  254. + */
  255. + rt2800_rfcsr_read(rt2x00dev, 16, &rfcsr);
  256. + rfcsr = rfcsr & (~0x0f);
  257. + rfcsr |= (rf->rf3 & 0x0f);
  258. + rt2800_rfcsr_write(rt2x00dev, 16, rfcsr);
  259. +
  260. + /* D setting (stored in rf->rf3[8:15])
  261. + * R22[2:0] (D=15, R22[2:0]=<111>)
  262. + */
  263. + rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
  264. + rfcsr = rfcsr & (~0x07);
  265. + rfcsr |= ((rf->rf3 >> 8) & 0x07);
  266. + rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
  267. +
  268. + /* Ksd setting (stored in rf->rf4)
  269. + * Ksd: R19<1:0>,R18<7:0>,R17<7:0>
  270. + */
  271. + rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
  272. + rfcsr = (rf->rf4 & 0x000000ff);
  273. + rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
  274. +
  275. + rt2800_rfcsr_read(rt2x00dev, 18, &rfcsr);
  276. + rfcsr = ((rf->rf4 & 0x0000ff00) >> 8);
  277. + rt2800_rfcsr_write(rt2x00dev, 18, rfcsr);
  278. +
  279. + rt2800_rfcsr_read(rt2x00dev, 19, &rfcsr);
  280. + rfcsr = rfcsr & (~0x03);
  281. + rfcsr |= ((rf->rf4 & 0x00030000) >> 16);
  282. + rt2800_rfcsr_write(rt2x00dev, 19, rfcsr);
  283. +
  284. + /* Default: XO=20MHz , SDM mode */
  285. + rt2800_rfcsr_read(rt2x00dev, 16, &rfcsr);
  286. + rfcsr = rfcsr & (~0xE0);
  287. + rfcsr |= 0x80;
  288. + rt2800_rfcsr_write(rt2x00dev, 16, rfcsr);
  289. +
  290. + rt2800_rfcsr_read(rt2x00dev, 21, &rfcsr);
  291. + rfcsr |= 0x80;
  292. + rt2800_rfcsr_write(rt2x00dev, 21, rfcsr);
  293. +
  294. + rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
  295. + if (rt2x00dev->default_ant.tx_chain_num == 1)
  296. + rfcsr &= (~0x2);
  297. + else
  298. + rfcsr |= 0x2;
  299. + rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
  300. +
  301. + rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr);
  302. + if (rt2x00dev->default_ant.tx_chain_num == 1)
  303. + rfcsr &= (~0x20);
  304. + else
  305. + rfcsr |= 0x20;
  306. + if (rt2x00dev->default_ant.rx_chain_num == 1)
  307. + rfcsr &= (~0x02);
  308. + else
  309. + rfcsr |= 0x02;
  310. + rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
  311. +
  312. + rt2800_rfcsr_read(rt2x00dev, 42, &rfcsr);
  313. + if (rt2x00dev->default_ant.tx_chain_num == 1)
  314. + rfcsr &= (~0x40);
  315. + else
  316. + rfcsr |= 0x40;
  317. + rt2800_rfcsr_write(rt2x00dev, 42, rfcsr);
  318. +
  319. + /* RF for DC Cal BW */
  320. + if (conf_is_ht40(conf)) {
  321. + rt2800_rfcsr_write_dccal(rt2x00dev, 6, 0x10);
  322. + rt2800_rfcsr_write_dccal(rt2x00dev, 7, 0x10);
  323. + rt2800_rfcsr_write_dccal(rt2x00dev, 8, 0x04);
  324. + rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x10);
  325. + rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x10);
  326. + } else {
  327. + rt2800_rfcsr_write_dccal(rt2x00dev, 6, 0x20);
  328. + rt2800_rfcsr_write_dccal(rt2x00dev, 7, 0x20);
  329. + rt2800_rfcsr_write_dccal(rt2x00dev, 8, 0x00);
  330. + rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x20);
  331. + rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x20);
  332. + }
  333. +
  334. + if (conf_is_ht40(conf)) {
  335. + rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x08);
  336. + rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x08);
  337. + } else {
  338. + rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x28);
  339. + rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x28);
  340. + }
  341. +
  342. + rt2800_rfcsr_read(rt2x00dev, 28, &rfcsr);
  343. + if (conf_is_ht40(conf) && (rf->channel == 11))
  344. + rfcsr |= 0x4;
  345. + else
  346. + rfcsr &= (~0x4);
  347. + rt2800_rfcsr_write(rt2x00dev, 28, rfcsr);
  348. +
  349. + /*if (bScan == FALSE)*/
  350. + if (conf_is_ht40(conf)) {
  351. + txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40,
  352. + RFCSR24_TX_AGC_FC);
  353. + } else {
  354. + txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20,
  355. + RFCSR24_TX_AGC_FC);
  356. + }
  357. + rt2800_rfcsr_read_bank(rt2x00dev, 5, 6, &rfcsr);
  358. + rfcsr &= (~0x3F);
  359. + rfcsr |= txrx_agc_fc;
  360. + rt2800_rfcsr_write_bank(rt2x00dev, 5, 6, rfcsr);
  361. + rt2800_rfcsr_read_bank(rt2x00dev, 5, 7, &rfcsr);
  362. + rfcsr &= (~0x3F);
  363. + rfcsr |= txrx_agc_fc;
  364. + rt2800_rfcsr_write_bank(rt2x00dev, 5, 7, rfcsr);
  365. + rt2800_rfcsr_read_bank(rt2x00dev, 7, 6, &rfcsr);
  366. + rfcsr &= (~0x3F);
  367. + rfcsr |= txrx_agc_fc;
  368. + rt2800_rfcsr_write_bank(rt2x00dev, 7, 6, rfcsr);
  369. + rt2800_rfcsr_read_bank(rt2x00dev, 7, 7, &rfcsr);
  370. + rfcsr &= (~0x3F);
  371. + rfcsr |= txrx_agc_fc;
  372. + rt2800_rfcsr_write_bank(rt2x00dev, 7, 7, rfcsr);
  373. +
  374. + rt2800_rfcsr_read_bank(rt2x00dev, 5, 58, &rfcsr);
  375. + rfcsr &= (~0x3F);
  376. + rfcsr |= txrx_agc_fc;
  377. + rt2800_rfcsr_write_bank(rt2x00dev, 5, 58, rfcsr);
  378. + rt2800_rfcsr_read_bank(rt2x00dev, 5, 59, &rfcsr);
  379. + rfcsr &= (~0x3F);
  380. + rfcsr |= txrx_agc_fc;
  381. + rt2800_rfcsr_write_bank(rt2x00dev, 5, 59, rfcsr);
  382. + rt2800_rfcsr_read_bank(rt2x00dev, 7, 58, &rfcsr);
  383. + rfcsr &= (~0x3F);
  384. + rfcsr |= txrx_agc_fc;
  385. + rt2800_rfcsr_write_bank(rt2x00dev, 7, 58, rfcsr);
  386. + rt2800_rfcsr_read_bank(rt2x00dev, 7, 59, &rfcsr);
  387. + rfcsr &= (~0x3F);
  388. + rfcsr |= txrx_agc_fc;
  389. + rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr);
  390. +
  391. + rt2800_register_read(rt2x00dev, TX_ALG_CFG_0, &reg);
  392. + reg = reg & (~0x3F3F);
  393. + reg |= info->default_power1;
  394. + reg |= (info->default_power2 << 8);
  395. + reg |= (0x2F << 16);
  396. + reg |= (0x2F << 24);
  397. +
  398. + rt2800_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
  399. + if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_INTERNAL_TX_ALC)) {
  400. + /* init base power by e2p target power */
  401. + rt2800_eeprom_read(rt2x00dev, 0xD0, &target_power);
  402. + target_power &= 0x3F;
  403. + reg = reg & (~0x3F3F);
  404. + reg |= target_power;
  405. + reg |= (target_power << 8);
  406. + }
  407. + rt2800_register_write(rt2x00dev, TX_ALG_CFG_0, reg);
  408. +
  409. + rt2800_register_read(rt2x00dev, TX_ALG_CFG_1, &reg);
  410. + reg = reg & (~0x3F);
  411. + rt2800_register_write(rt2x00dev, TX_ALG_CFG_1, reg);
  412. +
  413. + /*if (bScan == FALSE)*/
  414. + /* Save MAC SYS CTRL registers */
  415. + rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &mac_sys_ctrl);
  416. + /* Disable Tx/Rx */
  417. + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0);
  418. + /* Check MAC Tx/Rx idle */
  419. + for (i = 0; i < 10000; i++) {
  420. + rt2800_register_read(rt2x00dev, MAC_STATUS_CFG, &mac_status);
  421. + if (mac_status & 0x3)
  422. + usleep_range(50, 200);
  423. + else
  424. + break;
  425. + }
  426. +
  427. + if (i == 10000)
  428. + rt2x00_warn(rt2x00dev, "Wait MAC Status to MAX !!!\n");
  429. +
  430. + if (rf->channel > 10) {
  431. + rt2800_bbp_read(rt2x00dev, 30, &bbp);
  432. + bbp = 0x40;
  433. + rt2800_bbp_write(rt2x00dev, 30, bbp);
  434. + rt2800_rfcsr_write(rt2x00dev, 39, 0);
  435. + if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
  436. + rt2800_rfcsr_write(rt2x00dev, 42, 0xfb);
  437. + else
  438. + rt2800_rfcsr_write(rt2x00dev, 42, 0x7b);
  439. + } else {
  440. + rt2800_bbp_read(rt2x00dev, 30, &bbp);
  441. + bbp = 0x1f;
  442. + rt2800_bbp_write(rt2x00dev, 30, bbp);
  443. + rt2800_rfcsr_write(rt2x00dev, 39, 0x80);
  444. + if (rt2x00_has_cap_external_lna_bg(rt2x00dev))
  445. + rt2800_rfcsr_write(rt2x00dev, 42, 0xdb);
  446. + else
  447. + rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
  448. + }
  449. +
  450. + rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, mac_sys_ctrl);
  451. +
  452. + rt2800_rfcsr_write(rt2x00dev, 5, 0x40);
  453. + rt2800_rfcsr_write(rt2x00dev, 4, 0x0C);
  454. +
  455. + /* vcocal_en (initiate VCO calibration (reset after completion)) */
  456. + rt2800_rfcsr_read(rt2x00dev, 4, &rfcsr);
  457. + rfcsr = ((rfcsr & ~0x80) | 0x80);
  458. + rt2800_rfcsr_write(rt2x00dev, 4, rfcsr);
  459. + usleep_range(2000, 3000);
  460. +
  461. + rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
  462. +
  463. + if (rt2x00dev->default_ant.tx_chain_num == 1) {
  464. + rt2800_bbp_write(rt2x00dev, 91, 0x07);
  465. + rt2800_bbp_write(rt2x00dev, 95, 0x1A);
  466. + rt2800_bbp_write(rt2x00dev, 195, 128);
  467. + rt2800_bbp_write(rt2x00dev, 196, 0xA0);
  468. + rt2800_bbp_write(rt2x00dev, 195, 170);
  469. + rt2800_bbp_write(rt2x00dev, 196, 0x12);
  470. + rt2800_bbp_write(rt2x00dev, 195, 171);
  471. + rt2800_bbp_write(rt2x00dev, 196, 0x10);
  472. + } else {
  473. + rt2800_bbp_write(rt2x00dev, 91, 0x06);
  474. + rt2800_bbp_write(rt2x00dev, 95, 0x9A);
  475. + rt2800_bbp_write(rt2x00dev, 195, 128);
  476. + rt2800_bbp_write(rt2x00dev, 196, 0xE0);
  477. + rt2800_bbp_write(rt2x00dev, 195, 170);
  478. + rt2800_bbp_write(rt2x00dev, 196, 0x30);
  479. + rt2800_bbp_write(rt2x00dev, 195, 171);
  480. + rt2800_bbp_write(rt2x00dev, 196, 0x30);
  481. + }
  482. +
  483. + if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  484. + rt2800_bbp_write(rt2x00dev, 75, 0x60);
  485. + rt2800_bbp_write(rt2x00dev, 76, 0x44);
  486. + rt2800_bbp_write(rt2x00dev, 79, 0x1C);
  487. + rt2800_bbp_write(rt2x00dev, 80, 0x0C);
  488. + rt2800_bbp_write(rt2x00dev, 82, 0xB6);
  489. +
  490. + if (!conf_is_ht40(conf)) {
  491. + rt2800_bbp_write(rt2x00dev, 195, 141);
  492. + rt2800_bbp_write(rt2x00dev, 196, 0x1A);
  493. + }
  494. + }
  495. +
  496. + /* On 11A, We should delay and wait RF/BBP to be stable
  497. + * and the appropriate time should be 1000 micro seconds
  498. + * 2005/06/05 - On 11G, we also need this delay time.
  499. + * Otherwise it's difficult to pass the WHQL.
  500. + */
  501. + usleep_range(1000, 1500);
  502. +}
  503. +
  504. static void rt2800_bbp_write_with_rx_chain(struct rt2x00_dev *rt2x00dev,
  505. const unsigned int word,
  506. const u8 value)
  507. @@ -3414,7 +3780,7 @@ static void rt2800_config_channel(struct
  508. struct channel_info *info)
  509. {
  510. u32 reg;
  511. - unsigned int tx_pin;
  512. + u32 tx_pin;
  513. u8 bbp, rfcsr;
  514. info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel,
  515. @@ -3468,6 +3834,9 @@ static void rt2800_config_channel(struct
  516. case RF5592:
  517. rt2800_config_channel_rf55xx(rt2x00dev, conf, rf, info);
  518. break;
  519. + case RF7620:
  520. + rt2800_config_channel_rf7620(rt2x00dev, conf, rf, info);
  521. + break;
  522. default:
  523. rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info);
  524. }
  525. @@ -3574,7 +3943,7 @@ static void rt2800_config_channel(struct
  526. else if (rt2x00_rt(rt2x00dev, RT3593) ||
  527. rt2x00_rt(rt2x00dev, RT3883))
  528. rt2800_bbp_write(rt2x00dev, 82, 0x82);
  529. - else
  530. + else if (rt2x00dev->chip.rf != RF7620)
  531. rt2800_bbp_write(rt2x00dev, 82, 0xf2);
  532. if (rt2x00_rt(rt2x00dev, RT3593) ||
  533. @@ -3596,7 +3965,7 @@ static void rt2800_config_channel(struct
  534. if (rt2x00_rt(rt2x00dev, RT3572))
  535. rt2800_rfcsr_write(rt2x00dev, 8, 0);
  536. - tx_pin = 0;
  537. + rt2800_register_read(rt2x00dev, TX_PIN_CFG, &tx_pin);
  538. switch (rt2x00dev->default_ant.tx_chain_num) {
  539. case 3:
  540. @@ -3645,6 +4014,7 @@ static void rt2800_config_channel(struct
  541. rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFTR_EN, 1);
  542. rt2x00_set_field32(&tx_pin, TX_PIN_CFG_TRSW_EN, 1);
  543. + rt2x00_set_field32(&tx_pin, TX_PIN_CFG_RFRX_EN, 1); /* mt7620 */
  544. rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
  545. @@ -3720,7 +4090,8 @@ static void rt2800_config_channel(struct
  546. usleep_range(1000, 1500);
  547. }
  548. - if (rt2x00_rt(rt2x00dev, RT5592)) {
  549. + if (rt2x00_rt(rt2x00dev, RT5592) ||
  550. + (rt2x00_rt(rt2x00dev, RT5390) && rt2x00_rf(rt2x00dev, RF7620))) {
  551. rt2800_bbp_write(rt2x00dev, 195, 141);
  552. rt2800_bbp_write(rt2x00dev, 196, conf_is_ht40(conf) ? 0x10 : 0x1a);
  553. @@ -4662,6 +5033,15 @@ void rt2800_vco_calibration(struct rt2x0
  554. rt2x00_set_field8(&rfcsr, RFCSR3_VCOCAL_EN, 1);
  555. rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
  556. break;
  557. + case RF7620:
  558. + rt2800_rfcsr_read(rt2x00dev, 4, &rfcsr);
  559. + /* vcocal_en (initiate VCO calibration (reset after completion))
  560. + * It should be at the end of RF configuration.
  561. + */
  562. + rfcsr = ((rfcsr & ~0x80) | 0x80);
  563. + rt2800_rfcsr_write(rt2x00dev, 4, rfcsr);
  564. + usleep_range(2000, 3000);
  565. + break;
  566. default:
  567. WARN_ONCE(1, "Not supported RF chipet %x for VCO recalibration",
  568. rt2x00dev->chip.rf);
  569. @@ -5037,6 +5417,24 @@ static int rt2800_init_registers(struct
  570. rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00040000);
  571. rt2800_register_write(rt2x00dev, TX_TXBF_CFG_0, 0x8000fc21);
  572. rt2800_register_write(rt2x00dev, TX_TXBF_CFG_3, 0x00009c40);
  573. + } else if (rt2x00_rf(rt2x00dev, RF7620)) {
  574. + rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000401);
  575. + rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x000C0000);
  576. + rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000);
  577. + rt2800_register_write(rt2x00dev, MIMO_PS_CFG, 0x00000002);
  578. + rt2800_register_write(rt2x00dev, TX_PIN_CFG, 0x00150F0F);
  579. + rt2800_register_write(rt2x00dev, TX_ALC_VGA3, 0x06060606);
  580. + rt2800_register_write(rt2x00dev, TX0_BB_GAIN_ATTEN, 0x0);
  581. + rt2800_register_write(rt2x00dev, TX1_BB_GAIN_ATTEN, 0x0);
  582. + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C);
  583. + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C666C);
  584. + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT,
  585. + 0x3630363A);
  586. + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_CORRECT,
  587. + 0x3630363A);
  588. + rt2800_register_read(rt2x00dev, TX_ALG_CFG_1, &reg);
  589. + reg = reg & (~0x80000000);
  590. + rt2800_register_write(rt2x00dev, TX_ALG_CFG_1, reg);
  591. } else if (rt2x00_rt(rt2x00dev, RT5390) ||
  592. rt2x00_rt(rt2x00dev, RT5392)) {
  593. rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
  594. @@ -6075,6 +6473,225 @@ static void rt2800_init_bbp_5592(struct
  595. rt2800_bbp_write(rt2x00dev, 103, 0xc0);
  596. }
  597. +static void rt2800_bbp_glrt_write(struct rt2x00_dev *rt2x00dev,
  598. + const u8 reg, const u8 value)
  599. +{
  600. + rt2800_bbp_write(rt2x00dev, 195, reg);
  601. + rt2800_bbp_write(rt2x00dev, 196, value);
  602. +}
  603. +
  604. +static void rt2800_bbp_dcoc_write(struct rt2x00_dev *rt2x00dev,
  605. + const u8 reg, const u8 value)
  606. +{
  607. + rt2800_bbp_write(rt2x00dev, 158, reg);
  608. + rt2800_bbp_write(rt2x00dev, 159, value);
  609. +}
  610. +
  611. +static void rt2800_init_bbp_7620(struct rt2x00_dev *rt2x00dev)
  612. +{
  613. + u8 bbp;
  614. +
  615. + /* Apply Maximum Likelihood Detection (MLD) for 2 stream case */
  616. + rt2800_bbp_read(rt2x00dev, 105, &bbp);
  617. + rt2x00_set_field8(&bbp, BBP105_MLD,
  618. + rt2x00dev->default_ant.rx_chain_num == 2);
  619. + rt2800_bbp_write(rt2x00dev, 105, bbp);
  620. +
  621. + /* Avoid data loss and CRC errors */
  622. + /* MAC interface control (MAC_IF_80M, 1: 80 MHz) */
  623. + rt2800_bbp4_mac_if_ctrl(rt2x00dev);
  624. +
  625. + /* Fix I/Q swap issue */
  626. + rt2800_bbp_read(rt2x00dev, 1, &bbp);
  627. + bbp |= 0x04;
  628. + rt2800_bbp_write(rt2x00dev, 1, bbp);
  629. +
  630. + /* BBP for G band */
  631. + rt2800_bbp_write(rt2x00dev, 3, 0x08);
  632. + rt2800_bbp_write(rt2x00dev, 4, 0x00); /* rt2800_bbp4_mac_if_ctrl? */
  633. + rt2800_bbp_write(rt2x00dev, 6, 0x08);
  634. + rt2800_bbp_write(rt2x00dev, 14, 0x09);
  635. + rt2800_bbp_write(rt2x00dev, 15, 0xFF);
  636. + rt2800_bbp_write(rt2x00dev, 16, 0x01);
  637. + rt2800_bbp_write(rt2x00dev, 20, 0x06);
  638. + rt2800_bbp_write(rt2x00dev, 21, 0x00);
  639. + rt2800_bbp_write(rt2x00dev, 22, 0x00);
  640. + rt2800_bbp_write(rt2x00dev, 27, 0x00);
  641. + rt2800_bbp_write(rt2x00dev, 28, 0x00);
  642. + rt2800_bbp_write(rt2x00dev, 30, 0x00);
  643. + rt2800_bbp_write(rt2x00dev, 31, 0x48);
  644. + rt2800_bbp_write(rt2x00dev, 47, 0x40);
  645. + rt2800_bbp_write(rt2x00dev, 62, 0x00);
  646. + rt2800_bbp_write(rt2x00dev, 63, 0x00);
  647. + rt2800_bbp_write(rt2x00dev, 64, 0x00);
  648. + rt2800_bbp_write(rt2x00dev, 65, 0x2C);
  649. + rt2800_bbp_write(rt2x00dev, 66, 0x1C);
  650. + rt2800_bbp_write(rt2x00dev, 67, 0x20);
  651. + rt2800_bbp_write(rt2x00dev, 68, 0xDD);
  652. + rt2800_bbp_write(rt2x00dev, 69, 0x10);
  653. + rt2800_bbp_write(rt2x00dev, 70, 0x05);
  654. + rt2800_bbp_write(rt2x00dev, 73, 0x18);
  655. + rt2800_bbp_write(rt2x00dev, 74, 0x0F);
  656. + rt2800_bbp_write(rt2x00dev, 75, 0x60);
  657. + rt2800_bbp_write(rt2x00dev, 76, 0x44);
  658. + rt2800_bbp_write(rt2x00dev, 77, 0x59);
  659. + rt2800_bbp_write(rt2x00dev, 78, 0x1E);
  660. + rt2800_bbp_write(rt2x00dev, 79, 0x1C);
  661. + rt2800_bbp_write(rt2x00dev, 80, 0x0C);
  662. + rt2800_bbp_write(rt2x00dev, 81, 0x3A);
  663. + rt2800_bbp_write(rt2x00dev, 82, 0xB6);
  664. + rt2800_bbp_write(rt2x00dev, 83, 0x9A);
  665. + rt2800_bbp_write(rt2x00dev, 84, 0x9A);
  666. + rt2800_bbp_write(rt2x00dev, 86, 0x38);
  667. + rt2800_bbp_write(rt2x00dev, 88, 0x90);
  668. + rt2800_bbp_write(rt2x00dev, 91, 0x04);
  669. + rt2800_bbp_write(rt2x00dev, 92, 0x02);
  670. + rt2800_bbp_write(rt2x00dev, 95, 0x9A);
  671. + rt2800_bbp_write(rt2x00dev, 96, 0x00);
  672. + rt2800_bbp_write(rt2x00dev, 103, 0xC0);
  673. + rt2800_bbp_write(rt2x00dev, 104, 0x92);
  674. + /* FIXME BBP105 owerwrite */
  675. + rt2800_bbp_write(rt2x00dev, 105, 0x3C);
  676. + rt2800_bbp_write(rt2x00dev, 106, 0x12);
  677. + rt2800_bbp_write(rt2x00dev, 109, 0x00);
  678. + rt2800_bbp_write(rt2x00dev, 134, 0x10);
  679. + rt2800_bbp_write(rt2x00dev, 135, 0xA6);
  680. + rt2800_bbp_write(rt2x00dev, 137, 0x04);
  681. + rt2800_bbp_write(rt2x00dev, 142, 0x30);
  682. + rt2800_bbp_write(rt2x00dev, 143, 0xF7);
  683. + rt2800_bbp_write(rt2x00dev, 160, 0xEC);
  684. + rt2800_bbp_write(rt2x00dev, 161, 0xC4);
  685. + rt2800_bbp_write(rt2x00dev, 162, 0x77);
  686. + rt2800_bbp_write(rt2x00dev, 163, 0xF9);
  687. + rt2800_bbp_write(rt2x00dev, 164, 0x00);
  688. + rt2800_bbp_write(rt2x00dev, 165, 0x00);
  689. + rt2800_bbp_write(rt2x00dev, 186, 0x00);
  690. + rt2800_bbp_write(rt2x00dev, 187, 0x00);
  691. + rt2800_bbp_write(rt2x00dev, 188, 0x00);
  692. + rt2800_bbp_write(rt2x00dev, 186, 0x00);
  693. + rt2800_bbp_write(rt2x00dev, 187, 0x01);
  694. + rt2800_bbp_write(rt2x00dev, 188, 0x00);
  695. + rt2800_bbp_write(rt2x00dev, 189, 0x00);
  696. +
  697. + rt2800_bbp_write(rt2x00dev, 91, 0x06);
  698. + rt2800_bbp_write(rt2x00dev, 92, 0x04);
  699. + rt2800_bbp_write(rt2x00dev, 93, 0x54);
  700. + rt2800_bbp_write(rt2x00dev, 99, 0x50);
  701. + rt2800_bbp_write(rt2x00dev, 148, 0x84);
  702. + rt2800_bbp_write(rt2x00dev, 167, 0x80);
  703. + rt2800_bbp_write(rt2x00dev, 178, 0xFF);
  704. + rt2800_bbp_write(rt2x00dev, 106, 0x13);
  705. +
  706. + /* BBP for G band GLRT function (BBP_128 ~ BBP_221) */
  707. + rt2800_bbp_glrt_write(rt2x00dev, 0, 0x00);
  708. + rt2800_bbp_glrt_write(rt2x00dev, 1, 0x14); /* ? see above */
  709. + rt2800_bbp_glrt_write(rt2x00dev, 2, 0x20);
  710. + rt2800_bbp_glrt_write(rt2x00dev, 3, 0x0A);
  711. + rt2800_bbp_glrt_write(rt2x00dev, 10, 0x16);
  712. + rt2800_bbp_glrt_write(rt2x00dev, 11, 0x06);
  713. + rt2800_bbp_glrt_write(rt2x00dev, 12, 0x02);
  714. + rt2800_bbp_glrt_write(rt2x00dev, 13, 0x07);
  715. + rt2800_bbp_glrt_write(rt2x00dev, 14, 0x05);
  716. + rt2800_bbp_glrt_write(rt2x00dev, 15, 0x09);
  717. + rt2800_bbp_glrt_write(rt2x00dev, 16, 0x20);
  718. + rt2800_bbp_glrt_write(rt2x00dev, 17, 0x08);
  719. + rt2800_bbp_glrt_write(rt2x00dev, 18, 0x4A);
  720. + rt2800_bbp_glrt_write(rt2x00dev, 19, 0x00);
  721. + rt2800_bbp_glrt_write(rt2x00dev, 20, 0x00);
  722. + rt2800_bbp_glrt_write(rt2x00dev, 128, 0xE0);
  723. + rt2800_bbp_glrt_write(rt2x00dev, 129, 0x1F);
  724. + rt2800_bbp_glrt_write(rt2x00dev, 130, 0x4F);
  725. + rt2800_bbp_glrt_write(rt2x00dev, 131, 0x32);
  726. + rt2800_bbp_glrt_write(rt2x00dev, 132, 0x08);
  727. + rt2800_bbp_glrt_write(rt2x00dev, 133, 0x28);
  728. + rt2800_bbp_glrt_write(rt2x00dev, 134, 0x19);
  729. + rt2800_bbp_glrt_write(rt2x00dev, 135, 0x0A);
  730. + rt2800_bbp_glrt_write(rt2x00dev, 138, 0x16);
  731. + rt2800_bbp_glrt_write(rt2x00dev, 139, 0x10);
  732. + rt2800_bbp_glrt_write(rt2x00dev, 140, 0x10);
  733. + rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1A);
  734. + rt2800_bbp_glrt_write(rt2x00dev, 142, 0x36);
  735. + rt2800_bbp_glrt_write(rt2x00dev, 143, 0x2C);
  736. + rt2800_bbp_glrt_write(rt2x00dev, 144, 0x26);
  737. + rt2800_bbp_glrt_write(rt2x00dev, 145, 0x24);
  738. + rt2800_bbp_glrt_write(rt2x00dev, 146, 0x42);
  739. + rt2800_bbp_glrt_write(rt2x00dev, 147, 0x40);
  740. + rt2800_bbp_glrt_write(rt2x00dev, 148, 0x30);
  741. + rt2800_bbp_glrt_write(rt2x00dev, 149, 0x29);
  742. + rt2800_bbp_glrt_write(rt2x00dev, 150, 0x4C);
  743. + rt2800_bbp_glrt_write(rt2x00dev, 151, 0x46);
  744. + rt2800_bbp_glrt_write(rt2x00dev, 152, 0x3D);
  745. + rt2800_bbp_glrt_write(rt2x00dev, 153, 0x40);
  746. + rt2800_bbp_glrt_write(rt2x00dev, 154, 0x3E);
  747. + rt2800_bbp_glrt_write(rt2x00dev, 155, 0x38);
  748. + rt2800_bbp_glrt_write(rt2x00dev, 156, 0x3D);
  749. + rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2F);
  750. + rt2800_bbp_glrt_write(rt2x00dev, 158, 0x3C);
  751. + rt2800_bbp_glrt_write(rt2x00dev, 159, 0x34);
  752. + rt2800_bbp_glrt_write(rt2x00dev, 160, 0x2C);
  753. + rt2800_bbp_glrt_write(rt2x00dev, 161, 0x2F);
  754. + rt2800_bbp_glrt_write(rt2x00dev, 162, 0x3C);
  755. + rt2800_bbp_glrt_write(rt2x00dev, 163, 0x35);
  756. + rt2800_bbp_glrt_write(rt2x00dev, 164, 0x2E);
  757. + rt2800_bbp_glrt_write(rt2x00dev, 165, 0x2F);
  758. + rt2800_bbp_glrt_write(rt2x00dev, 166, 0x49);
  759. + rt2800_bbp_glrt_write(rt2x00dev, 167, 0x41);
  760. + rt2800_bbp_glrt_write(rt2x00dev, 168, 0x36);
  761. + rt2800_bbp_glrt_write(rt2x00dev, 169, 0x39);
  762. + rt2800_bbp_glrt_write(rt2x00dev, 170, 0x30);
  763. + rt2800_bbp_glrt_write(rt2x00dev, 171, 0x30);
  764. + rt2800_bbp_glrt_write(rt2x00dev, 172, 0x0E);
  765. + rt2800_bbp_glrt_write(rt2x00dev, 173, 0x0D);
  766. + rt2800_bbp_glrt_write(rt2x00dev, 174, 0x28);
  767. + rt2800_bbp_glrt_write(rt2x00dev, 175, 0x21);
  768. + rt2800_bbp_glrt_write(rt2x00dev, 176, 0x1C);
  769. + rt2800_bbp_glrt_write(rt2x00dev, 177, 0x16);
  770. + rt2800_bbp_glrt_write(rt2x00dev, 178, 0x50);
  771. + rt2800_bbp_glrt_write(rt2x00dev, 179, 0x4A);
  772. + rt2800_bbp_glrt_write(rt2x00dev, 180, 0x43);
  773. + rt2800_bbp_glrt_write(rt2x00dev, 181, 0x50);
  774. + rt2800_bbp_glrt_write(rt2x00dev, 182, 0x10);
  775. + rt2800_bbp_glrt_write(rt2x00dev, 183, 0x10);
  776. + rt2800_bbp_glrt_write(rt2x00dev, 184, 0x10);
  777. + rt2800_bbp_glrt_write(rt2x00dev, 185, 0x10);
  778. + rt2800_bbp_glrt_write(rt2x00dev, 200, 0x7D);
  779. + rt2800_bbp_glrt_write(rt2x00dev, 201, 0x14);
  780. + rt2800_bbp_glrt_write(rt2x00dev, 202, 0x32);
  781. + rt2800_bbp_glrt_write(rt2x00dev, 203, 0x2C);
  782. + rt2800_bbp_glrt_write(rt2x00dev, 204, 0x36);
  783. + rt2800_bbp_glrt_write(rt2x00dev, 205, 0x4C);
  784. + rt2800_bbp_glrt_write(rt2x00dev, 206, 0x43);
  785. + rt2800_bbp_glrt_write(rt2x00dev, 207, 0x2C);
  786. + rt2800_bbp_glrt_write(rt2x00dev, 208, 0x2E);
  787. + rt2800_bbp_glrt_write(rt2x00dev, 209, 0x36);
  788. + rt2800_bbp_glrt_write(rt2x00dev, 210, 0x30);
  789. + rt2800_bbp_glrt_write(rt2x00dev, 211, 0x6E);
  790. +
  791. + /* BBP for G band DCOC function */
  792. + rt2800_bbp_dcoc_write(rt2x00dev, 140, 0x0C);
  793. + rt2800_bbp_dcoc_write(rt2x00dev, 141, 0x00);
  794. + rt2800_bbp_dcoc_write(rt2x00dev, 142, 0x10);
  795. + rt2800_bbp_dcoc_write(rt2x00dev, 143, 0x10);
  796. + rt2800_bbp_dcoc_write(rt2x00dev, 144, 0x10);
  797. + rt2800_bbp_dcoc_write(rt2x00dev, 145, 0x10);
  798. + rt2800_bbp_dcoc_write(rt2x00dev, 146, 0x08);
  799. + rt2800_bbp_dcoc_write(rt2x00dev, 147, 0x40);
  800. + rt2800_bbp_dcoc_write(rt2x00dev, 148, 0x04);
  801. + rt2800_bbp_dcoc_write(rt2x00dev, 149, 0x04);
  802. + rt2800_bbp_dcoc_write(rt2x00dev, 150, 0x08);
  803. + rt2800_bbp_dcoc_write(rt2x00dev, 151, 0x08);
  804. + rt2800_bbp_dcoc_write(rt2x00dev, 152, 0x03);
  805. + rt2800_bbp_dcoc_write(rt2x00dev, 153, 0x03);
  806. + rt2800_bbp_dcoc_write(rt2x00dev, 154, 0x03);
  807. + rt2800_bbp_dcoc_write(rt2x00dev, 155, 0x02);
  808. + rt2800_bbp_dcoc_write(rt2x00dev, 156, 0x40);
  809. + rt2800_bbp_dcoc_write(rt2x00dev, 157, 0x40);
  810. + rt2800_bbp_dcoc_write(rt2x00dev, 158, 0x64);
  811. + rt2800_bbp_dcoc_write(rt2x00dev, 159, 0x64);
  812. +
  813. + rt2800_bbp4_mac_if_ctrl(rt2x00dev);
  814. +}
  815. +
  816. static void rt2800_init_bbp(struct rt2x00_dev *rt2x00dev)
  817. {
  818. unsigned int i;
  819. @@ -6117,7 +6734,10 @@ static void rt2800_init_bbp(struct rt2x0
  820. return;
  821. case RT5390:
  822. case RT5392:
  823. - rt2800_init_bbp_53xx(rt2x00dev);
  824. + if (rt2x00dev->chip.rf == RF7620)
  825. + rt2800_init_bbp_7620(rt2x00dev);
  826. + else
  827. + rt2800_init_bbp_53xx(rt2x00dev);
  828. break;
  829. case RT5592:
  830. rt2800_init_bbp_5592(rt2x00dev);
  831. @@ -7331,6 +7951,277 @@ static void rt2800_init_rfcsr_5592(struc
  832. rt2800_led_open_drain_enable(rt2x00dev);
  833. }
  834. +static void rt2800_init_rfcsr_7620(struct rt2x00_dev *rt2x00dev)
  835. +{
  836. + u8 rfvalue;
  837. + u16 freq;
  838. +
  839. + /* Initialize RF central register to default value */
  840. + rt2800_rfcsr_write(rt2x00dev, 0, 0x02);
  841. + rt2800_rfcsr_write(rt2x00dev, 1, 0x03);
  842. + rt2800_rfcsr_write(rt2x00dev, 2, 0x33);
  843. + rt2800_rfcsr_write(rt2x00dev, 3, 0xFF);
  844. + rt2800_rfcsr_write(rt2x00dev, 4, 0x0C);
  845. + rt2800_rfcsr_write(rt2x00dev, 5, 0x40); /* Read only */
  846. + rt2800_rfcsr_write(rt2x00dev, 6, 0x00);
  847. + rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
  848. + rt2800_rfcsr_write(rt2x00dev, 8, 0x00);
  849. + rt2800_rfcsr_write(rt2x00dev, 9, 0x00);
  850. + rt2800_rfcsr_write(rt2x00dev, 10, 0x00);
  851. + rt2800_rfcsr_write(rt2x00dev, 11, 0x00);
  852. + /* rt2800_rfcsr_write(rt2x00dev, 12, 0x43); *//* EEPROM */
  853. + rt2800_rfcsr_write(rt2x00dev, 13, 0x00);
  854. + rt2800_rfcsr_write(rt2x00dev, 14, 0x40);
  855. + rt2800_rfcsr_write(rt2x00dev, 15, 0x22);
  856. + rt2800_rfcsr_write(rt2x00dev, 16, 0x4C);
  857. + rt2800_rfcsr_write(rt2x00dev, 17, 0x00);
  858. + rt2800_rfcsr_write(rt2x00dev, 18, 0x00);
  859. + rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
  860. + rt2800_rfcsr_write(rt2x00dev, 20, 0xA0);
  861. + rt2800_rfcsr_write(rt2x00dev, 21, 0x12);
  862. + rt2800_rfcsr_write(rt2x00dev, 22, 0x07);
  863. + rt2800_rfcsr_write(rt2x00dev, 23, 0x13);
  864. + rt2800_rfcsr_write(rt2x00dev, 24, 0xFE);
  865. + rt2800_rfcsr_write(rt2x00dev, 25, 0x24);
  866. + rt2800_rfcsr_write(rt2x00dev, 26, 0x7A);
  867. + rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
  868. + rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
  869. + rt2800_rfcsr_write(rt2x00dev, 29, 0x05);
  870. + rt2800_rfcsr_write(rt2x00dev, 30, 0x00);
  871. + rt2800_rfcsr_write(rt2x00dev, 31, 0x00);
  872. + rt2800_rfcsr_write(rt2x00dev, 32, 0x00);
  873. + rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
  874. + rt2800_rfcsr_write(rt2x00dev, 34, 0x00);
  875. + rt2800_rfcsr_write(rt2x00dev, 35, 0x00);
  876. + rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
  877. + rt2800_rfcsr_write(rt2x00dev, 37, 0x00);
  878. + rt2800_rfcsr_write(rt2x00dev, 38, 0x00);
  879. + rt2800_rfcsr_write(rt2x00dev, 39, 0x00);
  880. + rt2800_rfcsr_write(rt2x00dev, 40, 0x00);
  881. + rt2800_rfcsr_write(rt2x00dev, 41, 0xD0);
  882. + rt2800_rfcsr_write(rt2x00dev, 42, 0x5B);
  883. + rt2800_rfcsr_write(rt2x00dev, 43, 0x00);
  884. +
  885. + rt2800_rfcsr_write(rt2x00dev, 11, 0x21);
  886. + if (rt2800_clk_is_20mhz(rt2x00dev))
  887. + rt2800_rfcsr_write(rt2x00dev, 13, 0x03);
  888. + else
  889. + rt2800_rfcsr_write(rt2x00dev, 13, 0x00);
  890. + rt2800_rfcsr_write(rt2x00dev, 14, 0x7C);
  891. + rt2800_rfcsr_write(rt2x00dev, 16, 0x80);
  892. + rt2800_rfcsr_write(rt2x00dev, 17, 0x99);
  893. + rt2800_rfcsr_write(rt2x00dev, 18, 0x99);
  894. + rt2800_rfcsr_write(rt2x00dev, 19, 0x09);
  895. + rt2800_rfcsr_write(rt2x00dev, 20, 0x50);
  896. + rt2800_rfcsr_write(rt2x00dev, 21, 0xB0);
  897. + rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
  898. + rt2800_rfcsr_write(rt2x00dev, 23, 0x06);
  899. + rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
  900. + rt2800_rfcsr_write(rt2x00dev, 25, 0x00);
  901. + rt2800_rfcsr_write(rt2x00dev, 26, 0x5D);
  902. + rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
  903. + rt2800_rfcsr_write(rt2x00dev, 28, 0x61);
  904. + rt2800_rfcsr_write(rt2x00dev, 29, 0xB5);
  905. + rt2800_rfcsr_write(rt2x00dev, 43, 0x02);
  906. +
  907. + rt2800_rfcsr_write(rt2x00dev, 28, 0x62);
  908. + rt2800_rfcsr_write(rt2x00dev, 29, 0xAD);
  909. + rt2800_rfcsr_write(rt2x00dev, 39, 0x80);
  910. +
  911. + /* use rt2800_adjust_freq_offset ? */
  912. + rt2800_eeprom_read(rt2x00dev, EEPROM_FREQ, &freq);
  913. + rfvalue = freq & 0xff;
  914. + rt2800_rfcsr_write(rt2x00dev, 12, rfvalue);
  915. +
  916. + /* Initialize RF channel register to default value */
  917. + rt2800_rfcsr_write_chanreg(rt2x00dev, 0, 0x03);
  918. + rt2800_rfcsr_write_chanreg(rt2x00dev, 1, 0x00);
  919. + rt2800_rfcsr_write_chanreg(rt2x00dev, 2, 0x00);
  920. + rt2800_rfcsr_write_chanreg(rt2x00dev, 3, 0x00);
  921. + rt2800_rfcsr_write_chanreg(rt2x00dev, 4, 0x00);
  922. + rt2800_rfcsr_write_chanreg(rt2x00dev, 5, 0x08);
  923. + rt2800_rfcsr_write_chanreg(rt2x00dev, 6, 0x00);
  924. + rt2800_rfcsr_write_chanreg(rt2x00dev, 7, 0x51);
  925. + rt2800_rfcsr_write_chanreg(rt2x00dev, 8, 0x53);
  926. + rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x16);
  927. + rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x61);
  928. + rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x53);
  929. + rt2800_rfcsr_write_chanreg(rt2x00dev, 12, 0x22);
  930. + /* rt2800_rfcsr_write_chanreg(rt2x00dev, 13, 0x3D); */ /* fails */
  931. + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x06);
  932. + rt2800_rfcsr_write_chanreg(rt2x00dev, 15, 0x13);
  933. + rt2800_rfcsr_write_chanreg(rt2x00dev, 16, 0x22);
  934. + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x27);
  935. + rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x02);
  936. + rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA7);
  937. + rt2800_rfcsr_write_chanreg(rt2x00dev, 20, 0x01);
  938. + rt2800_rfcsr_write_chanreg(rt2x00dev, 21, 0x52);
  939. + rt2800_rfcsr_write_chanreg(rt2x00dev, 22, 0x80);
  940. + rt2800_rfcsr_write_chanreg(rt2x00dev, 23, 0xB3);
  941. + rt2800_rfcsr_write_chanreg(rt2x00dev, 24, 0x00);
  942. + rt2800_rfcsr_write_chanreg(rt2x00dev, 25, 0x00);
  943. + rt2800_rfcsr_write_chanreg(rt2x00dev, 26, 0x00);
  944. + rt2800_rfcsr_write_chanreg(rt2x00dev, 27, 0x00);
  945. + rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x5C);
  946. + rt2800_rfcsr_write_chanreg(rt2x00dev, 29, 0x6B);
  947. + rt2800_rfcsr_write_chanreg(rt2x00dev, 30, 0x6B);
  948. + rt2800_rfcsr_write_chanreg(rt2x00dev, 31, 0x31);
  949. + rt2800_rfcsr_write_chanreg(rt2x00dev, 32, 0x5D);
  950. + rt2800_rfcsr_write_chanreg(rt2x00dev, 33, 0x00);
  951. + rt2800_rfcsr_write_chanreg(rt2x00dev, 34, 0xE6);
  952. + rt2800_rfcsr_write_chanreg(rt2x00dev, 35, 0x55);
  953. + rt2800_rfcsr_write_chanreg(rt2x00dev, 36, 0x00);
  954. + rt2800_rfcsr_write_chanreg(rt2x00dev, 37, 0xBB);
  955. + rt2800_rfcsr_write_chanreg(rt2x00dev, 38, 0xB3);
  956. + rt2800_rfcsr_write_chanreg(rt2x00dev, 39, 0xB3);
  957. + rt2800_rfcsr_write_chanreg(rt2x00dev, 40, 0x03);
  958. + rt2800_rfcsr_write_chanreg(rt2x00dev, 41, 0x00);
  959. + rt2800_rfcsr_write_chanreg(rt2x00dev, 42, 0x00);
  960. + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xB3);
  961. + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xD3);
  962. + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5);
  963. + rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x07);
  964. + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x68);
  965. + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xEF);
  966. + rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1C);
  967. + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x07);
  968. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xA8);
  969. + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0x85);
  970. + rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x10);
  971. + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x07);
  972. + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6A);
  973. + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0x85);
  974. + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x10);
  975. + rt2800_rfcsr_write_chanreg(rt2x00dev, 62, 0x1C);
  976. + rt2800_rfcsr_write_chanreg(rt2x00dev, 63, 0x00);
  977. +
  978. + rt2800_rfcsr_write_bank(rt2x00dev, 6, 45, 0xC5);
  979. +
  980. + rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x47);
  981. + rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x71);
  982. + rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x33);
  983. + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x0E);
  984. + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23);
  985. + rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA4);
  986. + rt2800_rfcsr_write_chanreg(rt2x00dev, 20, 0x02);
  987. + rt2800_rfcsr_write_chanreg(rt2x00dev, 21, 0x12);
  988. + rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x1C);
  989. + rt2800_rfcsr_write_chanreg(rt2x00dev, 29, 0xEB);
  990. + rt2800_rfcsr_write_chanreg(rt2x00dev, 32, 0x7D);
  991. + rt2800_rfcsr_write_chanreg(rt2x00dev, 34, 0xD6);
  992. + rt2800_rfcsr_write_chanreg(rt2x00dev, 36, 0x08);
  993. + rt2800_rfcsr_write_chanreg(rt2x00dev, 38, 0xB4);
  994. + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3);
  995. + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xB3);
  996. + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5);
  997. + rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27);
  998. + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x69);
  999. + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFF);
  1000. + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x20);
  1001. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66);
  1002. + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xFF);
  1003. + rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x1C);
  1004. + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x20);
  1005. + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B);
  1006. + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xF7);
  1007. + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09);
  1008. +
  1009. + rt2800_rfcsr_write_chanreg(rt2x00dev, 10, 0x51);
  1010. + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x06);
  1011. + rt2800_rfcsr_write_chanreg(rt2x00dev, 19, 0xA7);
  1012. + rt2800_rfcsr_write_chanreg(rt2x00dev, 28, 0x2C);
  1013. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x64);
  1014. + rt2800_rfcsr_write_chanreg(rt2x00dev, 8, 0x51);
  1015. + rt2800_rfcsr_write_chanreg(rt2x00dev, 9, 0x36);
  1016. + rt2800_rfcsr_write_chanreg(rt2x00dev, 11, 0x53);
  1017. + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16);
  1018. +
  1019. + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6C);
  1020. + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFC);
  1021. + rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1F);
  1022. + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27);
  1023. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66);
  1024. + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B);
  1025. +
  1026. + /* Initialize RF channel register for DRQFN */
  1027. + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3);
  1028. + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xE3);
  1029. + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xE5);
  1030. + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x28);
  1031. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x68);
  1032. + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xF7);
  1033. + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x02);
  1034. + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xC7);
  1035. +
  1036. + /* Initialize RF DC calibration register to default value */
  1037. + rt2800_rfcsr_write_dccal(rt2x00dev, 0, 0x47);
  1038. + rt2800_rfcsr_write_dccal(rt2x00dev, 1, 0x00);
  1039. + rt2800_rfcsr_write_dccal(rt2x00dev, 2, 0x00);
  1040. + rt2800_rfcsr_write_dccal(rt2x00dev, 3, 0x00);
  1041. + rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x00);
  1042. + rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
  1043. + rt2800_rfcsr_write_dccal(rt2x00dev, 6, 0x10);
  1044. + rt2800_rfcsr_write_dccal(rt2x00dev, 7, 0x10);
  1045. + rt2800_rfcsr_write_dccal(rt2x00dev, 8, 0x04);
  1046. + rt2800_rfcsr_write_dccal(rt2x00dev, 9, 0x00);
  1047. + rt2800_rfcsr_write_dccal(rt2x00dev, 10, 0x07);
  1048. + rt2800_rfcsr_write_dccal(rt2x00dev, 11, 0x01);
  1049. + rt2800_rfcsr_write_dccal(rt2x00dev, 12, 0x07);
  1050. + rt2800_rfcsr_write_dccal(rt2x00dev, 13, 0x07);
  1051. + rt2800_rfcsr_write_dccal(rt2x00dev, 14, 0x07);
  1052. + rt2800_rfcsr_write_dccal(rt2x00dev, 15, 0x20);
  1053. + rt2800_rfcsr_write_dccal(rt2x00dev, 16, 0x22);
  1054. + rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x00);
  1055. + rt2800_rfcsr_write_dccal(rt2x00dev, 18, 0x00);
  1056. + rt2800_rfcsr_write_dccal(rt2x00dev, 19, 0x00);
  1057. + rt2800_rfcsr_write_dccal(rt2x00dev, 20, 0x00);
  1058. + rt2800_rfcsr_write_dccal(rt2x00dev, 21, 0xF1);
  1059. + rt2800_rfcsr_write_dccal(rt2x00dev, 22, 0x11);
  1060. + rt2800_rfcsr_write_dccal(rt2x00dev, 23, 0x02);
  1061. + rt2800_rfcsr_write_dccal(rt2x00dev, 24, 0x41);
  1062. + rt2800_rfcsr_write_dccal(rt2x00dev, 25, 0x20);
  1063. + rt2800_rfcsr_write_dccal(rt2x00dev, 26, 0x00);
  1064. + rt2800_rfcsr_write_dccal(rt2x00dev, 27, 0xD7);
  1065. + rt2800_rfcsr_write_dccal(rt2x00dev, 28, 0xA2);
  1066. + rt2800_rfcsr_write_dccal(rt2x00dev, 29, 0x20);
  1067. + rt2800_rfcsr_write_dccal(rt2x00dev, 30, 0x49);
  1068. + rt2800_rfcsr_write_dccal(rt2x00dev, 31, 0x20);
  1069. + rt2800_rfcsr_write_dccal(rt2x00dev, 32, 0x04);
  1070. + rt2800_rfcsr_write_dccal(rt2x00dev, 33, 0xF1);
  1071. + rt2800_rfcsr_write_dccal(rt2x00dev, 34, 0xA1);
  1072. + rt2800_rfcsr_write_dccal(rt2x00dev, 35, 0x01);
  1073. + rt2800_rfcsr_write_dccal(rt2x00dev, 41, 0x00);
  1074. + rt2800_rfcsr_write_dccal(rt2x00dev, 42, 0x00);
  1075. + rt2800_rfcsr_write_dccal(rt2x00dev, 43, 0x00);
  1076. + rt2800_rfcsr_write_dccal(rt2x00dev, 44, 0x00);
  1077. + rt2800_rfcsr_write_dccal(rt2x00dev, 45, 0x00);
  1078. + rt2800_rfcsr_write_dccal(rt2x00dev, 46, 0x00);
  1079. + rt2800_rfcsr_write_dccal(rt2x00dev, 47, 0x3E);
  1080. + rt2800_rfcsr_write_dccal(rt2x00dev, 48, 0x3D);
  1081. + rt2800_rfcsr_write_dccal(rt2x00dev, 49, 0x3E);
  1082. + rt2800_rfcsr_write_dccal(rt2x00dev, 50, 0x3D);
  1083. + rt2800_rfcsr_write_dccal(rt2x00dev, 51, 0x3E);
  1084. + rt2800_rfcsr_write_dccal(rt2x00dev, 52, 0x3D);
  1085. + rt2800_rfcsr_write_dccal(rt2x00dev, 53, 0x00);
  1086. + rt2800_rfcsr_write_dccal(rt2x00dev, 54, 0x00);
  1087. + rt2800_rfcsr_write_dccal(rt2x00dev, 55, 0x00);
  1088. + rt2800_rfcsr_write_dccal(rt2x00dev, 56, 0x00);
  1089. + rt2800_rfcsr_write_dccal(rt2x00dev, 57, 0x00);
  1090. + rt2800_rfcsr_write_dccal(rt2x00dev, 58, 0x10);
  1091. + rt2800_rfcsr_write_dccal(rt2x00dev, 59, 0x10);
  1092. + rt2800_rfcsr_write_dccal(rt2x00dev, 60, 0x0A);
  1093. + rt2800_rfcsr_write_dccal(rt2x00dev, 61, 0x00);
  1094. + rt2800_rfcsr_write_dccal(rt2x00dev, 62, 0x00);
  1095. + rt2800_rfcsr_write_dccal(rt2x00dev, 63, 0x00);
  1096. +
  1097. + rt2800_rfcsr_write_dccal(rt2x00dev, 3, 0x08);
  1098. + rt2800_rfcsr_write_dccal(rt2x00dev, 4, 0x04);
  1099. + rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x20);
  1100. +
  1101. + rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
  1102. + rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
  1103. +}
  1104. +
  1105. static void rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
  1106. {
  1107. if (rt2800_is_305x_soc(rt2x00dev)) {
  1108. @@ -7366,7 +8257,10 @@ static void rt2800_init_rfcsr(struct rt2
  1109. rt2800_init_rfcsr_5350(rt2x00dev);
  1110. break;
  1111. case RT5390:
  1112. - rt2800_init_rfcsr_5390(rt2x00dev);
  1113. + if (rt2x00dev->chip.rf == RF7620)
  1114. + rt2800_init_rfcsr_7620(rt2x00dev);
  1115. + else
  1116. + rt2800_init_rfcsr_5390(rt2x00dev);
  1117. break;
  1118. case RT5392:
  1119. rt2800_init_rfcsr_5392(rt2x00dev);
  1120. @@ -7780,6 +8674,7 @@ static int rt2800_init_eeprom(struct rt2
  1121. case RF5390:
  1122. case RF5392:
  1123. case RF5592:
  1124. + case RF7620:
  1125. break;
  1126. default:
  1127. rt2x00_err(rt2x00dev, "Invalid RF chipset 0x%04x detected\n",
  1128. @@ -8258,6 +9153,24 @@ static const struct rf_channel rf_vals_5
  1129. {196, 83, 0, 12, 1},
  1130. };
  1131. +static const struct rf_channel rf_vals_7620[] = {
  1132. + /* Channel, Rdiv, N, K | (D >> 8), Ksd */
  1133. + {1, 3, 0x50, 0 | (0 >> 8), 0x19999},
  1134. + {2, 3, 0x50, 0 | (0 >> 8), 0x24444},
  1135. + {3, 3, 0x50, 0 | (0 >> 8), 0x2EEEE},
  1136. + {4, 3, 0x50, 0 | (0 >> 8), 0x39999},
  1137. + {5, 3, 0x51, 0 | (0 >> 8), 0x04444},
  1138. + {6, 3, 0x51, 0 | (0 >> 8), 0x0EEEE},
  1139. + {7, 3, 0x51, 0 | (0 >> 8), 0x19999},
  1140. + {8, 3, 0x51, 0 | (0 >> 8), 0x24444},
  1141. + {9, 3, 0x51, 0 | (0 >> 8), 0x2EEEE},
  1142. + {10, 3, 0x51, 0 | (0 >> 8), 0x39999},
  1143. + {11, 3, 0x52, 0 | (0 >> 8), 0x04444},
  1144. + {12, 3, 0x52, 0 | (0 >> 8), 0x0EEEE},
  1145. + {13, 3, 0x52, 0 | (0 >> 8), 0x19999},
  1146. + {14, 3, 0x52, 0 | (0 >> 8), 0x33333},
  1147. +};
  1148. +
  1149. static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
  1150. {
  1151. struct hw_mode_spec *spec = &rt2x00dev->spec;
  1152. @@ -8361,6 +9274,11 @@ static int rt2800_probe_hw_mode(struct r
  1153. spec->channels = rf_vals_3x;
  1154. break;
  1155. + case RF7620:
  1156. + spec->num_channels = ARRAY_SIZE(rf_vals_7620);
  1157. + spec->channels = rf_vals_7620;
  1158. + break;
  1159. +
  1160. case RF3052:
  1161. case RF3053:
  1162. spec->num_channels = ARRAY_SIZE(rf_vals_3x);
  1163. @@ -8498,6 +9416,7 @@ static int rt2800_probe_hw_mode(struct r
  1164. case RF5390:
  1165. case RF5392:
  1166. case RF5592:
  1167. + case RF7620:
  1168. __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags);
  1169. break;
  1170. }