blob: 7694c6a6ccbcd40558a438981d4c996c853f572b [file] [log] [blame]
wdenkbd1575f2003-10-14 19:43:55 +00001/*
Wolfgang Denk4646d2a2006-05-30 15:56:48 +02002 * (C) Copyright 2006
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
wdenkbd1575f2003-10-14 19:43:55 +00005 * (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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020013 * SPDX-License-Identifier: GPL-2.0+
wdenkbd1575f2003-10-14 19:43:55 +000014 */
15
16#include <common.h>
17#include <asm/arch/ixp425.h>
Andreas Engel2d4b2532008-01-14 09:06:52 +000018#include <asm/proc-armv/ptrace.h>
19
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020020struct _irq_handler {
21 void *m_data;
22 void (*m_func)( void *data);
23};
24
25static struct _irq_handler IRQ_HANDLER[N_IRQS];
26
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020027static void default_isr(void *data)
28{
29 printf("default_isr(): called for IRQ %d, Interrupt Status=%x PR=%x\n",
30 (int)data, *IXP425_ICIP, *IXP425_ICIH);
31}
32
33static int next_irq(void)
34{
35 return (((*IXP425_ICIH & 0x000000fc) >> 2) - 1);
36}
37
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020038void do_irq (struct pt_regs *pt_regs)
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020039{
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020040 int irq = next_irq();
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020041
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020042 IRQ_HANDLER[irq].m_func(IRQ_HANDLER[irq].m_data);
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020043}
44
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020045void irq_install_handler (int irq, interrupt_handler_t handle_irq, void *data)
wdenkbd1575f2003-10-14 19:43:55 +000046{
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020047 if (irq >= N_IRQS || !handle_irq)
48 return;
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020049
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020050 IRQ_HANDLER[irq].m_data = data;
51 IRQ_HANDLER[irq].m_func = handle_irq;
wdenkbd1575f2003-10-14 19:43:55 +000052}
53
Jean-Christophe PLAGNIOL-VILLARDda7b3db2009-05-09 13:21:18 +020054int arch_interrupt_init (void)
wdenkbd1575f2003-10-14 19:43:55 +000055{
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020056 int i;
57
58 /* install default interrupt handlers */
Jean-Christophe PLAGNIOL-VILLARD8c9fc002009-05-15 23:47:02 +020059 for (i = 0; i < N_IRQS; i++)
60 irq_install_handler(i, default_isr, (void *)i);
Wolfgang Denk4646d2a2006-05-30 15:56:48 +020061
62 /* configure interrupts for IRQ mode */
63 *IXP425_ICLR = 0x00000000;
64
wdenkbd1575f2003-10-14 19:43:55 +000065 return (0);
66}