hif.c 17 KB

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