1
2
3
4
5
6
7
8
9
10
11#include <linux/kernel.h>
12#include <linux/types.h>
13#include <linux/interrupt.h>
14#include <linux/list.h>
15#include <linux/timer.h>
16#include <linux/init.h>
17#include <linux/gpio.h>
18#include <linux/input.h>
19#include <linux/io.h>
20#include <linux/serial_core.h>
21#include <linux/serial_s3c.h>
22#include <linux/dm9000.h>
23#include <linux/property.h>
24#include <linux/platform_device.h>
25#include <linux/gpio_keys.h>
26#include <linux/i2c.h>
27#include <linux/mmc/host.h>
28
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31
32#include <mach/hardware.h>
33#include <mach/fb.h>
34#include <asm/mach-types.h>
35
36#include <mach/regs-gpio.h>
37#include <linux/platform_data/leds-s3c24xx.h>
38#include <mach/regs-lcd.h>
39#include <mach/irqs.h>
40#include <mach/gpio-samsung.h>
41#include <linux/platform_data/mtd-nand-s3c2410.h>
42#include <linux/platform_data/i2c-s3c2410.h>
43#include <linux/platform_data/mmc-s3cmci.h>
44#include <linux/platform_data/usb-s3c2410_udc.h>
45
46#include <linux/mtd/mtd.h>
47#include <linux/mtd/rawnand.h>
48#include <linux/mtd/nand_ecc.h>
49#include <linux/mtd/partitions.h>
50
51#include <plat/gpio-cfg.h>
52#include <plat/devs.h>
53#include <plat/cpu.h>
54#include <plat/samsung-time.h>
55
56#include <sound/s3c24xx_uda134x.h>
57
58#include "common.h"
59
60#define MACH_MINI2440_DM9K_BASE (S3C2410_CS4 + 0x300)
61
62static struct map_desc mini2440_iodesc[] __initdata = {
63
64};
65
66#define UCON S3C2410_UCON_DEFAULT
67#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
68#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
69
70
71static struct s3c2410_uartcfg mini2440_uartcfgs[] __initdata = {
72 [0] = {
73 .hwport = 0,
74 .flags = 0,
75 .ucon = UCON,
76 .ulcon = ULCON,
77 .ufcon = UFCON,
78 },
79 [1] = {
80 .hwport = 1,
81 .flags = 0,
82 .ucon = UCON,
83 .ulcon = ULCON,
84 .ufcon = UFCON,
85 },
86 [2] = {
87 .hwport = 2,
88 .flags = 0,
89 .ucon = UCON,
90 .ulcon = ULCON,
91 .ufcon = UFCON,
92 },
93};
94
95
96
97static struct s3c2410_udc_mach_info mini2440_udc_cfg __initdata = {
98 .pullup_pin = S3C2410_GPC(5),
99};
100
101
102
103
104
105
106
107#define _LCD_DECLARE(_clock,_xres,margin_left,margin_right,hsync, \
108 _yres,margin_top,margin_bottom,vsync, refresh) \
109 .width = _xres, \
110 .xres = _xres, \
111 .height = _yres, \
112 .yres = _yres, \
113 .left_margin = margin_left, \
114 .right_margin = margin_right, \
115 .upper_margin = margin_top, \
116 .lower_margin = margin_bottom, \
117 .hsync_len = hsync, \
118 .vsync_len = vsync, \
119 .pixclock = ((_clock*100000000000LL) / \
120 ((refresh) * \
121 (hsync + margin_left + _xres + margin_right) * \
122 (vsync + margin_top + _yres + margin_bottom))), \
123 .bpp = 16,\
124 .type = (S3C2410_LCDCON1_TFT16BPP |\
125 S3C2410_LCDCON1_TFT)
126
127static struct s3c2410fb_display mini2440_lcd_cfg[] __initdata = {
128 [0] = {
129 _LCD_DECLARE(
130 7,
131 240, 21, 38, 6,
132 320, 4, 4, 2,
133 60),
134 .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
135 S3C2410_LCDCON5_INVVLINE |
136 S3C2410_LCDCON5_INVVFRAME |
137 S3C2410_LCDCON5_INVVDEN |
138 S3C2410_LCDCON5_PWREN),
139 },
140 [1] = {
141 _LCD_DECLARE(
142 10,
143 800, 40, 40, 48,
144 480, 29, 3, 3,
145 50),
146 .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
147 S3C2410_LCDCON5_INVVLINE |
148 S3C2410_LCDCON5_INVVFRAME |
149 S3C2410_LCDCON5_PWREN),
150 },
151
152
153
154
155
156
157 [2] = {
158 _LCD_DECLARE(
159 10,
160 1024, 1, 2, 2,
161 768, 200, 16, 16,
162 24),
163
164 .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
165 S3C2410_LCDCON5_HWSWP),
166 },
167
168 [3] = {
169 _LCD_DECLARE(
170
171 7,
172
173 320, 68, 66, 4,
174
175 240, 4, 4, 9,
176
177 60),
178 .lcdcon5 = (S3C2410_LCDCON5_FRM565 |
179 S3C2410_LCDCON5_INVVDEN |
180 S3C2410_LCDCON5_INVVFRAME |
181 S3C2410_LCDCON5_INVVLINE |
182 S3C2410_LCDCON5_INVVCLK |
183 S3C2410_LCDCON5_HWSWP),
184 },
185};
186
187
188
189#define S3C2410_GPCCON_MASK(x) (3 << ((x) * 2))
190#define S3C2410_GPDCON_MASK(x) (3 << ((x) * 2))
191
192static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
193 .displays = &mini2440_lcd_cfg[0],
194 .num_displays = 1,
195 .default_display = 0,
196
197
198
199
200
201 .gpcup = (0xf << 1) | (0x3f << 10),
202
203 .gpccon = (S3C2410_GPC1_VCLK | S3C2410_GPC2_VLINE |
204 S3C2410_GPC3_VFRAME | S3C2410_GPC4_VM |
205 S3C2410_GPC10_VD2 | S3C2410_GPC11_VD3 |
206 S3C2410_GPC12_VD4 | S3C2410_GPC13_VD5 |
207 S3C2410_GPC14_VD6 | S3C2410_GPC15_VD7),
208
209 .gpccon_mask = (S3C2410_GPCCON_MASK(1) | S3C2410_GPCCON_MASK(2) |
210 S3C2410_GPCCON_MASK(3) | S3C2410_GPCCON_MASK(4) |
211 S3C2410_GPCCON_MASK(10) | S3C2410_GPCCON_MASK(11) |
212 S3C2410_GPCCON_MASK(12) | S3C2410_GPCCON_MASK(13) |
213 S3C2410_GPCCON_MASK(14) | S3C2410_GPCCON_MASK(15)),
214
215 .gpdup = (0x3f << 2) | (0x3f << 10),
216
217 .gpdcon = (S3C2410_GPD2_VD10 | S3C2410_GPD3_VD11 |
218 S3C2410_GPD4_VD12 | S3C2410_GPD5_VD13 |
219 S3C2410_GPD6_VD14 | S3C2410_GPD7_VD15 |
220 S3C2410_GPD10_VD18 | S3C2410_GPD11_VD19 |
221 S3C2410_GPD12_VD20 | S3C2410_GPD13_VD21 |
222 S3C2410_GPD14_VD22 | S3C2410_GPD15_VD23),
223
224 .gpdcon_mask = (S3C2410_GPDCON_MASK(2) | S3C2410_GPDCON_MASK(3) |
225 S3C2410_GPDCON_MASK(4) | S3C2410_GPDCON_MASK(5) |
226 S3C2410_GPDCON_MASK(6) | S3C2410_GPDCON_MASK(7) |
227 S3C2410_GPDCON_MASK(10) | S3C2410_GPDCON_MASK(11)|
228 S3C2410_GPDCON_MASK(12) | S3C2410_GPDCON_MASK(13)|
229 S3C2410_GPDCON_MASK(14) | S3C2410_GPDCON_MASK(15)),
230};
231
232
233
234static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = {
235 .gpio_detect = S3C2410_GPG(8),
236 .gpio_wprotect = S3C2410_GPH(8),
237 .set_power = NULL,
238 .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
239};
240
241
242
243static struct mtd_partition mini2440_default_nand_part[] __initdata = {
244 [0] = {
245 .name = "u-boot",
246 .size = SZ_256K,
247 .offset = 0,
248 },
249 [1] = {
250 .name = "u-boot-env",
251 .size = SZ_128K,
252 .offset = SZ_256K,
253 },
254 [2] = {
255 .name = "kernel",
256
257
258 .size = 0x00500000,
259 .offset = SZ_256K + SZ_128K,
260 },
261 [3] = {
262 .name = "root",
263 .offset = SZ_256K + SZ_128K + 0x00500000,
264 .size = MTDPART_SIZ_FULL,
265 },
266};
267
268static struct s3c2410_nand_set mini2440_nand_sets[] __initdata = {
269 [0] = {
270 .name = "nand",
271 .nr_chips = 1,
272 .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part),
273 .partitions = mini2440_default_nand_part,
274 .flash_bbt = 1,
275 },
276};
277
278static struct s3c2410_platform_nand mini2440_nand_info __initdata = {
279 .tacls = 0,
280 .twrph0 = 25,
281 .twrph1 = 15,
282 .nr_sets = ARRAY_SIZE(mini2440_nand_sets),
283 .sets = mini2440_nand_sets,
284 .ignore_unset_ecc = 1,
285 .ecc_mode = NAND_ECC_HW,
286};
287
288
289
290static struct resource mini2440_dm9k_resource[] = {
291 [0] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE, 4),
292 [1] = DEFINE_RES_MEM(MACH_MINI2440_DM9K_BASE + 4, 4),
293 [2] = DEFINE_RES_NAMED(IRQ_EINT7, 1, NULL, IORESOURCE_IRQ \
294 | IORESOURCE_IRQ_HIGHEDGE),
295};
296
297
298
299
300
301static struct dm9000_plat_data mini2440_dm9k_pdata = {
302 .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
303};
304
305static struct platform_device mini2440_device_eth = {
306 .name = "dm9000",
307 .id = -1,
308 .num_resources = ARRAY_SIZE(mini2440_dm9k_resource),
309 .resource = mini2440_dm9k_resource,
310 .dev = {
311 .platform_data = &mini2440_dm9k_pdata,
312 },
313};
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332static struct gpio_keys_button mini2440_buttons[] = {
333 {
334 .gpio = S3C2410_GPG(0),
335 .code = KEY_F1,
336 .desc = "Button 1",
337 .active_low = 1,
338 },
339 {
340 .gpio = S3C2410_GPG(3),
341 .code = KEY_F2,
342 .desc = "Button 2",
343 .active_low = 1,
344 },
345 {
346 .gpio = S3C2410_GPG(5),
347 .code = KEY_F3,
348 .desc = "Button 3",
349 .active_low = 1,
350 },
351 {
352 .gpio = S3C2410_GPG(6),
353 .code = KEY_POWER,
354 .desc = "Power",
355 .active_low = 1,
356 },
357 {
358 .gpio = S3C2410_GPG(7),
359 .code = KEY_F5,
360 .desc = "Button 5",
361 .active_low = 1,
362 },
363#if 0
364
365
366 {
367 .gpio = S3C2410_GPG(11),
368 .code = KEY_F6,
369 .desc = "Button 6",
370 .active_low = 1,
371 },
372#endif
373};
374
375static struct gpio_keys_platform_data mini2440_button_data = {
376 .buttons = mini2440_buttons,
377 .nbuttons = ARRAY_SIZE(mini2440_buttons),
378};
379
380static struct platform_device mini2440_button_device = {
381 .name = "gpio-keys",
382 .id = -1,
383 .dev = {
384 .platform_data = &mini2440_button_data,
385 }
386};
387
388
389
390static struct s3c24xx_led_platdata mini2440_led1_pdata = {
391 .name = "led1",
392 .gpio = S3C2410_GPB(5),
393 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
394 .def_trigger = "heartbeat",
395};
396
397static struct s3c24xx_led_platdata mini2440_led2_pdata = {
398 .name = "led2",
399 .gpio = S3C2410_GPB(6),
400 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
401 .def_trigger = "nand-disk",
402};
403
404static struct s3c24xx_led_platdata mini2440_led3_pdata = {
405 .name = "led3",
406 .gpio = S3C2410_GPB(7),
407 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
408 .def_trigger = "mmc0",
409};
410
411static struct s3c24xx_led_platdata mini2440_led4_pdata = {
412 .name = "led4",
413 .gpio = S3C2410_GPB(8),
414 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
415 .def_trigger = "",
416};
417
418static struct s3c24xx_led_platdata mini2440_led_backlight_pdata = {
419 .name = "backlight",
420 .gpio = S3C2410_GPG(4),
421 .def_trigger = "backlight",
422};
423
424static struct platform_device mini2440_led1 = {
425 .name = "s3c24xx_led",
426 .id = 1,
427 .dev = {
428 .platform_data = &mini2440_led1_pdata,
429 },
430};
431
432static struct platform_device mini2440_led2 = {
433 .name = "s3c24xx_led",
434 .id = 2,
435 .dev = {
436 .platform_data = &mini2440_led2_pdata,
437 },
438};
439
440static struct platform_device mini2440_led3 = {
441 .name = "s3c24xx_led",
442 .id = 3,
443 .dev = {
444 .platform_data = &mini2440_led3_pdata,
445 },
446};
447
448static struct platform_device mini2440_led4 = {
449 .name = "s3c24xx_led",
450 .id = 4,
451 .dev = {
452 .platform_data = &mini2440_led4_pdata,
453 },
454};
455
456static struct platform_device mini2440_led_backlight = {
457 .name = "s3c24xx_led",
458 .id = 5,
459 .dev = {
460 .platform_data = &mini2440_led_backlight_pdata,
461 },
462};
463
464
465
466static struct s3c24xx_uda134x_platform_data mini2440_audio_pins = {
467 .l3_clk = S3C2410_GPB(4),
468 .l3_mode = S3C2410_GPB(2),
469 .l3_data = S3C2410_GPB(3),
470 .model = UDA134X_UDA1341
471};
472
473static struct platform_device mini2440_audio = {
474 .name = "s3c24xx_uda134x",
475 .id = 0,
476 .dev = {
477 .platform_data = &mini2440_audio_pins,
478 },
479};
480
481
482
483
484static const struct property_entry mini2440_at24_properties[] = {
485 PROPERTY_ENTRY_U32("pagesize", 16),
486 { }
487};
488
489static struct i2c_board_info mini2440_i2c_devs[] __initdata = {
490 {
491 I2C_BOARD_INFO("24c08", 0x50),
492 .properties = mini2440_at24_properties,
493 },
494};
495
496static struct uda134x_platform_data s3c24xx_uda134x = {
497 .l3 = {
498 .gpio_clk = S3C2410_GPB(4),
499 .gpio_data = S3C2410_GPB(3),
500 .gpio_mode = S3C2410_GPB(2),
501 .use_gpios = 1,
502 .data_hold = 1,
503 .data_setup = 1,
504 .clock_high = 1,
505 .mode_hold = 1,
506 .mode = 1,
507 .mode_setup = 1,
508 },
509 .model = UDA134X_UDA1341,
510};
511
512static struct platform_device uda1340_codec = {
513 .name = "uda134x-codec",
514 .id = -1,
515 .dev = {
516 .platform_data = &s3c24xx_uda134x,
517 },
518};
519
520static struct platform_device *mini2440_devices[] __initdata = {
521 &s3c_device_ohci,
522 &s3c_device_wdt,
523 &s3c_device_i2c0,
524 &s3c_device_rtc,
525 &s3c_device_usbgadget,
526 &mini2440_device_eth,
527 &mini2440_led1,
528 &mini2440_led2,
529 &mini2440_led3,
530 &mini2440_led4,
531 &mini2440_button_device,
532 &s3c_device_nand,
533 &s3c_device_sdi,
534 &s3c2440_device_dma,
535 &s3c_device_iis,
536 &uda1340_codec,
537 &mini2440_audio,
538};
539
540static void __init mini2440_map_io(void)
541{
542 s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));
543 s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));
544 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
545}
546
547static void __init mini2440_init_time(void)
548{
549 s3c2440_init_clocks(12000000);
550 samsung_timer_init();
551}
552
553
554
555
556
557
558
559
560
561
562static char mini2440_features_str[12] __initdata = "0tb";
563
564static int __init mini2440_features_setup(char *str)
565{
566 if (str)
567 strlcpy(mini2440_features_str, str, sizeof(mini2440_features_str));
568 return 1;
569}
570
571__setup("mini2440=", mini2440_features_setup);
572
573#define FEATURE_SCREEN (1 << 0)
574#define FEATURE_BACKLIGHT (1 << 1)
575#define FEATURE_TOUCH (1 << 2)
576#define FEATURE_CAMERA (1 << 3)
577
578struct mini2440_features_t {
579 int count;
580 int done;
581 int lcd_index;
582 struct platform_device *optional[8];
583};
584
585static void __init mini2440_parse_features(
586 struct mini2440_features_t * features,
587 const char * features_str )
588{
589 const char * fp = features_str;
590
591 features->count = 0;
592 features->done = 0;
593 features->lcd_index = -1;
594
595 while (*fp) {
596 char f = *fp++;
597
598 switch (f) {
599 case '0'...'9':
600 if (features->done & FEATURE_SCREEN) {
601 printk(KERN_INFO "MINI2440: '%c' ignored, "
602 "screen type already set\n", f);
603 } else {
604 int li = f - '0';
605 if (li >= ARRAY_SIZE(mini2440_lcd_cfg))
606 printk(KERN_INFO "MINI2440: "
607 "'%c' out of range LCD mode\n", f);
608 else {
609 features->optional[features->count++] =
610 &s3c_device_lcd;
611 features->lcd_index = li;
612 }
613 }
614 features->done |= FEATURE_SCREEN;
615 break;
616 case 'b':
617 if (features->done & FEATURE_BACKLIGHT)
618 printk(KERN_INFO "MINI2440: '%c' ignored, "
619 "backlight already set\n", f);
620 else {
621 features->optional[features->count++] =
622 &mini2440_led_backlight;
623 }
624 features->done |= FEATURE_BACKLIGHT;
625 break;
626 case 't':
627 printk(KERN_INFO "MINI2440: '%c' ignored, "
628 "touchscreen not compiled in\n", f);
629 break;
630 case 'c':
631 if (features->done & FEATURE_CAMERA)
632 printk(KERN_INFO "MINI2440: '%c' ignored, "
633 "camera already registered\n", f);
634 else
635 features->optional[features->count++] =
636 &s3c_device_camif;
637 features->done |= FEATURE_CAMERA;
638 break;
639 }
640 }
641}
642
643static void __init mini2440_init(void)
644{
645 struct mini2440_features_t features = { 0 };
646 int i;
647
648 printk(KERN_INFO "MINI2440: Option string mini2440=%s\n",
649 mini2440_features_str);
650
651
652 mini2440_parse_features(&features, mini2440_features_str);
653
654
655 s3c_gpio_cfgpin(S3C2410_GPC(0), S3C2410_GPC0_LEND);
656
657
658 WARN_ON(gpio_request_one(S3C2410_GPG(4), GPIOF_OUT_INIT_HIGH, NULL));
659 gpio_free(S3C2410_GPG(4));
660
661
662 gpio_request_one(S3C2410_GPB(1), GPIOF_IN, NULL);
663 s3c_gpio_setpull(S3C2410_GPB(1), S3C_GPIO_PULL_UP);
664 gpio_free(S3C2410_GPB(1));
665
666
667 for (i = 0; i < ARRAY_SIZE(mini2440_buttons); i++) {
668 s3c_gpio_setpull(mini2440_buttons[i].gpio, S3C_GPIO_PULL_UP);
669 s3c_gpio_cfgpin(mini2440_buttons[i].gpio, S3C2410_GPIO_INPUT);
670 }
671 if (features.lcd_index != -1) {
672 int li;
673
674 mini2440_fb_info.displays =
675 &mini2440_lcd_cfg[features.lcd_index];
676
677 printk(KERN_INFO "MINI2440: LCD");
678 for (li = 0; li < ARRAY_SIZE(mini2440_lcd_cfg); li++)
679 if (li == features.lcd_index)
680 printk(" [%d:%dx%d]", li,
681 mini2440_lcd_cfg[li].width,
682 mini2440_lcd_cfg[li].height);
683 else
684 printk(" %d:%dx%d", li,
685 mini2440_lcd_cfg[li].width,
686 mini2440_lcd_cfg[li].height);
687 printk("\n");
688 s3c24xx_fb_set_platdata(&mini2440_fb_info);
689 }
690
691 s3c24xx_udc_set_platdata(&mini2440_udc_cfg);
692 s3c24xx_mci_set_platdata(&mini2440_mmc_cfg);
693 s3c_nand_set_platdata(&mini2440_nand_info);
694 s3c_i2c0_set_platdata(NULL);
695
696 i2c_register_board_info(0, mini2440_i2c_devs,
697 ARRAY_SIZE(mini2440_i2c_devs));
698
699 platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
700
701 if (features.count)
702 platform_add_devices(features.optional, features.count);
703
704}
705
706
707MACHINE_START(MINI2440, "MINI2440")
708
709 .atag_offset = 0x100,
710 .map_io = mini2440_map_io,
711 .init_machine = mini2440_init,
712 .init_irq = s3c2440_init_irq,
713 .init_time = mini2440_init_time,
714MACHINE_END
715