sdio.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /*
  2. * Marvell Wireless LAN device driver: SDIO specific definitions
  3. *
  4. * Copyright (C) 2011-2014, Marvell International Ltd.
  5. *
  6. * This software file (the "File") is distributed by Marvell International
  7. * Ltd. under the terms of the GNU General Public License Version 2, June 1991
  8. * (the "License"). You may use, redistribute and/or modify this File in
  9. * accordance with the terms and conditions of the License, a copy of which
  10. * is available by writing to the Free Software Foundation, Inc.,
  11. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
  12. * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
  13. *
  14. * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
  16. * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
  17. * this warranty disclaimer.
  18. */
  19. #ifndef _MWIFIEX_SDIO_H
  20. #define _MWIFIEX_SDIO_H
  21. #include <linux/mmc/sdio.h>
  22. #include <linux/mmc/sdio_ids.h>
  23. #include <linux/mmc/sdio_func.h>
  24. #include <linux/mmc/card.h>
  25. #include <linux/mmc/host.h>
  26. #include "main.h"
  27. #define SD8786_DEFAULT_FW_NAME "mrvl/sd8786_uapsta.bin"
  28. #define SD8787_DEFAULT_FW_NAME "mrvl/sd8787_uapsta.bin"
  29. #define SD8797_DEFAULT_FW_NAME "mrvl/sd8797_uapsta.bin"
  30. #define SD8897_DEFAULT_FW_NAME "mrvl/sd8897_uapsta.bin"
  31. #define SD8887_DEFAULT_FW_NAME "mrvl/sd8887_uapsta.bin"
  32. #define SD8801_DEFAULT_FW_NAME "mrvl/sd8801_uapsta.bin"
  33. #define SD8997_DEFAULT_FW_NAME "mrvl/sd8997_uapsta.bin"
  34. #define BLOCK_MODE 1
  35. #define BYTE_MODE 0
  36. #define REG_PORT 0
  37. #define MWIFIEX_SDIO_IO_PORT_MASK 0xfffff
  38. #define MWIFIEX_SDIO_BYTE_MODE_MASK 0x80000000
  39. #define MWIFIEX_MAX_FUNC2_REG_NUM 13
  40. #define MWIFIEX_SDIO_SCRATCH_SIZE 10
  41. #define SDIO_MPA_ADDR_BASE 0x1000
  42. #define CTRL_PORT 0
  43. #define CTRL_PORT_MASK 0x0001
  44. #define CMD_PORT_UPLD_INT_MASK (0x1U<<6)
  45. #define CMD_PORT_DNLD_INT_MASK (0x1U<<7)
  46. #define HOST_TERM_CMD53 (0x1U << 2)
  47. #define REG_PORT 0
  48. #define MEM_PORT 0x10000
  49. #define CMD53_NEW_MODE (0x1U << 0)
  50. #define CMD_PORT_RD_LEN_EN (0x1U << 2)
  51. #define CMD_PORT_AUTO_EN (0x1U << 0)
  52. #define CMD_PORT_SLCT 0x8000
  53. #define UP_LD_CMD_PORT_HOST_INT_STATUS (0x40U)
  54. #define DN_LD_CMD_PORT_HOST_INT_STATUS (0x80U)
  55. #define MWIFIEX_MP_AGGR_BUF_SIZE_16K (16384)
  56. #define MWIFIEX_MP_AGGR_BUF_SIZE_32K (32768)
  57. /* we leave one block of 256 bytes for DMA alignment*/
  58. #define MWIFIEX_MP_AGGR_BUF_SIZE_MAX (65280)
  59. /* Misc. Config Register : Auto Re-enable interrupts */
  60. #define AUTO_RE_ENABLE_INT BIT(4)
  61. /* Host Control Registers : Configuration */
  62. #define CONFIGURATION_REG 0x00
  63. /* Host Control Registers : Host power up */
  64. #define HOST_POWER_UP (0x1U << 1)
  65. /* Host Control Registers : Upload host interrupt mask */
  66. #define UP_LD_HOST_INT_MASK (0x1U)
  67. /* Host Control Registers : Download host interrupt mask */
  68. #define DN_LD_HOST_INT_MASK (0x2U)
  69. /* Host Control Registers : Upload host interrupt status */
  70. #define UP_LD_HOST_INT_STATUS (0x1U)
  71. /* Host Control Registers : Download host interrupt status */
  72. #define DN_LD_HOST_INT_STATUS (0x2U)
  73. /* Host Control Registers : Host interrupt status */
  74. #define CARD_INT_STATUS_REG 0x28
  75. /* Card Control Registers : Card I/O ready */
  76. #define CARD_IO_READY (0x1U << 3)
  77. /* Card Control Registers : Download card ready */
  78. #define DN_LD_CARD_RDY (0x1U << 0)
  79. /* Max retry number of CMD53 write */
  80. #define MAX_WRITE_IOMEM_RETRY 2
  81. /* SDIO Tx aggregation in progress ? */
  82. #define MP_TX_AGGR_IN_PROGRESS(a) (a->mpa_tx.pkt_cnt > 0)
  83. /* SDIO Tx aggregation buffer room for next packet ? */
  84. #define MP_TX_AGGR_BUF_HAS_ROOM(a, len) ((a->mpa_tx.buf_len+len) \
  85. <= a->mpa_tx.buf_size)
  86. /* Copy current packet (SDIO Tx aggregation buffer) to SDIO buffer */
  87. #define MP_TX_AGGR_BUF_PUT(a, payload, pkt_len, port) do { \
  88. memmove(&a->mpa_tx.buf[a->mpa_tx.buf_len], \
  89. payload, pkt_len); \
  90. a->mpa_tx.buf_len += pkt_len; \
  91. if (!a->mpa_tx.pkt_cnt) \
  92. a->mpa_tx.start_port = port; \
  93. if (a->mpa_tx.start_port <= port) \
  94. a->mpa_tx.ports |= (1<<(a->mpa_tx.pkt_cnt)); \
  95. else \
  96. a->mpa_tx.ports |= (1<<(a->mpa_tx.pkt_cnt+1+ \
  97. (a->max_ports - \
  98. a->mp_end_port))); \
  99. a->mpa_tx.pkt_cnt++; \
  100. } while (0)
  101. /* SDIO Tx aggregation limit ? */
  102. #define MP_TX_AGGR_PKT_LIMIT_REACHED(a) \
  103. (a->mpa_tx.pkt_cnt == a->mpa_tx.pkt_aggr_limit)
  104. /* Reset SDIO Tx aggregation buffer parameters */
  105. #define MP_TX_AGGR_BUF_RESET(a) do { \
  106. a->mpa_tx.pkt_cnt = 0; \
  107. a->mpa_tx.buf_len = 0; \
  108. a->mpa_tx.ports = 0; \
  109. a->mpa_tx.start_port = 0; \
  110. } while (0)
  111. /* SDIO Rx aggregation limit ? */
  112. #define MP_RX_AGGR_PKT_LIMIT_REACHED(a) \
  113. (a->mpa_rx.pkt_cnt == a->mpa_rx.pkt_aggr_limit)
  114. /* SDIO Rx aggregation in progress ? */
  115. #define MP_RX_AGGR_IN_PROGRESS(a) (a->mpa_rx.pkt_cnt > 0)
  116. /* SDIO Rx aggregation buffer room for next packet ? */
  117. #define MP_RX_AGGR_BUF_HAS_ROOM(a, rx_len) \
  118. ((a->mpa_rx.buf_len+rx_len) <= a->mpa_rx.buf_size)
  119. /* Reset SDIO Rx aggregation buffer parameters */
  120. #define MP_RX_AGGR_BUF_RESET(a) do { \
  121. a->mpa_rx.pkt_cnt = 0; \
  122. a->mpa_rx.buf_len = 0; \
  123. a->mpa_rx.ports = 0; \
  124. a->mpa_rx.start_port = 0; \
  125. } while (0)
  126. /* data structure for SDIO MPA TX */
  127. struct mwifiex_sdio_mpa_tx {
  128. /* multiport tx aggregation buffer pointer */
  129. u8 *buf;
  130. u32 buf_len;
  131. u32 pkt_cnt;
  132. u32 ports;
  133. u16 start_port;
  134. u8 enabled;
  135. u32 buf_size;
  136. u32 pkt_aggr_limit;
  137. };
  138. struct mwifiex_sdio_mpa_rx {
  139. u8 *buf;
  140. u32 buf_len;
  141. u32 pkt_cnt;
  142. u32 ports;
  143. u16 start_port;
  144. struct sk_buff **skb_arr;
  145. u32 *len_arr;
  146. u8 enabled;
  147. u32 buf_size;
  148. u32 pkt_aggr_limit;
  149. };
  150. int mwifiex_bus_register(void);
  151. void mwifiex_bus_unregister(void);
  152. struct mwifiex_sdio_card_reg {
  153. u8 start_rd_port;
  154. u8 start_wr_port;
  155. u8 base_0_reg;
  156. u8 base_1_reg;
  157. u8 poll_reg;
  158. u8 host_int_enable;
  159. u8 host_int_rsr_reg;
  160. u8 host_int_status_reg;
  161. u8 host_int_mask_reg;
  162. u8 status_reg_0;
  163. u8 status_reg_1;
  164. u8 sdio_int_mask;
  165. u32 data_port_mask;
  166. u8 io_port_0_reg;
  167. u8 io_port_1_reg;
  168. u8 io_port_2_reg;
  169. u8 max_mp_regs;
  170. u8 rd_bitmap_l;
  171. u8 rd_bitmap_u;
  172. u8 rd_bitmap_1l;
  173. u8 rd_bitmap_1u;
  174. u8 wr_bitmap_l;
  175. u8 wr_bitmap_u;
  176. u8 wr_bitmap_1l;
  177. u8 wr_bitmap_1u;
  178. u8 rd_len_p0_l;
  179. u8 rd_len_p0_u;
  180. u8 card_misc_cfg_reg;
  181. u8 card_cfg_2_1_reg;
  182. u8 cmd_rd_len_0;
  183. u8 cmd_rd_len_1;
  184. u8 cmd_rd_len_2;
  185. u8 cmd_rd_len_3;
  186. u8 cmd_cfg_0;
  187. u8 cmd_cfg_1;
  188. u8 cmd_cfg_2;
  189. u8 cmd_cfg_3;
  190. u8 fw_dump_host_ready;
  191. u8 fw_dump_ctrl;
  192. u8 fw_dump_start;
  193. u8 fw_dump_end;
  194. u8 func1_dump_reg_start;
  195. u8 func1_dump_reg_end;
  196. u8 func1_scratch_reg;
  197. u8 func1_spec_reg_num;
  198. u8 func1_spec_reg_table[MWIFIEX_MAX_FUNC2_REG_NUM];
  199. };
  200. struct sdio_mmc_card {
  201. struct sdio_func *func;
  202. struct mwifiex_adapter *adapter;
  203. const char *firmware;
  204. const struct mwifiex_sdio_card_reg *reg;
  205. u8 max_ports;
  206. u8 mp_agg_pkt_limit;
  207. u16 tx_buf_size;
  208. u32 mp_tx_agg_buf_size;
  209. u32 mp_rx_agg_buf_size;
  210. u32 mp_rd_bitmap;
  211. u32 mp_wr_bitmap;
  212. u16 mp_end_port;
  213. u32 mp_data_port_mask;
  214. u8 curr_rd_port;
  215. u8 curr_wr_port;
  216. u8 *mp_regs;
  217. bool supports_sdio_new_mode;
  218. bool has_control_mask;
  219. bool can_dump_fw;
  220. bool fw_dump_enh;
  221. bool can_auto_tdls;
  222. bool can_ext_scan;
  223. struct mwifiex_sdio_mpa_tx mpa_tx;
  224. struct mwifiex_sdio_mpa_rx mpa_rx;
  225. /* needed for card reset */
  226. const struct sdio_device_id *device_id;
  227. };
  228. struct mwifiex_sdio_device {
  229. const char *firmware;
  230. const struct mwifiex_sdio_card_reg *reg;
  231. u8 max_ports;
  232. u8 mp_agg_pkt_limit;
  233. u16 tx_buf_size;
  234. u32 mp_tx_agg_buf_size;
  235. u32 mp_rx_agg_buf_size;
  236. bool supports_sdio_new_mode;
  237. bool has_control_mask;
  238. bool can_dump_fw;
  239. bool fw_dump_enh;
  240. bool can_auto_tdls;
  241. bool can_ext_scan;
  242. };
  243. static const struct mwifiex_sdio_card_reg mwifiex_reg_sd87xx = {
  244. .start_rd_port = 1,
  245. .start_wr_port = 1,
  246. .base_0_reg = 0x0040,
  247. .base_1_reg = 0x0041,
  248. .poll_reg = 0x30,
  249. .host_int_enable = UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK,
  250. .host_int_rsr_reg = 0x1,
  251. .host_int_mask_reg = 0x02,
  252. .host_int_status_reg = 0x03,
  253. .status_reg_0 = 0x60,
  254. .status_reg_1 = 0x61,
  255. .sdio_int_mask = 0x3f,
  256. .data_port_mask = 0x0000fffe,
  257. .io_port_0_reg = 0x78,
  258. .io_port_1_reg = 0x79,
  259. .io_port_2_reg = 0x7A,
  260. .max_mp_regs = 64,
  261. .rd_bitmap_l = 0x04,
  262. .rd_bitmap_u = 0x05,
  263. .wr_bitmap_l = 0x06,
  264. .wr_bitmap_u = 0x07,
  265. .rd_len_p0_l = 0x08,
  266. .rd_len_p0_u = 0x09,
  267. .card_misc_cfg_reg = 0x6c,
  268. .func1_dump_reg_start = 0x0,
  269. .func1_dump_reg_end = 0x9,
  270. .func1_scratch_reg = 0x60,
  271. .func1_spec_reg_num = 5,
  272. .func1_spec_reg_table = {0x28, 0x30, 0x34, 0x38, 0x3c},
  273. };
  274. static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8897 = {
  275. .start_rd_port = 0,
  276. .start_wr_port = 0,
  277. .base_0_reg = 0x60,
  278. .base_1_reg = 0x61,
  279. .poll_reg = 0x50,
  280. .host_int_enable = UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK |
  281. CMD_PORT_UPLD_INT_MASK | CMD_PORT_DNLD_INT_MASK,
  282. .host_int_rsr_reg = 0x1,
  283. .host_int_status_reg = 0x03,
  284. .host_int_mask_reg = 0x02,
  285. .status_reg_0 = 0xc0,
  286. .status_reg_1 = 0xc1,
  287. .sdio_int_mask = 0xff,
  288. .data_port_mask = 0xffffffff,
  289. .io_port_0_reg = 0xD8,
  290. .io_port_1_reg = 0xD9,
  291. .io_port_2_reg = 0xDA,
  292. .max_mp_regs = 184,
  293. .rd_bitmap_l = 0x04,
  294. .rd_bitmap_u = 0x05,
  295. .rd_bitmap_1l = 0x06,
  296. .rd_bitmap_1u = 0x07,
  297. .wr_bitmap_l = 0x08,
  298. .wr_bitmap_u = 0x09,
  299. .wr_bitmap_1l = 0x0a,
  300. .wr_bitmap_1u = 0x0b,
  301. .rd_len_p0_l = 0x0c,
  302. .rd_len_p0_u = 0x0d,
  303. .card_misc_cfg_reg = 0xcc,
  304. .card_cfg_2_1_reg = 0xcd,
  305. .cmd_rd_len_0 = 0xb4,
  306. .cmd_rd_len_1 = 0xb5,
  307. .cmd_rd_len_2 = 0xb6,
  308. .cmd_rd_len_3 = 0xb7,
  309. .cmd_cfg_0 = 0xb8,
  310. .cmd_cfg_1 = 0xb9,
  311. .cmd_cfg_2 = 0xba,
  312. .cmd_cfg_3 = 0xbb,
  313. .fw_dump_host_ready = 0xee,
  314. .fw_dump_ctrl = 0xe2,
  315. .fw_dump_start = 0xe3,
  316. .fw_dump_end = 0xea,
  317. .func1_dump_reg_start = 0x0,
  318. .func1_dump_reg_end = 0xb,
  319. .func1_scratch_reg = 0xc0,
  320. .func1_spec_reg_num = 8,
  321. .func1_spec_reg_table = {0x4C, 0x50, 0x54, 0x55, 0x58,
  322. 0x59, 0x5c, 0x5d},
  323. };
  324. static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8997 = {
  325. .start_rd_port = 0,
  326. .start_wr_port = 0,
  327. .base_0_reg = 0xF8,
  328. .base_1_reg = 0xF9,
  329. .poll_reg = 0x5C,
  330. .host_int_enable = UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK |
  331. CMD_PORT_UPLD_INT_MASK | CMD_PORT_DNLD_INT_MASK,
  332. .host_int_rsr_reg = 0x4,
  333. .host_int_status_reg = 0x0C,
  334. .host_int_mask_reg = 0x08,
  335. .status_reg_0 = 0xE8,
  336. .status_reg_1 = 0xE9,
  337. .sdio_int_mask = 0xff,
  338. .data_port_mask = 0xffffffff,
  339. .io_port_0_reg = 0xE4,
  340. .io_port_1_reg = 0xE5,
  341. .io_port_2_reg = 0xE6,
  342. .max_mp_regs = 196,
  343. .rd_bitmap_l = 0x10,
  344. .rd_bitmap_u = 0x11,
  345. .rd_bitmap_1l = 0x12,
  346. .rd_bitmap_1u = 0x13,
  347. .wr_bitmap_l = 0x14,
  348. .wr_bitmap_u = 0x15,
  349. .wr_bitmap_1l = 0x16,
  350. .wr_bitmap_1u = 0x17,
  351. .rd_len_p0_l = 0x18,
  352. .rd_len_p0_u = 0x19,
  353. .card_misc_cfg_reg = 0xd8,
  354. .card_cfg_2_1_reg = 0xd9,
  355. .cmd_rd_len_0 = 0xc0,
  356. .cmd_rd_len_1 = 0xc1,
  357. .cmd_rd_len_2 = 0xc2,
  358. .cmd_rd_len_3 = 0xc3,
  359. .cmd_cfg_0 = 0xc4,
  360. .cmd_cfg_1 = 0xc5,
  361. .cmd_cfg_2 = 0xc6,
  362. .cmd_cfg_3 = 0xc7,
  363. .fw_dump_host_ready = 0xcc,
  364. .fw_dump_ctrl = 0xf0,
  365. .fw_dump_start = 0xf1,
  366. .fw_dump_end = 0xf8,
  367. .func1_dump_reg_start = 0x10,
  368. .func1_dump_reg_end = 0x17,
  369. .func1_scratch_reg = 0xe8,
  370. .func1_spec_reg_num = 13,
  371. .func1_spec_reg_table = {0x08, 0x58, 0x5C, 0x5D,
  372. 0x60, 0x61, 0x62, 0x64,
  373. 0x65, 0x66, 0x68, 0x69,
  374. 0x6a},
  375. };
  376. static const struct mwifiex_sdio_card_reg mwifiex_reg_sd8887 = {
  377. .start_rd_port = 0,
  378. .start_wr_port = 0,
  379. .base_0_reg = 0x6C,
  380. .base_1_reg = 0x6D,
  381. .poll_reg = 0x5C,
  382. .host_int_enable = UP_LD_HOST_INT_MASK | DN_LD_HOST_INT_MASK |
  383. CMD_PORT_UPLD_INT_MASK | CMD_PORT_DNLD_INT_MASK,
  384. .host_int_rsr_reg = 0x4,
  385. .host_int_status_reg = 0x0C,
  386. .host_int_mask_reg = 0x08,
  387. .status_reg_0 = 0x90,
  388. .status_reg_1 = 0x91,
  389. .sdio_int_mask = 0xff,
  390. .data_port_mask = 0xffffffff,
  391. .io_port_0_reg = 0xE4,
  392. .io_port_1_reg = 0xE5,
  393. .io_port_2_reg = 0xE6,
  394. .max_mp_regs = 196,
  395. .rd_bitmap_l = 0x10,
  396. .rd_bitmap_u = 0x11,
  397. .rd_bitmap_1l = 0x12,
  398. .rd_bitmap_1u = 0x13,
  399. .wr_bitmap_l = 0x14,
  400. .wr_bitmap_u = 0x15,
  401. .wr_bitmap_1l = 0x16,
  402. .wr_bitmap_1u = 0x17,
  403. .rd_len_p0_l = 0x18,
  404. .rd_len_p0_u = 0x19,
  405. .card_misc_cfg_reg = 0xd8,
  406. .card_cfg_2_1_reg = 0xd9,
  407. .cmd_rd_len_0 = 0xc0,
  408. .cmd_rd_len_1 = 0xc1,
  409. .cmd_rd_len_2 = 0xc2,
  410. .cmd_rd_len_3 = 0xc3,
  411. .cmd_cfg_0 = 0xc4,
  412. .cmd_cfg_1 = 0xc5,
  413. .cmd_cfg_2 = 0xc6,
  414. .cmd_cfg_3 = 0xc7,
  415. .func1_dump_reg_start = 0x10,
  416. .func1_dump_reg_end = 0x17,
  417. .func1_scratch_reg = 0x90,
  418. .func1_spec_reg_num = 13,
  419. .func1_spec_reg_table = {0x08, 0x58, 0x5C, 0x5D, 0x60,
  420. 0x61, 0x62, 0x64, 0x65, 0x66,
  421. 0x68, 0x69, 0x6a},
  422. };
  423. static const struct mwifiex_sdio_device mwifiex_sdio_sd8786 = {
  424. .firmware = SD8786_DEFAULT_FW_NAME,
  425. .reg = &mwifiex_reg_sd87xx,
  426. .max_ports = 16,
  427. .mp_agg_pkt_limit = 8,
  428. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
  429. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  430. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  431. .supports_sdio_new_mode = false,
  432. .has_control_mask = true,
  433. .can_dump_fw = false,
  434. .can_auto_tdls = false,
  435. .can_ext_scan = false,
  436. };
  437. static const struct mwifiex_sdio_device mwifiex_sdio_sd8787 = {
  438. .firmware = SD8787_DEFAULT_FW_NAME,
  439. .reg = &mwifiex_reg_sd87xx,
  440. .max_ports = 16,
  441. .mp_agg_pkt_limit = 8,
  442. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
  443. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  444. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  445. .supports_sdio_new_mode = false,
  446. .has_control_mask = true,
  447. .can_dump_fw = false,
  448. .can_auto_tdls = false,
  449. .can_ext_scan = true,
  450. };
  451. static const struct mwifiex_sdio_device mwifiex_sdio_sd8797 = {
  452. .firmware = SD8797_DEFAULT_FW_NAME,
  453. .reg = &mwifiex_reg_sd87xx,
  454. .max_ports = 16,
  455. .mp_agg_pkt_limit = 8,
  456. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
  457. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  458. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  459. .supports_sdio_new_mode = false,
  460. .has_control_mask = true,
  461. .can_dump_fw = false,
  462. .can_auto_tdls = false,
  463. .can_ext_scan = true,
  464. };
  465. static const struct mwifiex_sdio_device mwifiex_sdio_sd8897 = {
  466. .firmware = SD8897_DEFAULT_FW_NAME,
  467. .reg = &mwifiex_reg_sd8897,
  468. .max_ports = 32,
  469. .mp_agg_pkt_limit = 16,
  470. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K,
  471. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
  472. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
  473. .supports_sdio_new_mode = true,
  474. .has_control_mask = false,
  475. .can_dump_fw = true,
  476. .can_auto_tdls = false,
  477. .can_ext_scan = true,
  478. };
  479. static const struct mwifiex_sdio_device mwifiex_sdio_sd8997 = {
  480. .firmware = SD8997_DEFAULT_FW_NAME,
  481. .reg = &mwifiex_reg_sd8997,
  482. .max_ports = 32,
  483. .mp_agg_pkt_limit = 16,
  484. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_4K,
  485. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
  486. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_MAX,
  487. .supports_sdio_new_mode = true,
  488. .has_control_mask = false,
  489. .can_dump_fw = true,
  490. .fw_dump_enh = true,
  491. .can_auto_tdls = false,
  492. .can_ext_scan = true,
  493. };
  494. static const struct mwifiex_sdio_device mwifiex_sdio_sd8887 = {
  495. .firmware = SD8887_DEFAULT_FW_NAME,
  496. .reg = &mwifiex_reg_sd8887,
  497. .max_ports = 32,
  498. .mp_agg_pkt_limit = 16,
  499. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
  500. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K,
  501. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_32K,
  502. .supports_sdio_new_mode = true,
  503. .has_control_mask = false,
  504. .can_dump_fw = false,
  505. .can_auto_tdls = true,
  506. .can_ext_scan = true,
  507. };
  508. static const struct mwifiex_sdio_device mwifiex_sdio_sd8801 = {
  509. .firmware = SD8801_DEFAULT_FW_NAME,
  510. .reg = &mwifiex_reg_sd87xx,
  511. .max_ports = 16,
  512. .mp_agg_pkt_limit = 8,
  513. .supports_sdio_new_mode = false,
  514. .has_control_mask = true,
  515. .tx_buf_size = MWIFIEX_TX_DATA_BUF_SIZE_2K,
  516. .mp_tx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  517. .mp_rx_agg_buf_size = MWIFIEX_MP_AGGR_BUF_SIZE_16K,
  518. .can_dump_fw = false,
  519. .can_auto_tdls = false,
  520. .can_ext_scan = true,
  521. };
  522. /*
  523. * .cmdrsp_complete handler
  524. */
  525. static inline int mwifiex_sdio_cmdrsp_complete(struct mwifiex_adapter *adapter,
  526. struct sk_buff *skb)
  527. {
  528. dev_kfree_skb_any(skb);
  529. return 0;
  530. }
  531. /*
  532. * .event_complete handler
  533. */
  534. static inline int mwifiex_sdio_event_complete(struct mwifiex_adapter *adapter,
  535. struct sk_buff *skb)
  536. {
  537. dev_kfree_skb_any(skb);
  538. return 0;
  539. }
  540. static inline bool
  541. mp_rx_aggr_port_limit_reached(struct sdio_mmc_card *card)
  542. {
  543. u8 tmp;
  544. if (card->curr_rd_port < card->mpa_rx.start_port) {
  545. if (card->supports_sdio_new_mode)
  546. tmp = card->mp_end_port >> 1;
  547. else
  548. tmp = card->mp_agg_pkt_limit;
  549. if (((card->max_ports - card->mpa_rx.start_port) +
  550. card->curr_rd_port) >= tmp)
  551. return true;
  552. }
  553. if (!card->supports_sdio_new_mode)
  554. return false;
  555. if ((card->curr_rd_port - card->mpa_rx.start_port) >=
  556. (card->mp_end_port >> 1))
  557. return true;
  558. return false;
  559. }
  560. static inline bool
  561. mp_tx_aggr_port_limit_reached(struct sdio_mmc_card *card)
  562. {
  563. u16 tmp;
  564. if (card->curr_wr_port < card->mpa_tx.start_port) {
  565. if (card->supports_sdio_new_mode)
  566. tmp = card->mp_end_port >> 1;
  567. else
  568. tmp = card->mp_agg_pkt_limit;
  569. if (((card->max_ports - card->mpa_tx.start_port) +
  570. card->curr_wr_port) >= tmp)
  571. return true;
  572. }
  573. if (!card->supports_sdio_new_mode)
  574. return false;
  575. if ((card->curr_wr_port - card->mpa_tx.start_port) >=
  576. (card->mp_end_port >> 1))
  577. return true;
  578. return false;
  579. }
  580. /* Prepare to copy current packet from card to SDIO Rx aggregation buffer */
  581. static inline void mp_rx_aggr_setup(struct sdio_mmc_card *card,
  582. u16 rx_len, u8 port)
  583. {
  584. card->mpa_rx.buf_len += rx_len;
  585. if (!card->mpa_rx.pkt_cnt)
  586. card->mpa_rx.start_port = port;
  587. if (card->supports_sdio_new_mode) {
  588. card->mpa_rx.ports |= (1 << port);
  589. } else {
  590. if (card->mpa_rx.start_port <= port)
  591. card->mpa_rx.ports |= 1 << (card->mpa_rx.pkt_cnt);
  592. else
  593. card->mpa_rx.ports |= 1 << (card->mpa_rx.pkt_cnt + 1);
  594. }
  595. card->mpa_rx.skb_arr[card->mpa_rx.pkt_cnt] = NULL;
  596. card->mpa_rx.len_arr[card->mpa_rx.pkt_cnt] = rx_len;
  597. card->mpa_rx.pkt_cnt++;
  598. }
  599. #endif /* _MWIFIEX_SDIO_H */