icoll.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/irq.h>
  21. #include <linux/io.h>
  22. #include <mach/mxs.h>
  23. #include <mach/common.h>
  24. #define HW_ICOLL_VECTOR 0x0000
  25. #define HW_ICOLL_LEVELACK 0x0010
  26. #define HW_ICOLL_CTRL 0x0020
  27. #define HW_ICOLL_INTERRUPTn_SET(n) (0x0124 + (n) * 0x10)
  28. #define HW_ICOLL_INTERRUPTn_CLR(n) (0x0128 + (n) * 0x10)
  29. #define BM_ICOLL_INTERRUPTn_ENABLE 0x00000004
  30. #define BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0 0x1
  31. static void __iomem *icoll_base = MXS_IO_ADDRESS(MXS_ICOLL_BASE_ADDR);
  32. static void icoll_ack_irq(struct irq_data *d)
  33. {
  34. /*
  35. * The Interrupt Collector is able to prioritize irqs.
  36. * Currently only level 0 is used. So acking can use
  37. * BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0 unconditionally.
  38. */
  39. __raw_writel(BV_ICOLL_LEVELACK_IRQLEVELACK__LEVEL0,
  40. icoll_base + HW_ICOLL_LEVELACK);
  41. }
  42. static void icoll_mask_irq(struct irq_data *d)
  43. {
  44. __raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
  45. icoll_base + HW_ICOLL_INTERRUPTn_CLR(d->irq));
  46. }
  47. static void icoll_unmask_irq(struct irq_data *d)
  48. {
  49. __raw_writel(BM_ICOLL_INTERRUPTn_ENABLE,
  50. icoll_base + HW_ICOLL_INTERRUPTn_SET(d->irq));
  51. }
  52. static struct irq_chip mxs_icoll_chip = {
  53. .irq_ack = icoll_ack_irq,
  54. .irq_mask = icoll_mask_irq,
  55. .irq_unmask = icoll_unmask_irq,
  56. };
  57. void __init icoll_init_irq(void)
  58. {
  59. int i;
  60. /*
  61. * Interrupt Collector reset, which initializes the priority
  62. * for each irq to level 0.
  63. */
  64. mxs_reset_block(icoll_base + HW_ICOLL_CTRL);
  65. for (i = 0; i < MXS_INTERNAL_IRQS; i++) {
  66. irq_set_chip_and_handler(i, &mxs_icoll_chip, handle_level_irq);
  67. set_irq_flags(i, IRQF_VALID);
  68. }
  69. }