AM1808触摸屏驱动移植

此文是基于AM1808平台的LCD 驱动移植过程。

一。Board-da850-evm.c

#define DA850_TSC_PEN GPIO_TO_PIN(2,12) //lct set
#include 
static int ads7843_pendown_state(void)
{
    int pdt = 0;
    pdt = !gpio_get_value(DA850_TSC_PEN); // SPI1_ENA
//printk("%s:ads7843_pendown_state = %d\n", __func__, pdt);
    return pdt;
}

static struct ads7846_platform_data ads_info = {
    .model                  = 7846,
    .x_min                  = 150,
    .x_max                  = 3830,
    .y_min                  = 190,
    .y_max                  = 3830,
    .vref_delay_usecs       = 100,
    .x_plate_ohms           = 450,
    .y_plate_ohms           = 250,
    .pressure_max           = 15000,
    .debounce_max           = 1,
    .debounce_rep           = 0,
    .debounce_tol           = (~0),
    .get_pendown_state      = ads7843_pendown_state,
};

static struct davinci_spi_config da850evm_ads7843_cfg = {
    .io_type    = SPI_IO_TYPE_DMA, //SPI_IO_TYPE_POLL
    .c2tdelay   = 8,
    .t2cdelay   = 8,
};
static struct spi_board_info da850evm_spi_info[] = {
#if 0
    {
        .modalias       = "m25p80",
        .platform_data      = &da850evm_spiflash_data,
        .controller_data    = &da850evm_spiflash_cfg,
        .mode           = SPI_MODE_0,
        .max_speed_hz       = 30000000,
        .bus_num        = 1,
        .chip_select        = 0,
    },
#else
    {
        .modalias       = "ads7846",
        .chip_select    = 0,
        .max_speed_hz   = 1000000,      /* (max sample rate @ 3V) * (cmd + data + overhead) */
        .bus_num        = 1,
        .platform_data  = &ads_info,
        .controller_data    = &da850evm_ads7843_cfg,
        .irq            = 145, //gpio_to_irq(DA850_TSC_PEN),
    },
#endif
};
static __init void da850_evm_init(void)
{
    。。。。。。。。。。。。。。。。。。
    。。。。。。。。。。。。。。。。。。
    。。。。。。。。。。。。。。。。。。
    printk("%s:%s:SPI1 init, ads784x IRQ=%d\n", __FILE__, __func__, gpio_to_irq(GPIO_TO_PIN(2,12)));
    da850evm_init_spi1(da850evm_spi_info, ARRAY_SIZE(da850evm_spi_info));
     //lct set 管脚配置
    ret = davinci_cfg_reg_list(da850_spi1_pins);//管脚配置
    if (ret)
        pr_warning("da850_evm_init: spi1 mux setup failed: %d\n",    ret);
    。。。。。。。。。。。。。。。。。。
    。。。。。。。。。。。。。。。。。。
    。。。。。。。。。。。。。。。。。。
}

二。头文件Da8xx.h, Mux.h

1.Da8xx.h

extern const short da850_spi1_pins[];//lct set

2.Mux.h

enum davinci_da850_index {
    。。。。。。。。。。。。。
    。。。。。。。。。。。。。
    。。。。。。。。。。。。。
    /* lct set spi1 function */
     //DA850_SPI1_CS_7,
     DA850_SPI1_ENA,
    DA850_SPI1_CLK,
    DA850_SPI1_SOMI,
    DA850_SPI1_SIMO,
    DA850_SPI1_SCS_1,//LCT ADD
 }

三。da850.c

//lct set da850_spi1_pins
const short da850_spi1_pins[] __initdata = {
    DA850_SPI1_ENA,DA850_SPI1_CLK,DA850_SPI1_SOMI,DA850_SPI1_SIMO,
    -1
};
static const struct mux_config da850_pins[] = {
    。。。。。。。。。。。。。。。。。。
    。。。。。。。。。。。。。。。。。。
    。。。。。。。。。。。。。。。。。。
    /* lct set spi1 function */
     //MUX_CFG(DA850, SPI1_CS_7,     4,     8,     15,     1,     false)
     MUX_CFG(DA850, SPI1_ENA,     5,     12,     15,     1,     false)
     MUX_CFG(DA850, SPI1_CLK,     5,     8,     15,     1,     false)
     MUX_CFG(DA850, SPI1_SOMI,     5,     16,     15,     1,     false)
     MUX_CFG(DA850, SPI1_SIMO,     5,     20,     15,     1,     false)
};

你可能感兴趣的:(Linux驱动)