1 /* linux/arch/arm/mach-s3c2410/mach-jive.c
3 * Copyright 2007 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
6 * http://armlinux.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.
13 #include <linux/kernel.h>
14 #include <linux/types.h>
15 #include <linux/interrupt.h>
16 #include <linux/list.h>
17 #include <linux/timer.h>
18 #include <linux/init.h>
19 #include <linux/sysdev.h>
20 #include <linux/delay.h>
21 #include <linux/serial_core.h>
22 #include <linux/platform_device.h>
24 #include <video/ili9320.h>
26 #include <linux/spi/spi.h>
28 #include <linux/mtd/mtd.h>
29 #include <linux/mtd/partitions.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/irq.h>
35 #include <asm/plat-s3c/regs-serial.h>
36 #include <asm/plat-s3c/nand.h>
38 #include <asm/arch/regs-power.h>
39 #include <asm/arch/regs-gpio.h>
40 #include <asm/arch/regs-mem.h>
41 #include <asm/arch/regs-lcd.h>
42 #include <asm/arch/spi-gpio.h>
43 #include <asm/arch/fb.h>
45 #include <asm/mach-types.h>
47 #include <linux/mtd/mtd.h>
48 #include <linux/mtd/nand.h>
49 #include <linux/mtd/nand_ecc.h>
50 #include <linux/mtd/partitions.h>
52 #include <asm/plat-s3c24xx/clock.h>
53 #include <asm/plat-s3c24xx/devs.h>
54 #include <asm/plat-s3c24xx/cpu.h>
55 #include <asm/plat-s3c24xx/pm.h>
56 #include <asm/plat-s3c24xx/udc.h>
58 static struct map_desc jive_iodesc[] __initdata = {
61 #define UCON S3C2410_UCON_DEFAULT
62 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE
63 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
65 static struct s3c2410_uartcfg jive_uartcfgs[] = {
89 /* Jive flash assignment
91 * 0x00000000-0x00028000 : uboot
92 * 0x00028000-0x0002c000 : uboot env
93 * 0x0002c000-0x00030000 : spare
94 * 0x00030000-0x00200000 : zimage A
95 * 0x00200000-0x01600000 : cramfs A
96 * 0x01600000-0x017d0000 : zimage B
97 * 0x017d0000-0x02bd0000 : cramfs B
98 * 0x02bd0000-0x03fd0000 : yaffs
100 static struct mtd_partition jive_imageA_nand_part[] = {
102 #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER
103 /* Don't allow access to the bootloader from linux */
107 .size = (160 * SZ_1K),
108 .mask_flags = MTD_WRITEABLE, /* force read-only */
114 .offset = (176 * SZ_1K),
115 .size = (16 * SZ_1K),
121 .name = "kernel (ro)",
122 .offset = (192 * SZ_1K),
123 .size = (SZ_2M) - (192 * SZ_1K),
124 .mask_flags = MTD_WRITEABLE, /* force read-only */
128 .size = (20 * SZ_1M),
129 .mask_flags = MTD_WRITEABLE, /* force read-only */
135 .offset = (44 * SZ_1M),
136 .size = (20 * SZ_1M),
139 /* bootloader environment */
142 .offset = (160 * SZ_1K),
143 .size = (16 * SZ_1K),
149 .offset = (22 * SZ_1M),
150 .size = (2 * SZ_1M) - (192 * SZ_1K),
153 .offset = (24 * SZ_1M) - (192*SZ_1K),
154 .size = (20 * SZ_1M),
158 static struct mtd_partition jive_imageB_nand_part[] = {
160 #ifdef CONFIG_MACH_JIVE_SHOW_BOOTLOADER
161 /* Don't allow access to the bootloader from linux */
165 .size = (160 * SZ_1K),
166 .mask_flags = MTD_WRITEABLE, /* force read-only */
172 .offset = (176 * SZ_1K),
173 .size = (16 * SZ_1K),
179 .name = "kernel (ro)",
180 .offset = (22 * SZ_1M),
181 .size = (2 * SZ_1M) - (192 * SZ_1K),
182 .mask_flags = MTD_WRITEABLE, /* force read-only */
186 .offset = (24 * SZ_1M) - (192 * SZ_1K),
187 .size = (20 * SZ_1M),
188 .mask_flags = MTD_WRITEABLE, /* force read-only */
194 .offset = (44 * SZ_1M),
195 .size = (20 * SZ_1M),
198 /* bootloader environment */
201 .offset = (160 * SZ_1K),
202 .size = (16 * SZ_1K),
208 .offset = (192 * SZ_1K),
209 .size = (2 * SZ_1M) - (192 * SZ_1K),
212 .offset = (2 * SZ_1M),
213 .size = (20 * SZ_1M),
217 static struct s3c2410_nand_set jive_nand_sets[] = {
221 .nr_partitions = ARRAY_SIZE(jive_imageA_nand_part),
222 .partitions = jive_imageA_nand_part,
226 static struct s3c2410_platform_nand jive_nand_info = {
227 /* set taken from osiris nand timings, possibly still conservative */
231 .sets = jive_nand_sets,
232 .nr_sets = ARRAY_SIZE(jive_nand_sets),
235 static int __init jive_mtdset(char *options)
237 struct s3c2410_nand_set *nand = &jive_nand_sets[0];
240 if (options == NULL || options[0] == '\0')
243 if (strict_strtoul(options, 10, &set)) {
244 printk(KERN_ERR "failed to parse mtdset=%s\n", options);
250 nand->nr_partitions = ARRAY_SIZE(jive_imageB_nand_part);
251 nand->partitions = jive_imageB_nand_part;
253 /* this is already setup in the nand info */
256 printk(KERN_ERR "Unknown mtd set %ld specified,"
257 "using default.", set);
263 /* parse the mtdset= option given to the kernel command line */
264 __setup("mtdset=", jive_mtdset);
266 /* LCD timing and setup */
268 #define LCD_XRES (240)
269 #define LCD_YRES (320)
270 #define LCD_LEFT_MARGIN (12)
271 #define LCD_RIGHT_MARGIN (12)
272 #define LCD_LOWER_MARGIN (12)
273 #define LCD_UPPER_MARGIN (12)
274 #define LCD_VSYNC (2)
275 #define LCD_HSYNC (2)
277 #define LCD_REFRESH (60)
279 #define LCD_HTOT (LCD_HSYNC + LCD_LEFT_MARGIN + LCD_XRES + LCD_RIGHT_MARGIN)
280 #define LCD_VTOT (LCD_VSYNC + LCD_LOWER_MARGIN + LCD_YRES + LCD_UPPER_MARGIN)
282 struct s3c2410fb_display jive_vgg2432a4_display[] = {
288 .left_margin = LCD_LEFT_MARGIN,
289 .right_margin = LCD_RIGHT_MARGIN,
290 .upper_margin = LCD_UPPER_MARGIN,
291 .lower_margin = LCD_LOWER_MARGIN,
292 .hsync_len = LCD_HSYNC,
293 .vsync_len = LCD_VSYNC,
295 .pixclock = (1000000000000LL /
296 (LCD_REFRESH * LCD_HTOT * LCD_VTOT)),
299 .type = (S3C2410_LCDCON1_TFT16BPP |
300 S3C2410_LCDCON1_TFT),
302 .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
303 S3C2410_LCDCON5_INVVLINE |
304 S3C2410_LCDCON5_INVVFRAME |
305 S3C2410_LCDCON5_INVVDEN |
306 S3C2410_LCDCON5_PWREN),
310 /* todo - put into gpio header */
312 #define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2))
313 #define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2))
315 struct s3c2410fb_mach_info jive_lcd_config = {
316 .displays = jive_vgg2432a4_display,
317 .num_displays = ARRAY_SIZE(jive_vgg2432a4_display),
318 .default_display = 0,
320 /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN
321 * and disable the pull down resistors on pins we are using for LCD
324 .gpcup = (0xf << 1) | (0x3f << 10),
326 .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE |
327 S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM |
328 S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 |
329 S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 |
330 S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7),
332 .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) |
333 S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) |
334 S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) |
335 S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) |
336 S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)),
338 .gpdup = (0x3f << 2) | (0x3f << 10),
340 .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 |
341 S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 |
342 S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 |
343 S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 |
344 S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 |
345 S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23),
347 .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) |
348 S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) |
349 S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) |
350 S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)|
351 S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)|
352 S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)),
355 /* ILI9320 support. */
357 static void jive_lcm_reset(unsigned int set)
359 printk(KERN_DEBUG "%s(%d)\n", __func__, set);
361 s3c2410_gpio_setpin(S3C2410_GPG13, set);
362 s3c2410_gpio_cfgpin(S3C2410_GPG13, S3C2410_GPIO_OUTPUT);
365 #undef LCD_UPPER_MARGIN
366 #define LCD_UPPER_MARGIN 2
368 static struct ili9320_platdata jive_lcm_config = {
372 .reset = jive_lcm_reset,
373 .suspend = ILI9320_SUSPEND_DEEP,
375 .entry_mode = ILI9320_ENTRYMODE_ID(3) | ILI9320_ENTRYMODE_BGR,
376 .display2 = (ILI9320_DISPLAY2_FP(LCD_UPPER_MARGIN) |
377 ILI9320_DISPLAY2_BP(LCD_LOWER_MARGIN)),
380 .rgb_if1 = (ILI9320_RGBIF1_RIM_RGB18 |
381 ILI9320_RGBIF1_RM | ILI9320_RGBIF1_CLK_RGBIF),
382 .rgb_if2 = ILI9320_RGBIF2_DPL,
385 .interface4 = (ILI9320_INTERFACE4_RTNE(16) |
386 ILI9320_INTERFACE4_DIVE(1)),
391 /* LCD SPI support */
393 static void jive_lcd_spi_chipselect(struct s3c2410_spigpio_info *spi, int cs)
395 s3c2410_gpio_setpin(S3C2410_GPB7, cs ? 0 : 1);
398 static struct s3c2410_spigpio_info jive_lcd_spi = {
400 .pin_clk = S3C2410_GPG8,
401 .pin_mosi = S3C2410_GPB8,
402 .chip_select = jive_lcd_spi_chipselect,
405 static struct platform_device jive_device_lcdspi = {
406 .name = "s3c24xx-spi-gpio",
409 .dev.platform_data = &jive_lcd_spi,
412 /* WM8750 audio code SPI definition */
414 static void jive_wm8750_chipselect(struct s3c2410_spigpio_info *spi, int cs)
416 s3c2410_gpio_setpin(S3C2410_GPH10, cs ? 0 : 1);
419 static struct s3c2410_spigpio_info jive_wm8750_spi = {
421 .pin_clk = S3C2410_GPB4,
422 .pin_mosi = S3C2410_GPB9,
423 .chip_select = jive_wm8750_chipselect,
426 static struct platform_device jive_device_wm8750 = {
427 .name = "s3c24xx-spi-gpio",
430 .dev.platform_data = &jive_wm8750_spi,
433 /* JIVE SPI devices. */
435 static struct spi_board_info __initdata jive_spi_devs[] = {
437 .modalias = "VGG2432A4",
440 .mode = SPI_MODE_3, /* CPOL=1, CPHA=1 */
441 .max_speed_hz = 100000,
442 .platform_data = &jive_lcm_config,
444 .modalias = "WM8750",
447 .mode = SPI_MODE_0, /* CPOL=0, CPHA=0 */
448 .max_speed_hz = 100000,
452 static struct platform_device *jive_devices[] __initdata = {
461 &s3c_device_usbgadget,
464 static struct s3c2410_udc_mach_info jive_udc_cfg __initdata = {
465 .vbus_pin = S3C2410_GPG1, /* detect is on GPG1 */
468 /* Jive power management device */
471 static int jive_pm_suspend(struct sys_device *sd, pm_message_t state)
473 /* Write the magic value u-boot uses to check for resume into
474 * the INFORM0 register, and ensure INFORM1 is set to the
475 * correct address to resume from. */
477 __raw_writel(0x2BED, S3C2412_INFORM0);
478 __raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2412_INFORM1);
483 static int jive_pm_resume(struct sys_device *sd)
485 __raw_writel(0x0, S3C2412_INFORM0);
490 #define jive_pm_suspend NULL
491 #define jive_pm_resume NULL
494 static struct sysdev_class jive_pm_sysclass = {
496 .suspend = jive_pm_suspend,
497 .resume = jive_pm_resume,
500 static struct sys_device jive_pm_sysdev = {
501 .cls = &jive_pm_sysclass,
504 static void __init jive_map_io(void)
506 s3c24xx_init_io(jive_iodesc, ARRAY_SIZE(jive_iodesc));
507 s3c24xx_init_clocks(12000000);
508 s3c24xx_init_uarts(jive_uartcfgs, ARRAY_SIZE(jive_uartcfgs));
511 static void __init jive_machine_init(void)
513 /* register system devices for managing low level suspend */
515 sysdev_class_register(&jive_pm_sysclass);
516 sysdev_register(&jive_pm_sysdev);
518 /* write our sleep configurations for the IO. Pull down all unused
519 * IO, ensure that we have turned off all peripherals we do not
520 * need, and configure the ones we do need. */
524 __raw_writel(S3C2412_SLPCON_IN(0) |
525 S3C2412_SLPCON_PULL(1) |
526 S3C2412_SLPCON_HIGH(2) |
527 S3C2412_SLPCON_PULL(3) |
528 S3C2412_SLPCON_PULL(4) |
529 S3C2412_SLPCON_PULL(5) |
530 S3C2412_SLPCON_PULL(6) |
531 S3C2412_SLPCON_HIGH(7) |
532 S3C2412_SLPCON_PULL(8) |
533 S3C2412_SLPCON_PULL(9) |
534 S3C2412_SLPCON_PULL(10), S3C2412_GPBSLPCON);
538 __raw_writel(S3C2412_SLPCON_PULL(0) |
539 S3C2412_SLPCON_PULL(1) |
540 S3C2412_SLPCON_PULL(2) |
541 S3C2412_SLPCON_PULL(3) |
542 S3C2412_SLPCON_PULL(4) |
543 S3C2412_SLPCON_PULL(5) |
544 S3C2412_SLPCON_LOW(6) |
545 S3C2412_SLPCON_PULL(6) |
546 S3C2412_SLPCON_PULL(7) |
547 S3C2412_SLPCON_PULL(8) |
548 S3C2412_SLPCON_PULL(9) |
549 S3C2412_SLPCON_PULL(10) |
550 S3C2412_SLPCON_PULL(11) |
551 S3C2412_SLPCON_PULL(12) |
552 S3C2412_SLPCON_PULL(13) |
553 S3C2412_SLPCON_PULL(14) |
554 S3C2412_SLPCON_PULL(15), S3C2412_GPCSLPCON);
558 __raw_writel(S3C2412_SLPCON_ALL_PULL, S3C2412_GPDSLPCON);
562 __raw_writel(S3C2412_SLPCON_LOW(0) |
563 S3C2412_SLPCON_LOW(1) |
564 S3C2412_SLPCON_LOW(2) |
565 S3C2412_SLPCON_EINT(3) |
566 S3C2412_SLPCON_EINT(4) |
567 S3C2412_SLPCON_EINT(5) |
568 S3C2412_SLPCON_EINT(6) |
569 S3C2412_SLPCON_EINT(7), S3C2412_GPFSLPCON);
573 __raw_writel(S3C2412_SLPCON_IN(0) |
574 S3C2412_SLPCON_IN(1) |
575 S3C2412_SLPCON_IN(2) |
576 S3C2412_SLPCON_IN(3) |
577 S3C2412_SLPCON_IN(4) |
578 S3C2412_SLPCON_IN(5) |
579 S3C2412_SLPCON_IN(6) |
580 S3C2412_SLPCON_IN(7) |
581 S3C2412_SLPCON_PULL(8) |
582 S3C2412_SLPCON_PULL(9) |
583 S3C2412_SLPCON_IN(10) |
584 S3C2412_SLPCON_PULL(11) |
585 S3C2412_SLPCON_PULL(12) |
586 S3C2412_SLPCON_PULL(13) |
587 S3C2412_SLPCON_IN(14) |
588 S3C2412_SLPCON_PULL(15), S3C2412_GPGSLPCON);
592 __raw_writel(S3C2412_SLPCON_PULL(0) |
593 S3C2412_SLPCON_PULL(1) |
594 S3C2412_SLPCON_PULL(2) |
595 S3C2412_SLPCON_PULL(3) |
596 S3C2412_SLPCON_PULL(4) |
597 S3C2412_SLPCON_PULL(5) |
598 S3C2412_SLPCON_PULL(6) |
599 S3C2412_SLPCON_IN(7) |
600 S3C2412_SLPCON_IN(8) |
601 S3C2412_SLPCON_PULL(9) |
602 S3C2412_SLPCON_IN(10), S3C2412_GPHSLPCON);
604 /* initialise the power management now we've setup everything. */
608 s3c_device_nand.dev.platform_data = &jive_nand_info;
610 /* initialise the spi */
612 s3c2410_gpio_setpin(S3C2410_GPG13, 0);
613 s3c2410_gpio_cfgpin(S3C2410_GPG13, S3C2410_GPIO_OUTPUT);
615 s3c2410_gpio_setpin(S3C2410_GPB7, 1);
616 s3c2410_gpio_cfgpin(S3C2410_GPB7, S3C2410_GPIO_OUTPUT);
618 s3c2410_gpio_setpin(S3C2410_GPB6, 0);
619 s3c2410_gpio_cfgpin(S3C2410_GPB6, S3C2410_GPIO_OUTPUT);
621 s3c2410_gpio_setpin(S3C2410_GPG8, 1);
622 s3c2410_gpio_cfgpin(S3C2410_GPG8, S3C2410_GPIO_OUTPUT);
624 /* initialise the WM8750 spi */
626 s3c2410_gpio_setpin(S3C2410_GPH10, 1);
627 s3c2410_gpio_cfgpin(S3C2410_GPH10, S3C2410_GPIO_OUTPUT);
629 /* Turn off suspend on both USB ports, and switch the
630 * selectable USB port to USB device mode. */
632 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
633 S3C2410_MISCCR_USBSUSPND0 |
634 S3C2410_MISCCR_USBSUSPND1, 0x0);
636 s3c24xx_udc_set_platdata(&jive_udc_cfg);
637 s3c24xx_fb_set_platdata(&jive_lcd_config);
639 spi_register_board_info(jive_spi_devs, ARRAY_SIZE(jive_spi_devs));
641 platform_add_devices(jive_devices, ARRAY_SIZE(jive_devices));
644 MACHINE_START(JIVE, "JIVE")
645 /* Maintainer: Ben Dooks <ben@fluff.org> */
646 .phys_io = S3C2410_PA_UART,
647 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
648 .boot_params = S3C2410_SDRAM_PA + 0x100,
650 .init_irq = s3c24xx_init_irq,
651 .map_io = jive_map_io,
652 .init_machine = jive_machine_init,
653 .timer = &s3c24xx_timer,