由于内核中已有ads7846的触摸屏驱动,而ads7846也兼容tsc2046,所以直接使用内核在中ads7846的驱动。
-
因为ads7846是通过spi总线进行读取数据的,所以首先要移植好spi总线驱动:
-
1.首先要进行管脚初始化,配置复用管脚寄存器。
-
//在ds850.c文件中:
-
static const struct mux_config da850_pins[] = {
-
。。。。。。
-
/*添加spi0的配置*/
-
MUX_CFG(DA850, SPI0_CLK, 3, 0, 15, 1, false)
-
MUX_CFG(DA850, SPI0_ENA, 3, 4, 15, 1, false)
-
MUX_CFG(DA850, SPI0_SOMI, 3, 8, 15, 1, false)
-
MUX_CFG(DA850, SPI0_SIMO, 3, 12, 15, 1, false)
-
-
/*原来的配置注销掉
-
MUX_CFG(DA850, MII_RXCLK, 3, 0, 15, 8, false)
-
MUX_CFG(DA850, MII_RXDV, 3, 4, 15, 8, false)
-
MUX_CFG(DA850, MII_RXER, 3, 8, 15, 8, false)
-
MUX_CFG(DA850, MII_CRS, 3, 12, 15, 8, false)
-
*/
-
。。。。。。
-
}
-
-
//在mux.h文件中添加
-
enum davinci_da850_index {
-
。。。。。。
-
/* spi0 function */
-
DA850_SPI0_CLK,
-
DA850_SPI0_ENA,
-
DA850_SPI0_SOMI,
-
DA850_SPI0_SIMO,
-
。。。。。。
-
}
-
-
//在ds850.c文件中添加数组
-
const short da850_spi0_pins[] __initdata = {
-
DA850_SPI0_CLK,DA850_SPI0_ENA,DA850_SPI0_SOMI,DA850_SPI0_SIMO,
-
-1
-
};
-
-
//在da8xx.h中声明该数组
-
extern const short da850_spi0_pins[];
-
-
2.在board-da850-evm.c文件中添加
-
static int ads7846_get_pendown_state(void)
-
{
-
return !gpio_get_value(DA850_PENIR_TS_GPIO);
-
}
-
-
static struct davinci_spi_platform_data da850evm_spi0_pdata = {
-
.version = SPI_VERSION_2,
-
.num_chipselect = 1,
-
.intr_line = 1,
-
};
-
-
struct ads7846_platform_data ads7846_config = {
-
.model = 7846,
-
.x_min = 150,
-
.x_max = 3830,
-
.y_min = 190,
-
.y_max = 3830,
-
.vref_delay_usecs = 100,
-
.x_plate_ohms = 900,
-
.y_plate_ohms = 900,
-
.pressure_max = 255,
-
.debounce_max = 10,
-
.debounce_rep = 1,
-
.debounce_tol = 50,
-
.get_pendown_state = ads7846_get_pendown_state,
-
.keep_vref_on = 1,
-
.wakeup = true,
-
.gpio_pendown = DA850_PENIR_TS_GPIO,
-
};
-
-
static struct spi_board_info da850evm_spi_info[] = {
-
{
-
.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,
-
},
-
-
{
-
.modalias = "ads7846",//设备节点名,与xxx_driver中定义的名字相同
-
.bus_num = 0,
-
.chip_select = 0,
-
.max_speed_hz = 1500000,
-
.mode = SPI_MODE_0,
-
.irq = 128,//GPIO1[11]
-
.platform_data = &ads7846_config,
-
},
-
};
-
-
//在函数添加:
-
static __init void da850_evm_init(void)
-
{
-
。。。。。
-
da850evm_init_spi1(da850evm_spi_info, ARRAY_SIZE(da850evm_spi_info));//注册板级信息
-
-
ret = davinci_cfg_reg_list(da850_spi0_pins);//管脚配置
-
if (ret)
-
pr_warning("da850_evm_init: spi0 mux setup failed: %d\n", ret);
-
da8xx_register_spi(0,&da850evm_spi0_pdata);//spi设备注册
-
。。。。。。
-
}
-
-
3.make menuconfig时要添加spi驱动和触摸屏的驱动,编译即可。
阅读(6008) | 评论(0) | 转发(0) |