blob: f133ccfc359e5d0200b521dd7430396d7c9ffdef [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* 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 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070013*/
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>
Ben Dooksd97a6662005-06-23 21:56:47 +010021#include <linux/dm9000.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
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
Ben Dooks531b6172007-07-22 16:05:25 +010042#include <asm/plat-s3c/regs-serial.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <asm/arch/regs-gpio.h>
Ben Dooksb2eba6b2006-12-07 20:28:23 +010044#include <asm/arch/leds-gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
Ben Dooksa21765a2007-02-11 18:31:01 +010046#include <asm/plat-s3c24xx/clock.h>
47#include <asm/plat-s3c24xx/devs.h>
48#include <asm/plat-s3c24xx/cpu.h>
Ben Dooks9d529c62008-07-03 11:24:39 +010049
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#include "usb-simtec.h"
Ben Dooks9d529c62008-07-03 11:24:39 +010051#include "nor-simtec.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53/* macros for virtual address mods for the io space entries */
54#define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
55#define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
56#define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
57#define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
58
59/* macros to modify the physical addresses for io space */
60
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000061#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
62#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
63#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
64#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66static struct map_desc vr1000_iodesc[] __initdata = {
67 /* ISA IO areas */
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000068 {
69 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
70 .pfn = PA_CS2(BAST_PA_ISAIO),
71 .length = SZ_16M,
72 .type = MT_DEVICE,
73 }, {
74 .virtual = (u32)S3C24XX_VA_ISA_WORD,
75 .pfn = PA_CS3(BAST_PA_ISAIO),
76 .length = SZ_16M,
77 .type = MT_DEVICE,
78 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000080 /* CPLD control registers, and external interrupt controls */
81 {
82 .virtual = (u32)VR1000_VA_CTRL1,
83 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
84 .length = SZ_1M,
85 .type = MT_DEVICE,
86 }, {
87 .virtual = (u32)VR1000_VA_CTRL2,
88 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
89 .length = SZ_1M,
90 .type = MT_DEVICE,
91 }, {
92 .virtual = (u32)VR1000_VA_CTRL3,
93 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
94 .length = SZ_1M,
95 .type = MT_DEVICE,
96 }, {
97 .virtual = (u32)VR1000_VA_CTRL4,
98 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
99 .length = SZ_1M,
100 .type = MT_DEVICE,
101 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102};
103
104#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
105#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
106#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
107
108/* uart clock source(s) */
109
110static struct s3c24xx_uart_clksrc vr1000_serial_clocks[] = {
111 [0] = {
112 .name = "uclk",
113 .divisor = 1,
114 .min_baud = 0,
115 .max_baud = 0,
116 },
117 [1] = {
118 .name = "pclk",
119 .divisor = 1,
120 .min_baud = 0,
121 .max_baud = 0.
122 }
123};
124
Ben Dooks66a9b492006-06-18 23:04:05 +0100125static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 [0] = {
127 .hwport = 0,
128 .flags = 0,
129 .ucon = UCON,
130 .ulcon = ULCON,
131 .ufcon = UFCON,
132 .clocks = vr1000_serial_clocks,
133 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
134 },
135 [1] = {
136 .hwport = 1,
137 .flags = 0,
138 .ucon = UCON,
139 .ulcon = ULCON,
140 .ufcon = UFCON,
141 .clocks = vr1000_serial_clocks,
142 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
143 },
144 /* port 2 is not actually used */
145 [2] = {
146 .hwport = 2,
147 .flags = 0,
148 .ucon = UCON,
149 .ulcon = ULCON,
150 .ufcon = UFCON,
151 .clocks = vr1000_serial_clocks,
152 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
153
154 }
155};
156
157/* definitions for the vr1000 extra 16550 serial ports */
158
159#define VR1000_BAUDBASE (3692307)
160
161#define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
162
163static struct plat_serial8250_port serial_platform_data[] = {
164 [0] = {
165 .mapbase = VR1000_SERIAL_MAPBASE(0),
166 .irq = IRQ_VR1000_SERIAL + 0,
167 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
168 .iotype = UPIO_MEM,
169 .regshift = 0,
170 .uartclk = VR1000_BAUDBASE,
171 },
172 [1] = {
173 .mapbase = VR1000_SERIAL_MAPBASE(1),
174 .irq = IRQ_VR1000_SERIAL + 1,
175 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
176 .iotype = UPIO_MEM,
177 .regshift = 0,
178 .uartclk = VR1000_BAUDBASE,
179 },
180 [2] = {
181 .mapbase = VR1000_SERIAL_MAPBASE(2),
182 .irq = IRQ_VR1000_SERIAL + 2,
183 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
184 .iotype = UPIO_MEM,
185 .regshift = 0,
186 .uartclk = VR1000_BAUDBASE,
187 },
188 [3] = {
189 .mapbase = VR1000_SERIAL_MAPBASE(3),
190 .irq = IRQ_VR1000_SERIAL + 3,
191 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
192 .iotype = UPIO_MEM,
193 .regshift = 0,
194 .uartclk = VR1000_BAUDBASE,
195 },
196 { },
197};
198
199static struct platform_device serial_device = {
200 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100201 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 .dev = {
203 .platform_data = serial_platform_data,
204 },
205};
206
Ben Dooksd97a6662005-06-23 21:56:47 +0100207/* DM9000 ethernet devices */
208
209static struct resource vr1000_dm9k0_resource[] = {
210 [0] = {
211 .start = S3C2410_CS5 + VR1000_PA_DM9000,
212 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 3,
213 .flags = IORESOURCE_MEM
214 },
215 [1] = {
216 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x40,
217 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0x7f,
218 .flags = IORESOURCE_MEM
219 },
220 [2] = {
221 .start = IRQ_VR1000_DM9000A,
222 .end = IRQ_VR1000_DM9000A,
Ben Dooks9cf345e2008-07-03 11:24:22 +0100223 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Ben Dooksd97a6662005-06-23 21:56:47 +0100224 }
225
226};
227
228static struct resource vr1000_dm9k1_resource[] = {
229 [0] = {
230 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x80,
231 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0x83,
232 .flags = IORESOURCE_MEM
233 },
234 [1] = {
235 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0,
236 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0xFF,
237 .flags = IORESOURCE_MEM
238 },
239 [2] = {
240 .start = IRQ_VR1000_DM9000N,
241 .end = IRQ_VR1000_DM9000N,
Ben Dooks9cf345e2008-07-03 11:24:22 +0100242 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Ben Dooksd97a6662005-06-23 21:56:47 +0100243 }
244};
245
246/* for the moment we limit ourselves to 16bit IO until some
247 * better IO routines can be written and tested
248*/
249
Ben Dooks9f693d72005-10-12 19:58:07 +0100250static struct dm9000_plat_data vr1000_dm9k_platdata = {
Ben Dooksd97a6662005-06-23 21:56:47 +0100251 .flags = DM9000_PLATF_16BITONLY,
252};
253
254static struct platform_device vr1000_dm9k0 = {
255 .name = "dm9000",
256 .id = 0,
257 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
258 .resource = vr1000_dm9k0_resource,
259 .dev = {
260 .platform_data = &vr1000_dm9k_platdata,
261 }
262};
263
264static struct platform_device vr1000_dm9k1 = {
265 .name = "dm9000",
266 .id = 1,
267 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
268 .resource = vr1000_dm9k1_resource,
269 .dev = {
270 .platform_data = &vr1000_dm9k_platdata,
271 }
272};
273
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100274/* LEDS */
275
276static struct s3c24xx_led_platdata vr1000_led1_pdata = {
277 .name = "led1",
278 .gpio = S3C2410_GPB0,
279 .def_trigger = "",
280};
281
282static struct s3c24xx_led_platdata vr1000_led2_pdata = {
283 .name = "led2",
284 .gpio = S3C2410_GPB1,
285 .def_trigger = "",
286};
287
288static struct s3c24xx_led_platdata vr1000_led3_pdata = {
289 .name = "led3",
290 .gpio = S3C2410_GPB2,
291 .def_trigger = "",
292};
293
294static struct platform_device vr1000_led1 = {
295 .name = "s3c24xx_led",
296 .id = 1,
297 .dev = {
298 .platform_data = &vr1000_led1_pdata,
299 },
300};
301
302static struct platform_device vr1000_led2 = {
303 .name = "s3c24xx_led",
304 .id = 2,
305 .dev = {
306 .platform_data = &vr1000_led2_pdata,
307 },
308};
309
310static struct platform_device vr1000_led3 = {
311 .name = "s3c24xx_led",
Ben Dooksabac08d72006-12-19 19:10:13 +0100312 .id = 3,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100313 .dev = {
314 .platform_data = &vr1000_led3_pdata,
315 },
316};
317
Ben Dooksd97a6662005-06-23 21:56:47 +0100318/* devices for this board */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
320static struct platform_device *vr1000_devices[] __initdata = {
321 &s3c_device_usb,
322 &s3c_device_lcd,
323 &s3c_device_wdt,
324 &s3c_device_i2c,
Ben Dooksd97a6662005-06-23 21:56:47 +0100325 &s3c_device_adc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 &serial_device,
Ben Dooksd97a6662005-06-23 21:56:47 +0100327 &vr1000_dm9k0,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100328 &vr1000_dm9k1,
329 &vr1000_led1,
330 &vr1000_led2,
331 &vr1000_led3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332};
333
334static struct clk *vr1000_clocks[] = {
335 &s3c24xx_dclk0,
336 &s3c24xx_dclk1,
337 &s3c24xx_clkout0,
338 &s3c24xx_clkout1,
339 &s3c24xx_uclk,
340};
341
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342static void vr1000_power_off(void)
343{
344 s3c2410_gpio_cfgpin(S3C2410_GPB9, S3C2410_GPB9_OUTP);
345 s3c2410_gpio_setpin(S3C2410_GPB9, 1);
346}
347
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100348static void __init vr1000_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349{
350 /* initialise clock sources */
351
Ben Dooksd96a9802008-04-16 00:12:39 +0100352 s3c24xx_dclk0.parent = &clk_upll;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 s3c24xx_dclk0.rate = 12*1000*1000;
354
355 s3c24xx_dclk1.parent = NULL;
356 s3c24xx_dclk1.rate = 3692307;
357
358 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
359 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
360
361 s3c24xx_uclk.parent = &s3c24xx_clkout1;
362
Ben Dooksce89c202007-04-20 11:15:27 +0100363 s3c24xx_register_clocks(vr1000_clocks, ARRAY_SIZE(vr1000_clocks));
364
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 pm_power_off = vr1000_power_off;
366
367 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
368 s3c24xx_init_clocks(0);
369 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370}
371
Ben Dooks57e51712007-04-20 11:19:16 +0100372static void __init vr1000_init(void)
373{
374 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
Ben Dooks9d529c62008-07-03 11:24:39 +0100375
376 nor_simtec_init();
Ben Dooks57e51712007-04-20 11:19:16 +0100377}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
379MACHINE_START(VR1000, "Thorcom-VR1000")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100380 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100381 .phys_io = S3C2410_PA_UART,
382 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
383 .boot_params = S3C2410_SDRAM_PA + 0x100,
Ben Dooks6904b242005-06-29 11:09:15 +0100384 .map_io = vr1000_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100385 .init_machine = vr1000_init,
Ben Dooks6904b242005-06-29 11:09:15 +0100386 .init_irq = s3c24xx_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 .timer = &s3c24xx_timer,
388MACHINE_END