irq-vic-timer.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/irqchip/chained_irq.h>
  19. #include <linux/io.h>
  20. #include <mach/map.h>
  21. #include <mach/irqs.h>
  22. #include <plat/cpu.h>
  23. #include <plat/irq-vic-timer.h>
  24. #include <plat/regs-timer.h>
  25. static void s3c_irq_demux_vic_timer(unsigned int irq, struct irq_desc *desc)
  26. {
  27. struct irq_chip *chip = irq_get_chip(irq);
  28. chained_irq_enter(chip, desc);
  29. generic_handle_irq((int)desc->irq_data.handler_data);
  30. chained_irq_exit(chip, desc);
  31. }
  32. /* We assume the IRQ_TIMER0..IRQ_TIMER4 range is continuous. */
  33. static void s3c_irq_timer_ack(struct irq_data *d)
  34. {
  35. struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
  36. u32 mask = (1 << 5) << (d->irq - gc->irq_base);
  37. irq_reg_writel(mask | gc->mask_cache, gc->reg_base);
  38. }
  39. /**
  40. * s3c_init_vic_timer_irq() - initialise timer irq chanined off VIC.\
  41. * @num: Number of timers to initialize
  42. * @timer_irq: Base IRQ number to be used for the timers.
  43. *
  44. * Register the necessary IRQ chaining and support for the timer IRQs
  45. * chained of the VIC.
  46. */
  47. void __init s3c_init_vic_timer_irq(unsigned int num, unsigned int timer_irq)
  48. {
  49. unsigned int pirq[5] = { IRQ_TIMER0_VIC, IRQ_TIMER1_VIC, IRQ_TIMER2_VIC,
  50. IRQ_TIMER3_VIC, IRQ_TIMER4_VIC };
  51. struct irq_chip_generic *s3c_tgc;
  52. struct irq_chip_type *ct;
  53. unsigned int i;
  54. #ifdef CONFIG_ARCH_EXYNOS
  55. if (soc_is_exynos5250()) {
  56. pirq[0] = EXYNOS5_IRQ_TIMER0_VIC;
  57. pirq[1] = EXYNOS5_IRQ_TIMER1_VIC;
  58. pirq[2] = EXYNOS5_IRQ_TIMER2_VIC;
  59. pirq[3] = EXYNOS5_IRQ_TIMER3_VIC;
  60. pirq[4] = EXYNOS5_IRQ_TIMER4_VIC;
  61. } else {
  62. pirq[0] = EXYNOS4_IRQ_TIMER0_VIC;
  63. pirq[1] = EXYNOS4_IRQ_TIMER1_VIC;
  64. pirq[2] = EXYNOS4_IRQ_TIMER2_VIC;
  65. pirq[3] = EXYNOS4_IRQ_TIMER3_VIC;
  66. pirq[4] = EXYNOS4_IRQ_TIMER4_VIC;
  67. }
  68. #endif
  69. s3c_tgc = irq_alloc_generic_chip("s3c-timer", 1, timer_irq,
  70. S3C64XX_TINT_CSTAT, handle_level_irq);
  71. if (!s3c_tgc) {
  72. pr_err("%s: irq_alloc_generic_chip for IRQ %d failed\n",
  73. __func__, timer_irq);
  74. return;
  75. }
  76. ct = s3c_tgc->chip_types;
  77. ct->chip.irq_mask = irq_gc_mask_clr_bit;
  78. ct->chip.irq_unmask = irq_gc_mask_set_bit;
  79. ct->chip.irq_ack = s3c_irq_timer_ack;
  80. irq_setup_generic_chip(s3c_tgc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE,
  81. IRQ_NOREQUEST | IRQ_NOPROBE, 0);
  82. /* Clear the upper bits of the mask_cache*/
  83. s3c_tgc->mask_cache &= 0x1f;
  84. for (i = 0; i < num; i++, timer_irq++) {
  85. irq_set_chained_handler(pirq[i], s3c_irq_demux_vic_timer);
  86. irq_set_handler_data(pirq[i], (void *)timer_irq);
  87. }
  88. }