From f500982deb465c6004d1af133662d6d6c738ae5c Mon Sep 17 00:00:00 2001 From: lw Date: Fri, 10 Feb 2012 16:12:10 +0800 Subject: [PATCH] rk30:add spi support --- arch/arm/mach-rk30/board-rk30-sdk.c | 123 +++++++++++++++++ arch/arm/mach-rk30/devices.c | 175 +++++++++++++++++++++++- arch/arm/mach-rk30/include/mach/board.h | 18 +++ arch/arm/mach-rk30/include/mach/iomux.h | 1 + arch/arm/mach-rk30/iomux.c | 16 +-- drivers/spi/Kconfig | 8 +- drivers/spi/rk29_spim.c | 2 +- drivers/spi/rk29_spim.h | 6 +- 8 files changed, 334 insertions(+), 15 deletions(-) mode change 100644 => 100755 arch/arm/mach-rk30/devices.c diff --git a/arch/arm/mach-rk30/board-rk30-sdk.c b/arch/arm/mach-rk30/board-rk30-sdk.c index ee4a335a83d1..1ed255ab2091 100755 --- a/arch/arm/mach-rk30/board-rk30-sdk.c +++ b/arch/arm/mach-rk30/board-rk30-sdk.c @@ -35,6 +35,128 @@ #include #include #include +#include +#include +/*set touchscreen different type header*/ +#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) +#include "../../../drivers/input/touchscreen/xpt2046_ts.h" +#elif defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI) +#include "../../../drivers/input/touchscreen/xpt2046_tslib_ts.h" +#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI) +#include "../../../drivers/input/touchscreen/xpt2046_cbn_ts.h" +#endif + + +/***************************************************************************************** + * xpt2046 touch panel + * author: hhb@rock-chips.com + *****************************************************************************************/ +#if defined(CONFIG_TOUCHSCREEN_XPT2046_NORMAL_SPI) || defined(CONFIG_TOUCHSCREEN_XPT2046_TSLIB_SPI) +#define XPT2046_GPIO_INT RK30_PIN6_PB7 +#define DEBOUNCE_REPTIME 3 + + +static struct xpt2046_platform_data xpt2046_info = { + .model = 2046, + .keep_vref_on = 1, + .swap_xy = 0, + .debounce_max = 7, + .debounce_rep = DEBOUNCE_REPTIME, + .debounce_tol = 20, + .gpio_pendown = XPT2046_GPIO_INT, + .pendown_iomux_name = GPIO6B7_TESTCLOCKOUT_NAME, + .pendown_iomux_mode = GPIO6B_GPIO6B7, + .touch_virtualkey_length = 60, + .penirq_recheck_delay_usecs = 1, +#if defined(CONFIG_TOUCHSCREEN_480X800) + .x_min = 0, + .x_max = 480, + .y_min = 0, + .y_max = 800, + .touch_ad_top = 3940, + .touch_ad_bottom = 310, + .touch_ad_left = 3772, + .touch_ad_right = 340, +#elif defined(CONFIG_TOUCHSCREEN_800X480) + .x_min = 0, + .x_max = 800, + .y_min = 0, + .y_max = 480, + .touch_ad_top = 2447, + .touch_ad_bottom = 207, + .touch_ad_left = 5938, + .touch_ad_right = 153, +#elif defined(CONFIG_TOUCHSCREEN_320X480) + .x_min = 0, + .x_max = 320, + .y_min = 0, + .y_max = 480, + .touch_ad_top = 3166, + .touch_ad_bottom = 256, + .touch_ad_left = 3658, + .touch_ad_right = 380, +#endif +}; +#elif defined(CONFIG_TOUCHSCREEN_XPT2046_CBN_SPI) +static struct xpt2046_platform_data xpt2046_info = { + .model = 2046, + .keep_vref_on = 1, + .swap_xy = 0, + .debounce_max = 7, + .debounce_rep = DEBOUNCE_REPTIME, + .debounce_tol = 20, + .gpio_pendown = XPT2046_GPIO_INT, + .pendown_iomux_name = GPIO6B7_TESTCLOCKOUT_NAME, + .pendown_iomux_mode = GPIO6B_GPIO6B7, + .touch_virtualkey_length = 60, + .penirq_recheck_delay_usecs = 1, + +#if defined(CONFIG_TOUCHSCREEN_480X800) + .x_min = 0, + .x_max = 480, + .y_min = 0, + .y_max = 800, + .screen_x = { 70, 410, 70, 410, 240}, + .screen_y = { 50, 50, 740, 740, 400}, + .uncali_x_default = { 3267, 831, 3139, 715, 1845 }, + .uncali_y_default = { 3638, 3664, 564, 591, 2087 }, +#elif defined(CONFIG_TOUCHSCREEN_800X480) + .x_min = 0, + .x_max = 800, + .y_min = 0, + .y_max = 480, + .screen_x[5] = { 50, 750, 50, 750, 400}; + .screen_y[5] = { 40, 40, 440, 440, 240}; + .uncali_x_default[5] = { 438, 565, 3507, 3631, 2105 }; + .uncali_y_default[5] = { 3756, 489, 3792, 534, 2159 }; +#elif defined(CONFIG_TOUCHSCREEN_320X480) + .x_min = 0, + .x_max = 320, + .y_min = 0, + .y_max = 480, + .screen_x[5] = { 50, 270, 50, 270, 160}; + .screen_y[5] = { 40, 40, 440, 440, 240}; + .uncali_x_default[5] = { 812, 3341, 851, 3371, 2183 }; + .uncali_y_default[5] = { 442, 435, 3193, 3195, 2004 }; +#endif +}; +#endif + +static struct spi_board_info board_spi_devices[] = { +#if defined(CONFIG_TOUCHSCREEN_XPT2046_SPI) + { + .modalias = "xpt2046_ts", + .chip_select = 1,// 2, + .max_speed_hz = 1 * 1000 * 1000,/* (max sample rate @ 3V) * (cmd + data + overhead) */ + .bus_num = 0, + .irq = XPT2046_GPIO_INT, + .platform_data = &xpt2046_info, + }, +#endif + +}; + + static struct platform_device *devices[] __initdata = { }; @@ -88,6 +210,7 @@ static void __init rk30_i2c_register_board_info(void) static void __init machine_rk30_board_init(void) { rk30_i2c_register_board_info(); + spi_register_board_info(board_spi_devices, ARRAY_SIZE(board_spi_devices)); platform_add_devices(devices, ARRAY_SIZE(devices)); } diff --git a/arch/arm/mach-rk30/devices.c b/arch/arm/mach-rk30/devices.c old mode 100644 new mode 100755 index fcc81ea550d9..9daef9b8e39b --- a/arch/arm/mach-rk30/devices.c +++ b/arch/arm/mach-rk30/devices.c @@ -22,7 +22,8 @@ #include #include #include - +#include +#include static u64 dma_dmamask = DMA_BIT_MASK(32); static struct resource resource_dmac1[] = { @@ -464,6 +465,177 @@ static void __init rk30_init_i2c(void) } //end of i2c +/***************************************************************************************** + * spi devices + * author: cmc@rock-chips.com + *****************************************************************************************/ +#define SPI_CHIPSELECT_NUM 2 +static struct spi_cs_gpio rk29xx_spi0_cs_gpios[SPI_CHIPSELECT_NUM] = { + { + .name = "spi0 cs0", + .cs_gpio = RK30_PIN1_PA4, + .cs_iomux_name = GPIO1A4_UART1SIN_SPI0CSN0_NAME, + .cs_iomux_mode = GPIO1A_SPI0_CSN0, + }, + { + .name = "spi0 cs1", + .cs_gpio = RK30_PIN4_PB7, + .cs_iomux_name = GPIO4B7_SPI0CSN1_NAME,//if no iomux,set it NULL + .cs_iomux_mode = GPIO4B_SPI0_CSN1, + } +}; + +static struct spi_cs_gpio rk29xx_spi1_cs_gpios[SPI_CHIPSELECT_NUM] = { + { + .name = "spi1 cs0", + .cs_gpio = RK30_PIN2_PC4, + .cs_iomux_name = GPIO2C4_LCDC1DATA20_SPI1CSN0_HSADCDATA1_NAME, + .cs_iomux_mode = GPIO2C_SPI1_CSN0, + }, + { + .name = "spi1 cs1", + .cs_gpio = RK30_PIN2_PC7, + .cs_iomux_name = GPIO2C7_LCDC1DATA23_SPI1CSN1_HSADCDATA4_NAME,//if no iomux,set it NULL + .cs_iomux_mode = GPIO2C_SPI1_CSN1, + } +}; + +static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num) +{ + int i; + if (cs_gpios) { + for (i=0; iregs: %p\n", dws->regs); - dws->irq = irq; + dws->irq = irq; dws->irq_polarity = IRQF_TRIGGER_NONE; dws->master = master; dws->type = SSI_MOTO_SPI; diff --git a/drivers/spi/rk29_spim.h b/drivers/spi/rk29_spim.h index fb3ab62c602d..6ac385315038 100755 --- a/drivers/spi/rk29_spim.h +++ b/drivers/spi/rk29_spim.h @@ -14,7 +14,11 @@ #ifndef __DRIVERS_SPIM_RK29XX_HEADER_H #define __DRIVERS_SPIM_RK29XX_HEADER_H #include -#include +#ifdef CONFIG_ARCH_RK30 +#include +#else +#include +#endif /* SPI register offsets */ #define SPIM_CTRLR0 0x0000 -- 2.34.1