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 // https://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 <plat/gpio-cfg.h>
49 #include <linux/platform_data/mmc-s3cmci.h>
50 #include <linux/platform_data/usb-s3c2410_udc.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. */
250 static struct gpiod_lookup_table n30_blue_led_gpio_table
= {
251 .dev_id
= "s3c24xx_led.1",
253 GPIO_LOOKUP("GPG", 6, NULL
, GPIO_ACTIVE_HIGH
),
258 static struct s3c24xx_led_platdata n30_blue_led_pdata
= {
263 /* This is the blue LED on the device. Originally used to indicate GPS activity
266 static struct gpiod_lookup_table n35_blue_led_gpio_table
= {
267 .dev_id
= "s3c24xx_led.1",
269 GPIO_LOOKUP("GPD", 8, NULL
, GPIO_ACTIVE_HIGH
),
274 static struct s3c24xx_led_platdata n35_blue_led_pdata
= {
279 /* This LED is driven by the battery microcontroller, and is blinking
280 * red, blinking green or solid green when the battery is low,
281 * charging or full respectively. By driving GPD9 low, it's possible
282 * to force the LED to blink red, so call that warning LED. */
284 static struct gpiod_lookup_table n30_warning_led_gpio_table
= {
285 .dev_id
= "s3c24xx_led.2",
287 GPIO_LOOKUP("GPD", 9, NULL
, GPIO_ACTIVE_LOW
),
292 static struct s3c24xx_led_platdata n30_warning_led_pdata
= {
293 .name
= "warning_led",
297 static struct gpiod_lookup_table n35_warning_led_gpio_table
= {
298 .dev_id
= "s3c24xx_led.2",
300 GPIO_LOOKUP("GPD", 9, NULL
, GPIO_ACTIVE_LOW
| GPIO_OPEN_DRAIN
),
305 static struct s3c24xx_led_platdata n35_warning_led_pdata
= {
306 .name
= "warning_led",
310 static struct platform_device n30_blue_led
= {
311 .name
= "s3c24xx_led",
314 .platform_data
= &n30_blue_led_pdata
,
318 static struct platform_device n35_blue_led
= {
319 .name
= "s3c24xx_led",
322 .platform_data
= &n35_blue_led_pdata
,
326 static struct platform_device n30_warning_led
= {
327 .name
= "s3c24xx_led",
330 .platform_data
= &n30_warning_led_pdata
,
334 static struct platform_device n35_warning_led
= {
335 .name
= "s3c24xx_led",
338 .platform_data
= &n35_warning_led_pdata
,
342 static struct s3c2410fb_display n30_display __initdata
= {
343 .type
= S3C2410_LCDCON1_TFT
,
358 .lcdcon5
= S3C2410_LCDCON5_INVVLINE
| S3C2410_LCDCON5_INVVFRAME
,
361 static struct s3c2410fb_mach_info n30_fb_info __initdata
= {
362 .displays
= &n30_display
,
364 .default_display
= 0,
368 static void n30_sdi_set_power(unsigned char power_mode
, unsigned short vdd
)
370 switch (power_mode
) {
373 gpio_set_value(S3C2410_GPG(4), 1);
377 gpio_set_value(S3C2410_GPG(4), 0);
382 static struct s3c24xx_mci_pdata n30_mci_cfg __initdata
= {
383 .ocr_avail
= MMC_VDD_32_33
,
384 .set_power
= n30_sdi_set_power
,
387 static struct gpiod_lookup_table n30_mci_gpio_table
= {
388 .dev_id
= "s3c2410-sdi",
390 /* Card detect S3C2410_GPF(1) */
391 GPIO_LOOKUP("GPF", 1, "cd", GPIO_ACTIVE_LOW
),
392 /* Write protect S3C2410_GPG(10) */
393 GPIO_LOOKUP("GPG", 10, "wp", GPIO_ACTIVE_LOW
),
398 static struct platform_device
*n30_devices
[] __initdata
= {
405 &s3c_device_usbgadget
,
412 static struct platform_device
*n35_devices
[] __initdata
= {
418 &s3c_device_usbgadget
,
425 static struct s3c2410_platform_i2c __initdata n30_i2ccfg
= {
428 .frequency
= 10*1000,
431 /* Lots of hardcoded stuff, but it sets up the hardware in a useful
432 * state so that we can boot Linux directly from flash. */
433 static void __init
n30_hwinit(void)
435 /* GPA0-11 special functions -- unknown what they do
436 * GPA12 N30 special function -- unknown what it does
437 * N35/PiN output -- unknown what it does
439 * A12 is nGCS1 on the N30 and an output on the N35/PiN. I
440 * don't think it does anything useful on the N30, so I ought
441 * to make it an output there too since it always driven to 0
442 * as far as I can tell. */
443 if (machine_is_n30())
444 __raw_writel(0x007fffff, S3C2410_GPACON
);
445 if (machine_is_n35())
446 __raw_writel(0x007fefff, S3C2410_GPACON
);
447 __raw_writel(0x00000000, S3C2410_GPADAT
);
449 /* GPB0 TOUT0 backlight level
450 * GPB1 output 1=backlight on
451 * GPB2 output IrDA enable 0=transceiver enabled, 1=disabled
452 * GPB3 output USB D+ pull up 0=disabled, 1=enabled
453 * GPB4 N30 output -- unknown function
454 * N30/PiN GPS control 0=GPS enabled, 1=GPS disabled
455 * GPB5 output -- unknown function
456 * GPB6 input -- unknown function
457 * GPB7 output -- unknown function
458 * GPB8 output -- probably LCD driver enable
459 * GPB9 output -- probably LCD VSYNC driver enable
460 * GPB10 output -- probably LCD HSYNC driver enable
462 __raw_writel(0x00154556, S3C2410_GPBCON
);
463 __raw_writel(0x00000750, S3C2410_GPBDAT
);
464 __raw_writel(0x00000073, S3C2410_GPBUP
);
466 /* GPC0 input RS232 DCD/DSR/RI
468 * GPC2 output RS232 DTR?
469 * GPC3 input RS232 DCD/DSR/RI
471 * GPC5 output 0=NAND write enabled, 1=NAND write protect
472 * GPC6 input -- unknown function
473 * GPC7 input charger status 0=charger connected
474 * this input can be triggered by power on the USB device
475 * port too, but will go back to disconnected soon after.
476 * GPC8 N30/N35 output -- unknown function, always driven to 1
477 * PiN input -- unknown function, always read as 1
478 * Make it an input with a pull up for all models.
481 __raw_writel(0xaaa80618, S3C2410_GPCCON
);
482 __raw_writel(0x0000014c, S3C2410_GPCDAT
);
483 __raw_writel(0x0000fef2, S3C2410_GPCUP
);
485 /* GPD0 input -- unknown function
487 * GPD8 N30 output -- unknown function
488 * N35/PiN output 1=GPS LED on
489 * GPD9 output 0=power led blinks red, 1=normal power led function
490 * GPD10 output -- unknown function
491 * GPD11-15 LCD drivers
493 __raw_writel(0xaa95aaa4, S3C2410_GPDCON
);
494 __raw_writel(0x00000601, S3C2410_GPDDAT
);
495 __raw_writel(0x0000fbfe, S3C2410_GPDUP
);
497 /* GPE0-4 I2S audio bus
499 * E11-13 outputs -- unknown function, probably power management
500 * E14-15 I2C bus connected to the battery controller
502 __raw_writel(0xa56aaaaa, S3C2410_GPECON
);
503 __raw_writel(0x0000efc5, S3C2410_GPEDAT
);
504 __raw_writel(0x0000f81f, S3C2410_GPEUP
);
506 /* GPF0 input 0=power button pressed
507 * GPF1 input SD/MMC switch 0=card present
508 * GPF2 N30 1=reset button pressed (inverted compared to the rest)
509 * N35/PiN 0=reset button pressed
510 * GPF3 N30/PiN input -- unknown function
511 * N35 input GPS antenna position, 0=antenna closed, 1=open
512 * GPF4 input 0=button 4 pressed
513 * GPF5 input 0=button 3 pressed
514 * GPF6 input 0=button 2 pressed
515 * GPF7 input 0=button 1 pressed
517 __raw_writel(0x0000aaaa, S3C2410_GPFCON
);
518 __raw_writel(0x00000000, S3C2410_GPFDAT
);
519 __raw_writel(0x000000ff, S3C2410_GPFUP
);
521 /* GPG0 input RS232 DCD/DSR/RI
522 * GPG1 input 1=USB gadget port has power from a host
523 * GPG2 N30 input -- unknown function
524 * N35/PiN input 0=headphones plugged in, 1=not plugged in
525 * GPG3 N30 output -- unknown function
526 * N35/PiN input with unknown function
527 * GPG4 N30 output 0=MMC enabled, 1=MMC disabled
528 * GPG5 N30 output 0=BlueTooth chip disabled, 1=enabled
529 * N35/PiN input joystick right
530 * GPG6 N30 output 0=blue led on, 1=off
531 * N35/PiN input joystick left
532 * GPG7 input 0=thumbwheel pressed
533 * GPG8 input 0=thumbwheel down
534 * GPG9 input 0=thumbwheel up
535 * GPG10 input SD/MMC write protect switch
536 * GPG11 N30 input -- unknown function
537 * N35 output 0=GPS antenna powered, 1=not powered
538 * PiN output -- unknown function
539 * GPG12-15 touch screen functions
541 * The pullups differ between the models, so enable all
542 * pullups that are enabled on any of the models.
544 if (machine_is_n30())
545 __raw_writel(0xff0a956a, S3C2410_GPGCON
);
546 if (machine_is_n35())
547 __raw_writel(0xff4aa92a, S3C2410_GPGCON
);
548 __raw_writel(0x0000e800, S3C2410_GPGDAT
);
549 __raw_writel(0x0000f86f, S3C2410_GPGUP
);
551 /* GPH0/1/2/3 RS232 serial port
552 * GPH4/5 IrDA serial port
553 * GPH6/7 N30 BlueTooth serial port
554 * N35/PiN GPS receiver
555 * GPH8 input -- unknown function
556 * GPH9 CLKOUT0 HCLK -- unknown use
557 * GPH10 CLKOUT1 FCLK -- unknown use
559 * The pull ups for H6/H7 are enabled on N30 but not on the
560 * N35/PiN. I suppose is useful for a budget model of the N30
561 * with no bluetooth. It doesn't hurt to have the pull ups
562 * enabled on the N35, so leave them enabled for all models.
564 __raw_writel(0x0028aaaa, S3C2410_GPHCON
);
565 __raw_writel(0x000005ef, S3C2410_GPHDAT
);
566 __raw_writel(0x0000063f, S3C2410_GPHUP
);
569 static void __init
n30_map_io(void)
571 s3c24xx_init_io(n30_iodesc
, ARRAY_SIZE(n30_iodesc
));
573 s3c24xx_init_uarts(n30_uartcfgs
, ARRAY_SIZE(n30_uartcfgs
));
574 samsung_set_timer_source(SAMSUNG_PWM3
, SAMSUNG_PWM4
);
577 static void __init
n30_init_time(void)
579 s3c2410_init_clocks(12000000);
580 samsung_timer_init();
583 /* GPB3 is the line that controls the pull-up for the USB D+ line */
585 static void __init
n30_init(void)
587 WARN_ON(gpio_request(S3C2410_GPG(4), "mmc power"));
589 s3c24xx_fb_set_platdata(&n30_fb_info
);
590 s3c24xx_udc_set_platdata(&n30_udc_cfg
);
591 gpiod_add_lookup_table(&n30_mci_gpio_table
);
592 s3c24xx_mci_set_platdata(&n30_mci_cfg
);
593 s3c_i2c0_set_platdata(&n30_i2ccfg
);
595 /* Turn off suspend on both USB ports, and switch the
596 * selectable USB port to USB device mode. */
598 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
599 S3C2410_MISCCR_USBSUSPND0
|
600 S3C2410_MISCCR_USBSUSPND1
, 0x0);
602 if (machine_is_n30()) {
603 /* Turn off suspend on both USB ports, and switch the
604 * selectable USB port to USB device mode. */
605 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
606 S3C2410_MISCCR_USBSUSPND0
|
607 S3C2410_MISCCR_USBSUSPND1
, 0x0);
609 /* Disable pull-up and add GPIO tables */
610 s3c_gpio_setpull(S3C2410_GPG(6), S3C_GPIO_PULL_NONE
);
611 s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE
);
612 gpiod_add_lookup_table(&n30_blue_led_gpio_table
);
613 gpiod_add_lookup_table(&n30_warning_led_gpio_table
);
615 platform_add_devices(n30_devices
, ARRAY_SIZE(n30_devices
));
618 if (machine_is_n35()) {
619 /* Turn off suspend and switch the selectable USB port
620 * to USB device mode. Turn on suspend for the host
621 * port since it is not connected on the N35.
623 * Actually, the host port is available at some pads
624 * on the back of the device, so it would actually be
625 * possible to add a USB device inside the N35 if you
626 * are willing to do some hardware modifications. */
627 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
628 S3C2410_MISCCR_USBSUSPND0
|
629 S3C2410_MISCCR_USBSUSPND1
,
630 S3C2410_MISCCR_USBSUSPND0
);
632 /* Disable pull-up and add GPIO tables */
633 s3c_gpio_setpull(S3C2410_GPD(8), S3C_GPIO_PULL_NONE
);
634 s3c_gpio_setpull(S3C2410_GPD(9), S3C_GPIO_PULL_NONE
);
635 gpiod_add_lookup_table(&n35_blue_led_gpio_table
);
636 gpiod_add_lookup_table(&n35_warning_led_gpio_table
);
638 platform_add_devices(n35_devices
, ARRAY_SIZE(n35_devices
));
642 MACHINE_START(N30
, "Acer-N30")
643 /* Maintainer: Christer Weinigel <christer@weinigel.se>,
644 Ben Dooks <ben-linux@fluff.org>
646 .atag_offset
= 0x100,
647 .init_time
= n30_init_time
,
648 .init_machine
= n30_init
,
649 .init_irq
= s3c2410_init_irq
,
650 .map_io
= n30_map_io
,
653 MACHINE_START(N35
, "Acer-N35")
654 /* Maintainer: Christer Weinigel <christer@weinigel.se>
656 .atag_offset
= 0x100,
657 .init_time
= n30_init_time
,
658 .init_machine
= n30_init
,
659 .init_irq
= s3c2410_init_irq
,
660 .map_io
= n30_map_io
,