blob: d4db3853ae795760aa7152c35e521f51e3eb080e [file] [log] [blame]
Kukjin Kimdb8304e2013-01-02 10:47:40 -08001/*
Ben Dooksccae9412009-11-13 22:54:14 +00002 * Copyright (c) 2003-2008 Simtec Electronics
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Ben Dooks <ben@simtec.co.uk>
4 *
5 * Machine support for Thorcom VR1000 board. Designed for Thorcom by
6 * Simtec Electronics, http://www.simtec.co.uk/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012*/
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/list.h>
18#include <linux/timer.h>
19#include <linux/init.h>
Ben Dooksec976d62009-05-13 22:52:24 +010020#include <linux/gpio.h>
Ben Dooksd97a6662005-06-23 21:56:47 +010021#include <linux/dm9000.h>
Ben Dooks60d66982008-07-03 11:24:42 +010022#include <linux/i2c.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <linux/serial.h>
25#include <linux/tty.h>
26#include <linux/serial_8250.h>
27#include <linux/serial_reg.h>
Russell Kingfced80c2008-09-06 12:10:45 +010028#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <asm/irq.h>
35#include <asm/mach-types.h>
36
Arnd Bergmann436d42c2012-08-24 15:22:12 +020037#include <linux/platform_data/leds-s3c24xx.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020038#include <linux/platform_data/i2c-s3c2410.h>
39#include <linux/platform_data/asoc-s3c24xx_simtec.h>
Ben Dooks9d529c62008-07-03 11:24:39 +010040
Kukjin Kimdb8304e2013-01-02 10:47:40 -080041#include <mach/hardware.h>
42#include <mach/regs-gpio.h>
43
44#include <plat/clock.h>
45#include <plat/cpu.h>
46#include <plat/devs.h>
47#include <plat/regs-serial.h>
48
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080049#include "bast.h"
Kukjin Kimb27b0722012-01-03 14:02:03 +010050#include "common.h"
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080051#include "simtec.h"
Kukjin Kimdb8304e2013-01-02 10:47:40 -080052#include "vr1000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54/* macros for virtual address mods for the io space entries */
55#define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
56#define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
57#define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
58#define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
59
60/* macros to modify the physical addresses for io space */
61
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000062#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
63#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
64#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
65#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67static struct map_desc vr1000_iodesc[] __initdata = {
68 /* ISA IO areas */
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000069 {
70 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
71 .pfn = PA_CS2(BAST_PA_ISAIO),
72 .length = SZ_16M,
73 .type = MT_DEVICE,
74 }, {
75 .virtual = (u32)S3C24XX_VA_ISA_WORD,
76 .pfn = PA_CS3(BAST_PA_ISAIO),
77 .length = SZ_16M,
78 .type = MT_DEVICE,
79 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000081 /* CPLD control registers, and external interrupt controls */
82 {
83 .virtual = (u32)VR1000_VA_CTRL1,
84 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
85 .length = SZ_1M,
86 .type = MT_DEVICE,
87 }, {
88 .virtual = (u32)VR1000_VA_CTRL2,
89 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
90 .length = SZ_1M,
91 .type = MT_DEVICE,
92 }, {
93 .virtual = (u32)VR1000_VA_CTRL3,
94 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
95 .length = SZ_1M,
96 .type = MT_DEVICE,
97 }, {
98 .virtual = (u32)VR1000_VA_CTRL4,
99 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
100 .length = SZ_1M,
101 .type = MT_DEVICE,
102 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103};
104
105#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
106#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
107#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
108
Ben Dooks66a9b492006-06-18 23:04:05 +0100109static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 [0] = {
111 .hwport = 0,
112 .flags = 0,
113 .ucon = UCON,
114 .ulcon = ULCON,
115 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 },
117 [1] = {
118 .hwport = 1,
119 .flags = 0,
120 .ucon = UCON,
121 .ulcon = ULCON,
122 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 },
124 /* port 2 is not actually used */
125 [2] = {
126 .hwport = 2,
127 .flags = 0,
128 .ucon = UCON,
129 .ulcon = ULCON,
130 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 }
132};
133
134/* definitions for the vr1000 extra 16550 serial ports */
135
136#define VR1000_BAUDBASE (3692307)
137
138#define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
139
140static struct plat_serial8250_port serial_platform_data[] = {
141 [0] = {
142 .mapbase = VR1000_SERIAL_MAPBASE(0),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800143 .irq = VR1000_IRQ_SERIAL + 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
145 .iotype = UPIO_MEM,
146 .regshift = 0,
147 .uartclk = VR1000_BAUDBASE,
148 },
149 [1] = {
150 .mapbase = VR1000_SERIAL_MAPBASE(1),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800151 .irq = VR1000_IRQ_SERIAL + 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
153 .iotype = UPIO_MEM,
154 .regshift = 0,
155 .uartclk = VR1000_BAUDBASE,
156 },
157 [2] = {
158 .mapbase = VR1000_SERIAL_MAPBASE(2),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800159 .irq = VR1000_IRQ_SERIAL + 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
161 .iotype = UPIO_MEM,
162 .regshift = 0,
163 .uartclk = VR1000_BAUDBASE,
164 },
165 [3] = {
166 .mapbase = VR1000_SERIAL_MAPBASE(3),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800167 .irq = VR1000_IRQ_SERIAL + 3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
169 .iotype = UPIO_MEM,
170 .regshift = 0,
171 .uartclk = VR1000_BAUDBASE,
172 },
173 { },
174};
175
176static struct platform_device serial_device = {
177 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100178 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 .dev = {
180 .platform_data = serial_platform_data,
181 },
182};
183
Ben Dooksd97a6662005-06-23 21:56:47 +0100184/* DM9000 ethernet devices */
185
186static struct resource vr1000_dm9k0_resource[] = {
Tushar Behera940e46a2012-05-12 16:12:25 +0900187 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
188 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800189 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
Tushar Behera940e46a2012-05-12 16:12:25 +0900190 | IORESOURCE_IRQ_HIGHLEVEL),
Ben Dooksd97a6662005-06-23 21:56:47 +0100191};
192
193static struct resource vr1000_dm9k1_resource[] = {
Tushar Behera940e46a2012-05-12 16:12:25 +0900194 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
195 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800196 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
Tushar Behera940e46a2012-05-12 16:12:25 +0900197 | IORESOURCE_IRQ_HIGHLEVEL),
Ben Dooksd97a6662005-06-23 21:56:47 +0100198};
199
200/* for the moment we limit ourselves to 16bit IO until some
201 * better IO routines can be written and tested
202*/
203
Ben Dooks9f693d72005-10-12 19:58:07 +0100204static struct dm9000_plat_data vr1000_dm9k_platdata = {
Ben Dooksd97a6662005-06-23 21:56:47 +0100205 .flags = DM9000_PLATF_16BITONLY,
206};
207
208static struct platform_device vr1000_dm9k0 = {
209 .name = "dm9000",
210 .id = 0,
211 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
212 .resource = vr1000_dm9k0_resource,
213 .dev = {
214 .platform_data = &vr1000_dm9k_platdata,
215 }
216};
217
218static struct platform_device vr1000_dm9k1 = {
219 .name = "dm9000",
220 .id = 1,
221 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
222 .resource = vr1000_dm9k1_resource,
223 .dev = {
224 .platform_data = &vr1000_dm9k_platdata,
225 }
226};
227
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100228/* LEDS */
229
230static struct s3c24xx_led_platdata vr1000_led1_pdata = {
231 .name = "led1",
Ben Dooks070276d2009-05-17 22:32:23 +0100232 .gpio = S3C2410_GPB(0),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100233 .def_trigger = "",
234};
235
236static struct s3c24xx_led_platdata vr1000_led2_pdata = {
237 .name = "led2",
Ben Dooks070276d2009-05-17 22:32:23 +0100238 .gpio = S3C2410_GPB(1),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100239 .def_trigger = "",
240};
241
242static struct s3c24xx_led_platdata vr1000_led3_pdata = {
243 .name = "led3",
Ben Dooks070276d2009-05-17 22:32:23 +0100244 .gpio = S3C2410_GPB(2),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100245 .def_trigger = "",
246};
247
248static struct platform_device vr1000_led1 = {
249 .name = "s3c24xx_led",
250 .id = 1,
251 .dev = {
252 .platform_data = &vr1000_led1_pdata,
253 },
254};
255
256static struct platform_device vr1000_led2 = {
257 .name = "s3c24xx_led",
258 .id = 2,
259 .dev = {
260 .platform_data = &vr1000_led2_pdata,
261 },
262};
263
264static struct platform_device vr1000_led3 = {
265 .name = "s3c24xx_led",
Ben Dooksabac08d72006-12-19 19:10:13 +0100266 .id = 3,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100267 .dev = {
268 .platform_data = &vr1000_led3_pdata,
269 },
270};
271
Ben Dooks60d66982008-07-03 11:24:42 +0100272/* I2C devices. */
273
274static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
275 {
276 I2C_BOARD_INFO("tlv320aic23", 0x1a),
277 }, {
Ben Dooks9c3871c2008-07-03 11:24:44 +0100278 I2C_BOARD_INFO("tmp101", 0x48),
279 }, {
Ben Dooks60d66982008-07-03 11:24:42 +0100280 I2C_BOARD_INFO("m41st87", 0x68),
281 },
282};
283
Ben Dooksd97a6662005-06-23 21:56:47 +0100284/* devices for this board */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286static struct platform_device *vr1000_devices[] __initdata = {
Ben Dooksb8132482009-11-23 00:13:39 +0000287 &s3c_device_ohci,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 &s3c_device_lcd,
289 &s3c_device_wdt,
Ben Dooks3e1b7762008-10-31 16:14:40 +0000290 &s3c_device_i2c0,
Ben Dooksd97a6662005-06-23 21:56:47 +0100291 &s3c_device_adc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 &serial_device,
Ben Dooksd97a6662005-06-23 21:56:47 +0100293 &vr1000_dm9k0,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100294 &vr1000_dm9k1,
295 &vr1000_led1,
296 &vr1000_led2,
297 &vr1000_led3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298};
299
Ben Dooks2bc75092008-07-15 17:17:48 +0100300static struct clk *vr1000_clocks[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 &s3c24xx_dclk0,
302 &s3c24xx_dclk1,
303 &s3c24xx_clkout0,
304 &s3c24xx_clkout1,
305 &s3c24xx_uclk,
306};
307
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308static void vr1000_power_off(void)
309{
Ben Dooks7614e1d2010-05-04 12:53:11 +0900310 gpio_direction_output(S3C2410_GPB(9), 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311}
312
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100313static void __init vr1000_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314{
315 /* initialise clock sources */
316
Ben Dooksd96a9802008-04-16 00:12:39 +0100317 s3c24xx_dclk0.parent = &clk_upll;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 s3c24xx_dclk0.rate = 12*1000*1000;
319
320 s3c24xx_dclk1.parent = NULL;
321 s3c24xx_dclk1.rate = 3692307;
322
323 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
324 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
325
326 s3c24xx_uclk.parent = &s3c24xx_clkout1;
327
Ben Dooksce89c202007-04-20 11:15:27 +0100328 s3c24xx_register_clocks(vr1000_clocks, ARRAY_SIZE(vr1000_clocks));
329
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 pm_power_off = vr1000_power_off;
331
332 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
333 s3c24xx_init_clocks(0);
334 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335}
336
Ben Dooks57e51712007-04-20 11:19:16 +0100337static void __init vr1000_init(void)
338{
Ben Dooks3e1b7762008-10-31 16:14:40 +0000339 s3c_i2c0_set_platdata(NULL);
Ben Dooks57e51712007-04-20 11:19:16 +0100340 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
Ben Dooks9d529c62008-07-03 11:24:39 +0100341
Ben Dooks60d66982008-07-03 11:24:42 +0100342 i2c_register_board_info(0, vr1000_i2c_devs,
343 ARRAY_SIZE(vr1000_i2c_devs));
344
Ben Dooks9d529c62008-07-03 11:24:39 +0100345 nor_simtec_init();
Ben Dooks4d3a3462009-11-13 22:34:20 +0000346 simtec_audio_add(NULL, true, NULL);
Ben Dooks7614e1d2010-05-04 12:53:11 +0900347
348 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
Ben Dooks57e51712007-04-20 11:19:16 +0100349}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350
351MACHINE_START(VR1000, "Thorcom-VR1000")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100352 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Nicolas Pitre69d50712011-07-05 22:38:17 -0400353 .atag_offset = 0x100,
Ben Dooks6904b242005-06-29 11:09:15 +0100354 .map_io = vr1000_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100355 .init_machine = vr1000_init,
Ben Dooks6904b242005-06-29 11:09:15 +0100356 .init_irq = s3c24xx_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 .timer = &s3c24xx_timer,
Kukjin Kimb27b0722012-01-03 14:02:03 +0100358 .restart = s3c2410_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359MACHINE_END