]> err.no Git - linux-2.6/blob - arch/arm/mach-s3c2410/mach-vr1000.c
[ARM] BAST/VR1000: Move to using ata_platform (libata)
[linux-2.6] / 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 */
14
15 #include <linux/kernel.h>
16 #include <linux/types.h>
17 #include <linux/interrupt.h>
18 #include <linux/list.h>
19 #include <linux/timer.h>
20 #include <linux/init.h>
21 #include <linux/dm9000.h>
22
23 #include <linux/serial.h>
24 #include <linux/tty.h>
25 #include <linux/serial_8250.h>
26 #include <linux/serial_reg.h>
27
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/irq.h>
31
32 #include <asm/arch/bast-map.h>
33 #include <asm/arch/vr1000-map.h>
34 #include <asm/arch/vr1000-irq.h>
35 #include <asm/arch/vr1000-cpld.h>
36
37 #include <asm/hardware.h>
38 #include <asm/io.h>
39 #include <asm/irq.h>
40 #include <asm/mach-types.h>
41
42 #include <asm/plat-s3c/regs-serial.h>
43 #include <asm/arch/regs-gpio.h>
44 #include <asm/arch/leds-gpio.h>
45
46 #include <asm/plat-s3c24xx/clock.h>
47 #include <asm/plat-s3c24xx/devs.h>
48 #include <asm/plat-s3c24xx/cpu.h>
49 #include "usb-simtec.h"
50
51 /* macros for virtual address mods for the io space entries */
52 #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
53 #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
54 #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
55 #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
56
57 /* macros to modify the physical addresses for io space */
58
59 #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
60 #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
61 #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
62 #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
63
64 static struct map_desc vr1000_iodesc[] __initdata = {
65   /* ISA IO areas */
66   {
67           .virtual      = (u32)S3C24XX_VA_ISA_BYTE,
68           .pfn          = PA_CS2(BAST_PA_ISAIO),
69           .length       = SZ_16M,
70           .type         = MT_DEVICE,
71   }, {
72           .virtual      = (u32)S3C24XX_VA_ISA_WORD,
73           .pfn          = PA_CS3(BAST_PA_ISAIO),
74           .length       = SZ_16M,
75           .type         = MT_DEVICE,
76   },
77
78   /*  CPLD control registers, and external interrupt controls */
79   {
80           .virtual      = (u32)VR1000_VA_CTRL1,
81           .pfn          = __phys_to_pfn(VR1000_PA_CTRL1),
82           .length       = SZ_1M,
83           .type         = MT_DEVICE,
84   }, {
85           .virtual      = (u32)VR1000_VA_CTRL2,
86           .pfn          = __phys_to_pfn(VR1000_PA_CTRL2),
87           .length       = SZ_1M,
88           .type         = MT_DEVICE,
89   }, {
90           .virtual      = (u32)VR1000_VA_CTRL3,
91           .pfn          = __phys_to_pfn(VR1000_PA_CTRL3),
92           .length       = SZ_1M,
93           .type         = MT_DEVICE,
94   }, {
95           .virtual      = (u32)VR1000_VA_CTRL4,
96           .pfn          = __phys_to_pfn(VR1000_PA_CTRL4),
97           .length       = SZ_1M,
98           .type         = MT_DEVICE,
99   },
100 };
101
102 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
103 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
104 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
105
106 /* uart clock source(s) */
107
108 static struct s3c24xx_uart_clksrc vr1000_serial_clocks[] = {
109         [0] = {
110                 .name           = "uclk",
111                 .divisor        = 1,
112                 .min_baud       = 0,
113                 .max_baud       = 0,
114         },
115         [1] = {
116                 .name           = "pclk",
117                 .divisor        = 1,
118                 .min_baud       = 0,
119                 .max_baud       = 0.
120         }
121 };
122
123 static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
124         [0] = {
125                 .hwport      = 0,
126                 .flags       = 0,
127                 .ucon        = UCON,
128                 .ulcon       = ULCON,
129                 .ufcon       = UFCON,
130                 .clocks      = vr1000_serial_clocks,
131                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
132         },
133         [1] = {
134                 .hwport      = 1,
135                 .flags       = 0,
136                 .ucon        = UCON,
137                 .ulcon       = ULCON,
138                 .ufcon       = UFCON,
139                 .clocks      = vr1000_serial_clocks,
140                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
141         },
142         /* port 2 is not actually used */
143         [2] = {
144                 .hwport      = 2,
145                 .flags       = 0,
146                 .ucon        = UCON,
147                 .ulcon       = ULCON,
148                 .ufcon       = UFCON,
149                 .clocks      = vr1000_serial_clocks,
150                 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
151
152         }
153 };
154
155 /* definitions for the vr1000 extra 16550 serial ports */
156
157 #define VR1000_BAUDBASE (3692307)
158
159 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
160
161 static struct plat_serial8250_port serial_platform_data[] = {
162         [0] = {
163                 .mapbase        = VR1000_SERIAL_MAPBASE(0),
164                 .irq            = IRQ_VR1000_SERIAL + 0,
165                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
166                 .iotype         = UPIO_MEM,
167                 .regshift       = 0,
168                 .uartclk        = VR1000_BAUDBASE,
169         },
170         [1] = {
171                 .mapbase        = VR1000_SERIAL_MAPBASE(1),
172                 .irq            = IRQ_VR1000_SERIAL + 1,
173                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
174                 .iotype         = UPIO_MEM,
175                 .regshift       = 0,
176                 .uartclk        = VR1000_BAUDBASE,
177         },
178         [2] = {
179                 .mapbase        = VR1000_SERIAL_MAPBASE(2),
180                 .irq            = IRQ_VR1000_SERIAL + 2,
181                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
182                 .iotype         = UPIO_MEM,
183                 .regshift       = 0,
184                 .uartclk        = VR1000_BAUDBASE,
185         },
186         [3] = {
187                 .mapbase        = VR1000_SERIAL_MAPBASE(3),
188                 .irq            = IRQ_VR1000_SERIAL + 3,
189                 .flags          = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
190                 .iotype         = UPIO_MEM,
191                 .regshift       = 0,
192                 .uartclk        = VR1000_BAUDBASE,
193         },
194         { },
195 };
196
197 static struct platform_device serial_device = {
198         .name                   = "serial8250",
199         .id                     = PLAT8250_DEV_PLATFORM,
200         .dev                    = {
201                 .platform_data  = serial_platform_data,
202         },
203 };
204
205 /* MTD NOR Flash */
206
207 static struct resource vr1000_nor_resource[] = {
208         [0] = {
209                 .start  = S3C2410_CS1 + 0x4000000,
210                 .end    = S3C2410_CS1 + 0x4000000 + SZ_16M - 1,
211                 .flags  = IORESOURCE_MEM,
212         }
213 };
214
215 static struct platform_device vr1000_nor = {
216         .name           = "bast-nor",
217         .id             = -1,
218         .num_resources  = ARRAY_SIZE(vr1000_nor_resource),
219         .resource       = vr1000_nor_resource,
220 };
221
222 /* DM9000 ethernet devices */
223
224 static struct resource vr1000_dm9k0_resource[] = {
225         [0] = {
226                 .start = S3C2410_CS5 + VR1000_PA_DM9000,
227                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 3,
228                 .flags = IORESOURCE_MEM
229         },
230         [1] = {
231                 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x40,
232                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 0x7f,
233                 .flags = IORESOURCE_MEM
234         },
235         [2] = {
236                 .start = IRQ_VR1000_DM9000A,
237                 .end   = IRQ_VR1000_DM9000A,
238                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
239         }
240
241 };
242
243 static struct resource vr1000_dm9k1_resource[] = {
244         [0] = {
245                 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x80,
246                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 0x83,
247                 .flags = IORESOURCE_MEM
248         },
249         [1] = {
250                 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0,
251                 .end   = S3C2410_CS5 + VR1000_PA_DM9000 + 0xFF,
252                 .flags = IORESOURCE_MEM
253         },
254         [2] = {
255                 .start = IRQ_VR1000_DM9000N,
256                 .end   = IRQ_VR1000_DM9000N,
257                 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
258         }
259 };
260
261 /* for the moment we limit ourselves to 16bit IO until some
262  * better IO routines can be written and tested
263 */
264
265 static struct dm9000_plat_data vr1000_dm9k_platdata = {
266         .flags          = DM9000_PLATF_16BITONLY,
267 };
268
269 static struct platform_device vr1000_dm9k0 = {
270         .name           = "dm9000",
271         .id             = 0,
272         .num_resources  = ARRAY_SIZE(vr1000_dm9k0_resource),
273         .resource       = vr1000_dm9k0_resource,
274         .dev            = {
275                 .platform_data = &vr1000_dm9k_platdata,
276         }
277 };
278
279 static struct platform_device vr1000_dm9k1 = {
280         .name           = "dm9000",
281         .id             = 1,
282         .num_resources  = ARRAY_SIZE(vr1000_dm9k1_resource),
283         .resource       = vr1000_dm9k1_resource,
284         .dev            = {
285                 .platform_data = &vr1000_dm9k_platdata,
286         }
287 };
288
289 /* LEDS */
290
291 static struct s3c24xx_led_platdata vr1000_led1_pdata = {
292         .name           = "led1",
293         .gpio           = S3C2410_GPB0,
294         .def_trigger    = "",
295 };
296
297 static struct s3c24xx_led_platdata vr1000_led2_pdata = {
298         .name           = "led2",
299         .gpio           = S3C2410_GPB1,
300         .def_trigger    = "",
301 };
302
303 static struct s3c24xx_led_platdata vr1000_led3_pdata = {
304         .name           = "led3",
305         .gpio           = S3C2410_GPB2,
306         .def_trigger    = "",
307 };
308
309 static struct platform_device vr1000_led1 = {
310         .name           = "s3c24xx_led",
311         .id             = 1,
312         .dev            = {
313                 .platform_data  = &vr1000_led1_pdata,
314         },
315 };
316
317 static struct platform_device vr1000_led2 = {
318         .name           = "s3c24xx_led",
319         .id             = 2,
320         .dev            = {
321                 .platform_data  = &vr1000_led2_pdata,
322         },
323 };
324
325 static struct platform_device vr1000_led3 = {
326         .name           = "s3c24xx_led",
327         .id             = 3,
328         .dev            = {
329                 .platform_data  = &vr1000_led3_pdata,
330         },
331 };
332
333 /* devices for this board */
334
335 static struct platform_device *vr1000_devices[] __initdata = {
336         &s3c_device_usb,
337         &s3c_device_lcd,
338         &s3c_device_wdt,
339         &s3c_device_i2c,
340         &s3c_device_adc,
341         &serial_device,
342         &vr1000_nor,
343         &vr1000_dm9k0,
344         &vr1000_dm9k1,
345         &vr1000_led1,
346         &vr1000_led2,
347         &vr1000_led3,
348 };
349
350 static struct clk *vr1000_clocks[] = {
351         &s3c24xx_dclk0,
352         &s3c24xx_dclk1,
353         &s3c24xx_clkout0,
354         &s3c24xx_clkout1,
355         &s3c24xx_uclk,
356 };
357
358 static void vr1000_power_off(void)
359 {
360         s3c2410_gpio_cfgpin(S3C2410_GPB9, S3C2410_GPB9_OUTP);
361         s3c2410_gpio_setpin(S3C2410_GPB9, 1);
362 }
363
364 static void __init vr1000_map_io(void)
365 {
366         /* initialise clock sources */
367
368         s3c24xx_dclk0.parent = &clk_upll;
369         s3c24xx_dclk0.rate   = 12*1000*1000;
370
371         s3c24xx_dclk1.parent = NULL;
372         s3c24xx_dclk1.rate   = 3692307;
373
374         s3c24xx_clkout0.parent  = &s3c24xx_dclk0;
375         s3c24xx_clkout1.parent  = &s3c24xx_dclk1;
376
377         s3c24xx_uclk.parent  = &s3c24xx_clkout1;
378
379         s3c24xx_register_clocks(vr1000_clocks, ARRAY_SIZE(vr1000_clocks));
380
381         pm_power_off = vr1000_power_off;
382
383         s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
384         s3c24xx_init_clocks(0);
385         s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
386 }
387
388 static void __init vr1000_init(void)
389 {
390         platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
391 }
392
393 MACHINE_START(VR1000, "Thorcom-VR1000")
394         /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
395         .phys_io        = S3C2410_PA_UART,
396         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
397         .boot_params    = S3C2410_SDRAM_PA + 0x100,
398         .map_io         = vr1000_map_io,
399         .init_machine   = vr1000_init,
400         .init_irq       = s3c24xx_init_irq,
401         .timer          = &s3c24xx_timer,
402 MACHINE_END