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>
37 * When interrupts are enabled, use timer 2 for time/delay generation...
41 #define CLOCK_TICK_RATE (((FREQ / CFG_HZ & ~IXP425_OST_RELOAD_MASK) + 1) * CFG_HZ)
42 #define LATCH ((CLOCK_TICK_RATE + CFG_HZ/2) / CFG_HZ) /* For divider */
46 void (*m_func
)( void *data
);
49 static struct _irq_handler IRQ_HANDLER
[N_IRQS
];
51 static volatile ulong timestamp
;
53 /* enable IRQ/FIQ interrupts */
54 void enable_interrupts(void)
57 __asm__
__volatile__("mrs %0, cpsr\n"
66 * disable IRQ/FIQ interrupts
67 * returns true if interrupts had been enabled before we disabled them
69 int disable_interrupts(void)
71 unsigned long old
,temp
;
72 __asm__
__volatile__("mrs %0, cpsr\n"
75 : "=r" (old
), "=r" (temp
)
78 return (old
& 0x80) == 0;
81 static void default_isr(void *data
)
83 printf("default_isr(): called for IRQ %d, Interrupt Status=%x PR=%x\n",
84 (int)data
, *IXP425_ICIP
, *IXP425_ICIH
);
87 static int next_irq(void)
89 return (((*IXP425_ICIH
& 0x000000fc) >> 2) - 1);
92 static void timer_isr(void *data
)
94 unsigned int *pTime
= (unsigned int *)data
;
101 *IXP425_OSST
= IXP425_OSST_TIMER_2_PEND
;
104 ulong
get_timer (ulong base
)
106 return timestamp
- base
;
109 void reset_timer (void)
114 #else /* #ifdef CONFIG_USE_IRQ */
115 void enable_interrupts (void)
119 int disable_interrupts (void)
123 #endif /* #ifdef CONFIG_USE_IRQ */
127 panic ("Resetting CPU ...\n");
131 void show_regs (struct pt_regs
*regs
)
134 const char *processor_modes
[] = {
135 "USER_26", "FIQ_26", "IRQ_26", "SVC_26",
136 "UK4_26", "UK5_26", "UK6_26", "UK7_26",
137 "UK8_26", "UK9_26", "UK10_26", "UK11_26",
138 "UK12_26", "UK13_26", "UK14_26", "UK15_26",
139 "USER_32", "FIQ_32", "IRQ_32", "SVC_32",
140 "UK4_32", "UK5_32", "UK6_32", "ABT_32",
141 "UK8_32", "UK9_32", "UK10_32", "UND_32",
142 "UK12_32", "UK13_32", "UK14_32", "SYS_32"
145 flags
= condition_codes (regs
);
147 printf ("pc : [<%08lx>] lr : [<%08lx>]\n"
148 "sp : %08lx ip : %08lx fp : %08lx\n",
149 instruction_pointer (regs
),
150 regs
->ARM_lr
, regs
->ARM_sp
, regs
->ARM_ip
, regs
->ARM_fp
);
151 printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
152 regs
->ARM_r10
, regs
->ARM_r9
, regs
->ARM_r8
);
153 printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
154 regs
->ARM_r7
, regs
->ARM_r6
, regs
->ARM_r5
, regs
->ARM_r4
);
155 printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
156 regs
->ARM_r3
, regs
->ARM_r2
, regs
->ARM_r1
, regs
->ARM_r0
);
157 printf ("Flags: %c%c%c%c",
158 flags
& CC_N_BIT
? 'N' : 'n',
159 flags
& CC_Z_BIT
? 'Z' : 'z',
160 flags
& CC_C_BIT
? 'C' : 'c', flags
& CC_V_BIT
? 'V' : 'v');
161 printf (" IRQs %s FIQs %s Mode %s%s\n",
162 interrupts_enabled (regs
) ? "on" : "off",
163 fast_interrupts_enabled (regs
) ? "on" : "off",
164 processor_modes
[processor_mode (regs
)],
165 thumb_mode (regs
) ? " (T)" : "");
168 void do_undefined_instruction (struct pt_regs
*pt_regs
)
170 printf ("undefined instruction\n");
175 void do_software_interrupt (struct pt_regs
*pt_regs
)
177 printf ("software interrupt\n");
182 void do_prefetch_abort (struct pt_regs
*pt_regs
)
184 printf ("prefetch abort\n");
189 void do_data_abort (struct pt_regs
*pt_regs
)
191 printf ("data abort\n");
196 void do_not_used (struct pt_regs
*pt_regs
)
198 printf ("not used\n");
203 void do_fiq (struct pt_regs
*pt_regs
)
205 printf ("fast interrupt request\n");
207 printf("IRQ=%08lx FIQ=%08lx\n", *IXP425_ICIH
, *IXP425_ICFH
);
210 void do_irq (struct pt_regs
*pt_regs
)
212 #ifdef CONFIG_USE_IRQ
213 int irq
= next_irq();
215 IRQ_HANDLER
[irq
].m_func(IRQ_HANDLER
[irq
].m_data
);
217 printf ("interrupt request\n");
223 int interrupt_init (void)
225 #ifdef CONFIG_USE_IRQ
228 /* install default interrupt handlers */
229 for (i
= 0; i
< N_IRQS
; i
++) {
230 IRQ_HANDLER
[i
].m_data
= (void *)i
;
231 IRQ_HANDLER
[i
].m_func
= default_isr
;
234 /* install interrupt handler for timer */
235 IRQ_HANDLER
[IXP425_TIMER_2_IRQ
].m_data
= (void *)×tamp
;
236 IRQ_HANDLER
[IXP425_TIMER_2_IRQ
].m_func
= timer_isr
;
238 /* setup the Timer counter value */
239 *IXP425_OSRT2
= (LATCH
& ~IXP425_OST_RELOAD_MASK
) | IXP425_OST_ENABLE
;
241 /* configure interrupts for IRQ mode */
242 *IXP425_ICLR
= 0x00000000;
244 /* enable timer irq */
245 *IXP425_ICMR
= (1 << IXP425_TIMER_2_IRQ
);