1 // SPDX-License-Identifier: GPL-2.0
3 // Machine specific code for the Acer n30, Acer N35, Navman PiN 570,
4 // Yakumo AlphaX and Airis NC05 PDAs.
6 // Copyright (c) 2003-2005 Simtec Electronics
7 // Ben Dooks <ben@simtec.co.uk>
9 // Copyright (c) 2005-2008 Christer Weinigel <christer@weinigel.se>
11 // There is a wiki with more information about the n30 port at
12 // http://handhelds.org/moin/moin.cgi/AcerN30Documentation .
14 #include <linux/kernel.h>
15 #include <linux/types.h>
17 #include <linux/gpio_keys.h>
18 #include <linux/init.h>
19 #include <linux/gpio.h>
20 #include <linux/gpio/machine.h>
21 #include <linux/input.h>
22 #include <linux/interrupt.h>
23 #include <linux/platform_device.h>
24 #include <linux/serial_core.h>
25 #include <linux/serial_s3c.h>
26 #include <linux/timer.h>
28 #include <linux/mmc/host.h>
30 #include <mach/hardware.h>
32 #include <asm/mach-types.h>
35 #include <linux/platform_data/leds-s3c24xx.h>
36 #include <mach/regs-gpio.h>
37 #include <mach/regs-lcd.h>
38 #include <mach/gpio-samsung.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/irq.h>
42 #include <asm/mach/map.h>
44 #include <linux/platform_data/i2c-s3c2410.h>
47 #include <plat/devs.h>
48 #include <linux/platform_data/mmc-s3cmci.h>
49 #include <linux/platform_data/usb-s3c2410_udc.h>
50 #include <plat/samsung-time.h>
54 static struct map_desc n30_iodesc[] __initdata = {
55 /* nothing here yet */
58 static struct s3c2410_uartcfg n30_uartcfgs[] = {
59 /* Normal serial port */
71 .uart_flags = UPF_CONS_FLOW,
76 /* On the N30 the bluetooth controller is connected here.
77 * On the N35 and variants the GPS receiver is connected here. */
87 static struct s3c2410_udc_mach_info n30_udc_cfg __initdata = {
88 .vbus_pin = S3C2410_GPG(1),
89 .vbus_pin_inverted = 0,
90 .pullup_pin = S3C2410_GPB(3),
93 static struct gpio_keys_button n30_buttons[] = {
95 .gpio = S3C2410_GPF(0),
101 .gpio = S3C2410_GPG(9),
103 .desc = "Thumbwheel Up",
107 .gpio = S3C2410_GPG(8),
109 .desc = "Thumbwheel Down",
113 .gpio = S3C2410_GPG(7),
115 .desc = "Thumbwheel Press",
119 .gpio = S3C2410_GPF(7),
120 .code = KEY_HOMEPAGE,
125 .gpio = S3C2410_GPF(6),
126 .code = KEY_CALENDAR,
131 .gpio = S3C2410_GPF(5),
132 .code = KEY_ADDRESSBOOK,
137 .gpio = S3C2410_GPF(4),
144 static struct gpio_keys_platform_data n30_button_data = {
145 .buttons = n30_buttons,
146 .nbuttons = ARRAY_SIZE(n30_buttons),
149 static struct platform_device n30_button_device = {
153 .platform_data = &n30_button_data,
157 static struct gpio_keys_button n35_buttons[] = {
159 .gpio = S3C2410_GPF(0),
167 .gpio = S3C2410_GPG(9),
169 .desc = "Joystick Up",
173 .gpio = S3C2410_GPG(8),
175 .desc = "Joystick Down",
179 .gpio = S3C2410_GPG(6),
181 .desc = "Joystick Left",
185 .gpio = S3C2410_GPG(5),
187 .desc = "Joystick Right",
191 .gpio = S3C2410_GPG(7),
193 .desc = "Joystick Press",
197 .gpio = S3C2410_GPF(7),
198 .code = KEY_HOMEPAGE,
203 .gpio = S3C2410_GPF(6),
204 .code = KEY_CALENDAR,
209 .gpio = S3C2410_GPF(5),
210 .code = KEY_ADDRESSBOOK,
215 .gpio = S3C2410_GPF(4),
221 .gpio = S3C2410_GPF(3),
223 .desc = "GPS Antenna",
227 .gpio = S3C2410_GPG(2),
228 .code = SW_HEADPHONE_INSERT,
234 static struct gpio_keys_platform_data n35_button_data = {
235 .buttons = n35_buttons,
236 .nbuttons = ARRAY_SIZE(n35_buttons),
239 static struct platform_device n35_button_device = {
244 .platform_data = &n35_button_data,
248 /* This is the bluetooth LED on the device. */
249 static struct s3c24xx_led_platdata n30_blue_led_pdata = {
251 .gpio = S3C2410_GPG(6),
255 /* This is the blue LED on the device. Originally used to indicate GPS activity
257 static struct s3c24xx_led_platdata n35_blue_led_pdata = {
259 .gpio = S3C2410_GPD(8),
263 /* This LED is driven by the battery microcontroller, and is blinking
264 * red, blinking green or solid green when the battery is low,
265 * charging or full respectively. By driving GPD9 low, it's possible
266 * to force the LED to blink red, so call that warning LED. */
267 static struct s3c24xx_led_platdata n30_warning_led_pdata = {
268 .name = "warning_led",
269 .flags = S3C24XX_LEDF_ACTLOW,
270 .gpio = S3C2410_GPD(9),
274 static struct s3c24xx_led_platdata n35_warning_led_pdata = {
275 .name = "warning_led",
276 .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE,
277 .gpio = S3C2410_GPD(9),
281 static struct platform_device n30_blue_led = {
282 .name = "s3c24xx_led",
285 .platform_data = &n30_blue_led_pdata,
289 static struct platform_device n35_blue_led = {
290 .name = "s3c24xx_led",
293 .platform_data = &n35_blue_led_pdata,
297 static struct platform_device n30_warning_led = {
298 .name = "s3c24xx_led",
301 .platform_data = &n30_warning_led_pdata,
305 static struct platform_device n35_warning_led = {
306 .name = "s3c24xx_led",
309 .platform_data = &n35_warning_led_pdata,
313 static struct s3c2410fb_display n30_display __initdata = {
314 .type = S3C2410_LCDCON1_TFT,
329 .lcdcon5 = S3C2410_LCDCON5_INVVLINE | S3C2410_LCDCON5_INVVFRAME,
332 static struct s3c2410fb_mach_info n30_fb_info __initdata = {
333 .displays = &n30_display,
335 .default_display = 0,
339 static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd)
341 switch (power_mode) {
344 gpio_set_value(S3C2410_GPG(4), 1);
348 gpio_set_value(S3C2410_GPG(4), 0);
353 static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = {
354 .ocr_avail = MMC_VDD_32_33,
355 .set_power = n30_sdi_set_power,
358 static struct gpiod_lookup_table n30_mci_gpio_table = {
359 .dev_id = "s3c2410-sdi",
361 /* Card detect S3C2410_GPF(1) */
362 GPIO_LOOKUP("GPF", 1, "cd", GPIO_ACTIVE_LOW),
363 /* Write protect S3C2410_GPG(10) */
364 GPIO_LOOKUP("GPG", 10, "wp", GPIO_ACTIVE_LOW),
369 static struct platform_device *n30_devices[] __initdata = {
376 &s3c_device_usbgadget,
383 static struct platform_device *n35_devices[] __initdata = {
389 &s3c_device_usbgadget,
396 static struct s3c2410_platform_i2c __initdata n30_i2ccfg = {
399 .frequency = 10*1000,
402 /* Lots of hardcoded stuff, but it sets up the hardware in a useful
403 * state so that we can boot Linux directly from flash. */
404 static void __init n30_hwinit(void)
406 /* GPA0-11 special functions -- unknown what they do
407 * GPA12 N30 special function -- unknown what it does
408 * N35/PiN output -- unknown what it does
410 * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
411 * don't think it does anything useful on the N30, so I ought
412 * to make it an output there too since it always driven to 0
413 * as far as I can tell. */
414 if (machine_is_n30())
415 __raw_writel(0x007fffff, S3C2410_GPACON);
416 if (machine_is_n35())
417 __raw_writel(0x007fefff, S3C2410_GPACON);
418 __raw_writel(0x00000000, S3C2410_GPADAT);
420 /* GPB0 TOUT0 backlight level
421 * GPB1 output 1=backlight on
422 * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
423 * GPB3 output USB D+ pull up 0=disabled, 1=enabled
424 * GPB4 N30 output -- unknown function
425 * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
426 * GPB5 output -- unknown function
427 * GPB6 input -- unknown function
428 * GPB7 output -- unknown function
429 * GPB8 output -- probably LCD driver enable
430 * GPB9 output -- probably LCD VSYNC driver enable
431 * GPB10 output -- probably LCD HSYNC driver enable
433 __raw_writel(0x00154556, S3C2410_GPBCON);
434 __raw_writel(0x00000750, S3C2410_GPBDAT);
435 __raw_writel(0x00000073, S3C2410_GPBUP);
437 /* GPC0 input RS232 DCD/DSR/RI
439 * GPC2 output RS232 DTR?
440 * GPC3 input RS232 DCD/DSR/RI
442 * GPC5 output 0=NAND write enabled, 1=NAND write protect
443 * GPC6 input -- unknown function
444 * GPC7 input charger status 0=charger connected
445 * this input can be triggered by power on the USB device
446 * port too, but will go back to disconnected soon after.
447 * GPC8 N30/N35 output -- unknown function, always driven to 1
448 * PiN input -- unknown function, always read as 1
449 * Make it an input with a pull up for all models.
452 __raw_writel(0xaaa80618, S3C2410_GPCCON);
453 __raw_writel(0x0000014c, S3C2410_GPCDAT);
454 __raw_writel(0x0000fef2, S3C2410_GPCUP);
456 /* GPD0 input -- unknown function
458 * GPD8 N30 output -- unknown function
459 * N35/PiN output 1=GPS LED on
460 * GPD9 output 0=power led blinks red, 1=normal power led function
461 * GPD10 output -- unknown function
462 * GPD11-15 LCD drivers
464 __raw_writel(0xaa95aaa4, S3C2410_GPDCON);
465 __raw_writel(0x00000601, S3C2410_GPDDAT);
466 __raw_writel(0x0000fbfe, S3C2410_GPDUP);
468 /* GPE0-4 I2S audio bus
470 * E11-13 outputs -- unknown function, probably power management
471 * E14-15 I2C bus connected to the battery controller
473 __raw_writel(0xa56aaaaa, S3C2410_GPECON);
474 __raw_writel(0x0000efc5, S3C2410_GPEDAT);
475 __raw_writel(0x0000f81f, S3C2410_GPEUP);
477 /* GPF0 input 0=power button pressed
478 * GPF1 input SD/MMC switch 0=card present
479 * GPF2 N30 1=reset button pressed (inverted compared to the rest)
480 * N35/PiN 0=reset button pressed
481 * GPF3 N30/PiN input -- unknown function
482 * N35 input GPS antenna position, 0=antenna closed, 1=open
483 * GPF4 input 0=button 4 pressed
484 * GPF5 input 0=button 3 pressed
485 * GPF6 input 0=button 2 pressed
486 * GPF7 input 0=button 1 pressed
488 __raw_writel(0x0000aaaa, S3C2410_GPFCON);
489 __raw_writel(0x00000000, S3C2410_GPFDAT);
490 __raw_writel(0x000000ff, S3C2410_GPFUP);
492 /* GPG0 input RS232 DCD/DSR/RI
493 * GPG1 input 1=USB gadget port has power from a host
494 * GPG2 N30 input -- unknown function
495 * N35/PiN input 0=headphones plugged in, 1=not plugged in
496 * GPG3 N30 output -- unknown function
497 * N35/PiN input with unknown function
498 * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
499 * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
500 * N35/PiN input joystick right
501 * GPG6 N30 output 0=blue led on, 1=off
502 * N35/PiN input joystick left
503 * GPG7 input 0=thumbwheel pressed
504 * GPG8 input 0=thumbwheel down
505 * GPG9 input 0=thumbwheel up
506 * GPG10 input SD/MMC write protect switch
507 * GPG11 N30 input -- unknown function
508 * N35 output 0=GPS antenna powered, 1=not powered
509 * PiN output -- unknown function
510 * GPG12-15 touch screen functions
512 * The pullups differ between the models, so enable all
513 * pullups that are enabled on any of the models.
515 if (machine_is_n30())
516 __raw_writel(0xff0a956a, S3C2410_GPGCON);
517 if (machine_is_n35())
518 __raw_writel(0xff4aa92a, S3C2410_GPGCON);
519 __raw_writel(0x0000e800, S3C2410_GPGDAT);
520 __raw_writel(0x0000f86f, S3C2410_GPGUP);
522 /* GPH0/1/2/3 RS232 serial port
523 * GPH4/5 IrDA serial port
524 * GPH6/7 N30 BlueTooth serial port
525 * N35/PiN GPS receiver
526 * GPH8 input -- unknown function
527 * GPH9 CLKOUT0 HCLK -- unknown use
528 * GPH10 CLKOUT1 FCLK -- unknown use
530 * The pull ups for H6/H7 are enabled on N30 but not on the
531 * N35/PiN. I suppose is useful for a budget model of the N30
532 * with no bluetooth. It doesn't hurt to have the pull ups
533 * enabled on the N35, so leave them enabled for all models.
535 __raw_writel(0x0028aaaa, S3C2410_GPHCON);
536 __raw_writel(0x000005ef, S3C2410_GPHDAT);
537 __raw_writel(0x0000063f, S3C2410_GPHUP);
540 static void __init n30_map_io(void)
542 s3c24xx_init_io(n30_iodesc, ARRAY_SIZE(n30_iodesc));
544 s3c24xx_init_uarts(n30_uartcfgs, ARRAY_SIZE(n30_uartcfgs));
545 samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
548 static void __init n30_init_time(void)
550 s3c2410_init_clocks(12000000);
551 samsung_timer_init();
554 /* GPB3 is the line that controls the pull-up for the USB D+ line */
556 static void __init n30_init(void)
558 WARN_ON(gpio_request(S3C2410_GPG(4), "mmc power"));
560 s3c24xx_fb_set_platdata(&n30_fb_info);
561 s3c24xx_udc_set_platdata(&n30_udc_cfg);
562 gpiod_add_lookup_table(&n30_mci_gpio_table);
563 s3c24xx_mci_set_platdata(&n30_mci_cfg);
564 s3c_i2c0_set_platdata(&n30_i2ccfg);
566 /* Turn off suspend on both USB ports, and switch the
567 * selectable USB port to USB device mode. */
569 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
570 S3C2410_MISCCR_USBSUSPND0 |
571 S3C2410_MISCCR_USBSUSPND1, 0x0);
573 if (machine_is_n30()) {
574 /* Turn off suspend on both USB ports, and switch the
575 * selectable USB port to USB device mode. */
576 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
577 S3C2410_MISCCR_USBSUSPND0 |
578 S3C2410_MISCCR_USBSUSPND1, 0x0);
580 platform_add_devices(n30_devices, ARRAY_SIZE(n30_devices));
583 if (machine_is_n35()) {
584 /* Turn off suspend and switch the selectable USB port
585 * to USB device mode. Turn on suspend for the host
586 * port since it is not connected on the N35.
588 * Actually, the host port is available at some pads
589 * on the back of the device, so it would actually be
590 * possible to add a USB device inside the N35 if you
591 * are willing to do some hardware modifications. */
592 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
593 S3C2410_MISCCR_USBSUSPND0 |
594 S3C2410_MISCCR_USBSUSPND1,
595 S3C2410_MISCCR_USBSUSPND0);
597 platform_add_devices(n35_devices, ARRAY_SIZE(n35_devices));
601 MACHINE_START(N30, "Acer-N30")
602 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
603 Ben Dooks <ben-linux@fluff.org>
605 .atag_offset = 0x100,
606 .init_time = n30_init_time,
607 .init_machine = n30_init,
608 .init_irq = s3c2410_init_irq,
609 .map_io = n30_map_io,
612 MACHINE_START(N35, "Acer-N35")
613 /* Maintainer: Christer Weinigel <christer@weinigel.se>
615 .atag_offset = 0x100,
616 .init_time = n30_init_time,
617 .init_machine = n30_init,
618 .init_irq = s3c2410_init_irq,
619 .map_io = n30_map_io,