blob: 63304b3d0d7634232bc95f89b1502162fcedce85 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Lennert Buytenhekc852ac82006-09-18 23:26:25 +01002 * arch/arm/mach-iop33x/irq.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Generic IOP331 IRQ handling functionality
5 *
6 * Author: Dave Jiang <dave.jiang@intel.com>
7 * Copyright (C) 2003 Intel Corp.
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 iop33x_mask0;
23static u32 iop33x_mask1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010025static inline void intctl0_write(u32 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070026{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010027 iop3xx_cp6_enable();
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010028 asm volatile("mcr p6, 0, %0, c0, c0, 0" : : "r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010029 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070030}
31
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010032static inline void intctl1_write(u32 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010034 iop3xx_cp6_enable();
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010035 asm volatile("mcr p6, 0, %0, c1, c0, 0" : : "r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010036 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070037}
38
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010039static inline void intstr0_write(u32 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010041 iop3xx_cp6_enable();
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010042 asm volatile("mcr p6, 0, %0, c2, c0, 0" : : "r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010043 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070044}
45
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010046static inline void intstr1_write(u32 val)
Linus Torvalds1da177e2005-04-16 15:20:36 -070047{
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010048 iop3xx_cp6_enable();
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010049 asm volatile("mcr p6, 0, %0, c3, c0, 0" : : "r" (val));
Lennert Buytenhek38ce73e2006-09-18 23:21:38 +010050 iop3xx_cp6_disable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
52
Lennert Buytenhek7412b102006-09-18 23:24:10 +010053static inline void intbase_write(u32 val)
54{
55 iop3xx_cp6_enable();
56 asm volatile("mcr p6, 0, %0, c12, c0, 0" : : "r" (val));
57 iop3xx_cp6_disable();
58}
59
60static inline void intsize_write(u32 val)
61{
62 iop3xx_cp6_enable();
63 asm volatile("mcr p6, 0, %0, c13, c0, 0" : : "r" (val));
64 iop3xx_cp6_disable();
65}
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067static void
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010068iop33x_irq_mask1 (unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070069{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010070 iop33x_mask0 &= ~(1 << irq);
71 intctl0_write(iop33x_mask0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73
74static void
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010075iop33x_irq_mask2 (unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010077 iop33x_mask1 &= ~(1 << (irq - 32));
78 intctl1_write(iop33x_mask1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
81static void
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010082iop33x_irq_unmask1(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010084 iop33x_mask0 |= 1 << irq;
85 intctl0_write(iop33x_mask0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
87
88static void
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010089iop33x_irq_unmask2(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010091 iop33x_mask1 |= (1 << (irq - 32));
92 intctl1_write(iop33x_mask1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Lennert Buytenhekc852ac82006-09-18 23:26:25 +010095struct irq_chip iop33x_irqchip1 = {
96 .name = "IOP33x-1",
97 .ack = iop33x_irq_mask1,
98 .mask = iop33x_irq_mask1,
99 .unmask = iop33x_irq_unmask1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100};
101
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100102struct irq_chip iop33x_irqchip2 = {
103 .name = "IOP33x-2",
104 .ack = iop33x_irq_mask2,
105 .mask = iop33x_irq_mask2,
106 .unmask = iop33x_irq_unmask2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107};
108
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100109void __init iop33x_init_irq(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100111 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100113 intctl0_write(0);
114 intctl1_write(0);
115 intstr0_write(0);
116 intstr1_write(0);
Lennert Buytenhek7412b102006-09-18 23:24:10 +0100117 intbase_write(0);
118 intsize_write(1);
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100119 if (machine_is_iq80331())
Lennert Buytenhek7e9740b2006-09-18 23:17:36 +0100120 *IOP3XX_PCIIRSR = 0x0f;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Lennert Buytenhekc852ac82006-09-18 23:26:25 +0100122 for (i = 0; i < NR_IRQS; i++) {
123 set_irq_chip(i, (i < 32) ? &iop33x_irqchip1 : &iop33x_irqchip2);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 set_irq_handler(i, do_level_IRQ);
125 set_irq_flags(i, IRQF_VALID | IRQF_PROBE);
126 }
127}