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/delay.h>
19 #include <linux/timer.h>
20 #include <linux/init.h>
21 #include <linux/gpio.h>
22 #include <linux/platform_device.h>
23 #include <linux/serial_core.h>
24 #include <linux/input.h>
25 #include <linux/gpio_keys.h>
26 #include <linux/sysdev.h>
27 #include <linux/pwm_backlight.h>
28 #include <linux/pwm.h>
30 #include <linux/mtd/mtd.h>
31 #include <linux/mtd/partitions.h>
33 #include <linux/mmc/host.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach-types.h>
39 #include <mach/regs-gpio.h>
40 #include <mach/regs-gpioj.h>
41 #include <mach/h1940.h>
44 #include <plat/clock.h>
45 #include <plat/regs-serial.h>
46 #include <plat/regs-iic.h>
49 #include <plat/nand.h>
51 #include <plat/devs.h>
57 #define LCD_PWM_PERIOD 192960
58 #define LCD_PWM_DUTY 127353
60 static struct map_desc rx1950_iodesc
[] __initdata
= {
63 static struct s3c24xx_uart_clksrc rx1950_serial_clocks
[] = {
72 static struct s3c2410_uartcfg rx1950_uartcfgs
[] __initdata
= {
79 .clocks
= rx1950_serial_clocks
,
80 .clocks_size
= ARRAY_SIZE(rx1950_serial_clocks
),
88 .clocks
= rx1950_serial_clocks
,
89 .clocks_size
= ARRAY_SIZE(rx1950_serial_clocks
),
98 .clocks
= rx1950_serial_clocks
,
99 .clocks_size
= ARRAY_SIZE(rx1950_serial_clocks
),
103 static struct s3c2410fb_display rx1950_display
= {
104 .type
= S3C2410_LCDCON1_TFT
,
119 .lcdcon5
= S3C2410_LCDCON5_FRM565
|
120 S3C2410_LCDCON5_INVVCLK
|
121 S3C2410_LCDCON5_INVVLINE
|
122 S3C2410_LCDCON5_INVVFRAME
|
123 S3C2410_LCDCON5_HWSWP
|
129 static struct s3c2410fb_mach_info rx1950_lcd_cfg
= {
130 .displays
= &rx1950_display
,
132 .default_display
= 0,
135 .gpccon
= 0xaa9556a9,
136 .gpccon_mask
= 0xffc003fc,
138 .gpcup_mask
= 0xffffffff,
140 .gpdcon
= 0xaa90aaa1,
141 .gpdcon_mask
= 0xffc0fff0,
143 .gpdup_mask
= 0xffffffff,
147 static struct pwm_device
*lcd_pwm
;
149 void rx1950_lcd_power(int enable
)
153 if (enabled
== enable
)
157 /* GPC11-GPC15->OUTPUT */
158 for (i
= 11; i
< 16; i
++)
159 gpio_direction_output(S3C2410_GPC(i
), 1);
161 /* Wait a bit here... */
164 /* GPD2-GPD7->OUTPUT */
165 /* GPD11-GPD15->OUTPUT */
166 /* GPD2-GPD7->1, GPD11-GPD15->1 */
167 for (i
= 2; i
< 8; i
++)
168 gpio_direction_output(S3C2410_GPD(i
), 1);
169 for (i
= 11; i
< 16; i
++)
170 gpio_direction_output(S3C2410_GPD(i
), 1);
172 /* Wait a bit here...*/
175 /* GPB0->OUTPUT, GPB0->0 */
176 gpio_direction_output(S3C2410_GPB(0), 0);
178 /* GPC1-GPC4->OUTPUT, GPC1-4->0 */
179 for (i
= 1; i
< 5; i
++)
180 gpio_direction_output(S3C2410_GPC(i
), 0);
183 for (i
= 11; i
< 16; i
++)
184 gpio_direction_output(S3C2410_GPC(i
), 0);
186 /* GPD15-GPD11->0, GPD2->GPD7->0 */
187 for (i
= 11; i
< 16; i
++)
188 gpio_direction_output(S3C2410_GPD(i
), 0);
190 for (i
= 2; i
< 8; i
++)
191 gpio_direction_output(S3C2410_GPD(i
), 0);
193 /* GPC6->0, GPC7->0, GPC5->0 */
194 gpio_direction_output(S3C2410_GPC(6), 0);
195 gpio_direction_output(S3C2410_GPC(7), 0);
196 gpio_direction_output(S3C2410_GPC(5), 0);
198 /* GPB1->OUTPUT, GPB1->0 */
199 gpio_direction_output(S3C2410_GPB(1), 0);
200 pwm_config(lcd_pwm
, 0, LCD_PWM_PERIOD
);
201 pwm_disable(lcd_pwm
);
203 /* GPC0->0, GPC10->0 */
204 gpio_direction_output(S3C2410_GPC(0), 0);
205 gpio_direction_output(S3C2410_GPC(10), 0);
207 pwm_config(lcd_pwm
, LCD_PWM_DUTY
, LCD_PWM_PERIOD
);
210 gpio_direction_output(S3C2410_GPC(0), 1);
211 gpio_direction_output(S3C2410_GPC(5), 1);
213 s3c_gpio_cfgpin(S3C2410_GPB(1), S3C2410_GPB1_TOUT1
);
214 gpio_direction_output(S3C2410_GPC(7), 1);
216 for (i
= 1; i
< 5; i
++)
217 s3c_gpio_cfgpin(S3C2410_GPC(i
), S3C_GPIO_SFN(2));
219 for (i
= 11; i
< 16; i
++)
220 s3c_gpio_cfgpin(S3C2410_GPC(i
), S3C_GPIO_SFN(2));
222 for (i
= 2; i
< 8; i
++)
223 s3c_gpio_cfgpin(S3C2410_GPD(i
), S3C_GPIO_SFN(2));
225 for (i
= 11; i
< 16; i
++)
226 s3c_gpio_cfgpin(S3C2410_GPD(i
), S3C_GPIO_SFN(2));
228 gpio_direction_output(S3C2410_GPC(10), 1);
229 gpio_direction_output(S3C2410_GPC(6), 1);
234 static void rx1950_bl_power(int enable
)
237 if (enabled
== enable
)
240 gpio_direction_output(S3C2410_GPB(0), 0);
242 /* LED driver need a "push" to power on */
243 gpio_direction_output(S3C2410_GPB(0), 1);
244 /* Warm up backlight for one period of PWM.
245 * Without this trick its almost impossible to
246 * enable backlight with low brightness value
249 s3c_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0
);
254 static int rx1950_backlight_init(struct device
*dev
)
256 WARN_ON(gpio_request(S3C2410_GPB(0), "Backlight"));
257 lcd_pwm
= pwm_request(1, "RX1950 LCD");
258 if (IS_ERR(lcd_pwm
)) {
259 dev_err(dev
, "Unable to request PWM for LCD power!\n");
260 return PTR_ERR(lcd_pwm
);
269 static void rx1950_backlight_exit(struct device
*dev
)
275 gpio_free(S3C2410_GPB(0));
279 static int rx1950_backlight_notify(struct device
*dev
, int brightness
)
291 static struct platform_pwm_backlight_data rx1950_backlight_data
= {
293 .max_brightness
= 24,
295 .pwm_period_ns
= 48000,
296 .init
= rx1950_backlight_init
,
297 .notify
= rx1950_backlight_notify
,
298 .exit
= rx1950_backlight_exit
,
301 static struct platform_device rx1950_backlight
= {
302 .name
= "pwm-backlight",
304 .parent
= &s3c_device_timer
[0].dev
,
305 .platform_data
= &rx1950_backlight_data
,
309 static void rx1950_set_mmc_power(unsigned char power_mode
, unsigned short vdd
)
311 switch (power_mode
) {
313 gpio_direction_output(S3C2410_GPJ(1), 0);
317 gpio_direction_output(S3C2410_GPJ(1), 1);
324 static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata
= {
325 .gpio_detect
= S3C2410_GPF(5),
326 .gpio_wprotect
= S3C2410_GPH(8),
327 .set_power
= rx1950_set_mmc_power
,
328 .ocr_avail
= MMC_VDD_32_33
,
331 static struct mtd_partition rx1950_nand_part
[] = {
336 .mask_flags
= MTD_WRITEABLE
,
340 .offset
= MTDPART_OFS_APPEND
,
342 .mask_flags
= MTD_WRITEABLE
,
346 .offset
= MTDPART_OFS_APPEND
,
351 .name
= "Filesystem",
352 .offset
= MTDPART_OFS_APPEND
,
353 .size
= MTDPART_SIZ_FULL
,
358 static struct s3c2410_nand_set rx1950_nand_sets
[] = {
362 .nr_partitions
= ARRAY_SIZE(rx1950_nand_part
),
363 .partitions
= rx1950_nand_part
,
367 static struct s3c2410_platform_nand rx1950_nand_info
= {
371 .nr_sets
= ARRAY_SIZE(rx1950_nand_sets
),
372 .sets
= rx1950_nand_sets
,
375 static void rx1950_udc_pullup(enum s3c2410_udc_cmd_e cmd
)
378 case S3C2410_UDC_P_ENABLE
:
379 gpio_direction_output(S3C2410_GPJ(5), 1);
381 case S3C2410_UDC_P_DISABLE
:
382 gpio_direction_output(S3C2410_GPJ(5), 0);
384 case S3C2410_UDC_P_RESET
:
391 static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata
= {
392 .udc_command
= rx1950_udc_pullup
,
393 .vbus_pin
= S3C2410_GPG(5),
394 .vbus_pin_inverted
= 1,
397 static struct s3c2410_ts_mach_info rx1950_ts_cfg __initdata
= {
400 .oversampling_shift
= 3,
403 static struct gpio_keys_button rx1950_gpio_keys_table
[] = {
406 .gpio
= S3C2410_GPF(0),
408 .desc
= "Power button",
413 .gpio
= S3C2410_GPF(7),
415 .desc
= "Record button",
419 .gpio
= S3C2410_GPG(0),
421 .desc
= "Calendar button",
425 .gpio
= S3C2410_GPG(2),
427 .desc
= "Contacts button",
431 .gpio
= S3C2410_GPG(3),
433 .desc
= "Mail button",
437 .gpio
= S3C2410_GPG(7),
439 .desc
= "WLAN button",
443 .gpio
= S3C2410_GPG(10),
445 .desc
= "Left button",
449 .gpio
= S3C2410_GPG(11),
451 .desc
= "Right button",
455 .gpio
= S3C2410_GPG(4),
461 .gpio
= S3C2410_GPG(6),
463 .desc
= "Down button",
467 .gpio
= S3C2410_GPG(9),
473 static struct gpio_keys_platform_data rx1950_gpio_keys_data
= {
474 .buttons
= rx1950_gpio_keys_table
,
475 .nbuttons
= ARRAY_SIZE(rx1950_gpio_keys_table
),
478 static struct platform_device rx1950_device_gpiokeys
= {
480 .dev
.platform_data
= &rx1950_gpio_keys_data
,
483 static struct s3c2410_platform_i2c rx1950_i2c_data
= {
486 .frequency
= 400 * 1000,
487 .sda_delay
= S3C2410_IICLC_SDA_DELAY5
| S3C2410_IICLC_FILTER_ON
,
490 static struct platform_device
*rx1950_devices
[] __initdata
= {
495 &s3c_device_usbgadget
,
501 &s3c_device_timer
[0],
502 &s3c_device_timer
[1],
504 &rx1950_device_gpiokeys
,
507 static struct clk
*rx1950_clocks
[] __initdata
= {
512 static void __init
rx1950_map_io(void)
514 s3c24xx_clkout0
.parent
= &clk_h
;
515 s3c24xx_clkout1
.parent
= &clk_f
;
517 s3c24xx_register_clocks(rx1950_clocks
, ARRAY_SIZE(rx1950_clocks
));
519 s3c24xx_init_io(rx1950_iodesc
, ARRAY_SIZE(rx1950_iodesc
));
520 s3c24xx_init_clocks(16934000);
521 s3c24xx_init_uarts(rx1950_uartcfgs
, ARRAY_SIZE(rx1950_uartcfgs
));
525 #ifdef CONFIG_PM_H1940
526 memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT
), h1940_pm_return
, 8);
532 static void __init
rx1950_init_machine(void)
536 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg
);
537 s3c24xx_udc_set_platdata(&rx1950_udc_cfg
);
538 s3c24xx_ts_set_platdata(&rx1950_ts_cfg
);
539 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg
);
540 s3c_i2c0_set_platdata(&rx1950_i2c_data
);
541 s3c_nand_set_platdata(&rx1950_nand_info
);
543 /* Turn off suspend on both USB ports, and switch the
544 * selectable USB port to USB device mode. */
545 s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST
|
546 S3C2410_MISCCR_USBSUSPND0
|
547 S3C2410_MISCCR_USBSUSPND1
, 0x0);
549 WARN_ON(gpio_request(S3C2410_GPJ(5), "UDC pullup"));
550 gpio_direction_output(S3C2410_GPJ(5), 0);
552 /* mmc power is disabled by default */
553 WARN_ON(gpio_request(S3C2410_GPJ(1), "MMC power"));
554 gpio_direction_output(S3C2410_GPJ(1), 0);
556 for (i
= 0; i
< 8; i
++)
557 WARN_ON(gpio_request(S3C2410_GPC(i
), "LCD power"));
559 for (i
= 10; i
< 16; i
++)
560 WARN_ON(gpio_request(S3C2410_GPC(i
), "LCD power"));
562 for (i
= 2; i
< 8; i
++)
563 WARN_ON(gpio_request(S3C2410_GPD(i
), "LCD power"));
565 for (i
= 11; i
< 16; i
++)
566 WARN_ON(gpio_request(S3C2410_GPD(i
), "LCD power"));
568 WARN_ON(gpio_request(S3C2410_GPB(1), "LCD power"));
570 platform_add_devices(rx1950_devices
, ARRAY_SIZE(rx1950_devices
));
573 MACHINE_START(RX1950
, "HP iPAQ RX1950")
574 /* Maintainers: Vasily Khoruzhick */
575 .phys_io
= S3C2410_PA_UART
,
576 .io_pg_offst
= (((u32
) S3C24XX_VA_UART
) >> 18) & 0xfffc,
577 .boot_params
= S3C2410_SDRAM_PA
+ 0x100,
578 .map_io
= rx1950_map_io
,
579 .init_irq
= s3c24xx_init_irq
,
580 .init_machine
= rx1950_init_machine
,
581 .timer
= &s3c24xx_timer
,