cx18-irq.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * cx18 interrupt handling
  3. *
  4. * Copyright (C) 2007 Hans Verkuil <[email protected]>
  5. * Copyright (C) 2008 Andy Walls <[email protected]>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20. * 02111-1307 USA
  21. */
  22. #include "cx18-driver.h"
  23. #include "cx18-io.h"
  24. #include "cx18-irq.h"
  25. #include "cx18-mailbox.h"
  26. #include "cx18-scb.h"
  27. static void xpu_ack(struct cx18 *cx, u32 sw2)
  28. {
  29. if (sw2 & IRQ_CPU_TO_EPU_ACK)
  30. wake_up(&cx->mb_cpu_waitq);
  31. if (sw2 & IRQ_APU_TO_EPU_ACK)
  32. wake_up(&cx->mb_apu_waitq);
  33. }
  34. static void epu_cmd(struct cx18 *cx, u32 sw1)
  35. {
  36. if (sw1 & IRQ_CPU_TO_EPU)
  37. cx18_api_epu_cmd_irq(cx, CPU);
  38. if (sw1 & IRQ_APU_TO_EPU)
  39. cx18_api_epu_cmd_irq(cx, APU);
  40. }
  41. irqreturn_t cx18_irq_handler(int irq, void *dev_id)
  42. {
  43. struct cx18 *cx = (struct cx18 *)dev_id;
  44. u32 sw1, sw2, hw2;
  45. sw1 = cx18_read_reg(cx, SW1_INT_STATUS) & cx->sw1_irq_mask;
  46. sw2 = cx18_read_reg(cx, SW2_INT_STATUS) & cx->sw2_irq_mask;
  47. hw2 = cx18_read_reg(cx, HW2_INT_CLR_STATUS) & cx->hw2_irq_mask;
  48. if (sw1)
  49. cx18_write_reg_expect(cx, sw1, SW1_INT_STATUS, ~sw1, sw1);
  50. if (sw2)
  51. cx18_write_reg_expect(cx, sw2, SW2_INT_STATUS, ~sw2, sw2);
  52. if (hw2)
  53. cx18_write_reg_expect(cx, hw2, HW2_INT_CLR_STATUS, ~hw2, hw2);
  54. if (sw1 || sw2 || hw2)
  55. CX18_DEBUG_HI_IRQ("received interrupts "
  56. "SW1: %x SW2: %x HW2: %x\n", sw1, sw2, hw2);
  57. /*
  58. * SW1 responses have to happen first. The sending XPU times out the
  59. * incoming mailboxes on us rather rapidly.
  60. */
  61. if (sw1)
  62. epu_cmd(cx, sw1);
  63. /* To do: interrupt-based I2C handling
  64. if (hw2 & (HW2_I2C1_INT|HW2_I2C2_INT)) {
  65. }
  66. */
  67. if (sw2)
  68. xpu_ack(cx, sw2);
  69. return (sw1 || sw2 || hw2) ? IRQ_HANDLED : IRQ_NONE;
  70. }