fix a kmap leak in virtio_console
[linux/fpc-iii.git] / arch / arm / mach-s3c24xx / mach-n30.c
blob997684f17930836c7e7212ea48a7ac64113373e4
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>
28 #include <linux/io.h>
29 #include <linux/mmc/host.h>
31 #include <mach/hardware.h>
32 #include <asm/irq.h>
33 #include <asm/mach-types.h>
35 #include <mach/fb.h>
36 #include <linux/platform_data/leds-s3c24xx.h>
37 #include <mach/regs-gpio.h>
38 #include <mach/regs-lcd.h>
39 #include <mach/gpio-samsung.h>
41 #include <asm/mach/arch.h>
42 #include <asm/mach/irq.h>
43 #include <asm/mach/map.h>
45 #include <linux/platform_data/i2c-s3c2410.h>
46 #include <plat/regs-serial.h>
48 #include <plat/clock.h>
49 #include <plat/cpu.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>
55 #include "common.h"
57 static struct map_desc n30_iodesc[] __initdata = {
58 /* nothing here yet */
61 static struct s3c2410_uartcfg n30_uartcfgs[] = {
62 /* Normal serial port */
63 [0] = {
64 .hwport = 0,
65 .flags = 0,
66 .ucon = 0x2c5,
67 .ulcon = 0x03,
68 .ufcon = 0x51,
70 /* IR port */
71 [1] = {
72 .hwport = 1,
73 .flags = 0,
74 .uart_flags = UPF_CONS_FLOW,
75 .ucon = 0x2c5,
76 .ulcon = 0x43,
77 .ufcon = 0x51,
79 /* On the N30 the bluetooth controller is connected here.
80 * On the N35 and variants the GPS receiver is connected here. */
81 [2] = {
82 .hwport = 2,
83 .flags = 0,
84 .ucon = 0x2c5,
85 .ulcon = 0x03,
86 .ufcon = 0x51,
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),
99 .code = KEY_POWER,
100 .desc = "Power",
101 .active_low = 0,
104 .gpio = S3C2410_GPG(9),
105 .code = KEY_UP,
106 .desc = "Thumbwheel Up",
107 .active_low = 0,
110 .gpio = S3C2410_GPG(8),
111 .code = KEY_DOWN,
112 .desc = "Thumbwheel Down",
113 .active_low = 0,
116 .gpio = S3C2410_GPG(7),
117 .code = KEY_ENTER,
118 .desc = "Thumbwheel Press",
119 .active_low = 0,
122 .gpio = S3C2410_GPF(7),
123 .code = KEY_HOMEPAGE,
124 .desc = "Home",
125 .active_low = 0,
128 .gpio = S3C2410_GPF(6),
129 .code = KEY_CALENDAR,
130 .desc = "Calendar",
131 .active_low = 0,
134 .gpio = S3C2410_GPF(5),
135 .code = KEY_ADDRESSBOOK,
136 .desc = "Contacts",
137 .active_low = 0,
140 .gpio = S3C2410_GPF(4),
141 .code = KEY_MAIL,
142 .desc = "Mail",
143 .active_low = 0,
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 = {
153 .name = "gpio-keys",
154 .id = -1,
155 .dev = {
156 .platform_data = &n30_button_data,
160 static struct gpio_keys_button n35_buttons[] = {
162 .gpio = S3C2410_GPF(0),
163 .code = KEY_POWER,
164 .type = EV_PWR,
165 .desc = "Power",
166 .active_low = 0,
167 .wakeup = 1,
170 .gpio = S3C2410_GPG(9),
171 .code = KEY_UP,
172 .desc = "Joystick Up",
173 .active_low = 0,
176 .gpio = S3C2410_GPG(8),
177 .code = KEY_DOWN,
178 .desc = "Joystick Down",
179 .active_low = 0,
182 .gpio = S3C2410_GPG(6),
183 .code = KEY_DOWN,
184 .desc = "Joystick Left",
185 .active_low = 0,
188 .gpio = S3C2410_GPG(5),
189 .code = KEY_DOWN,
190 .desc = "Joystick Right",
191 .active_low = 0,
194 .gpio = S3C2410_GPG(7),
195 .code = KEY_ENTER,
196 .desc = "Joystick Press",
197 .active_low = 0,
200 .gpio = S3C2410_GPF(7),
201 .code = KEY_HOMEPAGE,
202 .desc = "Home",
203 .active_low = 0,
206 .gpio = S3C2410_GPF(6),
207 .code = KEY_CALENDAR,
208 .desc = "Calendar",
209 .active_low = 0,
212 .gpio = S3C2410_GPF(5),
213 .code = KEY_ADDRESSBOOK,
214 .desc = "Contacts",
215 .active_low = 0,
218 .gpio = S3C2410_GPF(4),
219 .code = KEY_MAIL,
220 .desc = "Mail",
221 .active_low = 0,
224 .gpio = S3C2410_GPF(3),
225 .code = SW_RADIO,
226 .desc = "GPS Antenna",
227 .active_low = 0,
230 .gpio = S3C2410_GPG(2),
231 .code = SW_HEADPHONE_INSERT,
232 .desc = "Headphone",
233 .active_low = 0,
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 = {
243 .name = "gpio-keys",
244 .id = -1,
245 .num_resources = 0,
246 .dev = {
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 = {
253 .name = "blue_led",
254 .gpio = S3C2410_GPG(6),
255 .def_trigger = "",
258 /* This is the blue LED on the device. Originally used to indicate GPS activity
259 * by flashing. */
260 static struct s3c24xx_led_platdata n35_blue_led_pdata = {
261 .name = "blue_led",
262 .gpio = S3C2410_GPD(8),
263 .def_trigger = "",
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),
274 .def_trigger = "",
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),
281 .def_trigger = "",
284 static struct platform_device n30_blue_led = {
285 .name = "s3c24xx_led",
286 .id = 1,
287 .dev = {
288 .platform_data = &n30_blue_led_pdata,
292 static struct platform_device n35_blue_led = {
293 .name = "s3c24xx_led",
294 .id = 1,
295 .dev = {
296 .platform_data = &n35_blue_led_pdata,
300 static struct platform_device n30_warning_led = {
301 .name = "s3c24xx_led",
302 .id = 2,
303 .dev = {
304 .platform_data = &n30_warning_led_pdata,
308 static struct platform_device n35_warning_led = {
309 .name = "s3c24xx_led",
310 .id = 2,
311 .dev = {
312 .platform_data = &n35_warning_led_pdata,
316 static struct s3c2410fb_display n30_display __initdata = {
317 .type = S3C2410_LCDCON1_TFT,
318 .width = 240,
319 .height = 320,
320 .pixclock = 170000,
322 .xres = 240,
323 .yres = 320,
324 .bpp = 16,
325 .left_margin = 3,
326 .right_margin = 40,
327 .hsync_len = 40,
328 .upper_margin = 2,
329 .lower_margin = 3,
330 .vsync_len = 2,
332 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
335 static struct s3c2410fb_mach_info n30_fb_info __initdata = {
336 .displays = &n30_display,
337 .num_displays = 1,
338 .default_display = 0,
339 .lpcsel = 0x06,
342 static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd)
344 switch (power_mode) {
345 case MMC_POWER_ON:
346 case MMC_POWER_UP:
347 gpio_set_value(S3C2410_GPG(4), 1);
348 break;
349 case MMC_POWER_OFF:
350 default:
351 gpio_set_value(S3C2410_GPG(4), 0);
352 break;
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 = {
364 &s3c_device_lcd,
365 &s3c_device_wdt,
366 &s3c_device_i2c0,
367 &s3c_device_iis,
368 &s3c_device_ohci,
369 &s3c_device_rtc,
370 &s3c_device_usbgadget,
371 &s3c_device_sdi,
372 &n30_button_device,
373 &n30_blue_led,
374 &n30_warning_led,
377 static struct platform_device *n35_devices[] __initdata = {
378 &s3c_device_lcd,
379 &s3c_device_wdt,
380 &s3c_device_i2c0,
381 &s3c_device_iis,
382 &s3c_device_rtc,
383 &s3c_device_usbgadget,
384 &s3c_device_sdi,
385 &n35_button_device,
386 &n35_blue_led,
387 &n35_warning_led,
390 static struct s3c2410_platform_i2c __initdata n30_i2ccfg = {
391 .flags = 0,
392 .slave_addr = 0x10,
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
432 * GPC1 LCD
433 * GPC2 output RS232 DTR?
434 * GPC3 input RS232 DCD/DSR/RI
435 * GPC4 LCD
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.
444 * GPC9-15 LCD
446 __raw_writel(0xaaa80618, S3C2410_GPCCON);
447 __raw_writel(0x0000014c, S3C2410_GPCDAT);
448 __raw_writel(0x0000fef2, S3C2410_GPCUP);
450 /* GPD0 input -- unknown function
451 * GPD1-D7 LCD
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
463 * GPE5-10 SD/MMC 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));
537 n30_hwinit();
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,
599 MACHINE_END
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,
610 MACHINE_END