First, the driver structure
1, Platform_device
Files:/arch/arm/mach-omap2/device.c
Static structOmap2_mcspi_platform_config Omap2_mcspi1_config ={. Num_cs=4,};Static structResource omap2_mcspi1_resources[] ={. Start=omap2_mcspi1_base,. End= Omap2_mcspi1_base +0xFF,. Flags=Ioresource_mem,},};Static structPlatform_device omap2_mcspi1 ={. Name="Omap2_mcspi",. ID=1,/* for identifying different devices in the Platform_driver probe function */
. num_resources=array_size (omap2_mcspi1_resources),. Resource=omap2_mcspi1_resources,. Dev={. Platform_data= &Omap2_mcspi1_config,},};
static void Omap_init_mcspi (void)
{
if (cpu_is_omap44xx ())
Omap4_mcspi_fixup ();
Platform_device_register (&omap2_mcspi1);
}
2, Dev_devices
Files:/arch/arm/mach-omap2/board-ti8148ipnc.c
Static structSpi_board_info dm8127_spi1_board[] = { [0] ={. Modalias="Spidev",. Bus_num=1,. Chip_select=0,. IRQ= -1,. Max_speed_hz= -* +* +,. Mode=Spi_mode_0,},};void__init Ti8148_spi_init (void){ Spi_register_board_info (Dm8127_spi1_board, Array_size (Dm8127_spi1_board)); }
1, Platform_driver
Files:/driver/spi/omap2_mcspi.c
Static Const structDev_pm_ops Omap2_mcspi_pm_ops ={. Resume=Omap2_mcspi_resume,};Static structPlatform_driver Omap2_mcspi_driver ={. Driver={. Name="Omap2_mcspi",. Owner=This_module,. PM= &Omap2_mcspi_pm_ops},. Remove=__exit_p (Omap2_mcspi_remove),};Static int__init Omap2_mcspi_init (void) {Omap2_mcspi_wq= Create_singlethread_workqueue (/*Create a work queue*/omap2_mcspi_driver.driver.name); if(Omap2_mcspi_wq = =NULL)return-1; returnPlatform_driver_probe (&Omap2_mcspi_driver, Omap2_mcspi_probe);}
1, Dev_driver
Files:/driver/spi/spidev.c
Static struct spi_driver spidev_spi_driver = { = {= "spidev " , = this_module, }, = spidev_probe, = __devexit_p ( Spidev_remove),};
SPI Drive Frame -1 (DM8127 Linux2.6.37 for example)