irq.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. /*!
  20. * Disable interrupt number "irq" in the AVIC
  21. *
  22. * @param irq interrupt source number
  23. */
  24. static void mxc_mask_irq(unsigned int irq)
  25. {
  26. __raw_writel(irq, AVIC_INTDISNUM);
  27. }
  28. /*!
  29. * Enable interrupt number "irq" in the AVIC
  30. *
  31. * @param irq interrupt source number
  32. */
  33. static void mxc_unmask_irq(unsigned int irq)
  34. {
  35. __raw_writel(irq, AVIC_INTENNUM);
  36. }
  37. static struct irq_chip mxc_avic_chip = {
  38. .mask_ack = mxc_mask_irq,
  39. .mask = mxc_mask_irq,
  40. .unmask = mxc_unmask_irq,
  41. };
  42. /*!
  43. * This function initializes the AVIC hardware and disables all the
  44. * interrupts. It registers the interrupt enable and disable functions
  45. * to the kernel for each interrupt source.
  46. */
  47. void __init mxc_init_irq(void)
  48. {
  49. int i;
  50. u32 reg;
  51. /* put the AVIC into the reset value with
  52. * all interrupts disabled
  53. */
  54. __raw_writel(0, AVIC_INTCNTL);
  55. __raw_writel(0x1f, AVIC_NIMASK);
  56. /* disable all interrupts */
  57. __raw_writel(0, AVIC_INTENABLEH);
  58. __raw_writel(0, AVIC_INTENABLEL);
  59. /* all IRQ no FIQ */
  60. __raw_writel(0, AVIC_INTTYPEH);
  61. __raw_writel(0, AVIC_INTTYPEL);
  62. for (i = 0; i < MXC_MAX_INT_LINES; i++) {
  63. set_irq_chip(i, &mxc_avic_chip);
  64. set_irq_handler(i, handle_level_irq);
  65. set_irq_flags(i, IRQF_VALID);
  66. }
  67. /* Set WDOG2's interrupt the highest priority level (bit 28-31) */
  68. reg = __raw_readl(AVIC_NIPRIORITY6);
  69. reg |= (0xF << 28);
  70. __raw_writel(reg, AVIC_NIPRIORITY6);
  71. printk(KERN_INFO "MXC IRQ initialized\n");
  72. }