huangning | | |
等级:超级版主
文章:1468
积分:3269
注册:2007-6-6
|
认真查看了Document/spi/spi-summary文件,发现里面有这一段话:
The SPI core will autmatically attempt to bind this driver to any SPI
device whose board_info gave a modalias of "CHIP".
比如你的SLAVE DEVICES 定义为:
static struct ads7846_platform_data ads_info = {
.vref_delay_usecs = 100,
.x_plate_ohms = 580,
.y_plate_ohms = 410,
};
static struct spi_board_info spi_board_info[] __initdata = {
{
.modalias = "ads7846",
.platform_data = &ads_info,
.mode = SPI_MODE_0,
.irq = GPIO_IRQ(31),
.max_speed_hz = 120000 /* max sample rate at 3V */ * 16,
.bus_num = 1,
.chip_select = 0,
},
};
那你的驱动的device可以这样定义:
static struct device_driver CHIP_driver = {
.name = "CHIP",
.bus = &spi_bus_type,
.probe = CHIP_probe,
.remove = __exit_p(CHIP_remove),
.suspend = CHIP_suspend,
.resume = CHIP_resume,
};
关键是这里的“CHIP”要和从设备定义的名字相同,因为内核就是*这个来匹配的,再一次引用文档的话:
The SPI core will autmatically attempt to bind this driver to any SPI
device whose board_info gave a modalias of "CHIP".
所以我把从设备的定义改为:
static struct spi_board_info s3c2410_spi_board[] = {
[0] = {
.modalias = "ads7846", //注意:只要和驱动的名字相同就行,改驱动下的名字也是可以的
.platform_data = NULL,
.irq = IRQ_EINT1,
.chip_select = 1,
.max_speed_hz = 500*1000,
},
};
就行了^_^
看来要提高E文的水平,多看一下内核自带的文档才行~
编辑者: luofuchong (07-04-24 23:33)
|
|