1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16
17#include <linux/gpio_keys.h>
18#include <linux/init.h>
19#include <linux/gpio.h>
20#include <linux/gpio/machine.h>
21#include <linux/input.h>
22#include <linux/interrupt.h>
23#include <linux/platform_device.h>
24#include <linux/serial_core.h>
25#include <linux/serial_s3c.h>
26#include <linux/timer.h>
27#include <linux/io.h>
28#include <linux/mmc/host.h>
29
30#include "hardware-s3c24xx.h"
31#include <asm/irq.h>
32#include <asm/mach-types.h>
33
34#include <linux/platform_data/fb-s3c2410.h>
35#include <linux/platform_data/leds-s3c24xx.h>
36#include "regs-gpio.h"
37#include "gpio-samsung.h"
38#include "gpio-cfg.h"
39
40#include <asm/mach/arch.h>
41#include <asm/mach/irq.h>
42#include <asm/mach/map.h>
43
44#include <linux/platform_data/i2c-s3c2410.h>
45
46#include "cpu.h"
47#include "devs.h"
48#include <linux/platform_data/mmc-s3cmci.h>
49#include <linux/platform_data/usb-s3c2410_udc.h>
50
51#include "s3c24xx.h"
52
53static struct map_desc n30_iodesc[] __initdata = {
54
55};
56
57static struct s3c2410_uartcfg n30_uartcfgs[] = {
58
59 [0] = {
60 .hwport = 0,
61 .flags = 0,
62 .ucon = 0x2c5,
63 .ulcon = 0x03,
64 .ufcon = 0x51,
65 },
66
67 [1] = {
68 .hwport = 1,
69 .flags = 0,
70 .uart_flags = UPF_CONS_FLOW,
71 .ucon = 0x2c5,
72 .ulcon = 0x43,
73 .ufcon = 0x51,
74 },
75
76
77 [2] = {
78 .hwport = 2,
79 .flags = 0,
80 .ucon = 0x2c5,
81 .ulcon = 0x03,
82 .ufcon = 0x51,
83 },
84};
85
86static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
87 .vbus_pin = S3C2410_GPG(1),
88 .vbus_pin_inverted = 0,
89 .pullup_pin = S3C2410_GPB(3),
90};
91
92static struct gpio_keys_button n30_buttons[] = {
93 {
94 .gpio = S3C2410_GPF(0),
95 .code = KEY_POWER,
96 .desc = "Power",
97 .active_low = 0,
98 },
99 {
100 .gpio = S3C2410_GPG(9),
101 .code = KEY_UP,
102 .desc = "Thumbwheel Up",
103 .active_low = 0,
104 },
105 {
106 .gpio = S3C2410_GPG(8),
107 .code = KEY_DOWN,
108 .desc = "Thumbwheel Down",
109 .active_low = 0,
110 },
111 {
112 .gpio = S3C2410_GPG(7),
113 .code = KEY_ENTER,
114 .desc = "Thumbwheel Press",
115 .active_low = 0,
116 },
117 {
118 .gpio = S3C2410_GPF(7),
119 .code = KEY_HOMEPAGE,
120 .desc = "Home",
121 .active_low = 0,
122 },
123 {
124 .gpio = S3C2410_GPF(6),
125 .code = KEY_CALENDAR,
126 .desc = "Calendar",
127 .active_low = 0,
128 },
129 {
130 .gpio = S3C2410_GPF(5),
131 .code = KEY_ADDRESSBOOK,
132 .desc = "Contacts",
133 .active_low = 0,
134 },
135 {
136 .gpio = S3C2410_GPF(4),
137 .code = KEY_MAIL,
138 .desc = "Mail",
139 .active_low = 0,
140 },
141};
142
143static struct gpio_keys_platform_data n30_button_data = {
144 .buttons = n30_buttons,
145 .nbuttons = ARRAY_SIZE(n30_buttons),
146};
147
148static struct platform_device n30_button_device = {
149 .name = "gpio-keys",
150 .id = -1,
151 .dev = {
152 .platform_data = &n30_button_data,
153 }
154};
155
156static struct gpio_keys_button n35_buttons[] = {
157 {
158 .gpio = S3C2410_GPF(0),
159 .code = KEY_POWER,
160 .type = EV_PWR,
161 .desc = "Power",
162 .active_low = 0,
163 .wakeup = 1,
164 },
165 {
166 .gpio = S3C2410_GPG(9),
167 .code = KEY_UP,
168 .desc = "Joystick Up",
169 .active_low = 0,
170 },
171 {
172 .gpio = S3C2410_GPG(8),
173 .code = KEY_DOWN,
174 .desc = "Joystick Down",
175 .active_low = 0,
176 },
177 {
178 .gpio = S3C2410_GPG(6),
179 .code = KEY_DOWN,
180 .desc = "Joystick Left",
181 .active_low = 0,
182 },
183 {
184 .gpio = S3C2410_GPG(5),
185 .code = KEY_DOWN,
186 .desc = "Joystick Right",
187 .active_low = 0,
188 },
189 {
190 .gpio = S3C2410_GPG(7),
191 .code = KEY_ENTER,
192 .desc = "Joystick Press",
193 .active_low = 0,
194 },
195 {
196 .gpio = S3C2410_GPF(7),
197 .code = KEY_HOMEPAGE,
198 .desc = "Home",
199 .active_low = 0,
200 },
201 {
202 .gpio = S3C2410_GPF(6),
203 .code = KEY_CALENDAR,
204 .desc = "Calendar",
205 .active_low = 0,
206 },
207 {
208 .gpio = S3C2410_GPF(5),
209 .code = KEY_ADDRESSBOOK,
210 .desc = "Contacts",
211 .active_low = 0,
212 },
213 {
214 .gpio = S3C2410_GPF(4),
215 .code = KEY_MAIL,
216 .desc = "Mail",
217 .active_low = 0,
218 },
219 {
220 .gpio = S3C2410_GPF(3),
221 .code = SW_RADIO,
222 .desc = "GPS Antenna",
223 .active_low = 0,
224 },
225 {
226 .gpio = S3C2410_GPG(2),
227 .code = SW_HEADPHONE_INSERT,
228 .desc = "Headphone",
229 .active_low = 0,
230 },
231};
232
233static struct gpio_keys_platform_data n35_button_data = {
234 .buttons = n35_buttons,
235 .nbuttons = ARRAY_SIZE(n35_buttons),
236};
237
238static struct platform_device n35_button_device = {
239 .name = "gpio-keys",
240 .id = -1,
241 .num_resources = 0,
242 .dev = {
243 .platform_data = &n35_button_data,
244 }
245};
246
247
248
249static struct gpiod_lookup_table n30_blue_led_gpio_table = {
250 .dev_id = "s3c24xx_led.1",
251 .table = {
252 GPIO_LOOKUP("GPG", 6, NULL, GPIO_ACTIVE_HIGH),
253 { },
254 },
255};
256
257static struct s3c24xx_led_platdata n30_blue_led_pdata = {
258 .name = "blue_led",
259 .def_trigger = "",
260};
261
262
263
264
265static struct gpiod_lookup_table n35_blue_led_gpio_table = {
266 .dev_id = "s3c24xx_led.1",
267 .table = {
268 GPIO_LOOKUP("GPD", 8, NULL, GPIO_ACTIVE_HIGH),
269 { },
270 },
271};
272
273static struct s3c24xx_led_platdata n35_blue_led_pdata = {
274 .name = "blue_led",
275 .def_trigger = "",
276};
277
278
279
280
281
282
283static struct gpiod_lookup_table n30_warning_led_gpio_table = {
284 .dev_id = "s3c24xx_led.2",
285 .table = {
286 GPIO_LOOKUP("GPD", 9, NULL, GPIO_ACTIVE_LOW),
287 { },
288 },
289};
290
291static struct s3c24xx_led_platdata n30_warning_led_pdata = {
292 .name = "warning_led",
293 .def_trigger = "",
294};
295
296static struct gpiod_lookup_table n35_warning_led_gpio_table = {
297 .dev_id = "s3c24xx_led.2",
298 .table = {
299 GPIO_LOOKUP("GPD", 9, NULL, GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN),
300 { },
301 },
302};
303
304static struct s3c24xx_led_platdata n35_warning_led_pdata = {
305 .name = "warning_led",
306 .def_trigger = "",
307};
308
309static struct platform_device n30_blue_led = {
310 .name = "s3c24xx_led",
311 .id = 1,
312 .dev = {
313 .platform_data = &n30_blue_led_pdata,
314 },
315};
316
317static struct platform_device n35_blue_led = {
318 .name = "s3c24xx_led",
319 .id = 1,
320 .dev = {
321 .platform_data = &n35_blue_led_pdata,
322 },
323};
324
325static struct platform_device n30_warning_led = {
326 .name = "s3c24xx_led",
327 .id = 2,
328 .dev = {
329 .platform_data = &n30_warning_led_pdata,
330 },
331};
332
333static struct platform_device n35_warning_led = {
334 .name = "s3c24xx_led",
335 .id = 2,
336 .dev = {
337 .platform_data = &n35_warning_led_pdata,
338 },
339};
340
341static struct s3c2410fb_display n30_display __initdata = {
342 .type = S3C2410_LCDCON1_TFT,
343 .width = 240,
344 .height = 320,
345 .pixclock = 170000,
346
347 .xres = 240,
348 .yres = 320,
349 .bpp = 16,
350 .left_margin = 3,
351 .right_margin = 40,
352 .hsync_len = 40,
353 .upper_margin = 2,
354 .lower_margin = 3,
355 .vsync_len = 2,
356
357 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
358};
359
360static struct s3c2410fb_mach_info n30_fb_info __initdata = {
361 .displays = &n30_display,
362 .num_displays = 1,
363 .default_display = 0,
364 .lpcsel = 0x06,
365};
366
367static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd)
368{
369 s3c24xx_mci_def_set_power(power_mode, vdd);
370
371 switch (power_mode) {
372 case MMC_POWER_ON:
373 case MMC_POWER_UP:
374 gpio_set_value(S3C2410_GPG(4), 1);
375 break;
376 case MMC_POWER_OFF:
377 default:
378 gpio_set_value(S3C2410_GPG(4), 0);
379 break;
380 }
381}
382
383static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
384 .ocr_avail = MMC_VDD_32_33,
385 .set_power = n30_sdi_set_power,
386};
387
388static struct gpiod_lookup_table n30_mci_gpio_table = {
389 .dev_id = "s3c2410-sdi",
390 .table = {
391
392 GPIO_LOOKUP("GPIOF", 1, "cd", GPIO_ACTIVE_LOW),
393
394 GPIO_LOOKUP("GPIOG", 10, "wp", GPIO_ACTIVE_LOW),
395 { },
396
397 GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
398 GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
399 GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
400 GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
401 GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
402 GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
403 },
404};
405
406static struct platform_device *n30_devices[] __initdata = {
407 &s3c_device_lcd,
408 &s3c_device_wdt,
409 &s3c_device_i2c0,
410 &s3c_device_iis,
411 &s3c_device_ohci,
412 &s3c_device_rtc,
413 &s3c_device_usbgadget,
414 &s3c_device_sdi,
415 &n30_button_device,
416 &n30_blue_led,
417 &n30_warning_led,
418};
419
420static struct platform_device *n35_devices[] __initdata = {
421 &s3c_device_lcd,
422 &s3c_device_wdt,
423 &s3c_device_i2c0,
424 &s3c_device_iis,
425 &s3c_device_rtc,
426 &s3c_device_usbgadget,
427 &s3c_device_sdi,
428 &n35_button_device,
429 &n35_blue_led,
430 &n35_warning_led,
431};
432
433static struct s3c2410_platform_i2c __initdata n30_i2ccfg = {
434 .flags = 0,
435 .slave_addr = 0x10,
436 .frequency = 10*1000,
437};
438
439
440
441static void __init n30_hwinit(void)
442{
443
444
445
446
447
448
449
450
451 if (machine_is_n30())
452 __raw_writel(0x007fffff, S3C2410_GPACON);
453 if (machine_is_n35())
454 __raw_writel(0x007fefff, S3C2410_GPACON);
455 __raw_writel(0x00000000, S3C2410_GPADAT);
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470 __raw_writel(0x00154556, S3C2410_GPBCON);
471 __raw_writel(0x00000750, S3C2410_GPBDAT);
472 __raw_writel(0x00000073, S3C2410_GPBUP);
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489 __raw_writel(0xaaa80618, S3C2410_GPCCON);
490 __raw_writel(0x0000014c, S3C2410_GPCDAT);
491 __raw_writel(0x0000fef2, S3C2410_GPCUP);
492
493
494
495
496
497
498
499
500
501 __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
502 __raw_writel(0x00000601, S3C2410_GPDDAT);
503 __raw_writel(0x0000fbfe, S3C2410_GPDUP);
504
505
506
507
508
509
510 __raw_writel(0xa56aaaaa, S3C2410_GPECON);
511 __raw_writel(0x0000efc5, S3C2410_GPEDAT);
512 __raw_writel(0x0000f81f, S3C2410_GPEUP);
513
514
515
516
517
518
519
520
521
522
523
524
525 __raw_writel(0x0000aaaa, S3C2410_GPFCON);
526 __raw_writel(0x00000000, S3C2410_GPFDAT);
527 __raw_writel(0x000000ff, S3C2410_GPFUP);
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552 if (machine_is_n30())
553 __raw_writel(0xff0a956a, S3C2410_GPGCON);
554 if (machine_is_n35())
555 __raw_writel(0xff4aa92a, S3C2410_GPGCON);
556 __raw_writel(0x0000e800, S3C2410_GPGDAT);
557 __raw_writel(0x0000f86f, S3C2410_GPGUP);
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572 __raw_writel(0x0028aaaa, S3C2410_GPHCON);
573 __raw_writel(0x000005ef, S3C2410_GPHDAT);
574 __raw_writel(0x0000063f, S3C2410_GPHUP);
575}
576
577static void __init n30_map_io(void)
578{
579 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
580 n30_hwinit();
581 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
582 s3c24xx_set_timer_source(S3C24XX_PWM3, S3C24XX_PWM4);
583}
584
585static void __init n30_init_time(void)
586{
587 s3c2410_init_clocks(12000000);
588 s3c24xx_timer_init();
589}
590
591
592
593static void __init n30_init(void)
594{
595 WARN_ON(gpio_request(S3C2410_GPG(4), "mmc power"));
596
597 s3c24xx_fb_set_platdata(&n30_fb_info);
598 s3c24xx_udc_set_platdata(&n30_udc_cfg);
599 gpiod_add_lookup_table(&n30_mci_gpio_table);
600 s3c24xx_mci_set_platdata(&n30_mci_cfg);
601 s3c_i2c0_set_platdata(&n30_i2ccfg);
602
603
604
605
606 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
607 S3C2410_MISCCR_USBSUSPND0 |
608 S3C2410_MISCCR_USBSUSPND1, 0x0);
609
610
611 s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2),
612 S3C_GPIO_PULL_NONE);
613
614 if (machine_is_n30()) {
615
616
617 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
618 S3C2410_MISCCR_USBSUSPND0 |
619 S3C2410_MISCCR_USBSUSPND1, 0x0);
620
621
622 s3c_gpio_setpull(S3C2410_GPG(6), S3C_GPIO_PULL_NONE);
623 s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE);
624 gpiod_add_lookup_table(&n30_blue_led_gpio_table);
625 gpiod_add_lookup_table(&n30_warning_led_gpio_table);
626
627 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
628 }
629
630 if (machine_is_n35()) {
631
632
633
634
635
636
637
638
639 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
640 S3C2410_MISCCR_USBSUSPND0 |
641 S3C2410_MISCCR_USBSUSPND1,
642 S3C2410_MISCCR_USBSUSPND0);
643
644
645 s3c_gpio_setpull(S3C2410_GPD(8), S3C_GPIO_PULL_NONE);
646 s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE);
647 gpiod_add_lookup_table(&n35_blue_led_gpio_table);
648 gpiod_add_lookup_table(&n35_warning_led_gpio_table);
649
650 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
651 }
652}
653
654MACHINE_START(N30, "Acer-N30")
655
656
657
658 .atag_offset = 0x100,
659 .init_time = n30_init_time,
660 .init_machine = n30_init,
661 .init_irq = s3c2410_init_irq,
662 .map_io = n30_map_io,
663MACHINE_END
664
665MACHINE_START(N35, "Acer-N35")
666
667
668 .atag_offset = 0x100,
669 .init_time = n30_init_time,
670 .init_machine = n30_init,
671 .init_irq = s3c2410_init_irq,
672 .map_io = n30_map_io,
673MACHINE_END
674