1 /* linux/arch/arm/mach-s3c2440/mach-rx1950.c
3 * Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev,
4 * Copyright (c) 2007-2010 Vasily Khoruzhick
6 * based on smdk2440 written by Ben Dooks
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/list.h>
18 #include <linux/memblock.h>
19 #include <linux/delay.h>
20 #include <linux/timer.h>
21 #include <linux/init.h>
22 #include <linux/gpio.h>
23 #include <linux/platform_device.h>
24 #include <linux/serial_core.h>
25 #include <linux/input.h>
26 #include <linux/gpio_keys.h>
27 #include <linux/sysdev.h>
28 #include <linux/pwm_backlight.h>
29 #include <linux/pwm.h>
31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/partitions.h>
34 #include <linux/mmc/host.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/map.h>
38 #include <asm/mach-types.h>
40 #include <mach/regs-gpio.h>
41 #include <mach/regs-gpioj.h>
42 #include <mach/h1940.h>
45 #include <plat/clock.h>
46 #include <plat/regs-serial.h>
47 #include <plat/regs-iic.h>
50 #include <plat/nand.h>
52 #include <plat/devs.h>
58 #define LCD_PWM_PERIOD 192960
59 #define LCD_PWM_DUTY 127353
61 static struct map_desc rx1950_iodesc[] __initdata = {
64 static struct s3c24xx_uart_clksrc rx1950_serial_clocks[] = {
73 static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = {
80 .clocks = rx1950_serial_clocks,
81 .clocks_size = ARRAY_SIZE(rx1950_serial_clocks),
89 .clocks = rx1950_serial_clocks,
90 .clocks_size = ARRAY_SIZE(rx1950_serial_clocks),
99 .clocks = rx1950_serial_clocks,
100 .clocks_size = ARRAY_SIZE(rx1950_serial_clocks),
104 static struct s3c2410fb_display rx1950_display = {
105 .type = S3C2410_LCDCON1_TFT,
120 .lcdcon5 = S3C2410_LCDCON5_FRM565 |
121 S3C2410_LCDCON5_INVVCLK |
122 S3C2410_LCDCON5_INVVLINE |
123 S3C2410_LCDCON5_INVVFRAME |
124 S3C2410_LCDCON5_HWSWP |
130 static struct s3c2410fb_mach_info rx1950_lcd_cfg = {
131 .displays = &rx1950_display,
133 .default_display = 0,
136 .gpccon = 0xaa9556a9,
137 .gpccon_mask = 0xffc003fc,
139 .gpcup_mask = 0xffffffff,
141 .gpdcon = 0xaa90aaa1,
142 .gpdcon_mask = 0xffc0fff0,
144 .gpdup_mask = 0xffffffff,
148 static struct pwm_device *lcd_pwm;
150 void rx1950_lcd_power(int enable)
154 if (enabled == enable)
158 /* GPC11-GPC15->OUTPUT */
159 for (i = 11; i < 16; i++)
160 gpio_direction_output(S3C2410_GPC(i), 1);
162 /* Wait a bit here... */
165 /* GPD2-GPD7->OUTPUT */
166 /* GPD11-GPD15->OUTPUT */
167 /* GPD2-GPD7->1, GPD11-GPD15->1 */
168 for (i = 2; i < 8; i++)
169 gpio_direction_output(S3C2410_GPD(i), 1);
170 for (i = 11; i < 16; i++)
171 gpio_direction_output(S3C2410_GPD(i), 1);
173 /* Wait a bit here...*/
176 /* GPB0->OUTPUT, GPB0->0 */
177 gpio_direction_output(S3C2410_GPB(0), 0);
179 /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
180 for (i = 1; i < 5; i++)
181 gpio_direction_output(S3C2410_GPC(i), 0);
184 for (i = 11; i < 16; i++)
185 gpio_direction_output(S3C2410_GPC(i), 0);
187 /* GPD15-GPD11->0, GPD2->GPD7->0 */
188 for (i = 11; i < 16; i++)
189 gpio_direction_output(S3C2410_GPD(i), 0);
191 for (i = 2; i < 8; i++)
192 gpio_direction_output(S3C2410_GPD(i), 0);
194 /* GPC6->0, GPC7->0, GPC5->0 */
195 gpio_direction_output(S3C2410_GPC(6), 0);
196 gpio_direction_output(S3C2410_GPC(7), 0);
197 gpio_direction_output(S3C2410_GPC(5), 0);
199 /* GPB1->OUTPUT, GPB1->0 */
200 gpio_direction_output(S3C2410_GPB(1), 0);
201 pwm_config(lcd_pwm, 0, LCD_PWM_PERIOD);
202 pwm_disable(lcd_pwm);
204 /* GPC0->0, GPC10->0 */
205 gpio_direction_output(S3C2410_GPC(0), 0);
206 gpio_direction_output(S3C2410_GPC(10), 0);
208 pwm_config(lcd_pwm, LCD_PWM_DUTY, LCD_PWM_PERIOD);
211 gpio_direction_output(S3C2410_GPC(0), 1);
212 gpio_direction_output(S3C2410_GPC(5), 1);
214 s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1);
215 gpio_direction_output(S3C2410_GPC(7), 1);
217 for (i = 1; i < 5; i++)
218 s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
220 for (i = 11; i < 16; i++)
221 s3c_gpio_cfgpin(S3C2410_GPC(i), S3C_GPIO_SFN(2));
223 for (i = 2; i < 8; i++)
224 s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
226 for (i = 11; i < 16; i++)
227 s3c_gpio_cfgpin(S3C2410_GPD(i), S3C_GPIO_SFN(2));
229 gpio_direction_output(S3C2410_GPC(10), 1);
230 gpio_direction_output(S3C2410_GPC(6), 1);
235 static void rx1950_bl_power(int enable)
238 if (enabled == enable)
241 gpio_direction_output(S3C2410_GPB(0), 0);
243 /* LED driver need a "push" to power on */
244 gpio_direction_output(S3C2410_GPB(0), 1);
245 /* Warm up backlight for one period of PWM.
246 * Without this trick its almost impossible to
247 * enable backlight with low brightness value
250 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);
255 static int rx1950_backlight_init(struct device *dev)
257 WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
258 lcd_pwm = pwm_request(1, "RX1950 LCD");
259 if (IS_ERR(lcd_pwm)) {
260 dev_err(dev, "Unable to request PWM for LCD power!\n");
261 return PTR_ERR(lcd_pwm);
270 static void rx1950_backlight_exit(struct device *dev)
276 gpio_free(S3C2410_GPB(0));
280 static int rx1950_backlight_notify(struct device *dev, int brightness)
292 static struct platform_pwm_backlight_data rx1950_backlight_data = {
294 .max_brightness = 24,
296 .pwm_period_ns = 48000,
297 .init = rx1950_backlight_init,
298 .notify = rx1950_backlight_notify,
299 .exit = rx1950_backlight_exit,
302 static struct platform_device rx1950_backlight = {
303 .name = "pwm-backlight",
305 .parent = &s3c_device_timer[0].dev,
306 .platform_data = &rx1950_backlight_data,
310 static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
312 switch (power_mode) {
314 gpio_direction_output(S3C2410_GPJ(1), 0);
318 gpio_direction_output(S3C2410_GPJ(1), 1);
325 static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = {
326 .gpio_detect = S3C2410_GPF(5),
327 .gpio_wprotect = S3C2410_GPH(8),
328 .set_power = rx1950_set_mmc_power,
329 .ocr_avail = MMC_VDD_32_33,
332 static struct mtd_partition rx1950_nand_part[] = {
337 .mask_flags = MTD_WRITEABLE,
341 .offset = MTDPART_OFS_APPEND,
343 .mask_flags = MTD_WRITEABLE,
347 .offset = MTDPART_OFS_APPEND,
352 .name = "Filesystem",
353 .offset = MTDPART_OFS_APPEND,
354 .size = MTDPART_SIZ_FULL,
359 static struct s3c2410_nand_set rx1950_nand_sets[] = {
363 .nr_partitions = ARRAY_SIZE(rx1950_nand_part),
364 .partitions = rx1950_nand_part,
368 static struct s3c2410_platform_nand rx1950_nand_info = {
372 .nr_sets = ARRAY_SIZE(rx1950_nand_sets),
373 .sets = rx1950_nand_sets,
376 static void rx1950_udc_pullup(enum s3c2410_udc_cmd_e cmd)
379 case S3C2410_UDC_P_ENABLE:
380 gpio_direction_output(S3C2410_GPJ(5), 1);
382 case S3C2410_UDC_P_DISABLE:
383 gpio_direction_output(S3C2410_GPJ(5), 0);
385 case S3C2410_UDC_P_RESET:
392 static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = {
393 .udc_command = rx1950_udc_pullup,
394 .vbus_pin = S3C2410_GPG(5),
395 .vbus_pin_inverted = 1,
398 static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata = {
401 .oversampling_shift = 3,
404 static struct gpio_keys_button rx1950_gpio_keys_table[] = {
407 .gpio = S3C2410_GPF(0),
409 .desc = "Power button",
414 .gpio = S3C2410_GPF(7),
416 .desc = "Record button",
420 .gpio = S3C2410_GPG(0),
422 .desc = "Calendar button",
426 .gpio = S3C2410_GPG(2),
428 .desc = "Contacts button",
432 .gpio = S3C2410_GPG(3),
434 .desc = "Mail button",
438 .gpio = S3C2410_GPG(7),
440 .desc = "WLAN button",
444 .gpio = S3C2410_GPG(10),
446 .desc = "Left button",
450 .gpio = S3C2410_GPG(11),
452 .desc = "Right button",
456 .gpio = S3C2410_GPG(4),
462 .gpio = S3C2410_GPG(6),
464 .desc = "Down button",
468 .gpio = S3C2410_GPG(9),
474 static struct gpio_keys_platform_data rx1950_gpio_keys_data = {
475 .buttons = rx1950_gpio_keys_table,
476 .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table),
479 static struct platform_device rx1950_device_gpiokeys = {
481 .dev.platform_data = &rx1950_gpio_keys_data,
484 static struct s3c2410_platform_i2c rx1950_i2c_data = {
487 .frequency = 400 * 1000,
488 .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON,
491 static struct platform_device *rx1950_devices[] __initdata = {
496 &s3c_device_usbgadget,
502 &s3c_device_timer[0],
503 &s3c_device_timer[1],
505 &rx1950_device_gpiokeys,
508 static struct clk *rx1950_clocks[] __initdata = {
513 static void __init rx1950_map_io(void)
515 s3c24xx_clkout0.parent = &clk_h;
516 s3c24xx_clkout1.parent = &clk_f;
518 s3c24xx_register_clocks(rx1950_clocks, ARRAY_SIZE(rx1950_clocks));
520 s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc));
521 s3c24xx_init_clocks(16934000);
522 s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs));
526 #ifdef CONFIG_PM_H1940
527 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8);
533 static void __init rx1950_init_machine(void)
537 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg);
538 s3c24xx_udc_set_platdata(&rx1950_udc_cfg);
539 s3c24xx_ts_set_platdata(&rx1950_ts_cfg);
540 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg);
541 s3c_i2c0_set_platdata(&rx1950_i2c_data);
542 s3c_nand_set_platdata(&rx1950_nand_info);
544 /* Turn off suspend on both USB ports, and switch the
545 * selectable USB port to USB device mode. */
546 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST |
547 S3C2410_MISCCR_USBSUSPND0 |
548 S3C2410_MISCCR_USBSUSPND1, 0x0);
550 WARN_ON(gpio_request(S3C2410_GPJ(5), "UDC pullup"));
551 gpio_direction_output(S3C2410_GPJ(5), 0);
553 /* mmc power is disabled by default */
554 WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
555 gpio_direction_output(S3C2410_GPJ(1), 0);
557 for (i = 0; i < 8; i++)
558 WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
560 for (i = 10; i < 16; i++)
561 WARN_ON(gpio_request(S3C2410_GPC(i), "LCD power"));
563 for (i = 2; i < 8; i++)
564 WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
566 for (i = 11; i < 16; i++)
567 WARN_ON(gpio_request(S3C2410_GPD(i), "LCD power"));
569 WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
571 platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices));
574 /* H1940 and RX3715 need to reserve this for suspend */
575 static void __init rx1950_reserve(void)
577 memblock_reserve(0x30003000, 0x1000);
578 memblock_reserve(0x30081000, 0x1000);
581 MACHINE_START(RX1950, "HP iPAQ RX1950")
582 /* Maintainers: Vasily Khoruzhick */
583 .phys_io = S3C2410_PA_UART,
584 .io_pg_offst = (((u32) S3C24XX_VA_UART) >> 18) & 0xfffc,
585 .boot_params = S3C2410_SDRAM_PA + 0x100,
586 .map_io = rx1950_map_io,
587 .reserve = rx1950_reserve,
588 .init_irq = s3c24xx_init_irq,
589 .init_machine = rx1950_init_machine,
590 .timer = &s3c24xx_timer,