S3C2440 SPI驱动代码详细解读:
https://www.linuxidc.com/Linux/2012-08/68402p4.htm
一、platform device and board_info
/* /arch/arm/plat-s3c24xx*/
static struct resource s3c_spi0_resource[] = {
[] = {
.start = S3C24XX_PA_SPI,
.end = S3C24XX_PA_SPI + 0x1f,
.flags = IORESOURCE_MEM,
},
[] = {
.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", /* 匹配platform_device 的.driver.namen */
.id = ,
.num_resources = ARRAY_SIZE(s3c_spi0_resource),
.resource = s3c_spi0_resource,
.dev = {
.dma_mask = &s3c_device_spi0_dmamask,
.coherent_dma_mask = 0xffffffffUL
}
};
EXPORT_SYMBOL(s3c_device_spi0); /* /arch/arm/mach-s3c2440/mach-tq2440.c */
static struct spi_board_info s3c2440_spi0_board[] = {
[] = {
.modalias = "spidev",
.bus_num = ,
.chip_select = ,
.irq = IRQ_SPI0, //IRQ_EINT10,/* 修改无效 */
.max_speed_hz = **,
},
}; static struct s3c2410_spi_info s3c2440_spi0_platdata = {
.pin_cs = S3C2410_GPG2,
.num_cs = ,
.bus_num = ,
}; static struct platform_device *tq2440_devices[] __initdata = {
......&s3c_device_spi0, /* sunhj add for spi0 */
&s3c_device_spi1,
};
static void __init tq2440_machine_init(void)
{
platform_add_devices(tq2440_devices, ARRAY_SIZE(tq2440_devices));
/* sunhj add for spi */
s3c_device_spi0.dev.platform_data= &s3c2440_spi0_platdata;
spi_register_board_info(s3c2440_spi0_board, ARRAY_SIZE(s3c2440_spi0_board));
}
二、Platform driver
/* /driver/spi/spi_s3c24xx.c */