zd_chip.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. /* ZD1211 USB-WLAN driver for Linux
  2. *
  3. * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
  4. * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef _ZD_CHIP_H
  21. #define _ZD_CHIP_H
  22. #include "zd_rf.h"
  23. #include "zd_usb.h"
  24. /* Header for the Media Access Controller (MAC) and the Baseband Processor
  25. * (BBP). It appears that the ZD1211 wraps the old ZD1205 with USB glue and
  26. * adds a processor for handling the USB protocol.
  27. */
  28. /* Address space */
  29. enum {
  30. /* CONTROL REGISTERS */
  31. CR_START = 0x9000,
  32. /* FIRMWARE */
  33. FW_START = 0xee00,
  34. /* EEPROM */
  35. E2P_START = 0xf800,
  36. E2P_LEN = 0x800,
  37. /* EEPROM layout */
  38. E2P_LOAD_CODE_LEN = 0xe, /* base 0xf800 */
  39. E2P_LOAD_VECT_LEN = 0x9, /* base 0xf80e */
  40. /* E2P_DATA indexes into this */
  41. E2P_DATA_LEN = 0x7e, /* base 0xf817 */
  42. E2P_BOOT_CODE_LEN = 0x760, /* base 0xf895 */
  43. E2P_INTR_VECT_LEN = 0xb, /* base 0xfff5 */
  44. /* Some precomputed offsets into the EEPROM */
  45. E2P_DATA_OFFSET = E2P_LOAD_CODE_LEN + E2P_LOAD_VECT_LEN,
  46. E2P_BOOT_CODE_OFFSET = E2P_DATA_OFFSET + E2P_DATA_LEN,
  47. };
  48. #define CTL_REG(offset) ((zd_addr_t)(CR_START + (offset)))
  49. #define E2P_DATA(offset) ((zd_addr_t)(E2P_START + E2P_DATA_OFFSET + (offset)))
  50. #define FWRAW_DATA(offset) ((zd_addr_t)(FW_START + (offset)))
  51. /* 8-bit hardware registers */
  52. #define CR0 CTL_REG(0x0000)
  53. #define CR1 CTL_REG(0x0004)
  54. #define CR2 CTL_REG(0x0008)
  55. #define CR3 CTL_REG(0x000C)
  56. #define CR5 CTL_REG(0x0010)
  57. /* bit 5: if set short preamble used
  58. * bit 6: filter band - Japan channel 14 on, else off
  59. */
  60. #define CR6 CTL_REG(0x0014)
  61. #define CR7 CTL_REG(0x0018)
  62. #define CR8 CTL_REG(0x001C)
  63. #define CR4 CTL_REG(0x0020)
  64. #define CR9 CTL_REG(0x0024)
  65. /* bit 2: antenna switch (together with CR10) */
  66. #define CR10 CTL_REG(0x0028)
  67. /* bit 1: antenna switch (together with CR9)
  68. * RF2959 controls with CR11 radion on and off
  69. */
  70. #define CR11 CTL_REG(0x002C)
  71. /* bit 6: TX power control for OFDM
  72. * RF2959 controls with CR10 radio on and off
  73. */
  74. #define CR12 CTL_REG(0x0030)
  75. #define CR13 CTL_REG(0x0034)
  76. #define CR14 CTL_REG(0x0038)
  77. #define CR15 CTL_REG(0x003C)
  78. #define CR16 CTL_REG(0x0040)
  79. #define CR17 CTL_REG(0x0044)
  80. #define CR18 CTL_REG(0x0048)
  81. #define CR19 CTL_REG(0x004C)
  82. #define CR20 CTL_REG(0x0050)
  83. #define CR21 CTL_REG(0x0054)
  84. #define CR22 CTL_REG(0x0058)
  85. #define CR23 CTL_REG(0x005C)
  86. #define CR24 CTL_REG(0x0060) /* CCA threshold */
  87. #define CR25 CTL_REG(0x0064)
  88. #define CR26 CTL_REG(0x0068)
  89. #define CR27 CTL_REG(0x006C)
  90. #define CR28 CTL_REG(0x0070)
  91. #define CR29 CTL_REG(0x0074)
  92. #define CR30 CTL_REG(0x0078)
  93. #define CR31 CTL_REG(0x007C) /* TX power control for RF in CCK mode */
  94. #define CR32 CTL_REG(0x0080)
  95. #define CR33 CTL_REG(0x0084)
  96. #define CR34 CTL_REG(0x0088)
  97. #define CR35 CTL_REG(0x008C)
  98. #define CR36 CTL_REG(0x0090)
  99. #define CR37 CTL_REG(0x0094)
  100. #define CR38 CTL_REG(0x0098)
  101. #define CR39 CTL_REG(0x009C)
  102. #define CR40 CTL_REG(0x00A0)
  103. #define CR41 CTL_REG(0x00A4)
  104. #define CR42 CTL_REG(0x00A8)
  105. #define CR43 CTL_REG(0x00AC)
  106. #define CR44 CTL_REG(0x00B0)
  107. #define CR45 CTL_REG(0x00B4)
  108. #define CR46 CTL_REG(0x00B8)
  109. #define CR47 CTL_REG(0x00BC) /* CCK baseband gain
  110. * (patch value might be in EEPROM)
  111. */
  112. #define CR48 CTL_REG(0x00C0)
  113. #define CR49 CTL_REG(0x00C4)
  114. #define CR50 CTL_REG(0x00C8)
  115. #define CR51 CTL_REG(0x00CC) /* TX power control for RF in 6-36M modes */
  116. #define CR52 CTL_REG(0x00D0) /* TX power control for RF in 48M mode */
  117. #define CR53 CTL_REG(0x00D4) /* TX power control for RF in 54M mode */
  118. #define CR54 CTL_REG(0x00D8)
  119. #define CR55 CTL_REG(0x00DC)
  120. #define CR56 CTL_REG(0x00E0)
  121. #define CR57 CTL_REG(0x00E4)
  122. #define CR58 CTL_REG(0x00E8)
  123. #define CR59 CTL_REG(0x00EC)
  124. #define CR60 CTL_REG(0x00F0)
  125. #define CR61 CTL_REG(0x00F4)
  126. #define CR62 CTL_REG(0x00F8)
  127. #define CR63 CTL_REG(0x00FC)
  128. #define CR64 CTL_REG(0x0100)
  129. #define CR65 CTL_REG(0x0104) /* OFDM 54M calibration */
  130. #define CR66 CTL_REG(0x0108) /* OFDM 48M calibration */
  131. #define CR67 CTL_REG(0x010C) /* OFDM 36M calibration */
  132. #define CR68 CTL_REG(0x0110) /* CCK calibration */
  133. #define CR69 CTL_REG(0x0114)
  134. #define CR70 CTL_REG(0x0118)
  135. #define CR71 CTL_REG(0x011C)
  136. #define CR72 CTL_REG(0x0120)
  137. #define CR73 CTL_REG(0x0124)
  138. #define CR74 CTL_REG(0x0128)
  139. #define CR75 CTL_REG(0x012C)
  140. #define CR76 CTL_REG(0x0130)
  141. #define CR77 CTL_REG(0x0134)
  142. #define CR78 CTL_REG(0x0138)
  143. #define CR79 CTL_REG(0x013C)
  144. #define CR80 CTL_REG(0x0140)
  145. #define CR81 CTL_REG(0x0144)
  146. #define CR82 CTL_REG(0x0148)
  147. #define CR83 CTL_REG(0x014C)
  148. #define CR84 CTL_REG(0x0150)
  149. #define CR85 CTL_REG(0x0154)
  150. #define CR86 CTL_REG(0x0158)
  151. #define CR87 CTL_REG(0x015C)
  152. #define CR88 CTL_REG(0x0160)
  153. #define CR89 CTL_REG(0x0164)
  154. #define CR90 CTL_REG(0x0168)
  155. #define CR91 CTL_REG(0x016C)
  156. #define CR92 CTL_REG(0x0170)
  157. #define CR93 CTL_REG(0x0174)
  158. #define CR94 CTL_REG(0x0178)
  159. #define CR95 CTL_REG(0x017C)
  160. #define CR96 CTL_REG(0x0180)
  161. #define CR97 CTL_REG(0x0184)
  162. #define CR98 CTL_REG(0x0188)
  163. #define CR99 CTL_REG(0x018C)
  164. #define CR100 CTL_REG(0x0190)
  165. #define CR101 CTL_REG(0x0194)
  166. #define CR102 CTL_REG(0x0198)
  167. #define CR103 CTL_REG(0x019C)
  168. #define CR104 CTL_REG(0x01A0)
  169. #define CR105 CTL_REG(0x01A4)
  170. #define CR106 CTL_REG(0x01A8)
  171. #define CR107 CTL_REG(0x01AC)
  172. #define CR108 CTL_REG(0x01B0)
  173. #define CR109 CTL_REG(0x01B4)
  174. #define CR110 CTL_REG(0x01B8)
  175. #define CR111 CTL_REG(0x01BC)
  176. #define CR112 CTL_REG(0x01C0)
  177. #define CR113 CTL_REG(0x01C4)
  178. #define CR114 CTL_REG(0x01C8)
  179. #define CR115 CTL_REG(0x01CC)
  180. #define CR116 CTL_REG(0x01D0)
  181. #define CR117 CTL_REG(0x01D4)
  182. #define CR118 CTL_REG(0x01D8)
  183. #define CR119 CTL_REG(0x01DC)
  184. #define CR120 CTL_REG(0x01E0)
  185. #define CR121 CTL_REG(0x01E4)
  186. #define CR122 CTL_REG(0x01E8)
  187. #define CR123 CTL_REG(0x01EC)
  188. #define CR124 CTL_REG(0x01F0)
  189. #define CR125 CTL_REG(0x01F4)
  190. #define CR126 CTL_REG(0x01F8)
  191. #define CR127 CTL_REG(0x01FC)
  192. #define CR128 CTL_REG(0x0200)
  193. #define CR129 CTL_REG(0x0204)
  194. #define CR130 CTL_REG(0x0208)
  195. #define CR131 CTL_REG(0x020C)
  196. #define CR132 CTL_REG(0x0210)
  197. #define CR133 CTL_REG(0x0214)
  198. #define CR134 CTL_REG(0x0218)
  199. #define CR135 CTL_REG(0x021C)
  200. #define CR136 CTL_REG(0x0220)
  201. #define CR137 CTL_REG(0x0224)
  202. #define CR138 CTL_REG(0x0228)
  203. #define CR139 CTL_REG(0x022C)
  204. #define CR140 CTL_REG(0x0230)
  205. #define CR141 CTL_REG(0x0234)
  206. #define CR142 CTL_REG(0x0238)
  207. #define CR143 CTL_REG(0x023C)
  208. #define CR144 CTL_REG(0x0240)
  209. #define CR145 CTL_REG(0x0244)
  210. #define CR146 CTL_REG(0x0248)
  211. #define CR147 CTL_REG(0x024C)
  212. #define CR148 CTL_REG(0x0250)
  213. #define CR149 CTL_REG(0x0254)
  214. #define CR150 CTL_REG(0x0258)
  215. #define CR151 CTL_REG(0x025C)
  216. #define CR152 CTL_REG(0x0260)
  217. #define CR153 CTL_REG(0x0264)
  218. #define CR154 CTL_REG(0x0268)
  219. #define CR155 CTL_REG(0x026C)
  220. #define CR156 CTL_REG(0x0270)
  221. #define CR157 CTL_REG(0x0274)
  222. #define CR158 CTL_REG(0x0278)
  223. #define CR159 CTL_REG(0x027C)
  224. #define CR160 CTL_REG(0x0280)
  225. #define CR161 CTL_REG(0x0284)
  226. #define CR162 CTL_REG(0x0288)
  227. #define CR163 CTL_REG(0x028C)
  228. #define CR164 CTL_REG(0x0290)
  229. #define CR165 CTL_REG(0x0294)
  230. #define CR166 CTL_REG(0x0298)
  231. #define CR167 CTL_REG(0x029C)
  232. #define CR168 CTL_REG(0x02A0)
  233. #define CR169 CTL_REG(0x02A4)
  234. #define CR170 CTL_REG(0x02A8)
  235. #define CR171 CTL_REG(0x02AC)
  236. #define CR172 CTL_REG(0x02B0)
  237. #define CR173 CTL_REG(0x02B4)
  238. #define CR174 CTL_REG(0x02B8)
  239. #define CR175 CTL_REG(0x02BC)
  240. #define CR176 CTL_REG(0x02C0)
  241. #define CR177 CTL_REG(0x02C4)
  242. #define CR178 CTL_REG(0x02C8)
  243. #define CR179 CTL_REG(0x02CC)
  244. #define CR180 CTL_REG(0x02D0)
  245. #define CR181 CTL_REG(0x02D4)
  246. #define CR182 CTL_REG(0x02D8)
  247. #define CR183 CTL_REG(0x02DC)
  248. #define CR184 CTL_REG(0x02E0)
  249. #define CR185 CTL_REG(0x02E4)
  250. #define CR186 CTL_REG(0x02E8)
  251. #define CR187 CTL_REG(0x02EC)
  252. #define CR188 CTL_REG(0x02F0)
  253. #define CR189 CTL_REG(0x02F4)
  254. #define CR190 CTL_REG(0x02F8)
  255. #define CR191 CTL_REG(0x02FC)
  256. #define CR192 CTL_REG(0x0300)
  257. #define CR193 CTL_REG(0x0304)
  258. #define CR194 CTL_REG(0x0308)
  259. #define CR195 CTL_REG(0x030C)
  260. #define CR196 CTL_REG(0x0310)
  261. #define CR197 CTL_REG(0x0314)
  262. #define CR198 CTL_REG(0x0318)
  263. #define CR199 CTL_REG(0x031C)
  264. #define CR200 CTL_REG(0x0320)
  265. #define CR201 CTL_REG(0x0324)
  266. #define CR202 CTL_REG(0x0328)
  267. #define CR203 CTL_REG(0x032C) /* I2C bus template value & flash control */
  268. #define CR204 CTL_REG(0x0330)
  269. #define CR205 CTL_REG(0x0334)
  270. #define CR206 CTL_REG(0x0338)
  271. #define CR207 CTL_REG(0x033C)
  272. #define CR208 CTL_REG(0x0340)
  273. #define CR209 CTL_REG(0x0344)
  274. #define CR210 CTL_REG(0x0348)
  275. #define CR211 CTL_REG(0x034C)
  276. #define CR212 CTL_REG(0x0350)
  277. #define CR213 CTL_REG(0x0354)
  278. #define CR214 CTL_REG(0x0358)
  279. #define CR215 CTL_REG(0x035C)
  280. #define CR216 CTL_REG(0x0360)
  281. #define CR217 CTL_REG(0x0364)
  282. #define CR218 CTL_REG(0x0368)
  283. #define CR219 CTL_REG(0x036C)
  284. #define CR220 CTL_REG(0x0370)
  285. #define CR221 CTL_REG(0x0374)
  286. #define CR222 CTL_REG(0x0378)
  287. #define CR223 CTL_REG(0x037C)
  288. #define CR224 CTL_REG(0x0380)
  289. #define CR225 CTL_REG(0x0384)
  290. #define CR226 CTL_REG(0x0388)
  291. #define CR227 CTL_REG(0x038C)
  292. #define CR228 CTL_REG(0x0390)
  293. #define CR229 CTL_REG(0x0394)
  294. #define CR230 CTL_REG(0x0398)
  295. #define CR231 CTL_REG(0x039C)
  296. #define CR232 CTL_REG(0x03A0)
  297. #define CR233 CTL_REG(0x03A4)
  298. #define CR234 CTL_REG(0x03A8)
  299. #define CR235 CTL_REG(0x03AC)
  300. #define CR236 CTL_REG(0x03B0)
  301. #define CR240 CTL_REG(0x03C0)
  302. /* bit 7: host-controlled RF register writes
  303. * CR241-CR245: for hardware controlled writing of RF bits, not needed for
  304. * USB
  305. */
  306. #define CR241 CTL_REG(0x03C4)
  307. #define CR242 CTL_REG(0x03C8)
  308. #define CR243 CTL_REG(0x03CC)
  309. #define CR244 CTL_REG(0x03D0)
  310. #define CR245 CTL_REG(0x03D4)
  311. #define CR251 CTL_REG(0x03EC) /* only used for activation and deactivation of
  312. * Airoha RFs AL2230 and AL7230B
  313. */
  314. #define CR252 CTL_REG(0x03F0)
  315. #define CR253 CTL_REG(0x03F4)
  316. #define CR254 CTL_REG(0x03F8)
  317. #define CR255 CTL_REG(0x03FC)
  318. #define CR_MAX_PHY_REG 255
  319. /* Taken from the ZYDAS driver, not all of them are relevant for the ZD1211
  320. * driver.
  321. */
  322. #define CR_RF_IF_CLK CTL_REG(0x0400)
  323. #define CR_RF_IF_DATA CTL_REG(0x0404)
  324. #define CR_PE1_PE2 CTL_REG(0x0408)
  325. #define CR_PE2_DLY CTL_REG(0x040C)
  326. #define CR_LE1 CTL_REG(0x0410)
  327. #define CR_LE2 CTL_REG(0x0414)
  328. /* Seems to enable/disable GPI (General Purpose IO?) */
  329. #define CR_GPI_EN CTL_REG(0x0418)
  330. #define CR_RADIO_PD CTL_REG(0x042C)
  331. #define CR_RF2948_PD CTL_REG(0x042C)
  332. #define CR_ENABLE_PS_MANUAL_AGC CTL_REG(0x043C)
  333. #define CR_CONFIG_PHILIPS CTL_REG(0x0440)
  334. #define CR_SA2400_SER_AP CTL_REG(0x0444)
  335. #define CR_I2C_WRITE CTL_REG(0x0444)
  336. #define CR_SA2400_SER_RP CTL_REG(0x0448)
  337. #define CR_RADIO_PE CTL_REG(0x0458)
  338. #define CR_RST_BUS_MASTER CTL_REG(0x045C)
  339. #define CR_RFCFG CTL_REG(0x0464)
  340. #define CR_HSTSCHG CTL_REG(0x046C)
  341. #define CR_PHY_ON CTL_REG(0x0474)
  342. #define CR_RX_DELAY CTL_REG(0x0478)
  343. #define CR_RX_PE_DELAY CTL_REG(0x047C)
  344. #define CR_GPIO_1 CTL_REG(0x0490)
  345. #define CR_GPIO_2 CTL_REG(0x0494)
  346. #define CR_EncryBufMux CTL_REG(0x04A8)
  347. #define CR_PS_CTRL CTL_REG(0x0500)
  348. #define CR_ADDA_PWR_DWN CTL_REG(0x0504)
  349. #define CR_ADDA_MBIAS_WARMTIME CTL_REG(0x0508)
  350. #define CR_MAC_PS_STATE CTL_REG(0x050C)
  351. #define CR_INTERRUPT CTL_REG(0x0510)
  352. #define INT_TX_COMPLETE (1 << 0)
  353. #define INT_RX_COMPLETE (1 << 1)
  354. #define INT_RETRY_FAIL (1 << 2)
  355. #define INT_WAKEUP (1 << 3)
  356. #define INT_DTIM_NOTIFY (1 << 5)
  357. #define INT_CFG_NEXT_BCN (1 << 6)
  358. #define INT_BUS_ABORT (1 << 7)
  359. #define INT_TX_FIFO_READY (1 << 8)
  360. #define INT_UART (1 << 9)
  361. #define INT_TX_COMPLETE_EN (1 << 16)
  362. #define INT_RX_COMPLETE_EN (1 << 17)
  363. #define INT_RETRY_FAIL_EN (1 << 18)
  364. #define INT_WAKEUP_EN (1 << 19)
  365. #define INT_DTIM_NOTIFY_EN (1 << 21)
  366. #define INT_CFG_NEXT_BCN_EN (1 << 22)
  367. #define INT_BUS_ABORT_EN (1 << 23)
  368. #define INT_TX_FIFO_READY_EN (1 << 24)
  369. #define INT_UART_EN (1 << 25)
  370. #define CR_TSF_LOW_PART CTL_REG(0x0514)
  371. #define CR_TSF_HIGH_PART CTL_REG(0x0518)
  372. /* Following three values are in time units (1024us)
  373. * Following condition must be met:
  374. * atim < tbtt < bcn
  375. */
  376. #define CR_ATIM_WND_PERIOD CTL_REG(0x051C)
  377. #define CR_BCN_INTERVAL CTL_REG(0x0520)
  378. #define CR_PRE_TBTT CTL_REG(0x0524)
  379. /* in units of TU(1024us) */
  380. /* for UART support */
  381. #define CR_UART_RBR_THR_DLL CTL_REG(0x0540)
  382. #define CR_UART_DLM_IER CTL_REG(0x0544)
  383. #define CR_UART_IIR_FCR CTL_REG(0x0548)
  384. #define CR_UART_LCR CTL_REG(0x054c)
  385. #define CR_UART_MCR CTL_REG(0x0550)
  386. #define CR_UART_LSR CTL_REG(0x0554)
  387. #define CR_UART_MSR CTL_REG(0x0558)
  388. #define CR_UART_ECR CTL_REG(0x055c)
  389. #define CR_UART_STATUS CTL_REG(0x0560)
  390. #define CR_PCI_TX_ADDR_P1 CTL_REG(0x0600)
  391. #define CR_PCI_TX_AddR_P2 CTL_REG(0x0604)
  392. #define CR_PCI_RX_AddR_P1 CTL_REG(0x0608)
  393. #define CR_PCI_RX_AddR_P2 CTL_REG(0x060C)
  394. /* must be overwritten if custom MAC address will be used */
  395. #define CR_MAC_ADDR_P1 CTL_REG(0x0610)
  396. #define CR_MAC_ADDR_P2 CTL_REG(0x0614)
  397. #define CR_BSSID_P1 CTL_REG(0x0618)
  398. #define CR_BSSID_P2 CTL_REG(0x061C)
  399. #define CR_BCN_PLCP_CFG CTL_REG(0x0620)
  400. /* Group hash table for filtering incoming packets.
  401. *
  402. * The group hash table is 64 bit large and split over two parts. The first
  403. * part is the lower part. The upper 6 bits of the last byte of the target
  404. * address are used as index. Packets are received if the hash table bit is
  405. * set. This is used for multicast handling, but for broadcasts (address
  406. * ff:ff:ff:ff:ff:ff) the highest bit in the second table must also be set.
  407. */
  408. #define CR_GROUP_HASH_P1 CTL_REG(0x0624)
  409. #define CR_GROUP_HASH_P2 CTL_REG(0x0628)
  410. #define CR_RX_TIMEOUT CTL_REG(0x062C)
  411. /* Basic rates supported by the BSS. When producing ACK or CTS messages, the
  412. * device will use a rate in this table that is less than or equal to the rate
  413. * of the incoming frame which prompted the response. */
  414. #define CR_BASIC_RATE_TBL CTL_REG(0x0630)
  415. #define CR_RATE_1M (1 << 0) /* 802.11b */
  416. #define CR_RATE_2M (1 << 1) /* 802.11b */
  417. #define CR_RATE_5_5M (1 << 2) /* 802.11b */
  418. #define CR_RATE_11M (1 << 3) /* 802.11b */
  419. #define CR_RATE_6M (1 << 8) /* 802.11g */
  420. #define CR_RATE_9M (1 << 9) /* 802.11g */
  421. #define CR_RATE_12M (1 << 10) /* 802.11g */
  422. #define CR_RATE_18M (1 << 11) /* 802.11g */
  423. #define CR_RATE_24M (1 << 12) /* 802.11g */
  424. #define CR_RATE_36M (1 << 13) /* 802.11g */
  425. #define CR_RATE_48M (1 << 14) /* 802.11g */
  426. #define CR_RATE_54M (1 << 15) /* 802.11g */
  427. #define CR_RATES_80211G 0xff00
  428. #define CR_RATES_80211B 0x000f
  429. /* Mandatory rates required in the BSS. When producing ACK or CTS messages, if
  430. * the device could not find an appropriate rate in CR_BASIC_RATE_TBL, it will
  431. * look for a rate in this table that is less than or equal to the rate of
  432. * the incoming frame. */
  433. #define CR_MANDATORY_RATE_TBL CTL_REG(0x0634)
  434. #define CR_RTS_CTS_RATE CTL_REG(0x0638)
  435. /* These are all bit indexes in CR_RTS_CTS_RATE, so remember to shift. */
  436. #define RTSCTS_SH_RTS_RATE 0
  437. #define RTSCTS_SH_EXP_CTS_RATE 4
  438. #define RTSCTS_SH_RTS_MOD_TYPE 8
  439. #define RTSCTS_SH_RTS_PMB_TYPE 9
  440. #define RTSCTS_SH_CTS_RATE 16
  441. #define RTSCTS_SH_CTS_MOD_TYPE 24
  442. #define RTSCTS_SH_CTS_PMB_TYPE 25
  443. #define CR_WEP_PROTECT CTL_REG(0x063C)
  444. #define CR_RX_THRESHOLD CTL_REG(0x0640)
  445. /* register for controlling the LEDS */
  446. #define CR_LED CTL_REG(0x0644)
  447. /* masks for controlling LEDs */
  448. #define LED1 (1 << 8)
  449. #define LED2 (1 << 9)
  450. #define LED_SW (1 << 10)
  451. /* Seems to indicate that the configuration is over.
  452. */
  453. #define CR_AFTER_PNP CTL_REG(0x0648)
  454. #define CR_ACK_TIME_80211 CTL_REG(0x0658)
  455. #define CR_RX_OFFSET CTL_REG(0x065c)
  456. #define CR_BCN_LENGTH CTL_REG(0x0664)
  457. #define CR_PHY_DELAY CTL_REG(0x066C)
  458. #define CR_BCN_FIFO CTL_REG(0x0670)
  459. #define CR_SNIFFER_ON CTL_REG(0x0674)
  460. #define CR_ENCRYPTION_TYPE CTL_REG(0x0678)
  461. #define NO_WEP 0
  462. #define WEP64 1
  463. #define WEP128 5
  464. #define WEP256 6
  465. #define ENC_SNIFFER 8
  466. #define CR_ZD1211_RETRY_MAX CTL_REG(0x067C)
  467. #define CR_REG1 CTL_REG(0x0680)
  468. /* Setting the bit UNLOCK_PHY_REGS disallows the write access to physical
  469. * registers, so one could argue it is a LOCK bit. But calling it
  470. * LOCK_PHY_REGS makes it confusing.
  471. */
  472. #define UNLOCK_PHY_REGS (1 << 7)
  473. #define CR_DEVICE_STATE CTL_REG(0x0684)
  474. #define CR_UNDERRUN_CNT CTL_REG(0x0688)
  475. #define CR_RX_FILTER CTL_REG(0x068c)
  476. #define RX_FILTER_ASSOC_REQUEST (1 << 0)
  477. #define RX_FILTER_ASSOC_RESPONSE (1 << 1)
  478. #define RX_FILTER_REASSOC_REQUEST (1 << 2)
  479. #define RX_FILTER_REASSOC_RESPONSE (1 << 3)
  480. #define RX_FILTER_PROBE_REQUEST (1 << 4)
  481. #define RX_FILTER_PROBE_RESPONSE (1 << 5)
  482. /* bits 6 and 7 reserved */
  483. #define RX_FILTER_BEACON (1 << 8)
  484. #define RX_FILTER_ATIM (1 << 9)
  485. #define RX_FILTER_DISASSOC (1 << 10)
  486. #define RX_FILTER_AUTH (1 << 11)
  487. #define RX_FILTER_DEAUTH (1 << 12)
  488. #define RX_FILTER_PSPOLL (1 << 26)
  489. #define RX_FILTER_RTS (1 << 27)
  490. #define RX_FILTER_CTS (1 << 28)
  491. #define RX_FILTER_ACK (1 << 29)
  492. #define RX_FILTER_CFEND (1 << 30)
  493. #define RX_FILTER_CFACK (1 << 31)
  494. /* Enable bits for all frames you are interested in. */
  495. #define STA_RX_FILTER (RX_FILTER_ASSOC_REQUEST | RX_FILTER_ASSOC_RESPONSE | \
  496. RX_FILTER_REASSOC_REQUEST | RX_FILTER_REASSOC_RESPONSE | \
  497. RX_FILTER_PROBE_REQUEST | RX_FILTER_PROBE_RESPONSE | \
  498. (0x3 << 6) /* vendor driver sets these reserved bits */ | \
  499. RX_FILTER_BEACON | RX_FILTER_ATIM | RX_FILTER_DISASSOC | \
  500. RX_FILTER_AUTH | RX_FILTER_DEAUTH | \
  501. (0x7 << 13) /* vendor driver sets these reserved bits */ | \
  502. RX_FILTER_PSPOLL | RX_FILTER_ACK) /* 0x2400ffff */
  503. #define RX_FILTER_CTRL (RX_FILTER_RTS | RX_FILTER_CTS | \
  504. RX_FILTER_CFEND | RX_FILTER_CFACK)
  505. #define BCN_MODE_IBSS 0x2000000
  506. /* Monitor mode sets filter to 0xfffff */
  507. #define CR_ACK_TIMEOUT_EXT CTL_REG(0x0690)
  508. #define CR_BCN_FIFO_SEMAPHORE CTL_REG(0x0694)
  509. #define CR_IFS_VALUE CTL_REG(0x0698)
  510. #define IFS_VALUE_DIFS_SH 0
  511. #define IFS_VALUE_EIFS_SH 12
  512. #define IFS_VALUE_SIFS_SH 24
  513. #define IFS_VALUE_DEFAULT (( 50 << IFS_VALUE_DIFS_SH) | \
  514. (1148 << IFS_VALUE_EIFS_SH) | \
  515. ( 10 << IFS_VALUE_SIFS_SH))
  516. #define CR_RX_TIME_OUT CTL_REG(0x069C)
  517. #define CR_TOTAL_RX_FRM CTL_REG(0x06A0)
  518. #define CR_CRC32_CNT CTL_REG(0x06A4)
  519. #define CR_CRC16_CNT CTL_REG(0x06A8)
  520. #define CR_DECRYPTION_ERR_UNI CTL_REG(0x06AC)
  521. #define CR_RX_FIFO_OVERRUN CTL_REG(0x06B0)
  522. #define CR_DECRYPTION_ERR_MUL CTL_REG(0x06BC)
  523. #define CR_NAV_CNT CTL_REG(0x06C4)
  524. #define CR_NAV_CCA CTL_REG(0x06C8)
  525. #define CR_RETRY_CNT CTL_REG(0x06CC)
  526. #define CR_READ_TCB_ADDR CTL_REG(0x06E8)
  527. #define CR_READ_RFD_ADDR CTL_REG(0x06EC)
  528. #define CR_CWMIN_CWMAX CTL_REG(0x06F0)
  529. #define CR_TOTAL_TX_FRM CTL_REG(0x06F4)
  530. /* CAM: Continuous Access Mode (power management) */
  531. #define CR_CAM_MODE CTL_REG(0x0700)
  532. #define MODE_IBSS 0x0
  533. #define MODE_AP 0x1
  534. #define MODE_STA 0x2
  535. #define MODE_AP_WDS 0x3
  536. #define CR_CAM_ROLL_TB_LOW CTL_REG(0x0704)
  537. #define CR_CAM_ROLL_TB_HIGH CTL_REG(0x0708)
  538. #define CR_CAM_ADDRESS CTL_REG(0x070C)
  539. #define CR_CAM_DATA CTL_REG(0x0710)
  540. #define CR_ROMDIR CTL_REG(0x0714)
  541. #define CR_DECRY_ERR_FLG_LOW CTL_REG(0x0714)
  542. #define CR_DECRY_ERR_FLG_HIGH CTL_REG(0x0718)
  543. #define CR_WEPKEY0 CTL_REG(0x0720)
  544. #define CR_WEPKEY1 CTL_REG(0x0724)
  545. #define CR_WEPKEY2 CTL_REG(0x0728)
  546. #define CR_WEPKEY3 CTL_REG(0x072C)
  547. #define CR_WEPKEY4 CTL_REG(0x0730)
  548. #define CR_WEPKEY5 CTL_REG(0x0734)
  549. #define CR_WEPKEY6 CTL_REG(0x0738)
  550. #define CR_WEPKEY7 CTL_REG(0x073C)
  551. #define CR_WEPKEY8 CTL_REG(0x0740)
  552. #define CR_WEPKEY9 CTL_REG(0x0744)
  553. #define CR_WEPKEY10 CTL_REG(0x0748)
  554. #define CR_WEPKEY11 CTL_REG(0x074C)
  555. #define CR_WEPKEY12 CTL_REG(0x0750)
  556. #define CR_WEPKEY13 CTL_REG(0x0754)
  557. #define CR_WEPKEY14 CTL_REG(0x0758)
  558. #define CR_WEPKEY15 CTL_REG(0x075c)
  559. #define CR_TKIP_MODE CTL_REG(0x0760)
  560. #define CR_EEPROM_PROTECT0 CTL_REG(0x0758)
  561. #define CR_EEPROM_PROTECT1 CTL_REG(0x075C)
  562. #define CR_DBG_FIFO_RD CTL_REG(0x0800)
  563. #define CR_DBG_SELECT CTL_REG(0x0804)
  564. #define CR_FIFO_Length CTL_REG(0x0808)
  565. #define CR_RSSI_MGC CTL_REG(0x0810)
  566. #define CR_PON CTL_REG(0x0818)
  567. #define CR_RX_ON CTL_REG(0x081C)
  568. #define CR_TX_ON CTL_REG(0x0820)
  569. #define CR_CHIP_EN CTL_REG(0x0824)
  570. #define CR_LO_SW CTL_REG(0x0828)
  571. #define CR_TXRX_SW CTL_REG(0x082C)
  572. #define CR_S_MD CTL_REG(0x0830)
  573. #define CR_USB_DEBUG_PORT CTL_REG(0x0888)
  574. #define CR_ZD1211B_CWIN_MAX_MIN_AC0 CTL_REG(0x0b00)
  575. #define CR_ZD1211B_CWIN_MAX_MIN_AC1 CTL_REG(0x0b04)
  576. #define CR_ZD1211B_CWIN_MAX_MIN_AC2 CTL_REG(0x0b08)
  577. #define CR_ZD1211B_CWIN_MAX_MIN_AC3 CTL_REG(0x0b0c)
  578. #define CR_ZD1211B_AIFS_CTL1 CTL_REG(0x0b10)
  579. #define CR_ZD1211B_AIFS_CTL2 CTL_REG(0x0b14)
  580. #define CR_ZD1211B_TXOP CTL_REG(0x0b20)
  581. #define CR_ZD1211B_RETRY_MAX CTL_REG(0x0b28)
  582. /* Used to detect PLL lock */
  583. #define UW2453_INTR_REG ((zd_addr_t)0x85c1)
  584. #define CWIN_SIZE 0x007f043f
  585. #define HWINT_ENABLED 0x004f0000
  586. #define HWINT_DISABLED 0
  587. #define E2P_PWR_INT_GUARD 8
  588. #define E2P_CHANNEL_COUNT 14
  589. /* If you compare this addresses with the ZYDAS orignal driver, please notify
  590. * that we use word mapping for the EEPROM.
  591. */
  592. /*
  593. * Upper 16 bit contains the regulatory domain.
  594. */
  595. #define E2P_SUBID E2P_DATA(0x00)
  596. #define E2P_POD E2P_DATA(0x02)
  597. #define E2P_MAC_ADDR_P1 E2P_DATA(0x04)
  598. #define E2P_MAC_ADDR_P2 E2P_DATA(0x06)
  599. #define E2P_PWR_CAL_VALUE1 E2P_DATA(0x08)
  600. #define E2P_PWR_CAL_VALUE2 E2P_DATA(0x0a)
  601. #define E2P_PWR_CAL_VALUE3 E2P_DATA(0x0c)
  602. #define E2P_PWR_CAL_VALUE4 E2P_DATA(0x0e)
  603. #define E2P_PWR_INT_VALUE1 E2P_DATA(0x10)
  604. #define E2P_PWR_INT_VALUE2 E2P_DATA(0x12)
  605. #define E2P_PWR_INT_VALUE3 E2P_DATA(0x14)
  606. #define E2P_PWR_INT_VALUE4 E2P_DATA(0x16)
  607. /* Contains a bit for each allowed channel. It gives for Europe (ETSI 0x30)
  608. * also only 11 channels. */
  609. #define E2P_ALLOWED_CHANNEL E2P_DATA(0x18)
  610. #define E2P_DEVICE_VER E2P_DATA(0x20)
  611. #define E2P_PHY_REG E2P_DATA(0x25)
  612. #define E2P_36M_CAL_VALUE1 E2P_DATA(0x28)
  613. #define E2P_36M_CAL_VALUE2 E2P_DATA(0x2a)
  614. #define E2P_36M_CAL_VALUE3 E2P_DATA(0x2c)
  615. #define E2P_36M_CAL_VALUE4 E2P_DATA(0x2e)
  616. #define E2P_11A_INT_VALUE1 E2P_DATA(0x30)
  617. #define E2P_11A_INT_VALUE2 E2P_DATA(0x32)
  618. #define E2P_11A_INT_VALUE3 E2P_DATA(0x34)
  619. #define E2P_11A_INT_VALUE4 E2P_DATA(0x36)
  620. #define E2P_48M_CAL_VALUE1 E2P_DATA(0x38)
  621. #define E2P_48M_CAL_VALUE2 E2P_DATA(0x3a)
  622. #define E2P_48M_CAL_VALUE3 E2P_DATA(0x3c)
  623. #define E2P_48M_CAL_VALUE4 E2P_DATA(0x3e)
  624. #define E2P_48M_INT_VALUE1 E2P_DATA(0x40)
  625. #define E2P_48M_INT_VALUE2 E2P_DATA(0x42)
  626. #define E2P_48M_INT_VALUE3 E2P_DATA(0x44)
  627. #define E2P_48M_INT_VALUE4 E2P_DATA(0x46)
  628. #define E2P_54M_CAL_VALUE1 E2P_DATA(0x48) /* ??? */
  629. #define E2P_54M_CAL_VALUE2 E2P_DATA(0x4a)
  630. #define E2P_54M_CAL_VALUE3 E2P_DATA(0x4c)
  631. #define E2P_54M_CAL_VALUE4 E2P_DATA(0x4e)
  632. #define E2P_54M_INT_VALUE1 E2P_DATA(0x50)
  633. #define E2P_54M_INT_VALUE2 E2P_DATA(0x52)
  634. #define E2P_54M_INT_VALUE3 E2P_DATA(0x54)
  635. #define E2P_54M_INT_VALUE4 E2P_DATA(0x56)
  636. /* This word contains the base address of the FW_REG_ registers below */
  637. #define FWRAW_REGS_ADDR FWRAW_DATA(0x1d)
  638. /* All 16 bit values, offset from the address in FWRAW_REGS_ADDR */
  639. enum {
  640. FW_REG_FIRMWARE_VER = 0,
  641. /* non-zero if USB high speed connection */
  642. FW_REG_USB_SPEED = 1,
  643. FW_REG_FIX_TX_RATE = 2,
  644. /* Seems to be able to control LEDs over the firmware */
  645. FW_REG_LED_LINK_STATUS = 3,
  646. FW_REG_SOFT_RESET = 4,
  647. FW_REG_FLASH_CHK = 5,
  648. };
  649. /* Values for FW_LINK_STATUS */
  650. #define FW_LINK_OFF 0x0
  651. #define FW_LINK_TX 0x1
  652. /* 0x2 - link led on? */
  653. enum {
  654. /* indices for ofdm_cal_values */
  655. OFDM_36M_INDEX = 0,
  656. OFDM_48M_INDEX = 1,
  657. OFDM_54M_INDEX = 2,
  658. };
  659. struct zd_chip {
  660. struct zd_usb usb;
  661. struct zd_rf rf;
  662. struct mutex mutex;
  663. /* Base address of FW_REG_ registers */
  664. zd_addr_t fw_regs_base;
  665. /* EepSetPoint in the vendor driver */
  666. u8 pwr_cal_values[E2P_CHANNEL_COUNT];
  667. /* integration values in the vendor driver */
  668. u8 pwr_int_values[E2P_CHANNEL_COUNT];
  669. /* SetPointOFDM in the vendor driver */
  670. u8 ofdm_cal_values[3][E2P_CHANNEL_COUNT];
  671. u16 link_led;
  672. unsigned int pa_type:4,
  673. patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1,
  674. new_phy_layout:1, al2230s_bit:1,
  675. supports_tx_led:1;
  676. };
  677. static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb)
  678. {
  679. return container_of(usb, struct zd_chip, usb);
  680. }
  681. static inline struct zd_chip *zd_rf_to_chip(struct zd_rf *rf)
  682. {
  683. return container_of(rf, struct zd_chip, rf);
  684. }
  685. #define zd_chip_dev(chip) (&(chip)->usb.intf->dev)
  686. void zd_chip_init(struct zd_chip *chip,
  687. struct ieee80211_hw *hw,
  688. struct usb_interface *intf);
  689. void zd_chip_clear(struct zd_chip *chip);
  690. int zd_chip_read_mac_addr_fw(struct zd_chip *chip, u8 *addr);
  691. int zd_chip_init_hw(struct zd_chip *chip);
  692. int zd_chip_reset(struct zd_chip *chip);
  693. static inline int zd_chip_is_zd1211b(struct zd_chip *chip)
  694. {
  695. return chip->usb.is_zd1211b;
  696. }
  697. static inline int zd_ioread16v_locked(struct zd_chip *chip, u16 *values,
  698. const zd_addr_t *addresses,
  699. unsigned int count)
  700. {
  701. ZD_ASSERT(mutex_is_locked(&chip->mutex));
  702. return zd_usb_ioread16v(&chip->usb, values, addresses, count);
  703. }
  704. static inline int zd_ioread16_locked(struct zd_chip *chip, u16 *value,
  705. const zd_addr_t addr)
  706. {
  707. ZD_ASSERT(mutex_is_locked(&chip->mutex));
  708. return zd_usb_ioread16(&chip->usb, value, addr);
  709. }
  710. int zd_ioread32v_locked(struct zd_chip *chip, u32 *values,
  711. const zd_addr_t *addresses, unsigned int count);
  712. static inline int zd_ioread32_locked(struct zd_chip *chip, u32 *value,
  713. const zd_addr_t addr)
  714. {
  715. return zd_ioread32v_locked(chip, value, (const zd_addr_t *)&addr, 1);
  716. }
  717. static inline int zd_iowrite16_locked(struct zd_chip *chip, u16 value,
  718. zd_addr_t addr)
  719. {
  720. struct zd_ioreq16 ioreq;
  721. ZD_ASSERT(mutex_is_locked(&chip->mutex));
  722. ioreq.addr = addr;
  723. ioreq.value = value;
  724. return zd_usb_iowrite16v(&chip->usb, &ioreq, 1);
  725. }
  726. int zd_iowrite16a_locked(struct zd_chip *chip,
  727. const struct zd_ioreq16 *ioreqs, unsigned int count);
  728. int _zd_iowrite32v_locked(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
  729. unsigned int count);
  730. static inline int zd_iowrite32_locked(struct zd_chip *chip, u32 value,
  731. zd_addr_t addr)
  732. {
  733. struct zd_ioreq32 ioreq;
  734. ioreq.addr = addr;
  735. ioreq.value = value;
  736. return _zd_iowrite32v_locked(chip, &ioreq, 1);
  737. }
  738. int zd_iowrite32a_locked(struct zd_chip *chip,
  739. const struct zd_ioreq32 *ioreqs, unsigned int count);
  740. static inline int zd_rfwrite_locked(struct zd_chip *chip, u32 value, u8 bits)
  741. {
  742. ZD_ASSERT(mutex_is_locked(&chip->mutex));
  743. return zd_usb_rfwrite(&chip->usb, value, bits);
  744. }
  745. int zd_rfwrite_cr_locked(struct zd_chip *chip, u32 value);
  746. int zd_rfwritev_locked(struct zd_chip *chip,
  747. const u32* values, unsigned int count, u8 bits);
  748. int zd_rfwritev_cr_locked(struct zd_chip *chip,
  749. const u32* values, unsigned int count);
  750. /* Locking functions for reading and writing registers.
  751. * The different parameters are intentional.
  752. */
  753. int zd_ioread16(struct zd_chip *chip, zd_addr_t addr, u16 *value);
  754. int zd_iowrite16(struct zd_chip *chip, zd_addr_t addr, u16 value);
  755. int zd_ioread32(struct zd_chip *chip, zd_addr_t addr, u32 *value);
  756. int zd_iowrite32(struct zd_chip *chip, zd_addr_t addr, u32 value);
  757. int zd_ioread32v(struct zd_chip *chip, const zd_addr_t *addresses,
  758. u32 *values, unsigned int count);
  759. int zd_iowrite32a(struct zd_chip *chip, const struct zd_ioreq32 *ioreqs,
  760. unsigned int count);
  761. int zd_chip_set_channel(struct zd_chip *chip, u8 channel);
  762. static inline u8 _zd_chip_get_channel(struct zd_chip *chip)
  763. {
  764. return chip->rf.channel;
  765. }
  766. u8 zd_chip_get_channel(struct zd_chip *chip);
  767. int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain);
  768. int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr);
  769. int zd_chip_switch_radio_on(struct zd_chip *chip);
  770. int zd_chip_switch_radio_off(struct zd_chip *chip);
  771. int zd_chip_enable_int(struct zd_chip *chip);
  772. void zd_chip_disable_int(struct zd_chip *chip);
  773. int zd_chip_enable_rxtx(struct zd_chip *chip);
  774. void zd_chip_disable_rxtx(struct zd_chip *chip);
  775. int zd_chip_enable_hwint(struct zd_chip *chip);
  776. int zd_chip_disable_hwint(struct zd_chip *chip);
  777. int zd_chip_generic_patch_6m_band(struct zd_chip *chip, int channel);
  778. int zd_chip_set_rts_cts_rate_locked(struct zd_chip *chip, int preamble);
  779. static inline int zd_get_encryption_type(struct zd_chip *chip, u32 *type)
  780. {
  781. return zd_ioread32(chip, CR_ENCRYPTION_TYPE, type);
  782. }
  783. static inline int zd_set_encryption_type(struct zd_chip *chip, u32 type)
  784. {
  785. return zd_iowrite32(chip, CR_ENCRYPTION_TYPE, type);
  786. }
  787. static inline int zd_chip_get_basic_rates(struct zd_chip *chip, u16 *cr_rates)
  788. {
  789. return zd_ioread16(chip, CR_BASIC_RATE_TBL, cr_rates);
  790. }
  791. int zd_chip_set_basic_rates(struct zd_chip *chip, u16 cr_rates);
  792. int zd_chip_lock_phy_regs(struct zd_chip *chip);
  793. int zd_chip_unlock_phy_regs(struct zd_chip *chip);
  794. enum led_status {
  795. LED_OFF = 0,
  796. LED_SCANNING = 1,
  797. LED_ASSOCIATED = 2,
  798. };
  799. int zd_chip_control_leds(struct zd_chip *chip, enum led_status status);
  800. int zd_set_beacon_interval(struct zd_chip *chip, u32 interval);
  801. static inline int zd_get_beacon_interval(struct zd_chip *chip, u32 *interval)
  802. {
  803. return zd_ioread32(chip, CR_BCN_INTERVAL, interval);
  804. }
  805. struct rx_status;
  806. u8 zd_rx_qual_percent(const void *rx_frame, unsigned int size,
  807. const struct rx_status *status);
  808. u8 zd_rx_rate(const void *rx_frame, const struct rx_status *status);
  809. struct zd_mc_hash {
  810. u32 low;
  811. u32 high;
  812. };
  813. static inline void zd_mc_clear(struct zd_mc_hash *hash)
  814. {
  815. hash->low = 0;
  816. /* The interfaces must always received broadcasts.
  817. * The hash of the broadcast address ff:ff:ff:ff:ff:ff is 63.
  818. */
  819. hash->high = 0x80000000;
  820. }
  821. static inline void zd_mc_add_all(struct zd_mc_hash *hash)
  822. {
  823. hash->low = hash->high = 0xffffffff;
  824. }
  825. static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr)
  826. {
  827. unsigned int i = addr[5] >> 2;
  828. if (i < 32) {
  829. hash->low |= 1 << i;
  830. } else {
  831. hash->high |= 1 << (i-32);
  832. }
  833. }
  834. int zd_chip_set_multicast_hash(struct zd_chip *chip,
  835. struct zd_mc_hash *hash);
  836. #endif /* _ZD_CHIP_H */