Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
[pandora-kernel.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  *     10-Feb-2005 BJD  Added power-off capability
28  *     10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA
29  *     14-Mar-2006 BJD  void __iomem fixes
30  *     22-Jun-2006 BJD  Added DM9000 platform information
31  *     20-Sep-2005 BJD  Added static to non-exported items
32 */
33
34 #include <linux/kernel.h>
35 #include <linux/types.h>
36 #include <linux/interrupt.h>
37 #include <linux/list.h>
38 #include <linux/timer.h>
39 #include <linux/init.h>
40 #include <linux/dm9000.h>
41
42 #include <linux/serial.h>
43 #include <linux/tty.h>
44 #include <linux/serial_8250.h>
45 #include <linux/serial_reg.h>
46
47 #include <asm/mach/arch.h>
48 #include <asm/mach/map.h>
49 #include <asm/mach/irq.h>
50
51 #include <asm/arch/bast-map.h>
52 #include <asm/arch/vr1000-map.h>
53 #include <asm/arch/vr1000-irq.h>
54 #include <asm/arch/vr1000-cpld.h>
55
56 #include <asm/hardware.h>
57 #include <asm/io.h>
58 #include <asm/irq.h>
59 #include <asm/mach-types.h>
60
61 #include <asm/arch/regs-serial.h>
62 #include <asm/arch/regs-gpio.h>
63
64 #include "clock.h"
65 #include "devs.h"
66 #include "cpu.h"
67 #include "usb-simtec.h"
68
69 /* macros for virtual address mods for the io space entries */
70 #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
71 #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
72 #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
73 #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
74
75 /* macros to modify the physical addresses for io space */
76
77 #define PA_CS2(item) ((item) + S3C2410_CS2)
78 #define PA_CS3(item) ((item) + S3C2410_CS3)
79 #define PA_CS4(item) ((item) + S3C2410_CS4)
80 #define PA_CS5(item) ((item) + S3C2410_CS5)
81
82 static struct map_desc vr1000_iodesc[] __initdata = {
83   /* ISA IO areas */
84
85   { (u32)S3C24XX_VA_ISA_BYTE, PA_CS2(BAST_PA_ISAIO),       SZ_16M, MT_DEVICE },
86   { (u32)S3C24XX_VA_ISA_WORD, PA_CS3(BAST_PA_ISAIO),       SZ_16M, MT_DEVICE },
87
88   /* we could possibly compress the next set down into a set of smaller tables
89    * pagetables, but that would mean using an L2 section, and it still means
90    * we cannot actually feed the same register to an LDR due to 16K spacing
91    */
92
93   /* bast CPLD control registers, and external interrupt controls */
94   { (u32)VR1000_VA_CTRL1, VR1000_PA_CTRL1,             SZ_1M, MT_DEVICE },
95   { (u32)VR1000_VA_CTRL2, VR1000_PA_CTRL2,             SZ_1M, MT_DEVICE },
96   { (u32)VR1000_VA_CTRL3, VR1000_PA_CTRL3,             SZ_1M, MT_DEVICE },
97   { (u32)VR1000_VA_CTRL4, VR1000_PA_CTRL4,             SZ_1M, MT_DEVICE },
98
99   /* peripheral space... one for each of fast/slow/byte/16bit */
100   /* note, ide is only decoded in word space, even though some registers
101    * are only 8bit */
102
103   /* slow, byte */
104   { VA_C2(VR1000_VA_IDEPRI),  PA_CS3(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
105   { VA_C2(VR1000_VA_IDESEC),  PA_CS3(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
106   { VA_C2(VR1000_VA_IDEPRIAUX), PA_CS3(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
107   { VA_C2(VR1000_VA_IDESECAUX), PA_CS3(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
108
109   /* slow, word */
110   { VA_C3(VR1000_VA_IDEPRI),  PA_CS3(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
111   { VA_C3(VR1000_VA_IDESEC),  PA_CS3(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
112   { VA_C3(VR1000_VA_IDEPRIAUX), PA_CS3(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
113   { VA_C3(VR1000_VA_IDESECAUX), PA_CS3(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
114
115   /* fast, byte */
116   { VA_C4(VR1000_VA_IDEPRI),  PA_CS5(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
117   { VA_C4(VR1000_VA_IDESEC),  PA_CS5(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
118   { VA_C4(VR1000_VA_IDEPRIAUX), PA_CS5(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
119   { VA_C4(VR1000_VA_IDESECAUX), PA_CS5(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
120
121   /* fast, word */
122   { VA_C5(VR1000_VA_IDEPRI),  PA_CS5(VR1000_PA_IDEPRI),   SZ_1M,  MT_DEVICE },
123   { VA_C5(VR1000_VA_IDESEC),  PA_CS5(VR1000_PA_IDESEC),   SZ_1M,  MT_DEVICE },
124   { VA_C5(VR1000_VA_IDEPRIAUX), PA_CS5(VR1000_PA_IDEPRIAUX), SZ_1M, MT_DEVICE },
125   { VA_C5(VR1000_VA_IDESECAUX), PA_CS5(VR1000_PA_IDESECAUX), SZ_1M, MT_DEVICE },
126 };
127
128 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
129 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
130 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
131
132 /* uart clock source(s) */
133
134 static struct s3c24xx_uart_clksrc vr1000_serial_clocks[] = {
135         [0] = {
136                 .name           = "uclk",
137                 .divisor        = 1,
138                 .min_baud       = 0,
139                 .max_baud       = 0,
140         },
141         [1] = {
142                 .name           = "pclk",
143                 .divisor        = 1,
144                 .min_baud       = 0,
145                 .max_baud       = 0.
146         }
147 };
148
149 static struct s3c2410_uartcfg vr1000_uartcfgs[] = {
150         [0] = {
151                 .hwport      = 0,
152                 .flags       = 0,
153                 .ucon        = UCON,
154                 .ulcon       = ULCON,
155                 .ufcon       = UFCON,
156                 .clocks      = vr1000_serial_clocks,
157                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
158         },
159         [1] = {
160                 .hwport      = 1,
161                 .flags       = 0,
162                 .ucon        = UCON,
163                 .ulcon       = ULCON,
164                 .ufcon       = UFCON,
165                 .clocks      = vr1000_serial_clocks,
166                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
167         },
168         /* port 2 is not actually used */
169         [2] = {
170                 .hwport      = 2,
171                 .flags       = 0,
172                 .ucon        = UCON,
173                 .ulcon       = ULCON,
174                 .ufcon       = UFCON,
175                 .clocks      = vr1000_serial_clocks,
176                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
177
178         }
179 };
180
181 /* definitions for the vr1000 extra 16550 serial ports */
182
183 #define VR1000_BAUDBASE (3692307)
184
185 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
186
187 static struct plat_serial8250_port serial_platform_data[] = {
188         [0] = {
189                 .mapbase        = VR1000_SERIAL_MAPBASE(0),
190                 .irq            = IRQ_VR1000_SERIAL + 0,
191                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
192                 .iotype         = UPIO_MEM,
193                 .regshift       = 0,
194                 .uartclk        = VR1000_BAUDBASE,
195         },
196         [1] = {
197                 .mapbase        = VR1000_SERIAL_MAPBASE(1),
198                 .irq            = IRQ_VR1000_SERIAL + 1,
199                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
200                 .iotype         = UPIO_MEM,
201                 .regshift       = 0,
202                 .uartclk        = VR1000_BAUDBASE,
203         },
204         [2] = {
205                 .mapbase        = VR1000_SERIAL_MAPBASE(2),
206                 .irq            = IRQ_VR1000_SERIAL + 2,
207                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
208                 .iotype         = UPIO_MEM,
209                 .regshift       = 0,
210                 .uartclk        = VR1000_BAUDBASE,
211         },
212         [3] = {
213                 .mapbase        = VR1000_SERIAL_MAPBASE(3),
214                 .irq            = IRQ_VR1000_SERIAL + 3,
215                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
216                 .iotype         = UPIO_MEM,
217                 .regshift       = 0,
218                 .uartclk        = VR1000_BAUDBASE,
219         },
220         { },
221 };
222
223 static struct platform_device serial_device = {
224         .name                   = "serial8250",
225         .id                     = PLAT8250_DEV_PLATFORM,
226         .dev                    = {
227                 .platform_data  = serial_platform_data,
228         },
229 };
230
231 /* MTD NOR Flash */
232
233 static struct resource vr1000_nor_resource[] = {
234         [0] = {
235                 .start  = S3C2410_CS1 + 0x4000000,
236                 .end    = S3C2410_CS1 + 0x4000000 + SZ_16M - 1,
237                 .flags  = IORESOURCE_MEM,
238         }
239 };
240
241 static struct platform_device vr1000_nor = {
242         .name           = "bast-nor",
243         .id             = -1,
244         .num_resources  = ARRAY_SIZE(vr1000_nor_resource),
245         .resource       = vr1000_nor_resource,
246 };
247
248 /* DM9000 ethernet devices */
249
250 static struct resource vr1000_dm9k0_resource[] = {
251         [0] = {
252                 .start = S3C2410_CS5 + VR1000_PA_DM9000,
253                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 3,
254                 .flags = IORESOURCE_MEM
255         },
256         [1] = {
257                 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x40,
258                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 0x7f,
259                 .flags = IORESOURCE_MEM
260         },
261         [2] = {
262                 .start = IRQ_VR1000_DM9000A,
263                 .end   = IRQ_VR1000_DM9000A,
264                 .flags = IORESOURCE_IRQ
265         }
266
267 };
268
269 static struct resource vr1000_dm9k1_resource[] = {
270         [0] = {
271                 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x80,
272                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 0x83,
273                 .flags = IORESOURCE_MEM
274         },
275         [1] = {
276                 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0,
277                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 0xFF,
278                 .flags = IORESOURCE_MEM
279         },
280         [2] = {
281                 .start = IRQ_VR1000_DM9000N,
282                 .end   = IRQ_VR1000_DM9000N,
283                 .flags = IORESOURCE_IRQ
284         }
285 };
286
287 /* for the moment we limit ourselves to 16bit IO until some
288  * better IO routines can be written and tested
289 */
290
291 static struct dm9000_plat_data vr1000_dm9k_platdata = {
292         .flags          = DM9000_PLATF_16BITONLY,
293 };
294
295 static struct platform_device vr1000_dm9k0 = {
296         .name           = "dm9000",
297         .id             = 0,
298         .num_resources  = ARRAY_SIZE(vr1000_dm9k0_resource),
299         .resource       = vr1000_dm9k0_resource,
300         .dev            = {
301                 .platform_data = &vr1000_dm9k_platdata,
302         }
303 };
304
305 static struct platform_device vr1000_dm9k1 = {
306         .name           = "dm9000",
307         .id             = 1,
308         .num_resources  = ARRAY_SIZE(vr1000_dm9k1_resource),
309         .resource       = vr1000_dm9k1_resource,
310         .dev            = {
311                 .platform_data = &vr1000_dm9k_platdata,
312         }
313 };
314
315 /* devices for this board */
316
317 static struct platform_device *vr1000_devices[] __initdata = {
318         &s3c_device_usb,
319         &s3c_device_lcd,
320         &s3c_device_wdt,
321         &s3c_device_i2c,
322         &s3c_device_iis,
323         &s3c_device_adc,
324         &serial_device,
325         &vr1000_nor,
326         &vr1000_dm9k0,
327         &vr1000_dm9k1
328 };
329
330 static struct clk *vr1000_clocks[] = {
331         &s3c24xx_dclk0,
332         &s3c24xx_dclk1,
333         &s3c24xx_clkout0,
334         &s3c24xx_clkout1,
335         &s3c24xx_uclk,
336 };
337
338 static struct s3c24xx_board vr1000_board __initdata = {
339         .devices       = vr1000_devices,
340         .devices_count = ARRAY_SIZE(vr1000_devices),
341         .clocks        = vr1000_clocks,
342         .clocks_count  = ARRAY_SIZE(vr1000_clocks),
343 };
344
345 static void vr1000_power_off(void)
346 {
347         s3c2410_gpio_cfgpin(S3C2410_GPB9, S3C2410_GPB9_OUTP);
348         s3c2410_gpio_setpin(S3C2410_GPB9, 1);
349 }
350
351 static void __init vr1000_map_io(void)
352 {
353         /* initialise clock sources */
354
355         s3c24xx_dclk0.parent = NULL;
356         s3c24xx_dclk0.rate   = 12*1000*1000;
357
358         s3c24xx_dclk1.parent = NULL;
359         s3c24xx_dclk1.rate   = 3692307;
360
361         s3c24xx_clkout0.parent  = &s3c24xx_dclk0;
362         s3c24xx_clkout1.parent  = &s3c24xx_dclk1;
363
364         s3c24xx_uclk.parent  = &s3c24xx_clkout1;
365
366         pm_power_off = vr1000_power_off;
367
368         s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
369         s3c24xx_init_clocks(0);
370         s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
371         s3c24xx_set_board(&vr1000_board);
372         usb_simtec_init();
373 }
374
375
376 MACHINE_START(VR1000, "Thorcom-VR1000")
377         /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
378         .phys_ram       = S3C2410_SDRAM_PA,
379         .phys_io        = S3C2410_PA_UART,
380         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
381         .boot_params    = S3C2410_SDRAM_PA + 0x100,
382         .map_io         = vr1000_map_io,
383         .init_irq       = s3c24xx_init_irq,
384         .timer          = &s3c24xx_timer,
385 MACHINE_END