blob: 853e74f9b8b5751c4f244b6ab43e2700362c4a36 [file] [log] [blame]
Krzysztof Kozlowski84b21702017-12-25 20:54:32 +01001// SPDX-License-Identifier: GPL-2.0
2//
3// Copyright (c) 2003-2008 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/
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9#include <linux/kernel.h>
10#include <linux/types.h>
11#include <linux/interrupt.h>
12#include <linux/list.h>
13#include <linux/timer.h>
14#include <linux/init.h>
Ben Dooksec976d62009-05-13 22:52:24 +010015#include <linux/gpio.h>
Ben Dooksd97a6662005-06-23 21:56:47 +010016#include <linux/dm9000.h>
Ben Dooks60d66982008-07-03 11:24:42 +010017#include <linux/i2c.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
19#include <linux/serial.h>
20#include <linux/tty.h>
21#include <linux/serial_8250.h>
22#include <linux/serial_reg.h>
Tushar Behera334a1c72014-02-14 10:32:45 +090023#include <linux/serial_s3c.h>
Russell Kingfced80c2008-09-06 12:10:45 +010024#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include <asm/mach/arch.h>
27#include <asm/mach/map.h>
28#include <asm/mach/irq.h>
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/irq.h>
31#include <asm/mach-types.h>
32
Arnd Bergmann436d42c2012-08-24 15:22:12 +020033#include <linux/platform_data/leds-s3c24xx.h>
Arnd Bergmann436d42c2012-08-24 15:22:12 +020034#include <linux/platform_data/i2c-s3c2410.h>
35#include <linux/platform_data/asoc-s3c24xx_simtec.h>
Ben Dooks9d529c62008-07-03 11:24:39 +010036
Kukjin Kimdb8304e2013-01-02 10:47:40 -080037#include <mach/hardware.h>
38#include <mach/regs-gpio.h>
Linus Walleijb0161ca2014-01-14 14:24:24 +010039#include <mach/gpio-samsung.h>
Kukjin Kimdb8304e2013-01-02 10:47:40 -080040
Kukjin Kimdb8304e2013-01-02 10:47:40 -080041#include <plat/cpu.h>
42#include <plat/devs.h>
Romain Naour7f78b6e2013-01-09 18:47:04 -080043#include <plat/samsung-time.h>
Kukjin Kimdb8304e2013-01-02 10:47:40 -080044
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080045#include "bast.h"
Kukjin Kimb27b0722012-01-03 14:02:03 +010046#include "common.h"
Kukjin Kimbbd7e5e2013-01-01 19:56:20 -080047#include "simtec.h"
Kukjin Kimdb8304e2013-01-02 10:47:40 -080048#include "vr1000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50/* macros for virtual address mods for the io space entries */
51#define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
52#define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
53#define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
54#define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
55
56/* macros to modify the physical addresses for io space */
57
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000058#define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
59#define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
60#define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
61#define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63static struct map_desc vr1000_iodesc[] __initdata = {
64 /* ISA IO areas */
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000065 {
66 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
67 .pfn = PA_CS2(BAST_PA_ISAIO),
68 .length = SZ_16M,
69 .type = MT_DEVICE,
70 }, {
71 .virtual = (u32)S3C24XX_VA_ISA_WORD,
72 .pfn = PA_CS3(BAST_PA_ISAIO),
73 .length = SZ_16M,
74 .type = MT_DEVICE,
75 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Ben Dooksdf1ec6d2005-11-08 19:15:30 +000077 /* CPLD control registers, and external interrupt controls */
78 {
79 .virtual = (u32)VR1000_VA_CTRL1,
80 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
81 .length = SZ_1M,
82 .type = MT_DEVICE,
83 }, {
84 .virtual = (u32)VR1000_VA_CTRL2,
85 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
86 .length = SZ_1M,
87 .type = MT_DEVICE,
88 }, {
89 .virtual = (u32)VR1000_VA_CTRL3,
90 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
91 .length = SZ_1M,
92 .type = MT_DEVICE,
93 }, {
94 .virtual = (u32)VR1000_VA_CTRL4,
95 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
96 .length = SZ_1M,
97 .type = MT_DEVICE,
98 },
Linus Torvalds1da177e2005-04-16 15:20:36 -070099};
100
101#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
102#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
103#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
104
Ben Dooks66a9b492006-06-18 23:04:05 +0100105static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 [0] = {
107 .hwport = 0,
108 .flags = 0,
109 .ucon = UCON,
110 .ulcon = ULCON,
111 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 },
113 [1] = {
114 .hwport = 1,
115 .flags = 0,
116 .ucon = UCON,
117 .ulcon = ULCON,
118 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 },
120 /* port 2 is not actually used */
121 [2] = {
122 .hwport = 2,
123 .flags = 0,
124 .ucon = UCON,
125 .ulcon = ULCON,
126 .ufcon = UFCON,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 }
128};
129
130/* definitions for the vr1000 extra 16550 serial ports */
131
132#define VR1000_BAUDBASE (3692307)
133
134#define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
135
136static struct plat_serial8250_port serial_platform_data[] = {
137 [0] = {
138 .mapbase = VR1000_SERIAL_MAPBASE(0),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800139 .irq = VR1000_IRQ_SERIAL + 0,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
141 .iotype = UPIO_MEM,
142 .regshift = 0,
143 .uartclk = VR1000_BAUDBASE,
144 },
145 [1] = {
146 .mapbase = VR1000_SERIAL_MAPBASE(1),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800147 .irq = VR1000_IRQ_SERIAL + 1,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
149 .iotype = UPIO_MEM,
150 .regshift = 0,
151 .uartclk = VR1000_BAUDBASE,
152 },
153 [2] = {
154 .mapbase = VR1000_SERIAL_MAPBASE(2),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800155 .irq = VR1000_IRQ_SERIAL + 2,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
157 .iotype = UPIO_MEM,
158 .regshift = 0,
159 .uartclk = VR1000_BAUDBASE,
160 },
161 [3] = {
162 .mapbase = VR1000_SERIAL_MAPBASE(3),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800163 .irq = VR1000_IRQ_SERIAL + 3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
165 .iotype = UPIO_MEM,
166 .regshift = 0,
167 .uartclk = VR1000_BAUDBASE,
168 },
169 { },
170};
171
172static struct platform_device serial_device = {
173 .name = "serial8250",
Russell King6df29de2005-09-08 16:04:41 +0100174 .id = PLAT8250_DEV_PLATFORM,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 .dev = {
176 .platform_data = serial_platform_data,
177 },
178};
179
Ben Dooksd97a6662005-06-23 21:56:47 +0100180/* DM9000 ethernet devices */
181
182static struct resource vr1000_dm9k0_resource[] = {
Tushar Behera940e46a2012-05-12 16:12:25 +0900183 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
184 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800185 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
Tushar Behera940e46a2012-05-12 16:12:25 +0900186 | IORESOURCE_IRQ_HIGHLEVEL),
Ben Dooksd97a6662005-06-23 21:56:47 +0100187};
188
189static struct resource vr1000_dm9k1_resource[] = {
Tushar Behera940e46a2012-05-12 16:12:25 +0900190 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
191 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
Kukjin Kimdb8304e2013-01-02 10:47:40 -0800192 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
Tushar Behera940e46a2012-05-12 16:12:25 +0900193 | IORESOURCE_IRQ_HIGHLEVEL),
Ben Dooksd97a6662005-06-23 21:56:47 +0100194};
195
196/* for the moment we limit ourselves to 16bit IO until some
197 * better IO routines can be written and tested
198*/
199
Ben Dooks9f693d72005-10-12 19:58:07 +0100200static struct dm9000_plat_data vr1000_dm9k_platdata = {
Ben Dooksd97a6662005-06-23 21:56:47 +0100201 .flags = DM9000_PLATF_16BITONLY,
202};
203
204static struct platform_device vr1000_dm9k0 = {
205 .name = "dm9000",
206 .id = 0,
207 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
208 .resource = vr1000_dm9k0_resource,
209 .dev = {
210 .platform_data = &vr1000_dm9k_platdata,
211 }
212};
213
214static struct platform_device vr1000_dm9k1 = {
215 .name = "dm9000",
216 .id = 1,
217 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
218 .resource = vr1000_dm9k1_resource,
219 .dev = {
220 .platform_data = &vr1000_dm9k_platdata,
221 }
222};
223
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100224/* LEDS */
225
226static struct s3c24xx_led_platdata vr1000_led1_pdata = {
227 .name = "led1",
Ben Dooks070276d2009-05-17 22:32:23 +0100228 .gpio = S3C2410_GPB(0),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100229 .def_trigger = "",
230};
231
232static struct s3c24xx_led_platdata vr1000_led2_pdata = {
233 .name = "led2",
Ben Dooks070276d2009-05-17 22:32:23 +0100234 .gpio = S3C2410_GPB(1),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100235 .def_trigger = "",
236};
237
238static struct s3c24xx_led_platdata vr1000_led3_pdata = {
239 .name = "led3",
Ben Dooks070276d2009-05-17 22:32:23 +0100240 .gpio = S3C2410_GPB(2),
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100241 .def_trigger = "",
242};
243
244static struct platform_device vr1000_led1 = {
245 .name = "s3c24xx_led",
246 .id = 1,
247 .dev = {
248 .platform_data = &vr1000_led1_pdata,
249 },
250};
251
252static struct platform_device vr1000_led2 = {
253 .name = "s3c24xx_led",
254 .id = 2,
255 .dev = {
256 .platform_data = &vr1000_led2_pdata,
257 },
258};
259
260static struct platform_device vr1000_led3 = {
261 .name = "s3c24xx_led",
Ben Dooksabac08d72006-12-19 19:10:13 +0100262 .id = 3,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100263 .dev = {
264 .platform_data = &vr1000_led3_pdata,
265 },
266};
267
Ben Dooks60d66982008-07-03 11:24:42 +0100268/* I2C devices. */
269
270static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
271 {
272 I2C_BOARD_INFO("tlv320aic23", 0x1a),
273 }, {
Ben Dooks9c3871c2008-07-03 11:24:44 +0100274 I2C_BOARD_INFO("tmp101", 0x48),
275 }, {
Ben Dooks60d66982008-07-03 11:24:42 +0100276 I2C_BOARD_INFO("m41st87", 0x68),
277 },
278};
279
Ben Dooksd97a6662005-06-23 21:56:47 +0100280/* devices for this board */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
282static struct platform_device *vr1000_devices[] __initdata = {
Heiko Stuebner51cb1282014-05-09 05:48:57 +0900283 &s3c2410_device_dclk,
Ben Dooksb8132482009-11-23 00:13:39 +0000284 &s3c_device_ohci,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 &s3c_device_lcd,
286 &s3c_device_wdt,
Ben Dooks3e1b7762008-10-31 16:14:40 +0000287 &s3c_device_i2c0,
Ben Dooksd97a6662005-06-23 21:56:47 +0100288 &s3c_device_adc,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 &serial_device,
Ben Dooksd97a6662005-06-23 21:56:47 +0100290 &vr1000_dm9k0,
Ben Dooksb2eba6b2006-12-07 20:28:23 +0100291 &vr1000_dm9k1,
292 &vr1000_led1,
293 &vr1000_led2,
294 &vr1000_led3,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295};
296
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297static void vr1000_power_off(void)
298{
Ben Dooks7614e1d2010-05-04 12:53:11 +0900299 gpio_direction_output(S3C2410_GPB(9), 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300}
301
Ben Dooks5fe10ab2005-09-20 17:24:33 +0100302static void __init vr1000_map_io(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 pm_power_off = vr1000_power_off;
305
306 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
Romain Naour7f78b6e2013-01-09 18:47:04 -0800308 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309}
310
Heiko Stuebner07ee5e72014-05-09 05:49:29 +0900311static void __init vr1000_init_time(void)
312{
313 s3c2410_init_clocks(12000000);
314 samsung_timer_init();
315}
316
Ben Dooks57e51712007-04-20 11:19:16 +0100317static void __init vr1000_init(void)
318{
Ben Dooks3e1b7762008-10-31 16:14:40 +0000319 s3c_i2c0_set_platdata(NULL);
Ben Dooks57e51712007-04-20 11:19:16 +0100320 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
Ben Dooks9d529c62008-07-03 11:24:39 +0100321
Ben Dooks60d66982008-07-03 11:24:42 +0100322 i2c_register_board_info(0, vr1000_i2c_devs,
323 ARRAY_SIZE(vr1000_i2c_devs));
324
Ben Dooks9d529c62008-07-03 11:24:39 +0100325 nor_simtec_init();
Ben Dooks4d3a3462009-11-13 22:34:20 +0000326 simtec_audio_add(NULL, true, NULL);
Ben Dooks7614e1d2010-05-04 12:53:11 +0900327
328 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
Ben Dooks57e51712007-04-20 11:19:16 +0100329}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
331MACHINE_START(VR1000, "Thorcom-VR1000")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100332 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
Nicolas Pitre69d50712011-07-05 22:38:17 -0400333 .atag_offset = 0x100,
Ben Dooks6904b242005-06-29 11:09:15 +0100334 .map_io = vr1000_map_io,
Ben Dooks57e51712007-04-20 11:19:16 +0100335 .init_machine = vr1000_init,
Heiko Stuebnerf182aa12013-03-07 12:38:19 +0900336 .init_irq = s3c2410_init_irq,
Heiko Stuebner07ee5e72014-05-09 05:49:29 +0900337 .init_time = vr1000_init_time,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338MACHINE_END