ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / m68knommu / platform / 5249 / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/5249/config.c
5  *
6  *      Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
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 <linux/init.h>
16 #include <asm/irq.h>
17 #include <asm/dma.h>
18 #include <asm/traps.h>
19 #include <asm/machdep.h>
20 #include <asm/coldfire.h>
21 #include <asm/mcftimer.h>
22 #include <asm/mcfsim.h>
23 #include <asm/mcfdma.h>
24 #include <asm/delay.h>
25
26 /***************************************************************************/
27
28 void coldfire_tick(void);
29 void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
30 unsigned long coldfire_timer_offset(void);
31 void coldfire_trap_init(void);
32 void coldfire_reset(void);
33
34 /***************************************************************************/
35
36 /*
37  *      DMA channel base address table.
38  */
39 unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
40         MCF_MBAR + MCFDMA_BASE0,
41         MCF_MBAR + MCFDMA_BASE1,
42         MCF_MBAR + MCFDMA_BASE2,
43         MCF_MBAR + MCFDMA_BASE3,
44 };
45
46 unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
47
48 /***************************************************************************/
49
50 void mcf_autovector(unsigned int vec)
51 {
52         volatile unsigned char  *mbar;
53
54         if ((vec >= 25) && (vec <= 31)) {
55                 mbar = (volatile unsigned char *) MCF_MBAR;
56                 vec = 0x1 << (vec - 24);
57                 *(mbar + MCFSIM_AVR) |= vec;
58                 mcf_setimr(mcf_getimr() & ~vec);
59         }
60 }
61
62 /***************************************************************************/
63
64 void mcf_settimericr(unsigned int timer, unsigned int level)
65 {
66         volatile unsigned char *icrp;
67         unsigned int icr, imr;
68
69         if (timer <= 2) {
70                 switch (timer) {
71                 case 2:  icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
72                 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
73                 }
74
75                 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
76                 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
77                 mcf_setimr(mcf_getimr() & ~imr);
78         }
79 }
80
81 /***************************************************************************/
82
83 int mcf_timerirqpending(int timer)
84 {
85         unsigned int imr = 0;
86
87         switch (timer) {
88         case 1:  imr = MCFSIM_IMR_TIMER1; break;
89         case 2:  imr = MCFSIM_IMR_TIMER2; break;
90         default: break;
91         }
92         return (mcf_getipr() & imr);
93 }
94
95 /***************************************************************************/
96
97 void config_BSP(char *commandp, int size)
98 {
99         mcf_setimr(MCFSIM_IMR_MASKALL);
100
101 #if defined(CONFIG_BOOTPARAM)
102         strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
103         commandp[size-1] = 0;
104 #else
105         memset(commandp, 0, size);
106 #endif
107
108         mach_sched_init = coldfire_timer_init;
109         mach_tick = coldfire_tick;
110         mach_gettimeoffset = coldfire_timer_offset;
111         mach_trap_init = coldfire_trap_init;
112         mach_reset = coldfire_reset;
113 }
114
115 /***************************************************************************/