hif.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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 "hif.h"
  17. #include "core.h"
  18. #include "target.h"
  19. #include "hif-ops.h"
  20. #include "debug.h"
  21. #define MAILBOX_FOR_BLOCK_SIZE 1
  22. #define ATH6KL_TIME_QUANTUM 10 /* in ms */
  23. static int ath6kl_hif_cp_scat_dma_buf(struct hif_scatter_req *req,
  24. bool from_dma)
  25. {
  26. u8 *buf;
  27. int i;
  28. buf = req->virt_dma_buf;
  29. for (i = 0; i < req->scat_entries; i++) {
  30. if (from_dma)
  31. memcpy(req->scat_list[i].buf, buf,
  32. req->scat_list[i].len);
  33. else
  34. memcpy(buf, req->scat_list[i].buf,
  35. req->scat_list[i].len);
  36. buf += req->scat_list[i].len;
  37. }
  38. return 0;
  39. }
  40. int ath6kl_hif_rw_comp_handler(void *context, int status)
  41. {
  42. struct htc_packet *packet = context;
  43. ath6kl_dbg(ATH6KL_DBG_HIF, "hif rw completion 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 ath6kl_hif_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 ath6kl_hif_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_HIF, "hif retry mbox poll try %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. ath6kl_hif_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 ath6kl_hif_rx_control(struct ath6kl_device *dev, bool enable_rx)
  119. {
  120. struct ath6kl_irq_enable_reg regs;
  121. int status = 0;
  122. ath6kl_dbg(ATH6KL_DBG_HIF, "hif rx %s\n",
  123. enable_rx ? "enable" : "disable");
  124. /* take the lock to protect interrupt enable shadows */
  125. spin_lock_bh(&dev->lock);
  126. if (enable_rx)
  127. dev->irq_en_reg.int_status_en |=
  128. SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01);
  129. else
  130. dev->irq_en_reg.int_status_en &=
  131. ~SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01);
  132. memcpy(&regs, &dev->irq_en_reg, sizeof(regs));
  133. spin_unlock_bh(&dev->lock);
  134. status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS,
  135. &regs.int_status_en,
  136. sizeof(struct ath6kl_irq_enable_reg),
  137. HIF_WR_SYNC_BYTE_INC);
  138. return status;
  139. }
  140. int ath6kl_hif_submit_scat_req(struct ath6kl_device *dev,
  141. struct hif_scatter_req *scat_req, bool read)
  142. {
  143. int status = 0;
  144. if (read) {
  145. scat_req->req = HIF_RD_SYNC_BLOCK_FIX;
  146. scat_req->addr = dev->ar->mbox_info.htc_addr;
  147. } else {
  148. scat_req->req = HIF_WR_ASYNC_BLOCK_INC;
  149. scat_req->addr =
  150. (scat_req->len > HIF_MBOX_WIDTH) ?
  151. dev->ar->mbox_info.htc_ext_addr :
  152. dev->ar->mbox_info.htc_addr;
  153. }
  154. ath6kl_dbg(ATH6KL_DBG_HIF,
  155. "hif submit scatter request entries %d len %d mbox 0x%x %s %s\n",
  156. scat_req->scat_entries, scat_req->len,
  157. scat_req->addr, !read ? "async" : "sync",
  158. (read) ? "rd" : "wr");
  159. if (!read && scat_req->virt_scat) {
  160. status = ath6kl_hif_cp_scat_dma_buf(scat_req, false);
  161. if (status) {
  162. scat_req->status = status;
  163. scat_req->complete(dev->ar->htc_target, scat_req);
  164. return 0;
  165. }
  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. ath6kl_hif_cp_scat_dma_buf(scat_req, true);
  174. }
  175. return status;
  176. }
  177. static int ath6kl_hif_proc_counter_intr(struct ath6kl_device *dev)
  178. {
  179. u8 counter_int_status;
  180. ath6kl_dbg(ATH6KL_DBG_IRQ, "counter interrupt\n");
  181. counter_int_status = dev->irq_proc_reg.counter_int_status &
  182. dev->irq_en_reg.cntr_int_status_en;
  183. ath6kl_dbg(ATH6KL_DBG_IRQ,
  184. "valid interrupt source(s) in COUNTER_INT_STATUS: 0x%x\n",
  185. counter_int_status);
  186. /*
  187. * NOTE: other modules like GMBOX may use the counter interrupt for
  188. * credit flow control on other counters, we only need to check for
  189. * the debug assertion counter interrupt.
  190. */
  191. if (counter_int_status & ATH6KL_TARGET_DEBUG_INTR_MASK)
  192. return ath6kl_hif_proc_dbg_intr(dev);
  193. return 0;
  194. }
  195. static int ath6kl_hif_proc_err_intr(struct ath6kl_device *dev)
  196. {
  197. int status;
  198. u8 error_int_status;
  199. u8 reg_buf[4];
  200. ath6kl_dbg(ATH6KL_DBG_IRQ, "error interrupt\n");
  201. error_int_status = dev->irq_proc_reg.error_int_status & 0x0F;
  202. if (!error_int_status) {
  203. WARN_ON(1);
  204. return -EIO;
  205. }
  206. ath6kl_dbg(ATH6KL_DBG_IRQ,
  207. "valid interrupt source(s) in ERROR_INT_STATUS: 0x%x\n",
  208. error_int_status);
  209. if (MS(ERROR_INT_STATUS_WAKEUP, error_int_status))
  210. ath6kl_dbg(ATH6KL_DBG_IRQ, "error : wakeup\n");
  211. if (MS(ERROR_INT_STATUS_RX_UNDERFLOW, error_int_status))
  212. ath6kl_err("rx underflow\n");
  213. if (MS(ERROR_INT_STATUS_TX_OVERFLOW, error_int_status))
  214. ath6kl_err("tx overflow\n");
  215. /* Clear the interrupt */
  216. dev->irq_proc_reg.error_int_status &= ~error_int_status;
  217. /* set W1C value to clear the interrupt, this hits the register first */
  218. reg_buf[0] = error_int_status;
  219. reg_buf[1] = 0;
  220. reg_buf[2] = 0;
  221. reg_buf[3] = 0;
  222. status = hif_read_write_sync(dev->ar, ERROR_INT_STATUS_ADDRESS,
  223. reg_buf, 4, HIF_WR_SYNC_BYTE_FIX);
  224. if (status)
  225. WARN_ON(1);
  226. return status;
  227. }
  228. static int ath6kl_hif_proc_cpu_intr(struct ath6kl_device *dev)
  229. {
  230. int status;
  231. u8 cpu_int_status;
  232. u8 reg_buf[4];
  233. ath6kl_dbg(ATH6KL_DBG_IRQ, "cpu interrupt\n");
  234. cpu_int_status = dev->irq_proc_reg.cpu_int_status &
  235. dev->irq_en_reg.cpu_int_status_en;
  236. if (!cpu_int_status) {
  237. WARN_ON(1);
  238. return -EIO;
  239. }
  240. ath6kl_dbg(ATH6KL_DBG_IRQ,
  241. "valid interrupt source(s) in CPU_INT_STATUS: 0x%x\n",
  242. cpu_int_status);
  243. /* Clear the interrupt */
  244. dev->irq_proc_reg.cpu_int_status &= ~cpu_int_status;
  245. /*
  246. * Set up the register transfer buffer to hit the register 4 times ,
  247. * this is done to make the access 4-byte aligned to mitigate issues
  248. * with host bus interconnects that restrict bus transfer lengths to
  249. * be a multiple of 4-bytes.
  250. */
  251. /* set W1C value to clear the interrupt, this hits the register first */
  252. reg_buf[0] = cpu_int_status;
  253. /* the remaining are set to zero which have no-effect */
  254. reg_buf[1] = 0;
  255. reg_buf[2] = 0;
  256. reg_buf[3] = 0;
  257. status = hif_read_write_sync(dev->ar, CPU_INT_STATUS_ADDRESS,
  258. reg_buf, 4, HIF_WR_SYNC_BYTE_FIX);
  259. if (status)
  260. WARN_ON(1);
  261. return status;
  262. }
  263. /* process pending interrupts synchronously */
  264. static int proc_pending_irqs(struct ath6kl_device *dev, bool *done)
  265. {
  266. struct ath6kl_irq_proc_registers *rg;
  267. int status = 0;
  268. u8 host_int_status = 0;
  269. u32 lk_ahd = 0;
  270. u8 htc_mbox = 1 << HTC_MAILBOX;
  271. ath6kl_dbg(ATH6KL_DBG_IRQ, "proc_pending_irqs: (dev: 0x%p)\n", dev);
  272. /*
  273. * NOTE: HIF implementation guarantees that the context of this
  274. * call allows us to perform SYNCHRONOUS I/O, that is we can block,
  275. * sleep or call any API that can block or switch thread/task
  276. * contexts. This is a fully schedulable context.
  277. */
  278. /*
  279. * Process pending intr only when int_status_en is clear, it may
  280. * result in unnecessary bus transaction otherwise. Target may be
  281. * unresponsive at the time.
  282. */
  283. if (dev->irq_en_reg.int_status_en) {
  284. /*
  285. * Read the first 28 bytes of the HTC register table. This
  286. * will yield us the value of different int status
  287. * registers and the lookahead registers.
  288. *
  289. * length = sizeof(int_status) + sizeof(cpu_int_status)
  290. * + sizeof(error_int_status) +
  291. * sizeof(counter_int_status) +
  292. * sizeof(mbox_frame) + sizeof(rx_lkahd_valid)
  293. * + sizeof(hole) + sizeof(rx_lkahd) +
  294. * sizeof(int_status_en) +
  295. * sizeof(cpu_int_status_en) +
  296. * sizeof(err_int_status_en) +
  297. * sizeof(cntr_int_status_en);
  298. */
  299. status = hif_read_write_sync(dev->ar, HOST_INT_STATUS_ADDRESS,
  300. (u8 *) &dev->irq_proc_reg,
  301. sizeof(dev->irq_proc_reg),
  302. HIF_RD_SYNC_BYTE_INC);
  303. if (status)
  304. goto out;
  305. if (AR_DBG_LVL_CHECK(ATH6KL_DBG_IRQ))
  306. ath6kl_dump_registers(dev, &dev->irq_proc_reg,
  307. &dev->irq_en_reg);
  308. /* Update only those registers that are enabled */
  309. host_int_status = dev->irq_proc_reg.host_int_status &
  310. dev->irq_en_reg.int_status_en;
  311. /* Look at mbox status */
  312. if (host_int_status & htc_mbox) {
  313. /*
  314. * Mask out pending mbox value, we use "lookAhead as
  315. * the real flag for mbox processing.
  316. */
  317. host_int_status &= ~htc_mbox;
  318. if (dev->irq_proc_reg.rx_lkahd_valid &
  319. htc_mbox) {
  320. rg = &dev->irq_proc_reg;
  321. lk_ahd = le32_to_cpu(rg->rx_lkahd[HTC_MAILBOX]);
  322. if (!lk_ahd)
  323. ath6kl_err("lookAhead is zero!\n");
  324. }
  325. }
  326. }
  327. if (!host_int_status && !lk_ahd) {
  328. *done = true;
  329. goto out;
  330. }
  331. if (lk_ahd) {
  332. int fetched = 0;
  333. ath6kl_dbg(ATH6KL_DBG_IRQ,
  334. "pending mailbox msg, lk_ahd: 0x%X\n", lk_ahd);
  335. /*
  336. * Mailbox Interrupt, the HTC layer may issue async
  337. * requests to empty the mailbox. When emptying the recv
  338. * mailbox we use the async handler above called from the
  339. * completion routine of the callers read request. This can
  340. * improve performance by reducing context switching when
  341. * we rapidly pull packets.
  342. */
  343. status = ath6kl_htc_rxmsg_pending_handler(dev->htc_cnxt,
  344. lk_ahd, &fetched);
  345. if (status)
  346. goto out;
  347. if (!fetched)
  348. /*
  349. * HTC could not pull any messages out due to lack
  350. * of resources.
  351. */
  352. dev->htc_cnxt->chk_irq_status_cnt = 0;
  353. }
  354. /* now handle the rest of them */
  355. ath6kl_dbg(ATH6KL_DBG_IRQ,
  356. "valid interrupt source(s) for other interrupts: 0x%x\n",
  357. host_int_status);
  358. if (MS(HOST_INT_STATUS_CPU, host_int_status)) {
  359. /* CPU Interrupt */
  360. status = ath6kl_hif_proc_cpu_intr(dev);
  361. if (status)
  362. goto out;
  363. }
  364. if (MS(HOST_INT_STATUS_ERROR, host_int_status)) {
  365. /* Error Interrupt */
  366. status = ath6kl_hif_proc_err_intr(dev);
  367. if (status)
  368. goto out;
  369. }
  370. if (MS(HOST_INT_STATUS_COUNTER, host_int_status))
  371. /* Counter Interrupt */
  372. status = ath6kl_hif_proc_counter_intr(dev);
  373. out:
  374. /*
  375. * An optimization to bypass reading the IRQ status registers
  376. * unecessarily which can re-wake the target, if upper layers
  377. * determine that we are in a low-throughput mode, we can rely on
  378. * taking another interrupt rather than re-checking the status
  379. * registers which can re-wake the target.
  380. *
  381. * NOTE : for host interfaces that makes use of detecting pending
  382. * mbox messages at hif can not use this optimization due to
  383. * possible side effects, SPI requires the host to drain all
  384. * messages from the mailbox before exiting the ISR routine.
  385. */
  386. ath6kl_dbg(ATH6KL_DBG_IRQ,
  387. "bypassing irq status re-check, forcing done\n");
  388. if (!dev->htc_cnxt->chk_irq_status_cnt)
  389. *done = true;
  390. ath6kl_dbg(ATH6KL_DBG_IRQ,
  391. "proc_pending_irqs: (done:%d, status=%d\n", *done, status);
  392. return status;
  393. }
  394. /* interrupt handler, kicks off all interrupt processing */
  395. int ath6kl_hif_intr_bh_handler(struct ath6kl *ar)
  396. {
  397. struct ath6kl_device *dev = ar->htc_target->dev;
  398. int status = 0;
  399. bool done = false;
  400. /*
  401. * Reset counter used to flag a re-scan of IRQ status registers on
  402. * the target.
  403. */
  404. dev->htc_cnxt->chk_irq_status_cnt = 0;
  405. /*
  406. * IRQ processing is synchronous, interrupt status registers can be
  407. * re-read.
  408. */
  409. while (!done) {
  410. status = proc_pending_irqs(dev, &done);
  411. if (status)
  412. break;
  413. }
  414. return status;
  415. }
  416. static int ath6kl_hif_enable_intrs(struct ath6kl_device *dev)
  417. {
  418. struct ath6kl_irq_enable_reg regs;
  419. int status;
  420. spin_lock_bh(&dev->lock);
  421. /* Enable all but ATH6KL CPU interrupts */
  422. dev->irq_en_reg.int_status_en =
  423. SM(INT_STATUS_ENABLE_ERROR, 0x01) |
  424. SM(INT_STATUS_ENABLE_CPU, 0x01) |
  425. SM(INT_STATUS_ENABLE_COUNTER, 0x01);
  426. /*
  427. * NOTE: There are some cases where HIF can do detection of
  428. * pending mbox messages which is disabled now.
  429. */
  430. dev->irq_en_reg.int_status_en |= SM(INT_STATUS_ENABLE_MBOX_DATA, 0x01);
  431. /* Set up the CPU Interrupt status Register */
  432. dev->irq_en_reg.cpu_int_status_en = 0;
  433. /* Set up the Error Interrupt status Register */
  434. dev->irq_en_reg.err_int_status_en =
  435. SM(ERROR_STATUS_ENABLE_RX_UNDERFLOW, 0x01) |
  436. SM(ERROR_STATUS_ENABLE_TX_OVERFLOW, 0x1);
  437. /*
  438. * Enable Counter interrupt status register to get fatal errors for
  439. * debugging.
  440. */
  441. dev->irq_en_reg.cntr_int_status_en = SM(COUNTER_INT_STATUS_ENABLE_BIT,
  442. ATH6KL_TARGET_DEBUG_INTR_MASK);
  443. memcpy(&regs, &dev->irq_en_reg, sizeof(regs));
  444. spin_unlock_bh(&dev->lock);
  445. status = hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS,
  446. &regs.int_status_en, sizeof(regs),
  447. HIF_WR_SYNC_BYTE_INC);
  448. if (status)
  449. ath6kl_err("failed to update interrupt ctl reg err: %d\n",
  450. status);
  451. return status;
  452. }
  453. int ath6kl_hif_disable_intrs(struct ath6kl_device *dev)
  454. {
  455. struct ath6kl_irq_enable_reg regs;
  456. spin_lock_bh(&dev->lock);
  457. /* Disable all interrupts */
  458. dev->irq_en_reg.int_status_en = 0;
  459. dev->irq_en_reg.cpu_int_status_en = 0;
  460. dev->irq_en_reg.err_int_status_en = 0;
  461. dev->irq_en_reg.cntr_int_status_en = 0;
  462. memcpy(&regs, &dev->irq_en_reg, sizeof(regs));
  463. spin_unlock_bh(&dev->lock);
  464. return hif_read_write_sync(dev->ar, INT_STATUS_ENABLE_ADDRESS,
  465. &regs.int_status_en, sizeof(regs),
  466. HIF_WR_SYNC_BYTE_INC);
  467. }
  468. /* enable device interrupts */
  469. int ath6kl_hif_unmask_intrs(struct ath6kl_device *dev)
  470. {
  471. int status = 0;
  472. /*
  473. * Make sure interrupt are disabled before unmasking at the HIF
  474. * layer. The rationale here is that between device insertion
  475. * (where we clear the interrupts the first time) and when HTC
  476. * is finally ready to handle interrupts, other software can perform
  477. * target "soft" resets. The ATH6KL interrupt enables reset back to an
  478. * "enabled" state when this happens.
  479. */
  480. ath6kl_hif_disable_intrs(dev);
  481. /* unmask the host controller interrupts */
  482. ath6kl_hif_irq_enable(dev->ar);
  483. status = ath6kl_hif_enable_intrs(dev);
  484. return status;
  485. }
  486. /* disable all device interrupts */
  487. int ath6kl_hif_mask_intrs(struct ath6kl_device *dev)
  488. {
  489. /*
  490. * Mask the interrupt at the HIF layer to avoid any stray interrupt
  491. * taken while we zero out our shadow registers in
  492. * ath6kl_hif_disable_intrs().
  493. */
  494. ath6kl_hif_irq_disable(dev->ar);
  495. return ath6kl_hif_disable_intrs(dev);
  496. }
  497. int ath6kl_hif_setup(struct ath6kl_device *dev)
  498. {
  499. int status = 0;
  500. spin_lock_init(&dev->lock);
  501. /*
  502. * NOTE: we actually get the block size of a mailbox other than 0,
  503. * for SDIO the block size on mailbox 0 is artificially set to 1.
  504. * So we use the block size that is set for the other 3 mailboxes.
  505. */
  506. dev->htc_cnxt->block_sz = dev->ar->mbox_info.block_size;
  507. /* must be a power of 2 */
  508. if ((dev->htc_cnxt->block_sz & (dev->htc_cnxt->block_sz - 1)) != 0) {
  509. WARN_ON(1);
  510. status = -EINVAL;
  511. goto fail_setup;
  512. }
  513. /* assemble mask, used for padding to a block */
  514. dev->htc_cnxt->block_mask = dev->htc_cnxt->block_sz - 1;
  515. ath6kl_dbg(ATH6KL_DBG_HIF, "hif block size %d mbox addr 0x%x\n",
  516. dev->htc_cnxt->block_sz, dev->ar->mbox_info.htc_addr);
  517. status = ath6kl_hif_disable_intrs(dev);
  518. fail_setup:
  519. return status;
  520. }