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/input.h>
23 #include <linux/interrupt.h>
24 #include <linux/platform_device.h>
25 #include <linux/serial_core.h>
26 #include <linux/timer.h>
29 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
34 #include <mach/leds-gpio.h>
35 #include <mach/regs-gpio.h>
36 #include <mach/regs-lcd.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/irq.h>
40 #include <asm/mach/map.h>
43 #include <plat/regs-serial.h>
45 #include <plat/clock.h>
47 #include <plat/devs.h>
48 #include <plat/s3c2410.h>
51 static struct map_desc n30_iodesc
[] __initdata
= {
52 /* nothing here yet */
55 static struct s3c2410_uartcfg n30_uartcfgs
[] = {
56 /* Normal serial port */
68 .uart_flags
= UPF_CONS_FLOW
,
73 /* On the N30 the bluetooth controller is connected here.
74 * On the N35 and variants the GPS receiver is connected here. */
84 static void n30_udc_pullup(enum s3c2410_udc_cmd_e cmd
)
87 case S3C2410_UDC_P_ENABLE
:
88 s3c2410_gpio_setpin(S3C2410_GPB3
, 1);
90 case S3C2410_UDC_P_DISABLE
:
91 s3c2410_gpio_setpin(S3C2410_GPB3
, 0);
93 case S3C2410_UDC_P_RESET
:
100 static struct s3c2410_udc_mach_info n30_udc_cfg __initdata
= {
101 .udc_command
= n30_udc_pullup
,
102 .vbus_pin
= S3C2410_GPG1
,
103 .vbus_pin_inverted
= 0,
106 static struct gpio_keys_button n30_buttons
[] = {
108 .gpio
= S3C2410_GPF0
,
114 .gpio
= S3C2410_GPG9
,
116 .desc
= "Thumbwheel Up",
120 .gpio
= S3C2410_GPG8
,
122 .desc
= "Thumbwheel Down",
126 .gpio
= S3C2410_GPG7
,
128 .desc
= "Thumbwheel Press",
132 .gpio
= S3C2410_GPF7
,
133 .code
= KEY_HOMEPAGE
,
138 .gpio
= S3C2410_GPF6
,
139 .code
= KEY_CALENDAR
,
144 .gpio
= S3C2410_GPF5
,
145 .code
= KEY_ADDRESSBOOK
,
150 .gpio
= S3C2410_GPF4
,
157 static struct gpio_keys_platform_data n30_button_data
= {
158 .buttons
= n30_buttons
,
159 .nbuttons
= ARRAY_SIZE(n30_buttons
),
162 static struct platform_device n30_button_device
= {
166 .platform_data
= &n30_button_data
,
170 static struct gpio_keys_button n35_buttons
[] = {
172 .gpio
= S3C2410_GPF0
,
178 .gpio
= S3C2410_GPG9
,
180 .desc
= "Joystick Up",
184 .gpio
= S3C2410_GPG8
,
186 .desc
= "Joystick Down",
190 .gpio
= S3C2410_GPG6
,
192 .desc
= "Joystick Left",
196 .gpio
= S3C2410_GPG5
,
198 .desc
= "Joystick Right",
202 .gpio
= S3C2410_GPG7
,
204 .desc
= "Joystick Press",
208 .gpio
= S3C2410_GPF7
,
209 .code
= KEY_HOMEPAGE
,
214 .gpio
= S3C2410_GPF6
,
215 .code
= KEY_CALENDAR
,
220 .gpio
= S3C2410_GPF5
,
221 .code
= KEY_ADDRESSBOOK
,
226 .gpio
= S3C2410_GPF4
,
232 .gpio
= S3C2410_GPF3
,
234 .desc
= "GPS Antenna",
238 .gpio
= S3C2410_GPG2
,
239 .code
= SW_HEADPHONE_INSERT
,
245 static struct gpio_keys_platform_data n35_button_data
= {
246 .buttons
= n35_buttons
,
247 .nbuttons
= ARRAY_SIZE(n35_buttons
),
250 static struct platform_device n35_button_device
= {
255 .platform_data
= &n35_button_data
,
259 /* This is the bluetooth LED on the device. */
260 static struct s3c24xx_led_platdata n30_blue_led_pdata
= {
262 .gpio
= S3C2410_GPG6
,
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_GPD9
,
277 static struct platform_device n30_blue_led
= {
278 .name
= "s3c24xx_led",
281 .platform_data
= &n30_blue_led_pdata
,
285 static struct platform_device n30_warning_led
= {
286 .name
= "s3c24xx_led",
289 .platform_data
= &n30_warning_led_pdata
,
293 static struct s3c2410fb_display n30_display __initdata
= {
294 .type
= S3C2410_LCDCON1_TFT
,
309 .lcdcon5
= S3C2410_LCDCON5_INVVLINE
| S3C2410_LCDCON5_INVVFRAME
,
312 static struct s3c2410fb_mach_info n30_fb_info __initdata
= {
313 .displays
= &n30_display
,
315 .default_display
= 0,
319 static struct platform_device
*n30_devices
[] __initdata
= {
325 &s3c_device_usbgadget
,
331 static struct platform_device
*n35_devices
[] __initdata
= {
336 &s3c_device_usbgadget
,
340 static struct s3c2410_platform_i2c n30_i2ccfg
= {
343 .frequency
= 10*1000,
346 /* Lots of hardcoded stuff, but it sets up the hardware in a useful
347 * state so that we can boot Linux directly from flash. */
348 static void __init
n30_hwinit(void)
350 /* GPA0-11 special functions -- unknown what they do
351 * GPA12 N30 special function -- unknown what it does
352 * N35/PiN output -- unknown what it does
354 * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
355 * don't think it does anything useful on the N30, so I ought
356 * to make it an output there too since it always driven to 0
357 * as far as I can tell. */
358 if (machine_is_n30())
359 __raw_writel(0x007fffff, S3C2410_GPACON
);
360 if (machine_is_n35())
361 __raw_writel(0x007fefff, S3C2410_GPACON
);
362 __raw_writel(0x00000000, S3C2410_GPADAT
);
364 /* GPB0 TOUT0 backlight level
365 * GPB1 output 1=backlight on
366 * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
367 * GPB3 output USB D+ pull up 0=disabled, 1=enabled
368 * GPB4 N30 output -- unknown function
369 * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
370 * GPB5 output -- unknown function
371 * GPB6 input -- unknown function
372 * GPB7 output -- unknown function
373 * GPB8 output -- probably LCD driver enable
374 * GPB9 output -- probably LCD VSYNC driver enable
375 * GPB10 output -- probably LCD HSYNC driver enable
377 __raw_writel(0x00154556, S3C2410_GPBCON
);
378 __raw_writel(0x00000750, S3C2410_GPBDAT
);
379 __raw_writel(0x00000073, S3C2410_GPBUP
);
381 /* GPC0 input RS232 DCD/DSR/RI
383 * GPC2 output RS232 DTR?
384 * GPC3 input RS232 DCD/DSR/RI
386 * GPC5 output 0=NAND write enabled, 1=NAND write protect
387 * GPC6 input -- unknown function
388 * GPC7 input charger status 0=charger connected
389 * this input can be triggered by power on the USB device
390 * port too, but will go back to disconnected soon after.
391 * GPC8 N30/N35 output -- unknown function, always driven to 1
392 * PiN input -- unknown function, always read as 1
393 * Make it an input with a pull up for all models.
396 __raw_writel(0xaaa80618, S3C2410_GPCCON
);
397 __raw_writel(0x0000014c, S3C2410_GPCDAT
);
398 __raw_writel(0x0000fef2, S3C2410_GPCUP
);
400 /* GPD0 input -- unknown function
402 * GPD8 N30 output -- unknown function
403 * N35/PiN output 1=GPS LED on
404 * GPD9 output 0=power led blinks red, 1=normal power led function
405 * GPD10 output -- unknown function
406 * GPD11-15 LCD drivers
408 __raw_writel(0xaa95aaa4, S3C2410_GPDCON
);
409 __raw_writel(0x00000601, S3C2410_GPDDAT
);
410 __raw_writel(0x0000fbfe, S3C2410_GPDUP
);
412 /* GPE0-4 I2S audio bus
414 * E11-13 outputs -- unknown function, probably power management
415 * E14-15 I2C bus connected to the battery controller
417 __raw_writel(0xa56aaaaa, S3C2410_GPECON
);
418 __raw_writel(0x0000efc5, S3C2410_GPEDAT
);
419 __raw_writel(0x0000f81f, S3C2410_GPEUP
);
421 /* GPF0 input 0=power button pressed
422 * GPF1 input SD/MMC switch 0=card present
423 * GPF2 N30 1=reset button pressed (inverted compared to the rest)
424 * N35/PiN 0=reset button pressed
425 * GPF3 N30/PiN input -- unknown function
426 * N35 input GPS antenna position, 0=antenna closed, 1=open
427 * GPF4 input 0=button 4 pressed
428 * GPF5 input 0=button 3 pressed
429 * GPF6 input 0=button 2 pressed
430 * GPF7 input 0=button 1 pressed
432 __raw_writel(0x0000aaaa, S3C2410_GPFCON
);
433 __raw_writel(0x00000000, S3C2410_GPFDAT
);
434 __raw_writel(0x000000ff, S3C2410_GPFUP
);
436 /* GPG0 input RS232 DCD/DSR/RI
437 * GPG1 input 1=USB gadget port has power from a host
438 * GPG2 N30 input -- unknown function
439 * N35/PiN input 0=headphones plugged in, 1=not plugged in
440 * GPG3 N30 output -- unknown function
441 * N35/PiN input with unknown function
442 * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
443 * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
444 * N35/PiN input joystick right
445 * GPG6 N30 output 0=blue led on, 1=off
446 * N35/PiN input joystick left
447 * GPG7 input 0=thumbwheel pressed
448 * GPG8 input 0=thumbwheel down
449 * GPG9 input 0=thumbwheel up
450 * GPG10 input SD/MMC write protect switch
451 * GPG11 N30 input -- unknown function
452 * N35 output 0=GPS antenna powered, 1=not powered
453 * PiN output -- unknown function
454 * GPG12-15 touch screen functions
456 * The pullups differ between the models, so enable all
457 * pullups that are enabled on any of the models.
459 if (machine_is_n30())
460 __raw_writel(0xff0a956a, S3C2410_GPGCON
);
461 if (machine_is_n35())
462 __raw_writel(0xff4aa92a, S3C2410_GPGCON
);
463 __raw_writel(0x0000e800, S3C2410_GPGDAT
);
464 __raw_writel(0x0000f86f, S3C2410_GPGUP
);
466 /* GPH0/1/2/3 RS232 serial port
467 * GPH4/5 IrDA serial port
468 * GPH6/7 N30 BlueTooth serial port
469 * N35/PiN GPS receiver
470 * GPH8 input -- unknown function
471 * GPH9 CLKOUT0 HCLK -- unknown use
472 * GPH10 CLKOUT1 FCLK -- unknown use
474 * The pull ups for H6/H7 are enabled on N30 but not on the
475 * N35/PiN. I suppose is useful for a budget model of the N30
476 * with no bluetooh. It doesn't hurt to have the pull ups
477 * enabled on the N35, so leave them enabled for all models.
479 __raw_writel(0x0028aaaa, S3C2410_GPHCON
);
480 __raw_writel(0x000005ef, S3C2410_GPHDAT
);
481 __raw_writel(0x0000063f, S3C2410_GPHUP
);
484 static void __init
n30_map_io(void)
486 s3c24xx_init_io(n30_iodesc
, ARRAY_SIZE(n30_iodesc
));
488 s3c24xx_init_clocks(0);
489 s3c24xx_init_uarts(n30_uartcfgs
, ARRAY_SIZE(n30_uartcfgs
));
492 static void __init
n30_init_irq(void)
497 /* GPB3 is the line that controls the pull-up for the USB D+ line */
499 static void __init
n30_init(void)
501 s3c24xx_fb_set_platdata(&n30_fb_info
);
502 s3c_device_i2c0
.dev
.platform_data
= &n30_i2ccfg
;
503 s3c24xx_udc_set_platdata(&n30_udc_cfg
);
505 /* Turn off suspend on both USB ports, and switch the
506 * selectable USB port to USB device mode. */
508 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
509 S3C2410_MISCCR_USBSUSPND0
|
510 S3C2410_MISCCR_USBSUSPND1
, 0x0);
512 if (machine_is_n30()) {
513 /* Turn off suspend on both USB ports, and switch the
514 * selectable USB port to USB device mode. */
515 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
516 S3C2410_MISCCR_USBSUSPND0
|
517 S3C2410_MISCCR_USBSUSPND1
, 0x0);
519 platform_add_devices(n30_devices
, ARRAY_SIZE(n30_devices
));
522 if (machine_is_n35()) {
523 /* Turn off suspend and switch the selectable USB port
524 * to USB device mode. Turn on suspend for the host
525 * port since it is not connected on the N35.
527 * Actually, the host port is available at some pads
528 * on the back of the device, so it would actually be
529 * possible to add a USB device inside the N35 if you
530 * are willing to do some hardware modifications. */
531 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
532 S3C2410_MISCCR_USBSUSPND0
|
533 S3C2410_MISCCR_USBSUSPND1
,
534 S3C2410_MISCCR_USBSUSPND1
);
536 platform_add_devices(n35_devices
, ARRAY_SIZE(n35_devices
));
540 MACHINE_START(N30
, "Acer-N30")
541 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
542 Ben Dooks <ben-linux@fluff.org>
544 .phys_io
= S3C2410_PA_UART
,
545 .io_pg_offst
= (((u32
)S3C24XX_VA_UART
) >> 18) & 0xfffc,
546 .boot_params
= S3C2410_SDRAM_PA
+ 0x100,
547 .timer
= &s3c24xx_timer
,
548 .init_machine
= n30_init
,
549 .init_irq
= n30_init_irq
,
550 .map_io
= n30_map_io
,
553 MACHINE_START(N35
, "Acer-N35")
554 /* Maintainer: Christer Weinigel <christer@weinigel.se>
556 .phys_io
= S3C2410_PA_UART
,
557 .io_pg_offst
= (((u32
)S3C24XX_VA_UART
) >> 18) & 0xfffc,
558 .boot_params
= S3C2410_SDRAM_PA
+ 0x100,
559 .timer
= &s3c24xx_timer
,
560 .init_machine
= n30_init
,
561 .init_irq
= n30_init_irq
,
562 .map_io
= n30_map_io
,