diff options
| author | Marc Zyngier <marc.zyngier@arm.com> | 2015-03-11 11:42:59 -0400 |
|---|---|---|
| committer | Jason Cooper <jason@lakedaemon.net> | 2015-03-14 20:40:29 -0400 |
| commit | de3ce0804916a9b4f3b58e4e78727d5483c4df04 (patch) | |
| tree | 0e866286aa47ae6f13a4a2832dcc3cf8b08dd6df | |
| parent | b3aa14c39944c6ea2ce20278afe87241413b0477 (diff) | |
irqchip: tegra: Add DT-based support for legacy interrupt controller
Tegra's LIC (Legacy Interrupt Controller) has been so far only
supported as a weird extension of the GIC, which is not exactly
pretty.
The stacked IRQ domain framework fits this pretty well, and allows
the LIC code to be turned into a standalone irqchip. In the process,
make the driver DT aware, something that was sorely missing from
the mach-tegra implementation.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Link: https://lkml.kernel.org/r/1426088583-15097-3-git-send-email-marc.zyngier@arm.com
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
| -rw-r--r-- | drivers/irqchip/Makefile | 1 | ||||
| -rw-r--r-- | drivers/irqchip/irq-tegra.c | 371 |
2 files changed, 372 insertions, 0 deletions
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 42965d2476bb..c6d607f1ec50 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile | |||
| @@ -6,6 +6,7 @@ obj-$(CONFIG_ARCH_HIP04) += irq-hip04.o | |||
| 6 | obj-$(CONFIG_ARCH_MMP) += irq-mmp.o | 6 | obj-$(CONFIG_ARCH_MMP) += irq-mmp.o |
| 7 | obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o | 7 | obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o |
| 8 | obj-$(CONFIG_ARCH_MXS) += irq-mxs.o | 8 | obj-$(CONFIG_ARCH_MXS) += irq-mxs.o |
| 9 | obj-$(CONFIG_ARCH_TEGRA) += irq-tegra.o | ||
| 9 | obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o | 10 | obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o |
| 10 | obj-$(CONFIG_DW_APB_ICTL) += irq-dw-apb-ictl.o | 11 | obj-$(CONFIG_DW_APB_ICTL) += irq-dw-apb-ictl.o |
| 11 | obj-$(CONFIG_METAG) += irq-metag-ext.o | 12 | obj-$(CONFIG_METAG) += irq-metag-ext.o |
diff --git a/drivers/irqchip/irq-tegra.c b/drivers/irqchip/irq-tegra.c new file mode 100644 index 000000000000..d919ecf29cf4 --- /dev/null +++ b/drivers/irqchip/irq-tegra.c | |||
| @@ -0,0 +1,371 @@ | |||
| 1 | /* | ||
| 2 | * Driver code for Tegra's Legacy Interrupt Controller | ||
| 3 | * | ||
| 4 | * Author: Marc Zyngier <marc.zyngier@arm.com> | ||
| 5 | * | ||
| 6 | * Heavily based on the original arch/arm/mach-tegra/irq.c code: | ||
| 7 | * Copyright (C) 2011 Google, Inc. | ||
| 8 | * | ||
| 9 | * Author: | ||
| 10 | * Colin Cross <ccross@android.com> | ||
| 11 | * | ||
| 12 | * Copyright (C) 2010,2013, NVIDIA Corporation | ||
| 13 | * | ||
| 14 | * This software is licensed under the terms of the GNU General Public | ||
| 15 | * License version 2, as published by the Free Software Foundation, and | ||
| 16 | * may be copied, distributed, and modified under those terms. | ||
| 17 | * | ||
| 18 | * This program is distributed in the hope that it will be useful, | ||
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 21 | * GNU General Public License for more details. | ||
| 22 | * | ||
| 23 | */ | ||
| 24 | |||
| 25 | #include <linux/io.h> | ||
| 26 | #include <linux/irq.h> | ||
| 27 | #include <linux/irqdomain.h> | ||
| 28 | #include <linux/of_address.h> | ||
| 29 | #include <linux/slab.h> | ||
| 30 | #include <linux/syscore_ops.h> | ||
| 31 | |||
| 32 | #include <dt-bindings/interrupt-controller/arm-gic.h> | ||
| 33 | |||
| 34 | #include "irqchip.h" | ||
| 35 | |||
| 36 | #define ICTLR_CPU_IEP_VFIQ 0x08 | ||
| 37 | #define ICTLR_CPU_IEP_FIR 0x14 | ||
| 38 | #define ICTLR_CPU_IEP_FIR_SET 0x18 | ||
| 39 | #define ICTLR_CPU_IEP_FIR_CLR 0x1c | ||
| 40 | |||
| 41 | #define ICTLR_CPU_IER 0x20 | ||
| 42 | #define ICTLR_CPU_IER_SET 0x24 | ||
| 43 | #define ICTLR_CPU_IER_CLR 0x28 | ||
| 44 | #define ICTLR_CPU_IEP_CLASS 0x2C | ||
| 45 | |||
| 46 | #define ICTLR_COP_IER 0x30 | ||
| 47 | #define ICTLR_COP_IER_SET 0x34 | ||
| 48 | #define ICTLR_COP_IER_CLR 0x38 | ||
| 49 | #define ICTLR_COP_IEP_CLASS 0x3c | ||
| 50 | |||
| 51 | #define TEGRA_MAX_NUM_ICTLRS 5 | ||
| 52 | |||
| 53 | static unsigned int num_ictlrs; | ||
| 54 | |||
| 55 | struct tegra_ictlr_soc { | ||
| 56 | unsigned int num_ictlrs; | ||
| 57 | }; | ||
| 58 | |||
| 59 | static const struct tegra_ictlr_soc tegra20_ictlr_soc = { | ||
| 60 | .num_ictlrs = 4, | ||
| 61 | }; | ||
| 62 | |||
| 63 | static const struct tegra_ictlr_soc tegra30_ictlr_soc = { | ||
| 64 | .num_ictlrs = 5, | ||
| 65 | }; | ||
| 66 | |||
| 67 | static const struct of_device_id ictlr_matches[] = { | ||
| 68 | { .compatible = "nvidia,tegra30-ictlr", .data = &tegra30_ictlr_soc }, | ||
| 69 | { .compatible = "nvidia,tegra20-ictlr", .data = &tegra20_ictlr_soc }, | ||
| 70 | { } | ||
| 71 | }; | ||
| 72 | |||
| 73 | struct tegra_ictlr_info { | ||
| 74 | void __iomem *base[TEGRA_MAX_NUM_ICTLRS]; | ||
| 75 | #ifdef CONFIG_PM_SLEEP | ||
| 76 | u32 cop_ier[TEGRA_MAX_NUM_ICTLRS]; | ||
| 77 | u32 cop_iep[TEGRA_MAX_NUM_ICTLRS]; | ||
| 78 | u32 cpu_ier[TEGRA_MAX_NUM_ICTLRS]; | ||
| 79 | u32 cpu_iep[TEGRA_MAX_NUM_ICTLRS]; | ||
| 80 | |||
| 81 | u32 ictlr_wake_mask[TEGRA_MAX_NUM_ICTLRS]; | ||
| 82 | #endif | ||
| 83 | }; | ||
| 84 | |||
| 85 | static struct tegra_ictlr_info *lic; | ||
| 86 | |||
| 87 | static inline void tegra_ictlr_write_mask(struct irq_data *d, unsigned long reg) | ||
| 88 | { | ||
| 89 | void __iomem *base = d->chip_data; | ||
| 90 | u32 mask; | ||
| 91 | |||
| 92 | mask = BIT(d->hwirq % 32); | ||
| 93 | writel_relaxed(mask, base + reg); | ||
| 94 | } | ||
| 95 | |||
| 96 | static void tegra_mask(struct irq_data *d) | ||
| 97 | { | ||
| 98 | tegra_ictlr_write_mask(d, ICTLR_CPU_IER_CLR); | ||
| 99 | irq_chip_mask_parent(d); | ||
| 100 | } | ||
| 101 | |||
| 102 | static void tegra_unmask(struct irq_data *d) | ||
| 103 | { | ||
| 104 | tegra_ictlr_write_mask(d, ICTLR_CPU_IER_SET); | ||
| 105 | irq_chip_unmask_parent(d); | ||
| 106 | } | ||
| 107 | |||
| 108 | static void tegra_eoi(struct irq_data *d) | ||
| 109 | { | ||
| 110 | tegra_ictlr_write_mask(d, ICTLR_CPU_IEP_FIR_CLR); | ||
| 111 | irq_chip_eoi_parent(d); | ||
| 112 | } | ||
| 113 | |||
| 114 | static int tegra_retrigger(struct irq_data *d) | ||
| 115 | { | ||
| 116 | tegra_ictlr_write_mask(d, ICTLR_CPU_IEP_FIR_SET); | ||
| 117 | return irq_chip_retrigger_hierarchy(d); | ||
| 118 | } | ||
| 119 | |||
| 120 | #ifdef CONFIG_PM_SLEEP | ||
| 121 | static int tegra_set_wake(struct irq_data *d, unsigned int enable) | ||
| 122 | { | ||
| 123 | u32 irq = d->hwirq; | ||
| 124 | u32 index, mask; | ||
| 125 | |||
| 126 | index = (irq / 32); | ||
| 127 | mask = BIT(irq % 32); | ||
| 128 | if (enable) | ||
| 129 | lic->ictlr_wake_mask[index] |= mask; | ||
| 130 | else | ||
| 131 | lic->ictlr_wake_mask[index] &= ~mask; | ||
| 132 | |||
| 133 | /* | ||
| 134 | * Do *not* call into the parent, as the GIC doesn't have any | ||
| 135 | * wake-up facility... | ||
| 136 | */ | ||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | |||
| 140 | static int tegra_ictlr_suspend(void) | ||
| 141 | { | ||
| 142 | unsigned long flags; | ||
| 143 | unsigned int i; | ||
| 144 | |||
| 145 | local_irq_save(flags); | ||
| 146 | for (i = 0; i < num_ictlrs; i++) { | ||
| 147 | void __iomem *ictlr = lic->base[i]; | ||
| 148 | |||
| 149 | /* Save interrupt state */ | ||
| 150 | lic->cpu_ier[i] = readl_relaxed(ictlr + ICTLR_CPU_IER); | ||
| 151 | lic->cpu_iep[i] = readl_relaxed(ictlr + ICTLR_CPU_IEP_CLASS); | ||
| 152 | lic->cop_ier[i] = readl_relaxed(ictlr + ICTLR_COP_IER); | ||
| 153 | lic->cop_iep[i] = readl_relaxed(ictlr + ICTLR_COP_IEP_CLASS); | ||
| 154 | |||
| 155 | /* Disable COP interrupts */ | ||
| 156 | writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR); | ||
| 157 | |||
| 158 | /* Disable CPU interrupts */ | ||
| 159 | writel_relaxed(~0ul, ictlr + ICTLR_CPU_IER_CLR); | ||
| 160 | |||
| 161 | /* Enable the wakeup sources of ictlr */ | ||
| 162 | writel_relaxed(lic->ictlr_wake_mask[i], ictlr + ICTLR_CPU_IER_SET); | ||
| 163 | } | ||
| 164 | local_irq_restore(flags); | ||
| 165 | |||
| 166 | return 0; | ||
| 167 | } | ||
| 168 | |||
| 169 | static void tegra_ictlr_resume(void) | ||
| 170 | { | ||
| 171 | unsigned long flags; | ||
| 172 | unsigned int i; | ||
| 173 | |||
| 174 | local_irq_save(flags); | ||
| 175 | for (i = 0; i < num_ictlrs; i++) { | ||
| 176 | void __iomem *ictlr = lic->base[i]; | ||
| 177 | |||
| 178 | writel_relaxed(lic->cpu_iep[i], | ||
| 179 | ictlr + ICTLR_CPU_IEP_CLASS); | ||
| 180 | writel_relaxed(~0ul, ictlr + ICTLR_CPU_IER_CLR); | ||
| 181 | writel_relaxed(lic->cpu_ier[i], | ||
| 182 | ictlr + ICTLR_CPU_IER_SET); | ||
| 183 | writel_relaxed(lic->cop_iep[i], | ||
| 184 | ictlr + ICTLR_COP_IEP_CLASS); | ||
| 185 | writel_relaxed(~0ul, ictlr + ICTLR_COP_IER_CLR); | ||
| 186 | writel_relaxed(lic->cop_ier[i], | ||
| 187 | ictlr + ICTLR_COP_IER_SET); | ||
| 188 | } | ||
| 189 | local_irq_restore(flags); | ||
| 190 | } | ||
| 191 | |||
| 192 | static struct syscore_ops tegra_ictlr_syscore_ops = { | ||
| 193 | .suspend = tegra_ictlr_suspend, | ||
| 194 | .resume = tegra_ictlr_resume, | ||
| 195 | }; | ||
| 196 | |||
| 197 | static void tegra_ictlr_syscore_init(void) | ||
| 198 | { | ||
| 199 | register_syscore_ops(&tegra_ictlr_syscore_ops); | ||
| 200 | } | ||
