2 * Copyright (c) 2003-2008 Simtec Electronics
3 * Ben Dooks <ben@simtec.co.uk>
5 * Machine support for Thorcom VR1000 board. Designed for Thorcom by
6 * Simtec Electronics, http://www.simtec.co.uk/
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.
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>
20 #include <linux/gpio.h>
21 #include <linux/dm9000.h>
22 #include <linux/i2c.h>
24 #include <linux/serial.h>
25 #include <linux/tty.h>
26 #include <linux/serial_8250.h>
27 #include <linux/serial_reg.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/irq.h>
35 #include <asm/mach-types.h>
37 #include <linux/platform_data/leds-s3c24xx.h>
38 #include <linux/platform_data/i2c-s3c2410.h>
39 #include <linux/platform_data/asoc-s3c24xx_simtec.h>
41 #include <mach/hardware.h>
42 #include <mach/regs-gpio.h>
44 #include <plat/clock.h>
46 #include <plat/devs.h>
47 #include <plat/regs-serial.h>
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)
60 /* macros to modify the physical addresses for io space */
62 #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))
67 static struct map_desc vr1000_iodesc[] __initdata = {
70 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
71 .pfn = PA_CS2(BAST_PA_ISAIO),
75 .virtual = (u32)S3C24XX_VA_ISA_WORD,
76 .pfn = PA_CS3(BAST_PA_ISAIO),
81 /* CPLD control registers, and external interrupt controls */
83 .virtual = (u32)VR1000_VA_CTRL1,
84 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
88 .virtual = (u32)VR1000_VA_CTRL2,
89 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
93 .virtual = (u32)VR1000_VA_CTRL3,
94 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
98 .virtual = (u32)VR1000_VA_CTRL4,
99 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
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
109 static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
124 /* port 2 is not actually used */
134 /* definitions for the vr1000 extra 16550 serial ports */
136 #define VR1000_BAUDBASE (3692307)
138 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
140 static struct plat_serial8250_port serial_platform_data[] = {
142 .mapbase = VR1000_SERIAL_MAPBASE(0),
143 .irq = VR1000_IRQ_SERIAL + 0,
144 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
147 .uartclk = VR1000_BAUDBASE,
150 .mapbase = VR1000_SERIAL_MAPBASE(1),
151 .irq = VR1000_IRQ_SERIAL + 1,
152 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
155 .uartclk = VR1000_BAUDBASE,
158 .mapbase = VR1000_SERIAL_MAPBASE(2),
159 .irq = VR1000_IRQ_SERIAL + 2,
160 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
163 .uartclk = VR1000_BAUDBASE,
166 .mapbase = VR1000_SERIAL_MAPBASE(3),
167 .irq = VR1000_IRQ_SERIAL + 3,
168 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
171 .uartclk = VR1000_BAUDBASE,
176 static struct platform_device serial_device = {
177 .name = "serial8250",
178 .id = PLAT8250_DEV_PLATFORM,
180 .platform_data = serial_platform_data,
184 /* DM9000 ethernet devices */
186 static struct resource vr1000_dm9k0_resource[] = {
187 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
188 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
189 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
190 | IORESOURCE_IRQ_HIGHLEVEL),
193 static struct resource vr1000_dm9k1_resource[] = {
194 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
195 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
196 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
197 | IORESOURCE_IRQ_HIGHLEVEL),
200 /* for the moment we limit ourselves to 16bit IO until some
201 * better IO routines can be written and tested
204 static struct dm9000_plat_data vr1000_dm9k_platdata = {
205 .flags = DM9000_PLATF_16BITONLY,
208 static struct platform_device vr1000_dm9k0 = {
211 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
212 .resource = vr1000_dm9k0_resource,
214 .platform_data = &vr1000_dm9k_platdata,
218 static struct platform_device vr1000_dm9k1 = {
221 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
222 .resource = vr1000_dm9k1_resource,
224 .platform_data = &vr1000_dm9k_platdata,
230 static struct s3c24xx_led_platdata vr1000_led1_pdata = {
232 .gpio = S3C2410_GPB(0),
236 static struct s3c24xx_led_platdata vr1000_led2_pdata = {
238 .gpio = S3C2410_GPB(1),
242 static struct s3c24xx_led_platdata vr1000_led3_pdata = {
244 .gpio = S3C2410_GPB(2),
248 static struct platform_device vr1000_led1 = {
249 .name = "s3c24xx_led",
252 .platform_data = &vr1000_led1_pdata,
256 static struct platform_device vr1000_led2 = {
257 .name = "s3c24xx_led",
260 .platform_data = &vr1000_led2_pdata,
264 static struct platform_device vr1000_led3 = {
265 .name = "s3c24xx_led",
268 .platform_data = &vr1000_led3_pdata,
274 static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
276 I2C_BOARD_INFO("tlv320aic23", 0x1a),
278 I2C_BOARD_INFO("tmp101", 0x48),
280 I2C_BOARD_INFO("m41st87", 0x68),
284 /* devices for this board */
286 static struct platform_device *vr1000_devices[] __initdata = {
300 static struct clk *vr1000_clocks[] __initdata = {
308 static void vr1000_power_off(void)
310 gpio_direction_output(S3C2410_GPB(9), 1);
313 static void __init vr1000_map_io(void)
315 /* initialise clock sources */
317 s3c24xx_dclk0.parent = &clk_upll;
318 s3c24xx_dclk0.rate = 12*1000*1000;
320 s3c24xx_dclk1.parent = NULL;
321 s3c24xx_dclk1.rate = 3692307;
323 s3c24xx_clkout0.parent = &s3c24xx_dclk0;
324 s3c24xx_clkout1.parent = &s3c24xx_dclk1;
326 s3c24xx_uclk.parent = &s3c24xx_clkout1;
328 s3c24xx_register_clocks(vr1000_clocks, ARRAY_SIZE(vr1000_clocks));
330 pm_power_off = vr1000_power_off;
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));
337 static void __init vr1000_init(void)
339 s3c_i2c0_set_platdata(NULL);
340 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
342 i2c_register_board_info(0, vr1000_i2c_devs,
343 ARRAY_SIZE(vr1000_i2c_devs));
346 simtec_audio_add(NULL, true, NULL);
348 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
351 MACHINE_START(VR1000, "Thorcom-VR1000")
352 /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
353 .atag_offset = 0x100,
354 .map_io = vr1000_map_io,
355 .init_machine = vr1000_init,
356 .init_irq = s3c24xx_init_irq,
357 .init_time = s3c24xx_timer_init,
358 .restart = s3c2410_restart,