1 // SPDX-License-Identifier: GPL-2.0+
3 // Copyright (C) 2006 by OpenMoko, Inc.
4 // Author: Harald Welte <laforge@openmoko.org>
5 // All rights reserved.
7 #include <linux/kernel.h>
8 #include <linux/types.h>
9 #include <linux/interrupt.h>
10 #include <linux/list.h>
11 #include <linux/timer.h>
12 #include <linux/init.h>
13 #include <linux/gpio.h>
14 #include <linux/gpio/machine.h>
15 #include <linux/device.h>
16 #include <linux/platform_device.h>
17 #include <linux/serial_core.h>
18 #include <linux/serial_s3c.h>
19 #include <linux/spi/spi.h>
20 #include <linux/spi/spi_gpio.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/rawnand.h>
24 #include <linux/mtd/nand_ecc.h>
25 #include <linux/mtd/partitions.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
31 #include <mach/hardware.h>
33 #include <asm/mach-types.h>
35 #include <linux/platform_data/leds-s3c24xx.h>
36 #include <mach/regs-lcd.h>
38 #include <linux/platform_data/mtd-nand-s3c2410.h>
39 #include <linux/platform_data/usb-s3c2410_udc.h>
40 #include <linux/platform_data/i2c-s3c2410.h>
41 #include <mach/gpio-samsung.h>
43 #include <plat/gpio-cfg.h>
44 #include <plat/devs.h>
47 #include <plat/samsung-time.h>
50 #include "common-smdk.h"
52 static struct map_desc qt2410_iodesc[] __initdata = {
53 { 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE }
56 #define UCON S3C2410_UCON_DEFAULT
57 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
58 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
60 static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
86 static struct s3c2410fb_display qt2410_lcd_cfg[] __initdata = {
88 /* Configuration for 640x480 SHARP LQ080V3DG01 */
89 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
90 S3C2410_LCDCON5_INVVLINE |
91 S3C2410_LCDCON5_INVVFRAME |
92 S3C2410_LCDCON5_PWREN |
93 S3C2410_LCDCON5_HWSWP,
95 .type = S3C2410_LCDCON1_TFT,
99 .pixclock = 40000, /* HCLK/4 */
111 /* Configuration for 480x640 toppoly TD028TTEC1 */
112 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
113 S3C2410_LCDCON5_INVVLINE |
114 S3C2410_LCDCON5_INVVFRAME |
115 S3C2410_LCDCON5_PWREN |
116 S3C2410_LCDCON5_HWSWP,
118 .type = S3C2410_LCDCON1_TFT,
121 .pixclock = 40000, /* HCLK/4 */
133 /* Config for 240x320 LCD */
134 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
135 S3C2410_LCDCON5_INVVLINE |
136 S3C2410_LCDCON5_INVVFRAME |
137 S3C2410_LCDCON5_PWREN |
138 S3C2410_LCDCON5_HWSWP,
140 .type = S3C2410_LCDCON1_TFT,
143 .pixclock = 100000, /* HCLK/10 */
157 static struct s3c2410fb_mach_info qt2410_fb_info __initdata = {
158 .displays = qt2410_lcd_cfg,
159 .num_displays = ARRAY_SIZE(qt2410_lcd_cfg),
160 .default_display = 0,
162 .lpcsel = ((0xCE6) & ~7) | 1<<4,
167 static struct resource qt2410_cs89x0_resources[] = {
168 [0] = DEFINE_RES_MEM(0x19000000, 17),
169 [1] = DEFINE_RES_IRQ(IRQ_EINT9),
172 static struct platform_device qt2410_cs89x0 = {
173 .name = "cirrus-cs89x0",
174 .num_resources = ARRAY_SIZE(qt2410_cs89x0_resources),
175 .resource = qt2410_cs89x0_resources,
180 static struct gpiod_lookup_table qt2410_led_gpio_table = {
181 .dev_id = "s3c24xx_led.0",
183 GPIO_LOOKUP("GPB", 0, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
188 static struct s3c24xx_led_platdata qt2410_pdata_led = {
190 .def_trigger = "timer",
193 static struct platform_device qt2410_led = {
194 .name = "s3c24xx_led",
197 .platform_data = &qt2410_pdata_led,
203 static struct spi_gpio_platform_data spi_gpio_cfg = {
207 static struct platform_device qt2410_spi = {
210 .dev.platform_data = &spi_gpio_cfg,
213 static struct gpiod_lookup_table qt2410_spi_gpiod_table = {
214 .dev_id = "spi_gpio",
216 GPIO_LOOKUP("GPIOG", 7,
217 "sck", GPIO_ACTIVE_HIGH),
218 GPIO_LOOKUP("GPIOG", 6,
219 "mosi", GPIO_ACTIVE_HIGH),
220 GPIO_LOOKUP("GPIOG", 5,
221 "miso", GPIO_ACTIVE_HIGH),
222 GPIO_LOOKUP("GPIOB", 5,
223 "cs", GPIO_ACTIVE_HIGH),
230 static struct platform_device *qt2410_devices[] __initdata = {
237 &s3c_device_usbgadget,
243 static struct mtd_partition __initdata qt2410_nand_part[] = {
250 .name = "U-Boot environment",
271 static struct s3c2410_nand_set __initdata qt2410_nand_sets[] = {
275 .nr_partitions = ARRAY_SIZE(qt2410_nand_part),
276 .partitions = qt2410_nand_part,
280 /* choose a set of timings which should suit most 512Mbit
284 static struct s3c2410_platform_nand __initdata qt2410_nand_info = {
288 .nr_sets = ARRAY_SIZE(qt2410_nand_sets),
289 .sets = qt2410_nand_sets,
290 .engine_type = NAND_ECC_ENGINE_TYPE_SOFT,
295 static struct s3c2410_udc_mach_info qt2410_udc_cfg = {
298 static char tft_type = 's';
300 static int __init qt2410_tft_setup(char *str)
306 __setup("tft=", qt2410_tft_setup);
308 static void __init qt2410_map_io(void)
310 s3c24xx_init_io(qt2410_iodesc, ARRAY_SIZE(qt2410_iodesc));
311 s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
312 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
315 static void __init qt2410_init_time(void)
317 s3c2410_init_clocks(12000000);
318 samsung_timer_init();
321 static void __init qt2410_machine_init(void)
323 s3c_nand_set_platdata(&qt2410_nand_info);
326 case 'p': /* production */
327 qt2410_fb_info.default_display = 1;
330 qt2410_fb_info.default_display = 0;
332 case 's': /* small */
334 qt2410_fb_info.default_display = 2;
337 s3c24xx_fb_set_platdata(&qt2410_fb_info);
339 /* set initial state of the LED GPIO */
340 WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH, NULL));
341 gpio_free(S3C2410_GPB(0));
343 s3c24xx_udc_set_platdata(&qt2410_udc_cfg);
344 s3c_i2c0_set_platdata(NULL);
346 gpiod_add_lookup_table(&qt2410_spi_gpiod_table);
347 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
348 gpiod_add_lookup_table(&qt2410_led_gpio_table);
349 platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
353 MACHINE_START(QT2410, "QT2410")
354 .atag_offset = 0x100,
355 .map_io = qt2410_map_io,
356 .init_irq = s3c2410_init_irq,
357 .init_machine = qt2410_machine_init,
358 .init_time = qt2410_init_time,