0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <linux/kernel.h>
0010 #include <linux/types.h>
0011 #include <linux/interrupt.h>
0012 #include <linux/list.h>
0013 #include <linux/timer.h>
0014 #include <linux/init.h>
0015 #include <linux/gpio.h>
0016 #include <linux/gpio/machine.h>
0017 #include <linux/dm9000.h>
0018 #include <linux/i2c.h>
0019
0020 #include <linux/serial.h>
0021 #include <linux/tty.h>
0022 #include <linux/serial_8250.h>
0023 #include <linux/serial_reg.h>
0024 #include <linux/serial_s3c.h>
0025 #include <linux/io.h>
0026
0027 #include <asm/mach/arch.h>
0028 #include <asm/mach/map.h>
0029 #include <asm/mach/irq.h>
0030
0031 #include <asm/irq.h>
0032 #include <asm/mach-types.h>
0033
0034 #include <linux/platform_data/leds-s3c24xx.h>
0035 #include <linux/platform_data/i2c-s3c2410.h>
0036 #include <linux/platform_data/asoc-s3c24xx_simtec.h>
0037
0038 #include "regs-gpio.h"
0039 #include "gpio-samsung.h"
0040 #include "gpio-cfg.h"
0041
0042 #include "cpu.h"
0043 #include "devs.h"
0044
0045 #include "bast.h"
0046 #include "s3c24xx.h"
0047 #include "simtec.h"
0048 #include "vr1000.h"
0049
0050
0051 #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
0052 #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
0053 #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
0054 #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
0055
0056
0057
0058 #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
0059 #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
0060 #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
0061 #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
0062
0063 static struct map_desc vr1000_iodesc[] __initdata = {
0064
0065 {
0066 .virtual = (u32)S3C24XX_VA_ISA_BYTE,
0067 .pfn = PA_CS2(BAST_PA_ISAIO),
0068 .length = SZ_16M,
0069 .type = MT_DEVICE,
0070 },
0071
0072
0073 {
0074 .virtual = (u32)VR1000_VA_CTRL1,
0075 .pfn = __phys_to_pfn(VR1000_PA_CTRL1),
0076 .length = SZ_1M,
0077 .type = MT_DEVICE,
0078 }, {
0079 .virtual = (u32)VR1000_VA_CTRL2,
0080 .pfn = __phys_to_pfn(VR1000_PA_CTRL2),
0081 .length = SZ_1M,
0082 .type = MT_DEVICE,
0083 }, {
0084 .virtual = (u32)VR1000_VA_CTRL3,
0085 .pfn = __phys_to_pfn(VR1000_PA_CTRL3),
0086 .length = SZ_1M,
0087 .type = MT_DEVICE,
0088 }, {
0089 .virtual = (u32)VR1000_VA_CTRL4,
0090 .pfn = __phys_to_pfn(VR1000_PA_CTRL4),
0091 .length = SZ_1M,
0092 .type = MT_DEVICE,
0093 },
0094 };
0095
0096 #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
0097 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
0098 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
0099
0100 static struct s3c2410_uartcfg vr1000_uartcfgs[] __initdata = {
0101 [0] = {
0102 .hwport = 0,
0103 .flags = 0,
0104 .ucon = UCON,
0105 .ulcon = ULCON,
0106 .ufcon = UFCON,
0107 },
0108 [1] = {
0109 .hwport = 1,
0110 .flags = 0,
0111 .ucon = UCON,
0112 .ulcon = ULCON,
0113 .ufcon = UFCON,
0114 },
0115
0116 [2] = {
0117 .hwport = 2,
0118 .flags = 0,
0119 .ucon = UCON,
0120 .ulcon = ULCON,
0121 .ufcon = UFCON,
0122 }
0123 };
0124
0125
0126
0127 #define VR1000_BAUDBASE (3692307)
0128
0129 #define VR1000_SERIAL_MAPBASE(x) (VR1000_PA_SERIAL + 0x80 + ((x) << 5))
0130
0131 static struct plat_serial8250_port serial_platform_data[] = {
0132 [0] = {
0133 .mapbase = VR1000_SERIAL_MAPBASE(0),
0134 .irq = VR1000_IRQ_SERIAL + 0,
0135 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
0136 .iotype = UPIO_MEM,
0137 .regshift = 0,
0138 .uartclk = VR1000_BAUDBASE,
0139 },
0140 [1] = {
0141 .mapbase = VR1000_SERIAL_MAPBASE(1),
0142 .irq = VR1000_IRQ_SERIAL + 1,
0143 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
0144 .iotype = UPIO_MEM,
0145 .regshift = 0,
0146 .uartclk = VR1000_BAUDBASE,
0147 },
0148 [2] = {
0149 .mapbase = VR1000_SERIAL_MAPBASE(2),
0150 .irq = VR1000_IRQ_SERIAL + 2,
0151 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
0152 .iotype = UPIO_MEM,
0153 .regshift = 0,
0154 .uartclk = VR1000_BAUDBASE,
0155 },
0156 [3] = {
0157 .mapbase = VR1000_SERIAL_MAPBASE(3),
0158 .irq = VR1000_IRQ_SERIAL + 3,
0159 .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,
0160 .iotype = UPIO_MEM,
0161 .regshift = 0,
0162 .uartclk = VR1000_BAUDBASE,
0163 },
0164 { },
0165 };
0166
0167 static struct platform_device serial_device = {
0168 .name = "serial8250",
0169 .id = PLAT8250_DEV_PLATFORM,
0170 .dev = {
0171 .platform_data = serial_platform_data,
0172 },
0173 };
0174
0175
0176
0177 static struct resource vr1000_dm9k0_resource[] = {
0178 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000, 4),
0179 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x40, 0x40),
0180 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000A, 1, NULL, IORESOURCE_IRQ \
0181 | IORESOURCE_IRQ_HIGHLEVEL),
0182 };
0183
0184 static struct resource vr1000_dm9k1_resource[] = {
0185 [0] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0x80, 4),
0186 [1] = DEFINE_RES_MEM(S3C2410_CS5 + VR1000_PA_DM9000 + 0xC0, 0x40),
0187 [2] = DEFINE_RES_NAMED(VR1000_IRQ_DM9000N, 1, NULL, IORESOURCE_IRQ \
0188 | IORESOURCE_IRQ_HIGHLEVEL),
0189 };
0190
0191
0192
0193
0194
0195 static struct dm9000_plat_data vr1000_dm9k_platdata = {
0196 .flags = DM9000_PLATF_16BITONLY,
0197 };
0198
0199 static struct platform_device vr1000_dm9k0 = {
0200 .name = "dm9000",
0201 .id = 0,
0202 .num_resources = ARRAY_SIZE(vr1000_dm9k0_resource),
0203 .resource = vr1000_dm9k0_resource,
0204 .dev = {
0205 .platform_data = &vr1000_dm9k_platdata,
0206 }
0207 };
0208
0209 static struct platform_device vr1000_dm9k1 = {
0210 .name = "dm9000",
0211 .id = 1,
0212 .num_resources = ARRAY_SIZE(vr1000_dm9k1_resource),
0213 .resource = vr1000_dm9k1_resource,
0214 .dev = {
0215 .platform_data = &vr1000_dm9k_platdata,
0216 }
0217 };
0218
0219
0220
0221 static struct gpiod_lookup_table vr1000_led1_gpio_table = {
0222 .dev_id = "s3c24xx_led.1",
0223 .table = {
0224 GPIO_LOOKUP("GPB", 0, NULL, GPIO_ACTIVE_HIGH),
0225 { },
0226 },
0227 };
0228
0229 static struct gpiod_lookup_table vr1000_led2_gpio_table = {
0230 .dev_id = "s3c24xx_led.2",
0231 .table = {
0232 GPIO_LOOKUP("GPB", 1, NULL, GPIO_ACTIVE_HIGH),
0233 { },
0234 },
0235 };
0236
0237 static struct gpiod_lookup_table vr1000_led3_gpio_table = {
0238 .dev_id = "s3c24xx_led.3",
0239 .table = {
0240 GPIO_LOOKUP("GPB", 2, NULL, GPIO_ACTIVE_HIGH),
0241 { },
0242 },
0243 };
0244
0245 static struct s3c24xx_led_platdata vr1000_led1_pdata = {
0246 .name = "led1",
0247 .def_trigger = "",
0248 };
0249
0250 static struct s3c24xx_led_platdata vr1000_led2_pdata = {
0251 .name = "led2",
0252 .def_trigger = "",
0253 };
0254
0255 static struct s3c24xx_led_platdata vr1000_led3_pdata = {
0256 .name = "led3",
0257 .def_trigger = "",
0258 };
0259
0260 static struct platform_device vr1000_led1 = {
0261 .name = "s3c24xx_led",
0262 .id = 1,
0263 .dev = {
0264 .platform_data = &vr1000_led1_pdata,
0265 },
0266 };
0267
0268 static struct platform_device vr1000_led2 = {
0269 .name = "s3c24xx_led",
0270 .id = 2,
0271 .dev = {
0272 .platform_data = &vr1000_led2_pdata,
0273 },
0274 };
0275
0276 static struct platform_device vr1000_led3 = {
0277 .name = "s3c24xx_led",
0278 .id = 3,
0279 .dev = {
0280 .platform_data = &vr1000_led3_pdata,
0281 },
0282 };
0283
0284
0285
0286 static struct i2c_board_info vr1000_i2c_devs[] __initdata = {
0287 {
0288 I2C_BOARD_INFO("tlv320aic23", 0x1a),
0289 }, {
0290 I2C_BOARD_INFO("tmp101", 0x48),
0291 }, {
0292 I2C_BOARD_INFO("m41st87", 0x68),
0293 },
0294 };
0295
0296
0297
0298 static struct platform_device *vr1000_devices[] __initdata = {
0299 &s3c2410_device_dclk,
0300 &s3c_device_ohci,
0301 &s3c_device_lcd,
0302 &s3c_device_wdt,
0303 &s3c_device_i2c0,
0304 &s3c_device_adc,
0305 &serial_device,
0306 &vr1000_dm9k0,
0307 &vr1000_dm9k1,
0308 &vr1000_led1,
0309 &vr1000_led2,
0310 &vr1000_led3,
0311 };
0312
0313 static void vr1000_power_off(void)
0314 {
0315 gpio_direction_output(S3C2410_GPB(9), 1);
0316 }
0317
0318 static void __init vr1000_map_io(void)
0319 {
0320 pm_power_off = vr1000_power_off;
0321
0322 s3c24xx_init_io(vr1000_iodesc, ARRAY_SIZE(vr1000_iodesc));
0323 s3c24xx_init_uarts(vr1000_uartcfgs, ARRAY_SIZE(vr1000_uartcfgs));
0324 s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
0325 }
0326
0327 static void __init vr1000_init_time(void)
0328 {
0329 s3c2410_init_clocks(12000000);
0330 s3c24xx_timer_init();
0331 }
0332
0333 static void __init vr1000_init(void)
0334 {
0335 s3c_i2c0_set_platdata(NULL);
0336
0337
0338 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
0339 s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_NONE);
0340 s3c_gpio_setpull(S3C2410_GPB(2), S3C_GPIO_PULL_NONE);
0341 gpiod_add_lookup_table(&vr1000_led1_gpio_table);
0342 gpiod_add_lookup_table(&vr1000_led2_gpio_table);
0343 gpiod_add_lookup_table(&vr1000_led3_gpio_table);
0344
0345 platform_add_devices(vr1000_devices, ARRAY_SIZE(vr1000_devices));
0346
0347 i2c_register_board_info(0, vr1000_i2c_devs,
0348 ARRAY_SIZE(vr1000_i2c_devs));
0349
0350 nor_simtec_init();
0351 simtec_audio_add(NULL, true, NULL);
0352
0353 WARN_ON(gpio_request(S3C2410_GPB(9), "power off"));
0354 }
0355
0356 MACHINE_START(VR1000, "Thorcom-VR1000")
0357
0358 .atag_offset = 0x100,
0359 .nr_irqs = NR_IRQS_S3C2410,
0360 .map_io = vr1000_map_io,
0361 .init_machine = vr1000_init,
0362 .init_irq = s3c2410_init_irq,
0363 .init_time = vr1000_init_time,
0364 MACHINE_END