intc-r8a7779.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * r8a7779 processor support - INTC hardware block
  3. *
  4. * Copyright (C) 2011 Renesas Solutions Corp.
  5. * Copyright (C) 2011 Magnus Damm
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/init.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/io.h>
  26. #include <linux/irqchip/arm-gic.h>
  27. #include <linux/platform_data/irq-renesas-intc-irqpin.h>
  28. #include <linux/irqchip.h>
  29. #include <mach/common.h>
  30. #include <mach/intc.h>
  31. #include <mach/irqs.h>
  32. #include <mach/r8a7779.h>
  33. #include <asm/mach-types.h>
  34. #include <asm/mach/arch.h>
  35. #define INT2SMSKCR0 IOMEM(0xfe7822a0)
  36. #define INT2SMSKCR1 IOMEM(0xfe7822a4)
  37. #define INT2SMSKCR2 IOMEM(0xfe7822a8)
  38. #define INT2SMSKCR3 IOMEM(0xfe7822ac)
  39. #define INT2SMSKCR4 IOMEM(0xfe7822b0)
  40. #define INT2NTSR0 IOMEM(0xfe700060)
  41. #define INT2NTSR1 IOMEM(0xfe700064)
  42. static struct renesas_intc_irqpin_config irqpin0_platform_data = {
  43. .irq_base = irq_pin(0), /* IRQ0 -> IRQ3 */
  44. .sense_bitfield_width = 2,
  45. };
  46. static struct resource irqpin0_resources[] = {
  47. DEFINE_RES_MEM(0xfe78001c, 4), /* ICR1 */
  48. DEFINE_RES_MEM(0xfe780010, 4), /* INTPRI */
  49. DEFINE_RES_MEM(0xfe780024, 4), /* INTREQ */
  50. DEFINE_RES_MEM(0xfe780044, 4), /* INTMSK0 */
  51. DEFINE_RES_MEM(0xfe780064, 4), /* INTMSKCLR0 */
  52. DEFINE_RES_IRQ(gic_spi(27)), /* IRQ0 */
  53. DEFINE_RES_IRQ(gic_spi(28)), /* IRQ1 */
  54. DEFINE_RES_IRQ(gic_spi(29)), /* IRQ2 */
  55. DEFINE_RES_IRQ(gic_spi(30)), /* IRQ3 */
  56. };
  57. static struct platform_device irqpin0_device = {
  58. .name = "renesas_intc_irqpin",
  59. .id = 0,
  60. .resource = irqpin0_resources,
  61. .num_resources = ARRAY_SIZE(irqpin0_resources),
  62. .dev = {
  63. .platform_data = &irqpin0_platform_data,
  64. },
  65. };
  66. void __init r8a7779_init_irq_extpin(int irlm)
  67. {
  68. void __iomem *icr0 = ioremap_nocache(0xfe780000, PAGE_SIZE);
  69. unsigned long tmp;
  70. if (icr0) {
  71. tmp = ioread32(icr0);
  72. if (irlm)
  73. tmp |= 1 << 23; /* IRQ0 -> IRQ3 as individual pins */
  74. else
  75. tmp &= ~(1 << 23); /* IRL mode - not supported */
  76. tmp |= (1 << 21); /* LVLMODE = 1 */
  77. iowrite32(tmp, icr0);
  78. iounmap(icr0);
  79. if (irlm)
  80. platform_device_register(&irqpin0_device);
  81. } else
  82. pr_warn("r8a7779: unable to setup external irq pin mode\n");
  83. }
  84. static int r8a7779_set_wake(struct irq_data *data, unsigned int on)
  85. {
  86. return 0; /* always allow wakeup */
  87. }
  88. static void __init r8a7779_init_irq_common(void)
  89. {
  90. gic_arch_extn.irq_set_wake = r8a7779_set_wake;
  91. /* route all interrupts to ARM */
  92. __raw_writel(0xffffffff, INT2NTSR0);
  93. __raw_writel(0x3fffffff, INT2NTSR1);
  94. /* unmask all known interrupts in INTCS2 */
  95. __raw_writel(0xfffffff0, INT2SMSKCR0);
  96. __raw_writel(0xfff7ffff, INT2SMSKCR1);
  97. __raw_writel(0xfffbffdf, INT2SMSKCR2);
  98. __raw_writel(0xbffffffc, INT2SMSKCR3);
  99. __raw_writel(0x003fee3f, INT2SMSKCR4);
  100. }
  101. void __init r8a7779_init_irq(void)
  102. {
  103. void __iomem *gic_dist_base = IOMEM(0xf0001000);
  104. void __iomem *gic_cpu_base = IOMEM(0xf0000100);
  105. /* use GIC to handle interrupts */
  106. gic_init(0, 29, gic_dist_base, gic_cpu_base);
  107. r8a7779_init_irq_common();
  108. }
  109. #ifdef CONFIG_OF
  110. void __init r8a7779_init_irq_dt(void)
  111. {
  112. irqchip_init();
  113. r8a7779_init_irq_common();
  114. }
  115. #endif