main.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  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, FW_DOWNLOAD, "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_INFOEX(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_INFO(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. LOG_INFO(priv, IRQ, "barker download request 0x%x is:\n", priv->barker);
  243. LOG_INFO(priv, IRQ, "******* Top FW %s requested ********\n",
  244. (priv->barker & BARKER_DNLOAD_TOP_MSK) ? "was" : "not");
  245. LOG_INFO(priv, IRQ, "******* GPS FW %s requested ********\n",
  246. (priv->barker & BARKER_DNLOAD_GPS_MSK) ? "was" : "not");
  247. LOG_INFO(priv, IRQ, "******* BT FW %s requested ********\n",
  248. (priv->barker & BARKER_DNLOAD_BT_MSK) ? "was" : "not");
  249. if (priv->dbg.fw_download)
  250. iwmct_fw_load(priv);
  251. else
  252. LOG_ERROR(priv, IRQ, "FW download not allowed\n");
  253. goto exit;
  254. exit_release:
  255. sdio_release_host(priv->func);
  256. exit:
  257. kfree(buf);
  258. LOG_INFO(priv, IRQ, "exit iwmct_irq_read_worker\n");
  259. }
  260. static void iwmct_irq(struct sdio_func *func)
  261. {
  262. struct iwmct_priv *priv;
  263. int val, ret;
  264. int iosize;
  265. int addr = IWMC_SDIO_INTR_GET_SIZE_ADDR;
  266. struct iwmct_work_struct *read_req;
  267. priv = sdio_get_drvdata(func);
  268. LOG_INFO(priv, IRQ, "enter iwmct_irq\n");
  269. /* read the function's status register */
  270. val = sdio_readb(func, IWMC_SDIO_INTR_STATUS_ADDR, &ret);
  271. LOG_INFO(priv, IRQ, "iir value = %d, ret=%d\n", val, ret);
  272. if (!val) {
  273. LOG_ERROR(priv, IRQ, "iir = 0, exiting ISR\n");
  274. goto exit_clear_intr;
  275. }
  276. /*
  277. * read 2 bytes of the transaction size
  278. * IMPORTANT: sdio transaction size has to be read before clearing
  279. * sdio interrupt!!!
  280. */
  281. val = sdio_readb(priv->func, addr++, &ret);
  282. iosize = val;
  283. val = sdio_readb(priv->func, addr++, &ret);
  284. iosize += val << 8;
  285. LOG_INFO(priv, IRQ, "READ size %d\n", iosize);
  286. if (iosize == 0) {
  287. LOG_ERROR(priv, IRQ, "READ size %d, exiting ISR\n", iosize);
  288. goto exit_clear_intr;
  289. }
  290. /* allocate a work structure to pass iosize to the worker */
  291. read_req = kzalloc(sizeof(struct iwmct_work_struct), GFP_KERNEL);
  292. if (!read_req) {
  293. LOG_ERROR(priv, IRQ, "failed to allocate read_req, exit ISR\n");
  294. goto exit_clear_intr;
  295. }
  296. INIT_LIST_HEAD(&read_req->list);
  297. read_req->iosize = iosize;
  298. list_add_tail(&priv->read_req_list, &read_req->list);
  299. /* clear the function's interrupt request bit (write 1 to clear) */
  300. sdio_writeb(func, 1, IWMC_SDIO_INTR_CLEAR_ADDR, &ret);
  301. queue_work(priv->wq, &priv->isr_worker);
  302. LOG_INFO(priv, IRQ, "exit iwmct_irq\n");
  303. return;
  304. exit_clear_intr:
  305. /* clear the function's interrupt request bit (write 1 to clear) */
  306. sdio_writeb(func, 1, IWMC_SDIO_INTR_CLEAR_ADDR, &ret);
  307. }
  308. static int blocks;
  309. module_param(blocks, int, 0604);
  310. MODULE_PARM_DESC(blocks, "max_blocks_to_send");
  311. static int dump;
  312. module_param(dump, bool, 0604);
  313. MODULE_PARM_DESC(dump, "dump_hex_content");
  314. static int jump = 1;
  315. module_param(jump, bool, 0604);
  316. static int direct = 1;
  317. module_param(direct, bool, 0604);
  318. static int checksum = 1;
  319. module_param(checksum, bool, 0604);
  320. static int fw_download = 1;
  321. module_param(fw_download, bool, 0604);
  322. static int block_size = IWMC_SDIO_BLK_SIZE;
  323. module_param(block_size, int, 0404);
  324. static int download_trans_blks = IWMC_DEFAULT_TR_BLK;
  325. module_param(download_trans_blks, int, 0604);
  326. static int rubbish_barker;
  327. module_param(rubbish_barker, bool, 0604);
  328. #ifdef CONFIG_IWMC3200TOP_DEBUG
  329. static int log_level[LOG_SRC_MAX];
  330. static unsigned int log_level_argc;
  331. module_param_array(log_level, int, &log_level_argc, 0604);
  332. MODULE_PARM_DESC(log_level, "log_level");
  333. static int log_level_fw[FW_LOG_SRC_MAX];
  334. static unsigned int log_level_fw_argc;
  335. module_param_array(log_level_fw, int, &log_level_fw_argc, 0604);
  336. MODULE_PARM_DESC(log_level_fw, "log_level_fw");
  337. #endif
  338. void iwmct_dbg_init_params(struct iwmct_priv *priv)
  339. {
  340. #ifdef CONFIG_IWMC3200TOP_DEBUG
  341. int i;
  342. for (i = 0; i < log_level_argc; i++) {
  343. dev_notice(&priv->func->dev, "log_level[%d]=0x%X\n",
  344. i, log_level[i]);
  345. iwmct_log_set_filter((log_level[i] >> 8) & 0xFF,
  346. log_level[i] & 0xFF);
  347. }
  348. for (i = 0; i < log_level_fw_argc; i++) {
  349. dev_notice(&priv->func->dev, "log_level_fw[%d]=0x%X\n",
  350. i, log_level_fw[i]);
  351. iwmct_log_set_fw_filter((log_level_fw[i] >> 8) & 0xFF,
  352. log_level_fw[i] & 0xFF);
  353. }
  354. #endif
  355. priv->dbg.blocks = blocks;
  356. LOG_INFO(priv, INIT, "blocks=%d\n", blocks);
  357. priv->dbg.dump = (bool)dump;
  358. LOG_INFO(priv, INIT, "dump=%d\n", dump);
  359. priv->dbg.jump = (bool)jump;
  360. LOG_INFO(priv, INIT, "jump=%d\n", jump);
  361. priv->dbg.direct = (bool)direct;
  362. LOG_INFO(priv, INIT, "direct=%d\n", direct);
  363. priv->dbg.checksum = (bool)checksum;
  364. LOG_INFO(priv, INIT, "checksum=%d\n", checksum);
  365. priv->dbg.fw_download = (bool)fw_download;
  366. LOG_INFO(priv, INIT, "fw_download=%d\n", fw_download);
  367. priv->dbg.block_size = block_size;
  368. LOG_INFO(priv, INIT, "block_size=%d\n", block_size);
  369. priv->dbg.download_trans_blks = download_trans_blks;
  370. LOG_INFO(priv, INIT, "download_trans_blks=%d\n", download_trans_blks);
  371. }
  372. /*****************************************************************************
  373. *
  374. * sysfs attributes
  375. *
  376. *****************************************************************************/
  377. static ssize_t show_iwmct_fw_version(struct device *d,
  378. struct device_attribute *attr, char *buf)
  379. {
  380. struct iwmct_priv *priv = dev_get_drvdata(d);
  381. return sprintf(buf, "%s\n", priv->dbg.label_fw);
  382. }
  383. static DEVICE_ATTR(cc_label_fw, S_IRUGO, show_iwmct_fw_version, NULL);
  384. #ifdef CONFIG_IWMC3200TOP_DEBUG
  385. static DEVICE_ATTR(log_level, S_IWUSR | S_IRUGO,
  386. show_iwmct_log_level, store_iwmct_log_level);
  387. static DEVICE_ATTR(log_level_fw, S_IWUSR | S_IRUGO,
  388. show_iwmct_log_level_fw, store_iwmct_log_level_fw);
  389. #endif
  390. static struct attribute *iwmct_sysfs_entries[] = {
  391. &dev_attr_cc_label_fw.attr,
  392. #ifdef CONFIG_IWMC3200TOP_DEBUG
  393. &dev_attr_log_level.attr,
  394. &dev_attr_log_level_fw.attr,
  395. #endif
  396. NULL
  397. };
  398. static struct attribute_group iwmct_attribute_group = {
  399. .name = NULL, /* put in device directory */
  400. .attrs = iwmct_sysfs_entries,
  401. };
  402. static int iwmct_probe(struct sdio_func *func,
  403. const struct sdio_device_id *id)
  404. {
  405. struct iwmct_priv *priv;
  406. int ret;
  407. int val = 1;
  408. int addr = IWMC_SDIO_INTR_ENABLE_ADDR;
  409. dev_dbg(&func->dev, "enter iwmct_probe\n");
  410. dev_dbg(&func->dev, "IRQ polling period id %u msecs, HZ is %d\n",
  411. jiffies_to_msecs(2147483647), HZ);
  412. priv = kzalloc(sizeof(struct iwmct_priv), GFP_KERNEL);
  413. if (!priv) {
  414. dev_err(&func->dev, "kzalloc error\n");
  415. return -ENOMEM;
  416. }
  417. priv->func = func;
  418. sdio_set_drvdata(func, priv);
  419. /* create drivers work queue */
  420. priv->wq = create_workqueue(DRV_NAME "_wq");
  421. priv->bus_rescan_wq = create_workqueue(DRV_NAME "_rescan_wq");
  422. INIT_WORK(&priv->bus_rescan_worker, iwmct_rescan_worker);
  423. INIT_WORK(&priv->isr_worker, iwmct_irq_read_worker);
  424. init_waitqueue_head(&priv->wait_q);
  425. sdio_claim_host(func);
  426. /* FIXME: Remove after it is fixed in the Boot ROM upgrade */
  427. func->enable_timeout = 10;
  428. /* In our HW, setting the block size also wakes up the boot rom. */
  429. ret = sdio_set_block_size(func, priv->dbg.block_size);
  430. if (ret) {
  431. LOG_ERROR(priv, INIT,
  432. "sdio_set_block_size() failure: %d\n", ret);
  433. goto error_sdio_enable;
  434. }
  435. ret = sdio_enable_func(func);
  436. if (ret) {
  437. LOG_ERROR(priv, INIT, "sdio_enable_func() failure: %d\n", ret);
  438. goto error_sdio_enable;
  439. }
  440. /* init reset and dev_sync states */
  441. atomic_set(&priv->reset, 0);
  442. atomic_set(&priv->dev_sync, 0);
  443. /* init read req queue */
  444. INIT_LIST_HEAD(&priv->read_req_list);
  445. /* process configurable parameters */
  446. iwmct_dbg_init_params(priv);
  447. ret = sysfs_create_group(&func->dev.kobj, &iwmct_attribute_group);
  448. if (ret) {
  449. LOG_ERROR(priv, INIT, "Failed to register attributes and "
  450. "initialize module_params\n");
  451. goto error_dev_attrs;
  452. }
  453. iwmct_dbgfs_register(priv, DRV_NAME);
  454. if (!priv->dbg.direct && priv->dbg.download_trans_blks > 8) {
  455. LOG_INFO(priv, INIT,
  456. "Reducing transaction to 8 blocks = 2K (from %d)\n",
  457. priv->dbg.download_trans_blks);
  458. priv->dbg.download_trans_blks = 8;
  459. }
  460. priv->trans_len = priv->dbg.download_trans_blks * priv->dbg.block_size;
  461. LOG_INFO(priv, INIT, "Transaction length = %d\n", priv->trans_len);
  462. ret = sdio_claim_irq(func, iwmct_irq);
  463. if (ret) {
  464. LOG_ERROR(priv, INIT, "sdio_claim_irq() failure: %d\n", ret);
  465. goto error_claim_irq;
  466. }
  467. /* Enable function's interrupt */
  468. sdio_writeb(priv->func, val, addr, &ret);
  469. if (ret) {
  470. LOG_ERROR(priv, INIT, "Failure writing to "
  471. "Interrupt Enable Register (%d): %d\n", addr, ret);
  472. goto error_enable_int;
  473. }
  474. sdio_release_host(func);
  475. LOG_INFO(priv, INIT, "exit iwmct_probe\n");
  476. return ret;
  477. error_enable_int:
  478. sdio_release_irq(func);
  479. error_claim_irq:
  480. sdio_disable_func(func);
  481. error_dev_attrs:
  482. iwmct_dbgfs_unregister(priv->dbgfs);
  483. sysfs_remove_group(&func->dev.kobj, &iwmct_attribute_group);
  484. error_sdio_enable:
  485. sdio_release_host(func);
  486. return ret;
  487. }
  488. static void iwmct_remove(struct sdio_func *func)
  489. {
  490. struct iwmct_work_struct *read_req;
  491. struct iwmct_priv *priv = sdio_get_drvdata(func);
  492. priv = sdio_get_drvdata(func);
  493. LOG_INFO(priv, INIT, "enter\n");
  494. sdio_claim_host(func);
  495. sdio_release_irq(func);
  496. sdio_release_host(func);
  497. /* Safely destroy osc workqueue */
  498. destroy_workqueue(priv->bus_rescan_wq);
  499. destroy_workqueue(priv->wq);
  500. sdio_claim_host(func);
  501. sdio_disable_func(func);
  502. sysfs_remove_group(&func->dev.kobj, &iwmct_attribute_group);
  503. iwmct_dbgfs_unregister(priv->dbgfs);
  504. sdio_release_host(func);
  505. /* free read requests */
  506. while (!list_empty(&priv->read_req_list)) {
  507. read_req = list_entry(priv->read_req_list.next,
  508. struct iwmct_work_struct, list);
  509. list_del(&read_req->list);
  510. kfree(read_req);
  511. }
  512. kfree(priv);
  513. }
  514. static const struct sdio_device_id iwmct_ids[] = {
  515. /* Intel Wireless MultiCom 3200 Top Driver */
  516. { SDIO_DEVICE(SDIO_VENDOR_ID_INTEL, 0x1404)},
  517. { }, /* Terminating entry */
  518. };
  519. MODULE_DEVICE_TABLE(sdio, iwmct_ids);
  520. static struct sdio_driver iwmct_driver = {
  521. .probe = iwmct_probe,
  522. .remove = iwmct_remove,
  523. .name = DRV_NAME,
  524. .id_table = iwmct_ids,
  525. };
  526. static int __init iwmct_init(void)
  527. {
  528. int rc;
  529. /* Default log filter settings */
  530. iwmct_log_set_filter(LOG_SRC_ALL, LOG_SEV_FILTER_RUNTIME);
  531. iwmct_log_set_filter(LOG_SRC_FW_MSG, LOG_SEV_FILTER_ALL);
  532. iwmct_log_set_fw_filter(LOG_SRC_ALL, FW_LOG_SEV_FILTER_RUNTIME);
  533. rc = sdio_register_driver(&iwmct_driver);
  534. return rc;
  535. }
  536. static void __exit iwmct_exit(void)
  537. {
  538. sdio_unregister_driver(&iwmct_driver);
  539. }
  540. module_init(iwmct_init);
  541. module_exit(iwmct_exit);