Colin Cross | 8726e4f | 2010-04-05 15:22:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-tegra/legacy_irq.c |
| 3 | * |
| 4 | * Copyright (C) 2010 Google, Inc. |
| 5 | * Author: Colin Cross <ccross@android.com> |
| 6 | * |
| 7 | * This software is licensed under the terms of the GNU General Public |
| 8 | * License version 2, as published by the Free Software Foundation, and |
| 9 | * may be copied, distributed, and modified under those terms. |
| 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 | */ |
| 17 | |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/kernel.h> |
| 20 | #include <mach/iomap.h> |
Colin Cross | 3524b70 | 2010-11-28 22:23:55 -0800 | [diff] [blame] | 21 | #include <mach/irqs.h> |
Colin Cross | 8726e4f | 2010-04-05 15:22:21 -0700 | [diff] [blame] | 22 | #include <mach/legacy_irq.h> |
| 23 | |
Colin Cross | 3524b70 | 2010-11-28 22:23:55 -0800 | [diff] [blame] | 24 | #define INT_SYS_NR (INT_GPIO_BASE - INT_PRI_BASE) |
| 25 | #define INT_SYS_SZ (INT_SEC_BASE - INT_PRI_BASE) |
| 26 | #define PPI_NR ((INT_SYS_NR+INT_SYS_SZ-1)/INT_SYS_SZ) |
| 27 | |
| 28 | #define ICTLR_CPU_IEP_VFIQ 0x08 |
| 29 | #define ICTLR_CPU_IEP_FIR 0x14 |
| 30 | #define ICTLR_CPU_IEP_FIR_SET 0x18 |
| 31 | #define ICTLR_CPU_IEP_FIR_CLR 0x1c |
| 32 | |
Colin Cross | 8726e4f | 2010-04-05 15:22:21 -0700 | [diff] [blame] | 33 | #define ICTLR_CPU_IER 0x20 |
| 34 | #define ICTLR_CPU_IER_SET 0x24 |
| 35 | #define ICTLR_CPU_IER_CLR 0x28 |
| 36 | #define ICTLR_CPU_IEP_CLASS 0x2C |
Colin Cross | 3524b70 | 2010-11-28 22:23:55 -0800 | [diff] [blame] | 37 | |
| 38 | #define ICTLR_COP_IER 0x30 |
| 39 | #define ICTLR_COP_IER_SET 0x34 |
| 40 | #define ICTLR_COP_IER_CLR 0x38 |
| 41 | #define ICTLR_COP_IEP_CLASS 0x3c |
| 42 | |
| 43 | #define NUM_ICTLRS 4 |
Colin Cross | 8726e4f | 2010-04-05 15:22:21 -0700 | [diff] [blame] | 44 | |
| 45 | static void __iomem *ictlr_reg_base[] = { |
| 46 | IO_ADDRESS(TEGRA_PRIMARY_ICTLR_BASE), |
| 47 | IO_ADDRESS(TEGRA_SECONDARY_ICTLR_BASE), |
| 48 | IO_ADDRESS(TEGRA_TERTIARY_ICTLR_BASE), |
| 49 | IO_ADDRESS(TEGRA_QUATERNARY_ICTLR_BASE), |
| 50 | }; |
| 51 | |
| 52 | /* When going into deep sleep, the CPU is powered down, taking the GIC with it |
| 53 | In order to wake, the wake interrupts need to be enabled in the legacy |
| 54 | interrupt controller. */ |
| 55 | void tegra_legacy_unmask_irq(unsigned int irq) |
| 56 | { |
| 57 | void __iomem *base; |
| 58 | pr_debug("%s: %d\n", __func__, irq); |
| 59 | |
| 60 | irq -= 32; |
| 61 | base = ictlr_reg_base[irq>>5]; |
| 62 | writel(1 << (irq & 31), base + ICTLR_CPU_IER_SET); |
| 63 | } |
| 64 | |
| 65 | void tegra_legacy_mask_irq(unsigned int irq) |
| 66 | { |
| 67 | void __iomem *base; |
| 68 | pr_debug("%s: %d\n", __func__, irq); |
| 69 | |
| 70 | irq -= 32; |
| 71 | base = ictlr_reg_base[irq>>5]; |
| 72 | writel(1 << (irq & 31), base + ICTLR_CPU_IER_CLR); |
| 73 | } |
| 74 | |
| 75 | void tegra_legacy_force_irq_set(unsigned int irq) |
| 76 | { |
| 77 | void __iomem *base; |
| 78 | pr_debug("%s: %d\n", __func__, irq); |
| 79 | |
| 80 | irq -= 32; |
| 81 | base = ictlr_reg_base[irq>>5]; |
| 82 | writel(1 << (irq & 31), base + ICTLR_CPU_IEP_FIR_SET); |
| 83 | } |
| 84 | |
| 85 | void tegra_legacy_force_irq_clr(unsigned int irq) |
| 86 | { |
| 87 | void __iomem *base; |
| 88 | pr_debug("%s: %d\n", __func__, irq); |
| 89 | |
| 90 | irq -= 32; |
| 91 | base = ictlr_reg_base[irq>>5]; |
| 92 | writel(1 << (irq & 31), base + ICTLR_CPU_IEP_FIR_CLR); |
| 93 | } |
| 94 | |
| 95 | int tegra_legacy_force_irq_status(unsigned int irq) |
| 96 | { |
| 97 | void __iomem *base; |
| 98 | pr_debug("%s: %d\n", __func__, irq); |
| 99 | |
| 100 | irq -= 32; |
| 101 | base = ictlr_reg_base[irq>>5]; |
| 102 | return !!(readl(base + ICTLR_CPU_IEP_FIR) & (1 << (irq & 31))); |
| 103 | } |
| 104 | |
| 105 | void tegra_legacy_select_fiq(unsigned int irq, bool fiq) |
| 106 | { |
| 107 | void __iomem *base; |
| 108 | pr_debug("%s: %d\n", __func__, irq); |
| 109 | |
| 110 | irq -= 32; |
| 111 | base = ictlr_reg_base[irq>>5]; |
| 112 | writel(fiq << (irq & 31), base + ICTLR_CPU_IEP_CLASS); |
| 113 | } |
| 114 | |
| 115 | unsigned long tegra_legacy_vfiq(int nr) |
| 116 | { |
| 117 | void __iomem *base; |
| 118 | base = ictlr_reg_base[nr]; |
| 119 | return readl(base + ICTLR_CPU_IEP_VFIQ); |
| 120 | } |
| 121 | |
| 122 | unsigned long tegra_legacy_class(int nr) |
| 123 | { |
| 124 | void __iomem *base; |
| 125 | base = ictlr_reg_base[nr]; |
| 126 | return readl(base + ICTLR_CPU_IEP_CLASS); |
| 127 | } |
Colin Cross | 3524b70 | 2010-11-28 22:23:55 -0800 | [diff] [blame] | 128 | |
Colin Cross | 3524b70 | 2010-11-28 22:23:55 -0800 | [diff] [blame] | 129 | void tegra_init_legacy_irq(void) |
| 130 | { |
| 131 | int i; |
| 132 | |
| 133 | for (i = 0; i < NUM_ICTLRS; i++) { |
| 134 | void __iomem *ictlr = ictlr_reg_base[i]; |
| 135 | writel(~0, ictlr + ICTLR_CPU_IER_CLR); |
| 136 | writel(0, ictlr + ICTLR_CPU_IEP_CLASS); |
| 137 | } |
| 138 | } |