android mmc register to platform

1:msm_sdcc.c

static struct platform_driver msmsdcc_driver = {                                                                                                                                
  .probe    = msmsdcc_probe,                                                                                                                     
  .remove   = msmsdcc_remove,                                                                                                                    
  .suspend  = msmsdcc_suspend,                                                                                                                   
  .resume   = msmsdcc_resume,                                                                                                                    
  .driver   = {                                                                                                                                  
    .name = "msm_sdcc",                                                                                                                          
  },                                                                                                                                             
};                                  

 

2:boardfile.c

static s#define MSM_SDC2_BASE         0xA0500000
truct resource resources_sdc2[] = {
  {
    .start  = MSM_SDC2_BASE,
    .end  = MSM_SDC2_BASE + SZ_4K - 1,
    .flags  = IORESOURCE_MEM,
  },
  {
    .start  = INT_SDC2_0,
    .end  = INT_SDC2_1,
    .flags  = IORESOURCE_IRQ,
  },
  {
    .start  = 8,
    .end  = 8,
    .flags  = IORESOURCE_DMA,
  },
};

static struct mmc_platform_data msm7x2x_sdc2_data = {                                                                                                                           
  .ocr_mask = MMC_VDD_28_29,                                                                                                                     
  .translate_vdd  = msm_sdcc_setup_power,                                                                                                        
  .mmc_bus_width  = MMC_CAP_4_BIT_DATA,                                                                                                          
#ifdef CONFIG_MMC_MSM_SDIO_SUPPORT                                                                                                               
  .sdiowakeup_irq = MSM_GPIO_TO_INT(13),                                                                                                         
#endif                                                                                                                                           
  .msmsdcc_fmin = 144000,                                                                                                                        
  .msmsdcc_fmid = 24576000,                                                                                                                      
  .msmsdcc_fmax = 49152000,                                                                                                                      
  .nonremovable = 1,                                                                                                                             
};

 

3:devicefile.c

struct platform_device msm_device_sdc2 = {
  .name   = "msm_sdcc",
  .id   = 2,
  .num_resources  = ARRAY_SIZE(resources_sdc2),
  .resource = resources_sdc2,
  .dev    = {
    .coherent_dma_mask  = 0xffffffff,
  },
};

static struct platform_device *msm_sdcc_devices[] __initdata = {
  &msm_device_sdc1,
  &msm_device_sdc2,
  &msm_device_sdc3,
  &msm_device_sdc4,
};

int __init msm_add_sdcc(unsigned int controller, struct mmc_platform_data *plat)
{
  struct platform_device  *pdev;

  if (controller < 1 || controller > 4)
    return -EINVAL;                                                                                                                                                             

  pdev = msm_sdcc_devices[controller-1];
  pdev->dev.platform_data = plat;
  return platform_device_register(pdev);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章