Merge branch 'upstream' of git://lost.foo-projects.org/~ahkok/git/netdev-2.6 into...
[pandora-kernel.git] / arch / m68knommu / platform / 68VZ328 / config.c
1 /***************************************************************************/
2
3 /*
4  *  linux/arch/m68knommu/platform/68VZ328/config.c
5  *
6  *  Copyright (C) 1993 Hamish Macdonald
7  *  Copyright (C) 1999 D. Jeff Dionne
8  *  Copyright (C) 2001 Georges Menie, Ken Desmet
9  *
10  * This file is subject to the terms and conditions of the GNU General Public
11  * License.  See the file COPYING in the main directory of this archive
12  * for more details.
13  */
14
15 /***************************************************************************/
16
17 #include <linux/types.h>
18 #include <linux/kernel.h>
19 #include <linux/mm.h>
20 #include <linux/tty.h>
21 #include <linux/console.h>
22 #include <linux/kd.h>
23 #include <linux/netdevice.h>
24
25 #include <asm/setup.h>
26 #include <asm/system.h>
27 #include <asm/pgtable.h>
28 #include <asm/irq.h>
29 #include <asm/machdep.h>
30 #include <asm/MC68VZ328.h>
31 #include <asm/bootstd.h>
32
33 #ifdef CONFIG_INIT_LCD
34 #include "bootlogo.h"
35 #endif
36
37 /***************************************************************************/
38
39 void m68328_timer_init(irqreturn_t (*timer_routine) (int, void *, struct pt_regs *));
40 void m68328_timer_tick(void);
41 unsigned long m68328_timer_gettimeoffset(void);
42 void m68328_timer_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec);
43
44 /***************************************************************************/
45 /*                        Init Drangon Engine hardware                     */
46 /***************************************************************************/
47 #if defined(CONFIG_DRAGEN2)
48
49 static void m68vz328_reset(void)
50 {
51         local_irq_disable();
52
53 #ifdef CONFIG_INIT_LCD
54         PBDATA |= 0x20;                         /* disable CCFL light */
55         PKDATA |= 0x4;                          /* disable LCD controller */
56         LCKCON = 0;
57 #endif
58
59         __asm__ __volatile__(
60                 "reset\n\t"
61                 "moveal #0x04000000, %a0\n\t"
62                 "moveal 0(%a0), %sp\n\t"
63                 "moveal 4(%a0), %a0\n\t"
64                 "jmp (%a0)"
65         );
66 }
67
68 static void init_hardware(char *command, int size)
69 {
70 #ifdef CONFIG_DIRECT_IO_ACCESS
71         SCR = 0x10;                                     /* allow user access to internal registers */
72 #endif
73
74         /* CSGB Init */
75         CSGBB = 0x4000;
76         CSB = 0x1a1;
77
78         /* CS8900 init */
79         /* PK3: hardware sleep function pin, active low */
80         PKSEL |= PK(3);                         /* select pin as I/O */
81         PKDIR |= PK(3);                         /* select pin as output */
82         PKDATA |= PK(3);                        /* set pin high */
83
84         /* PF5: hardware reset function pin, active high */
85         PFSEL |= PF(5);                         /* select pin as I/O */
86         PFDIR |= PF(5);                         /* select pin as output */
87         PFDATA &= ~PF(5);                       /* set pin low */
88
89         /* cs8900 hardware reset */
90         PFDATA |= PF(5);
91         { int i; for (i = 0; i < 32000; ++i); }
92         PFDATA &= ~PF(5);
93
94         /* INT1 enable (cs8900 IRQ) */
95         PDPOL &= ~PD(1);                        /* active high signal */
96         PDIQEG &= ~PD(1);
97         PDIRQEN |= PD(1);                       /* IRQ enabled */
98
99 #ifdef CONFIG_68328_SERIAL_UART2
100         /* Enable RXD TXD port bits to enable UART2 */
101         PJSEL &= ~(PJ(5) | PJ(4));
102 #endif
103
104 #ifdef CONFIG_INIT_LCD
105         /* initialize LCD controller */
106         LSSA = (long) screen_bits;
107         LVPW = 0x14;
108         LXMAX = 0x140;
109         LYMAX = 0xef;
110         LRRA = 0;
111         LPXCD = 3;
112         LPICF = 0x08;
113         LPOLCF = 0;
114         LCKCON = 0x80;
115         PCPDEN = 0xff;
116         PCSEL = 0;
117
118         /* Enable LCD controller */
119         PKDIR |= 0x4;
120         PKSEL |= 0x4;
121         PKDATA &= ~0x4;
122
123         /* Enable CCFL backlighting circuit */
124         PBDIR |= 0x20;
125         PBSEL |= 0x20;
126         PBDATA &= ~0x20;
127
128         /* contrast control register */
129         PFDIR |= 0x1;
130         PFSEL &= ~0x1;
131         PWMR = 0x037F;
132 #endif
133 }
134
135 /***************************************************************************/
136 /*                      Init RT-Control uCdimm hardware                    */
137 /***************************************************************************/
138 #elif defined(CONFIG_UCDIMM)
139
140 static void m68vz328_reset(void)
141 {
142         local_irq_disable();
143         asm volatile (
144                 "moveal #0x10c00000, %a0;\n\t"
145                 "moveb #0, 0xFFFFF300;\n\t"
146                 "moveal 0(%a0), %sp;\n\t"
147                 "moveal 4(%a0), %a0;\n\t"
148                 "jmp (%a0);\n"
149         );
150 }
151
152 unsigned char *cs8900a_hwaddr;
153 static int errno;
154
155 _bsc0(char *, getserialnum)
156 _bsc1(unsigned char *, gethwaddr, int, a)
157 _bsc1(char *, getbenv, char *, a)
158
159 static void init_hardware(char *command, int size)
160 {
161         char *p;
162
163         printk(KERN_INFO "uCdimm serial string [%s]\n", getserialnum());
164         p = cs8900a_hwaddr = gethwaddr(0);
165         printk(KERN_INFO "uCdimm hwaddr %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
166                 p[0], p[1], p[2], p[3], p[4], p[5]);
167         p = getbenv("APPEND");
168         if (p)
169                 strcpy(p, command);
170         else
171                 command[0] = 0;
172 }
173
174 /***************************************************************************/
175 #else
176
177 static void m68vz328_reset(void)
178 {
179 }
180
181 static void init_hardware(char *command, int size)
182 {
183 }
184
185 /***************************************************************************/
186 #endif
187 /***************************************************************************/
188
189 void config_BSP(char *command, int size)
190 {
191         printk(KERN_INFO "68VZ328 DragonBallVZ support (c) 2001 Lineo, Inc.\n");
192
193 #if defined(CONFIG_BOOTPARAM)
194         strncpy(command, CONFIG_BOOTPARAM_STRING, size);
195         command[size-1] = 0;
196 #else
197         memset(command, 0, size);
198 #endif
199
200         init_hardware(command, size);
201
202         mach_sched_init = (void *) m68328_timer_init;
203         mach_tick = m68328_timer_tick;
204         mach_gettimeoffset = m68328_timer_gettimeoffset;
205         mach_gettod = m68328_timer_gettod;
206         mach_reset = m68vz328_reset;
207 }
208
209 /***************************************************************************/