htc_hif.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * Copyright (c) 2007-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include "core.h"
  17. #include "target.h"
  18. #include "hif-ops.h"
  19. #include "htc_hif.h"
  20. #include "debug.h"
  21. #define MAILBOX_FOR_BLOCK_SIZE 1
  22. #define ATH6KL_TIME_QUANTUM 10 /* in ms */
  23. static int ath6kldev_cp_scat_dma_buf(struct hif_scatter_req *req, bool from_dma)
  24. {
  25. u8 *buf;
  26. int i;
  27. buf = req->virt_dma_buf;
  28. for (i = 0; i < req->scat_entries; i++) {
  29. if (from_dma)
  30. memcpy(req->scat_list[i].buf, buf,
  31. req->scat_list[i].len);
  32. else
  33. memcpy(buf, req->scat_list[i].buf,
  34. req->scat_list[i].len);
  35. buf += req->scat_list[i].len;
  36. }
  37. return 0;
  38. }
  39. int ath6kldev_rw_comp_handler(void *context, int status)
  40. {
  41. struct htc_packet *packet = context;
  42. ath6kl_dbg(ATH6KL_DBG_HTC_RECV,
  43. "ath6kldev_rw_comp_handler (pkt:0x%p , status: %d\n",
  44. packet, status);
  45. packet->status = status;
  46. packet->completion(packet->context, packet);
  47. return 0;
  48. }
  49. static int ath6kldev_proc_dbg_intr(struct ath6kl_device *dev)
  50. {
  51. u32 dummy;
  52. int status;
  53. ath6kl_err("target debug interrupt\n");
  54. ath6kl_target_failure(dev->ar);
  55. /*
  56. * read counter to clear the interrupt, the debug error interrupt is
  57. * counter 0.
  58. */
  59. status = hif_read_write_sync(dev->ar, COUNT_DEC_ADDRESS,
  60. (u8 *)&dummy, 4, HIF_RD_SYNC_BYTE_INC);
  61. if (status)
  62. WARN_ON(1);
  63. return status;
  64. }
  65. /* mailbox recv message polling */
  66. int ath6kldev_poll_mboxmsg_rx(struct ath6kl_device *dev, u32 *lk_ahd,
  67. int timeout)
  68. {
  69. struct ath6kl_irq_proc_registers *rg;
  70. int status = 0, i;
  71. u8 htc_mbox = 1 << HTC_MAILBOX;
  72. for (i = timeout / ATH6KL_TIME_QUANTUM; i > 0; i--) {
  73. /* this is the standard HIF way, load the reg table */
  74. status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS,
  75. (u8 *) &dev->irq_proc_reg,
  76. sizeof(dev->irq_proc_reg),
  77. HIF_RD_SYNC_BYTE_INC);
  78. if (status) {
  79. ath6kl_err("failed to read reg table\n");
  80. return status;
  81. }
  82. /* check for MBOX data and valid lookahead */
  83. if (dev->irq_proc_reg.host_int_status & htc_mbox) {
  84. if (dev->irq_proc_reg.rx_lkahd_valid &
  85. htc_mbox) {
  86. /*
  87. * Mailbox has a message and the look ahead
  88. * is valid.
  89. */
  90. rg = &dev->irq_proc_reg;
  91. *lk_ahd =
  92. le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]);
  93. break;
  94. }
  95. }
  96. /* delay a little */
  97. mdelay(ATH6KL_TIME_QUANTUM);
  98. ath6kl_dbg(ATH6KL_DBG_HTC_RECV, "retry mbox poll : %d\n", i);
  99. }
  100. if (i == 0) {
  101. ath6kl_err("timeout waiting for recv message\n");
  102. status = -ETIME;
  103. /* check if the target asserted */
  104. if (dev->irq_proc_reg.counter_int_status &
  105. ATH6KL_TARGET_DEBUG_INTR_MASK)
  106. /*
  107. * Target failure handler will be called in case of
  108. * an assert.
  109. */
  110. ath6kldev_proc_dbg_intr(dev);
  111. }
  112. return status;
  113. }
  114. /*
  115. * Disable packet reception (used in case the host runs out of buffers)
  116. * using the interrupt enable registers through the host I/F
  117. */
  118. int ath6kldev_rx_control(struct ath6kl_device *dev, bool enable_rx)
  119. {
  120. struct ath6kl_irq_enable_reg regs;
  121. int status = 0;
  122. /* take the lock to protect interrupt enable shadows */
  123. spin_lock_bh(&dev->lock);
  124. if (enable_rx)
  125. dev->irq_en_reg.int_status_en |=
  126. SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01);
  127. else
  128. dev->irq_en_reg.int_status_en &=
  129. ~SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01);
  130. memcpy(&regs, &dev->irq_en_reg, sizeof(regs));
  131. spin_unlock_bh(&dev->lock);
  132. status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS,
  133. &regs.int_status_en,
  134. sizeof(struct ath6kl_irq_enable_reg),
  135. HIF_WR_SYNC_BYTE_INC);
  136. return status;
  137. }
  138. int ath6kldev_submit_scat_req(struct ath6kl_device *dev,
  139. struct hif_scatter_req *scat_req, bool read)
  140. {
  141. int status = 0;
  142. if (read) {
  143. scat_req->req = HIF_RD_SYNC_BLOCK_FIX;
  144. scat_req->addr = dev->ar->mbox_info.htc_addr;
  145. } else {
  146. scat_req->req = HIF_WR_ASYNC_BLOCK_INC;
  147. scat_req->addr =
  148. (scat_req->len > HIF_MBOX_WIDTH) ?
  149. dev->ar->mbox_info.htc_ext_addr :
  150. dev->ar->mbox_info.htc_addr;
  151. }
  152. ath6kl_dbg((ATH6KL_DBG_HTC_RECV | ATH6KL_DBG_HTC_SEND),
  153. "ath6kldev_submit_scat_req, entries: %d, total len: %d mbox:0x%X (mode: %s : %s)\n",
  154. scat_req->scat_entries, scat_req->len,
  155. scat_req->addr, !read ? "async" : "sync",
  156. (read) ? "rd" : "wr");
  157. if (!read && scat_req->virt_scat)
  158. status = ath6kldev_cp_scat_dma_buf(scat_req, false);
  159. if (status) {
  160. if (!read) {
  161. scat_req->status = status;
  162. scat_req->complete(dev->ar->htc_target, scat_req);
  163. return 0;
  164. }
  165. return status;
  166. }
  167. status = ath6kl_hif_scat_req_rw(dev->ar, scat_req);
  168. if (read) {
  169. /* in sync mode, we can touch the scatter request */
  170. scat_req->status = status;
  171. if (!status && scat_req->virt_scat)
  172. scat_req->status =
  173. ath6kldev_cp_scat_dma_buf(scat_req, true);
  174. }
  175. return status;
  176. }
  177. int ath6kldev_setup_msg_bndl(struct ath6kl_device *dev, int max_msg_per_trans)
  178. {
  179. return ath6kl_hif_enable_scatter(dev->ar, &dev->hif_scat_info);
  180. }
  181. static int ath6kldev_proc_counter_intr(struct ath6kl_device *dev)
  182. {
  183. u8 counter_int_status;
  184. ath6kl_dbg(ATH6KL_DBG_IRQ, "counter interrupt\n");
  185. counter_int_status = dev->irq_proc_reg.counter_int_status &
  186. dev->irq_en_reg.cntr_int_status_en;
  187. ath6kl_dbg(ATH6KL_DBG_IRQ,
  188. "valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n",
  189. counter_int_status);
  190. /*
  191. * NOTE: other modules like GMBOX may use the counter interrupt for
  192. * credit flow control on other counters, we only need to check for
  193. * the debug assertion counter interrupt.
  194. */
  195. if (counter_int_status & ATH6KL_TARGET_DEBUG_INTR_MASK)
  196. return ath6kldev_proc_dbg_intr(dev);
  197. return 0;
  198. }
  199. static int ath6kldev_proc_err_intr(struct ath6kl_device *dev)
  200. {
  201. int status;
  202. u8 error_int_status;
  203. u8 reg_buf[4];
  204. ath6kl_dbg(ATH6KL_DBG_IRQ, "error interrupt\n");
  205. error_int_status = dev->irq_proc_reg.error_int_status & 0x0F;
  206. if (!error_int_status) {
  207. WARN_ON(1);
  208. return -EIO;
  209. }
  210. ath6kl_dbg(ATH6KL_DBG_IRQ,
  211. "valid interrupt source(s) in ERROR_INT_STATUS: 0x%x\n",
  212. error_int_status);
  213. if (MS(ERROR_INT_STATUS_WAKEUP, error_int_status))
  214. ath6kl_dbg(ATH6KL_DBG_IRQ, "error : wakeup\n");
  215. if (MS(ERROR_INT_STATUS_RX_UNDERFLOW, error_int_status))
  216. ath6kl_err("rx underflow\n");
  217. if (MS(ERROR_INT_STATUS_TX_OVERFLOW, error_int_status))
  218. ath6kl_err("tx overflow\n");
  219. /* Clear the interrupt */
  220. dev->irq_proc_reg.error_int_status &= ~error_int_status;
  221. /* set W1C value to clear the interrupt, this hits the register first */
  222. reg_buf[0] = error_int_status;
  223. reg_buf[1] = 0;
  224. reg_buf[2] = 0;
  225. reg_buf[3] = 0;
  226. status = hif_read_write_sync(dev->ar, ERROR_INT_STATUS_ADDRESS,
  227. reg_buf, 4, HIF_WR_SYNC_BYTE_FIX);
  228. if (status)
  229. WARN_ON(1);
  230. return status;
  231. }
  232. static int ath6kldev_proc_cpu_intr(struct ath6kl_device *dev)
  233. {
  234. int status;
  235. u8 cpu_int_status;
  236. u8 reg_buf[4];
  237. ath6kl_dbg(ATH6KL_DBG_IRQ, "cpu interrupt\n");
  238. cpu_int_status = dev->irq_proc_reg.cpu_int_status &
  239. dev->irq_en_reg.cpu_int_status_en;
  240. if (!cpu_int_status) {
  241. WARN_ON(1);
  242. return -EIO;
  243. }
  244. ath6kl_dbg(ATH6KL_DBG_IRQ,
  245. "valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n",
  246. cpu_int_status);
  247. /* Clear the interrupt */
  248. dev->irq_proc_reg.cpu_int_status &= ~cpu_int_status;
  249. /*
  250. * Set up the register transfer buffer to hit the register 4 times ,
  251. * this is done to make the access 4-byte aligned to mitigate issues
  252. * with host bus interconnects that restrict bus transfer lengths to
  253. * be a multiple of 4-bytes.
  254. */
  255. /* set W1C value to clear the interrupt, this hits the register first */
  256. reg_buf[0] = cpu_int_status;
  257. /* the remaining are set to zero which have no-effect */
  258. reg_buf[1] = 0;
  259. reg_buf[2] = 0;
  260. reg_buf[3] = 0;
  261. status = hif_read_write_sync(dev->ar, CPU_INT_STATUS_ADDRESS,
  262. reg_buf, 4, HIF_WR_SYNC_BYTE_FIX);
  263. if (status)
  264. WARN_ON(1);
  265. return status;
  266. }
  267. /* process pending interrupts synchronously */
  268. static int proc_pending_irqs(struct ath6kl_device *dev, bool *done)
  269. {
  270. struct ath6kl_irq_proc_registers *rg;
  271. int status = 0;
  272. u8 host_int_status = 0;
  273. u32 lk_ahd = 0;
  274. u8 htc_mbox = 1 << HTC_MAILBOX;
  275. ath6kl_dbg(ATH6KL_DBG_IRQ, "proc_pending_irqs: (dev: 0x%p)\n", dev);
  276. /*
  277. * NOTE: HIF implementation guarantees that the context of this
  278. * call allows us to perform SYNCHRONOUS I/O, that is we can block,
  279. * sleep or call any API that can block or switch thread/task
  280. * contexts. This is a fully schedulable context.
  281. */
  282. /*
  283. * Process pending intr only when int_status_en is clear, it may
  284. * result in unnecessary bus transaction otherwise. Target may be
  285. * unresponsive at the time.
  286. */
  287. if (dev->irq_en_reg.int_status_en) {
  288. /*
  289. * Read the first 28 bytes of the HTC register table. This
  290. * will yield us the value of different int status
  291. * registers and the lookahead registers.
  292. *
  293. * length = sizeof(int_status) + sizeof(cpu_int_status)
  294. * + sizeof(error_int_status) +
  295. * sizeof(counter_int_status) +
  296. * sizeof(mbox_frame) + sizeof(rx_lkahd_valid)
  297. * + sizeof(hole) + sizeof(rx_lkahd) +
  298. * sizeof(int_status_en) +
  299. * sizeof(cpu_int_status_en) +
  300. * sizeof(err_int_status_en) +
  301. * sizeof(cntr_int_status_en);
  302. */
  303. status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS,
  304. (u8 *) &dev->irq_proc_reg,
  305. sizeof(dev->irq_proc_reg),
  306. HIF_RD_SYNC_BYTE_INC);
  307. if (status)
  308. goto out;
  309. if (AR_DBG_LVL_CHECK(ATH6KL_DBG_IRQ))
  310. ath6kl_dump_registers(dev, &dev->irq_proc_reg,
  311. &dev->irq_en_reg);
  312. /* Update only those registers that are enabled */
  313. host_int_status = dev->irq_proc_reg.host_int_status &
  314. dev->irq_en_reg.int_status_en;
  315. /* Look at mbox status */
  316. if (host_int_status & htc_mbox) {
  317. /*
  318. * Mask out pending mbox value, we use "lookAhead as
  319. * the real flag for mbox processing.
  320. */
  321. host_int_status &= ~htc_mbox;
  322. if (dev->irq_proc_reg.rx_lkahd_valid &
  323. htc_mbox) {
  324. rg = &dev->irq_proc_reg;
  325. lk_ahd = le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]);
  326. if (!lk_ahd)
  327. ath6kl_err("lookAhead is zero!\n");
  328. }
  329. }
  330. }
  331. if (!host_int_status && !lk_ahd) {
  332. *done = true;
  333. goto out;
  334. }
  335. if (lk_ahd) {
  336. int fetched = 0;
  337. ath6kl_dbg(ATH6KL_DBG_IRQ,
  338. "pending mailbox msg, lk_ahd: 0x%X\n", lk_ahd);
  339. /*
  340. * Mailbox Interrupt, the HTC layer may issue async
  341. * requests to empty the mailbox. When emptying the recv
  342. * mailbox we use the async handler above called from the
  343. * completion routine of the callers read request. This can
  344. * improve performance by reducing context switching when
  345. * we rapidly pull packets.
  346. */
  347. status = dev->msg_pending(dev->htc_cnxt, &lk_ahd, &fetched);
  348. if (status)
  349. goto out;
  350. if (!fetched)
  351. /*
  352. * HTC could not pull any messages out due to lack
  353. * of resources.
  354. */
  355. dev->chk_irq_status_cnt = 0;
  356. }
  357. /* now handle the rest of them */
  358. ath6kl_dbg(ATH6KL_DBG_IRQ,
  359. "valid interrupt source(s) for other interrupts: 0x%x\n",
  360. host_int_status);
  361. if (MS(HOST_INT_STATUS_CPU, host_int_status)) {
  362. /* CPU Interrupt */
  363. status = ath6kldev_proc_cpu_intr(dev);
  364. if (status)
  365. goto out;
  366. }
  367. if (MS(HOST_INT_STATUS_ERROR, host_int_status)) {
  368. /* Error Interrupt */
  369. status = ath6kldev_proc_err_intr(dev);
  370. if (status)
  371. goto out;
  372. }
  373. if (MS(HOST_INT_STATUS_COUNTER, host_int_status))
  374. /* Counter Interrupt */
  375. status = ath6kldev_proc_counter_intr(dev);
  376. out:
  377. /*
  378. * An optimization to bypass reading the IRQ status registers
  379. * unecessarily which can re-wake the target, if upper layers
  380. * determine that we are in a low-throughput mode, we can rely on
  381. * taking another interrupt rather than re-checking the status
  382. * registers which can re-wake the target.
  383. *
  384. * NOTE : for host interfaces that makes use of detecting pending
  385. * mbox messages at hif can not use this optimization due to
  386. * possible side effects, SPI requires the host to drain all
  387. * messages from the mailbox before exiting the ISR routine.
  388. */
  389. ath6kl_dbg(ATH6KL_DBG_IRQ,
  390. "bypassing irq status re-check, forcing done\n");
  391. *done = true;
  392. ath6kl_dbg(ATH6KL_DBG_IRQ,
  393. "proc_pending_irqs: (done:%d, status=%d\n", *done, status);
  394. return status;
  395. }
  396. /* interrupt handler, kicks off all interrupt processing */
  397. int ath6kldev_intr_bh_handler(struct ath6kl *ar)
  398. {
  399. struct ath6kl_device *dev = ar->htc_target->dev;
  400. int status = 0;
  401. bool done = false;
  402. /*
  403. * Reset counter used to flag a re-scan of IRQ status registers on
  404. * the target.
  405. */
  406. dev->chk_irq_status_cnt = 0;
  407. /*
  408. * IRQ processing is synchronous, interrupt status registers can be
  409. * re-read.
  410. */
  411. while (!done) {
  412. status = proc_pending_irqs(dev, &done);
  413. if (status)
  414. break;
  415. }
  416. return status;
  417. }
  418. static int ath6kldev_enable_intrs(struct ath6kl_device *dev)
  419. {
  420. struct ath6kl_irq_enable_reg regs;
  421. int status;
  422. spin_lock_bh(&dev->lock);
  423. /* Enable all but ATH6KL CPU interrupts */
  424. dev->irq_en_reg.int_status_en =
  425. SM(INT_STATUS_ENABLE_ERROR, 0x01) |
  426. SM(INT_STATUS_ENABLE_CPU, 0x01) |
  427. SM(INT_STATUS_ENABLE_COUNTER, 0x01);
  428. /*
  429. * NOTE: There are some cases where HIF can do detection of
  430. * pending mbox messages which is disabled now.
  431. */
  432. dev->irq_en_reg.int_status_en |= SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01);
  433. /* Set up the CPU Interrupt status Register */
  434. dev->irq_en_reg.cpu_int_status_en = 0;
  435. /* Set up the Error Interrupt status Register */
  436. dev->irq_en_reg.err_int_status_en =
  437. SM(ERROR_STATUS_ENABLE_RX_UNDERFLOW, 0x01) |
  438. SM(ERROR_STATUS_ENABLE_TX_OVERFLOW, 0x1);
  439. /*
  440. * Enable Counter interrupt status register to get fatal errors for
  441. * debugging.
  442. */
  443. dev->irq_en_reg.cntr_int_status_en = SM(COUNTER_INT_STATUS_ENABLE_BIT,
  444. ATH6KL_TARGET_DEBUG_INTR_MASK);
  445. memcpy(&regs, &dev->irq_en_reg, sizeof(regs));
  446. spin_unlock_bh(&dev->lock);
  447. status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS,
  448. &regs.int_status_en, sizeof(regs),
  449. HIF_WR_SYNC_BYTE_INC);
  450. if (status)
  451. ath6kl_err("failed to update interrupt ctl reg err: %d\n",
  452. status);
  453. return status;
  454. }
  455. int ath6kldev_disable_intrs(struct ath6kl_device *dev)
  456. {
  457. struct ath6kl_irq_enable_reg regs;
  458. spin_lock_bh(&dev->lock);
  459. /* Disable all interrupts */
  460. dev->irq_en_reg.int_status_en = 0;
  461. dev->irq_en_reg.cpu_int_status_en = 0;
  462. dev->irq_en_reg.err_int_status_en = 0;
  463. dev->irq_en_reg.cntr_int_status_en = 0;
  464. memcpy(&regs, &dev->irq_en_reg, sizeof(regs));
  465. spin_unlock_bh(&dev->lock);
  466. return hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS,
  467. &regs.int_status_en, sizeof(regs),
  468. HIF_WR_SYNC_BYTE_INC);
  469. }
  470. /* enable device interrupts */
  471. int ath6kldev_unmask_intrs(struct ath6kl_device *dev)
  472. {
  473. int status = 0;
  474. /*
  475. * Make sure interrupt are disabled before unmasking at the HIF
  476. * layer. The rationale here is that between device insertion
  477. * (where we clear the interrupts the first time) and when HTC
  478. * is finally ready to handle interrupts, other software can perform
  479. * target "soft" resets. The ATH6KL interrupt enables reset back to an
  480. * "enabled" state when this happens.
  481. */
  482. ath6kldev_disable_intrs(dev);
  483. /* unmask the host controller interrupts */
  484. ath6kl_hif_irq_enable(dev->ar);
  485. status = ath6kldev_enable_intrs(dev);
  486. return status;
  487. }
  488. /* disable all device interrupts */
  489. int ath6kldev_mask_intrs(struct ath6kl_device *dev)
  490. {
  491. /*
  492. * Mask the interrupt at the HIF layer to avoid any stray interrupt
  493. * taken while we zero out our shadow registers in
  494. * ath6kldev_disable_intrs().
  495. */
  496. ath6kl_hif_irq_disable(dev->ar);
  497. return ath6kldev_disable_intrs(dev);
  498. }
  499. int ath6kldev_setup(struct ath6kl_device *dev)
  500. {
  501. int status = 0;
  502. spin_lock_init(&dev->lock);
  503. /*
  504. * NOTE: we actually get the block size of a mailbox other than 0,
  505. * for SDIO the block size on mailbox 0 is artificially set to 1.
  506. * So we use the block size that is set for the other 3 mailboxes.
  507. */
  508. dev->block_sz = dev->ar->mbox_info.block_size;
  509. /* must be a power of 2 */
  510. if ((dev->block_sz & (dev->block_sz - 1)) != 0) {
  511. WARN_ON(1);
  512. goto fail_setup;
  513. }
  514. /* assemble mask, used for padding to a block */
  515. dev->block_mask = dev->block_sz - 1;
  516. ath6kl_dbg(ATH6KL_DBG_TRC, "block size: %d, mbox addr:0x%X\n",
  517. dev->block_sz, dev->ar->mbox_info.htc_addr);
  518. ath6kl_dbg(ATH6KL_DBG_TRC,
  519. "hif interrupt processing is sync only\n");
  520. status = ath6kldev_disable_intrs(dev);
  521. fail_setup:
  522. return status;
  523. }