最近折腾了很久,总算搞定了。
发个补丁,希望大家不要再折腾了,而且也不要看网上的所谓垃圾移植指南了,都是 bullshit.
From 144759a9929f0858398b834a5cbfdb79ce56f077 Mon Sep 17 00:00:00 2001 From: microcai <microcai@fedoraproject.org> Date: Sat, 30 Apr 2011 14:28:11 +0800 Subject: [PATCH 2/4] =TQ 2440 补丁 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- arch/arm/mach-s3c2440/Kconfig | 46 +++ arch/arm/mach-s3c2440/Makefile | 1 + arch/arm/mach-s3c2440/mach-tq2440.c | 539 +++++++++++++++++++++++++++++++++++ 3 files changed, 586 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-s3c2440/mach-tq2440.c diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig index 50825a3..9afdfe5 100644 --- a/arch/arm/mach-s3c2440/Kconfig +++ b/arch/arm/mach-s3c2440/Kconfig @@ -203,4 +203,50 @@ config MACH_RX1950 help Say Y here if you're using HP iPAQ rx1950 +config MACH_TQ2440 + bool "TQ 2440" + select MACH_SMDK + select CPU_S3C2440 + select S3C_DEV_NAND + select MTD + select MTD_NAND + select MTD_NAND_S3C2410 + select S3C_DEV_USB_HOST + select RTC_DRV_S3C if RTC_CLASS + select S3C2410_WATCHDOG if WATCHDOG + select SND_SOC_SAMSUNG_S3C24XX_UDA134X if SOUND + select USB_GADGET_S3C2410 + select FB_S3C2410 if FB + select SERIAL_SAMSUNG + select SERIAL_S3C2440 + select SERIAL_SAMSUNG_CONSOLE + select SERIO + select AEABI + select BINFMT_ELF + select CPU_FREQ_S3C24XX if CPU_FREQ + select DM9000 if NETDEVICES + select DEPRECATED_PARAM_STRUCT + + help + Say Y here if you are using the TQ 2440 Machine + development system + +choice + prompt "LCD size" + default FB_S3C24X0_LCD480272 + depends on FB_S3C2410 && MACH_TQ2440 + +config FB_S3C24X0_LCD480272 + bool "4.3in LCD" + help + Support 4.3in LCD + + +config FB_S3C24X0_TFT640480 + bool "640x480 LCD" + + +endchoice + + endmenu diff --git a/arch/arm/mach-s3c2440/Makefile b/arch/arm/mach-s3c2440/Makefile index d5440fa..c001bdd 100644 --- a/arch/arm/mach-s3c2440/Makefile +++ b/arch/arm/mach-s3c2440/Makefile @@ -26,6 +26,7 @@ obj-$(CONFIG_S3C2440_PLL_16934400) += s3c2440-pll-16934400.o # Machine support +obj-$(CONFIG_MACH_TQ2440) += mach-tq2440.o obj-$(CONFIG_MACH_ANUBIS) += mach-anubis.o obj-$(CONFIG_MACH_OSIRIS) += mach-osiris.o obj-$(CONFIG_MACH_RX3715) += mach-rx3715.o diff --git a/arch/arm/mach-s3c2440/mach-tq2440.c b/arch/arm/mach-s3c2440/mach-tq2440.c new file mode 100644 index 0000000..3d1bef7 --- /dev/null +++ b/arch/arm/mach-s3c2440/mach-tq2440.c @@ -0,0 +1,539 @@ +/* linux/arch/arm/mach-s3c2440/mach-smdk2440.c + * + * Copyright (c) 2004-2005 Simtec Electronics + * Ben Dooks <ben@simtec.co.uk> + * + * http://www.fluff.org/ben/smdk2440/ + * + * Thanks to Dimity Andric and TomTom for the loan of an SMDK2440. + * + * 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 <linux/kernel.h> +#include <linux/types.h> +#include <linux/interrupt.h> +#include <linux/list.h> +#include <linux/timer.h> +#include <linux/init.h> +#include <linux/serial_core.h> +#include <linux/platform_device.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/nand.h> +#include <linux/mtd/nand_ecc.h> +#include <linux/mtd/partitions.h> +#include <linux/i2c/at24.h> +#include <linux/i2c.h> +#include <linux/io.h> +#include <linux/input.h> +#include <linux/dm9000.h> +#include <linux/gpio_keys.h> +#include <linux/mmc/host.h> +#include <sound/s3c24xx_uda134x.h> + +#include <asm/mach/arch.h> +#include <asm/mach/map.h> +#include <asm/mach/irq.h> + +#include <mach/hardware.h> +#include <asm/irq.h> +#include <asm/mach-types.h> + +#include <plat/regs-serial.h> +#include <plat/regs-adc.h> +#include <mach/regs-mem.h> +#include <plat/iic.h> +#include <plat/nand.h> +#include <plat/s3c2410.h> +#include <plat/s3c244x.h> +#include <plat/clock.h> +#include <plat/devs.h> +#include <plat/cpu.h> +#include <plat/udc.h> +#include <plat/pm.h> +#include <plat/ts.h> +#include <plat/mci.h> + +#include <mach/fb.h> +#include <mach/gpio-fns.h> +#include <mach/regs-gpio.h> +#include <mach/regs-lcd.h> +#include <mach/leds-gpio.h> +#include <mach/idle.h> + + +/*NAND*/ + +static struct mtd_partition smdk_default_nand_part[] = { + + [0] = { + + .name = "uboot", + + .offset = 0x00000000, + .size = SZ_2M, + + }, + [1] = { + + .name = "kernel", + .offset = SZ_2M, + .size = SZ_2M + SZ_1M, + }, + + [2] = { + .name = "yaffs2", + .offset = SZ_4M+SZ_1M, + .size = MTDPART_SIZ_FULL, + } +}; + +static struct s3c2410_nand_set smdk_nand_sets[] = { + [0] = { + .disable_ecc = 1, // 在这里设置才是正确的 + .name = "NAND", + .nr_chips = 1, + .nr_partitions = ARRAY_SIZE(smdk_default_nand_part), + .partitions = smdk_default_nand_part, + }, +}; + + +static struct s3c2410_platform_nand smdk_nand_info = { + .tacls = 20, + .twrph0 = 60, + .twrph1 = 20, + .nr_sets = ARRAY_SIZE(smdk_nand_sets), + .sets = smdk_nand_sets, +}; + + +/*IO*/ +static struct map_desc tq2440_iodesc[] = { + /* 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, + }, { + .virtual = (u32)S3C24XX_VA_ISA_BYTE, + .pfn = __phys_to_pfn(S3C2410_CS2), + .length = 0x10000, + .type = MT_DEVICE, + }, { + .virtual = (u32)S3C24XX_VA_ISA_BYTE + 0x10000, + .pfn = __phys_to_pfn(S3C2410_CS2 + (1<<24)), + .length = SZ_4M, + .type = MT_DEVICE, + } +}; + +#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK +#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB +#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE + +static struct s3c2410_uartcfg tq2440_uartcfgs[] = { + [0] = { + .hwport = 0, + .flags = 0, + .ucon = 0x3c5, + .ulcon = 0x03, + .ufcon = 0x51, + }, +}; + +/* LCD driver info */ + +static struct s3c2410fb_display tq2440_lcd_cfg = { + + .lcdcon5 = S3C2410_LCDCON5_FRM565 | + S3C2410_LCDCON5_INVVLINE | + S3C2410_LCDCON5_INVVFRAME | + S3C2410_LCDCON5_PWREN | + S3C2410_LCDCON5_HWSWP, + + .type = S3C2410_LCDCON1_TFT, + +#if defined(CONFIG_FB_S3C24X0_LCD480272) + .width = 480, + .height = 272, + + .pixclock = 40000, /* HCLK 100 MHz, divisor 1 */ + .xres = 480, + .yres = 272, + .bpp = 16, + .left_margin = 15, /* for HFPD*/ + .right_margin = 16, /* for HBPD*/ + .hsync_len = 30, /* for HSPW*/ + .upper_margin = 4, /* for VFPD*/ + .lower_margin = 2, /* for VBPD*/ + .vsync_len = 8, /* for VSPW*/ + +#elif defined(CONFIG_FB_S3C24X0_TFT640480) + .width = 640, + .height = 480, + + .pixclock = 40000, /* HCLK 100 MHz, divisor 1 */ + .xres = 640, + .yres = 480, + .bpp = 16, + .left_margin = 40, /* for HFPD*/ + .right_margin = 67, /* for HBPD*/ + .hsync_len = 31, /* for HSPW*/ + .upper_margin = 5, /* for VFPD*/ + .lower_margin = 25, /* for VBPD*/ + .vsync_len = 1, /* for VSPW*/ + +#else + .width = 240, + .height = 320, + + .pixclock = 166667, /* HCLK 60 MHz, divisor 10 */ + .xres = 240, + .yres = 320, + .bpp = 16, + .left_margin = 20, + .right_margin = 8, + .hsync_len = 4, + .upper_margin = 8, + .lower_margin = 7, + .vsync_len = 4, +#endif + +}; + +static struct s3c2410fb_mach_info tq2440_fb_info = { + .displays = &tq2440_lcd_cfg, + .num_displays = 1, + .default_display = 0, +}; + + +static struct resource s3c_dm9000_resource[] = { + [0] = { + .start = S3C2410_CS4, + .end = S3C2410_CS4+3, + .flags = IORESOURCE_MEM, + }, + + [1] = { + .start = S3C2410_CS4+4, + .end = S3C2410_CS4+4+3, + .flags = IORESOURCE_MEM, + }, + + [2] = { + .start = IRQ_EINT7, + .end =IRQ_EINT7, + .flags =IORESOURCE_IRQ|IORESOURCE_IRQ_HIGHEDGE|IORESOURCE_IRQ_SHAREABLE, + } +}; + +static struct dm9000_plat_data dm9k_plat_data = { + .flags = DM9000_PLATF_16BITONLY|DM9000_PLATF_NO_EEPROM, + .dev_addr = "", + }; + +static struct platform_device s3c_device_dm9k = { + .name = "dm9000", + .id = 0, + .num_resources = ARRAY_SIZE(s3c_dm9000_resource), + .resource = s3c_dm9000_resource, + .dev = { + .platform_data = &dm9k_plat_data, + } +}; + + +/*设置udc回调函数udc_pullup()用于使能/禁止UDC上拉电阻*/ +/*udc*/ +static void udc_pullup(enum s3c2410_udc_cmd_e cmd) +{ + switch(cmd) + { + case S3C2410_UDC_P_ENABLE: + s3c2410_gpio_setpin(S3C2410_GPG(12),1); + break; + case S3C2410_UDC_P_DISABLE: + s3c2410_gpio_setpin(S3C2410_GPG(12),0); + break; + case S3C2410_UDC_P_RESET: + break; + default: + break; + } +} +static struct s3c2410_udc_mach_info udc_machine = { + .udc_command = udc_pullup, +}; + + +/*KEY*/ +static struct gpio_keys_button mini2440_buttons[] = { + { + .gpio = S3C2410_GPF(1), /* K1 */ + .code = KEY_UP, + .desc = "UP", + .active_low = 1, + }, + { + .gpio = S3C2410_GPF(4), /* K2 */ + .code = KEY_DOWN, + .desc = "DOWN", + .active_low = 1, + }, + { + .gpio = S3C2410_GPF(2), /* K3 */ + .code = KEY_LEFT, + .desc = "LEFT", + .active_low = 1, + }, + { + .gpio = S3C2410_GPF(0), /* K4 */ + .code = KEY_RIGHT, + .desc = "RIGHT", + .active_low = 1, + }, + +}; + +static struct gpio_keys_platform_data mini2440_button_data = { + .buttons = mini2440_buttons, + .nbuttons = ARRAY_SIZE(mini2440_buttons), +}; + +static struct platform_device mini2440_button_device = { + .name = "gpio-keys", + .id = -1, + .dev = { + .platform_data = &mini2440_button_data, + } +}; + +/* LED devices */ + +static struct s3c24xx_led_platdata smdk_pdata_led4 = { + .gpio = S3C2410_GPB(5), + .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, + .name = "led4", + .def_trigger = "timer", +}; + +static struct s3c24xx_led_platdata smdk_pdata_led5 = { + .gpio = S3C2410_GPB(6), + .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, + .name = "led5", + .def_trigger = "nand-disk", +}; + +static struct s3c24xx_led_platdata smdk_pdata_led6 = { + .gpio = S3C2410_GPB(7), + .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, + .name = "led6", +}; + +static struct s3c24xx_led_platdata smdk_pdata_led7 = { + .gpio = S3C2410_GPB(8), + .flags = S3C24XX_LEDF_ACTLOW | S3C24XX_LEDF_TRISTATE, + .name = "led7", +}; + +static struct platform_device smdk_led4 = { + .name = "s3c24xx_led", + .id = 0, + .dev = { + .platform_data = &smdk_pdata_led4, + }, +}; + +static struct platform_device smdk_led5 = { + .name = "s3c24xx_led", + .id = 1, + .dev = { + .platform_data = &smdk_pdata_led5, + }, +}; + +static struct platform_device smdk_led6 = { + .name = "s3c24xx_led", + .id = 2, + .dev = { + .platform_data = &smdk_pdata_led6, + }, +}; + +static struct platform_device smdk_led7 = { + .name = "s3c24xx_led", + .id = 3, + .dev = { + .platform_data = &smdk_pdata_led7, + }, +}; + +static struct s3c24xx_uda134x_platform_data tq2440_audio_pins = { + .l3_clk = S3C2410_GPB(4), + .l3_data = S3C2410_GPB(3), + .l3_mode = S3C2410_GPB(2), + .model = UDA134X_UDA1341, +}; + +static struct platform_device tq2440_audio = { + .name = "s3c24xx_uda134x", + .id = 0, + .dev = { + .platform_data = &tq2440_audio_pins, + }, +}; + +static struct platform_device uda1340_codec = { + .name = "uda134x-codec", +}; + +/* Touchscreen */ +static struct s3c2410_ts_mach_info tq2400_ts_info = { + .delay = 10000, + .presc = 49, + .oversampling_shift = 2, +}; + +static struct resource s3c_adc_resource[] = { + [0] = { + .start = S3C2410_PA_ADC, + .end = S3C2410_PA_ADC + 0x20 , + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_TC, + .end = IRQ_TC, + .flags = IORESOURCE_IRQ, + }, + [2] = { + .start = IRQ_ADC, + .end = IRQ_ADC, + .flags = IORESOURCE_IRQ, + }, +}; + + +/* + * I2C devices + */ +static struct at24_platform_data at24c08 = { + .byte_len = SZ_8K / 8, + .page_size = 16, +}; + +static struct i2c_board_info mini2440_i2c_devs[] = { + { + I2C_BOARD_INFO("24c08", 0x50), + .platform_data = &at24c08, + }, +}; + + +static struct platform_device *tq2440_devices[] = { + &s3c_device_adc, + &s3c_device_ts, + &s3c_device_ohci, // s3c24xx_ohci + &s3c_device_wdt, // 看门狗狗 + &s3c_device_lcd, + &s3c_device_i2c0, + &s3c_device_iis, + &s3c_device_nand, // MTD NAND 分区表 + &s3c_device_dm9k, // 特别的DM9000网卡芯片 + &s3c_device_rtc, + &mini2440_button_device, + &s3c_device_sdi, // SD 卡读卡器 + &s3c_device_usbgadget, + &uda1340_codec, + &tq2440_audio, // ALSA 声卡 + &samsung_asoc_dma, + &smdk_led4, + &smdk_led5, + &smdk_led6, + &smdk_led7, +}; + +/* MMC/SD */ + +static struct s3c24xx_mci_pdata mini2440_mmc_cfg = { + .gpio_detect = S3C2410_GPG(8), + .gpio_wprotect = S3C2410_GPH(8), + .set_power = NULL, + .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, +}; + +static void __init tq2440_map_io(void) +{ + s3c24xx_init_io(tq2440_iodesc, ARRAY_SIZE(tq2440_iodesc)); + s3c24xx_init_clocks(12000000); + s3c24xx_init_uarts(tq2440_uartcfgs, ARRAY_SIZE(tq2440_uartcfgs)); +} + +static void __init tq2440_machine_init(void) +{ + int i; + + s3c24xx_fb_set_platdata(&tq2440_fb_info); + s3c_i2c0_set_platdata(NULL); + + s3c2410_gpio_cfgpin(S3C2410_GPG(8),S3C2410_GPG8_EINT16); + + s3c_nand_set_platdata(&smdk_nand_info); + s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); + +// s3c_device_adc.num_resources = ARRAY_SIZE(s3c_adc_resource); +// s3c_device_adc.resource = s3c_adc_resource; + + s3c_device_ts.dev.platform_data = &tq2400_ts_info; + + +#ifdef CONFIG_DM9000 + *((volatile unsigned int *)S3C2410_BANKCON4) = 0x1f7c; //config time seq +#endif + + /* mark the key as input, without pullups (there is one on the board) */ + for ( i = 0; i < ARRAY_SIZE(mini2440_buttons); i++) { + s3c_gpio_setpull(mini2440_buttons[i].gpio, S3C_GPIO_PULL_UP); + s3c_gpio_cfgpin(mini2440_buttons[i].gpio, S3C2410_GPIO_INPUT); + } + + s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); + + i2c_register_board_info(0, mini2440_i2c_devs, + ARRAY_SIZE(mini2440_i2c_devs)); + + platform_add_devices(tq2440_devices, ARRAY_SIZE(tq2440_devices)); + + s3c2410_gpio_setpin(S3C2410_GPG(12),0); + s3c2410_gpio_cfgpin(S3C2410_GPG(12),S3C2410_GPIO_OUTPUT); + s3c24xx_udc_set_platdata(&udc_machine); +} + +#define MACH_TYPE_168 168 +/*For some reason , my machine is ID 168*/ +MACHINE_START(168, "TQ2440-168") + .boot_params = S3C2410_SDRAM_PA + 0x100, + .init_irq = s3c24xx_init_irq, + .map_io = tq2440_map_io, + .init_machine = tq2440_machine_init, + .timer = &s3c24xx_timer, +MACHINE_END + +MACHINE_START(TQ2440, "TQ2440") + .boot_params = S3C2410_SDRAM_PA + 0x100, + .init_irq = s3c24xx_init_irq, + .map_io = tq2440_map_io, + .init_machine = tq2440_machine_init, + .timer = &s3c24xx_timer, +MACHINE_END -- 1.7.5.rc3 From 119021354fa6001311db9f1df5d3ea8061a35f9b Mon Sep 17 00:00:00 2001 From: microcai <microcai@fedoraproject.org> Date: Thu, 5 May 2011 14:40:44 +0800 Subject: [PATCH 3/4] add report for ABS_PRESSURE, this fix tslib problem that not been able to detect pen-down and pen-up events. --- drivers/input/touchscreen/s3c2410_ts.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c index 8feb7f3..ecab5d4 100644 --- a/drivers/input/touchscreen/s3c2410_ts.c +++ b/drivers/input/touchscreen/s3c2410_ts.c @@ -126,6 +126,7 @@ static void touch_timer_fire(unsigned long data) input_report_abs(ts.input, ABS_Y, ts.yp); input_report_key(ts.input, BTN_TOUCH, 1); + input_report_abs(ts.input, ABS_PRESSURE, 1); input_sync(ts.input); ts.xp = 0; @@ -140,6 +141,7 @@ static void touch_timer_fire(unsigned long data) ts.count = 0; input_report_key(ts.input, BTN_TOUCH, 0); + input_report_abs(ts.input, ABS_PRESSURE, 0); input_sync(ts.input); writel(WAIT4INT | INT_DOWN, ts.io + S3C2410_ADCTSC); @@ -318,6 +320,7 @@ static int __devinit s3c2410ts_probe(struct platform_device *pdev) ts.input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); input_set_abs_params(ts.input, ABS_X, 0, 0x3FF, 0, 0); input_set_abs_params(ts.input, ABS_Y, 0, 0x3FF, 0, 0); + input_set_abs_params(ts.input, ABS_PRESSURE, 0, 1, 0, 0); ts.input->name = "S3C24XX TouchScreen"; ts.input->id.bustype = BUS_HOST; -- 1.7.5.rc3 From 4684013358b6edf0e8a790ef32de13a236cf7987 Mon Sep 17 00:00:00 2001 From: microcai <microcai@fedoraproject.org> Date: Thu, 5 May 2011 16:19:53 +0800 Subject: [PATCH 4/4] fix some time later then driver not response --- drivers/input/touchscreen/s3c2410_ts.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/input/touchscreen/s3c2410_ts.c b/drivers/input/touchscreen/s3c2410_ts.c index ecab5d4..db868d2 100644 --- a/drivers/input/touchscreen/s3c2410_ts.c +++ b/drivers/input/touchscreen/s3c2410_ts.c @@ -227,6 +227,7 @@ static void s3c24xx_ts_select(struct s3c_adc_client *client, unsigned select) if (select) { writel(S3C2410_ADCTSC_PULL_UP_DISABLE | AUTOPST, ts.io + S3C2410_ADCTSC); + writel(readl(ts.io+S3C2410_ADCCON) | S3C2410_ADCCON_ENABLE_START, ts.io+S3C2410_ADCCON); } else { mod_timer(&touch_timer, jiffies+1); writel(WAIT4INT | INT_UP, ts.io + S3C2410_ADCTSC); -- 1.7.5.rc3