s3c6410 的SDIO驱动分析(2)

static struct sdio_driver if_sdio_driver = {
 .name  = "libertas_sdio",
 .id_table = if_sdio_ids,
 .probe  = if_sdio_probe,
 .remove  = if_sdio_remove,
};

static int __init if_sdio_init_module(void)  
{                                            
 int ret = 0;                               
 ret = sdio_register_driver(&if_sdio_driver);
 return ret;                                
}                                            
                                             
static void __exit if_sdio_exit_module(void) 
{                                            
 sdio_unregister_driver(&if_sdio_driver);   
}                                            

 

 

SDIO采用的与MMC兼容的命令接口,因此对于mmc的操作,LINUX又封装一层,使用数据结构 mmc_host

 

struct mmc_host {
 struct device  *parent;
 struct device  class_dev;
 int   index;
 const struct mmc_host_ops *ops;
 unsigned int  f_min;
 unsigned int  f_max;
 u32   ocr_avail;
 unsigned long  caps;  /* Host capabilities */
 /* host specific block data */
 unsigned int  max_seg_size; /* see blk_queue_max_segment_size */
 unsigned short  max_hw_segs; /* see blk_queue_max_hw_segments */
 unsigned short  max_phys_segs; /* see blk_queue_max_phys_segments */
 unsigned short  unused;
 unsigned int  max_req_size; /* maximum number of bytes in one req */
 unsigned int  max_blk_size; /* maximum size of one mmc block */
 unsigned int  max_blk_count; /* maximum number of blocks in one req */

/* private data */
 spinlock_t  lock;  /* lock for claim and bus ops */

struct mmc_ios  ios;  /* current io bus settings */
 u32   ocr;  /* the current OCR setting */

/* group bitfields together to minimize padding */
 unsigned int  use_spi_crc:1;
 unsigned int  claimed:1; /* host exclusively claimed */
 unsigned int  bus_dead:1; /* bus has been released */
#ifdef CONFIG_MMC_DEBUG
 unsigned int  removed:1; /* host is being removed */
#endif

struct mmc_card  *card;  /* device attached to this host */

wait_queue_head_t wq;

struct delayed_work detect;

const struct mmc_bus_ops *bus_ops; /* current bus driver */
 unsigned int  bus_refs; /* reference counter */

unsigned int  sdio_irqs;
 struct task_struct *sdio_irq_thread;
 atomic_t  sdio_irq_thread_abort;

#ifdef CONFIG_LEDS_TRIGGERS
 struct led_trigger *led;  /* activity led */
#endif

struct dentry  *debugfs_root;

unsigned long  private[0] ____cacheline_aligned;
};

 

 

而mmc_host是一个特殊内核类 mmc_host,它会在 /sys/class/ 建立一个mmc_host类.

//drivers/mmc/core/host.c

static struct class mmc_host_class = {
 .name  = "mmc_host",
 .dev_release = mmc_host_classdev_release,
};

int mmc_register_host_class(void)
{
 return class_register(&mmc_host_class);
}

void mmc_unregister_host_class(void)
{
 class_unregister(&mmc_host_class);
}

 

 

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwfggy.html