main.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. * iwmc3200top - Intel Wireless MultiCom 3200 Top Driver
  3. * drivers/misc/iwmc3200top/main.c
  4. *
  5. * Copyright (C) 2009 Intel Corporation. All rights reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License version
  9. * 2 as published by the Free Software Foundation.
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  19. * 02110-1301, USA.
  20. *
  21. *
  22. * Author Name: Maxim Grabarnik <maxim.grabarnink@intel.com>
  23. * -
  24. *
  25. */
  26. #include <linux/module.h>
  27. #include <linux/slab.h>
  28. #include <linux/init.h>
  29. #include <linux/kernel.h>
  30. #include <linux/debugfs.h>
  31. #include <linux/mmc/sdio_ids.h>
  32. #include <linux/mmc/sdio_func.h>
  33. #include <linux/mmc/sdio.h>
  34. #include "iwmc3200top.h"
  35. #include "log.h"
  36. #include "fw-msg.h"
  37. #include "debugfs.h"
  38. #define DRIVER_DESCRIPTION "Intel(R) IWMC 3200 Top Driver"
  39. #define DRIVER_COPYRIGHT "Copyright (c) 2008 Intel Corporation."
  40. #define DRIVER_VERSION "0.1.62"
  41. MODULE_DESCRIPTION(DRIVER_DESCRIPTION);
  42. MODULE_VERSION(DRIVER_VERSION);
  43. MODULE_LICENSE("GPL");
  44. MODULE_AUTHOR(DRIVER_COPYRIGHT);
  45. MODULE_FIRMWARE(FW_NAME(FW_API_VER));
  46. static inline int __iwmct_tx(struct iwmct_priv *priv, void *src, int count)
  47. {
  48. return sdio_memcpy_toio(priv->func, IWMC_SDIO_DATA_ADDR, src, count);
  49. }
  50. int iwmct_tx(struct iwmct_priv *priv, void *src, int count)
  51. {
  52. int ret;
  53. sdio_claim_host(priv->func);
  54. ret = __iwmct_tx(priv, src, count);
  55. sdio_release_host(priv->func);
  56. return ret;
  57. }
  58. /*
  59. * This workers main task is to wait for OP_OPR_ALIVE
  60. * from TOP FW until ALIVE_MSG_TIMOUT timeout is elapsed.
  61. * When OP_OPR_ALIVE received it will issue
  62. * a call to "bus_rescan_devices".
  63. */
  64. static void iwmct_rescan_worker(struct work_struct *ws)
  65. {
  66. struct iwmct_priv *priv;
  67. int ret;
  68. priv = container_of(ws, struct iwmct_priv, bus_rescan_worker);
  69. LOG_INFO(priv, FW_MSG, "Calling bus_rescan\n");
  70. ret = bus_rescan_devices(priv->func->dev.bus);
  71. if (ret < 0)
  72. LOG_INFO(priv, INIT, "bus_rescan_devices FAILED!!!\n");
  73. }
  74. static void op_top_message(struct iwmct_priv *priv, struct top_msg *msg)
  75. {
  76. switch (msg->hdr.opcode) {
  77. case OP_OPR_ALIVE:
  78. LOG_INFO(priv, FW_MSG, "Got ALIVE from device, wake rescan\n");
  79. schedule_work(&priv->bus_rescan_worker);
  80. break;
  81. default:
  82. LOG_INFO(priv, FW_MSG, "Received msg opcode 0x%X\n",
  83. msg->hdr.opcode);
  84. break;
  85. }
  86. }
  87. static void handle_top_message(struct iwmct_priv *priv, u8 *buf, int len)
  88. {
  89. struct top_msg *msg;
  90. msg = (struct top_msg *)buf;
  91. if (msg->hdr.type != COMM_TYPE_D2H) {
  92. LOG_ERROR(priv, FW_MSG,
  93. "Message from TOP with invalid message type 0x%X\n",
  94. msg->hdr.type);
  95. return;
  96. }
  97. if (len < sizeof(msg->hdr)) {
  98. LOG_ERROR(priv, FW_MSG,
  99. "Message from TOP is too short for message header "
  100. "received %d bytes, expected at least %zd bytes\n",
  101. len, sizeof(msg->hdr));
  102. return;
  103. }
  104. if (len < le16_to_cpu(msg->hdr.length) + sizeof(msg->hdr)) {
  105. LOG_ERROR(priv, FW_MSG,
  106. "Message length (%d bytes) is shorter than "
  107. "in header (%d bytes)\n",
  108. len, le16_to_cpu(msg->hdr.length));
  109. return;
  110. }
  111. switch (msg->hdr.category) {
  112. case COMM_CATEGORY_OPERATIONAL:
  113. op_top_message(priv, (struct top_msg *)buf);
  114. break;
  115. case COMM_CATEGORY_DEBUG:
  116. case COMM_CATEGORY_TESTABILITY:
  117. case COMM_CATEGORY_DIAGNOSTICS:
  118. iwmct_log_top_message(priv, buf, len);
  119. break;
  120. default:
  121. LOG_ERROR(priv, FW_MSG,
  122. "Message from TOP with unknown category 0x%X\n",
  123. msg->hdr.category);
  124. break;
  125. }
  126. }
  127. int iwmct_send_hcmd(struct iwmct_priv *priv, u8 *cmd, u16 len)
  128. {
  129. int ret;
  130. u8 *buf;
  131. LOG_TRACE(priv, FW_MSG, "Sending hcmd:\n");
  132. /* add padding to 256 for IWMC */
  133. ((struct top_msg *)cmd)->hdr.flags |= CMD_FLAG_PADDING_256;
  134. LOG_HEXDUMP(FW_MSG, cmd, len);
  135. if (len > FW_HCMD_BLOCK_SIZE) {
  136. LOG_ERROR(priv, FW_MSG, "size %d exceeded hcmd max size %d\n",
  137. len, FW_HCMD_BLOCK_SIZE);
  138. return -1;
  139. }
  140. buf = kzalloc(FW_HCMD_BLOCK_SIZE, GFP_KERNEL);
  141. if (!buf) {
  142. LOG_ERROR(priv, FW_MSG, "kzalloc error, buf size %d\n",
  143. FW_HCMD_BLOCK_SIZE);
  144. return -1;
  145. }
  146. memcpy(buf, cmd, len);
  147. ret = iwmct_tx(priv, buf, FW_HCMD_BLOCK_SIZE);
  148. kfree(buf);
  149. return ret;
  150. }
  151. static void iwmct_irq_read_worker(struct work_struct *ws)
  152. {
  153. struct iwmct_priv *priv;
  154. struct iwmct_work_struct *read_req;
  155. __le32 *buf = NULL;
  156. int ret;
  157. int iosize;
  158. u32 barker;
  159. bool is_barker;
  160. priv = container_of(ws, struct iwmct_priv, isr_worker);
  161. LOG_TRACE(priv, IRQ, "enter iwmct_irq_read_worker %p\n", ws);
  162. /* --------------------- Handshake with device -------------------- */
  163. sdio_claim_host(priv->func);
  164. /* all list manipulations have to be protected by
  165. * sdio_claim_host/sdio_release_host */
  166. if (list_empty(&priv->read_req_list)) {
  167. LOG_ERROR(priv, IRQ, "read_req_list empty in read worker\n");
  168. goto exit_release;
  169. }
  170. read_req = list_entry(priv->read_req_list.next,
  171. struct iwmct_work_struct, list);
  172. list_del(&read_req->list);
  173. iosize = read_req->iosize;
  174. kfree(read_req);
  175. buf = kzalloc(iosize, GFP_KERNEL);
  176. if (!buf) {
  177. LOG_ERROR(priv, IRQ, "kzalloc error, buf size %d\n", iosize);
  178. goto exit_release;
  179. }
  180. LOG_INFO(priv, IRQ, "iosize=%d, buf=%p, func=%d\n",
  181. iosize, buf, priv->func->num);
  182. /* read from device */
  183. ret = sdio_memcpy_fromio(priv->func, buf, IWMC_SDIO_DATA_ADDR, iosize);
  184. if (ret) {
  185. LOG_ERROR(priv, IRQ, "error %d reading buffer\n", ret);
  186. goto exit_release;
  187. }
  188. LOG_HEXDUMP(IRQ, (u8 *)buf, iosize);
  189. barker = le32_to_cpu(buf[0]);
  190. /* Verify whether it's a barker and if not - treat as regular Rx */
  191. if (barker == IWMC_BARKER_ACK ||
  192. (barker & BARKER_DNLOAD_BARKER_MSK) == IWMC_BARKER_REBOOT) {
  193. /* Valid Barker is equal on first 4 dwords */
  194. is_barker = (buf[1] == buf[0]) &&
  195. (buf[2] == buf[0]) &&
  196. (buf[3] == buf[0]);
  197. if (!is_barker) {
  198. LOG_WARNING(priv, IRQ,
  199. "Potentially inconsistent barker "
  200. "%08X_%08X_%08X_%08X\n",
  201. le32_to_cpu(buf[0]), le32_to_cpu(buf[1]),
  202. le32_to_cpu(buf[2]), le32_to_cpu(buf[3]));
  203. }
  204. } else {
  205. is_barker = false;
  206. }
  207. /* Handle Top CommHub message */
  208. if (!is_barker) {
  209. sdio_release_host(priv->func);
  210. handle_top_message(priv, (u8 *)buf, iosize);
  211. goto exit;
  212. } else if (barker == IWMC_BARKER_ACK) { /* Handle barkers */
  213. if (atomic_read(&priv->dev_sync) == 0) {
  214. LOG_ERROR(priv, IRQ,
  215. "ACK barker arrived out-of-sync\n");
  216. goto exit_release;
  217. }
  218. /* Continuing to FW download (after Sync is completed)*/
  219. atomic_set(&priv->dev_sync, 0);
  220. LOG_INFO(priv, IRQ, "ACK barker arrived "
  221. "- starting FW download\n");
  222. } else { /* REBOOT barker */
  223. LOG_INFO(priv, IRQ, "Received reboot barker: %x\n", barker);
  224. priv->barker = barker;
  225. if (barker & BARKER_DNLOAD_SYNC_MSK) {
  226. /* Send the same barker back */
  227. ret = __iwmct_tx(priv, buf, iosize);
  228. if (ret) {
  229. LOG_ERROR(priv, IRQ,
  230. "error %d echoing barker\n", ret);
  231. goto exit_release;
  232. }
  233. LOG_INFO(priv, IRQ, "Echoing barker to device\n");
  234. atomic_set(&priv->dev_sync, 1);
  235. goto exit_release;
  236. }
  237. /* Continuing to FW download (without Sync) */
  238. LOG_INFO(priv, IRQ, "No sync requested "
  239. "- starting FW download\n");
  240. }
  241. sdio_release_host(priv->func);
  242. if (priv->dbg.fw_download)
  243. iwmct_fw_load(priv);
  244. else
  245. LOG_ERROR(priv, IRQ, "FW download not allowed\n");
  246. goto exit;
  247. exit_release:
  248. sdio_release_host(priv->func);
  249. exit:
  250. kfree(buf);
  251. LOG_TRACE(priv, IRQ, "exit iwmct_irq_read_worker\n");
  252. }
  253. static void iwmct_irq(struct sdio_func *func)
  254. {
  255. struct iwmct_priv *priv;
  256. int val, ret;
  257. int iosize;
  258. int addr = IWMC_SDIO_INTR_GET_SIZE_ADDR;
  259. struct iwmct_work_struct *read_req;
  260. priv = sdio_get_drvdata(func);
  261. LOG_TRACE(priv, IRQ, "enter iwmct_irq\n");
  262. /* read the function's status register */
  263. val = sdio_readb(func, IWMC_SDIO_INTR_STATUS_ADDR, &ret);
  264. LOG_TRACE(priv, IRQ, "iir value = %d, ret=%d\n", val, ret);
  265. if (!val) {
  266. LOG_ERROR(priv, IRQ, "iir = 0, exiting ISR\n");
  267. goto exit_clear_intr;
  268. }
  269. /*
  270. * read 2 bytes of the transaction size
  271. * IMPORTANT: sdio transaction size has to be read before clearing
  272. * sdio interrupt!!!
  273. */
  274. val = sdio_readb(priv->func, addr++, &ret);
  275. iosize = val;
  276. val = sdio_readb(priv->func, addr++, &ret);
  277. iosize += val << 8;
  278. LOG_INFO(priv, IRQ, "READ size %d\n", iosize);
  279. if (iosize == 0) {
  280. LOG_ERROR(priv, IRQ, "READ size %d, exiting ISR\n", iosize);
  281. goto exit_clear_intr;
  282. }
  283. /* allocate a work structure to pass iosize to the worker */
  284. read_req = kzalloc(sizeof(struct iwmct_work_struct), GFP_KERNEL);
  285. if (!read_req) {
  286. LOG_ERROR(priv, IRQ, "failed to allocate read_req, exit ISR\n");
  287. goto exit_clear_intr;
  288. }
  289. INIT_LIST_HEAD(&read_req->list);
  290. read_req->iosize = iosize;
  291. list_add_tail(&priv->read_req_list, &read_req->list);
  292. /* clear the function's interrupt request bit (write 1 to clear) */
  293. sdio_writeb(func, 1, IWMC_SDIO_INTR_CLEAR_ADDR, &ret);
  294. schedule_work(&priv->isr_worker);
  295. LOG_TRACE(priv, IRQ, "exit iwmct_irq\n");
  296. return;
  297. exit_clear_intr:
  298. /* clear the function's interrupt request bit (write 1 to clear) */
  299. sdio_writeb(func, 1, IWMC_SDIO_INTR_CLEAR_ADDR, &ret);
  300. }
  301. static int blocks;
  302. module_param(blocks, int, 0604);
  303. MODULE_PARM_DESC(blocks, "max_blocks_to_send");
  304. static bool dump;
  305. module_param(dump, bool, 0604);
  306. MODULE_PARM_DESC(dump, "dump_hex_content");
  307. static bool jump = 1;
  308. module_param(jump, bool, 0604);
  309. static bool direct = 1;
  310. module_param(direct, bool, 0604);
  311. static bool checksum = 1;
  312. module_param(checksum, bool, 0604);
  313. static bool fw_download = 1;
  314. module_param(fw_download, bool, 0604);
  315. static int block_size = IWMC_SDIO_BLK_SIZE;
  316. module_param(block_size, int, 0404);
  317. static int download_trans_blks = IWMC_DEFAULT_TR_BLK;
  318. module_param(download_trans_blks, int, 0604);
  319. static bool rubbish_barker;
  320. module_param(rubbish_barker, bool, 0604);
  321. #ifdef CONFIG_IWMC3200TOP_DEBUG
  322. static int log_level[LOG_SRC_MAX];
  323. static unsigned int log_level_argc;
  324. module_param_array(log_level, int, &log_level_argc, 0604);
  325. MODULE_PARM_DESC(log_level, "log_level");
  326. static int log_level_fw[FW_LOG_SRC_MAX];
  327. static unsigned int log_level_fw_argc;
  328. module_param_array(log_level_fw, int, &log_level_fw_argc, 0604);
  329. MODULE_PARM_DESC(log_level_fw, "log_level_fw");
  330. #endif
  331. void iwmct_dbg_init_params(struct iwmct_priv *priv)
  332. {
  333. #ifdef CONFIG_IWMC3200TOP_DEBUG
  334. int i;
  335. for (i = 0; i < log_level_argc; i++) {
  336. dev_notice(&priv->func->dev, "log_level[%d]=0x%X\n",
  337. i, log_level[i]);
  338. iwmct_log_set_filter((log_level[i] >> 8) & 0xFF,
  339. log_level[i] & 0xFF);
  340. }
  341. for (i = 0; i < log_level_fw_argc; i++) {
  342. dev_notice(&priv->func->dev, "log_level_fw[%d]=0x%X\n",
  343. i, log_level_fw[i]);
  344. iwmct_log_set_fw_filter((log_level_fw[i] >> 8) & 0xFF,
  345. log_level_fw[i] & 0xFF);
  346. }
  347. #endif
  348. priv->dbg.blocks = blocks;
  349. LOG_INFO(priv, INIT, "blocks=%d\n", blocks);
  350. priv->dbg.dump = (bool)dump;
  351. LOG_INFO(priv, INIT, "dump=%d\n", dump);
  352. priv->dbg.jump = (bool)jump;
  353. LOG_INFO(priv, INIT, "jump=%d\n", jump);
  354. priv->dbg.direct = (bool)direct;
  355. LOG_INFO(priv, INIT, "direct=%d\n", direct);
  356. priv->dbg.checksum = (bool)checksum;
  357. LOG_INFO(priv, INIT, "checksum=%d\n", checksum);
  358. priv->dbg.fw_download = (bool)fw_download;
  359. LOG_INFO(priv, INIT, "fw_download=%d\n", fw_download);
  360. priv->dbg.block_size = block_size;
  361. LOG_INFO(priv, INIT, "block_size=%d\n", block_size);
  362. priv->dbg.download_trans_blks = download_trans_blks;
  363. LOG_INFO(priv, INIT, "download_trans_blks=%d\n", download_trans_blks);
  364. }
  365. /*****************************************************************************
  366. *
  367. * sysfs attributes
  368. *
  369. *****************************************************************************/
  370. static ssize_t show_iwmct_fw_version(struct device *d,
  371. struct device_attribute *attr, char *buf)
  372. {
  373. struct iwmct_priv *priv = dev_get_drvdata(d);
  374. return sprintf(buf, "%s\n", priv->dbg.label_fw);
  375. }
  376. static DEVICE_ATTR(cc_label_fw, S_IRUGO, show_iwmct_fw_version, NULL);
  377. #ifdef CONFIG_IWMC3200TOP_DEBUG
  378. static DEVICE_ATTR(log_level, S_IWUSR | S_IRUGO,
  379. show_iwmct_log_level, store_iwmct_log_level);
  380. static DEVICE_ATTR(log_level_fw, S_IWUSR | S_IRUGO,
  381. show_iwmct_log_level_fw, store_iwmct_log_level_fw);
  382. #endif
  383. static struct attribute *iwmct_sysfs_entries[] = {
  384. &dev_attr_cc_label_fw.attr,
  385. #ifdef CONFIG_IWMC3200TOP_DEBUG
  386. &dev_attr_log_level.attr,
  387. &dev_attr_log_level_fw.attr,
  388. #endif
  389. NULL
  390. };
  391. static struct attribute_group iwmct_attribute_group = {
  392. .name = NULL, /* put in device directory */
  393. .attrs = iwmct_sysfs_entries,
  394. };
  395. static int iwmct_probe(struct sdio_func *func,
  396. const struct sdio_device_id *id)
  397. {
  398. struct iwmct_priv *priv;
  399. int ret;
  400. int val = 1;
  401. int addr = IWMC_SDIO_INTR_ENABLE_ADDR;
  402. dev_dbg(&func->dev, "enter iwmct_probe\n");
  403. dev_dbg(&func->dev, "IRQ polling period id %u msecs, HZ is %d\n",
  404. jiffies_to_msecs(2147483647), HZ);
  405. priv = kzalloc(sizeof(struct iwmct_priv), GFP_KERNEL);
  406. if (!priv) {
  407. dev_err(&func->dev, "kzalloc error\n");
  408. return -ENOMEM;
  409. }
  410. priv->func = func;
  411. sdio_set_drvdata(func, priv);
  412. INIT_WORK(&priv->bus_rescan_worker, iwmct_rescan_worker);
  413. INIT_WORK(&priv->isr_worker, iwmct_irq_read_worker);
  414. init_waitqueue_head(&priv->wait_q);
  415. sdio_claim_host(func);
  416. /* FIXME: Remove after it is fixed in the Boot ROM upgrade */
  417. func->enable_timeout = 10;
  418. /* In our HW, setting the block size also wakes up the boot rom. */
  419. ret = sdio_set_block_size(func, priv->dbg.block_size);
  420. if (ret) {
  421. LOG_ERROR(priv, INIT,
  422. "sdio_set_block_size() failure: %d\n", ret);
  423. goto error_sdio_enable;
  424. }
  425. ret = sdio_enable_func(func);
  426. if (ret) {
  427. LOG_ERROR(priv, INIT, "sdio_enable_func() failure: %d\n", ret);
  428. goto error_sdio_enable;
  429. }
  430. /* init reset and dev_sync states */
  431. atomic_set(&priv->reset, 0);
  432. atomic_set(&priv->dev_sync, 0);
  433. /* init read req queue */
  434. INIT_LIST_HEAD(&priv->read_req_list);
  435. /* process configurable parameters */
  436. iwmct_dbg_init_params(priv);
  437. ret = sysfs_create_group(&func->dev.kobj, &iwmct_attribute_group);
  438. if (ret) {
  439. LOG_ERROR(priv, INIT, "Failed to register attributes and "
  440. "initialize module_params\n");
  441. goto error_dev_attrs;
  442. }
  443. iwmct_dbgfs_register(priv, DRV_NAME);
  444. if (!priv->dbg.direct && priv->dbg.download_trans_blks > 8) {
  445. LOG_INFO(priv, INIT,
  446. "Reducing transaction to 8 blocks = 2K (from %d)\n",
  447. priv->dbg.download_trans_blks);
  448. priv->dbg.download_trans_blks = 8;
  449. }
  450. priv->trans_len = priv->dbg.download_trans_blks * priv->dbg.block_size;
  451. LOG_INFO(priv, INIT, "Transaction length = %d\n", priv->trans_len);
  452. ret = sdio_claim_irq(func, iwmct_irq);
  453. if (ret) {
  454. LOG_ERROR(priv, INIT, "sdio_claim_irq() failure: %d\n", ret);
  455. goto error_claim_irq;
  456. }
  457. /* Enable function's interrupt */
  458. sdio_writeb(priv->func, val, addr, &ret);
  459. if (ret) {
  460. LOG_ERROR(priv, INIT, "Failure writing to "
  461. "Interrupt Enable Register (%d): %d\n", addr, ret);
  462. goto error_enable_int;
  463. }
  464. sdio_release_host(func);
  465. LOG_INFO(priv, INIT, "exit iwmct_probe\n");
  466. return ret;
  467. error_enable_int:
  468. sdio_release_irq(func);
  469. error_claim_irq:
  470. sdio_disable_func(func);
  471. error_dev_attrs:
  472. iwmct_dbgfs_unregister(priv->dbgfs);
  473. sysfs_remove_group(&func->dev.kobj, &iwmct_attribute_group);
  474. error_sdio_enable:
  475. sdio_release_host(func);
  476. return ret;
  477. }
  478. static void iwmct_remove(struct sdio_func *func)
  479. {
  480. struct iwmct_work_struct *read_req;
  481. struct iwmct_priv *priv = sdio_get_drvdata(func);
  482. LOG_INFO(priv, INIT, "enter\n");
  483. sdio_claim_host(func);
  484. sdio_release_irq(func);
  485. sdio_release_host(func);
  486. /* Make sure works are finished */
  487. flush_work_sync(&priv->bus_rescan_worker);
  488. flush_work_sync(&priv->isr_worker);
  489. sdio_claim_host(func);
  490. sdio_disable_func(func);
  491. sysfs_remove_group(&func->dev.kobj, &iwmct_attribute_group);
  492. iwmct_dbgfs_unregister(priv->dbgfs);
  493. sdio_release_host(func);
  494. /* free read requests */
  495. while (!list_empty(&priv->read_req_list)) {
  496. read_req = list_entry(priv->read_req_list.next,
  497. struct iwmct_work_struct, list);
  498. list_del(&read_req->list);
  499. kfree(read_req);
  500. }
  501. kfree(priv);
  502. }
  503. static const struct sdio_device_id iwmct_ids[] = {
  504. /* Intel Wireless MultiCom 3200 Top Driver */
  505. { SDIO_DEVICE(SDIO_VENDOR_ID_INTEL, 0x1404)},
  506. { }, /* Terminating entry */
  507. };
  508. MODULE_DEVICE_TABLE(sdio, iwmct_ids);
  509. static struct sdio_driver iwmct_driver = {
  510. .probe = iwmct_probe,
  511. .remove = iwmct_remove,
  512. .name = DRV_NAME,
  513. .id_table = iwmct_ids,
  514. };
  515. static int __init iwmct_init(void)
  516. {
  517. int rc;
  518. /* Default log filter settings */
  519. iwmct_log_set_filter(LOG_SRC_ALL, LOG_SEV_FILTER_RUNTIME);
  520. iwmct_log_set_filter(LOG_SRC_FW_MSG, LOG_SEV_FW_FILTER_ALL);
  521. iwmct_log_set_fw_filter(LOG_SRC_ALL, FW_LOG_SEV_FILTER_RUNTIME);
  522. rc = sdio_register_driver(&iwmct_driver);
  523. return rc;
  524. }
  525. static void __exit iwmct_exit(void)
  526. {
  527. sdio_unregister_driver(&iwmct_driver);
  528. }
  529. module_init(iwmct_init);
  530. module_exit(iwmct_exit);