wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 1 | /* |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 2 | * (C) Copyright 2006 |
| 3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 4 | * |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 5 | * (C) Copyright 2002 |
| 6 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 7 | * Marius Groeger <mgroeger@sysgo.de> |
| 8 | * |
| 9 | * (C) Copyright 2002 |
| 10 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 11 | * Alex Zuepke <azu@sysgo.de> |
| 12 | * |
| 13 | * See file CREDITS for list of people who contributed to this |
| 14 | * project. |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or |
| 17 | * modify it under the terms of the GNU General Public License as |
| 18 | * published by the Free Software Foundation; either version 2 of |
| 19 | * the License, or (at your option) any later version. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * You should have received a copy of the GNU General Public License |
| 27 | * along with this program; if not, write to the Free Software |
| 28 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 29 | * MA 02111-1307 USA |
| 30 | */ |
| 31 | |
| 32 | #include <common.h> |
| 33 | #include <asm/arch/ixp425.h> |
Andreas Engel | 2d4b253 | 2008-01-14 09:06:52 +0000 | [diff] [blame] | 34 | #include <asm/proc-armv/ptrace.h> |
| 35 | |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 36 | struct _irq_handler { |
| 37 | void *m_data; |
| 38 | void (*m_func)( void *data); |
| 39 | }; |
| 40 | |
| 41 | static struct _irq_handler IRQ_HANDLER[N_IRQS]; |
| 42 | |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 43 | static void default_isr(void *data) |
| 44 | { |
| 45 | printf("default_isr(): called for IRQ %d, Interrupt Status=%x PR=%x\n", |
| 46 | (int)data, *IXP425_ICIP, *IXP425_ICIH); |
| 47 | } |
| 48 | |
| 49 | static int next_irq(void) |
| 50 | { |
| 51 | return (((*IXP425_ICIH & 0x000000fc) >> 2) - 1); |
| 52 | } |
| 53 | |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 54 | void do_irq (struct pt_regs *pt_regs) |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 55 | { |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 56 | int irq = next_irq(); |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 57 | |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 58 | IRQ_HANDLER[irq].m_func(IRQ_HANDLER[irq].m_data); |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 59 | } |
| 60 | |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 61 | void irq_install_handler (int irq, interrupt_handler_t handle_irq, void *data) |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 62 | { |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 63 | if (irq >= N_IRQS || !handle_irq) |
| 64 | return; |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 65 | |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 66 | IRQ_HANDLER[irq].m_data = data; |
| 67 | IRQ_HANDLER[irq].m_func = handle_irq; |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Jean-Christophe PLAGNIOL-VILLARD | da7b3db | 2009-05-09 13:21:18 +0200 | [diff] [blame] | 70 | int arch_interrupt_init (void) |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 71 | { |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 72 | int i; |
| 73 | |
| 74 | /* install default interrupt handlers */ |
Jean-Christophe PLAGNIOL-VILLARD | 8c9fc00 | 2009-05-15 23:47:02 +0200 | [diff] [blame] | 75 | for (i = 0; i < N_IRQS; i++) |
| 76 | irq_install_handler(i, default_isr, (void *)i); |
Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 77 | |
| 78 | /* configure interrupts for IRQ mode */ |
| 79 | *IXP425_ICLR = 0x00000000; |
| 80 | |
wdenk | bd1575f | 2003-10-14 19:43:55 +0000 | [diff] [blame] | 81 | return (0); |
| 82 | } |