3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
6 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
7 * Marius Groeger <mgroeger@sysgo.de>
10 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
11 * Alex Zuepke <azu@sysgo.de>
13 * See file CREDITS for list of people who contributed to this
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.
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.
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,
33 #include <asm/arch/ixp425.h>
34 #include <asm/proc-armv/ptrace.h>
37 * When interrupts are enabled, use timer 2 for time/delay generation...
41 #define CLOCK_TICK_RATE (((FREQ / CONFIG_SYS_HZ & ~IXP425_OST_RELOAD_MASK) + 1) * CONFIG_SYS_HZ)
42 #define LATCH ((CLOCK_TICK_RATE + CONFIG_SYS_HZ/2) / CONFIG_SYS_HZ) /* For divider */
46 void (*m_func)( void *data);
49 static struct _irq_handler IRQ_HANDLER[N_IRQS];
51 static volatile ulong timestamp;
53 static void default_isr(void *data)
55 printf("default_isr(): called for IRQ %d, Interrupt Status=%x PR=%x\n",
56 (int)data, *IXP425_ICIP, *IXP425_ICIH);
59 static int next_irq(void)
61 return (((*IXP425_ICIH & 0x000000fc) >> 2) - 1);
64 static void timer_isr(void *data)
66 unsigned int *pTime = (unsigned int *)data;
73 *IXP425_OSST = IXP425_OSST_TIMER_2_PEND;
76 ulong get_timer (ulong base)
78 return timestamp - base;
81 void reset_timer (void)
86 void do_irq (struct pt_regs *pt_regs)
90 IRQ_HANDLER[irq].m_func(IRQ_HANDLER[irq].m_data);
93 int interrupt_init (void)
97 /* install default interrupt handlers */
98 for (i = 0; i < N_IRQS; i++) {
99 IRQ_HANDLER[i].m_data = (void *)i;
100 IRQ_HANDLER[i].m_func = default_isr;
103 /* install interrupt handler for timer */
104 IRQ_HANDLER[IXP425_TIMER_2_IRQ].m_data = (void *)×tamp;
105 IRQ_HANDLER[IXP425_TIMER_2_IRQ].m_func = timer_isr;
107 /* setup the Timer counter value */
108 *IXP425_OSRT2 = (LATCH & ~IXP425_OST_RELOAD_MASK) | IXP425_OST_ENABLE;
110 /* configure interrupts for IRQ mode */
111 *IXP425_ICLR = 0x00000000;
113 /* enable timer irq */
114 *IXP425_ICMR = (1 << IXP425_TIMER_2_IRQ);