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 <asm/hardware.h>
32 #include <asm/mach-types.h>
34 #include <asm/arch/leds-gpio.h>
35 #include <asm/arch/regs-gpio.h>
37 #include <asm/mach/arch.h>
38 #include <asm/mach/irq.h>
39 #include <asm/mach/map.h>
41 #include <asm/plat-s3c/iic.h>
42 #include <asm/plat-s3c/regs-serial.h>
44 #include <asm/plat-s3c24xx/clock.h>
45 #include <asm/plat-s3c24xx/cpu.h>
46 #include <asm/plat-s3c24xx/devs.h>
47 #include <asm/plat-s3c24xx/s3c2410.h>
48 #include <asm/plat-s3c24xx/udc.h>
50 static struct map_desc n30_iodesc[] __initdata = {
51 /* nothing here yet */
54 static struct s3c2410_uartcfg n30_uartcfgs[] = {
55 /* Normal serial port */
67 .uart_flags = UPF_CONS_FLOW,
72 /* On the N30 the bluetooth controller is connected here.
73 * On the N35 and variants the GPS receiver is connected here. */
83 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 platform_device *n30_devices[] __initdata = {
299 &s3c_device_usbgadget,
305 static struct platform_device *n35_devices[] __initdata = {
310 &s3c_device_usbgadget,
314 static struct s3c2410_platform_i2c n30_i2ccfg = {
321 static void __init n30_map_io(void)
323 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
324 s3c24xx_init_clocks(0);
325 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
328 static void __init n30_init_irq(void)
333 /* GPB3 is the line that controls the pull-up for the USB D+ line */
335 static void __init n30_init(void)
337 s3c_device_i2c.dev.platform_data = &n30_i2ccfg;
338 s3c24xx_udc_set_platdata(&n30_udc_cfg);
340 /* Turn off suspend on both USB ports, and switch the
341 * selectable USB port to USB device mode. */
343 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
344 S3C2410_MISCCR_USBSUSPND0 |
345 S3C2410_MISCCR_USBSUSPND1, 0x0);
347 if (machine_is_n30()) {
348 /* Turn off suspend on both USB ports, and switch the
349 * selectable USB port to USB device mode. */
350 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
351 S3C2410_MISCCR_USBSUSPND0 |
352 S3C2410_MISCCR_USBSUSPND1, 0x0);
354 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
357 if (machine_is_n35()) {
358 /* Turn off suspend and switch the selectable USB port
359 * to USB device mode. Turn on suspend for the host
360 * port since it is not connected on the N35.
362 * Actually, the host port is available at some pads
363 * on the back of the device, so it would actually be
364 * possible to add a USB device inside the N35 if you
365 * are willing to do some hardware modifications. */
366 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
367 S3C2410_MISCCR_USBSUSPND0 |
368 S3C2410_MISCCR_USBSUSPND1,
369 S3C2410_MISCCR_USBSUSPND1);
371 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
375 MACHINE_START(N30, "Acer-N30")
376 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
377 Ben Dooks <ben-linux@fluff.org>
379 .phys_io = S3C2410_PA_UART,
380 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
381 .boot_params = S3C2410_SDRAM_PA + 0x100,
382 .timer = &s3c24xx_timer,
383 .init_machine = n30_init,
384 .init_irq = n30_init_irq,
385 .map_io = n30_map_io,
388 MACHINE_START(N35, "Acer-N35")
389 /* Maintainer: Christer Weinigel <christer@weinigel.se>
391 .phys_io = S3C2410_PA_UART,
392 .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
393 .boot_params = S3C2410_SDRAM_PA + 0x100,
394 .timer = &s3c24xx_timer,
395 .init_machine = n30_init,
396 .init_irq = n30_init_irq,
397 .map_io = n30_map_io,