1 /* Machine specific code for the Acer n30, Acer N35, Navman PiN 570,
2 * Yakumo AlphaX and Airis NC05 PDAs.
4 * Copyright (c) 2003-2005 Simtec Electronics
5 * Ben Dooks <ben@simtec.co.uk>
7 * Copyright (c) 2005-2008 Christer Weinigel <christer@weinigel.se>
9 * There is a wiki with more information about the n30 port at
10 * http://handhelds.org/moin/moin.cgi/AcerN30Documentation .
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
17 #include <linux/kernel.h>
18 #include <linux/types.h>
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>
30 #include <linux/mmc/host.h>
32 #include <mach/hardware.h>
34 #include <asm/mach-types.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>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/irq.h>
44 #include <asm/mach/map.h>
46 #include <linux/platform_data/i2c-s3c2410.h>
48 #include <plat/clock.h>
50 #include <plat/devs.h>
51 #include <linux/platform_data/mmc-s3cmci.h>
52 #include <linux/platform_data/usb-s3c2410_udc.h>
53 #include <plat/samsung-time.h>
57 static struct map_desc n30_iodesc[] __initdata = {
58 /* nothing here yet */
61 static struct s3c2410_uartcfg n30_uartcfgs[] = {
62 /* Normal serial port */
74 .uart_flags = UPF_CONS_FLOW,
79 /* On the N30 the bluetooth controller is connected here.
80 * On the N35 and variants the GPS receiver is connected here. */
90 static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
91 .vbus_pin = S3C2410_GPG(1),
92 .vbus_pin_inverted = 0,
93 .pullup_pin = S3C2410_GPB(3),
96 static struct gpio_keys_button n30_buttons[] = {
98 .gpio = S3C2410_GPF(0),
104 .gpio = S3C2410_GPG(9),
106 .desc = "Thumbwheel Up",
110 .gpio = S3C2410_GPG(8),
112 .desc = "Thumbwheel Down",
116 .gpio = S3C2410_GPG(7),
118 .desc = "Thumbwheel Press",
122 .gpio = S3C2410_GPF(7),
123 .code = KEY_HOMEPAGE,
128 .gpio = S3C2410_GPF(6),
129 .code = KEY_CALENDAR,
134 .gpio = S3C2410_GPF(5),
135 .code = KEY_ADDRESSBOOK,
140 .gpio = S3C2410_GPF(4),
147 static struct gpio_keys_platform_data n30_button_data = {
148 .buttons = n30_buttons,
149 .nbuttons = ARRAY_SIZE(n30_buttons),
152 static struct platform_device n30_button_device = {
156 .platform_data = &n30_button_data,
160 static struct gpio_keys_button n35_buttons[] = {
162 .gpio = S3C2410_GPF(0),
170 .gpio = S3C2410_GPG(9),
172 .desc = "Joystick Up",
176 .gpio = S3C2410_GPG(8),
178 .desc = "Joystick Down",
182 .gpio = S3C2410_GPG(6),
184 .desc = "Joystick Left",
188 .gpio = S3C2410_GPG(5),
190 .desc = "Joystick Right",
194 .gpio = S3C2410_GPG(7),
196 .desc = "Joystick Press",
200 .gpio = S3C2410_GPF(7),
201 .code = KEY_HOMEPAGE,
206 .gpio = S3C2410_GPF(6),
207 .code = KEY_CALENDAR,
212 .gpio = S3C2410_GPF(5),
213 .code = KEY_ADDRESSBOOK,
218 .gpio = S3C2410_GPF(4),
224 .gpio = S3C2410_GPF(3),
226 .desc = "GPS Antenna",
230 .gpio = S3C2410_GPG(2),
231 .code = SW_HEADPHONE_INSERT,
237 static struct gpio_keys_platform_data n35_button_data = {
238 .buttons = n35_buttons,
239 .nbuttons = ARRAY_SIZE(n35_buttons),
242 static struct platform_device n35_button_device = {
247 .platform_data = &n35_button_data,
251 /* This is the bluetooth LED on the device. */
252 static struct s3c24xx_led_platdata n30_blue_led_pdata = {
254 .gpio = S3C2410_GPG(6),
258 /* This is the blue LED on the device. Originally used to indicate GPS activity
260 static struct s3c24xx_led_platdata n35_blue_led_pdata = {
262 .gpio = S3C2410_GPD(8),
266 /* This LED is driven by the battery microcontroller, and is blinking
267 * red, blinking green or solid green when the battery is low,
268 * charging or full respectively. By driving GPD9 low, it's possible
269 * to force the LED to blink red, so call that warning LED. */
270 static struct s3c24xx_led_platdata n30_warning_led_pdata = {
271 .name = "warning_led",
272 .flags = S3C24XX_LEDF_ACTLOW,
273 .gpio = S3C2410_GPD(9),
277 static struct s3c24xx_led_platdata n35_warning_led_pdata = {
278 .name = "warning_led",
279 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
280 .gpio = S3C2410_GPD(9),
284 static struct platform_device n30_blue_led = {
285 .name = "s3c24xx_led",
288 .platform_data = &n30_blue_led_pdata,
292 static struct platform_device n35_blue_led = {
293 .name = "s3c24xx_led",
296 .platform_data = &n35_blue_led_pdata,
300 static struct platform_device n30_warning_led = {
301 .name = "s3c24xx_led",
304 .platform_data = &n30_warning_led_pdata,
308 static struct platform_device n35_warning_led = {
309 .name = "s3c24xx_led",
312 .platform_data = &n35_warning_led_pdata,
316 static struct s3c2410fb_display n30_display __initdata = {
317 .type = S3C2410_LCDCON1_TFT,
332 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
335 static struct s3c2410fb_mach_info n30_fb_info __initdata = {
336 .displays = &n30_display,
338 .default_display = 0,
342 static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd)
344 switch (power_mode) {
347 gpio_set_value(S3C2410_GPG(4), 1);
351 gpio_set_value(S3C2410_GPG(4), 0);
356 static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
357 .gpio_detect = S3C2410_GPF(1),
358 .gpio_wprotect = S3C2410_GPG(10),
359 .ocr_avail = MMC_VDD_32_33,
360 .set_power = n30_sdi_set_power,
363 static struct platform_device *n30_devices[] __initdata = {
370 &s3c_device_usbgadget,
377 static struct platform_device *n35_devices[] __initdata = {
383 &s3c_device_usbgadget,
390 static struct s3c2410_platform_i2c __initdata n30_i2ccfg = {
393 .frequency = 10*1000,
396 /* Lots of hardcoded stuff, but it sets up the hardware in a useful
397 * state so that we can boot Linux directly from flash. */
398 static void __init n30_hwinit(void)
400 /* GPA0-11 special functions -- unknown what they do
401 * GPA12 N30 special function -- unknown what it does
402 * N35/PiN output -- unknown what it does
404 * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
405 * don't think it does anything useful on the N30, so I ought
406 * to make it an output there too since it always driven to 0
407 * as far as I can tell. */
408 if (machine_is_n30())
409 __raw_writel(0x007fffff, S3C2410_GPACON);
410 if (machine_is_n35())
411 __raw_writel(0x007fefff, S3C2410_GPACON);
412 __raw_writel(0x00000000, S3C2410_GPADAT);
414 /* GPB0 TOUT0 backlight level
415 * GPB1 output 1=backlight on
416 * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
417 * GPB3 output USB D+ pull up 0=disabled, 1=enabled
418 * GPB4 N30 output -- unknown function
419 * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
420 * GPB5 output -- unknown function
421 * GPB6 input -- unknown function
422 * GPB7 output -- unknown function
423 * GPB8 output -- probably LCD driver enable
424 * GPB9 output -- probably LCD VSYNC driver enable
425 * GPB10 output -- probably LCD HSYNC driver enable
427 __raw_writel(0x00154556, S3C2410_GPBCON);
428 __raw_writel(0x00000750, S3C2410_GPBDAT);
429 __raw_writel(0x00000073, S3C2410_GPBUP);
431 /* GPC0 input RS232 DCD/DSR/RI
433 * GPC2 output RS232 DTR?
434 * GPC3 input RS232 DCD/DSR/RI
436 * GPC5 output 0=NAND write enabled, 1=NAND write protect
437 * GPC6 input -- unknown function
438 * GPC7 input charger status 0=charger connected
439 * this input can be triggered by power on the USB device
440 * port too, but will go back to disconnected soon after.
441 * GPC8 N30/N35 output -- unknown function, always driven to 1
442 * PiN input -- unknown function, always read as 1
443 * Make it an input with a pull up for all models.
446 __raw_writel(0xaaa80618, S3C2410_GPCCON);
447 __raw_writel(0x0000014c, S3C2410_GPCDAT);
448 __raw_writel(0x0000fef2, S3C2410_GPCUP);
450 /* GPD0 input -- unknown function
452 * GPD8 N30 output -- unknown function
453 * N35/PiN output 1=GPS LED on
454 * GPD9 output 0=power led blinks red, 1=normal power led function
455 * GPD10 output -- unknown function
456 * GPD11-15 LCD drivers
458 __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
459 __raw_writel(0x00000601, S3C2410_GPDDAT);
460 __raw_writel(0x0000fbfe, S3C2410_GPDUP);
462 /* GPE0-4 I2S audio bus
464 * E11-13 outputs -- unknown function, probably power management
465 * E14-15 I2C bus connected to the battery controller
467 __raw_writel(0xa56aaaaa, S3C2410_GPECON);
468 __raw_writel(0x0000efc5, S3C2410_GPEDAT);
469 __raw_writel(0x0000f81f, S3C2410_GPEUP);
471 /* GPF0 input 0=power button pressed
472 * GPF1 input SD/MMC switch 0=card present
473 * GPF2 N30 1=reset button pressed (inverted compared to the rest)
474 * N35/PiN 0=reset button pressed
475 * GPF3 N30/PiN input -- unknown function
476 * N35 input GPS antenna position, 0=antenna closed, 1=open
477 * GPF4 input 0=button 4 pressed
478 * GPF5 input 0=button 3 pressed
479 * GPF6 input 0=button 2 pressed
480 * GPF7 input 0=button 1 pressed
482 __raw_writel(0x0000aaaa, S3C2410_GPFCON);
483 __raw_writel(0x00000000, S3C2410_GPFDAT);
484 __raw_writel(0x000000ff, S3C2410_GPFUP);
486 /* GPG0 input RS232 DCD/DSR/RI
487 * GPG1 input 1=USB gadget port has power from a host
488 * GPG2 N30 input -- unknown function
489 * N35/PiN input 0=headphones plugged in, 1=not plugged in
490 * GPG3 N30 output -- unknown function
491 * N35/PiN input with unknown function
492 * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
493 * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
494 * N35/PiN input joystick right
495 * GPG6 N30 output 0=blue led on, 1=off
496 * N35/PiN input joystick left
497 * GPG7 input 0=thumbwheel pressed
498 * GPG8 input 0=thumbwheel down
499 * GPG9 input 0=thumbwheel up
500 * GPG10 input SD/MMC write protect switch
501 * GPG11 N30 input -- unknown function
502 * N35 output 0=GPS antenna powered, 1=not powered
503 * PiN output -- unknown function
504 * GPG12-15 touch screen functions
506 * The pullups differ between the models, so enable all
507 * pullups that are enabled on any of the models.
509 if (machine_is_n30())
510 __raw_writel(0xff0a956a, S3C2410_GPGCON);
511 if (machine_is_n35())
512 __raw_writel(0xff4aa92a, S3C2410_GPGCON);
513 __raw_writel(0x0000e800, S3C2410_GPGDAT);
514 __raw_writel(0x0000f86f, S3C2410_GPGUP);
516 /* GPH0/1/2/3 RS232 serial port
517 * GPH4/5 IrDA serial port
518 * GPH6/7 N30 BlueTooth serial port
519 * N35/PiN GPS receiver
520 * GPH8 input -- unknown function
521 * GPH9 CLKOUT0 HCLK -- unknown use
522 * GPH10 CLKOUT1 FCLK -- unknown use
524 * The pull ups for H6/H7 are enabled on N30 but not on the
525 * N35/PiN. I suppose is useful for a budget model of the N30
526 * with no bluetooh. It doesn't hurt to have the pull ups
527 * enabled on the N35, so leave them enabled for all models.
529 __raw_writel(0x0028aaaa, S3C2410_GPHCON);
530 __raw_writel(0x000005ef, S3C2410_GPHDAT);
531 __raw_writel(0x0000063f, S3C2410_GPHUP);
534 static void __init n30_map_io(void)
536 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
538 s3c24xx_init_clocks(0);
539 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
540 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
543 /* GPB3 is the line that controls the pull-up for the USB D+ line */
545 static void __init n30_init(void)
547 WARN_ON(gpio_request(S3C2410_GPG(4), "mmc power"));
549 s3c24xx_fb_set_platdata(&n30_fb_info);
550 s3c24xx_udc_set_platdata(&n30_udc_cfg);
551 s3c24xx_mci_set_platdata(&n30_mci_cfg);
552 s3c_i2c0_set_platdata(&n30_i2ccfg);
554 /* Turn off suspend on both USB ports, and switch the
555 * selectable USB port to USB device mode. */
557 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
558 S3C2410_MISCCR_USBSUSPND0 |
559 S3C2410_MISCCR_USBSUSPND1, 0x0);
561 if (machine_is_n30()) {
562 /* Turn off suspend on both USB ports, and switch the
563 * selectable USB port to USB device mode. */
564 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
565 S3C2410_MISCCR_USBSUSPND0 |
566 S3C2410_MISCCR_USBSUSPND1, 0x0);
568 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
571 if (machine_is_n35()) {
572 /* Turn off suspend and switch the selectable USB port
573 * to USB device mode. Turn on suspend for the host
574 * port since it is not connected on the N35.
576 * Actually, the host port is available at some pads
577 * on the back of the device, so it would actually be
578 * possible to add a USB device inside the N35 if you
579 * are willing to do some hardware modifications. */
580 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
581 S3C2410_MISCCR_USBSUSPND0 |
582 S3C2410_MISCCR_USBSUSPND1,
583 S3C2410_MISCCR_USBSUSPND0);
585 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
589 MACHINE_START(N30, "Acer-N30")
590 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
591 Ben Dooks <ben-linux@fluff.org>
593 .atag_offset = 0x100,
594 .init_time = samsung_timer_init,
595 .init_machine = n30_init,
596 .init_irq = s3c2410_init_irq,
597 .map_io = n30_map_io,
598 .restart = s3c2410_restart,
601 MACHINE_START(N35, "Acer-N35")
602 /* Maintainer: Christer Weinigel <christer@weinigel.se>
604 .atag_offset = 0x100,
605 .init_time = samsung_timer_init,
606 .init_machine = n30_init,
607 .init_irq = s3c2410_init_irq,
608 .map_io = n30_map_io,
609 .restart = s3c2410_restart,