vserver 1.9.5.x5
[linux-2.6.git] / arch / arm / mach-s3c2410 / mach-vr1000.c
1 /* linux/arch/arm/mach-s3c2410/mach-vr1000.c
2  *
3  * Copyright (c) 2003-2005 Simtec Electronics
4  *   Ben Dooks <ben@simtec.co.uk>
5  *
6  * Machine support for Thorcom VR1000 board. Designed for Thorcom by
7  * Simtec Electronics, http://www.simtec.co.uk/
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  * Modifications:
14  *     14-Sep-2004 BJD  USB Power control
15  *     04-Sep-2004 BJD  Added new uart init, and io init
16  *     21-Aug-2004 BJD  Added struct s3c2410_board
17  *     06-Aug-2004 BJD  Fixed call to time initialisation
18  *     05-Apr-2004 BJD  Copied to make mach-vr1000.c
19  *     18-Oct-2004 BJD  Updated board struct
20  *     04-Nov-2004 BJD  Clock and serial configuration update
21  *
22  *     04-Jan-2005 BJD  Updated uart init call
23  *     10-Jan-2005 BJD  Removed include of s3c2410.h
24  *     14-Jan-2005 BJD  Added clock init
25  *     15-Jan-2005 BJD  Add serial port device definition
26  *     20-Jan-2005 BJD  Use UPF_IOREMAP for ports
27 */
28
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/interrupt.h>
32 #include <linux/list.h>
33 #include <linux/timer.h>
34 #include <linux/init.h>
35
36 #include <linux/serial.h>
37 #include <linux/tty.h>
38 #include <linux/serial_8250.h>
39 #include <linux/serial_reg.h>
40
41 #include <asm/mach/arch.h>
42 #include <asm/mach/map.h>
43 #include <asm/mach/irq.h>
44
45 #include <asm/arch/bast-map.h>
46 #include <asm/arch/vr1000-map.h>
47 #include <asm/arch/vr1000-irq.h>
48 #include <asm/arch/vr1000-cpld.h>
49
50 #include <asm/hardware.h>
51 #include <asm/io.h>
52 #include <asm/irq.h>
53 #include <asm/mach-types.h>
54
55 //#include <asm/debug-ll.h>
56 #include <asm/arch/regs-serial.h>
57
58 #include "clock.h"
59 #include "devs.h"
60 #include "cpu.h"
61 #include "usb-simtec.h"
62
63 /* macros for virtual address mods for the io space entries */
64 #define VA_C5(item) ((item) + BAST_VAM_CS5)
65 #define VA_C4(item) ((item) + BAST_VAM_CS4)
66 #define VA_C3(item) ((item) + BAST_VAM_CS3)
67 #define VA_C2(item) ((item) + BAST_VAM_CS2)
68
69 /* macros to modify the physical addresses for io space */
70
71 #define PA_CS2(item) ((item) + S3C2410_CS2)
72 #define PA_CS3(item) ((item) + S3C2410_CS3)
73 #define PA_CS4(item) ((item) + S3C2410_CS4)
74 #define PA_CS5(item) ((item) + S3C2410_CS5)
75
76 static struct map_desc vr1000_iodesc[] __initdata = {
77   /* ISA IO areas */
78
79   { S3C2410_VA_ISA_BYTE, PA_CS2(BAST_PA_ISAIO),    SZ_16M, MT_DEVICE },
80   { S3C2410_VA_ISA_WORD, PA_CS3(BAST_PA_ISAIO),    SZ_16M, MT_DEVICE },
81
82   /* we could possibly compress the next set down into a set of smaller tables
83    * pagetables, but that would mean using an L2 section, and it still means
84    * we cannot actually feed the same register to an LDR due to 16K spacing
85    */
86
87   /* bast CPLD control registers, and external interrupt controls */
88   { VR1000_VA_CTRL1, VR1000_PA_CTRL1,                  SZ_1M, MT_DEVICE },
89   { VR1000_VA_CTRL2, VR1000_PA_CTRL2,                  SZ_1M, MT_DEVICE },
90   { VR1000_VA_CTRL3, VR1000_PA_CTRL3,                  SZ_1M, MT_DEVICE },
91   { VR1000_VA_CTRL4, VR1000_PA_CTRL4,                  SZ_1M, MT_DEVICE },
92
93   /* peripheral space... one for each of fast/slow/byte/16bit */
94   /* note, ide is only decoded in word space, even though some registers
95    * are only 8bit */
96
97   /* slow, byte */
98   { VA_C2(VR1000_VA_DM9000),  PA_CS2(VR1000_PA_DM9000),   SZ_1M,  MT_DEVICE },
99   { VA_C2(VR1000_VA_IDEPRI),  PA_CS3(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
100   { VA_C2(VR1000_VA_IDESEC),  PA_CS3(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
101   { VA_C2(VR1000_VA_IDEPRIAUX), PA_CS3(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
102   { VA_C2(VR1000_VA_IDESECAUX), PA_CS3(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
103
104   /* slow, word */
105   { VA_C3(VR1000_VA_DM9000),  PA_CS3(VR1000_PA_DM9000),   SZ_1M,  MT_DEVICE },
106   { VA_C3(VR1000_VA_IDEPRI),  PA_CS3(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
107   { VA_C3(VR1000_VA_IDESEC),  PA_CS3(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
108   { VA_C3(VR1000_VA_IDEPRIAUX), PA_CS3(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
109   { VA_C3(VR1000_VA_IDESECAUX), PA_CS3(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
110
111   /* fast, byte */
112   { VA_C4(VR1000_VA_DM9000),  PA_CS4(VR1000_PA_DM9000),   SZ_1M,  MT_DEVICE },
113   { VA_C4(VR1000_VA_IDEPRI),  PA_CS5(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
114   { VA_C4(VR1000_VA_IDESEC),  PA_CS5(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
115   { VA_C4(VR1000_VA_IDEPRIAUX), PA_CS5(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
116   { VA_C4(VR1000_VA_IDESECAUX), PA_CS5(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
117
118   /* fast, word */
119   { VA_C5(VR1000_VA_DM9000),  PA_CS5(VR1000_PA_DM9000),   SZ_1M,  MT_DEVICE },
120   { VA_C5(VR1000_VA_IDEPRI),  PA_CS5(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
121   { VA_C5(VR1000_VA_IDESEC),  PA_CS5(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
122   { VA_C5(VR1000_VA_IDEPRIAUX), PA_CS5(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
123   { VA_C5(VR1000_VA_IDESECAUX), PA_CS5(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
124 };
125
126 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
127 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
128 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
129
130 /* uart clock source(s) */
131
132 static struct s3c24xx_uart_clksrc vr1000_serial_clocks[] = {
133         [0] = {
134                 .name           = "uclk",
135                 .divisor        = 1,
136                 .min_baud       = 0,
137                 .max_baud       = 0,
138         },
139         [1] = {
140                 .name           = "pclk",
141                 .divisor        = 1,
142                 .min_baud       = 0,
143                 .max_baud       = 0.
144         }
145 };
146
147 static struct s3c2410_uartcfg vr1000_uartcfgs[] = {
148         [0] = {
149                 .hwport      = 0,
150                 .flags       = 0,
151                 .ucon        = UCON,
152                 .ulcon       = ULCON,
153                 .ufcon       = UFCON,
154                 .clocks      = vr1000_serial_clocks,
155                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
156         },
157         [1] = {
158                 .hwport      = 1,
159                 .flags       = 0,
160                 .ucon        = UCON,
161                 .ulcon       = ULCON,
162                 .ufcon       = UFCON,
163                 .clocks      = vr1000_serial_clocks,
164                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
165         },
166         /* port 2 is not actually used */
167         [2] = {
168                 .hwport      = 2,
169                 .flags       = 0,
170                 .ucon        = UCON,
171                 .ulcon       = ULCON,
172                 .ufcon       = UFCON,
173                 .clocks      = vr1000_serial_clocks,
174                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
175
176         }
177 };
178
179 /* definitions for the vr1000 extra 16550 serial ports */
180
181 #define VR1000_BAUDBASE (3692307)
182
183 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
184
185 static struct plat_serial8250_port serial_platform_data[] = {
186         [0] = {
187                 .mapbase        = VR1000_SERIAL_MAPBASE(0),
188                 .irq            = IRQ_VR1000_SERIAL + 0,
189                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
190                 .iotype         = UPIO_MEM,
191                 .regshift       = 0,
192                 .uartclk        = VR1000_BAUDBASE,
193         },
194         [1] = {
195                 .mapbase        = VR1000_SERIAL_MAPBASE(1),
196                 .irq            = IRQ_VR1000_SERIAL + 1,
197                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
198                 .iotype         = UPIO_MEM,
199                 .regshift       = 0,
200                 .uartclk        = VR1000_BAUDBASE,
201         },
202         [2] = {
203                 .mapbase        = VR1000_SERIAL_MAPBASE(2),
204                 .irq            = IRQ_VR1000_SERIAL + 2,
205                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
206                 .iotype         = UPIO_MEM,
207                 .regshift       = 0,
208                 .uartclk        = VR1000_BAUDBASE,
209         },
210         [3] = {
211                 .mapbase        = VR1000_SERIAL_MAPBASE(3),
212                 .irq            = IRQ_VR1000_SERIAL + 3,
213                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
214                 .iotype         = UPIO_MEM,
215                 .regshift       = 0,
216                 .uartclk        = VR1000_BAUDBASE,
217         },
218         { },
219 };
220
221 static struct platform_device serial_device = {
222         .name                   = "serial8250",
223         .id                     = 0,
224         .dev                    = {
225                 .platform_data  = serial_platform_data,
226         },
227 };
228
229 /* MTD NOR Flash */
230
231 static struct resource vr1000_nor_resource[] = {
232         [0] = {
233                 .start  = S3C2410_CS1 + 0x4000000,
234                 .end    = S3C2410_CS1 + 0x4000000 + SZ_16M - 1,
235                 .flags  = IORESOURCE_MEM,
236         }
237 };
238
239 static struct platform_device vr1000_nor = {
240         .name           = "bast-nor",
241         .id             = -1,
242         .num_resources  = ARRAY_SIZE(vr1000_nor_resource),
243         .resource       = vr1000_nor_resource,
244 };
245
246
247 static struct platform_device *vr1000_devices[] __initdata = {
248         &s3c_device_usb,
249         &s3c_device_lcd,
250         &s3c_device_wdt,
251         &s3c_device_i2c,
252         &s3c_device_iis,
253         &serial_device,
254         &vr1000_nor,
255 };
256
257 static struct clk *vr1000_clocks[] = {
258         &s3c24xx_dclk0,
259         &s3c24xx_dclk1,
260         &s3c24xx_clkout0,
261         &s3c24xx_clkout1,
262         &s3c24xx_uclk,
263 };
264
265 static struct s3c24xx_board vr1000_board __initdata = {
266         .devices       = vr1000_devices,
267         .devices_count = ARRAY_SIZE(vr1000_devices),
268         .clocks        = vr1000_clocks,
269         .clocks_count  = ARRAY_SIZE(vr1000_clocks),
270 };
271
272
273 void __init vr1000_map_io(void)
274 {
275         /* initialise clock sources */
276
277         s3c24xx_dclk0.parent = NULL;
278         s3c24xx_dclk0.rate   = 12*1000*1000;
279
280         s3c24xx_dclk1.parent = NULL;
281         s3c24xx_dclk1.rate   = 3692307;
282
283         s3c24xx_clkout0.parent  = &s3c24xx_dclk0;
284         s3c24xx_clkout1.parent  = &s3c24xx_dclk1;
285
286         s3c24xx_uclk.parent  = &s3c24xx_clkout1;
287
288         s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
289         s3c24xx_init_clocks(0);
290         s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
291         s3c24xx_set_board(&vr1000_board);
292         usb_simtec_init();
293 }
294
295 void __init vr1000_init_irq(void)
296 {
297         s3c24xx_init_irq();
298 }
299
300 MACHINE_START(VR1000, "Thorcom-VR1000")
301      MAINTAINER("Ben Dooks <ben@simtec.co.uk>")
302      BOOT_MEM(S3C2410_SDRAM_PA, S3C2410_PA_UART, S3C2410_VA_UART)
303      BOOT_PARAMS(S3C2410_SDRAM_PA + 0x100)
304      MAPIO(vr1000_map_io)
305      INITIRQ(vr1000_init_irq)
306         .timer          = &s3c24xx_timer,
307 MACHINE_END