blob: 0caae43301e54e472d82187680ed69fca4feda72 [file] [log] [blame]
Tzachi Perelstein3085de62007-10-23 15:14:42 -04001/*
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -04002 * arch/arm/mach-orion5x/irq.c
Tzachi Perelstein3085de62007-10-23 15:14:42 -04003 *
4 * Core IRQ functions for Marvell Orion System On Chip
5 *
6 * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
7 *
8 * This file is licensed under the terms of the GNU General Public
Lennert Buytenhek159ffb32008-03-27 14:51:41 -04009 * License version 2. This program is licensed "as is" without any
Tzachi Perelstein3085de62007-10-23 15:14:42 -040010 * warranty of any kind, whether express or implied.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/irq.h>
Russell Kingfced80c2008-09-06 12:10:45 +010016#include <linux/io.h>
Tzachi Perelstein3085de62007-10-23 15:14:42 -040017#include <asm/gpio.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010018#include <mach/orion5x.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020019#include <plat/irq.h>
Tzachi Perelstein3085de62007-10-23 15:14:42 -040020#include "common.h"
21
Lennert Buytenhek07332312008-10-20 01:51:03 +020022static void gpio_irq_handler(unsigned int irq, struct irq_desc *desc)
Tzachi Perelsteinf0066612007-11-15 10:57:48 +020023{
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040024 BUG_ON(irq < IRQ_ORION5X_GPIO_0_7 || irq > IRQ_ORION5X_GPIO_24_31);
Tzachi Perelstein3085de62007-10-23 15:14:42 -040025
Lennert Buytenhek07332312008-10-20 01:51:03 +020026 orion_gpio_irq_handler((irq - IRQ_ORION5X_GPIO_0_7) << 3);
Tzachi Perelstein3085de62007-10-23 15:14:42 -040027}
28
Lennert Buytenhek07332312008-10-20 01:51:03 +020029void __init orion5x_init_irq(void)
Tzachi Perelstein3085de62007-10-23 15:14:42 -040030{
31 int i;
Lennert Buytenhek07332312008-10-20 01:51:03 +020032
33 orion_irq_init(0, (void __iomem *)MAIN_IRQ_MASK);
Tzachi Perelstein3085de62007-10-23 15:14:42 -040034
35 /*
36 * Mask and clear GPIO IRQ interrupts
37 */
Lennert Buytenhek07332312008-10-20 01:51:03 +020038 writel(0x0, GPIO_LEVEL_MASK(0));
39 writel(0x0, GPIO_EDGE_MASK(0));
40 writel(0x0, GPIO_EDGE_CAUSE(0));
Tzachi Perelstein3085de62007-10-23 15:14:42 -040041
42 /*
Tzachi Perelsteinf0066612007-11-15 10:57:48 +020043 * Register chained level handlers for GPIO IRQs by default.
44 * User can use set_type() if he wants to use edge types handlers.
Tzachi Perelstein3085de62007-10-23 15:14:42 -040045 */
Lennert Buytenhek9dd0b192008-03-27 14:51:41 -040046 for (i = IRQ_ORION5X_GPIO_START; i < NR_IRQS; i++) {
Lennert Buytenhek07332312008-10-20 01:51:03 +020047 set_irq_chip(i, &orion_gpio_irq_level_chip);
Tzachi Perelstein3085de62007-10-23 15:14:42 -040048 set_irq_handler(i, handle_level_irq);
Lennert Buytenhek07332312008-10-20 01:51:03 +020049 irq_desc[i].status |= IRQ_LEVEL;
Tzachi Perelstein3085de62007-10-23 15:14:42 -040050 set_irq_flags(i, IRQF_VALID);
51 }
Lennert Buytenhek07332312008-10-20 01:51:03 +020052 set_irq_chained_handler(IRQ_ORION5X_GPIO_0_7, gpio_irq_handler);
53 set_irq_chained_handler(IRQ_ORION5X_GPIO_8_15, gpio_irq_handler);
54 set_irq_chained_handler(IRQ_ORION5X_GPIO_16_23, gpio_irq_handler);
55 set_irq_chained_handler(IRQ_ORION5X_GPIO_24_31, gpio_irq_handler);
Tzachi Perelstein3085de62007-10-23 15:14:42 -040056}