Merge branch 'sg' of git://git.kernel.dk/linux-2.6-block
[sfrench/cifs-2.6.git] / arch / m68knommu / platform / 5307 / config.c
1 /***************************************************************************/
2
3 /*
4  *      linux/arch/m68knommu/platform/5307/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/param.h>
14 #include <linux/init.h>
15 #include <linux/interrupt.h>
16 #include <asm/dma.h>
17 #include <asm/machdep.h>
18 #include <asm/coldfire.h>
19 #include <asm/mcfsim.h>
20 #include <asm/mcfdma.h>
21 #include <asm/mcfwdebug.h>
22
23 /***************************************************************************/
24
25 void coldfire_reset(void);
26
27 extern unsigned int mcf_timervector;
28 extern unsigned int mcf_profilevector;
29 extern unsigned int mcf_timerlevel;
30
31 /***************************************************************************/
32
33 /*
34  *      Some platforms need software versions of the GPIO data registers.
35  */
36 unsigned short ppdata;
37 unsigned char ledbank = 0xff;
38
39 /***************************************************************************/
40
41 /*
42  *      DMA channel base address table.
43  */
44 unsigned int   dma_base_addr[MAX_M68K_DMA_CHANNELS] = {
45         MCF_MBAR + MCFDMA_BASE0,
46         MCF_MBAR + MCFDMA_BASE1,
47         MCF_MBAR + MCFDMA_BASE2,
48         MCF_MBAR + MCFDMA_BASE3,
49 };
50
51 unsigned int dma_device_address[MAX_M68K_DMA_CHANNELS];
52
53 /***************************************************************************/
54
55 void mcf_autovector(unsigned int vec)
56 {
57         volatile unsigned char  *mbar;
58
59         if ((vec >= 25) && (vec <= 31)) {
60                 mbar = (volatile unsigned char *) MCF_MBAR;
61                 vec = 0x1 << (vec - 24);
62                 *(mbar + MCFSIM_AVR) |= vec;
63                 mcf_setimr(mcf_getimr() & ~vec);
64         }
65 }
66
67 /***************************************************************************/
68
69 void mcf_settimericr(unsigned int timer, unsigned int level)
70 {
71         volatile unsigned char *icrp;
72         unsigned int icr, imr;
73
74         if (timer <= 2) {
75                 switch (timer) {
76                 case 2:  icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
77                 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
78                 }
79
80                 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
81                 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
82                 mcf_setimr(mcf_getimr() & ~imr);
83         }
84 }
85
86 /***************************************************************************/
87
88 int mcf_timerirqpending(int timer)
89 {
90         unsigned int imr = 0;
91
92         switch (timer) {
93         case 1:  imr = MCFSIM_IMR_TIMER1; break;
94         case 2:  imr = MCFSIM_IMR_TIMER2; break;
95         default: break;
96         }
97         return (mcf_getipr() & imr);
98 }
99
100 /***************************************************************************/
101
102 void config_BSP(char *commandp, int size)
103 {
104         mcf_setimr(MCFSIM_IMR_MASKALL);
105
106 #if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
107       defined(CONFIG_DISKtel) || defined(CONFIG_SECUREEDGEMP3) || \
108       defined(CONFIG_CLEOPATRA)
109         /* Copy command line from FLASH to local buffer... */
110         memcpy(commandp, (char *) 0xf0004000, size);
111         commandp[size-1] = 0;
112         /* Different timer setup - to prevent device clash */
113         mcf_timervector = 30;
114         mcf_profilevector = 31;
115         mcf_timerlevel = 6;
116 #endif
117
118         mach_reset = coldfire_reset;
119
120 #ifdef MCF_BDM_DISABLE
121         /*
122          * Disable the BDM clocking.  This also turns off most of the rest of
123          * the BDM device.  This is good for EMC reasons. This option is not
124          * incompatible with the memory protection option.
125          */
126         wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK);
127 #endif
128 }
129
130 /***************************************************************************/