Merge branch 'master' of /home/sam/kernel/linux-2.6/
[pandora-kernel.git] / arch / m68knommu / platform / 5407 / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/5407/config.c
5  *
6  *      Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
7  *      Copyright (C) 2000, Lineo (www.lineo.com)
8  */
9
10 /***************************************************************************/
11
12 #include <linux/kernel.h>
13 #include <linux/sched.h>
14 #include <linux/param.h>
15 #include <linux/init.h>
16 #include <linux/interrupt.h>
17 #include <asm/irq.h>
18 #include <asm/dma.h>
19 #include <asm/traps.h>
20 #include <asm/machdep.h>
21 #include <asm/coldfire.h>
22 #include <asm/mcftimer.h>
23 #include <asm/mcfsim.h>
24 #include <asm/mcfdma.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 extern unsigned int mcf_timervector;
35 extern unsigned int mcf_profilevector;
36 extern unsigned int mcf_timerlevel;
37
38 /***************************************************************************/
39
40 /*
41  *      DMA channel base address table.
42  */
43 unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
44         MCF_MBAR + MCFDMA_BASE0,
45         MCF_MBAR + MCFDMA_BASE1,
46         MCF_MBAR + MCFDMA_BASE2,
47         MCF_MBAR + MCFDMA_BASE3,
48 };
49
50 unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
51
52 /***************************************************************************/
53
54 void mcf_autovector(unsigned int vec)
55 {
56         volatile unsigned char  *mbar;
57
58         if ((vec >= 25) && (vec <= 31)) {
59                 mbar = (volatile unsigned char *) MCF_MBAR;
60                 vec = 0x1 << (vec - 24);
61                 *(mbar + MCFSIM_AVR) |= vec;
62                 mcf_setimr(mcf_getimr() & ~vec);
63         }
64 }
65
66 /***************************************************************************/
67
68 void mcf_settimericr(unsigned int timer, unsigned int level)
69 {
70         volatile unsigned char *icrp;
71         unsigned int icr, imr;
72
73         if (timer <= 2) {
74                 switch (timer) {
75                 case 2:  icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
76                 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
77                 }
78
79                 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
80                 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
81                 mcf_setimr(mcf_getimr() & ~imr);
82         }
83 }
84
85 /***************************************************************************/
86
87 int mcf_timerirqpending(int timer)
88 {
89         unsigned int imr = 0;
90
91         switch (timer) {
92         case 1:  imr = MCFSIM_IMR_TIMER1; break;
93         case 2:  imr = MCFSIM_IMR_TIMER2; break;
94         default: break;
95         }
96         return (mcf_getipr() & imr);
97 }
98
99 /***************************************************************************/
100
101 void config_BSP(char *commandp, int size)
102 {
103         mcf_setimr(MCFSIM_IMR_MASKALL);
104
105 #if defined(CONFIG_BOOTPARAM)
106         strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
107         commandp[size-1] = 0;
108 #else
109         memset(commandp, 0, size);
110 #endif
111
112 #if defined(CONFIG_CLEOPATRA)
113         /* Different timer setup - to prevent device clash */
114         mcf_timervector = 30;
115         mcf_profilevector = 31;
116         mcf_timerlevel = 6;
117 #endif
118
119         mach_sched_init = coldfire_timer_init;
120         mach_tick = coldfire_tick;
121         mach_gettimeoffset = coldfire_timer_offset;
122         mach_trap_init = coldfire_trap_init;
123         mach_reset = coldfire_reset;
124 }
125
126 /***************************************************************************/