irq.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  3. */
  4. /*
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <linux/module.h>
  10. #include <linux/moduleparam.h>
  11. #include <linux/init.h>
  12. #include <linux/device.h>
  13. #include <linux/errno.h>
  14. #include <asm/hardware.h>
  15. #include <asm/io.h>
  16. #include <asm/irq.h>
  17. #include <asm/mach/irq.h>
  18. #include <asm/arch/common.h>
  19. /* Disable interrupt number "irq" in the AVIC */
  20. static void mxc_mask_irq(unsigned int irq)
  21. {
  22. __raw_writel(irq, AVIC_INTDISNUM);
  23. }
  24. /* Enable interrupt number "irq" in the AVIC */
  25. static void mxc_unmask_irq(unsigned int irq)
  26. {
  27. __raw_writel(irq, AVIC_INTENNUM);
  28. }
  29. static struct irq_chip mxc_avic_chip = {
  30. .mask_ack = mxc_mask_irq,
  31. .mask = mxc_mask_irq,
  32. .unmask = mxc_unmask_irq,
  33. };
  34. /*
  35. * This function initializes the AVIC hardware and disables all the
  36. * interrupts. It registers the interrupt enable and disable functions
  37. * to the kernel for each interrupt source.
  38. */
  39. void __init mxc_init_irq(void)
  40. {
  41. int i;
  42. u32 reg;
  43. /* put the AVIC into the reset value with
  44. * all interrupts disabled
  45. */
  46. __raw_writel(0, AVIC_INTCNTL);
  47. __raw_writel(0x1f, AVIC_NIMASK);
  48. /* disable all interrupts */
  49. __raw_writel(0, AVIC_INTENABLEH);
  50. __raw_writel(0, AVIC_INTENABLEL);
  51. /* all IRQ no FIQ */
  52. __raw_writel(0, AVIC_INTTYPEH);
  53. __raw_writel(0, AVIC_INTTYPEL);
  54. for (i = 0; i < MXC_MAX_INT_LINES; i++) {
  55. set_irq_chip(i, &mxc_avic_chip);
  56. set_irq_handler(i, handle_level_irq);
  57. set_irq_flags(i, IRQF_VALID);
  58. }
  59. /* Set WDOG2's interrupt the highest priority level (bit 28-31) */
  60. reg = __raw_readl(AVIC_NIPRIORITY6);
  61. reg |= (0xF << 28);
  62. __raw_writel(reg, AVIC_NIPRIORITY6);
  63. printk(KERN_INFO "MXC IRQ initialized\n");
  64. }