intc-5249.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * intc2.c -- support for the 2nd INTC controller of the 5249
  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. static void intc2_irq_gpio_mask(struct irq_data *d)
  19. {
  20. u32 imr;
  21. imr = readl(MCFSIM2_GPIOINTENABLE);
  22. imr &= ~(0x1 << (d->irq - MCF_IRQ_GPIO0));
  23. writel(imr, MCFSIM2_GPIOINTENABLE);
  24. }
  25. static void intc2_irq_gpio_unmask(struct irq_data *d)
  26. {
  27. u32 imr;
  28. imr = readl(MCFSIM2_GPIOINTENABLE);
  29. imr |= (0x1 << (d->irq - MCF_IRQ_GPIO0));
  30. writel(imr, MCFSIM2_GPIOINTENABLE);
  31. }
  32. static void intc2_irq_gpio_ack(struct irq_data *d)
  33. {
  34. writel(0x1 << (d->irq - MCF_IRQ_GPIO0), MCFSIM2_GPIOINTCLEAR);
  35. }
  36. static struct irq_chip intc2_irq_gpio_chip = {
  37. .name = "CF-INTC2",
  38. .irq_mask = intc2_irq_gpio_mask,
  39. .irq_unmask = intc2_irq_gpio_unmask,
  40. .irq_ack = intc2_irq_gpio_ack,
  41. };
  42. static int __init mcf_intc2_init(void)
  43. {
  44. int irq;
  45. /* GPIO interrupt sources */
  46. for (irq = MCF_IRQ_GPIO0; (irq <= MCF_IRQ_GPIO7); irq++) {
  47. irq_set_chip(irq, &intc2_irq_gpio_chip);
  48. irq_set_handler(irq, handle_edge_irq);
  49. }
  50. return 0;
  51. }
  52. arch_initcall(mcf_intc2_init);