内核只带了spi协议的核心层和具体的spi控制器(例如s3c2410)的驱动,当然你要设置必要的配置这个spi控制器的驱动才能正常运行。
spi核心层导出了一些接口函数供外部设备调用,具体怎么去调用可以查看spi协议层的代码和内核自带的使用到spi的驱动(例如触摸屏等)。
这里给出我以前所搜集的一些资料:
1、针对s3c2410的spi控制器的配置信息(dev.c文件中):
/* add by lfc */
static struct spi_board_info s3c2410_spi_board[] =
{
[0] = {
.modalias = "spi-test",
.platform_data = NULL,
.irq = IRQ_EINT1,
.chip_select = 1,
.max_speed_hz = 500 * 1000,
},
};
static struct s3c2410_spi_info s3c2410_spi_platdata =
{
.pin_cs = S3C2410_GPG2,
.board_info = s3c2410_spi_board,
.board_size = ARRAY_SIZE ( s3c2410_spi_board ),
};
/* end add */
static struct resource s3c_spi0_resource[] =
{
[0] = {
.start = S3C24XX_PA_SPI,
.end = S3C24XX_PA_SPI + 0x1f,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_SPI0,
.end = IRQ_SPI0,
.flags = IORESOURCE_IRQ,
}
};
static u64 s3c_device_spi0_dmamask = 0xffffffffUL;
struct platform_device s3c_device_spi0 =
{
.name = "s3c2410-spi",
.id = 0,
.num_resources = ARRAY_SIZE ( s3c_spi0_resource ),
.resource = s3c_spi0_resource,
.dev = {
.dma_mask = &s3c_device_spi0_dmamask,
.coherent_dma_mask = 0xffffffffUL,
.platform_data = &s3c2410_spi_platdata,//add by lfc
}
};
阅读(755) | 评论(0) | 转发(0) |