1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (c) 2003-2008 Simtec Electronics
4 // Ben Dooks <ben@simtec.co.uk>
6 // Machine support for Thorcom VR1000 board. Designed for Thorcom by
7 // Simtec Electronics, http://www.simtec.co.uk/
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>
15 #include <linux/gpio.h>
16 #include <linux/dm9000.h>
17 #include <linux/i2c.h>
19 #include <linux/serial.h>
20 #include <linux/tty.h>
21 #include <linux/serial_8250.h>
22 #include <linux/serial_reg.h>
23 #include <linux/serial_s3c.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/irq.h>
31 #include <asm/mach-types.h>
33 #include <linux/platform_data/leds-s3c24xx.h>
34 #include <linux/platform_data/i2c-s3c2410.h>
35 #include <linux/platform_data/asoc-s3c24xx_simtec.h>
37 #include <mach/hardware.h>
38 #include <mach/regs-gpio.h>
39 #include <mach/gpio-samsung.h>
42 #include <plat/devs.h>
43 #include <plat/samsung-time.h>
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)
56 /* macros to modify the physical addresses for io space */
58 #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))
63 static struct map_desc vr1000_iodesc[] __initdata = {
66 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
67 .pfn = PA_CS2(BAST_PA_ISAIO),
71 .virtual = (u32)S3C24XX_VA_ISA_WORD,
72 .pfn = PA_CS3(BAST_PA_ISAIO),
77 /* CPLD control registers, and external interrupt controls */
79 .virtual = (u32)VR1000_VA_CTRL1,
80 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
84 .virtual = (u32)VR1000_VA_CTRL2,
85 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
89 .virtual = (u32)VR1000_VA_CTRL3,
90 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
94 .virtual = (u32)VR1000_VA_CTRL4,
95 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
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
105 static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
120 /* port 2 is not actually used */
130 /* definitions for the vr1000 extra 16550 serial ports */
132 #define VR1000_BAUDBASE (3692307)
134 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
136 static struct plat_serial8250_port serial_platform_data[] = {
138 .mapbase = VR1000_SERIAL_MAPBASE(0),
139 .irq = VR1000_IRQ_SERIAL + 0,
140 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
143 .uartclk = VR1000_BAUDBASE,
146 .mapbase = VR1000_SERIAL_MAPBASE(1),
147 .irq = VR1000_IRQ_SERIAL + 1,
148 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
151 .uartclk = VR1000_BAUDBASE,
154 .mapbase = VR1000_SERIAL_MAPBASE(2),
155 .irq = VR1000_IRQ_SERIAL + 2,
156 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
159 .uartclk = VR1000_BAUDBASE,
162 .mapbase = VR1000_SERIAL_MAPBASE(3),
163 .irq = VR1000_IRQ_SERIAL + 3,
164 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
167 .uartclk = VR1000_BAUDBASE,
172 static struct platform_device serial_device = {
173 .name = "serial8250",
174 .id = PLAT8250_DEV_PLATFORM,
176 .platform_data = serial_platform_data,
180 /* DM9000 ethernet devices */
182 static struct resource vr1000_dm9k0_resource[] = {
183 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
184 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
185 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
186 | IORESOURCE_IRQ_HIGHLEVEL),
189 static struct resource vr1000_dm9k1_resource[] = {
190 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
191 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
192 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
193 | IORESOURCE_IRQ_HIGHLEVEL),
196 /* for the moment we limit ourselves to 16bit IO until some
197 * better IO routines can be written and tested
200 static struct dm9000_plat_data vr1000_dm9k_platdata = {
201 .flags = DM9000_PLATF_16BITONLY,
204 static struct platform_device vr1000_dm9k0 = {
207 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
208 .resource = vr1000_dm9k0_resource,
210 .platform_data = &vr1000_dm9k_platdata,
214 static struct platform_device vr1000_dm9k1 = {
217 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
218 .resource = vr1000_dm9k1_resource,
220 .platform_data = &vr1000_dm9k_platdata,
226 static struct s3c24xx_led_platdata vr1000_led1_pdata = {
228 .gpio = S3C2410_GPB(0),
232 static struct s3c24xx_led_platdata vr1000_led2_pdata = {
234 .gpio = S3C2410_GPB(1),
238 static struct s3c24xx_led_platdata vr1000_led3_pdata = {
240 .gpio = S3C2410_GPB(2),
244 static struct platform_device vr1000_led1 = {
245 .name = "s3c24xx_led",
248 .platform_data = &vr1000_led1_pdata,
252 static struct platform_device vr1000_led2 = {
253 .name = "s3c24xx_led",
256 .platform_data = &vr1000_led2_pdata,
260 static struct platform_device vr1000_led3 = {
261 .name = "s3c24xx_led",
264 .platform_data = &vr1000_led3_pdata,
270 static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
272 I2C_BOARD_INFO("tlv320aic23", 0x1a),
274 I2C_BOARD_INFO("tmp101", 0x48),
276 I2C_BOARD_INFO("m41st87", 0x68),
280 /* devices for this board */
282 static struct platform_device *vr1000_devices[] __initdata = {
283 &s3c2410_device_dclk,
297 static void vr1000_power_off(void)
299 gpio_direction_output(S3C2410_GPB(9), 1);
302 static void __init vr1000_map_io(void)
304 pm_power_off = vr1000_power_off;
306 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
307 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
308 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
311 static void __init vr1000_init_time(void)
313 s3c2410_init_clocks(12000000);
314 samsung_timer_init();
317 static void __init vr1000_init(void)
319 s3c_i2c0_set_platdata(NULL);
320 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
322 i2c_register_board_info(0, vr1000_i2c_devs,
323 ARRAY_SIZE(vr1000_i2c_devs));
326 simtec_audio_add(NULL, true, NULL);
328 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
331 MACHINE_START(VR1000, "Thorcom-VR1000")
332 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
333 .atag_offset = 0x100,
334 .map_io = vr1000_map_io,
335 .init_machine = vr1000_init,
336 .init_irq = s3c2410_init_irq,
337 .init_time = vr1000_init_time,