main.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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. /*
  46. * This workers main task is to wait for OP_OPR_ALIVE
  47. * from TOP FW until ALIVE_MSG_TIMOUT timeout is elapsed.
  48. * When OP_OPR_ALIVE received it will issue
  49. * a call to "bus_rescan_devices".
  50. */
  51. static void iwmct_rescan_worker(struct work_struct *ws)
  52. {
  53. struct iwmct_priv *priv;
  54. int ret;
  55. priv = container_of(ws, struct iwmct_priv, bus_rescan_worker);
  56. LOG_INFO(priv, FW_MSG, "Calling bus_rescan\n");
  57. ret = bus_rescan_devices(priv->func->dev.bus);
  58. if (ret < 0)
  59. LOG_INFO(priv, INIT, "bus_rescan_devices FAILED!!!\n");
  60. }
  61. static void op_top_message(struct iwmct_priv *priv, struct top_msg *msg)
  62. {
  63. switch (msg->hdr.opcode) {
  64. case OP_OPR_ALIVE:
  65. LOG_INFO(priv, FW_MSG, "Got ALIVE from device, wake rescan\n");
  66. queue_work(priv->bus_rescan_wq, &priv->bus_rescan_worker);
  67. break;
  68. default:
  69. LOG_INFO(priv, FW_MSG, "Received msg opcode 0x%X\n",
  70. msg->hdr.opcode);
  71. break;
  72. }
  73. }
  74. static void handle_top_message(struct iwmct_priv *priv, u8 *buf, int len)
  75. {
  76. struct top_msg *msg;
  77. msg = (struct top_msg *)buf;
  78. if (msg->hdr.type != COMM_TYPE_D2H) {
  79. LOG_ERROR(priv, FW_MSG,
  80. "Message from TOP with invalid message type 0x%X\n",
  81. msg->hdr.type);
  82. return;
  83. }
  84. if (len < sizeof(msg->hdr)) {
  85. LOG_ERROR(priv, FW_MSG,
  86. "Message from TOP is too short for message header "
  87. "received %d bytes, expected at least %zd bytes\n",
  88. len, sizeof(msg->hdr));
  89. return;
  90. }
  91. if (len < le16_to_cpu(msg->hdr.length) + sizeof(msg->hdr)) {
  92. LOG_ERROR(priv, FW_MSG,
  93. "Message length (%d bytes) is shorter than "
  94. "in header (%d bytes)\n",
  95. len, le16_to_cpu(msg->hdr.length));
  96. return;
  97. }
  98. switch (msg->hdr.category) {
  99. case COMM_CATEGORY_OPERATIONAL:
  100. op_top_message(priv, (struct top_msg *)buf);
  101. break;
  102. case COMM_CATEGORY_DEBUG:
  103. case COMM_CATEGORY_TESTABILITY:
  104. case COMM_CATEGORY_DIAGNOSTICS:
  105. iwmct_log_top_message(priv, buf, len);
  106. break;
  107. default:
  108. LOG_ERROR(priv, FW_MSG,
  109. "Message from TOP with unknown category 0x%X\n",
  110. msg->hdr.category);
  111. break;
  112. }
  113. }
  114. int iwmct_send_hcmd(struct iwmct_priv *priv, u8 *cmd, u16 len)
  115. {
  116. int ret;
  117. u8 *buf;
  118. LOG_TRACE(priv, FW_MSG, "Sending hcmd:\n");
  119. /* add padding to 256 for IWMC */
  120. ((struct top_msg *)cmd)->hdr.flags |= CMD_FLAG_PADDING_256;
  121. LOG_HEXDUMP(FW_MSG, cmd, len);
  122. if (len > FW_HCMD_BLOCK_SIZE) {
  123. LOG_ERROR(priv, FW_MSG, "size %d exceeded hcmd max size %d\n",
  124. len, FW_HCMD_BLOCK_SIZE);
  125. return -1;
  126. }
  127. buf = kzalloc(FW_HCMD_BLOCK_SIZE, GFP_KERNEL);
  128. if (!buf) {
  129. LOG_ERROR(priv, FW_MSG, "kzalloc error, buf size %d\n",
  130. FW_HCMD_BLOCK_SIZE);
  131. return -1;
  132. }
  133. memcpy(buf, cmd, len);
  134. sdio_claim_host(priv->func);
  135. ret = sdio_memcpy_toio(priv->func, IWMC_SDIO_DATA_ADDR, buf,
  136. FW_HCMD_BLOCK_SIZE);
  137. sdio_release_host(priv->func);
  138. kfree(buf);
  139. return ret;
  140. }
  141. int iwmct_tx(struct iwmct_priv *priv, unsigned int addr,
  142. void *src, int count)
  143. {
  144. int ret;
  145. sdio_claim_host(priv->func);
  146. ret = sdio_memcpy_toio(priv->func, addr, src, count);
  147. sdio_release_host(priv->func);
  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 = sdio_memcpy_toio(priv->func, IWMC_SDIO_DATA_ADDR,
  227. 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. queue_work(priv->wq, &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 int dump;
  305. module_param(dump, bool, 0604);
  306. MODULE_PARM_DESC(dump, "dump_hex_content");
  307. static int jump = 1;
  308. module_param(jump, bool, 0604);
  309. static int direct = 1;
  310. module_param(direct, bool, 0604);
  311. static int checksum = 1;
  312. module_param(checksum, bool, 0604);
  313. static int 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 int 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. /* create drivers work queue */
  413. priv->wq = create_workqueue(DRV_NAME "_wq");
  414. priv->bus_rescan_wq = create_workqueue(DRV_NAME "_rescan_wq");
  415. INIT_WORK(&priv->bus_rescan_worker, iwmct_rescan_worker);
  416. INIT_WORK(&priv->isr_worker, iwmct_irq_read_worker);
  417. init_waitqueue_head(&priv->wait_q);
  418. sdio_claim_host(func);
  419. /* FIXME: Remove after it is fixed in the Boot ROM upgrade */
  420. func->enable_timeout = 10;
  421. /* In our HW, setting the block size also wakes up the boot rom. */
  422. ret = sdio_set_block_size(func, priv->dbg.block_size);
  423. if (ret) {
  424. LOG_ERROR(priv, INIT,
  425. "sdio_set_block_size() failure: %d\n", ret);
  426. goto error_sdio_enable;
  427. }
  428. ret = sdio_enable_func(func);
  429. if (ret) {
  430. LOG_ERROR(priv, INIT, "sdio_enable_func() failure: %d\n", ret);
  431. goto error_sdio_enable;
  432. }
  433. /* init reset and dev_sync states */
  434. atomic_set(&priv->reset, 0);
  435. atomic_set(&priv->dev_sync, 0);
  436. /* init read req queue */
  437. INIT_LIST_HEAD(&priv->read_req_list);
  438. /* process configurable parameters */
  439. iwmct_dbg_init_params(priv);
  440. ret = sysfs_create_group(&func->dev.kobj, &iwmct_attribute_group);
  441. if (ret) {
  442. LOG_ERROR(priv, INIT, "Failed to register attributes and "
  443. "initialize module_params\n");
  444. goto error_dev_attrs;
  445. }
  446. iwmct_dbgfs_register(priv, DRV_NAME);
  447. if (!priv->dbg.direct && priv->dbg.download_trans_blks > 8) {
  448. LOG_INFO(priv, INIT,
  449. "Reducing transaction to 8 blocks = 2K (from %d)\n",
  450. priv->dbg.download_trans_blks);
  451. priv->dbg.download_trans_blks = 8;
  452. }
  453. priv->trans_len = priv->dbg.download_trans_blks * priv->dbg.block_size;
  454. LOG_INFO(priv, INIT, "Transaction length = %d\n", priv->trans_len);
  455. ret = sdio_claim_irq(func, iwmct_irq);
  456. if (ret) {
  457. LOG_ERROR(priv, INIT, "sdio_claim_irq() failure: %d\n", ret);
  458. goto error_claim_irq;
  459. }
  460. /* Enable function's interrupt */
  461. sdio_writeb(priv->func, val, addr, &ret);
  462. if (ret) {
  463. LOG_ERROR(priv, INIT, "Failure writing to "
  464. "Interrupt Enable Register (%d): %d\n", addr, ret);
  465. goto error_enable_int;
  466. }
  467. sdio_release_host(func);
  468. LOG_INFO(priv, INIT, "exit iwmct_probe\n");
  469. return ret;
  470. error_enable_int:
  471. sdio_release_irq(func);
  472. error_claim_irq:
  473. sdio_disable_func(func);
  474. error_dev_attrs:
  475. iwmct_dbgfs_unregister(priv->dbgfs);
  476. sysfs_remove_group(&func->dev.kobj, &iwmct_attribute_group);
  477. error_sdio_enable:
  478. sdio_release_host(func);
  479. return ret;
  480. }
  481. static void iwmct_remove(struct sdio_func *func)
  482. {
  483. struct iwmct_work_struct *read_req;
  484. struct iwmct_priv *priv = sdio_get_drvdata(func);
  485. priv = sdio_get_drvdata(func);
  486. LOG_INFO(priv, INIT, "enter\n");
  487. sdio_claim_host(func);
  488. sdio_release_irq(func);
  489. sdio_release_host(func);
  490. /* Safely destroy osc workqueue */
  491. destroy_workqueue(priv->bus_rescan_wq);
  492. destroy_workqueue(priv->wq);
  493. sdio_claim_host(func);
  494. sdio_disable_func(func);
  495. sysfs_remove_group(&func->dev.kobj, &iwmct_attribute_group);
  496. iwmct_dbgfs_unregister(priv->dbgfs);
  497. sdio_release_host(func);
  498. /* free read requests */
  499. while (!list_empty(&priv->read_req_list)) {
  500. read_req = list_entry(priv->read_req_list.next,
  501. struct iwmct_work_struct, list);
  502. list_del(&read_req->list);
  503. kfree(read_req);
  504. }
  505. kfree(priv);
  506. }
  507. static const struct sdio_device_id iwmct_ids[] = {
  508. /* Intel Wireless MultiCom 3200 Top Driver */
  509. { SDIO_DEVICE(SDIO_VENDOR_ID_INTEL, 0x1404)},
  510. { }, /* Terminating entry */
  511. };
  512. MODULE_DEVICE_TABLE(sdio, iwmct_ids);
  513. static struct sdio_driver iwmct_driver = {
  514. .probe = iwmct_probe,
  515. .remove = iwmct_remove,
  516. .name = DRV_NAME,
  517. .id_table = iwmct_ids,
  518. };
  519. static int __init iwmct_init(void)
  520. {
  521. int rc;
  522. /* Default log filter settings */
  523. iwmct_log_set_filter(LOG_SRC_ALL, LOG_SEV_FILTER_RUNTIME);
  524. iwmct_log_set_filter(LOG_SRC_FW_MSG, LOG_SEV_FW_FILTER_ALL);
  525. iwmct_log_set_fw_filter(LOG_SRC_ALL, FW_LOG_SEV_FILTER_RUNTIME);
  526. rc = sdio_register_driver(&iwmct_driver);
  527. return rc;
  528. }
  529. static void __exit iwmct_exit(void)
  530. {
  531. sdio_unregister_driver(&iwmct_driver);
  532. }
  533. module_init(iwmct_init);
  534. module_exit(iwmct_exit);