sdio.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852
  1. /*
  2. * Marvell Wireless LAN device driver: SDIO specific handling
  3. *
  4. * Copyright (C) 2011, 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. #include <linux/firmware.h>
  20. #include "decl.h"
  21. #include "ioctl.h"
  22. #include "util.h"
  23. #include "fw.h"
  24. #include "main.h"
  25. #include "wmm.h"
  26. #include "11n.h"
  27. #include "sdio.h"
  28. #define SDIO_VERSION "1.0"
  29. /* The mwifiex_sdio_remove() callback function is called when
  30. * user removes this module from kernel space or ejects
  31. * the card from the slot. The driver handles these 2 cases
  32. * differently.
  33. * If the user is removing the module, the few commands (FUNC_SHUTDOWN,
  34. * HS_CANCEL etc.) are sent to the firmware.
  35. * If the card is removed, there is no need to send these command.
  36. *
  37. * The variable 'user_rmmod' is used to distinguish these two
  38. * scenarios. This flag is initialized as FALSE in case the card
  39. * is removed, and will be set to TRUE for module removal when
  40. * module_exit function is called.
  41. */
  42. static u8 user_rmmod;
  43. static struct mwifiex_if_ops sdio_ops;
  44. static struct semaphore add_remove_card_sem;
  45. static int mwifiex_sdio_resume(struct device *dev);
  46. /*
  47. * SDIO probe.
  48. *
  49. * This function probes an mwifiex device and registers it. It allocates
  50. * the card structure, enables SDIO function number and initiates the
  51. * device registration and initialization procedure by adding a logical
  52. * interface.
  53. */
  54. static int
  55. mwifiex_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
  56. {
  57. int ret;
  58. struct sdio_mmc_card *card = NULL;
  59. pr_debug("info: vendor=0x%4.04X device=0x%4.04X class=%d function=%d\n",
  60. func->vendor, func->device, func->class, func->num);
  61. card = kzalloc(sizeof(struct sdio_mmc_card), GFP_KERNEL);
  62. if (!card)
  63. return -ENOMEM;
  64. card->func = func;
  65. func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
  66. sdio_claim_host(func);
  67. ret = sdio_enable_func(func);
  68. sdio_release_host(func);
  69. if (ret) {
  70. pr_err("%s: failed to enable function\n", __func__);
  71. kfree(card);
  72. return -EIO;
  73. }
  74. if (mwifiex_add_card(card, &add_remove_card_sem, &sdio_ops,
  75. MWIFIEX_SDIO)) {
  76. pr_err("%s: add card failed\n", __func__);
  77. kfree(card);
  78. sdio_claim_host(func);
  79. ret = sdio_disable_func(func);
  80. sdio_release_host(func);
  81. ret = -1;
  82. }
  83. return ret;
  84. }
  85. /*
  86. * SDIO remove.
  87. *
  88. * This function removes the interface and frees up the card structure.
  89. */
  90. static void
  91. mwifiex_sdio_remove(struct sdio_func *func)
  92. {
  93. struct sdio_mmc_card *card;
  94. struct mwifiex_adapter *adapter;
  95. struct mwifiex_private *priv;
  96. int i;
  97. pr_debug("info: SDIO func num=%d\n", func->num);
  98. card = sdio_get_drvdata(func);
  99. if (!card)
  100. return;
  101. adapter = card->adapter;
  102. if (!adapter || !adapter->priv_num)
  103. return;
  104. /* In case driver is removed when asynchronous FW load is in progress */
  105. wait_for_completion(&adapter->fw_load);
  106. if (user_rmmod) {
  107. if (adapter->is_suspended)
  108. mwifiex_sdio_resume(adapter->dev);
  109. for (i = 0; i < adapter->priv_num; i++)
  110. if ((GET_BSS_ROLE(adapter->priv[i]) ==
  111. MWIFIEX_BSS_ROLE_STA) &&
  112. adapter->priv[i]->media_connected)
  113. mwifiex_deauthenticate(adapter->priv[i], NULL);
  114. priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
  115. mwifiex_disable_auto_ds(priv);
  116. mwifiex_init_shutdown_fw(priv, MWIFIEX_FUNC_SHUTDOWN);
  117. }
  118. mwifiex_remove_card(card->adapter, &add_remove_card_sem);
  119. kfree(card);
  120. }
  121. /*
  122. * SDIO suspend.
  123. *
  124. * Kernel needs to suspend all functions separately. Therefore all
  125. * registered functions must have drivers with suspend and resume
  126. * methods. Failing that the kernel simply removes the whole card.
  127. *
  128. * If already not suspended, this function allocates and sends a host
  129. * sleep activate request to the firmware and turns off the traffic.
  130. */
  131. static int mwifiex_sdio_suspend(struct device *dev)
  132. {
  133. struct sdio_func *func = dev_to_sdio_func(dev);
  134. struct sdio_mmc_card *card;
  135. struct mwifiex_adapter *adapter;
  136. mmc_pm_flag_t pm_flag = 0;
  137. int i;
  138. int ret = 0;
  139. if (func) {
  140. pm_flag = sdio_get_host_pm_caps(func);
  141. pr_debug("cmd: %s: suspend: PM flag = 0x%x\n",
  142. sdio_func_id(func), pm_flag);
  143. if (!(pm_flag & MMC_PM_KEEP_POWER)) {
  144. pr_err("%s: cannot remain alive while host is"
  145. " suspended\n", sdio_func_id(func));
  146. return -ENOSYS;
  147. }
  148. card = sdio_get_drvdata(func);
  149. if (!card || !card->adapter) {
  150. pr_err("suspend: invalid card or adapter\n");
  151. return 0;
  152. }
  153. } else {
  154. pr_err("suspend: sdio_func is not specified\n");
  155. return 0;
  156. }
  157. adapter = card->adapter;
  158. /* Enable the Host Sleep */
  159. if (!mwifiex_enable_hs(adapter)) {
  160. dev_err(adapter->dev, "cmd: failed to suspend\n");
  161. return -EFAULT;
  162. }
  163. dev_dbg(adapter->dev, "cmd: suspend with MMC_PM_KEEP_POWER\n");
  164. ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
  165. /* Indicate device suspended */
  166. adapter->is_suspended = true;
  167. for (i = 0; i < adapter->priv_num; i++)
  168. netif_carrier_off(adapter->priv[i]->netdev);
  169. return ret;
  170. }
  171. /*
  172. * SDIO resume.
  173. *
  174. * Kernel needs to suspend all functions separately. Therefore all
  175. * registered functions must have drivers with suspend and resume
  176. * methods. Failing that the kernel simply removes the whole card.
  177. *
  178. * If already not resumed, this function turns on the traffic and
  179. * sends a host sleep cancel request to the firmware.
  180. */
  181. static int mwifiex_sdio_resume(struct device *dev)
  182. {
  183. struct sdio_func *func = dev_to_sdio_func(dev);
  184. struct sdio_mmc_card *card;
  185. struct mwifiex_adapter *adapter;
  186. mmc_pm_flag_t pm_flag = 0;
  187. int i;
  188. if (func) {
  189. pm_flag = sdio_get_host_pm_caps(func);
  190. card = sdio_get_drvdata(func);
  191. if (!card || !card->adapter) {
  192. pr_err("resume: invalid card or adapter\n");
  193. return 0;
  194. }
  195. } else {
  196. pr_err("resume: sdio_func is not specified\n");
  197. return 0;
  198. }
  199. adapter = card->adapter;
  200. if (!adapter->is_suspended) {
  201. dev_warn(adapter->dev, "device already resumed\n");
  202. return 0;
  203. }
  204. adapter->is_suspended = false;
  205. for (i = 0; i < adapter->priv_num; i++)
  206. if (adapter->priv[i]->media_connected)
  207. netif_carrier_on(adapter->priv[i]->netdev);
  208. /* Disable Host Sleep */
  209. mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
  210. MWIFIEX_ASYNC_CMD);
  211. return 0;
  212. }
  213. /* Device ID for SD8786 */
  214. #define SDIO_DEVICE_ID_MARVELL_8786 (0x9116)
  215. /* Device ID for SD8787 */
  216. #define SDIO_DEVICE_ID_MARVELL_8787 (0x9119)
  217. /* Device ID for SD8797 */
  218. #define SDIO_DEVICE_ID_MARVELL_8797 (0x9129)
  219. /* WLAN IDs */
  220. static const struct sdio_device_id mwifiex_ids[] = {
  221. {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8786)},
  222. {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8787)},
  223. {SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_8797)},
  224. {},
  225. };
  226. MODULE_DEVICE_TABLE(sdio, mwifiex_ids);
  227. static const struct dev_pm_ops mwifiex_sdio_pm_ops = {
  228. .suspend = mwifiex_sdio_suspend,
  229. .resume = mwifiex_sdio_resume,
  230. };
  231. static struct sdio_driver mwifiex_sdio = {
  232. .name = "mwifiex_sdio",
  233. .id_table = mwifiex_ids,
  234. .probe = mwifiex_sdio_probe,
  235. .remove = mwifiex_sdio_remove,
  236. .drv = {
  237. .owner = THIS_MODULE,
  238. .pm = &mwifiex_sdio_pm_ops,
  239. }
  240. };
  241. /*
  242. * This function writes data into SDIO card register.
  243. */
  244. static int
  245. mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u32 data)
  246. {
  247. struct sdio_mmc_card *card = adapter->card;
  248. int ret = -1;
  249. sdio_claim_host(card->func);
  250. sdio_writeb(card->func, (u8) data, reg, &ret);
  251. sdio_release_host(card->func);
  252. return ret;
  253. }
  254. /*
  255. * This function reads data from SDIO card register.
  256. */
  257. static int
  258. mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u32 *data)
  259. {
  260. struct sdio_mmc_card *card = adapter->card;
  261. int ret = -1;
  262. u8 val;
  263. sdio_claim_host(card->func);
  264. val = sdio_readb(card->func, reg, &ret);
  265. sdio_release_host(card->func);
  266. *data = val;
  267. return ret;
  268. }
  269. /*
  270. * This function writes multiple data into SDIO card memory.
  271. *
  272. * This does not work in suspended mode.
  273. */
  274. static int
  275. mwifiex_write_data_sync(struct mwifiex_adapter *adapter,
  276. u8 *buffer, u32 pkt_len, u32 port)
  277. {
  278. struct sdio_mmc_card *card = adapter->card;
  279. int ret = -1;
  280. u8 blk_mode =
  281. (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE;
  282. u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1;
  283. u32 blk_cnt =
  284. (blk_mode ==
  285. BLOCK_MODE) ? (pkt_len /
  286. MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len;
  287. u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK);
  288. if (adapter->is_suspended) {
  289. dev_err(adapter->dev,
  290. "%s: not allowed while suspended\n", __func__);
  291. return -1;
  292. }
  293. sdio_claim_host(card->func);
  294. if (!sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size))
  295. ret = 0;
  296. sdio_release_host(card->func);
  297. return ret;
  298. }
  299. /*
  300. * This function reads multiple data from SDIO card memory.
  301. */
  302. static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *buffer,
  303. u32 len, u32 port, u8 claim)
  304. {
  305. struct sdio_mmc_card *card = adapter->card;
  306. int ret = -1;
  307. u8 blk_mode = (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE
  308. : BLOCK_MODE;
  309. u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1;
  310. u32 blk_cnt = (blk_mode == BLOCK_MODE) ? (len / MWIFIEX_SDIO_BLOCK_SIZE)
  311. : len;
  312. u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK);
  313. if (claim)
  314. sdio_claim_host(card->func);
  315. if (!sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size))
  316. ret = 0;
  317. if (claim)
  318. sdio_release_host(card->func);
  319. return ret;
  320. }
  321. /*
  322. * This function wakes up the card.
  323. *
  324. * A host power up command is written to the card configuration
  325. * register to wake up the card.
  326. */
  327. static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter)
  328. {
  329. dev_dbg(adapter->dev, "event: wakeup device...\n");
  330. return mwifiex_write_reg(adapter, CONFIGURATION_REG, HOST_POWER_UP);
  331. }
  332. /*
  333. * This function is called after the card has woken up.
  334. *
  335. * The card configuration register is reset.
  336. */
  337. static int mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter)
  338. {
  339. dev_dbg(adapter->dev, "cmd: wakeup device completed\n");
  340. return mwifiex_write_reg(adapter, CONFIGURATION_REG, 0);
  341. }
  342. /*
  343. * This function initializes the IO ports.
  344. *
  345. * The following operations are performed -
  346. * - Read the IO ports (0, 1 and 2)
  347. * - Set host interrupt Reset-To-Read to clear
  348. * - Set auto re-enable interrupt
  349. */
  350. static int mwifiex_init_sdio_ioport(struct mwifiex_adapter *adapter)
  351. {
  352. u32 reg;
  353. adapter->ioport = 0;
  354. /* Read the IO port */
  355. if (!mwifiex_read_reg(adapter, IO_PORT_0_REG, &reg))
  356. adapter->ioport |= (reg & 0xff);
  357. else
  358. return -1;
  359. if (!mwifiex_read_reg(adapter, IO_PORT_1_REG, &reg))
  360. adapter->ioport |= ((reg & 0xff) << 8);
  361. else
  362. return -1;
  363. if (!mwifiex_read_reg(adapter, IO_PORT_2_REG, &reg))
  364. adapter->ioport |= ((reg & 0xff) << 16);
  365. else
  366. return -1;
  367. pr_debug("info: SDIO FUNC1 IO port: %#x\n", adapter->ioport);
  368. /* Set Host interrupt reset to read to clear */
  369. if (!mwifiex_read_reg(adapter, HOST_INT_RSR_REG, &reg))
  370. mwifiex_write_reg(adapter, HOST_INT_RSR_REG,
  371. reg | SDIO_INT_MASK);
  372. else
  373. return -1;
  374. /* Dnld/Upld ready set to auto reset */
  375. if (!mwifiex_read_reg(adapter, CARD_MISC_CFG_REG, &reg))
  376. mwifiex_write_reg(adapter, CARD_MISC_CFG_REG,
  377. reg | AUTO_RE_ENABLE_INT);
  378. else
  379. return -1;
  380. return 0;
  381. }
  382. /*
  383. * This function sends data to the card.
  384. */
  385. static int mwifiex_write_data_to_card(struct mwifiex_adapter *adapter,
  386. u8 *payload, u32 pkt_len, u32 port)
  387. {
  388. u32 i = 0;
  389. int ret;
  390. do {
  391. ret = mwifiex_write_data_sync(adapter, payload, pkt_len, port);
  392. if (ret) {
  393. i++;
  394. dev_err(adapter->dev, "host_to_card, write iomem"
  395. " (%d) failed: %d\n", i, ret);
  396. if (mwifiex_write_reg(adapter, CONFIGURATION_REG, 0x04))
  397. dev_err(adapter->dev, "write CFG reg failed\n");
  398. ret = -1;
  399. if (i > MAX_WRITE_IOMEM_RETRY)
  400. return ret;
  401. }
  402. } while (ret == -1);
  403. return ret;
  404. }
  405. /*
  406. * This function gets the read port.
  407. *
  408. * If control port bit is set in MP read bitmap, the control port
  409. * is returned, otherwise the current read port is returned and
  410. * the value is increased (provided it does not reach the maximum
  411. * limit, in which case it is reset to 1)
  412. */
  413. static int mwifiex_get_rd_port(struct mwifiex_adapter *adapter, u8 *port)
  414. {
  415. struct sdio_mmc_card *card = adapter->card;
  416. u16 rd_bitmap = card->mp_rd_bitmap;
  417. dev_dbg(adapter->dev, "data: mp_rd_bitmap=0x%04x\n", rd_bitmap);
  418. if (!(rd_bitmap & (CTRL_PORT_MASK | DATA_PORT_MASK)))
  419. return -1;
  420. if (card->mp_rd_bitmap & CTRL_PORT_MASK) {
  421. card->mp_rd_bitmap &= (u16) (~CTRL_PORT_MASK);
  422. *port = CTRL_PORT;
  423. dev_dbg(adapter->dev, "data: port=%d mp_rd_bitmap=0x%04x\n",
  424. *port, card->mp_rd_bitmap);
  425. } else {
  426. if (card->mp_rd_bitmap & (1 << card->curr_rd_port)) {
  427. card->mp_rd_bitmap &= (u16)
  428. (~(1 << card->curr_rd_port));
  429. *port = card->curr_rd_port;
  430. if (++card->curr_rd_port == MAX_PORT)
  431. card->curr_rd_port = 1;
  432. } else {
  433. return -1;
  434. }
  435. dev_dbg(adapter->dev,
  436. "data: port=%d mp_rd_bitmap=0x%04x -> 0x%04x\n",
  437. *port, rd_bitmap, card->mp_rd_bitmap);
  438. }
  439. return 0;
  440. }
  441. /*
  442. * This function gets the write port for data.
  443. *
  444. * The current write port is returned if available and the value is
  445. * increased (provided it does not reach the maximum limit, in which
  446. * case it is reset to 1)
  447. */
  448. static int mwifiex_get_wr_port_data(struct mwifiex_adapter *adapter, u8 *port)
  449. {
  450. struct sdio_mmc_card *card = adapter->card;
  451. u16 wr_bitmap = card->mp_wr_bitmap;
  452. dev_dbg(adapter->dev, "data: mp_wr_bitmap=0x%04x\n", wr_bitmap);
  453. if (!(wr_bitmap & card->mp_data_port_mask))
  454. return -1;
  455. if (card->mp_wr_bitmap & (1 << card->curr_wr_port)) {
  456. card->mp_wr_bitmap &= (u16) (~(1 << card->curr_wr_port));
  457. *port = card->curr_wr_port;
  458. if (++card->curr_wr_port == card->mp_end_port)
  459. card->curr_wr_port = 1;
  460. } else {
  461. adapter->data_sent = true;
  462. return -EBUSY;
  463. }
  464. if (*port == CTRL_PORT) {
  465. dev_err(adapter->dev, "invalid data port=%d cur port=%d"
  466. " mp_wr_bitmap=0x%04x -> 0x%04x\n",
  467. *port, card->curr_wr_port, wr_bitmap,
  468. card->mp_wr_bitmap);
  469. return -1;
  470. }
  471. dev_dbg(adapter->dev, "data: port=%d mp_wr_bitmap=0x%04x -> 0x%04x\n",
  472. *port, wr_bitmap, card->mp_wr_bitmap);
  473. return 0;
  474. }
  475. /*
  476. * This function polls the card status.
  477. */
  478. static int
  479. mwifiex_sdio_poll_card_status(struct mwifiex_adapter *adapter, u8 bits)
  480. {
  481. u32 tries;
  482. u32 cs;
  483. for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
  484. if (mwifiex_read_reg(adapter, CARD_STATUS_REG, &cs))
  485. break;
  486. else if ((cs & bits) == bits)
  487. return 0;
  488. usleep_range(10, 20);
  489. }
  490. dev_err(adapter->dev, "poll card status failed, tries = %d\n", tries);
  491. return -1;
  492. }
  493. /*
  494. * This function reads the firmware status.
  495. */
  496. static int
  497. mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat)
  498. {
  499. u32 fws0, fws1;
  500. if (mwifiex_read_reg(adapter, CARD_FW_STATUS0_REG, &fws0))
  501. return -1;
  502. if (mwifiex_read_reg(adapter, CARD_FW_STATUS1_REG, &fws1))
  503. return -1;
  504. *dat = (u16) ((fws1 << 8) | fws0);
  505. return 0;
  506. }
  507. /*
  508. * This function disables the host interrupt.
  509. *
  510. * The host interrupt mask is read, the disable bit is reset and
  511. * written back to the card host interrupt mask register.
  512. */
  513. static int mwifiex_sdio_disable_host_int(struct mwifiex_adapter *adapter)
  514. {
  515. u32 host_int_mask;
  516. /* Read back the host_int_mask register */
  517. if (mwifiex_read_reg(adapter, HOST_INT_MASK_REG, &host_int_mask))
  518. return -1;
  519. /* Update with the mask and write back to the register */
  520. host_int_mask &= ~HOST_INT_DISABLE;
  521. if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, host_int_mask)) {
  522. dev_err(adapter->dev, "disable host interrupt failed\n");
  523. return -1;
  524. }
  525. return 0;
  526. }
  527. /*
  528. * This function enables the host interrupt.
  529. *
  530. * The host interrupt enable mask is written to the card
  531. * host interrupt mask register.
  532. */
  533. static int mwifiex_sdio_enable_host_int(struct mwifiex_adapter *adapter)
  534. {
  535. /* Simply write the mask to the register */
  536. if (mwifiex_write_reg(adapter, HOST_INT_MASK_REG, HOST_INT_ENABLE)) {
  537. dev_err(adapter->dev, "enable host interrupt failed\n");
  538. return -1;
  539. }
  540. return 0;
  541. }
  542. /*
  543. * This function sends a data buffer to the card.
  544. */
  545. static int mwifiex_sdio_card_to_host(struct mwifiex_adapter *adapter,
  546. u32 *type, u8 *buffer,
  547. u32 npayload, u32 ioport)
  548. {
  549. int ret;
  550. u32 nb;
  551. if (!buffer) {
  552. dev_err(adapter->dev, "%s: buffer is NULL\n", __func__);
  553. return -1;
  554. }
  555. ret = mwifiex_read_data_sync(adapter, buffer, npayload, ioport, 1);
  556. if (ret) {
  557. dev_err(adapter->dev, "%s: read iomem failed: %d\n", __func__,
  558. ret);
  559. return -1;
  560. }
  561. nb = le16_to_cpu(*(__le16 *) (buffer));
  562. if (nb > npayload) {
  563. dev_err(adapter->dev, "%s: invalid packet, nb=%d npayload=%d\n",
  564. __func__, nb, npayload);
  565. return -1;
  566. }
  567. *type = le16_to_cpu(*(__le16 *) (buffer + 2));
  568. return ret;
  569. }
  570. /*
  571. * This function downloads the firmware to the card.
  572. *
  573. * Firmware is downloaded to the card in blocks. Every block download
  574. * is tested for CRC errors, and retried a number of times before
  575. * returning failure.
  576. */
  577. static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter,
  578. struct mwifiex_fw_image *fw)
  579. {
  580. int ret;
  581. u8 *firmware = fw->fw_buf;
  582. u32 firmware_len = fw->fw_len;
  583. u32 offset = 0;
  584. u32 base0, base1;
  585. u8 *fwbuf;
  586. u16 len = 0;
  587. u32 txlen, tx_blocks = 0, tries;
  588. u32 i = 0;
  589. if (!firmware_len) {
  590. dev_err(adapter->dev,
  591. "firmware image not found! Terminating download\n");
  592. return -1;
  593. }
  594. dev_dbg(adapter->dev, "info: downloading FW image (%d bytes)\n",
  595. firmware_len);
  596. /* Assume that the allocated buffer is 8-byte aligned */
  597. fwbuf = kzalloc(MWIFIEX_UPLD_SIZE, GFP_KERNEL);
  598. if (!fwbuf) {
  599. dev_err(adapter->dev,
  600. "unable to alloc buffer for FW. Terminating dnld\n");
  601. return -ENOMEM;
  602. }
  603. /* Perform firmware data transfer */
  604. do {
  605. /* The host polls for the DN_LD_CARD_RDY and CARD_IO_READY
  606. bits */
  607. ret = mwifiex_sdio_poll_card_status(adapter, CARD_IO_READY |
  608. DN_LD_CARD_RDY);
  609. if (ret) {
  610. dev_err(adapter->dev, "FW download with helper:"
  611. " poll status timeout @ %d\n", offset);
  612. goto done;
  613. }
  614. /* More data? */
  615. if (offset >= firmware_len)
  616. break;
  617. for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
  618. ret = mwifiex_read_reg(adapter, HOST_F1_RD_BASE_0,
  619. &base0);
  620. if (ret) {
  621. dev_err(adapter->dev,
  622. "dev BASE0 register read failed: "
  623. "base0=%#04X(%d). Terminating dnld\n",
  624. base0, base0);
  625. goto done;
  626. }
  627. ret = mwifiex_read_reg(adapter, HOST_F1_RD_BASE_1,
  628. &base1);
  629. if (ret) {
  630. dev_err(adapter->dev,
  631. "dev BASE1 register read failed: "
  632. "base1=%#04X(%d). Terminating dnld\n",
  633. base1, base1);
  634. goto done;
  635. }
  636. len = (u16) (((base1 & 0xff) << 8) | (base0 & 0xff));
  637. if (len)
  638. break;
  639. usleep_range(10, 20);
  640. }
  641. if (!len) {
  642. break;
  643. } else if (len > MWIFIEX_UPLD_SIZE) {
  644. dev_err(adapter->dev,
  645. "FW dnld failed @ %d, invalid length %d\n",
  646. offset, len);
  647. ret = -1;
  648. goto done;
  649. }
  650. txlen = len;
  651. if (len & BIT(0)) {
  652. i++;
  653. if (i > MAX_WRITE_IOMEM_RETRY) {
  654. dev_err(adapter->dev,
  655. "FW dnld failed @ %d, over max retry\n",
  656. offset);
  657. ret = -1;
  658. goto done;
  659. }
  660. dev_err(adapter->dev, "CRC indicated by the helper:"
  661. " len = 0x%04X, txlen = %d\n", len, txlen);
  662. len &= ~BIT(0);
  663. /* Setting this to 0 to resend from same offset */
  664. txlen = 0;
  665. } else {
  666. i = 0;
  667. /* Set blocksize to transfer - checking for last
  668. block */
  669. if (firmware_len - offset < txlen)
  670. txlen = firmware_len - offset;
  671. tx_blocks = (txlen + MWIFIEX_SDIO_BLOCK_SIZE - 1)
  672. / MWIFIEX_SDIO_BLOCK_SIZE;
  673. /* Copy payload to buffer */
  674. memmove(fwbuf, &firmware[offset], txlen);
  675. }
  676. ret = mwifiex_write_data_sync(adapter, fwbuf, tx_blocks *
  677. MWIFIEX_SDIO_BLOCK_SIZE,
  678. adapter->ioport);
  679. if (ret) {
  680. dev_err(adapter->dev,
  681. "FW download, write iomem (%d) failed @ %d\n",
  682. i, offset);
  683. if (mwifiex_write_reg(adapter, CONFIGURATION_REG, 0x04))
  684. dev_err(adapter->dev, "write CFG reg failed\n");
  685. ret = -1;
  686. goto done;
  687. }
  688. offset += txlen;
  689. } while (true);
  690. dev_dbg(adapter->dev, "info: FW download over, size %d bytes\n",
  691. offset);
  692. ret = 0;
  693. done:
  694. kfree(fwbuf);
  695. return ret;
  696. }
  697. /*
  698. * This function checks the firmware status in card.
  699. *
  700. * The winner interface is also determined by this function.
  701. */
  702. static int mwifiex_check_fw_status(struct mwifiex_adapter *adapter,
  703. u32 poll_num)
  704. {
  705. int ret = 0;
  706. u16 firmware_stat;
  707. u32 tries;
  708. u32 winner_status;
  709. /* Wait for firmware initialization event */
  710. for (tries = 0; tries < poll_num; tries++) {
  711. ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat);
  712. if (ret)
  713. continue;
  714. if (firmware_stat == FIRMWARE_READY_SDIO) {
  715. ret = 0;
  716. break;
  717. } else {
  718. mdelay(100);
  719. ret = -1;
  720. }
  721. }
  722. if (ret) {
  723. if (mwifiex_read_reg
  724. (adapter, CARD_FW_STATUS0_REG, &winner_status))
  725. winner_status = 0;
  726. if (winner_status)
  727. adapter->winner = 0;
  728. else
  729. adapter->winner = 1;
  730. }
  731. return ret;
  732. }
  733. /*
  734. * This function reads the interrupt status from card.
  735. */
  736. static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter)
  737. {
  738. struct sdio_mmc_card *card = adapter->card;
  739. u32 sdio_ireg;
  740. unsigned long flags;
  741. if (mwifiex_read_data_sync(adapter, card->mp_regs, MAX_MP_REGS,
  742. REG_PORT | MWIFIEX_SDIO_BYTE_MODE_MASK,
  743. 0)) {
  744. dev_err(adapter->dev, "read mp_regs failed\n");
  745. return;
  746. }
  747. sdio_ireg = card->mp_regs[HOST_INTSTATUS_REG];
  748. if (sdio_ireg) {
  749. /*
  750. * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
  751. * Clear the interrupt status register
  752. */
  753. dev_dbg(adapter->dev, "int: sdio_ireg = %#x\n", sdio_ireg);
  754. spin_lock_irqsave(&adapter->int_lock, flags);
  755. adapter->int_status |= sdio_ireg;
  756. spin_unlock_irqrestore(&adapter->int_lock, flags);
  757. }
  758. }
  759. /*
  760. * SDIO interrupt handler.
  761. *
  762. * This function reads the interrupt status from firmware and handles
  763. * the interrupt in current thread (ksdioirqd) right away.
  764. */
  765. static void
  766. mwifiex_sdio_interrupt(struct sdio_func *func)
  767. {
  768. struct mwifiex_adapter *adapter;
  769. struct sdio_mmc_card *card;
  770. card = sdio_get_drvdata(func);
  771. if (!card || !card->adapter) {
  772. pr_debug("int: func=%p card=%p adapter=%p\n",
  773. func, card, card ? card->adapter : NULL);
  774. return;
  775. }
  776. adapter = card->adapter;
  777. if (adapter->surprise_removed)
  778. return;
  779. if (!adapter->pps_uapsd_mode && adapter->ps_state == PS_STATE_SLEEP)
  780. adapter->ps_state = PS_STATE_AWAKE;
  781. mwifiex_interrupt_status(adapter);
  782. mwifiex_main_process(adapter);
  783. }
  784. /*
  785. * This function decodes a received packet.
  786. *
  787. * Based on the type, the packet is treated as either a data, or
  788. * a command response, or an event, and the correct handler
  789. * function is invoked.
  790. */
  791. static int mwifiex_decode_rx_packet(struct mwifiex_adapter *adapter,
  792. struct sk_buff *skb, u32 upld_typ)
  793. {
  794. u8 *cmd_buf;
  795. skb_pull(skb, INTF_HEADER_LEN);
  796. switch (upld_typ) {
  797. case MWIFIEX_TYPE_DATA:
  798. dev_dbg(adapter->dev, "info: --- Rx: Data packet ---\n");
  799. mwifiex_handle_rx_packet(adapter, skb);
  800. break;
  801. case MWIFIEX_TYPE_CMD:
  802. dev_dbg(adapter->dev, "info: --- Rx: Cmd Response ---\n");
  803. /* take care of curr_cmd = NULL case */
  804. if (!adapter->curr_cmd) {
  805. cmd_buf = adapter->upld_buf;
  806. if (adapter->ps_state == PS_STATE_SLEEP_CFM)
  807. mwifiex_process_sleep_confirm_resp(adapter,
  808. skb->data,
  809. skb->len);
  810. memcpy(cmd_buf, skb->data,
  811. min_t(u32, MWIFIEX_SIZE_OF_CMD_BUFFER,
  812. skb->len));
  813. dev_kfree_skb_any(skb);
  814. } else {
  815. adapter->cmd_resp_received = true;
  816. adapter->curr_cmd->resp_skb = skb;
  817. }
  818. break;
  819. case MWIFIEX_TYPE_EVENT:
  820. dev_dbg(adapter->dev, "info: --- Rx: Event ---\n");
  821. adapter->event_cause = *(u32 *) skb->data;
  822. if ((skb->len > 0) && (skb->len < MAX_EVENT_SIZE))
  823. memcpy(adapter->event_body,
  824. skb->data + MWIFIEX_EVENT_HEADER_LEN,
  825. skb->len);
  826. /* event cause has been saved to adapter->event_cause */
  827. adapter->event_received = true;
  828. adapter->event_skb = skb;
  829. break;
  830. default:
  831. dev_err(adapter->dev, "unknown upload type %#x\n", upld_typ);
  832. dev_kfree_skb_any(skb);
  833. break;
  834. }
  835. return 0;
  836. }
  837. /*
  838. * This function transfers received packets from card to driver, performing
  839. * aggregation if required.
  840. *
  841. * For data received on control port, or if aggregation is disabled, the
  842. * received buffers are uploaded as separate packets. However, if aggregation
  843. * is enabled and required, the buffers are copied onto an aggregation buffer,
  844. * provided there is space left, processed and finally uploaded.
  845. */
  846. static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter,
  847. struct sk_buff *skb, u8 port)
  848. {
  849. struct sdio_mmc_card *card = adapter->card;
  850. s32 f_do_rx_aggr = 0;
  851. s32 f_do_rx_cur = 0;
  852. s32 f_aggr_cur = 0;
  853. struct sk_buff *skb_deaggr;
  854. u32 pind;
  855. u32 pkt_len, pkt_type = 0;
  856. u8 *curr_ptr;
  857. u32 rx_len = skb->len;
  858. if (port == CTRL_PORT) {
  859. /* Read the command Resp without aggr */
  860. dev_dbg(adapter->dev, "info: %s: no aggregation for cmd "
  861. "response\n", __func__);
  862. f_do_rx_cur = 1;
  863. goto rx_curr_single;
  864. }
  865. if (!card->mpa_rx.enabled) {
  866. dev_dbg(adapter->dev, "info: %s: rx aggregation disabled\n",
  867. __func__);
  868. f_do_rx_cur = 1;
  869. goto rx_curr_single;
  870. }
  871. if (card->mp_rd_bitmap & (~((u16) CTRL_PORT_MASK))) {
  872. /* Some more data RX pending */
  873. dev_dbg(adapter->dev, "info: %s: not last packet\n", __func__);
  874. if (MP_RX_AGGR_IN_PROGRESS(card)) {
  875. if (MP_RX_AGGR_BUF_HAS_ROOM(card, skb->len)) {
  876. f_aggr_cur = 1;
  877. } else {
  878. /* No room in Aggr buf, do rx aggr now */
  879. f_do_rx_aggr = 1;
  880. f_do_rx_cur = 1;
  881. }
  882. } else {
  883. /* Rx aggr not in progress */
  884. f_aggr_cur = 1;
  885. }
  886. } else {
  887. /* No more data RX pending */
  888. dev_dbg(adapter->dev, "info: %s: last packet\n", __func__);
  889. if (MP_RX_AGGR_IN_PROGRESS(card)) {
  890. f_do_rx_aggr = 1;
  891. if (MP_RX_AGGR_BUF_HAS_ROOM(card, skb->len))
  892. f_aggr_cur = 1;
  893. else
  894. /* No room in Aggr buf, do rx aggr now */
  895. f_do_rx_cur = 1;
  896. } else {
  897. f_do_rx_cur = 1;
  898. }
  899. }
  900. if (f_aggr_cur) {
  901. dev_dbg(adapter->dev, "info: current packet aggregation\n");
  902. /* Curr pkt can be aggregated */
  903. MP_RX_AGGR_SETUP(card, skb, port);
  904. if (MP_RX_AGGR_PKT_LIMIT_REACHED(card) ||
  905. MP_RX_AGGR_PORT_LIMIT_REACHED(card)) {
  906. dev_dbg(adapter->dev, "info: %s: aggregated packet "
  907. "limit reached\n", __func__);
  908. /* No more pkts allowed in Aggr buf, rx it */
  909. f_do_rx_aggr = 1;
  910. }
  911. }
  912. if (f_do_rx_aggr) {
  913. /* do aggr RX now */
  914. dev_dbg(adapter->dev, "info: do_rx_aggr: num of packets: %d\n",
  915. card->mpa_rx.pkt_cnt);
  916. if (mwifiex_read_data_sync(adapter, card->mpa_rx.buf,
  917. card->mpa_rx.buf_len,
  918. (adapter->ioport | 0x1000 |
  919. (card->mpa_rx.ports << 4)) +
  920. card->mpa_rx.start_port, 1))
  921. goto error;
  922. curr_ptr = card->mpa_rx.buf;
  923. for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) {
  924. /* get curr PKT len & type */
  925. pkt_len = *(u16 *) &curr_ptr[0];
  926. pkt_type = *(u16 *) &curr_ptr[2];
  927. /* copy pkt to deaggr buf */
  928. skb_deaggr = card->mpa_rx.skb_arr[pind];
  929. if ((pkt_type == MWIFIEX_TYPE_DATA) && (pkt_len <=
  930. card->mpa_rx.len_arr[pind])) {
  931. memcpy(skb_deaggr->data, curr_ptr, pkt_len);
  932. skb_trim(skb_deaggr, pkt_len);
  933. /* Process de-aggr packet */
  934. mwifiex_decode_rx_packet(adapter, skb_deaggr,
  935. pkt_type);
  936. } else {
  937. dev_err(adapter->dev, "wrong aggr pkt:"
  938. " type=%d len=%d max_len=%d\n",
  939. pkt_type, pkt_len,
  940. card->mpa_rx.len_arr[pind]);
  941. dev_kfree_skb_any(skb_deaggr);
  942. }
  943. curr_ptr += card->mpa_rx.len_arr[pind];
  944. }
  945. MP_RX_AGGR_BUF_RESET(card);
  946. }
  947. rx_curr_single:
  948. if (f_do_rx_cur) {
  949. dev_dbg(adapter->dev, "info: RX: port: %d, rx_len: %d\n",
  950. port, rx_len);
  951. if (mwifiex_sdio_card_to_host(adapter, &pkt_type,
  952. skb->data, skb->len,
  953. adapter->ioport + port))
  954. goto error;
  955. mwifiex_decode_rx_packet(adapter, skb, pkt_type);
  956. }
  957. return 0;
  958. error:
  959. if (MP_RX_AGGR_IN_PROGRESS(card)) {
  960. /* Multiport-aggregation transfer failed - cleanup */
  961. for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) {
  962. /* copy pkt to deaggr buf */
  963. skb_deaggr = card->mpa_rx.skb_arr[pind];
  964. dev_kfree_skb_any(skb_deaggr);
  965. }
  966. MP_RX_AGGR_BUF_RESET(card);
  967. }
  968. if (f_do_rx_cur)
  969. /* Single transfer pending. Free curr buff also */
  970. dev_kfree_skb_any(skb);
  971. return -1;
  972. }
  973. /*
  974. * This function checks the current interrupt status.
  975. *
  976. * The following interrupts are checked and handled by this function -
  977. * - Data sent
  978. * - Command sent
  979. * - Packets received
  980. *
  981. * Since the firmware does not generate download ready interrupt if the
  982. * port updated is command port only, command sent interrupt checking
  983. * should be done manually, and for every SDIO interrupt.
  984. *
  985. * In case of Rx packets received, the packets are uploaded from card to
  986. * host and processed accordingly.
  987. */
  988. static int mwifiex_process_int_status(struct mwifiex_adapter *adapter)
  989. {
  990. struct sdio_mmc_card *card = adapter->card;
  991. int ret = 0;
  992. u8 sdio_ireg;
  993. struct sk_buff *skb;
  994. u8 port = CTRL_PORT;
  995. u32 len_reg_l, len_reg_u;
  996. u32 rx_blocks;
  997. u16 rx_len;
  998. unsigned long flags;
  999. spin_lock_irqsave(&adapter->int_lock, flags);
  1000. sdio_ireg = adapter->int_status;
  1001. adapter->int_status = 0;
  1002. spin_unlock_irqrestore(&adapter->int_lock, flags);
  1003. if (!sdio_ireg)
  1004. return ret;
  1005. if (sdio_ireg & DN_LD_HOST_INT_STATUS) {
  1006. card->mp_wr_bitmap = ((u16) card->mp_regs[WR_BITMAP_U]) << 8;
  1007. card->mp_wr_bitmap |= (u16) card->mp_regs[WR_BITMAP_L];
  1008. dev_dbg(adapter->dev, "int: DNLD: wr_bitmap=0x%04x\n",
  1009. card->mp_wr_bitmap);
  1010. if (adapter->data_sent &&
  1011. (card->mp_wr_bitmap & card->mp_data_port_mask)) {
  1012. dev_dbg(adapter->dev,
  1013. "info: <--- Tx DONE Interrupt --->\n");
  1014. adapter->data_sent = false;
  1015. }
  1016. }
  1017. /* As firmware will not generate download ready interrupt if the port
  1018. updated is command port only, cmd_sent should be done for any SDIO
  1019. interrupt. */
  1020. if (adapter->cmd_sent) {
  1021. /* Check if firmware has attach buffer at command port and
  1022. update just that in wr_bit_map. */
  1023. card->mp_wr_bitmap |=
  1024. (u16) card->mp_regs[WR_BITMAP_L] & CTRL_PORT_MASK;
  1025. if (card->mp_wr_bitmap & CTRL_PORT_MASK)
  1026. adapter->cmd_sent = false;
  1027. }
  1028. dev_dbg(adapter->dev, "info: cmd_sent=%d data_sent=%d\n",
  1029. adapter->cmd_sent, adapter->data_sent);
  1030. if (sdio_ireg & UP_LD_HOST_INT_STATUS) {
  1031. card->mp_rd_bitmap = ((u16) card->mp_regs[RD_BITMAP_U]) << 8;
  1032. card->mp_rd_bitmap |= (u16) card->mp_regs[RD_BITMAP_L];
  1033. dev_dbg(adapter->dev, "int: UPLD: rd_bitmap=0x%04x\n",
  1034. card->mp_rd_bitmap);
  1035. while (true) {
  1036. ret = mwifiex_get_rd_port(adapter, &port);
  1037. if (ret) {
  1038. dev_dbg(adapter->dev,
  1039. "info: no more rd_port available\n");
  1040. break;
  1041. }
  1042. len_reg_l = RD_LEN_P0_L + (port << 1);
  1043. len_reg_u = RD_LEN_P0_U + (port << 1);
  1044. rx_len = ((u16) card->mp_regs[len_reg_u]) << 8;
  1045. rx_len |= (u16) card->mp_regs[len_reg_l];
  1046. dev_dbg(adapter->dev, "info: RX: port=%d rx_len=%u\n",
  1047. port, rx_len);
  1048. rx_blocks =
  1049. (rx_len + MWIFIEX_SDIO_BLOCK_SIZE -
  1050. 1) / MWIFIEX_SDIO_BLOCK_SIZE;
  1051. if (rx_len <= INTF_HEADER_LEN ||
  1052. (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE) >
  1053. MWIFIEX_RX_DATA_BUF_SIZE) {
  1054. dev_err(adapter->dev, "invalid rx_len=%d\n",
  1055. rx_len);
  1056. return -1;
  1057. }
  1058. rx_len = (u16) (rx_blocks * MWIFIEX_SDIO_BLOCK_SIZE);
  1059. skb = dev_alloc_skb(rx_len);
  1060. if (!skb) {
  1061. dev_err(adapter->dev, "%s: failed to alloc skb",
  1062. __func__);
  1063. return -1;
  1064. }
  1065. skb_put(skb, rx_len);
  1066. dev_dbg(adapter->dev, "info: rx_len = %d skb->len = %d\n",
  1067. rx_len, skb->len);
  1068. if (mwifiex_sdio_card_to_host_mp_aggr(adapter, skb,
  1069. port)) {
  1070. u32 cr = 0;
  1071. dev_err(adapter->dev, "card_to_host_mpa failed:"
  1072. " int status=%#x\n", sdio_ireg);
  1073. if (mwifiex_read_reg(adapter,
  1074. CONFIGURATION_REG, &cr))
  1075. dev_err(adapter->dev,
  1076. "read CFG reg failed\n");
  1077. dev_dbg(adapter->dev,
  1078. "info: CFG reg val = %d\n", cr);
  1079. if (mwifiex_write_reg(adapter,
  1080. CONFIGURATION_REG,
  1081. (cr | 0x04)))
  1082. dev_err(adapter->dev,
  1083. "write CFG reg failed\n");
  1084. dev_dbg(adapter->dev, "info: write success\n");
  1085. if (mwifiex_read_reg(adapter,
  1086. CONFIGURATION_REG, &cr))
  1087. dev_err(adapter->dev,
  1088. "read CFG reg failed\n");
  1089. dev_dbg(adapter->dev,
  1090. "info: CFG reg val =%x\n", cr);
  1091. return -1;
  1092. }
  1093. }
  1094. }
  1095. return 0;
  1096. }
  1097. /*
  1098. * This function aggregates transmission buffers in driver and downloads
  1099. * the aggregated packet to card.
  1100. *
  1101. * The individual packets are aggregated by copying into an aggregation
  1102. * buffer and then downloaded to the card. Previous unsent packets in the
  1103. * aggregation buffer are pre-copied first before new packets are added.
  1104. * Aggregation is done till there is space left in the aggregation buffer,
  1105. * or till new packets are available.
  1106. *
  1107. * The function will only download the packet to the card when aggregation
  1108. * stops, otherwise it will just aggregate the packet in aggregation buffer
  1109. * and return.
  1110. */
  1111. static int mwifiex_host_to_card_mp_aggr(struct mwifiex_adapter *adapter,
  1112. u8 *payload, u32 pkt_len, u8 port,
  1113. u32 next_pkt_len)
  1114. {
  1115. struct sdio_mmc_card *card = adapter->card;
  1116. int ret = 0;
  1117. s32 f_send_aggr_buf = 0;
  1118. s32 f_send_cur_buf = 0;
  1119. s32 f_precopy_cur_buf = 0;
  1120. s32 f_postcopy_cur_buf = 0;
  1121. if ((!card->mpa_tx.enabled) || (port == CTRL_PORT)) {
  1122. dev_dbg(adapter->dev, "info: %s: tx aggregation disabled\n",
  1123. __func__);
  1124. f_send_cur_buf = 1;
  1125. goto tx_curr_single;
  1126. }
  1127. if (next_pkt_len) {
  1128. /* More pkt in TX queue */
  1129. dev_dbg(adapter->dev, "info: %s: more packets in queue.\n",
  1130. __func__);
  1131. if (MP_TX_AGGR_IN_PROGRESS(card)) {
  1132. if (!MP_TX_AGGR_PORT_LIMIT_REACHED(card) &&
  1133. MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len)) {
  1134. f_precopy_cur_buf = 1;
  1135. if (!(card->mp_wr_bitmap &
  1136. (1 << card->curr_wr_port)) ||
  1137. !MP_TX_AGGR_BUF_HAS_ROOM(
  1138. card, pkt_len + next_pkt_len))
  1139. f_send_aggr_buf = 1;
  1140. } else {
  1141. /* No room in Aggr buf, send it */
  1142. f_send_aggr_buf = 1;
  1143. if (MP_TX_AGGR_PORT_LIMIT_REACHED(card) ||
  1144. !(card->mp_wr_bitmap &
  1145. (1 << card->curr_wr_port)))
  1146. f_send_cur_buf = 1;
  1147. else
  1148. f_postcopy_cur_buf = 1;
  1149. }
  1150. } else {
  1151. if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len) &&
  1152. (card->mp_wr_bitmap & (1 << card->curr_wr_port)))
  1153. f_precopy_cur_buf = 1;
  1154. else
  1155. f_send_cur_buf = 1;
  1156. }
  1157. } else {
  1158. /* Last pkt in TX queue */
  1159. dev_dbg(adapter->dev, "info: %s: Last packet in Tx Queue.\n",
  1160. __func__);
  1161. if (MP_TX_AGGR_IN_PROGRESS(card)) {
  1162. /* some packs in Aggr buf already */
  1163. f_send_aggr_buf = 1;
  1164. if (MP_TX_AGGR_BUF_HAS_ROOM(card, pkt_len))
  1165. f_precopy_cur_buf = 1;
  1166. else
  1167. /* No room in Aggr buf, send it */
  1168. f_send_cur_buf = 1;
  1169. } else {
  1170. f_send_cur_buf = 1;
  1171. }
  1172. }
  1173. if (f_precopy_cur_buf) {
  1174. dev_dbg(adapter->dev, "data: %s: precopy current buffer\n",
  1175. __func__);
  1176. MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port);
  1177. if (MP_TX_AGGR_PKT_LIMIT_REACHED(card) ||
  1178. MP_TX_AGGR_PORT_LIMIT_REACHED(card))
  1179. /* No more pkts allowed in Aggr buf, send it */
  1180. f_send_aggr_buf = 1;
  1181. }
  1182. if (f_send_aggr_buf) {
  1183. dev_dbg(adapter->dev, "data: %s: send aggr buffer: %d %d\n",
  1184. __func__,
  1185. card->mpa_tx.start_port, card->mpa_tx.ports);
  1186. ret = mwifiex_write_data_to_card(adapter, card->mpa_tx.buf,
  1187. card->mpa_tx.buf_len,
  1188. (adapter->ioport | 0x1000 |
  1189. (card->mpa_tx.ports << 4)) +
  1190. card->mpa_tx.start_port);
  1191. MP_TX_AGGR_BUF_RESET(card);
  1192. }
  1193. tx_curr_single:
  1194. if (f_send_cur_buf) {
  1195. dev_dbg(adapter->dev, "data: %s: send current buffer %d\n",
  1196. __func__, port);
  1197. ret = mwifiex_write_data_to_card(adapter, payload, pkt_len,
  1198. adapter->ioport + port);
  1199. }
  1200. if (f_postcopy_cur_buf) {
  1201. dev_dbg(adapter->dev, "data: %s: postcopy current buffer\n",
  1202. __func__);
  1203. MP_TX_AGGR_BUF_PUT(card, payload, pkt_len, port);
  1204. }
  1205. return ret;
  1206. }
  1207. /*
  1208. * This function downloads data from driver to card.
  1209. *
  1210. * Both commands and data packets are transferred to the card by this
  1211. * function.
  1212. *
  1213. * This function adds the SDIO specific header to the front of the buffer
  1214. * before transferring. The header contains the length of the packet and
  1215. * the type. The firmware handles the packets based upon this set type.
  1216. */
  1217. static int mwifiex_sdio_host_to_card(struct mwifiex_adapter *adapter,
  1218. u8 type, struct sk_buff *skb,
  1219. struct mwifiex_tx_param *tx_param)
  1220. {
  1221. struct sdio_mmc_card *card = adapter->card;
  1222. int ret;
  1223. u32 buf_block_len;
  1224. u32 blk_size;
  1225. u8 port = CTRL_PORT;
  1226. u8 *payload = (u8 *)skb->data;
  1227. u32 pkt_len = skb->len;
  1228. /* Allocate buffer and copy payload */
  1229. blk_size = MWIFIEX_SDIO_BLOCK_SIZE;
  1230. buf_block_len = (pkt_len + blk_size - 1) / blk_size;
  1231. *(u16 *) &payload[0] = (u16) pkt_len;
  1232. *(u16 *) &payload[2] = type;
  1233. /*
  1234. * This is SDIO specific header
  1235. * u16 length,
  1236. * u16 type (MWIFIEX_TYPE_DATA = 0, MWIFIEX_TYPE_CMD = 1,
  1237. * MWIFIEX_TYPE_EVENT = 3)
  1238. */
  1239. if (type == MWIFIEX_TYPE_DATA) {
  1240. ret = mwifiex_get_wr_port_data(adapter, &port);
  1241. if (ret) {
  1242. dev_err(adapter->dev, "%s: no wr_port available\n",
  1243. __func__);
  1244. return ret;
  1245. }
  1246. } else {
  1247. adapter->cmd_sent = true;
  1248. /* Type must be MWIFIEX_TYPE_CMD */
  1249. if (pkt_len <= INTF_HEADER_LEN ||
  1250. pkt_len > MWIFIEX_UPLD_SIZE)
  1251. dev_err(adapter->dev, "%s: payload=%p, nb=%d\n",
  1252. __func__, payload, pkt_len);
  1253. }
  1254. /* Transfer data to card */
  1255. pkt_len = buf_block_len * blk_size;
  1256. if (tx_param)
  1257. ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len,
  1258. port, tx_param->next_pkt_len
  1259. );
  1260. else
  1261. ret = mwifiex_host_to_card_mp_aggr(adapter, payload, pkt_len,
  1262. port, 0);
  1263. if (ret) {
  1264. if (type == MWIFIEX_TYPE_CMD)
  1265. adapter->cmd_sent = false;
  1266. if (type == MWIFIEX_TYPE_DATA)
  1267. adapter->data_sent = false;
  1268. } else {
  1269. if (type == MWIFIEX_TYPE_DATA) {
  1270. if (!(card->mp_wr_bitmap & (1 << card->curr_wr_port)))
  1271. adapter->data_sent = true;
  1272. else
  1273. adapter->data_sent = false;
  1274. }
  1275. }
  1276. return ret;
  1277. }
  1278. /*
  1279. * This function allocates the MPA Tx and Rx buffers.
  1280. */
  1281. static int mwifiex_alloc_sdio_mpa_buffers(struct mwifiex_adapter *adapter,
  1282. u32 mpa_tx_buf_size, u32 mpa_rx_buf_size)
  1283. {
  1284. struct sdio_mmc_card *card = adapter->card;
  1285. int ret = 0;
  1286. card->mpa_tx.buf = kzalloc(mpa_tx_buf_size, GFP_KERNEL);
  1287. if (!card->mpa_tx.buf) {
  1288. dev_err(adapter->dev, "could not alloc buffer for MP-A TX\n");
  1289. ret = -1;
  1290. goto error;
  1291. }
  1292. card->mpa_tx.buf_size = mpa_tx_buf_size;
  1293. card->mpa_rx.buf = kzalloc(mpa_rx_buf_size, GFP_KERNEL);
  1294. if (!card->mpa_rx.buf) {
  1295. dev_err(adapter->dev, "could not alloc buffer for MP-A RX\n");
  1296. ret = -1;
  1297. goto error;
  1298. }
  1299. card->mpa_rx.buf_size = mpa_rx_buf_size;
  1300. error:
  1301. if (ret) {
  1302. kfree(card->mpa_tx.buf);
  1303. kfree(card->mpa_rx.buf);
  1304. }
  1305. return ret;
  1306. }
  1307. /*
  1308. * This function unregisters the SDIO device.
  1309. *
  1310. * The SDIO IRQ is released, the function is disabled and driver
  1311. * data is set to null.
  1312. */
  1313. static void
  1314. mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
  1315. {
  1316. struct sdio_mmc_card *card = adapter->card;
  1317. if (adapter->card) {
  1318. /* Release the SDIO IRQ */
  1319. sdio_claim_host(card->func);
  1320. sdio_release_irq(card->func);
  1321. sdio_disable_func(card->func);
  1322. sdio_release_host(card->func);
  1323. sdio_set_drvdata(card->func, NULL);
  1324. }
  1325. }
  1326. /*
  1327. * This function registers the SDIO device.
  1328. *
  1329. * SDIO IRQ is claimed, block size is set and driver data is initialized.
  1330. */
  1331. static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
  1332. {
  1333. int ret = 0;
  1334. struct sdio_mmc_card *card = adapter->card;
  1335. struct sdio_func *func = card->func;
  1336. /* save adapter pointer in card */
  1337. card->adapter = adapter;
  1338. sdio_claim_host(func);
  1339. /* Request the SDIO IRQ */
  1340. ret = sdio_claim_irq(func, mwifiex_sdio_interrupt);
  1341. if (ret) {
  1342. pr_err("claim irq failed: ret=%d\n", ret);
  1343. goto disable_func;
  1344. }
  1345. /* Set block size */
  1346. ret = sdio_set_block_size(card->func, MWIFIEX_SDIO_BLOCK_SIZE);
  1347. if (ret) {
  1348. pr_err("cannot set SDIO block size\n");
  1349. ret = -1;
  1350. goto release_irq;
  1351. }
  1352. sdio_release_host(func);
  1353. sdio_set_drvdata(func, card);
  1354. adapter->dev = &func->dev;
  1355. switch (func->device) {
  1356. case SDIO_DEVICE_ID_MARVELL_8786:
  1357. strcpy(adapter->fw_name, SD8786_DEFAULT_FW_NAME);
  1358. break;
  1359. case SDIO_DEVICE_ID_MARVELL_8797:
  1360. strcpy(adapter->fw_name, SD8797_DEFAULT_FW_NAME);
  1361. break;
  1362. case SDIO_DEVICE_ID_MARVELL_8787:
  1363. default:
  1364. strcpy(adapter->fw_name, SD8787_DEFAULT_FW_NAME);
  1365. break;
  1366. }
  1367. return 0;
  1368. release_irq:
  1369. sdio_release_irq(func);
  1370. disable_func:
  1371. sdio_disable_func(func);
  1372. sdio_release_host(func);
  1373. adapter->card = NULL;
  1374. return -1;
  1375. }
  1376. /*
  1377. * This function initializes the SDIO driver.
  1378. *
  1379. * The following initializations steps are followed -
  1380. * - Read the Host interrupt status register to acknowledge
  1381. * the first interrupt got from bootloader
  1382. * - Disable host interrupt mask register
  1383. * - Get SDIO port
  1384. * - Initialize SDIO variables in card
  1385. * - Allocate MP registers
  1386. * - Allocate MPA Tx and Rx buffers
  1387. */
  1388. static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
  1389. {
  1390. struct sdio_mmc_card *card = adapter->card;
  1391. int ret;
  1392. u32 sdio_ireg;
  1393. /*
  1394. * Read the HOST_INT_STATUS_REG for ACK the first interrupt got
  1395. * from the bootloader. If we don't do this we get a interrupt
  1396. * as soon as we register the irq.
  1397. */
  1398. mwifiex_read_reg(adapter, HOST_INTSTATUS_REG, &sdio_ireg);
  1399. /* Disable host interrupt mask register for SDIO */
  1400. mwifiex_sdio_disable_host_int(adapter);
  1401. /* Get SDIO ioport */
  1402. mwifiex_init_sdio_ioport(adapter);
  1403. /* Initialize SDIO variables in card */
  1404. card->mp_rd_bitmap = 0;
  1405. card->mp_wr_bitmap = 0;
  1406. card->curr_rd_port = 1;
  1407. card->curr_wr_port = 1;
  1408. card->mp_data_port_mask = DATA_PORT_MASK;
  1409. card->mpa_tx.buf_len = 0;
  1410. card->mpa_tx.pkt_cnt = 0;
  1411. card->mpa_tx.start_port = 0;
  1412. card->mpa_tx.enabled = 1;
  1413. card->mpa_tx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT;
  1414. card->mpa_rx.buf_len = 0;
  1415. card->mpa_rx.pkt_cnt = 0;
  1416. card->mpa_rx.start_port = 0;
  1417. card->mpa_rx.enabled = 1;
  1418. card->mpa_rx.pkt_aggr_limit = SDIO_MP_AGGR_DEF_PKT_LIMIT;
  1419. /* Allocate buffers for SDIO MP-A */
  1420. card->mp_regs = kzalloc(MAX_MP_REGS, GFP_KERNEL);
  1421. if (!card->mp_regs) {
  1422. dev_err(adapter->dev, "failed to alloc mp_regs\n");
  1423. return -ENOMEM;
  1424. }
  1425. ret = mwifiex_alloc_sdio_mpa_buffers(adapter,
  1426. SDIO_MP_TX_AGGR_DEF_BUF_SIZE,
  1427. SDIO_MP_RX_AGGR_DEF_BUF_SIZE);
  1428. if (ret) {
  1429. dev_err(adapter->dev, "failed to alloc sdio mp-a buffers\n");
  1430. kfree(card->mp_regs);
  1431. return -1;
  1432. }
  1433. return ret;
  1434. }
  1435. /*
  1436. * This function resets the MPA Tx and Rx buffers.
  1437. */
  1438. static void mwifiex_cleanup_mpa_buf(struct mwifiex_adapter *adapter)
  1439. {
  1440. struct sdio_mmc_card *card = adapter->card;
  1441. MP_TX_AGGR_BUF_RESET(card);
  1442. MP_RX_AGGR_BUF_RESET(card);
  1443. }
  1444. /*
  1445. * This function cleans up the allocated card buffers.
  1446. *
  1447. * The following are freed by this function -
  1448. * - MP registers
  1449. * - MPA Tx buffer
  1450. * - MPA Rx buffer
  1451. */
  1452. static void mwifiex_cleanup_sdio(struct mwifiex_adapter *adapter)
  1453. {
  1454. struct sdio_mmc_card *card = adapter->card;
  1455. kfree(card->mp_regs);
  1456. kfree(card->mpa_tx.buf);
  1457. kfree(card->mpa_rx.buf);
  1458. }
  1459. /*
  1460. * This function updates the MP end port in card.
  1461. */
  1462. static void
  1463. mwifiex_update_mp_end_port(struct mwifiex_adapter *adapter, u16 port)
  1464. {
  1465. struct sdio_mmc_card *card = adapter->card;
  1466. int i;
  1467. card->mp_end_port = port;
  1468. card->mp_data_port_mask = DATA_PORT_MASK;
  1469. for (i = 1; i <= MAX_PORT - card->mp_end_port; i++)
  1470. card->mp_data_port_mask &= ~(1 << (MAX_PORT - i));
  1471. card->curr_wr_port = 1;
  1472. dev_dbg(adapter->dev, "cmd: mp_end_port %d, data port mask 0x%x\n",
  1473. port, card->mp_data_port_mask);
  1474. }
  1475. static struct mmc_host *reset_host;
  1476. static void sdio_card_reset_worker(struct work_struct *work)
  1477. {
  1478. /* The actual reset operation must be run outside of driver thread.
  1479. * This is because mmc_remove_host() will cause the device to be
  1480. * instantly destroyed, and the driver then needs to end its thread,
  1481. * leading to a deadlock.
  1482. *
  1483. * We run it in a totally independent workqueue.
  1484. */
  1485. pr_err("Resetting card...\n");
  1486. mmc_remove_host(reset_host);
  1487. /* 20ms delay is based on experiment with sdhci controller */
  1488. mdelay(20);
  1489. mmc_add_host(reset_host);
  1490. }
  1491. static DECLARE_WORK(card_reset_work, sdio_card_reset_worker);
  1492. /* This function resets the card */
  1493. static void mwifiex_sdio_card_reset(struct mwifiex_adapter *adapter)
  1494. {
  1495. struct sdio_mmc_card *card = adapter->card;
  1496. if (work_pending(&card_reset_work))
  1497. return;
  1498. reset_host = card->func->card->host;
  1499. schedule_work(&card_reset_work);
  1500. }
  1501. static struct mwifiex_if_ops sdio_ops = {
  1502. .init_if = mwifiex_init_sdio,
  1503. .cleanup_if = mwifiex_cleanup_sdio,
  1504. .check_fw_status = mwifiex_check_fw_status,
  1505. .prog_fw = mwifiex_prog_fw_w_helper,
  1506. .register_dev = mwifiex_register_dev,
  1507. .unregister_dev = mwifiex_unregister_dev,
  1508. .enable_int = mwifiex_sdio_enable_host_int,
  1509. .process_int_status = mwifiex_process_int_status,
  1510. .host_to_card = mwifiex_sdio_host_to_card,
  1511. .wakeup = mwifiex_pm_wakeup_card,
  1512. .wakeup_complete = mwifiex_pm_wakeup_card_complete,
  1513. /* SDIO specific */
  1514. .update_mp_end_port = mwifiex_update_mp_end_port,
  1515. .cleanup_mpa_buf = mwifiex_cleanup_mpa_buf,
  1516. .cmdrsp_complete = mwifiex_sdio_cmdrsp_complete,
  1517. .event_complete = mwifiex_sdio_event_complete,
  1518. .card_reset = mwifiex_sdio_card_reset,
  1519. };
  1520. /*
  1521. * This function initializes the SDIO driver.
  1522. *
  1523. * This initiates the semaphore and registers the device with
  1524. * SDIO bus.
  1525. */
  1526. static int
  1527. mwifiex_sdio_init_module(void)
  1528. {
  1529. sema_init(&add_remove_card_sem, 1);
  1530. /* Clear the flag in case user removes the card. */
  1531. user_rmmod = 0;
  1532. return sdio_register_driver(&mwifiex_sdio);
  1533. }
  1534. /*
  1535. * This function cleans up the SDIO driver.
  1536. *
  1537. * The following major steps are followed for cleanup -
  1538. * - Resume the device if its suspended
  1539. * - Disconnect the device if connected
  1540. * - Shutdown the firmware
  1541. * - Unregister the device from SDIO bus.
  1542. */
  1543. static void
  1544. mwifiex_sdio_cleanup_module(void)
  1545. {
  1546. if (!down_interruptible(&add_remove_card_sem))
  1547. up(&add_remove_card_sem);
  1548. /* Set the flag as user is removing this module. */
  1549. user_rmmod = 1;
  1550. cancel_work_sync(&card_reset_work);
  1551. sdio_unregister_driver(&mwifiex_sdio);
  1552. }
  1553. module_init(mwifiex_sdio_init_module);
  1554. module_exit(mwifiex_sdio_cleanup_module);
  1555. MODULE_AUTHOR("Marvell International Ltd.");
  1556. MODULE_DESCRIPTION("Marvell WiFi-Ex SDIO Driver version " SDIO_VERSION);
  1557. MODULE_VERSION(SDIO_VERSION);
  1558. MODULE_LICENSE("GPL v2");
  1559. MODULE_FIRMWARE(SD8786_DEFAULT_FW_NAME);
  1560. MODULE_FIRMWARE(SD8787_DEFAULT_FW_NAME);
  1561. MODULE_FIRMWARE(SD8797_DEFAULT_FW_NAME);