Chinaunix首页 | 论坛 | 博客
  • 博客访问: 162748
  • 博文数量: 40
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 355
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-27 18:05
文章分类
文章存档

2011年(1)

2010年(9)

2009年(16)

2008年(14)

我的朋友

分类: LINUX

2010-01-29 18:16:25

yyy_irq()
{
  mmc_detect_change(host->mmc, 50);

}


xxx_irq()
{
    irq_status = ...
    
    if(irq_status & err){
        ...
    }
    if(irq_status & cmd_complete){
        completion(xxx_cmd);
        goto cmd;
    }
    if(irq_status & dma_complete){
        completion(xxx_dma);
        goto dma;
    }
    ...
}


xxx_send_cmd()
{
    根据上层的命令标志,填写相应寄存器
    if(host->cmd.flag & MMC_RSP_PRESENT){
        cmd_flags = xxx;
    }
    ...
    
}

void xxx_sdio_request()
{

    
    xxx_send_cmd();
    wait_for_completion(xxx_cmd);
    xxx_get_resp();
    if(要读写数据){
        blockaddr = ...
        blockcnt =...
        xxx_dma_init()
        xxx_do_dma()
        wait_for_completion(xxx_dma);
    }
    
cmd_complete:
    host->mrq = NULL;
     host->cmd = NULL;
    SDIO_DEBUG("request done.\n");
    mmc_request_done(mmc, mrq);
    
}


//操作函数

static struct mmc_host_ops xxx_sdio_ops = {
        .request = xxx_sdio_request, //处理来自块层的请求,主要是对命令的处理,把数据放在sg中,或从sg中读出

        .set_ios = xxx_sdio_set_ios, //设置卡的状态,包括,1.电源开关, 2.时钟频率设置,3.总线宽度设置

        .get_ro = xxx_get_ro,            //卡只读属性

        .get_cd = xxx_card_present,        //卡是否存在

};



    struct xxx_host{
        unsigned int        clk_rate;
        struct mmc_host *mmc;
        struct mmc_request *mrq;
     struct mmc_command     *cmd;
        int                 irq;
        struct completion complete_request;
             struct completion complete_dma;
      int bus_width;
              unsigned int status;
        ...
    };



probe中
{    
    mmc = mmc_alloc_host(sizeof(struct xxx_host), &pdev->dev);
    mmc->ops = &xxx_ops;
    mmc->ocr_avail = host->pdata->ocr_avail;
    mmc->caps = MMC_CAP_4_BIT_DATA;
      mmc->f_min = host->clk_rate / (host->clk_div * 256);
      mmc->f_max = host->clk_rate / host->clk_div;
 
      mmc->max_blk_count = 4095;
      mmc->max_blk_size = 4095;
      mmc->max_req_size = 4095 * 512;
      mmc->max_seg_size = mmc->max_req_size;

     mmc_add_host(mmc);
    dev_set_drvdata(dev, mmc);

      mmc->max_phys_segs = 128;
      mmc->max_hw_segs = 128;
}



阅读(1133) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~