From 1490cd5bd21d387b122332edfb2537437d3cb1f3 Mon Sep 17 00:00:00 2001 From: Vasily Khoruzhick Date: Thu, 24 Sep 2009 21:58:36 +0300 Subject: [PATCH v2 2/5] Add basic HP iPAQ rx1950 support Signed-off-by: Vasily Khoruzhick --- arch/arm/mach-s3c2442/Kconfig | 10 + arch/arm/mach-s3c2442/Makefile | 2 +- arch/arm/mach-s3c2442/mach-rx1950.c | 368 +++++++++++++++++++++++++++++++++++ 3 files changed, 379 insertions(+), 1 deletions(-) create mode 100644 arch/arm/mach-s3c2442/mach-rx1950.c diff --git a/arch/arm/mach-s3c2442/Kconfig b/arch/arm/mach-s3c2442/Kconfig index 103e913..e12faf4 100644 --- a/arch/arm/mach-s3c2442/Kconfig +++ b/arch/arm/mach-s3c2442/Kconfig @@ -36,6 +36,16 @@ config MACH_NEO1973_GTA02 help Say Y here if you are using the Openmoko GTA02 / Freerunner GSM Phone +config MACH_RX1950 + bool "HP iPAQ rx1950" + select CPU_S3C2442 + select PM_H1940 if PM + select I2C + select S3C2410_PWM + select S3C2410_IOTIMING if S3C2440_CPUFREQ + select S3C2440_XTAL_16934400 + help + Say Y here if you're using HP iPAQ rx1950 endmenu diff --git a/arch/arm/mach-s3c2442/Makefile b/arch/arm/mach-s3c2442/Makefile index 2a19113..e40caa8 100644 --- a/arch/arm/mach-s3c2442/Makefile +++ b/arch/arm/mach-s3c2442/Makefile @@ -13,6 +13,6 @@ obj-$(CONFIG_CPU_S3C2442) += s3c2442.o obj-$(CONFIG_CPU_S3C2442) += clock.o obj-$(CONFIG_MACH_NEO1973_GTA02) += mach-gta02.o - +obj-$(CONFIG_MACH_RX1950) += mach-rx1950.o # Machine support diff --git a/arch/arm/mach-s3c2442/mach-rx1950.c b/arch/arm/mach-s3c2442/mach-rx1950.c new file mode 100644 index 0000000..c1390ba --- /dev/null +++ b/arch/arm/mach-s3c2442/mach-rx1950.c @@ -0,0 +1,368 @@ +/* linux/arch/arm/mach-s3c2440/mach-rx1950.c + * + * Copyright (c) 2006-2009 Victor Chukhantsev, Denis Grigoriev, + * Copyright (c) 2007-2009 Vasily Khoruzhick + * + * based on smdk2440 written by Ben Dooks + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static struct map_desc rx1950_iodesc[] __initdata = { + /* ISA IO Space map (memory space selected by A24) */ + { + .virtual = (u32) S3C24XX_VA_ISA_WORD, + .pfn = __phys_to_pfn(S3C2410_CS2), + .length = 0x10000, + .type = MT_DEVICE, + }, + { + .virtual = (u32) S3C24XX_VA_ISA_WORD + 0x10000, + .pfn = __phys_to_pfn(S3C2410_CS2 + (1 << 24)), + .length = SZ_4M, + .type = MT_DEVICE, + }, +}; + +static struct s3c24xx_uart_clksrc rx1950_serial_clocks[] = { + [0] = { + .name = "fclk", + .divisor = 0x0a, + .min_baud = 0, + .max_baud = 0, + } +}; + +static struct s3c2410_uartcfg rx1950_uartcfgs[] __initdata = { + [0] = { + .hwport = 0, + .flags = 0, + .ucon = 0x3c5, + .ulcon = 0x03, + .ufcon = 0x51, + .clocks = rx1950_serial_clocks, + .clocks_size = ARRAY_SIZE(rx1950_serial_clocks), + }, + [1] = { + .hwport = 1, + .flags = 0, + .ucon = 0x3c5, + .ulcon = 0x03, + .ufcon = 0x51, + .clocks = rx1950_serial_clocks, + .clocks_size = ARRAY_SIZE(rx1950_serial_clocks), + }, + /* IR port */ + [2] = { + .hwport = 2, + .flags = 0, + .ucon = 0x3c5, + .ulcon = 0x43, + .ufcon = 0xf1, + .clocks = rx1950_serial_clocks, + .clocks_size = ARRAY_SIZE(rx1950_serial_clocks), + } +}; + +static struct s3c2410fb_display rx1950_display = { + .type = S3C2410_LCDCON1_TFT, + .width = 240, + .height = 320, + .xres = 240, + .yres = 320, + .bpp = 16, + + .pixclock = 260000, + .left_margin = 10, + .right_margin = 20, + .hsync_len = 10, + .upper_margin = 2, + .lower_margin = 2, + .vsync_len = 2, + + .lcdcon5 = S3C2410_LCDCON5_FRM565 | + S3C2410_LCDCON5_INVVCLK | + S3C2410_LCDCON5_INVVLINE | + S3C2410_LCDCON5_INVVFRAME | + S3C2410_LCDCON5_HWSWP | + (0x02 << 13) | + (0x02 << 15), + +}; + +static struct s3c2410fb_mach_info rx1950_lcd_cfg = { + .displays = &rx1950_display, + .num_displays = 1, + .default_display = 0, + + .lpcsel = 0x02, + .gpccon = 0xaa9556a9, + .gpccon_mask = 0xFFC003FC, + .gpcup = 0x0000ffff, + .gpcup_mask = 0xffffffff, + + .gpdcon = 0xaa90aaa1, + .gpdcon_mask = 0xFFC0FFF0, + .gpdup = 0x0000fcfd, + .gpdup_mask = 0xffffffff, + +}; + +static int rx1950_backlight_notify(int brightness) +{ + static int disabled = 1; + if (!brightness) { + if (!disabled) { + s3c2410_gpio_setpin(S3C2410_GPB(0), 0); + s3c2410_gpio_pullup(S3C2410_GPB(0), 0); + s3c2410_gpio_cfgpin(S3C2410_GPB(0), + S3C2410_GPIO_OUTPUT); + } + disabled = 1; + } else { + if (disabled) { + /* LED driver need a "push" to power on */ + s3c2410_gpio_setpin(S3C2410_GPB(0), 1); + s3c2410_gpio_pullup(S3C2410_GPB(0), 1); + /* Warm up backlight for one period of PWM. + * Without this trick its almost impossible to + * enable backlight + */ + ndelay(48000); + s3c2410_gpio_cfgpin(S3C2410_GPB(0), + S3C2410_GPB0_TOUT0); + } + disabled = 0; + } + return brightness; +} + +static struct platform_pwm_backlight_data rx1950_backlight_data = { + .pwm_id = 0, + .max_brightness = 24, + .dft_brightness = 4, + .pwm_period_ns = 48000, + .notify = rx1950_backlight_notify, +}; + +static struct platform_device rx1950_backlight = { + .name = "pwm-backlight", + .dev = { + .parent = &s3c_device_timer[0].dev, + .platform_data = &rx1950_backlight_data, + }, +}; + +static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd) +{ + s3c2410_gpio_cfgpin(S3C2440_GPJ1, S3C2410_GPIO_OUTPUT); + switch (power_mode) { + case MMC_POWER_OFF: + s3c2410_gpio_setpin(S3C2440_GPJ1, 0); + break; + case MMC_POWER_UP: + case MMC_POWER_ON: + s3c2410_gpio_setpin(S3C2440_GPJ1, 1); + break; + default: + break; + } +} + +static struct s3c24xx_mci_pdata rx1950_mmc_cfg = { + .gpio_detect = S3C2410_GPF(5), + .set_power = rx1950_set_mmc_power, + .ocr_avail = MMC_VDD_32_33, +}; + +static struct mtd_partition rx1950_nand_part[] = { + [0] = { + .name = "Whole Flash", + .offset = 0, + .size = MTDPART_SIZ_FULL, + .mask_flags = MTD_WRITEABLE, + } +}; + +static struct s3c2410_nand_set rx1950_nand_sets[] = { + [0] = { + .name = "Internal", + .nr_chips = 1, + .nr_partitions = ARRAY_SIZE(rx1950_nand_part), + .partitions = rx1950_nand_part, + }, +}; + +static struct s3c2410_platform_nand rx1950_nand_info = { + .tacls = 25, + .twrph0 = 50, + .twrph1 = 15, + .nr_sets = ARRAY_SIZE(rx1950_nand_sets), + .sets = rx1950_nand_sets, +}; + +static void rx1950_udc_pullup(enum s3c2410_udc_cmd_e cmd) +{ + switch (cmd) { + case S3C2410_UDC_P_ENABLE: + s3c2410_gpio_setpin(S3C2440_GPJ5, 1); + break; + case S3C2410_UDC_P_DISABLE: + s3c2410_gpio_setpin(S3C2440_GPJ5, 0); + break; + case S3C2410_UDC_P_RESET: + break; + default: + break; + } +} + +static struct s3c2410_udc_mach_info rx1950_udc_cfg __initdata = { + .udc_command = rx1950_udc_pullup, + .vbus_pin = S3C2410_GPG(5), + .vbus_pin_inverted = 1, +}; + +static struct gpio_keys_button rx1950_gpio_keys_table[] = { + {KEY_POWER, S3C2410_GPF(0), 1, "Power button"}, + {KEY_A, S3C2410_GPF(7), 1, "Record button"}, + {KEY_B, S3C2410_GPG(0), 1, "Calendar button"}, + {KEY_C, S3C2410_GPG(2), 1, "Contacts button"}, + {KEY_D, S3C2410_GPG(3), 1, "Mail button"}, + {KEY_E, S3C2410_GPG(7), 1, "Home button"}, + {KEY_LEFT, S3C2410_GPG(10), 1, "Left button"}, + {KEY_RIGHT, S3C2410_GPG(11), 1, "Right button"}, + {KEY_UP, S3C2410_GPG(4), 1, "Up button"}, + {KEY_DOWN, S3C2410_GPG(6), 1, "Down button"}, + {KEY_ENTER, S3C2410_GPG(9), 1, "Ok button"}, +}; + +static struct gpio_keys_platform_data rx1950_gpio_keys_data = { + .buttons = rx1950_gpio_keys_table, + .nbuttons = ARRAY_SIZE(rx1950_gpio_keys_table), +}; + +static struct platform_device rx1950_device_gpiokeys = { + .name = "gpio-keys", + .dev = {.platform_data = &rx1950_gpio_keys_data,} +}; + +static struct s3c2410_platform_i2c rx1950_i2c_data = { + .flags = 0, + .slave_addr = 0x42, + .frequency = 400 * 1000, + .sda_delay = S3C2410_IICLC_SDA_DELAY5 | S3C2410_IICLC_FILTER_ON, +}; + +static struct platform_device *rx1950_devices[] __initdata = { + &s3c_device_usb, + &s3c_device_lcd, + &s3c_device_wdt, + &s3c_device_i2c0, + &s3c_device_iis, + &s3c_device_usbgadget, + &s3c_device_rtc, + &s3c_device_nand, + &s3c_device_sdi, + &s3c_device_adc, + &s3c_device_timer[0], + /* FIXME: uncomment this after adding + * proper backlight support + &s3c_device_timer[1], + */ + &rx1950_backlight, + &rx1950_device_gpiokeys, +}; + +static void __init rx1950_map_io(void) +{ + s3c_device_nand.dev.platform_data = &rx1950_nand_info; + s3c24xx_init_io(rx1950_iodesc, ARRAY_SIZE(rx1950_iodesc)); + s3c24xx_init_clocks(16934000); + s3c24xx_init_uarts(rx1950_uartcfgs, ARRAY_SIZE(rx1950_uartcfgs)); +} + +static void __init rx1950_init_machine(void) +{ +#ifdef CONFIG_PM_H1940 + memcpy(phys_to_virt(H1940_SUSPEND_RESUMEAT), h1940_pm_return, 8); +#endif + s3c24xx_fb_set_platdata(&rx1950_lcd_cfg); + s3c_device_sdi.dev.platform_data = &rx1950_mmc_cfg; + s3c_device_i2c0.dev.platform_data = &rx1950_i2c_data; + + /* Configuring udc pullup */ + s3c2410_gpio_cfgpin(S3C2440_GPJ5, S3C2410_GPIO_OUTPUT); + + /* Configuring mmc ro sense pin */ + s3c2410_gpio_cfgpin(S3C2410_GPH(8), S3C2410_GPIO_INPUT); + /* Configuring mmc power pin */ + s3c2410_gpio_setpin(S3C2440_GPJ1, S3C2410_GPIO_OUTPUT); + /* mmc power is disabled by default */ + s3c2410_gpio_setpin(S3C2440_GPJ1, 0); + + /* Configuring udc vbus pin */ + s3c2410_gpio_setpin(S3C2410_GPG(5), S3C2410_GPG5_EINT13); + + /* Some udc magic */ + s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST | + S3C2410_MISCCR_USBSUSPND0 | + S3C2410_MISCCR_USBSUSPND1, 0x0); + + s3c24xx_udc_set_platdata(&rx1950_udc_cfg); + + platform_add_devices(rx1950_devices, ARRAY_SIZE(rx1950_devices)); + + s3c_pm_init(); + s3c_irq_wake(IRQ_EINT0, 1); +} + +MACHINE_START(RX1950, "HP iPAQ RX1950") + /* Maintainers: Denis Grigoriev, Vasily Khoruzhick */ + .phys_io = S3C2410_PA_UART, + .io_pg_offst = (((u32) S3C24XX_VA_UART) >> 18) & 0xfffc, + .boot_params = S3C2410_SDRAM_PA + 0x100, + .map_io = rx1950_map_io, + .init_irq = s3c24xx_init_irq, + .init_machine = rx1950_init_machine, + .timer = &s3c24xx_timer, +MACHINE_END -- 1.6.5.rc1