Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-mv78xx0/irq.c |
| 3 | * |
| 4 | * MV78xx0 IRQ handling. |
| 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public |
| 7 | * License version 2. This program is licensed "as is" without any |
| 8 | * warranty of any kind, whether express or implied. |
| 9 | */ |
Russell King | 2f8163b | 2011-07-26 10:53:52 +0100 | [diff] [blame] | 10 | #include <linux/gpio.h> |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 11 | #include <linux/kernel.h> |
Lennert Buytenhek | b95a13d | 2008-10-20 01:51:04 +0200 | [diff] [blame] | 12 | #include <linux/irq.h> |
Thomas Petazzoni | 383b996 | 2012-09-11 14:27:20 +0200 | [diff] [blame] | 13 | #include <linux/io.h> |
Arnd Bergmann | b8cd337 | 2015-12-02 22:27:04 +0100 | [diff] [blame] | 14 | #include <asm/exception.h> |
Rob Herring | ce91574 | 2012-08-29 10:16:55 -0500 | [diff] [blame] | 15 | #include <plat/orion-gpio.h> |
Lennert Buytenhek | 6f088f1 | 2008-08-09 13:44:58 +0200 | [diff] [blame] | 16 | #include <plat/irq.h> |
Arnd Bergmann | 4c811b9 | 2015-12-02 22:27:06 +0100 | [diff] [blame] | 17 | #include "bridge-regs.h" |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 18 | #include "common.h" |
| 19 | |
Andrew Lunn | 278b45b | 2012-06-27 13:40:04 +0200 | [diff] [blame] | 20 | static int __initdata gpio0_irqs[4] = { |
| 21 | IRQ_MV78XX0_GPIO_0_7, |
| 22 | IRQ_MV78XX0_GPIO_8_15, |
| 23 | IRQ_MV78XX0_GPIO_16_23, |
| 24 | IRQ_MV78XX0_GPIO_24_31, |
| 25 | }; |
Lennert Buytenhek | b95a13d | 2008-10-20 01:51:04 +0200 | [diff] [blame] | 26 | |
Arnd Bergmann | b8cd337 | 2015-12-02 22:27:04 +0100 | [diff] [blame] | 27 | static void __iomem *mv78xx0_irq_base = IRQ_VIRT_BASE; |
| 28 | |
| 29 | static asmlinkage void |
| 30 | __exception_irq_entry mv78xx0_legacy_handle_irq(struct pt_regs *regs) |
| 31 | { |
| 32 | u32 stat; |
| 33 | |
| 34 | stat = readl_relaxed(mv78xx0_irq_base + IRQ_CAUSE_LOW_OFF); |
| 35 | stat &= readl_relaxed(mv78xx0_irq_base + IRQ_MASK_LOW_OFF); |
| 36 | if (stat) { |
| 37 | unsigned int hwirq = __fls(stat); |
| 38 | handle_IRQ(hwirq, regs); |
| 39 | return; |
| 40 | } |
| 41 | stat = readl_relaxed(mv78xx0_irq_base + IRQ_CAUSE_HIGH_OFF); |
| 42 | stat &= readl_relaxed(mv78xx0_irq_base + IRQ_MASK_HIGH_OFF); |
| 43 | if (stat) { |
| 44 | unsigned int hwirq = 32 + __fls(stat); |
| 45 | handle_IRQ(hwirq, regs); |
| 46 | return; |
| 47 | } |
| 48 | stat = readl_relaxed(mv78xx0_irq_base + IRQ_CAUSE_ERR_OFF); |
| 49 | stat &= readl_relaxed(mv78xx0_irq_base + IRQ_MASK_ERR_OFF); |
| 50 | if (stat) { |
| 51 | unsigned int hwirq = 64 + __fls(stat); |
| 52 | handle_IRQ(hwirq, regs); |
| 53 | return; |
| 54 | } |
| 55 | } |
| 56 | |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 57 | void __init mv78xx0_init_irq(void) |
| 58 | { |
Thomas Petazzoni | 383b996 | 2012-09-11 14:27:20 +0200 | [diff] [blame] | 59 | orion_irq_init(0, IRQ_VIRT_BASE + IRQ_MASK_LOW_OFF); |
| 60 | orion_irq_init(32, IRQ_VIRT_BASE + IRQ_MASK_HIGH_OFF); |
| 61 | orion_irq_init(64, IRQ_VIRT_BASE + IRQ_MASK_ERR_OFF); |
Lennert Buytenhek | b95a13d | 2008-10-20 01:51:04 +0200 | [diff] [blame] | 62 | |
Arnd Bergmann | b8cd337 | 2015-12-02 22:27:04 +0100 | [diff] [blame] | 63 | set_handle_irq(mv78xx0_legacy_handle_irq); |
| 64 | |
Lennert Buytenhek | b95a13d | 2008-10-20 01:51:04 +0200 | [diff] [blame] | 65 | /* |
Lennert Buytenhek | 9eac6d0 | 2010-12-14 12:54:03 +0100 | [diff] [blame] | 66 | * Initialize gpiolib for GPIOs 0-31. (The GPIO interrupt mask |
| 67 | * registers for core #1 are at an offset of 0x18 from those of |
| 68 | * core #0.) |
Lennert Buytenhek | b95a13d | 2008-10-20 01:51:04 +0200 | [diff] [blame] | 69 | */ |
Thomas Petazzoni | 383b996 | 2012-09-11 14:27:20 +0200 | [diff] [blame] | 70 | orion_gpio_init(NULL, 0, 32, GPIO_VIRT_BASE, |
Lennert Buytenhek | 9eac6d0 | 2010-12-14 12:54:03 +0100 | [diff] [blame] | 71 | mv78xx0_core_index() ? 0x18 : 0, |
Andrew Lunn | 278b45b | 2012-06-27 13:40:04 +0200 | [diff] [blame] | 72 | IRQ_MV78XX0_GPIO_START, gpio0_irqs); |
Stanislav Samsonov | 794d15b | 2008-06-22 22:45:10 +0200 | [diff] [blame] | 73 | } |