1 /* linux/arch/arm/mach-s3c2440/mach-mini2440.c
3 * Copyright (c) 2008 Ramax Lo <ramaxlo@gmail.com>
4 * Based on mach-anubis.c by Ben Dooks <ben@simtec.co.uk>
5 * and modifications by SBZ <sbz@spgui.org> and
6 * Weibing <http://weibing.blogbus.com> and
7 * Michel Pollet <buserror@gmail.com>
9 * For product information, visit http://code.google.com/p/mini2440/
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/kernel.h>
17 #include <linux/types.h>
18 #include <linux/interrupt.h>
19 #include <linux/list.h>
20 #include <linux/timer.h>
21 #include <linux/init.h>
22 #include <linux/gpio.h>
23 #include <linux/input.h>
25 #include <linux/serial_core.h>
26 #include <linux/dm9000.h>
27 #include <linux/i2c/at24.h>
28 #include <linux/platform_device.h>
29 #include <linux/gpio_keys.h>
30 #include <linux/i2c.h>
31 #include <linux/mmc/host.h>
33 #include <asm/mach/arch.h>
34 #include <asm/mach/map.h>
36 #include <mach/hardware.h>
38 #include <asm/mach-types.h>
40 #include <plat/regs-serial.h>
41 #include <mach/regs-gpio.h>
42 #include <mach/leds-gpio.h>
43 #include <mach/regs-mem.h>
44 #include <mach/regs-lcd.h>
45 #include <mach/irqs.h>
46 #include <plat/nand.h>
51 #include <linux/mtd/mtd.h>
52 #include <linux/mtd/nand.h>
53 #include <linux/mtd/nand_ecc.h>
54 #include <linux/mtd/partitions.h>
56 #include <plat/clock.h>
57 #include <plat/devs.h>
60 #include <sound/s3c24xx_uda134x.h>
62 #define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
64 static struct map_desc mini2440_iodesc
[] __initdata
= {
65 /* nothing to declare, move along */
68 #define UCON S3C2410_UCON_DEFAULT
69 #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
70 #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
73 static struct s3c2410_uartcfg mini2440_uartcfgs
[] __initdata
= {
97 /* USB device UDC support */
99 static void mini2440_udc_pullup(enum s3c2410_udc_cmd_e cmd
)
101 pr_debug("udc: pullup(%d)\n", cmd
);
104 case S3C2410_UDC_P_ENABLE
:
105 s3c2410_gpio_setpin(S3C2410_GPC(5), 1);
107 case S3C2410_UDC_P_DISABLE
:
108 s3c2410_gpio_setpin(S3C2410_GPC(5), 0);
110 case S3C2410_UDC_P_RESET
:
117 static struct s3c2410_udc_mach_info mini2440_udc_cfg __initdata
= {
118 .udc_command
= mini2440_udc_pullup
,
122 /* LCD timing and setup */
125 * This macro simplifies the table bellow
127 #define _LCD_DECLARE(_clock,_xres,margin_left,margin_right,hsync, \
128 _yres,margin_top,margin_bottom,vsync, refresh) \
133 .left_margin = margin_left, \
134 .right_margin = margin_right, \
135 .upper_margin = margin_top, \
136 .lower_margin = margin_bottom, \
137 .hsync_len = hsync, \
138 .vsync_len = vsync, \
139 .pixclock = ((_clock*100000000000LL) / \
141 (hsync + margin_left + _xres + margin_right) * \
142 (vsync + margin_top + _yres + margin_bottom))), \
144 .type = (S3C2410_LCDCON1_TFT16BPP |\
147 static struct s3c2410fb_display mini2440_lcd_cfg
[] __initdata
= {
148 [0] = { /* mini2440 + 3.5" TFT + touchscreen - old model "N35" */
150 7, /* The 3.5 is quite fast */
151 240, 21, 38, 6, /* x timing */
152 320, 4, 4, 2, /* y timing */
153 60), /* refresh rate */
154 .lcdcon5
= (S3C2410_LCDCON5_FRM565
|
155 S3C2410_LCDCON5_INVVLINE
|
156 S3C2410_LCDCON5_INVVFRAME
|
157 S3C2410_LCDCON5_INVVDEN
|
158 S3C2410_LCDCON5_PWREN
),
160 [1] = { /* mini2440 + 7" TFT + touchscreen */
162 10, /* the 7" runs slower */
163 800, 40, 40, 48, /* x timing */
164 480, 29, 3, 3, /* y timing */
165 50), /* refresh rate */
166 .lcdcon5
= (S3C2410_LCDCON5_FRM565
|
167 S3C2410_LCDCON5_INVVLINE
|
168 S3C2410_LCDCON5_INVVFRAME
|
169 S3C2410_LCDCON5_PWREN
),
171 /* The VGA shield can outout at several resolutions. All share
172 * the same timings, however, anything smaller than 1024x768
173 * will only be displayed in the top left corner of a 1024x768
174 * XGA output unless you add optional dip switches to the shield.
175 * Therefore timings for other resolutions have been ommited here.
180 1024, 1, 2, 2, /* y timing */
181 768, 200, 16, 16, /* x timing */
182 24), /* refresh rate, maximum stable,
183 tested with the FPGA shield */
184 .lcdcon5
= (S3C2410_LCDCON5_FRM565
|
185 S3C2410_LCDCON5_HWSWP
),
188 [3] = { /* mini2440 + 3.5" TFT + TS -- New model as Nov 2009 "T35" */
190 7, /* The 3.5 is quite fast */
191 240, 21, 25, 6, /* x timing */
192 320, 2, 4, 2, /* y timing */
193 40), /* refresh rate */
194 .lcdcon5
= (S3C2410_LCDCON5_FRM565
|
195 S3C2410_LCDCON5_INVVLINE
|
196 S3C2410_LCDCON5_INVVFRAME
|
197 S3C2410_LCDCON5_INVVDEN
|
198 S3C2410_LCDCON5_PWREN
),
200 [4] = { /* mini2440 + 5.6" TFT + touchscreen -- Innolux AT056TN52 */
201 /* be sure the "power" jumper is set accordingly ! */
203 10, /* the 5.3" runs slower */
204 640, 41, 68, 22, /* x timing */
205 480, 26, 6, 2, /* y timing */
206 40), /* refresh rate */
207 .lcdcon5
= (S3C2410_LCDCON5_FRM565
|
208 S3C2410_LCDCON5_INVVLINE
|
209 S3C2410_LCDCON5_INVVFRAME
|
210 S3C2410_LCDCON5_PWREN
),
214 /* todo - put into gpio header */
216 #define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2))
217 #define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2))
219 static struct s3c2410fb_mach_info mini2440_fb_info __initdata
= {
220 .displays
= &mini2440_lcd_cfg
[0], /* not constant! see init */
222 .default_display
= 0,
224 /* Enable VD[2..7], VD[10..15], VD[18..23] and VCLK, syncs, VDEN
225 * and disable the pull down resistors on pins we are using for LCD
228 .gpcup
= (0xf << 1) | (0x3f << 10),
230 .gpccon
= (S3C2410_GPC1_VCLK
| S3C2410_GPC2_VLINE
|
231 S3C2410_GPC3_VFRAME
| S3C2410_GPC4_VM
|
232 S3C2410_GPC10_VD2
| S3C2410_GPC11_VD3
|
233 S3C2410_GPC12_VD4
| S3C2410_GPC13_VD5
|
234 S3C2410_GPC14_VD6
| S3C2410_GPC15_VD7
),
236 .gpccon_mask
= (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) |
237 S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) |
238 S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) |
239 S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) |
240 S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)),
242 .gpdup
= (0x3f << 2) | (0x3f << 10),
244 .gpdcon
= (S3C2410_GPD2_VD10
| S3C2410_GPD3_VD11
|
245 S3C2410_GPD4_VD12
| S3C2410_GPD5_VD13
|
246 S3C2410_GPD6_VD14
| S3C2410_GPD7_VD15
|
247 S3C2410_GPD10_VD18
| S3C2410_GPD11_VD19
|
248 S3C2410_GPD12_VD20
| S3C2410_GPD13_VD21
|
249 S3C2410_GPD14_VD22
| S3C2410_GPD15_VD23
),
251 .gpdcon_mask
= (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) |
252 S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) |
253 S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) |
254 S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)|
255 S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)|
256 S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)),
261 static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata
= {
262 .gpio_detect
= S3C2410_GPG(8),
263 .gpio_wprotect
= S3C2410_GPH(8),
265 .ocr_avail
= MMC_VDD_32_33
|MMC_VDD_33_34
,
268 /* NAND Flash on MINI2440 board */
270 static struct mtd_partition mini2440_default_nand_part
[] __initdata
= {
277 .name
= "u-boot-env",
283 /* 5 megabytes, for a kernel with no modules
284 * or a uImage with a ramdisk attached */
286 .offset
= SZ_256K
+ SZ_128K
,
290 .offset
= SZ_256K
+ SZ_128K
+ 0x00500000,
291 .size
= MTDPART_SIZ_FULL
,
295 static struct s3c2410_nand_set mini2440_nand_sets
[] __initdata
= {
299 .nr_partitions
= ARRAY_SIZE(mini2440_default_nand_part
),
300 .partitions
= mini2440_default_nand_part
,
301 .flash_bbt
= 1, /* we use u-boot to create a BBT */
305 static struct s3c2410_platform_nand mini2440_nand_info __initdata
= {
309 .nr_sets
= ARRAY_SIZE(mini2440_nand_sets
),
310 .sets
= mini2440_nand_sets
,
311 .ignore_unset_ecc
= 1,
314 /* DM9000AEP 10/100 ethernet controller */
316 static struct resource mini2440_dm9k_resource
[] __initdata
= {
318 .start
= MACH_MINI2440_DM9K_BASE
,
319 .end
= MACH_MINI2440_DM9K_BASE
+ 3,
320 .flags
= IORESOURCE_MEM
323 .start
= MACH_MINI2440_DM9K_BASE
+ 4,
324 .end
= MACH_MINI2440_DM9K_BASE
+ 7,
325 .flags
= IORESOURCE_MEM
330 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
335 * The DM9000 has no eeprom, and it's MAC address is set by
336 * the bootloader before starting the kernel.
338 static struct dm9000_plat_data mini2440_dm9k_pdata __initdata
= {
339 .flags
= (DM9000_PLATF_16BITONLY
| DM9000_PLATF_NO_EEPROM
),
342 static struct platform_device mini2440_device_eth __initdata
= {
345 .num_resources
= ARRAY_SIZE(mini2440_dm9k_resource
),
346 .resource
= mini2440_dm9k_resource
,
348 .platform_data
= &mini2440_dm9k_pdata
,
369 static struct gpio_keys_button mini2440_buttons
[] __initdata
= {
371 .gpio
= S3C2410_GPG(0), /* K1 */
377 .gpio
= S3C2410_GPG(3), /* K2 */
383 .gpio
= S3C2410_GPG(5), /* K3 */
389 .gpio
= S3C2410_GPG(6), /* K4 */
395 .gpio
= S3C2410_GPG(7), /* K5 */
401 /* this pin is also known as TCLK1 and seems to already
402 * marked as "in use" somehow in the kernel -- possibly wrongly */
404 .gpio
= S3C2410_GPG(11), /* K6 */
412 static struct gpio_keys_platform_data mini2440_button_data __initdata
= {
413 .buttons
= mini2440_buttons
,
414 .nbuttons
= ARRAY_SIZE(mini2440_buttons
),
417 static struct platform_device mini2440_button_device __initdata
= {
421 .platform_data
= &mini2440_button_data
,
427 static struct s3c24xx_led_platdata mini2440_led1_pdata __initdata
= {
429 .gpio
= S3C2410_GPB(5),
430 .flags
= S3C24XX_LEDF_ACTLOW
| S3C24XX_LEDF_TRISTATE
,
431 .def_trigger
= "heartbeat",
434 static struct s3c24xx_led_platdata mini2440_led2_pdata __initdata
= {
436 .gpio
= S3C2410_GPB(6),
437 .flags
= S3C24XX_LEDF_ACTLOW
| S3C24XX_LEDF_TRISTATE
,
438 .def_trigger
= "nand-disk",
441 static struct s3c24xx_led_platdata mini2440_led3_pdata __initdata
= {
443 .gpio
= S3C2410_GPB(7),
444 .flags
= S3C24XX_LEDF_ACTLOW
| S3C24XX_LEDF_TRISTATE
,
445 .def_trigger
= "mmc0",
448 static struct s3c24xx_led_platdata mini2440_led4_pdata __initdata
= {
450 .gpio
= S3C2410_GPB(8),
451 .flags
= S3C24XX_LEDF_ACTLOW
| S3C24XX_LEDF_TRISTATE
,
455 static struct s3c24xx_led_platdata mini2440_led_backlight_pdata __initdata
= {
457 .gpio
= S3C2410_GPG(4),
458 .flags
= S3C24XX_LEDF_STARTON
,
459 .def_trigger
= "backlight",
462 static struct platform_device mini2440_led1 __initdata
= {
463 .name
= "s3c24xx_led",
466 .platform_data
= &mini2440_led1_pdata
,
470 static struct platform_device mini2440_led2 __initdata
= {
471 .name
= "s3c24xx_led",
474 .platform_data
= &mini2440_led2_pdata
,
478 static struct platform_device mini2440_led3 __initdata
= {
479 .name
= "s3c24xx_led",
482 .platform_data
= &mini2440_led3_pdata
,
486 static struct platform_device mini2440_led4 __initdata
= {
487 .name
= "s3c24xx_led",
490 .platform_data
= &mini2440_led4_pdata
,
494 static struct platform_device mini2440_led_backlight __initdata
= {
495 .name
= "s3c24xx_led",
498 .platform_data
= &mini2440_led_backlight_pdata
,
504 static struct s3c24xx_uda134x_platform_data mini2440_audio_pins __initdata
= {
505 .l3_clk
= S3C2410_GPB(4),
506 .l3_mode
= S3C2410_GPB(2),
507 .l3_data
= S3C2410_GPB(3),
508 .model
= UDA134X_UDA1341
511 static struct platform_device mini2440_audio __initdata
= {
512 .name
= "s3c24xx_uda134x",
515 .platform_data
= &mini2440_audio_pins
,
522 static struct at24_platform_data at24c08
= {
523 .byte_len
= SZ_8K
/ 8,
527 static struct i2c_board_info mini2440_i2c_devs
[] __initdata
= {
529 I2C_BOARD_INFO("24c08", 0x50),
530 .platform_data
= &at24c08
,
534 static struct platform_device
*mini2440_devices
[] __initdata
= {
537 /* &s3c_device_adc,*/ /* ADC doesn't like living with touchscreen ! */
540 &s3c_device_usbgadget
,
541 &mini2440_device_eth
,
546 &mini2440_button_device
,
551 /* &s3c_device_timer[0],*/ /* buzzer pwm, no API for it */
552 /* remaining devices are optional */
555 static void __init
mini2440_map_io(void)
557 s3c24xx_init_io(mini2440_iodesc
, ARRAY_SIZE(mini2440_iodesc
));
558 s3c24xx_init_clocks(12000000);
559 s3c24xx_init_uarts(mini2440_uartcfgs
, ARRAY_SIZE(mini2440_uartcfgs
));
561 s3c_device_nand
.dev
.platform_data
= &mini2440_nand_info
;
562 s3c_device_sdi
.dev
.platform_data
= &mini2440_mmc_cfg
;
566 * mini2440_features string
568 * t = Touchscreen present
569 * b = backlight control
571 * 0-9 LCD configuration
574 static char mini2440_features_str
[12] __initdata
= "0tb";
576 static int __init
mini2440_features_setup(char *str
)
579 strlcpy(mini2440_features_str
, str
, sizeof(mini2440_features_str
));
583 __setup("mini2440=", mini2440_features_setup
);
585 #define FEATURE_SCREEN (1 << 0)
586 #define FEATURE_BACKLIGHT (1 << 1)
587 #define FEATURE_TOUCH (1 << 2)
588 #define FEATURE_CAMERA (1 << 3)
590 struct mini2440_features_t
{
594 struct platform_device
*optional
[8];
597 static void mini2440_parse_features(
598 struct mini2440_features_t
* features
,
599 const char * features_str
)
601 const char * fp
= features_str
;
605 features
->lcd_index
= -1;
611 case '0'...'9': /* tft screen */
612 if (features
->done
& FEATURE_SCREEN
) {
613 printk(KERN_INFO
"MINI2440: '%c' ignored, "
614 "screen type already set\n", f
);
617 if (li
>= ARRAY_SIZE(mini2440_lcd_cfg
))
618 printk(KERN_INFO
"MINI2440: "
619 "'%c' out of range LCD mode\n", f
);
621 features
->optional
[features
->count
++] =
623 features
->lcd_index
= li
;
626 features
->done
|= FEATURE_SCREEN
;
629 if (features
->done
& FEATURE_BACKLIGHT
)
630 printk(KERN_INFO
"MINI2440: '%c' ignored, "
631 "backlight already set\n", f
);
633 features
->optional
[features
->count
++] =
634 &mini2440_led_backlight
;
636 features
->done
|= FEATURE_BACKLIGHT
;
639 printk(KERN_INFO
"MINI2440: '%c' ignored, "
640 "touchscreen not compiled in\n", f
);
643 if (features
->done
& FEATURE_CAMERA
)
644 printk(KERN_INFO
"MINI2440: '%c' ignored, "
645 "camera already registered\n", f
);
647 features
->optional
[features
->count
++] =
649 features
->done
|= FEATURE_CAMERA
;
655 static void __init
mini2440_init(void)
657 struct mini2440_features_t features
= { 0 };
660 printk(KERN_INFO
"MINI2440: Option string mini2440=%s\n",
661 mini2440_features_str
);
663 /* Parse the feature string */
664 mini2440_parse_features(&features
, mini2440_features_str
);
667 s3c2410_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND
);
669 /* Turn the backlight early on */
670 s3c2410_gpio_setpin(S3C2410_GPG(4), 1);
671 s3c2410_gpio_cfgpin(S3C2410_GPG(4), S3C2410_GPIO_OUTPUT
);
673 /* remove pullup on optional PWM backlight -- unused on 3.5 and 7"s */
674 s3c2410_gpio_pullup(S3C2410_GPB(1), 0);
675 s3c2410_gpio_setpin(S3C2410_GPB(1), 0);
676 s3c2410_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPIO_INPUT
);
678 /* Make sure the D+ pullup pin is output */
679 s3c2410_gpio_cfgpin(S3C2410_GPC(5), S3C2410_GPIO_OUTPUT
);
681 /* mark the key as input, without pullups (there is one on the board) */
682 for (i
= 0; i
< ARRAY_SIZE(mini2440_buttons
); i
++) {
683 s3c2410_gpio_pullup(mini2440_buttons
[i
].gpio
, 0);
684 s3c2410_gpio_cfgpin(mini2440_buttons
[i
].gpio
,
687 if (features
.lcd_index
!= -1) {
690 mini2440_fb_info
.displays
=
691 &mini2440_lcd_cfg
[features
.lcd_index
];
693 printk(KERN_INFO
"MINI2440: LCD");
694 for (li
= 0; li
< ARRAY_SIZE(mini2440_lcd_cfg
); li
++)
695 if (li
== features
.lcd_index
)
696 printk(" [%d:%dx%d]", li
,
697 mini2440_lcd_cfg
[li
].width
,
698 mini2440_lcd_cfg
[li
].height
);
700 printk(" %d:%dx%d", li
,
701 mini2440_lcd_cfg
[li
].width
,
702 mini2440_lcd_cfg
[li
].height
);
704 s3c24xx_fb_set_platdata(&mini2440_fb_info
);
706 s3c24xx_udc_set_platdata(&mini2440_udc_cfg
);
707 s3c_i2c0_set_platdata(NULL
);
708 i2c_register_board_info(0, mini2440_i2c_devs
,
709 ARRAY_SIZE(mini2440_i2c_devs
));
711 platform_add_devices(mini2440_devices
, ARRAY_SIZE(mini2440_devices
));
713 if (features
.count
) /* the optional features */
714 platform_add_devices(features
.optional
, features
.count
);
719 MACHINE_START(MINI2440
, "MINI2440")
720 /* Maintainer: Michel Pollet <buserror@gmail.com> */
721 .phys_io
= S3C2410_PA_UART
,
722 .io_pg_offst
= (((u32
)S3C24XX_VA_UART
) >> 18) & 0xfffc,
723 .boot_params
= S3C2410_SDRAM_PA
+ 0x100,
724 .map_io
= mini2440_map_io
,
725 .init_machine
= mini2440_init
,
726 .init_irq
= s3c24xx_init_irq
,
727 .timer
= &s3c24xx_timer
,