blob: 0479a1048b9ebbf34e7a4fb5eaeeebabb48701b8 [file] [log] [blame]
wdenk32fe2872002-10-11 07:57:01 +00001/*
2 * (C) Copyright 2002
3 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
4 * Marius Groeger <mgroeger@sysgo.de>
5 *
6 * (C) Copyright 2002
7 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
8 * Alex Zuepke <azu@sysgo.de>
9 *
10 * See file CREDITS for list of people who contributed to this
11 * project.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 * MA 02111-1307 USA
27 */
28
29#include <common.h>
30#include <asm/arch/pxa-regs.h>
31
wdenk32fe2872002-10-11 07:57:01 +000032#ifdef CONFIG_USE_IRQ
33/* enable IRQ/FIQ interrupts */
34void enable_interrupts (void)
35{
36#error: interrupts not implemented yet
37}
38
39
40/*
41 * disable IRQ/FIQ interrupts
42 * returns true if interrupts had been enabled before we disabled them
43 */
44int disable_interrupts (void)
45{
46#error: interrupts not implemented yet
47}
48#else
49void enable_interrupts (void)
50{
51 return;
52}
53int disable_interrupts (void)
54{
55 return 0;
56}
57#endif
58
59
wdenk32fe2872002-10-11 07:57:01 +000060void bad_mode (void)
61{
62 panic ("Resetting CPU ...\n");
63 reset_cpu (0);
64}
65
66void show_regs (struct pt_regs *regs)
67{
68 unsigned long flags;
69 const char *processor_modes[] = {
70 "USER_26", "FIQ_26", "IRQ_26", "SVC_26",
71 "UK4_26", "UK5_26", "UK6_26", "UK7_26",
72 "UK8_26", "UK9_26", "UK10_26", "UK11_26",
73 "UK12_26", "UK13_26", "UK14_26", "UK15_26",
74 "USER_32", "FIQ_32", "IRQ_32", "SVC_32",
75 "UK4_32", "UK5_32", "UK6_32", "ABT_32",
76 "UK8_32", "UK9_32", "UK10_32", "UND_32",
77 "UK12_32", "UK13_32", "UK14_32", "SYS_32"
78 };
79
80 flags = condition_codes (regs);
81
82 printf ("pc : [<%08lx>] lr : [<%08lx>]\n"
83 "sp : %08lx ip : %08lx fp : %08lx\n",
84 instruction_pointer (regs),
85 regs->ARM_lr, regs->ARM_sp, regs->ARM_ip, regs->ARM_fp);
86 printf ("r10: %08lx r9 : %08lx r8 : %08lx\n",
87 regs->ARM_r10, regs->ARM_r9, regs->ARM_r8);
88 printf ("r7 : %08lx r6 : %08lx r5 : %08lx r4 : %08lx\n",
89 regs->ARM_r7, regs->ARM_r6, regs->ARM_r5, regs->ARM_r4);
90 printf ("r3 : %08lx r2 : %08lx r1 : %08lx r0 : %08lx\n",
91 regs->ARM_r3, regs->ARM_r2, regs->ARM_r1, regs->ARM_r0);
92 printf ("Flags: %c%c%c%c",
93 flags & CC_N_BIT ? 'N' : 'n',
94 flags & CC_Z_BIT ? 'Z' : 'z',
95 flags & CC_C_BIT ? 'C' : 'c', flags & CC_V_BIT ? 'V' : 'v');
96 printf (" IRQs %s FIQs %s Mode %s%s\n",
97 interrupts_enabled (regs) ? "on" : "off",
98 fast_interrupts_enabled (regs) ? "on" : "off",
99 processor_modes[processor_mode (regs)],
100 thumb_mode (regs) ? " (T)" : "");
101}
102
103void do_undefined_instruction (struct pt_regs *pt_regs)
104{
105 printf ("undefined instruction\n");
106 show_regs (pt_regs);
107 bad_mode ();
108}
109
110void do_software_interrupt (struct pt_regs *pt_regs)
111{
112 printf ("software interrupt\n");
113 show_regs (pt_regs);
114 bad_mode ();
115}
116
117void do_prefetch_abort (struct pt_regs *pt_regs)
118{
119 printf ("prefetch abort\n");
120 show_regs (pt_regs);
121 bad_mode ();
122}
123
124void do_data_abort (struct pt_regs *pt_regs)
125{
126 printf ("data abort\n");
127 show_regs (pt_regs);
128 bad_mode ();
129}
130
131void do_not_used (struct pt_regs *pt_regs)
132{
133 printf ("not used\n");
134 show_regs (pt_regs);
135 bad_mode ();
136}
137
138void do_fiq (struct pt_regs *pt_regs)
139{
140 printf ("fast interrupt request\n");
141 show_regs (pt_regs);
142 bad_mode ();
143}
144
145void do_irq (struct pt_regs *pt_regs)
146{
147 printf ("interrupt request\n");
148 show_regs (pt_regs);
149 bad_mode ();
150}
151
152
153int interrupt_init (void)
154{
155 /* nothing happens here - we don't setup any IRQs */
156 return (0);
157}
158
159void reset_timer (void)
160{
161 reset_timer_masked ();
162}
163
164ulong get_timer (ulong base)
165{
wdenk3c711762004-06-09 13:37:52 +0000166 return get_timer_masked () - base;
wdenk32fe2872002-10-11 07:57:01 +0000167}
168
169void set_timer (ulong t)
170{
171 /* nop */
172}
173
174void udelay (unsigned long usec)
175{
176 udelay_masked (usec);
177}
178
179
180void reset_timer_masked (void)
181{
182 OSCR = 0;
183}
184
185ulong get_timer_masked (void)
186{
187 return OSCR;
188}
189
190void udelay_masked (unsigned long usec)
191{
192 ulong tmo;
wdenk7af1f9d2005-04-04 12:08:28 +0000193 ulong endtime;
194 signed long diff;
wdenk32fe2872002-10-11 07:57:01 +0000195
wdenkac40ade2004-11-24 23:35:19 +0000196 if (usec >= 1000) {
197 tmo = usec / 1000;
198 tmo *= CFG_HZ;
199 tmo /= 1000;
200 } else {
201 tmo = usec * CFG_HZ;
202 tmo /= (1000*1000);
203 }
wdenk32fe2872002-10-11 07:57:01 +0000204
wdenk7af1f9d2005-04-04 12:08:28 +0000205 endtime = get_timer_masked () + tmo;
wdenk32fe2872002-10-11 07:57:01 +0000206
wdenk7af1f9d2005-04-04 12:08:28 +0000207 do {
208 ulong now = get_timer_masked ();
209 diff = endtime - now;
210 } while (diff >= 0);
wdenk32fe2872002-10-11 07:57:01 +0000211}
wdenk49c3f672003-10-08 22:33:00 +0000212
213/*
214 * This function is derived from PowerPC code (read timebase as long long).
215 * On ARM it just returns the timer value.
216 */
217unsigned long long get_ticks(void)
218{
219 return get_timer(0);
220}
221
222/*
223 * This function is derived from PowerPC code (timebase clock frequency).
224 * On ARM it returns the number of timer ticks per second.
225 */
226ulong get_tbclk (void)
227{
228 ulong tbclk;
229 tbclk = CFG_HZ;
230 return tbclk;
231}