9d19d5bdb8afd3cc5598465965a921761dc92a80
[sfrench/cifs-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/kernel.h>
12 #include <linux/sched.h>
13 #include <linux/param.h>
14 #include <linux/init.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 /***************************************************************************/
25
26 void coldfire_tick(void);
27 void coldfire_timer_init(irqreturn_t (*handler)(int, void *, struct pt_regs *));
28 unsigned long coldfire_timer_offset(void);
29 void coldfire_trap_init(void);
30 void coldfire_reset(void);
31
32 /***************************************************************************/
33
34 /*
35  *      DMA channel base address table.
36  */
37 unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
38         MCF_MBAR + MCFDMA_BASE0,
39         MCF_MBAR + MCFDMA_BASE1,
40         MCF_MBAR + MCFDMA_BASE2,
41         MCF_MBAR + MCFDMA_BASE3,
42 };
43
44 unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
45
46 /***************************************************************************/
47
48 void mcf_autovector(unsigned int vec)
49 {
50         volatile unsigned char  *mbar;
51
52         if ((vec >= 25) && (vec <= 31)) {
53                 mbar = (volatile unsigned char *) MCF_MBAR;
54                 vec = 0x1 << (vec - 24);
55                 *(mbar + MCFSIM_AVR) |= vec;
56                 mcf_setimr(mcf_getimr() & ~vec);
57         }
58 }
59
60 /***************************************************************************/
61
62 void mcf_settimericr(unsigned int timer, unsigned int level)
63 {
64         volatile unsigned char *icrp;
65         unsigned int icr, imr;
66
67         if (timer <= 2) {
68                 switch (timer) {
69                 case 2:  icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
70                 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
71                 }
72
73                 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
74                 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
75                 mcf_setimr(mcf_getimr() & ~imr);
76         }
77 }
78
79 /***************************************************************************/
80
81 int mcf_timerirqpending(int timer)
82 {
83         unsigned int imr = 0;
84
85         switch (timer) {
86         case 1:  imr = MCFSIM_IMR_TIMER1; break;
87         case 2:  imr = MCFSIM_IMR_TIMER2; break;
88         default: break;
89         }
90         return (mcf_getipr() & imr);
91 }
92
93 /***************************************************************************/
94
95 void config_BSP(char *commandp, int size)
96 {
97         mcf_setimr(MCFSIM_IMR_MASKALL);
98
99 #if defined(CONFIG_BOOTPARAM)
100         strncpy(commandp, CONFIG_BOOTPARAM_STRING, size);
101         commandp[size-1] = 0;
102 #else
103         memset(commandp, 0, size);
104 #endif
105
106         mach_sched_init = coldfire_timer_init;
107         mach_tick = coldfire_tick;
108         mach_gettimeoffset = coldfire_timer_offset;
109         mach_trap_init = coldfire_trap_init;
110         mach_reset = coldfire_reset;
111 }
112
113 /***************************************************************************/