main.c 17 KB

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