Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / arm / mach-s3c24xx / mach-qt2410.c
blob9c8373b8d9c35c01141791e24cf0425006182ea6
1 // SPDX-License-Identifier: GPL-2.0+
2 //
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/device.h>
15 #include <linux/platform_device.h>
16 #include <linux/serial_core.h>
17 #include <linux/serial_s3c.h>
18 #include <linux/spi/spi.h>
19 #include <linux/spi/spi_gpio.h>
20 #include <linux/io.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/rawnand.h>
23 #include <linux/mtd/nand_ecc.h>
24 #include <linux/mtd/partitions.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/map.h>
28 #include <asm/mach/irq.h>
30 #include <mach/hardware.h>
31 #include <asm/irq.h>
32 #include <asm/mach-types.h>
34 #include <linux/platform_data/leds-s3c24xx.h>
35 #include <mach/regs-lcd.h>
36 #include <mach/fb.h>
37 #include <linux/platform_data/mtd-nand-s3c2410.h>
38 #include <linux/platform_data/usb-s3c2410_udc.h>
39 #include <linux/platform_data/i2c-s3c2410.h>
40 #include <mach/gpio-samsung.h>
42 #include <plat/gpio-cfg.h>
43 #include <plat/devs.h>
44 #include <plat/cpu.h>
45 #include <plat/pm.h>
46 #include <plat/samsung-time.h>
48 #include "common.h"
49 #include "common-smdk.h"
51 static struct map_desc qt2410_iodesc[] __initdata = {
52 { 0xe0000000, __phys_to_pfn(S3C2410_CS3+0x01000000), SZ_1M, MT_DEVICE }
55 #define UCON S3C2410_UCON_DEFAULT
56 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
57 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
59 static struct s3c2410_uartcfg smdk2410_uartcfgs[] = {
60 [0] = {
61 .hwport = 0,
62 .flags = 0,
63 .ucon = UCON,
64 .ulcon = ULCON,
65 .ufcon = UFCON,
67 [1] = {
68 .hwport = 1,
69 .flags = 0,
70 .ucon = UCON,
71 .ulcon = ULCON,
72 .ufcon = UFCON,
74 [2] = {
75 .hwport = 2,
76 .flags = 0,
77 .ucon = UCON,
78 .ulcon = ULCON,
79 .ufcon = UFCON,
83 /* LCD driver info */
85 static struct s3c2410fb_display qt2410_lcd_cfg[] __initdata = {
87 /* Configuration for 640x480 SHARP LQ080V3DG01 */
88 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
89 S3C2410_LCDCON5_INVVLINE |
90 S3C2410_LCDCON5_INVVFRAME |
91 S3C2410_LCDCON5_PWREN |
92 S3C2410_LCDCON5_HWSWP,
94 .type = S3C2410_LCDCON1_TFT,
95 .width = 640,
96 .height = 480,
98 .pixclock = 40000, /* HCLK/4 */
99 .xres = 640,
100 .yres = 480,
101 .bpp = 16,
102 .left_margin = 44,
103 .right_margin = 116,
104 .hsync_len = 96,
105 .upper_margin = 19,
106 .lower_margin = 11,
107 .vsync_len = 15,
110 /* Configuration for 480x640 toppoly TD028TTEC1 */
111 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
112 S3C2410_LCDCON5_INVVLINE |
113 S3C2410_LCDCON5_INVVFRAME |
114 S3C2410_LCDCON5_PWREN |
115 S3C2410_LCDCON5_HWSWP,
117 .type = S3C2410_LCDCON1_TFT,
118 .width = 480,
119 .height = 640,
120 .pixclock = 40000, /* HCLK/4 */
121 .xres = 480,
122 .yres = 640,
123 .bpp = 16,
124 .left_margin = 8,
125 .right_margin = 24,
126 .hsync_len = 8,
127 .upper_margin = 2,
128 .lower_margin = 4,
129 .vsync_len = 2,
132 /* Config for 240x320 LCD */
133 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
134 S3C2410_LCDCON5_INVVLINE |
135 S3C2410_LCDCON5_INVVFRAME |
136 S3C2410_LCDCON5_PWREN |
137 S3C2410_LCDCON5_HWSWP,
139 .type = S3C2410_LCDCON1_TFT,
140 .width = 240,
141 .height = 320,
142 .pixclock = 100000, /* HCLK/10 */
143 .xres = 240,
144 .yres = 320,
145 .bpp = 16,
146 .left_margin = 13,
147 .right_margin = 8,
148 .hsync_len = 4,
149 .upper_margin = 2,
150 .lower_margin = 7,
151 .vsync_len = 4,
156 static struct s3c2410fb_mach_info qt2410_fb_info __initdata = {
157 .displays = qt2410_lcd_cfg,
158 .num_displays = ARRAY_SIZE(qt2410_lcd_cfg),
159 .default_display = 0,
161 .lpcsel = ((0xCE6) & ~7) | 1<<4,
164 /* CS8900 */
166 static struct resource qt2410_cs89x0_resources[] = {
167 [0] = DEFINE_RES_MEM(0x19000000, 17),
168 [1] = DEFINE_RES_IRQ(IRQ_EINT9),
171 static struct platform_device qt2410_cs89x0 = {
172 .name = "cirrus-cs89x0",
173 .num_resources = ARRAY_SIZE(qt2410_cs89x0_resources),
174 .resource = qt2410_cs89x0_resources,
177 /* LED */
179 static struct s3c24xx_led_platdata qt2410_pdata_led = {
180 .gpio = S3C2410_GPB(0),
181 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
182 .name = "led",
183 .def_trigger = "timer",
186 static struct platform_device qt2410_led = {
187 .name = "s3c24xx_led",
188 .id = 0,
189 .dev = {
190 .platform_data = &qt2410_pdata_led,
194 /* SPI */
196 static struct spi_gpio_platform_data spi_gpio_cfg = {
197 .sck = S3C2410_GPG(7),
198 .mosi = S3C2410_GPG(6),
199 .miso = S3C2410_GPG(5),
202 static struct platform_device qt2410_spi = {
203 .name = "spi-gpio",
204 .id = 1,
205 .dev.platform_data = &spi_gpio_cfg,
208 /* Board devices */
210 static struct platform_device *qt2410_devices[] __initdata = {
211 &s3c_device_ohci,
212 &s3c_device_lcd,
213 &s3c_device_wdt,
214 &s3c_device_i2c0,
215 &s3c_device_iis,
216 &s3c_device_sdi,
217 &s3c_device_usbgadget,
218 &qt2410_spi,
219 &qt2410_cs89x0,
220 &qt2410_led,
223 static struct mtd_partition __initdata qt2410_nand_part[] = {
224 [0] = {
225 .name = "U-Boot",
226 .size = 0x30000,
227 .offset = 0,
229 [1] = {
230 .name = "U-Boot environment",
231 .offset = 0x30000,
232 .size = 0x4000,
234 [2] = {
235 .name = "kernel",
236 .offset = 0x34000,
237 .size = SZ_2M,
239 [3] = {
240 .name = "initrd",
241 .offset = 0x234000,
242 .size = SZ_4M,
244 [4] = {
245 .name = "jffs2",
246 .offset = 0x634000,
247 .size = 0x39cc000,
251 static struct s3c2410_nand_set __initdata qt2410_nand_sets[] = {
252 [0] = {
253 .name = "NAND",
254 .nr_chips = 1,
255 .nr_partitions = ARRAY_SIZE(qt2410_nand_part),
256 .partitions = qt2410_nand_part,
260 /* choose a set of timings which should suit most 512Mbit
261 * chips and beyond.
264 static struct s3c2410_platform_nand __initdata qt2410_nand_info = {
265 .tacls = 20,
266 .twrph0 = 60,
267 .twrph1 = 20,
268 .nr_sets = ARRAY_SIZE(qt2410_nand_sets),
269 .sets = qt2410_nand_sets,
270 .ecc_mode = NAND_ECC_SOFT,
273 /* UDC */
275 static struct s3c2410_udc_mach_info qt2410_udc_cfg = {
278 static char tft_type = 's';
280 static int __init qt2410_tft_setup(char *str)
282 tft_type = str[0];
283 return 1;
286 __setup("tft=", qt2410_tft_setup);
288 static void __init qt2410_map_io(void)
290 s3c24xx_init_io(qt2410_iodesc, ARRAY_SIZE(qt2410_iodesc));
291 s3c24xx_init_uarts(smdk2410_uartcfgs, ARRAY_SIZE(smdk2410_uartcfgs));
292 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
295 static void __init qt2410_init_time(void)
297 s3c2410_init_clocks(12000000);
298 samsung_timer_init();
301 static void __init qt2410_machine_init(void)
303 s3c_nand_set_platdata(&qt2410_nand_info);
305 switch (tft_type) {
306 case 'p': /* production */
307 qt2410_fb_info.default_display = 1;
308 break;
309 case 'b': /* big */
310 qt2410_fb_info.default_display = 0;
311 break;
312 case 's': /* small */
313 default:
314 qt2410_fb_info.default_display = 2;
315 break;
317 s3c24xx_fb_set_platdata(&qt2410_fb_info);
319 /* set initial state of the LED GPIO */
320 WARN_ON(gpio_request_one(S3C2410_GPB(0), GPIOF_OUT_INIT_HIGH, NULL));
321 gpio_free(S3C2410_GPB(0));
323 s3c24xx_udc_set_platdata(&qt2410_udc_cfg);
324 s3c_i2c0_set_platdata(NULL);
326 WARN_ON(gpio_request(S3C2410_GPB(5), "spi cs"));
327 gpio_direction_output(S3C2410_GPB(5), 1);
329 platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
330 s3c_pm_init();
333 MACHINE_START(QT2410, "QT2410")
334 .atag_offset = 0x100,
335 .map_io = qt2410_map_io,
336 .init_irq = s3c2410_init_irq,
337 .init_machine = qt2410_machine_init,
338 .init_time = qt2410_init_time,
339 MACHINE_END