910-01-add-support-for-mt7620.patch 43 KB

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