int.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Wireless Host Controller (WHC) interrupt handling.
  3. *
  4. * Copyright (C) 2007 Cambridge Silicon Radio Ltd.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License version
  8. * 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/uwb/umc.h>
  20. #include "../../wusbcore/wusbhc.h"
  21. #include "whcd.h"
  22. static void transfer_done(struct whc *whc)
  23. {
  24. queue_work(whc->workqueue, &whc->async_work);
  25. queue_work(whc->workqueue, &whc->periodic_work);
  26. }
  27. irqreturn_t whc_int_handler(struct usb_hcd *hcd)
  28. {
  29. struct wusbhc *wusbhc = usb_hcd_to_wusbhc(hcd);
  30. struct whc *whc = wusbhc_to_whc(wusbhc);
  31. u32 sts;
  32. sts = le_readl(whc->base + WUSBSTS);
  33. if (!(sts & WUSBSTS_INT_MASK))
  34. return IRQ_NONE;
  35. le_writel(sts & WUSBSTS_INT_MASK, whc->base + WUSBSTS);
  36. if (sts & WUSBSTS_GEN_CMD_DONE)
  37. wake_up(&whc->cmd_wq);
  38. if (sts & WUSBSTS_HOST_ERR)
  39. dev_err(&whc->umc->dev, "FIXME: host system error\n");
  40. if (sts & WUSBSTS_ASYNC_SCHED_SYNCED)
  41. wake_up(&whc->async_list_wq);
  42. if (sts & WUSBSTS_PERIODIC_SCHED_SYNCED)
  43. wake_up(&whc->periodic_list_wq);
  44. if (sts & WUSBSTS_DNTS_INT)
  45. queue_work(whc->workqueue, &whc->dn_work);
  46. /*
  47. * A transfer completed (see [WHCI] section 4.7.1.2 for when
  48. * this occurs).
  49. */
  50. if (sts & (WUSBSTS_INT | WUSBSTS_ERR_INT))
  51. transfer_done(whc);
  52. return IRQ_HANDLED;
  53. }
  54. static int process_dn_buf(struct whc *whc)
  55. {
  56. struct wusbhc *wusbhc = &whc->wusbhc;
  57. struct dn_buf_entry *dn;
  58. int processed = 0;
  59. for (dn = whc->dn_buf; dn < whc->dn_buf + WHC_N_DN_ENTRIES; dn++) {
  60. if (dn->status & WHC_DN_STATUS_VALID) {
  61. wusbhc_handle_dn(wusbhc, dn->src_addr,
  62. (struct wusb_dn_hdr *)dn->dn_data,
  63. dn->msg_size);
  64. dn->status &= ~WHC_DN_STATUS_VALID;
  65. processed++;
  66. }
  67. }
  68. return processed;
  69. }
  70. void whc_dn_work(struct work_struct *work)
  71. {
  72. struct whc *whc = container_of(work, struct whc, dn_work);
  73. int processed;
  74. do {
  75. processed = process_dn_buf(whc);
  76. } while (processed);
  77. }