linux SDIO实现

在Linu 2.6.21的SDIO驱动,它是除了是mmc_host的驱动外,还是一个Platform驱动.身兼两职.
在这个版本中,首先是定义三个platform_deivce 以注册到系统当中。但是它定义在
  arch/arm/plat-s3c24xx/devs.c (这会让人感当相当迷惑),它创建是 s3c-hsmmc设备
 
struct platform_device s3c_device_hsmmc0 = {                
        .name             = "s3c-hsmmc",                    
        .id               = 0,                              
        .num_resources    = ARRAY_SIZE(s3c_hsmmc0_resource),
        .resource         = s3c_hsmmc0_resource,            
        .dev            = {                                 
                .platform_data = &s3c_hsmmc0_platform,      
        }                                                   
};                                                          
                                                            
                                                            
struct platform_device s3c_device_hsmmc1 = {                
        .name             = "s3c-hsmmc",                    
        .id               = 1,                              
        .num_resources    = ARRAY_SIZE(s3c_hsmmc1_resource),
        .resource         = s3c_hsmmc1_resource,            
        .dev            = {                                 
                .platform_data = &s3c_hsmmc1_platform,      
        }                                                   
};                                                          
 
  其platform_driver 定义在drivers/mmc/s3c-hsmmc.c
 
static struct platform_driver s3c_hsmmc_driver =            
{                                                           
        .probe          = s3c_hsmmc_probe,                  
        .remove         = s3c_hsmmc_remove,                 
        .suspend        = s3c_hsmmc_suspend,                
        .resume         = s3c_hsmmc_resume,                 
        .driver         = {                                 
                .name   = "s3c-hsmmc",                      
                .owner  = THIS_MODULE,                      
        },                                                  
};                                                          
                                                            
static int __init s3c_hsmmc_drv_init(void)                  
{                                                           
        return platform_driver_register(&s3c_hsmmc_driver); 
}                                                           
                                                            
static void __exit s3c_hsmmc_drv_exit(void)                 
{                                                           
        platform_driver_unregister(&s3c_hsmmc_driver);      
}                                                           
 
在s3c_hsmmc_probe函数中,会进行一系列的初始化操作.

 
Linux 2.6.28的SDIO的实现
  Linux 2.6.28又做了进一步调整,原来的s3c-hsmmc的设备和驱动已经放弃,原来在s3c-hsmmc.c 已经成为残余代码,虽然在内核中,但是不会加入Makefile编译。
其新的platform_device 定义分布定义在 dev-hsmmc.c /dev-hsmmc1.c / dev-hsmmc2.c,可以看到设备名字已经变成了 s3c-sdhci

struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata = {
 .max_width = 4,
 .host_caps = (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |
    MMC_CAP_SD_HIGHSPEED),
 .cfg_ext_cd = setup_sdhci0_irq_cd,
 .detect_ext_cd = detect_sdhci0_irq_cd,
 .ext_cd  = S3C_EINT(13),
};

struct platform_device s3c_device_hsmmc0 = {
 .name  = "s3c-sdhci",
 .id  = 0,
 .num_resources = ARRAY_SIZE(s3c_hsmmc_resource),
 .resource = s3c_hsmmc_resource,
 .dev  = {
  .dma_mask  = &s3c_device_hsmmc_dmamask,
  .coherent_dma_mask = 0xffffffffUL,
  .platform_data  = &s3c_hsmmc0_def_platdata,
 },
};

 
它会在系统初始化注册deivce.
 而platform_driver定义在 drivers/mmc/host/sdhci-s3c.c
 

//drivers/mmc/host/sdhci-s3c.c

static struct platform_driver sdhci_s3c_driver = {
 .probe  = sdhci_s3c_probe,
 .remove  = __devexit_p(sdhci_s3c_remove),
        .suspend        = sdhci_s3c_suspend,
        .resume         = sdhci_s3c_resume,
 .driver  = {
  .owner = THIS_MODULE,
  .name = "s3c-sdhci",
 },
};

你可能感兴趣的:(linux SDIO实现)