blob: 6ccce5a761b4009b28f0905e6ea398596fb40b86 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* linux/arch/arm/mach-s3c2410/mach-vr1000.c
2 *
Ben Dooksccae9412009-11-13 22:54:14 +00003 * Copyright (c) 2003-2008 Simtec Electronics
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * 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 Dooksec976d62009-05-13 22:52:24 +010021#include <linux/gpio.h>
Ben Dooksd97a6662005-06-23 21:56:47 +010022#include <linux/dm9000.h>
Ben Dooks60d66982008-07-03 11:24:42 +010023#include <linux/i2c.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include <linux/serial.h>
26#include <linux/tty.h>
27#include <linux/serial_8250.h>
28#include <linux/serial_reg.h>
Russell Kingfced80c2008-09-06 12:10:45 +010029#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34
Russell Kinga09e64f2008-08-05 16:14:15 +010035#include <mach/bast-map.h>
36#include <mach/vr1000-map.h>
37#include <mach/vr1000-irq.h>
38#include <mach/vr1000-cpld.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Russell Kinga09e64f2008-08-05 16:14:15 +010040#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <asm/irq.h>
42#include <asm/mach-types.h>
43
Ben Dooksa2b7ba92008-10-07 22:26:09 +010044#include <plat/regs-serial.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010045#include <mach/regs-gpio.h>
46#include <mach/leds-gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Ben Dooksd5120ae2008-10-07 23:09:51 +010048#include <plat/clock.h>
Ben Dooksa2b7ba92008-10-07 22:26:09 +010049#include <plat/devs.h>
50#include <plat/cpu.h>
Ben Dooks3e1b7762008-10-31 16:14:40 +000051#include <plat/iic.h>
Ben Dooks4d3a3462009-11-13 22:34:20 +000052#include <plat/audio-simtec.h>
Ben Dooks9d529c62008-07-03 11:24:39 +010053
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#include "usb-simtec.h"
Ben Dooks9d529c62008-07-03 11:24:39 +010055#include "nor-simtec.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57/* macros for virtual address mods for the io space entries */
58#define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
59#define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
60#define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
61#define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
62
63/* macros to modify the physical addresses for io space */
64
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000065#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
66#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
67#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
68#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70static struct map_desc vr1000_iodesc[] __initdata = {
71 /* ISA IO areas */
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000072 {
73 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
74 .pfn = PA_CS2(BAST_PA_ISAIO),
75 .length = SZ_16M,
76 .type = MT_DEVICE,
77 }, {
78 .virtual = (u32)S3C24XX_VA_ISA_WORD,
79 .pfn = PA_CS3(BAST_PA_ISAIO),
80 .length = SZ_16M,
81 .type = MT_DEVICE,
82 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000084 /* CPLD control registers, and external interrupt controls */
85 {
86 .virtual = (u32)VR1000_VA_CTRL1,
87 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
88 .length = SZ_1M,
89 .type = MT_DEVICE,
90 }, {
91 .virtual = (u32)VR1000_VA_CTRL2,
92 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
93 .length = SZ_1M,
94 .type = MT_DEVICE,
95 }, {
96 .virtual = (u32)VR1000_VA_CTRL3,
97 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
98 .length = SZ_1M,
99 .type = MT_DEVICE,
100 }, {
101 .virtual = (u32)VR1000_VA_CTRL4,
102 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
103 .length = SZ_1M,
104 .type = MT_DEVICE,
105 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106};
107
108#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
109#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
110#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
111
112/* uart clock source(s) */
113
114static struct s3c24xx_uart_clksrc vr1000_serial_clocks[] = {
115 [0] = {
116 .name = "uclk",
117 .divisor = 1,
118 .min_baud = 0,
119 .max_baud = 0,
120 },
121 [1] = {
122 .name = "pclk",
123 .divisor = 1,
124 .min_baud = 0,
125 .max_baud = 0.
126 }
127};
128
Ben Dooks66a9b492006-06-18 23:04:05 +0100129static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 [0] = {
131 .hwport = 0,
132 .flags = 0,
133 .ucon = UCON,
134 .ulcon = ULCON,
135 .ufcon = UFCON,
136 .clocks = vr1000_serial_clocks,
137 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
138 },
139 [1] = {
140 .hwport = 1,
141 .flags = 0,
142 .ucon = UCON,
143 .ulcon = ULCON,
144 .ufcon = UFCON,
145 .clocks = vr1000_serial_clocks,
146 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
147 },
148 /* port 2 is not actually used */
149 [2] = {
150 .hwport = 2,
151 .flags = 0,
152 .ucon = UCON,
153 .ulcon = ULCON,
154 .ufcon = UFCON,
155 .clocks = vr1000_serial_clocks,
156 .clocks_size = ARRAY_SIZE(vr1000_serial_clocks),
157
158 }
159};
160
161/* definitions for the vr1000 extra 16550 serial ports */
162
163#define VR1000_BAUDBASE (3692307)
164
165#define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
166
167static struct plat_serial8250_port serial_platform_data[] = {
168 [0] = {
169 .mapbase = VR1000_SERIAL_MAPBASE(0),
170 .irq = IRQ_VR1000_SERIAL + 0,
171 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
172 .iotype = UPIO_MEM,
173 .regshift = 0,
174 .uartclk = VR1000_BAUDBASE,
175 },
176 [1] = {
177 .mapbase = VR1000_SERIAL_MAPBASE(1),
178 .irq = IRQ_VR1000_SERIAL + 1,
179 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
180 .iotype = UPIO_MEM,
181 .regshift = 0,
182 .uartclk = VR1000_BAUDBASE,
183 },
184 [2] = {
185 .mapbase = VR1000_SERIAL_MAPBASE(2),
186 .irq = IRQ_VR1000_SERIAL + 2,
187 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
188 .iotype = UPIO_MEM,
189 .regshift = 0,
190 .uartclk = VR1000_BAUDBASE,
191 },
192 [3] = {
193 .mapbase = VR1000_SERIAL_MAPBASE(3),
194 .irq = IRQ_VR1000_SERIAL + 3,
195 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
196 .iotype = UPIO_MEM,
197 .regshift = 0,
198 .uartclk = VR1000_BAUDBASE,
199 },
200 { },
201};
202
203static struct platform_device serial_device = {
204 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100205 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 .dev = {
207 .platform_data = serial_platform_data,
208 },
209};
210
Ben Dooksd97a6662005-06-23 21:56:47 +0100211/* DM9000 ethernet devices */
212
213static struct resource vr1000_dm9k0_resource[] = {
214 [0] = {
215 .start = S3C2410_CS5 + VR1000_PA_DM9000,
216 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 3,
217 .flags = IORESOURCE_MEM
218 },
219 [1] = {
220 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x40,
221 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0x7f,
222 .flags = IORESOURCE_MEM
223 },
224 [2] = {
225 .start = IRQ_VR1000_DM9000A,
226 .end = IRQ_VR1000_DM9000A,
Ben Dooks9cf345e2008-07-03 11:24:22 +0100227 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Ben Dooksd97a6662005-06-23 21:56:47 +0100228 }
229
230};
231
232static struct resource vr1000_dm9k1_resource[] = {
233 [0] = {
234 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0x80,
235 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0x83,
236 .flags = IORESOURCE_MEM
237 },
238 [1] = {
239 .start = S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0,
240 .end = S3C2410_CS5 + VR1000_PA_DM9000 + 0xFF,
241 .flags = IORESOURCE_MEM
242 },
243 [2] = {
244 .start = IRQ_VR1000_DM9000N,
245 .end = IRQ_VR1000_DM9000N,
Ben Dooks9cf345e2008-07-03 11:24:22 +0100246 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
Ben Dooksd97a6662005-06-23 21:56:47 +0100247 }
248};
249
250/* for the moment we limit ourselves to 16bit IO until some
251 * better IO routines can be written and tested
252*/
253
Ben Dooks9f693d72005-10-12 19:58:07 +0100254static struct dm9000_plat_data vr1000_dm9k_platdata = {
Ben Dooksd97a6662005-06-23 21:56:47 +0100255 .flags = DM9000_PLATF_16BITONLY,
256};
257
258static struct platform_device vr1000_dm9k0 = {
259 .name = "dm9000",
260 .id = 0,
261 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
262 .resource = vr1000_dm9k0_resource,
263 .dev = {
264 .platform_data = &vr1000_dm9k_platdata,
265 }
266};
267
268static struct platform_device vr1000_dm9k1 = {
269 .name = "dm9000",
270 .id = 1,
271 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
272 .resource = vr1000_dm9k1_resource,
273 .dev = {
274 .platform_data = &vr1000_dm9k_platdata,
275 }
276};
277
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100278/* LEDS */
279
280static struct s3c24xx_led_platdata vr1000_led1_pdata = {
281 .name = "led1",
Ben Dooks070276d2009-05-17 22:32:23 +0100282 .gpio = S3C2410_GPB(0),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100283 .def_trigger = "",
284};
285
286static struct s3c24xx_led_platdata vr1000_led2_pdata = {
287 .name = "led2",
Ben Dooks070276d2009-05-17 22:32:23 +0100288 .gpio = S3C2410_GPB(1),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100289 .def_trigger = "",
290};
291
292static struct s3c24xx_led_platdata vr1000_led3_pdata = {
293 .name = "led3",
Ben Dooks070276d2009-05-17 22:32:23 +0100294 .gpio = S3C2410_GPB(2),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100295 .def_trigger = "",
296};
297
298static struct platform_device vr1000_led1 = {
299 .name = "s3c24xx_led",
300 .id = 1,
301 .dev = {
302 .platform_data = &vr1000_led1_pdata,
303 },
304};
305
306static struct platform_device vr1000_led2 = {
307 .name = "s3c24xx_led",
308 .id = 2,
309 .dev = {
310 .platform_data = &vr1000_led2_pdata,
311 },
312};
313
314static struct platform_device vr1000_led3 = {
315 .name = "s3c24xx_led",
Ben Dooksabac08d72006-12-19 19:10:13 +0100316 .id = 3,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100317 .dev = {
318 .platform_data = &vr1000_led3_pdata,
319 },
320};
321
Ben Dooks60d66982008-07-03 11:24:42 +0100322/* I2C devices. */
323
324static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
325 {
326 I2C_BOARD_INFO("tlv320aic23", 0x1a),
327 }, {
Ben Dooks9c3871c2008-07-03 11:24:44 +0100328 I2C_BOARD_INFO("tmp101", 0x48),
329 }, {
Ben Dooks60d66982008-07-03 11:24:42 +0100330 I2C_BOARD_INFO("m41st87", 0x68),
331 },
332};
333
Ben Dooksd97a6662005-06-23 21:56:47 +0100334/* devices for this board */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336static struct platform_device *vr1000_devices[] __initdata = {
Ben Dooksb8132482009-11-23 00:13:39 +0000337 &s3c_device_ohci,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 &s3c_device_lcd,
339 &s3c_device_wdt,
Ben Dooks3e1b7762008-10-31 16:14:40 +0000340 &s3c_device_i2c0,
Ben Dooksd97a6662005-06-23 21:56:47 +0100341 &s3c_device_adc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 &serial_device,
Ben Dooksd97a6662005-06-23 21:56:47 +0100343 &vr1000_dm9k0,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100344 &vr1000_dm9k1,
345 &vr1000_led1,
346 &vr1000_led2,
347 &vr1000_led3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348};
349
Ben Dooks2bc75092008-07-15 17:17:48 +0100350static struct clk *vr1000_clocks[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 &s3c24xx_dclk0,
352 &s3c24xx_dclk1,
353 &s3c24xx_clkout0,
354 &s3c24xx_clkout1,
355 &s3c24xx_uclk,
356};
357
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358static void vr1000_power_off(void)
359{
Ben Dooks7614e1d2010-05-04 12:53:11 +0900360 gpio_direction_output(S3C2410_GPB(9), 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361}
362
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100363static void __init vr1000_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
365 /* initialise clock sources */
366
Ben Dooksd96a9802008-04-16 00:12:39 +0100367 s3c24xx_dclk0.parent = &clk_upll;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 s3c24xx_dclk0.rate = 12*1000*1000;
369
370 s3c24xx_dclk1.parent = NULL;
371 s3c24xx_dclk1.rate = 3692307;
372
373 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
374 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
375
376 s3c24xx_uclk.parent = &s3c24xx_clkout1;
377
Ben Dooksce89c202007-04-20 11:15:27 +0100378 s3c24xx_register_clocks(vr1000_clocks, ARRAY_SIZE(vr1000_clocks));
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 pm_power_off = vr1000_power_off;
381
382 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
383 s3c24xx_init_clocks(0);
384 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385}
386
Ben Dooks57e51712007-04-20 11:19:16 +0100387static void __init vr1000_init(void)
388{
Ben Dooks3e1b7762008-10-31 16:14:40 +0000389 s3c_i2c0_set_platdata(NULL);
Ben Dooks57e51712007-04-20 11:19:16 +0100390 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
Ben Dooks9d529c62008-07-03 11:24:39 +0100391
Ben Dooks60d66982008-07-03 11:24:42 +0100392 i2c_register_board_info(0, vr1000_i2c_devs,
393 ARRAY_SIZE(vr1000_i2c_devs));
394
Ben Dooks9d529c62008-07-03 11:24:39 +0100395 nor_simtec_init();
Ben Dooks4d3a3462009-11-13 22:34:20 +0000396 simtec_audio_add(NULL, true, NULL);
Ben Dooks7614e1d2010-05-04 12:53:11 +0900397
398 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
Ben Dooks57e51712007-04-20 11:19:16 +0100399}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401MACHINE_START(VR1000, "Thorcom-VR1000")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100402 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Russell Kinge9dea0c2005-07-03 17:38:58 +0100403 .boot_params = S3C2410_SDRAM_PA + 0x100,
Ben Dooks6904b242005-06-29 11:09:15 +0100404 .map_io = vr1000_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100405 .init_machine = vr1000_init,
Ben Dooks6904b242005-06-29 11:09:15 +0100406 .init_irq = s3c24xx_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 .timer = &s3c24xx_timer,
408MACHINE_END