blob: 89f32bd3f01b53e442cd963037bf18613f652e5b [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>
Tushar Behera334a1c72014-02-14 10:32:45 +090028#include <linux/serial_s3c.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
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <asm/irq.h>
36#include <asm/mach-types.h>
37
Arnd Bergmann436d42c2012-08-24 15:22:12 +020038#include <linux/platform_data/leds-s3c24xx.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020039#include <linux/platform_data/i2c-s3c2410.h>
40#include <linux/platform_data/asoc-s3c24xx_simtec.h>
Ben Dooks9d529c62008-07-03 11:24:39 +010041
Kukjin Kimdb8304e2013-01-02 10:47:40 -080042#include <mach/hardware.h>
43#include <mach/regs-gpio.h>
Linus Walleijb0161ca2014-01-14 14:24:24 +010044#include <mach/gpio-samsung.h>
Kukjin Kimdb8304e2013-01-02 10:47:40 -080045
Kukjin Kimdb8304e2013-01-02 10:47:40 -080046#include <plat/cpu.h>
47#include <plat/devs.h>
Romain Naour7f78b6e2013-01-09 18:47:04 -080048#include <plat/samsung-time.h>
Kukjin Kimdb8304e2013-01-02 10:47:40 -080049
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080050#include "bast.h"
Kukjin Kimb27b0722012-01-03 14:02:03 +010051#include "common.h"
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080052#include "simtec.h"
Kukjin Kimdb8304e2013-01-02 10:47:40 -080053#include "vr1000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55/* macros for virtual address mods for the io space entries */
56#define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
57#define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
58#define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
59#define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
60
61/* macros to modify the physical addresses for io space */
62
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000063#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
64#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
65#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
66#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68static struct map_desc vr1000_iodesc[] __initdata = {
69 /* ISA IO areas */
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000070 {
71 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
72 .pfn = PA_CS2(BAST_PA_ISAIO),
73 .length = SZ_16M,
74 .type = MT_DEVICE,
75 }, {
76 .virtual = (u32)S3C24XX_VA_ISA_WORD,
77 .pfn = PA_CS3(BAST_PA_ISAIO),
78 .length = SZ_16M,
79 .type = MT_DEVICE,
80 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000082 /* CPLD control registers, and external interrupt controls */
83 {
84 .virtual = (u32)VR1000_VA_CTRL1,
85 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
86 .length = SZ_1M,
87 .type = MT_DEVICE,
88 }, {
89 .virtual = (u32)VR1000_VA_CTRL2,
90 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
91 .length = SZ_1M,
92 .type = MT_DEVICE,
93 }, {
94 .virtual = (u32)VR1000_VA_CTRL3,
95 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
96 .length = SZ_1M,
97 .type = MT_DEVICE,
98 }, {
99 .virtual = (u32)VR1000_VA_CTRL4,
100 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
101 .length = SZ_1M,
102 .type = MT_DEVICE,
103 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104};
105
106#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
107#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
108#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
109
Ben Dooks66a9b492006-06-18 23:04:05 +0100110static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 [0] = {
112 .hwport = 0,
113 .flags = 0,
114 .ucon = UCON,
115 .ulcon = ULCON,
116 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 },
118 [1] = {
119 .hwport = 1,
120 .flags = 0,
121 .ucon = UCON,
122 .ulcon = ULCON,
123 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 },
125 /* port 2 is not actually used */
126 [2] = {
127 .hwport = 2,
128 .flags = 0,
129 .ucon = UCON,
130 .ulcon = ULCON,
131 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 }
133};
134
135/* definitions for the vr1000 extra 16550 serial ports */
136
137#define VR1000_BAUDBASE (3692307)
138
139#define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
140
141static struct plat_serial8250_port serial_platform_data[] = {
142 [0] = {
143 .mapbase = VR1000_SERIAL_MAPBASE(0),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800144 .irq = VR1000_IRQ_SERIAL + 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
146 .iotype = UPIO_MEM,
147 .regshift = 0,
148 .uartclk = VR1000_BAUDBASE,
149 },
150 [1] = {
151 .mapbase = VR1000_SERIAL_MAPBASE(1),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800152 .irq = VR1000_IRQ_SERIAL + 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
154 .iotype = UPIO_MEM,
155 .regshift = 0,
156 .uartclk = VR1000_BAUDBASE,
157 },
158 [2] = {
159 .mapbase = VR1000_SERIAL_MAPBASE(2),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800160 .irq = VR1000_IRQ_SERIAL + 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
162 .iotype = UPIO_MEM,
163 .regshift = 0,
164 .uartclk = VR1000_BAUDBASE,
165 },
166 [3] = {
167 .mapbase = VR1000_SERIAL_MAPBASE(3),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800168 .irq = VR1000_IRQ_SERIAL + 3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
170 .iotype = UPIO_MEM,
171 .regshift = 0,
172 .uartclk = VR1000_BAUDBASE,
173 },
174 { },
175};
176
177static struct platform_device serial_device = {
178 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100179 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 .dev = {
181 .platform_data = serial_platform_data,
182 },
183};
184
Ben Dooksd97a6662005-06-23 21:56:47 +0100185/* DM9000 ethernet devices */
186
187static struct resource vr1000_dm9k0_resource[] = {
Tushar Behera940e46a2012-05-12 16:12:25 +0900188 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
189 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800190 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
Tushar Behera940e46a2012-05-12 16:12:25 +0900191 | IORESOURCE_IRQ_HIGHLEVEL),
Ben Dooksd97a6662005-06-23 21:56:47 +0100192};
193
194static struct resource vr1000_dm9k1_resource[] = {
Tushar Behera940e46a2012-05-12 16:12:25 +0900195 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
196 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800197 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
Tushar Behera940e46a2012-05-12 16:12:25 +0900198 | IORESOURCE_IRQ_HIGHLEVEL),
Ben Dooksd97a6662005-06-23 21:56:47 +0100199};
200
201/* for the moment we limit ourselves to 16bit IO until some
202 * better IO routines can be written and tested
203*/
204
Ben Dooks9f693d72005-10-12 19:58:07 +0100205static struct dm9000_plat_data vr1000_dm9k_platdata = {
Ben Dooksd97a6662005-06-23 21:56:47 +0100206 .flags = DM9000_PLATF_16BITONLY,
207};
208
209static struct platform_device vr1000_dm9k0 = {
210 .name = "dm9000",
211 .id = 0,
212 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
213 .resource = vr1000_dm9k0_resource,
214 .dev = {
215 .platform_data = &vr1000_dm9k_platdata,
216 }
217};
218
219static struct platform_device vr1000_dm9k1 = {
220 .name = "dm9000",
221 .id = 1,
222 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
223 .resource = vr1000_dm9k1_resource,
224 .dev = {
225 .platform_data = &vr1000_dm9k_platdata,
226 }
227};
228
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100229/* LEDS */
230
231static struct s3c24xx_led_platdata vr1000_led1_pdata = {
232 .name = "led1",
Ben Dooks070276d2009-05-17 22:32:23 +0100233 .gpio = S3C2410_GPB(0),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100234 .def_trigger = "",
235};
236
237static struct s3c24xx_led_platdata vr1000_led2_pdata = {
238 .name = "led2",
Ben Dooks070276d2009-05-17 22:32:23 +0100239 .gpio = S3C2410_GPB(1),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100240 .def_trigger = "",
241};
242
243static struct s3c24xx_led_platdata vr1000_led3_pdata = {
244 .name = "led3",
Ben Dooks070276d2009-05-17 22:32:23 +0100245 .gpio = S3C2410_GPB(2),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100246 .def_trigger = "",
247};
248
249static struct platform_device vr1000_led1 = {
250 .name = "s3c24xx_led",
251 .id = 1,
252 .dev = {
253 .platform_data = &vr1000_led1_pdata,
254 },
255};
256
257static struct platform_device vr1000_led2 = {
258 .name = "s3c24xx_led",
259 .id = 2,
260 .dev = {
261 .platform_data = &vr1000_led2_pdata,
262 },
263};
264
265static struct platform_device vr1000_led3 = {
266 .name = "s3c24xx_led",
Ben Dooksabac08d72006-12-19 19:10:13 +0100267 .id = 3,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100268 .dev = {
269 .platform_data = &vr1000_led3_pdata,
270 },
271};
272
Ben Dooks60d66982008-07-03 11:24:42 +0100273/* I2C devices. */
274
275static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
276 {
277 I2C_BOARD_INFO("tlv320aic23", 0x1a),
278 }, {
Ben Dooks9c3871c2008-07-03 11:24:44 +0100279 I2C_BOARD_INFO("tmp101", 0x48),
280 }, {
Ben Dooks60d66982008-07-03 11:24:42 +0100281 I2C_BOARD_INFO("m41st87", 0x68),
282 },
283};
284
Ben Dooksd97a6662005-06-23 21:56:47 +0100285/* devices for this board */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286
287static struct platform_device *vr1000_devices[] __initdata = {
Heiko Stuebner51cb1282014-05-09 05:48:57 +0900288 &s3c2410_device_dclk,
Ben Dooksb8132482009-11-23 00:13:39 +0000289 &s3c_device_ohci,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 &s3c_device_lcd,
291 &s3c_device_wdt,
Ben Dooks3e1b7762008-10-31 16:14:40 +0000292 &s3c_device_i2c0,
Ben Dooksd97a6662005-06-23 21:56:47 +0100293 &s3c_device_adc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 &serial_device,
Ben Dooksd97a6662005-06-23 21:56:47 +0100295 &vr1000_dm9k0,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100296 &vr1000_dm9k1,
297 &vr1000_led1,
298 &vr1000_led2,
299 &vr1000_led3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300};
301
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302static void vr1000_power_off(void)
303{
Ben Dooks7614e1d2010-05-04 12:53:11 +0900304 gpio_direction_output(S3C2410_GPB(9), 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305}
306
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100307static void __init vr1000_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 pm_power_off = vr1000_power_off;
310
311 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
Romain Naour7f78b6e2013-01-09 18:47:04 -0800313 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314}
315
Heiko Stuebner07ee5e72014-05-09 05:49:29 +0900316static void __init vr1000_init_time(void)
317{
318 s3c2410_init_clocks(12000000);
319 samsung_timer_init();
320}
321
Ben Dooks57e51712007-04-20 11:19:16 +0100322static void __init vr1000_init(void)
323{
Ben Dooks3e1b7762008-10-31 16:14:40 +0000324 s3c_i2c0_set_platdata(NULL);
Ben Dooks57e51712007-04-20 11:19:16 +0100325 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
Ben Dooks9d529c62008-07-03 11:24:39 +0100326
Ben Dooks60d66982008-07-03 11:24:42 +0100327 i2c_register_board_info(0, vr1000_i2c_devs,
328 ARRAY_SIZE(vr1000_i2c_devs));
329
Ben Dooks9d529c62008-07-03 11:24:39 +0100330 nor_simtec_init();
Ben Dooks4d3a3462009-11-13 22:34:20 +0000331 simtec_audio_add(NULL, true, NULL);
Ben Dooks7614e1d2010-05-04 12:53:11 +0900332
333 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
Ben Dooks57e51712007-04-20 11:19:16 +0100334}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
336MACHINE_START(VR1000, "Thorcom-VR1000")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100337 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Nicolas Pitre69d50712011-07-05 22:38:17 -0400338 .atag_offset = 0x100,
Ben Dooks6904b242005-06-29 11:09:15 +0100339 .map_io = vr1000_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100340 .init_machine = vr1000_init,
Heiko Stuebnerf182aa12013-03-07 12:38:19 +0900341 .init_irq = s3c2410_init_irq,
Heiko Stuebner07ee5e72014-05-09 05:49:29 +0900342 .init_time = vr1000_init_time,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343MACHINE_END