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/delay.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/init.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>
29 #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>
43 #include <asm/plat-s3c/iic.h>
44 #include <asm/plat-s3c/regs-serial.h>
46 #include <asm/plat-s3c24xx/clock.h>
47 #include <asm/plat-s3c24xx/cpu.h>
48 #include <asm/plat-s3c24xx/devs.h>
49 #include <asm/plat-s3c24xx/s3c2410.h>
50 #include <asm/plat-s3c24xx/udc.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_GPB3, 1);
91 case S3C2410_UDC_P_DISABLE :
92 s3c2410_gpio_setpin(S3C2410_GPB3, 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_GPG1,
104 .vbus_pin_inverted = 0,
107 static struct gpio_keys_button n30_buttons[] = {
109 .gpio = S3C2410_GPF0,
115 .gpio = S3C2410_GPG9,
117 .desc = "Thumbwheel Up",
121 .gpio = S3C2410_GPG8,
123 .desc = "Thumbwheel Down",
127 .gpio = S3C2410_GPG7,
129 .desc = "Thumbwheel Press",
133 .gpio = S3C2410_GPF7,
134 .code = KEY_HOMEPAGE,
139 .gpio = S3C2410_GPF6,
140 .code = KEY_CALENDAR,
145 .gpio = S3C2410_GPF5,
146 .code = KEY_ADDRESSBOOK,
151 .gpio = S3C2410_GPF4,
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_GPF0,
179 .gpio = S3C2410_GPG9,
181 .desc = "Joystick Up",
185 .gpio = S3C2410_GPG8,
187 .desc = "Joystick Down",
191 .gpio = S3C2410_GPG6,
193 .desc = "Joystick Left",
197 .gpio = S3C2410_GPG5,
199 .desc = "Joystick Right",
203 .gpio = S3C2410_GPG7,
205 .desc = "Joystick Press",
209 .gpio = S3C2410_GPF7,
210 .code = KEY_HOMEPAGE,
215 .gpio = S3C2410_GPF6,
216 .code = KEY_CALENDAR,
221 .gpio = S3C2410_GPF5,
222 .code = KEY_ADDRESSBOOK,
227 .gpio = S3C2410_GPF4,
233 .gpio = S3C2410_GPF3,
235 .desc = "GPS Antenna",
239 .gpio = S3C2410_GPG2,
240 .code = SW_HEADPHONE_INSERT,
246 static struct gpio_keys_platform_data n35_button_data = {
247 .buttons = n35_buttons,
248 .nbuttons = ARRAY_SIZE(n35_buttons),
251 static struct platform_device n35_button_device = {
256 .platform_data = &n35_button_data,
260 /* This is the bluetooth LED on the device. */
261 static struct s3c24xx_led_platdata n30_blue_led_pdata = {
263 .gpio = S3C2410_GPG6,
267 /* This LED is driven by the battery microcontroller, and is blinking
268 * red, blinking green or solid green when the battery is low,
269 * charging or full respectively. By driving GPD9 low, it's possible
270 * to force the LED to blink red, so call that warning LED. */
271 static struct s3c24xx_led_platdata n30_warning_led_pdata = {
272 .name = "warning_led",
273 .flags = S3C24XX_LEDF_ACTLOW,
274 .gpio = S3C2410_GPD9,
278 static struct platform_device n30_blue_led = {
279 .name = "s3c24xx_led",
282 .platform_data = &n30_blue_led_pdata,
286 static struct platform_device n30_warning_led = {
287 .name = "s3c24xx_led",
290 .platform_data = &n30_warning_led_pdata,
294 static struct s3c2410fb_display n30_display __initdata = {
295 .type = S3C2410_LCDCON1_TFT,
310 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
313 static struct s3c2410fb_mach_info n30_fb_info __initdata = {
314 .displays = &n30_display,
316 .default_display = 0,
320 static struct platform_device *n30_devices[] __initdata = {
326 &s3c_device_usbgadget,
332 static struct platform_device *n35_devices[] __initdata = {
337 &s3c_device_usbgadget,
341 static struct s3c2410_platform_i2c n30_i2ccfg = {
348 /* Lots of hardcoded stuff, but it sets up the hardware in a useful
349 * state so that we can boot Linux directly from flash. */
350 static void __init n30_hwinit(void)
352 /* GPA0-11 special functions -- unknown what they do
353 * GPA12 N30 special function -- unknown what it does
354 * N35/PiN output -- unknown what it does
356 * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
357 * don't think it does anything useful on the N30, so I ought
358 * to make it an output there too since it always driven to 0
359 * as far as I can tell. */
360 if (machine_is_n30())
361 __raw_writel(0x007fffff, S3C2410_GPACON);
362 if (machine_is_n35())
363 __raw_writel(0x007fefff, S3C2410_GPACON);
364 __raw_writel(0x00000000, S3C2410_GPADAT);
366 /* GPB0 TOUT0 backlight level
367 * GPB1 output 1=backlight on
368 * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
369 * GPB3 output USB D+ pull up 0=disabled, 1=enabled
370 * GPB4 N30 output -- unknown function
371 * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
372 * GPB5 output -- unknown function
373 * GPB6 input -- unknown function
374 * GPB7 output -- unknown function
375 * GPB8 output -- probably LCD driver enable
376 * GPB9 output -- probably LCD VSYNC driver enable
377 * GPB10 output -- probably LCD HSYNC driver enable
379 __raw_writel(0x00154556, S3C2410_GPBCON);
380 __raw_writel(0x00000750, S3C2410_GPBDAT);
381 __raw_writel(0x00000073, S3C2410_GPBUP);
383 /* GPC0 input RS232 DCD/DSR/RI
385 * GPC2 output RS232 DTR?
386 * GPC3 input RS232 DCD/DSR/RI
388 * GPC5 output 0=NAND write enabled, 1=NAND write protect
389 * GPC6 input -- unknown function
390 * GPC7 input charger status 0=charger connected
391 * this input can be triggered by power on the USB device
392 * port too, but will go back to disconnected soon after.
393 * GPC8 N30/N35 output -- unknown function, always driven to 1
394 * PiN input -- unknown function, always read as 1
395 * Make it an input with a pull up for all models.
398 __raw_writel(0xaaa80618, S3C2410_GPCCON);
399 __raw_writel(0x0000014c, S3C2410_GPCDAT);
400 __raw_writel(0x0000fef2, S3C2410_GPCUP);
402 /* GPD0 input -- unknown function
404 * GPD8 N30 output -- unknown function
405 * N35/PiN output 1=GPS LED on
406 * GPD9 output 0=power led blinks red, 1=normal power led function
407 * GPD10 output -- unknown function
408 * GPD11-15 LCD drivers
410 __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
411 __raw_writel(0x00000601, S3C2410_GPDDAT);
412 __raw_writel(0x0000fbfe, S3C2410_GPDUP);
414 /* GPE0-4 I2S audio bus
416 * E11-13 outputs -- unknown function, probably power management
417 * E14-15 I2C bus connected to the battery controller
419 __raw_writel(0xa56aaaaa, S3C2410_GPECON);
420 __raw_writel(0x0000efc5, S3C2410_GPEDAT);
421 __raw_writel(0x0000f81f, S3C2410_GPEUP);
423 /* GPF0 input 0=power button pressed
424 * GPF1 input SD/MMC switch 0=card present
425 * GPF2 N30 1=reset button pressed (inverted compared to the rest)
426 * N35/PiN 0=reset button pressed
427 * GPF3 N30/PiN input -- unknown function
428 * N35 input GPS antenna position, 0=antenna closed, 1=open
429 * GPF4 input 0=button 4 pressed
430 * GPF5 input 0=button 3 pressed
431 * GPF6 input 0=button 2 pressed
432 * GPF7 input 0=button 1 pressed
434 __raw_writel(0x0000aaaa, S3C2410_GPFCON);
435 __raw_writel(0x00000000, S3C2410_GPFDAT);
436 __raw_writel(0x000000ff, S3C2410_GPFUP);
438 /* GPG0 input RS232 DCD/DSR/RI
439 * GPG1 input 1=USB gadget port has power from a host
440 * GPG2 N30 input -- unknown function
441 * N35/PiN input 0=headphones plugged in, 1=not plugged in
442 * GPG3 N30 output -- unknown function
443 * N35/PiN input with unknown function
444 * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
445 * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
446 * N35/PiN input joystick right
447 * GPG6 N30 output 0=blue led on, 1=off
448 * N35/PiN input joystick left
449 * GPG7 input 0=thumbwheel pressed
450 * GPG8 input 0=thumbwheel down
451 * GPG9 input 0=thumbwheel up
452 * GPG10 input SD/MMC write protect switch
453 * GPG11 N30 input -- unknown function
454 * N35 output 0=GPS antenna powered, 1=not powered
455 * PiN output -- unknown function
456 * GPG12-15 touch screen functions
458 * The pullups differ between the models, so enable all
459 * pullups that are enabled on any of the models.
461 if (machine_is_n30())
462 __raw_writel(0xff0a956a, S3C2410_GPGCON);
463 if (machine_is_n35())
464 __raw_writel(0xff4aa92a, S3C2410_GPGCON);
465 __raw_writel(0x0000e800, S3C2410_GPGDAT);
466 __raw_writel(0x0000f86f, S3C2410_GPGUP);
468 /* GPH0/1/2/3 RS232 serial port
469 * GPH4/5 IrDA serial port
470 * GPH6/7 N30 BlueTooth serial port
471 * N35/PiN GPS receiver
472 * GPH8 input -- unknown function
473 * GPH9 CLKOUT0 HCLK -- unknown use
474 * GPH10 CLKOUT1 FCLK -- unknown use
476 * The pull ups for H6/H7 are enabled on N30 but not on the
477 * N35/PiN. I suppose is useful for a budget model of the N30
478 * with no bluetooh. It doesn't hurt to have the pull ups
479 * enabled on the N35, so leave them enabled for all models.
481 __raw_writel(0x0028aaaa, S3C2410_GPHCON);
482 __raw_writel(0x000005ef, S3C2410_GPHDAT);
483 __raw_writel(0x0000063f, S3C2410_GPHUP);
486 static void __init n30_map_io(void)
488 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
490 s3c24xx_init_clocks(0);
491 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
494 static void __init n30_init_irq(void)
499 /* GPB3 is the line that controls the pull-up for the USB D+ line */
501 static void __init n30_init(void)
503 s3c24xx_fb_set_platdata(&n30_fb_info);
504 s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
505 s3c24xx_udc_set_platdata(&n30_udc_cfg);
507 /* Turn off suspend on both USB ports, and switch the
508 * selectable USB port to USB device mode. */
510 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
511 S3C2410_MISCCR_USBSUSPND0 |
512 S3C2410_MISCCR_USBSUSPND1, 0x0);
514 if (machine_is_n30()) {
515 /* Turn off suspend on both USB ports, and switch the
516 * selectable USB port to USB device mode. */
517 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
518 S3C2410_MISCCR_USBSUSPND0 |
519 S3C2410_MISCCR_USBSUSPND1, 0x0);
521 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
524 if (machine_is_n35()) {
525 /* Turn off suspend and switch the selectable USB port
526 * to USB device mode. Turn on suspend for the host
527 * port since it is not connected on the N35.
529 * Actually, the host port is available at some pads
530 * on the back of the device, so it would actually be
531 * possible to add a USB device inside the N35 if you
532 * are willing to do some hardware modifications. */
533 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
534 S3C2410_MISCCR_USBSUSPND0 |
535 S3C2410_MISCCR_USBSUSPND1,
536 S3C2410_MISCCR_USBSUSPND1);
538 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
542 MACHINE_START(N30, "Acer-N30")
543 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
544 Ben Dooks <ben-linux@fluff.org>
546 .phys_io = S3C2410_PA_UART,
547 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
548 .boot_params = S3C2410_SDRAM_PA + 0x100,
549 .timer = &s3c24xx_timer,
550 .init_machine = n30_init,
551 .init_irq = n30_init_irq,
552 .map_io = n30_map_io,
555 MACHINE_START(N35, "Acer-N35")
556 /* Maintainer: Christer Weinigel <christer@weinigel.se>
558 .phys_io = S3C2410_PA_UART,
559 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
560 .boot_params = S3C2410_SDRAM_PA + 0x100,
561 .timer = &s3c24xx_timer,
562 .init_machine = n30_init,
563 .init_irq = n30_init_irq,
564 .map_io = n30_map_io,