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/timer.h>
30 #include <mach/hardware.h>
32 #include <asm/mach-types.h>
35 #include <mach/leds-gpio.h>
36 #include <mach/regs-gpio.h>
37 #include <mach/regs-lcd.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/irq.h>
41 #include <asm/mach/map.h>
44 #include <plat/regs-serial.h>
46 #include <plat/clock.h>
48 #include <plat/devs.h>
49 #include <plat/s3c2410.h>
52 static struct map_desc n30_iodesc[] __initdata = {
53 /* nothing here yet */
56 static struct s3c2410_uartcfg n30_uartcfgs[] = {
57 /* Normal serial port */
69 .uart_flags = UPF_CONS_FLOW,
74 /* On the N30 the bluetooth controller is connected here.
75 * On the N35 and variants the GPS receiver is connected here. */
85 static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd)
88 case S3C2410_UDC_P_ENABLE :
89 s3c2410_gpio_setpin(S3C2410_GPB(3), 1);
91 case S3C2410_UDC_P_DISABLE :
92 s3c2410_gpio_setpin(S3C2410_GPB(3), 0);
94 case S3C2410_UDC_P_RESET :
101 static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
102 .udc_command = n30_udc_pullup,
103 .vbus_pin = S3C2410_GPG(1),
104 .vbus_pin_inverted = 0,
107 static struct gpio_keys_button n30_buttons[] = {
109 .gpio = S3C2410_GPF(0),
115 .gpio = S3C2410_GPG(9),
117 .desc = "Thumbwheel Up",
121 .gpio = S3C2410_GPG(8),
123 .desc = "Thumbwheel Down",
127 .gpio = S3C2410_GPG(7),
129 .desc = "Thumbwheel Press",
133 .gpio = S3C2410_GPF(7),
134 .code = KEY_HOMEPAGE,
139 .gpio = S3C2410_GPF(6),
140 .code = KEY_CALENDAR,
145 .gpio = S3C2410_GPF(5),
146 .code = KEY_ADDRESSBOOK,
151 .gpio = S3C2410_GPF(4),
158 static struct gpio_keys_platform_data n30_button_data = {
159 .buttons = n30_buttons,
160 .nbuttons = ARRAY_SIZE(n30_buttons),
163 static struct platform_device n30_button_device = {
167 .platform_data = &n30_button_data,
171 static struct gpio_keys_button n35_buttons[] = {
173 .gpio = S3C2410_GPF(0),
181 .gpio = S3C2410_GPG(9),
183 .desc = "Joystick Up",
187 .gpio = S3C2410_GPG(8),
189 .desc = "Joystick Down",
193 .gpio = S3C2410_GPG(6),
195 .desc = "Joystick Left",
199 .gpio = S3C2410_GPG(5),
201 .desc = "Joystick Right",
205 .gpio = S3C2410_GPG(7),
207 .desc = "Joystick Press",
211 .gpio = S3C2410_GPF(7),
212 .code = KEY_HOMEPAGE,
217 .gpio = S3C2410_GPF(6),
218 .code = KEY_CALENDAR,
223 .gpio = S3C2410_GPF(5),
224 .code = KEY_ADDRESSBOOK,
229 .gpio = S3C2410_GPF(4),
235 .gpio = S3C2410_GPF(3),
237 .desc = "GPS Antenna",
241 .gpio = S3C2410_GPG(2),
242 .code = SW_HEADPHONE_INSERT,
248 static struct gpio_keys_platform_data n35_button_data = {
249 .buttons = n35_buttons,
250 .nbuttons = ARRAY_SIZE(n35_buttons),
253 static struct platform_device n35_button_device = {
258 .platform_data = &n35_button_data,
262 /* This is the bluetooth LED on the device. */
263 static struct s3c24xx_led_platdata n30_blue_led_pdata = {
265 .gpio = S3C2410_GPG(6),
269 /* This is the blue LED on the device. Originaly used to indicate GPS activity
271 static struct s3c24xx_led_platdata n35_blue_led_pdata = {
273 .gpio = S3C2410_GPD(8),
277 /* This LED is driven by the battery microcontroller, and is blinking
278 * red, blinking green or solid green when the battery is low,
279 * charging or full respectively. By driving GPD9 low, it's possible
280 * to force the LED to blink red, so call that warning LED. */
281 static struct s3c24xx_led_platdata n30_warning_led_pdata = {
282 .name = "warning_led",
283 .flags = S3C24XX_LEDF_ACTLOW,
284 .gpio = S3C2410_GPD(9),
288 static struct s3c24xx_led_platdata n35_warning_led_pdata = {
289 .name = "warning_led",
290 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
291 .gpio = S3C2410_GPD(9),
295 static struct platform_device n30_blue_led = {
296 .name = "s3c24xx_led",
299 .platform_data = &n30_blue_led_pdata,
303 static struct platform_device n35_blue_led = {
304 .name = "s3c24xx_led",
307 .platform_data = &n35_blue_led_pdata,
311 static struct platform_device n30_warning_led = {
312 .name = "s3c24xx_led",
315 .platform_data = &n30_warning_led_pdata,
319 static struct platform_device n35_warning_led = {
320 .name = "s3c24xx_led",
323 .platform_data = &n35_warning_led_pdata,
327 static struct s3c2410fb_display n30_display __initdata = {
328 .type = S3C2410_LCDCON1_TFT,
343 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
346 static struct s3c2410fb_mach_info n30_fb_info __initdata = {
347 .displays = &n30_display,
349 .default_display = 0,
353 static struct platform_device *n30_devices[] __initdata = {
360 &s3c_device_usbgadget,
366 static struct platform_device *n35_devices[] __initdata = {
372 &s3c_device_usbgadget,
378 static struct s3c2410_platform_i2c __initdata n30_i2ccfg = {
381 .frequency = 10*1000,
384 /* Lots of hardcoded stuff, but it sets up the hardware in a useful
385 * state so that we can boot Linux directly from flash. */
386 static void __init n30_hwinit(void)
388 /* GPA0-11 special functions -- unknown what they do
389 * GPA12 N30 special function -- unknown what it does
390 * N35/PiN output -- unknown what it does
392 * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
393 * don't think it does anything useful on the N30, so I ought
394 * to make it an output there too since it always driven to 0
395 * as far as I can tell. */
396 if (machine_is_n30())
397 __raw_writel(0x007fffff, S3C2410_GPACON);
398 if (machine_is_n35())
399 __raw_writel(0x007fefff, S3C2410_GPACON);
400 __raw_writel(0x00000000, S3C2410_GPADAT);
402 /* GPB0 TOUT0 backlight level
403 * GPB1 output 1=backlight on
404 * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
405 * GPB3 output USB D+ pull up 0=disabled, 1=enabled
406 * GPB4 N30 output -- unknown function
407 * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
408 * GPB5 output -- unknown function
409 * GPB6 input -- unknown function
410 * GPB7 output -- unknown function
411 * GPB8 output -- probably LCD driver enable
412 * GPB9 output -- probably LCD VSYNC driver enable
413 * GPB10 output -- probably LCD HSYNC driver enable
415 __raw_writel(0x00154556, S3C2410_GPBCON);
416 __raw_writel(0x00000750, S3C2410_GPBDAT);
417 __raw_writel(0x00000073, S3C2410_GPBUP);
419 /* GPC0 input RS232 DCD/DSR/RI
421 * GPC2 output RS232 DTR?
422 * GPC3 input RS232 DCD/DSR/RI
424 * GPC5 output 0=NAND write enabled, 1=NAND write protect
425 * GPC6 input -- unknown function
426 * GPC7 input charger status 0=charger connected
427 * this input can be triggered by power on the USB device
428 * port too, but will go back to disconnected soon after.
429 * GPC8 N30/N35 output -- unknown function, always driven to 1
430 * PiN input -- unknown function, always read as 1
431 * Make it an input with a pull up for all models.
434 __raw_writel(0xaaa80618, S3C2410_GPCCON);
435 __raw_writel(0x0000014c, S3C2410_GPCDAT);
436 __raw_writel(0x0000fef2, S3C2410_GPCUP);
438 /* GPD0 input -- unknown function
440 * GPD8 N30 output -- unknown function
441 * N35/PiN output 1=GPS LED on
442 * GPD9 output 0=power led blinks red, 1=normal power led function
443 * GPD10 output -- unknown function
444 * GPD11-15 LCD drivers
446 __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
447 __raw_writel(0x00000601, S3C2410_GPDDAT);
448 __raw_writel(0x0000fbfe, S3C2410_GPDUP);
450 /* GPE0-4 I2S audio bus
452 * E11-13 outputs -- unknown function, probably power management
453 * E14-15 I2C bus connected to the battery controller
455 __raw_writel(0xa56aaaaa, S3C2410_GPECON);
456 __raw_writel(0x0000efc5, S3C2410_GPEDAT);
457 __raw_writel(0x0000f81f, S3C2410_GPEUP);
459 /* GPF0 input 0=power button pressed
460 * GPF1 input SD/MMC switch 0=card present
461 * GPF2 N30 1=reset button pressed (inverted compared to the rest)
462 * N35/PiN 0=reset button pressed
463 * GPF3 N30/PiN input -- unknown function
464 * N35 input GPS antenna position, 0=antenna closed, 1=open
465 * GPF4 input 0=button 4 pressed
466 * GPF5 input 0=button 3 pressed
467 * GPF6 input 0=button 2 pressed
468 * GPF7 input 0=button 1 pressed
470 __raw_writel(0x0000aaaa, S3C2410_GPFCON);
471 __raw_writel(0x00000000, S3C2410_GPFDAT);
472 __raw_writel(0x000000ff, S3C2410_GPFUP);
474 /* GPG0 input RS232 DCD/DSR/RI
475 * GPG1 input 1=USB gadget port has power from a host
476 * GPG2 N30 input -- unknown function
477 * N35/PiN input 0=headphones plugged in, 1=not plugged in
478 * GPG3 N30 output -- unknown function
479 * N35/PiN input with unknown function
480 * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
481 * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
482 * N35/PiN input joystick right
483 * GPG6 N30 output 0=blue led on, 1=off
484 * N35/PiN input joystick left
485 * GPG7 input 0=thumbwheel pressed
486 * GPG8 input 0=thumbwheel down
487 * GPG9 input 0=thumbwheel up
488 * GPG10 input SD/MMC write protect switch
489 * GPG11 N30 input -- unknown function
490 * N35 output 0=GPS antenna powered, 1=not powered
491 * PiN output -- unknown function
492 * GPG12-15 touch screen functions
494 * The pullups differ between the models, so enable all
495 * pullups that are enabled on any of the models.
497 if (machine_is_n30())
498 __raw_writel(0xff0a956a, S3C2410_GPGCON);
499 if (machine_is_n35())
500 __raw_writel(0xff4aa92a, S3C2410_GPGCON);
501 __raw_writel(0x0000e800, S3C2410_GPGDAT);
502 __raw_writel(0x0000f86f, S3C2410_GPGUP);
504 /* GPH0/1/2/3 RS232 serial port
505 * GPH4/5 IrDA serial port
506 * GPH6/7 N30 BlueTooth serial port
507 * N35/PiN GPS receiver
508 * GPH8 input -- unknown function
509 * GPH9 CLKOUT0 HCLK -- unknown use
510 * GPH10 CLKOUT1 FCLK -- unknown use
512 * The pull ups for H6/H7 are enabled on N30 but not on the
513 * N35/PiN. I suppose is useful for a budget model of the N30
514 * with no bluetooh. It doesn't hurt to have the pull ups
515 * enabled on the N35, so leave them enabled for all models.
517 __raw_writel(0x0028aaaa, S3C2410_GPHCON);
518 __raw_writel(0x000005ef, S3C2410_GPHDAT);
519 __raw_writel(0x0000063f, S3C2410_GPHUP);
522 static void __init n30_map_io(void)
524 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
526 s3c24xx_init_clocks(0);
527 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
530 static void __init n30_init_irq(void)
535 /* GPB3 is the line that controls the pull-up for the USB D+ line */
537 static void __init n30_init(void)
539 s3c24xx_fb_set_platdata(&n30_fb_info);
540 s3c24xx_udc_set_platdata(&n30_udc_cfg);
541 s3c_i2c0_set_platdata(&n30_i2ccfg);
543 /* Turn off suspend on both USB ports, and switch the
544 * selectable USB port to USB device mode. */
546 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
547 S3C2410_MISCCR_USBSUSPND0 |
548 S3C2410_MISCCR_USBSUSPND1, 0x0);
550 if (machine_is_n30()) {
551 /* Turn off suspend on both USB ports, and switch the
552 * selectable USB port to USB device mode. */
553 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
554 S3C2410_MISCCR_USBSUSPND0 |
555 S3C2410_MISCCR_USBSUSPND1, 0x0);
557 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
560 if (machine_is_n35()) {
561 /* Turn off suspend and switch the selectable USB port
562 * to USB device mode. Turn on suspend for the host
563 * port since it is not connected on the N35.
565 * Actually, the host port is available at some pads
566 * on the back of the device, so it would actually be
567 * possible to add a USB device inside the N35 if you
568 * are willing to do some hardware modifications. */
569 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
570 S3C2410_MISCCR_USBSUSPND0 |
571 S3C2410_MISCCR_USBSUSPND1,
572 S3C2410_MISCCR_USBSUSPND0);
574 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
578 MACHINE_START(N30, "Acer-N30")
579 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
580 Ben Dooks <ben-linux@fluff.org>
582 .phys_io = S3C2410_PA_UART,
583 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
584 .boot_params = S3C2410_SDRAM_PA + 0x100,
585 .timer = &s3c24xx_timer,
586 .init_machine = n30_init,
587 .init_irq = n30_init_irq,
588 .map_io = n30_map_io,
591 MACHINE_START(N35, "Acer-N35")
592 /* Maintainer: Christer Weinigel <christer@weinigel.se>
594 .phys_io = S3C2410_PA_UART,
595 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
596 .boot_params = S3C2410_SDRAM_PA + 0x100,
597 .timer = &s3c24xx_timer,
598 .init_machine = n30_init,
599 .init_irq = n30_init_irq,
600 .map_io = n30_map_io,