irq-vic-timer.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* arch/arm/plat-samsung/irq-vic-timer.c
  2. * originally part of arch/arm/plat-s3c64xx/irq.c
  3. *
  4. * Copyright 2008 Openmoko, Inc.
  5. * Copyright 2008 Simtec Electronics
  6. * Ben Dooks <ben@simtec.co.uk>
  7. * http://armlinux.simtec.co.uk/
  8. *
  9. * S3C64XX - Interrupt handling
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #include <linux/kernel.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/irq.h>
  18. #include <linux/io.h>
  19. #include <mach/map.h>
  20. #include <plat/irq-vic-timer.h>
  21. #include <plat/regs-timer.h>
  22. static void s3c_irq_demux_vic_timer(unsigned int irq, struct irq_desc *desc)
  23. {
  24. generic_handle_irq((int)desc->handler_data);
  25. }
  26. /* We assume the IRQ_TIMER0..IRQ_TIMER4 range is continuous. */
  27. static void s3c_irq_timer_mask(unsigned int irq)
  28. {
  29. u32 reg = __raw_readl(S3C64XX_TINT_CSTAT);
  30. reg &= 0x1f; /* mask out pending interrupts */
  31. reg &= ~(1 << (irq - IRQ_TIMER0));
  32. __raw_writel(reg, S3C64XX_TINT_CSTAT);
  33. }
  34. static void s3c_irq_timer_unmask(unsigned int irq)
  35. {
  36. u32 reg = __raw_readl(S3C64XX_TINT_CSTAT);
  37. reg &= 0x1f; /* mask out pending interrupts */
  38. reg |= 1 << (irq - IRQ_TIMER0);
  39. __raw_writel(reg, S3C64XX_TINT_CSTAT);
  40. }
  41. static void s3c_irq_timer_ack(unsigned int irq)
  42. {
  43. u32 reg = __raw_readl(S3C64XX_TINT_CSTAT);
  44. reg &= 0x1f;
  45. reg |= (1 << 5) << (irq - IRQ_TIMER0);
  46. __raw_writel(reg, S3C64XX_TINT_CSTAT);
  47. }
  48. static struct irq_chip s3c_irq_timer = {
  49. .name = "s3c-timer",
  50. .mask = s3c_irq_timer_mask,
  51. .unmask = s3c_irq_timer_unmask,
  52. .ack = s3c_irq_timer_ack,
  53. };
  54. /**
  55. * s3c_init_vic_timer_irq() - initialise timer irq chanined off VIC.\
  56. * @parent_irq: The parent IRQ on the VIC for the timer.
  57. * @timer_irq: The IRQ to be used for the timer.
  58. *
  59. * Register the necessary IRQ chaining and support for the timer IRQs
  60. * chained of the VIC.
  61. */
  62. void __init s3c_init_vic_timer_irq(unsigned int parent_irq,
  63. unsigned int timer_irq)
  64. {
  65. struct irq_desc *desc = irq_to_desc(parent_irq);
  66. set_irq_chained_handler(parent_irq, s3c_irq_demux_vic_timer);
  67. set_irq_chip(timer_irq, &s3c_irq_timer);
  68. set_irq_handler(timer_irq, handle_level_irq);
  69. set_irq_flags(timer_irq, IRQF_VALID);
  70. desc->handler_data = (void *)timer_irq;
  71. }