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-sw-hamming.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>
32 #include <asm/mach-types.h>
34 #include <linux/platform_data/leds-s3c24xx.h>
35 #include <linux/platform_data/fb-s3c2410.h>
36 #include <linux/platform_data/mtd-nand-s3c2410.h>
37 #include <linux/platform_data/usb-s3c2410_udc.h>
38 #include <linux/platform_data/i2c-s3c2410.h>
39 #include "gpio-samsung.h"
47 #include "common-smdk-s3c24xx.h"
49 static struct map_desc qt2410_iodesc
[] __initdata
= {
50 { 0xe0000000, __phys_to_pfn(S3C2410_CS3
+0x01000000), SZ_1M
, MT_DEVICE
}
53 #define UCON S3C2410_UCON_DEFAULT
54 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
55 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
57 static struct s3c2410_uartcfg smdk2410_uartcfgs
[] = {
83 static struct s3c2410fb_display qt2410_lcd_cfg
[] __initdata
= {
85 /* Configuration for 640x480 SHARP LQ080V3DG01 */
86 .lcdcon5
= S3C2410_LCDCON5_FRM565
|
87 S3C2410_LCDCON5_INVVLINE
|
88 S3C2410_LCDCON5_INVVFRAME
|
89 S3C2410_LCDCON5_PWREN
|
90 S3C2410_LCDCON5_HWSWP
,
92 .type
= S3C2410_LCDCON1_TFT
,
96 .pixclock
= 40000, /* HCLK/4 */
108 /* Configuration for 480x640 toppoly TD028TTEC1 */
109 .lcdcon5
= S3C2410_LCDCON5_FRM565
|
110 S3C2410_LCDCON5_INVVLINE
|
111 S3C2410_LCDCON5_INVVFRAME
|
112 S3C2410_LCDCON5_PWREN
|
113 S3C2410_LCDCON5_HWSWP
,
115 .type
= S3C2410_LCDCON1_TFT
,
118 .pixclock
= 40000, /* HCLK/4 */
130 /* Config for 240x320 LCD */
131 .lcdcon5
= S3C2410_LCDCON5_FRM565
|
132 S3C2410_LCDCON5_INVVLINE
|
133 S3C2410_LCDCON5_INVVFRAME
|
134 S3C2410_LCDCON5_PWREN
|
135 S3C2410_LCDCON5_HWSWP
,
137 .type
= S3C2410_LCDCON1_TFT
,
140 .pixclock
= 100000, /* HCLK/10 */
154 static struct s3c2410fb_mach_info qt2410_fb_info __initdata
= {
155 .displays
= qt2410_lcd_cfg
,
156 .num_displays
= ARRAY_SIZE(qt2410_lcd_cfg
),
157 .default_display
= 0,
159 .lpcsel
= ((0xCE6) & ~7) | 1<<4,
164 static struct resource qt2410_cs89x0_resources
[] = {
165 [0] = DEFINE_RES_MEM(0x19000000, 17),
166 [1] = DEFINE_RES_IRQ(IRQ_EINT9
),
169 static struct platform_device qt2410_cs89x0
= {
170 .name
= "cirrus-cs89x0",
171 .num_resources
= ARRAY_SIZE(qt2410_cs89x0_resources
),
172 .resource
= qt2410_cs89x0_resources
,
177 static struct gpiod_lookup_table qt2410_led_gpio_table
= {
178 .dev_id
= "s3c24xx_led.0",
180 GPIO_LOOKUP("GPB", 0, NULL
, GPIO_ACTIVE_LOW
| GPIO_OPEN_DRAIN
),
185 static struct s3c24xx_led_platdata qt2410_pdata_led
= {
187 .def_trigger
= "timer",
190 static struct platform_device qt2410_led
= {
191 .name
= "s3c24xx_led",
194 .platform_data
= &qt2410_pdata_led
,
200 static struct spi_gpio_platform_data spi_gpio_cfg
= {
204 static struct platform_device qt2410_spi
= {
207 .dev
.platform_data
= &spi_gpio_cfg
,
210 static struct gpiod_lookup_table qt2410_spi_gpiod_table
= {
211 .dev_id
= "spi_gpio",
213 GPIO_LOOKUP("GPIOG", 7,
214 "sck", GPIO_ACTIVE_HIGH
),
215 GPIO_LOOKUP("GPIOG", 6,
216 "mosi", GPIO_ACTIVE_HIGH
),
217 GPIO_LOOKUP("GPIOG", 5,
218 "miso", GPIO_ACTIVE_HIGH
),
219 GPIO_LOOKUP("GPIOB", 5,
220 "cs", GPIO_ACTIVE_HIGH
),
225 static struct gpiod_lookup_table qt2410_mmc_gpiod_table
= {
226 .dev_id
= "s3c2410-sdi",
229 GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH
),
230 GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH
),
231 GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH
),
232 GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH
),
233 GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH
),
234 GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH
),
241 static struct platform_device
*qt2410_devices
[] __initdata
= {
248 &s3c_device_usbgadget
,
254 static struct mtd_partition __initdata qt2410_nand_part
[] = {
261 .name
= "U-Boot environment",
282 static struct s3c2410_nand_set __initdata qt2410_nand_sets
[] = {
286 .nr_partitions
= ARRAY_SIZE(qt2410_nand_part
),
287 .partitions
= qt2410_nand_part
,
291 /* choose a set of timings which should suit most 512Mbit
295 static struct s3c2410_platform_nand __initdata qt2410_nand_info
= {
299 .nr_sets
= ARRAY_SIZE(qt2410_nand_sets
),
300 .sets
= qt2410_nand_sets
,
301 .engine_type
= NAND_ECC_ENGINE_TYPE_SOFT
,
306 static struct s3c2410_udc_mach_info qt2410_udc_cfg
= {
309 static char tft_type
= 's';
311 static int __init
qt2410_tft_setup(char *str
)
317 __setup("tft=", qt2410_tft_setup
);
319 static void __init
qt2410_map_io(void)
321 s3c24xx_init_io(qt2410_iodesc
, ARRAY_SIZE(qt2410_iodesc
));
322 s3c24xx_init_uarts(smdk2410_uartcfgs
, ARRAY_SIZE(smdk2410_uartcfgs
));
323 s3c24xx_set_timer_source(S3C24XX_PWM3
, S3C24XX_PWM4
);
326 static void __init
qt2410_init_time(void)
328 s3c2410_init_clocks(12000000);
329 s3c24xx_timer_init();
332 static void __init
qt2410_machine_init(void)
334 s3c_nand_set_platdata(&qt2410_nand_info
);
337 case 'p': /* production */
338 qt2410_fb_info
.default_display
= 1;
341 qt2410_fb_info
.default_display
= 0;
343 case 's': /* small */
345 qt2410_fb_info
.default_display
= 2;
348 s3c24xx_fb_set_platdata(&qt2410_fb_info
);
350 /* set initial state of the LED GPIO */
351 WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH
, NULL
));
352 gpio_free(S3C2410_GPB(0));
354 s3c24xx_udc_set_platdata(&qt2410_udc_cfg
);
355 s3c_i2c0_set_platdata(NULL
);
357 /* Configure the I2S pins (GPE0...GPE4) in correct mode */
358 s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
360 gpiod_add_lookup_table(&qt2410_spi_gpiod_table
);
361 s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE
);
362 gpiod_add_lookup_table(&qt2410_led_gpio_table
);
363 gpiod_add_lookup_table(&qt2410_mmc_gpiod_table
);
364 platform_add_devices(qt2410_devices
, ARRAY_SIZE(qt2410_devices
));
368 MACHINE_START(QT2410
, "QT2410")
369 .atag_offset
= 0x100,
370 .map_io
= qt2410_map_io
,
371 .init_irq
= s3c2410_init_irq
,
372 .init_machine
= qt2410_machine_init
,
373 .init_time
= qt2410_init_time
,