intc-simr.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * intc-simr.c
  3. *
  4. * (C) Copyright 2009, Greg Ungerer <gerg@snapgear.com>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/types.h>
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/irq.h>
  15. #include <linux/io.h>
  16. #include <asm/coldfire.h>
  17. #include <asm/mcfsim.h>
  18. #include <asm/traps.h>
  19. static void intc_irq_mask(unsigned int irq)
  20. {
  21. if (irq >= MCFINT_VECBASE) {
  22. if (irq < MCFINT_VECBASE + 64)
  23. __raw_writeb(irq - MCFINT_VECBASE, MCFINTC0_SIMR);
  24. else if ((irq < MCFINT_VECBASE + 128) && MCFINTC1_SIMR)
  25. __raw_writeb(irq - MCFINT_VECBASE - 64, MCFINTC1_SIMR);
  26. }
  27. }
  28. static void intc_irq_unmask(unsigned int irq)
  29. {
  30. if (irq >= MCFINT_VECBASE) {
  31. if (irq < MCFINT_VECBASE + 64)
  32. __raw_writeb(irq - MCFINT_VECBASE, MCFINTC0_CIMR);
  33. else if ((irq < MCFINT_VECBASE + 128) && MCFINTC1_CIMR)
  34. __raw_writeb(irq - MCFINT_VECBASE - 64, MCFINTC1_CIMR);
  35. }
  36. }
  37. static int intc_irq_set_type(unsigned int irq, unsigned int type)
  38. {
  39. if (irq >= MCFINT_VECBASE) {
  40. if (irq < MCFINT_VECBASE + 64)
  41. __raw_writeb(5, MCFINTC0_ICR0 + irq - MCFINT_VECBASE);
  42. else if ((irq < MCFINT_VECBASE) && MCFINTC1_ICR0)
  43. __raw_writeb(5, MCFINTC1_ICR0 + irq - MCFINT_VECBASE - 64);
  44. }
  45. return 0;
  46. }
  47. static struct irq_chip intc_irq_chip = {
  48. .name = "CF-INTC",
  49. .mask = intc_irq_mask,
  50. .unmask = intc_irq_unmask,
  51. .set_type = intc_irq_set_type,
  52. };
  53. void __init init_IRQ(void)
  54. {
  55. int irq;
  56. init_vectors();
  57. /* Mask all interrupt sources */
  58. __raw_writeb(0xff, MCFINTC0_SIMR);
  59. if (MCFINTC1_SIMR)
  60. __raw_writeb(0xff, MCFINTC1_SIMR);
  61. for (irq = 0; (irq < NR_IRQS); irq++) {
  62. irq_desc[irq].status = IRQ_DISABLED;
  63. irq_desc[irq].action = NULL;
  64. irq_desc[irq].depth = 1;
  65. irq_desc[irq].chip = &intc_irq_chip;
  66. intc_irq_set_type(irq, 0);
  67. }
  68. }