blob: 3ec1cd5c4f99733e4b1e76a9116f27b6040709b9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Lennert Buytenhekc852ac82006-09-18 23:26:25 +01002 * arch/arm/mach-iop32x/irq.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Lennert Buytenhek3f7e5812006-09-18 23:10:26 +01004 * Generic IOP32X IRQ handling functionality
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
6 * Author: Rory Bolt <rorybolt@pacbell.net>
7 * Copyright (C) 2002 Rory Bolt
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 */
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/list.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/mach/irq.h>
18#include <asm/irq.h>
19#include <asm/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/mach-types.h>
21
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010022static u32 iop32x_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24static inline void intctl_write(u32 val)
25{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010026 iop3xx_cp6_enable();
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010027 asm volatile("mcr p6, 0, %0, c0, c0, 0" : : "r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010028 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070029}
30
31static inline void intstr_write(u32 val)
32{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010033 iop3xx_cp6_enable();
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010034 asm volatile("mcr p6, 0, %0, c4, c0, 0" : : "r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010035 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070036}
37
38static void
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010039iop32x_irq_mask(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010041 iop32x_mask &= ~(1 << irq);
42 intctl_write(iop32x_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070043}
44
45static void
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010046iop32x_irq_unmask(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010048 iop32x_mask |= 1 << irq;
49 intctl_write(iop32x_mask);
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
David Brownell38c677c2006-08-01 22:26:25 +010052struct irq_chip ext_chip = {
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010053 .name = "IOP32x",
54 .ack = iop32x_irq_mask,
55 .mask = iop32x_irq_mask,
56 .unmask = iop32x_irq_unmask,
Linus Torvalds1da177e2005-04-16 15:20:36 -070057};
58
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010059void __init iop32x_init_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010061 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010063 intctl_write(0);
64 intstr_write(0);
Lennert Buytenhek0c92e832006-09-21 02:46:03 +010065 if (machine_is_glantank() ||
66 machine_is_iq80321() ||
Lennert Buytenheke60d07b2006-09-21 02:42:12 +010067 machine_is_iq31244() ||
68 machine_is_n2100())
Lennert Buytenhek7e9740b2006-09-18 23:17:36 +010069 *IOP3XX_PCIIRSR = 0x0f;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010071 for (i = 0; i < NR_IRQS; i++) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 set_irq_chip(i, &ext_chip);
Russell King10dd5ce2006-11-23 11:41:32 +000073 set_irq_handler(i, handle_level_irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 }
76}