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