OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uClinux-2.0.x/] [arch/] [m68knommu/] [platform/] [5206e/] [config.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/***************************************************************************/
2
 
3
/*
4
 *      linux/arch/m68knommu/platform/5206e/config.c
5
 *
6
 *      Copyright (C) 1999-2000, Greg Ungerer (gerg@moreton.com.au)
7
 */
8
 
9
/***************************************************************************/
10
 
11
#include <linux/config.h>
12
#include <linux/kernel.h>
13
#include <linux/sched.h>
14
#include <linux/param.h>
15
#include <asm/irq.h>
16
#include <asm/dma.h>
17
#include <asm/traps.h>
18
#include <asm/machdep.h>
19
#include <asm/coldfire.h>
20
#include <asm/mcftimer.h>
21
#include <asm/mcfsim.h>
22
#include <asm/mcfdma.h>
23
 
24
#ifdef CONFIG_NETtel
25
#include <asm/irq.h>
26
#include <asm/delay.h>
27
#include <asm/nettel.h>
28
#endif
29
 
30
/***************************************************************************/
31
 
32
#ifdef CONFIG_NETtel
33
void    reset_setupbutton(void);
34
#endif
35
 
36
/***************************************************************************/
37
 
38
/*
39
 *      DMA channel base address table.
40
 */
41
unsigned int   dma_base_addr[MAX_DMA_CHANNELS] = {
42
        MCF_MBAR + MCFDMA_BASE0,
43
        MCF_MBAR + MCFDMA_BASE1,
44
};
45
 
46
/***************************************************************************/
47
 
48
void coldfire_tick(void)
49
{
50
        volatile unsigned char  *timerp;
51
 
52
        /* Reset the ColdFire timer */
53
        timerp = (volatile unsigned char *) (MCF_MBAR + MCFTIMER_BASE1);
54
        timerp[MCFTIMER_TER] = MCFTIMER_TER_CAP | MCFTIMER_TER_REF;
55
 
56
#ifdef CONFIG_NETtel
57
/*
58
 *      This is some NETtel LED flashing code. Gotta love flashing
59
 *      LEDs :-)
60
 */
61
{
62
        static unsigned int     ticks = 0, oldgetled = 0;
63
 
64
#ifdef NETtel_LEDETH
65
        extern int              ethernet_tick;
66
        if (ethernet_tick-- == 0)
67
                unsetled(NETtel_LEDETH);
68
#endif
69
        ledbank = (ledbank | oldgetled) ^ GETLED();
70
        oldgetled = GETLED();
71
        if ((ticks = (ticks + 1) & 0x3f) > 0xf) {
72
                unsetledpp(NETtel_LEDDIAG);
73
                rewriteled();
74
        } else {
75
                setledpp(NETtel_LEDDIAG);
76
                writeled(GETFLASH());
77
        }
78
}
79
#endif /* CONFIG_NETtel */
80
}
81
 
82
/***************************************************************************/
83
 
84
void coldfire_timer_init(void (*handler)(int, void *, struct pt_regs *))
85
{
86
        volatile unsigned short *timerp;
87
        volatile unsigned char  *icrp;
88
 
89
        /* Set up TIMER 1 as poll clock */
90
        timerp = (volatile unsigned short *) (MCF_MBAR + MCFTIMER_BASE1);
91
        timerp[MCFTIMER_TMR] = MCFTIMER_TMR_DISABLE;
92
 
93
        timerp[MCFTIMER_TRR] = (unsigned short) ((MCF_CLK / 16) / HZ);
94
        timerp[MCFTIMER_TMR] = MCFTIMER_TMR_ENORI | MCFTIMER_TMR_CLK16 |
95
                MCFTIMER_TMR_RESTART | MCFTIMER_TMR_ENABLE;
96
 
97
        icrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_TIMER1ICR);
98
 
99
#ifdef CONFIG_NETtel
100
        *icrp = MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI3;
101
        request_irq(30, handler, SA_INTERRUPT, "ColdFire Timer", NULL);
102
        reset_setupbutton();
103
#else
104
        *icrp = MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI3;
105
        request_irq(29, handler, SA_INTERRUPT, "ColdFire Timer", NULL);
106
#endif
107
        mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_TIMER1);
108
}
109
 
110
/***************************************************************************/
111
 
112
/*
113
 *      Program the vector to be an auto-vectored.
114
 */
115
 
116
void mcf_autovector(unsigned int vec)
117
{
118
        volatile unsigned char  *mbar;
119
        unsigned char           icr;
120
 
121
        if ((vec >= 25) && (vec <= 31)) {
122
                vec -= 25;
123
                mbar = (volatile unsigned char *) MCF_MBAR;
124
                icr = MCFSIM_ICR_AUTOVEC | (vec << 3);
125
                *(mbar + MCFSIM_ICR1 + vec) = icr;
126
                vec = 0x1 << (vec + 1);
127
                mcf_setimr(mcf_getimr() & ~vec);
128
        }
129
}
130
 
131
/***************************************************************************/
132
 
133
extern e_vector *_ramvec;
134
 
135
void set_evector(int vecnum, void (*handler)(void))
136
{
137
        if (vecnum >= 0 && vecnum <= 255)
138
                _ramvec[vecnum] = handler;
139
}
140
 
141
/***************************************************************************/
142
 
143
/* assembler routines */
144
asmlinkage void buserr(void);
145
asmlinkage void trap(void);
146
asmlinkage void system_call(void);
147
asmlinkage void intrhandler(void);
148
 
149
void coldfire_trap_init(void)
150
{
151
        int i;
152
 
153
#ifndef ENABLE_dBUG
154
        mcf_setimr(MCFSIM_IMR_MASKALL);
155
#endif
156
 
157
        /*
158
         *      There is a common trap handler and common interrupt
159
         *      handler that handle almost every vector. We treat
160
         *      the system call and bus error special, they get their
161
         *      own first level handlers.
162
         */
163
#ifndef ENABLE_dBUG
164
        for (i = 3; (i <= 23); i++)
165
                _ramvec[i] = trap;
166
        for (i = 33; (i <= 63); i++)
167
                _ramvec[i] = trap;
168
#endif
169
 
170
        for (i = 24; (i <= 30); i++)
171
                _ramvec[i] = intrhandler;
172
#ifndef ENABLE_dBUG
173
        _ramvec[31] = intrhandler;  // Disables the IRQ7 button
174
#endif
175
 
176
        for (i = 64; (i < 255); i++)
177
                _ramvec[i] = intrhandler;
178
        _ramvec[255] = 0;
179
 
180
        _ramvec[2] = buserr;
181
        _ramvec[32] = system_call;
182
}
183
 
184
/***************************************************************************/
185
 
186
/*
187
 *      Generic dumping code. Used for panic and debug.
188
 */
189
 
190
void dump(struct pt_regs *fp)
191
{
192
        extern unsigned int sw_usp, sw_ksp;
193
        unsigned long   *sp;
194
        unsigned char   *tp;
195
        int             i;
196
 
197
        printk("\nCURRENT PROCESS:\n\n");
198
        printk("COMM=%s PID=%d\n", current->comm, current->pid);
199
        printk("TEXT=%08x-%08x DATA=%08x-%08x BSS=%08x-%08x\n",
200
                (int) current->mm->start_code,
201
                (int) current->mm->end_code,
202
                (int) current->mm->start_data,
203
                (int) current->mm->end_data,
204
                (int) current->mm->end_data,
205
                (int) current->mm->brk);
206
        printk("USER-STACK=%08x  KERNEL-STACK=%08x\n\n",
207
                (int) current->mm->start_stack,
208
                (int) current->kernel_stack_page);
209
 
210
        printk("PC: %08lx\n", fp->pc);
211
        printk("SR: %08lx    SP: %08lx\n", (long) fp->sr, (long) fp);
212
        printk("d0: %08lx    d1: %08lx    d2: %08lx    d3: %08lx\n",
213
                fp->d0, fp->d1, fp->d2, fp->d3);
214
        printk("d4: %08lx    d5: %08lx    a0: %08lx    a1: %08lx\n",
215
                fp->d4, fp->d5, fp->a0, fp->a1);
216
        printk("\nUSP: %08x   KSP: %08x   TRAPFRAME: %08x\n",
217
                sw_usp, sw_ksp, (unsigned int) fp);
218
 
219
        printk("\nCODE:");
220
        tp = ((unsigned char *) fp->pc) - 0x20;
221
        for (sp = (unsigned long *) tp, i = 0; (i < 0x40);  i += 4) {
222
                if ((i % 0x10) == 0)
223
                        printk("\n%08x: ", (int) (tp + i));
224
                printk("%08x ", (int) *sp++);
225
        }
226
        printk("\n");
227
 
228
        printk("\nKERNEL STACK:");
229
        tp = ((unsigned char *) fp) - 0x40;
230
        for (sp = (unsigned long *) tp, i = 0; (i < 0xc0); i += 4) {
231
                if ((i % 0x10) == 0)
232
                        printk("\n%08x: ", (int) (tp + i));
233
                printk("%08x ", (int) *sp++);
234
        }
235
        printk("\n");
236
        if (STACK_MAGIC != *(unsigned long *)current->kernel_stack_page)
237
                printk("(Possibly corrupted stack page??)\n");
238
        printk("\n");
239
 
240
#if 1
241
        printk("\nUSER STACK:");
242
        tp = (unsigned char *) sw_usp;
243
        for (sp = (unsigned long *) tp, i = 0; (i < 0x80); i += 4) {
244
                if ((i % 0x10) == 0)
245
                        printk("\n%08x: ", (int) (tp + i));
246
                printk("%08x ", (int) *sp++);
247
        }
248
        printk("\n\n");
249
#endif
250
}
251
 
252
/***************************************************************************/
253
 
254
#ifdef CONFIG_NETtel
255
 
256
/*
257
 *      Routines to support the NETtel software reset button.
258
 */
259
void reset_button(int irq, void *dev_id, struct pt_regs *regs)
260
{
261
        extern void     flash_eraseconfig(void);
262
        static int      inbutton = 0;
263
 
264
        /*
265
         *      IRQ7 is not maskable by the CPU core. It is possible
266
         *      that switch bounce mey get us back here before we have
267
         *      really serviced the interrupt.
268
         */
269
        if (inbutton)
270
                return;
271
        inbutton = 1;
272
        /* Disable interrupt at SIM - best we can do... */
273
        mcf_setimr(mcf_getimr() | MCFSIM_IMR_EINT7);
274
        /* Try and de-bounce the switch a little... */
275
        udelay(10000);
276
 
277
        flash_eraseconfig();
278
 
279
        /* Don't leave here 'till button is no longer pushed! */
280
        for (;;) {
281
                if ((mcf_getipr() & MCFSIM_IMR_EINT7) == 0)
282
                        break;
283
        }
284
 
285
        HARD_RESET_NOW();
286
        /* Should never get here... */
287
 
288
        inbutton = 0;
289
        /* Interrupt service done, enable it again */
290
        mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT7);
291
}
292
 
293
/***************************************************************************/
294
 
295
void reset_setupbutton(void)
296
{
297
        volatile unsigned char  *mbar;
298
 
299
        mbar = (volatile unsigned char *) MCF_MBAR;
300
 
301
        /* FIXME: this is broken for 5206! */
302
#if 0
303
        *(mbar + MCFSIM_AVR) |= MCFSIM_IMR_EINT7;
304
        mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_EINT7);
305
        request_irq(31, reset_button, (SA_INTERRUPT | IRQ_FLG_FAST),
306
                "Reset Button", NULL);
307
#endif
308
}
309
 
310
#endif /* CONFIG_NETtel */
311
 
312
/***************************************************************************/
313
 
314
void config_BSP(char *commandp, int size)
315
{
316
#ifdef CONFIG_NETtel
317
        /* Copy command line from FLASH to local buffer... */
318
        memcpy(commandp, (char *) 0xf0004000, size);
319
        commandp[size-1] = 0;
320
#else
321
        memset(commandp, 0, size);
322
#endif /* CONFIG_NETtel */
323
 
324
        mach_sched_init = coldfire_timer_init;
325
        mach_tick = coldfire_tick;
326
        mach_trap_init = coldfire_trap_init;
327
}
328
 
329
/***************************************************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.