一、注册平台设备

platform_device_register(&usr_mci_device);

二、填写平台设备结构体

static struct platform_device usr_mci_device= {

.name          = "xxx",

.id             = 0,

.dev = {

.release     = usr_mci_platdev_release,

.dma_mask  = &usr_mmc_dmamask,

.coherent_dma_mask = DMA_BIT_MASK(32),

},

.num_resources    = ARRAY_SIZE(usr_mci_resources),

.resource          = usr_mci_resources,

};

三、填写资源结构体(物理地址查芯片手册)

static struct resource usr_mci_resources[] = {

[0] = {

.start          = CONFIG_USR_IOBASE,

.end            = CONFIG_USR_IOBASE + USR_MCI_IO_SIZE - 1,

.flags          = IORESOURCE_MEM,

},

[1] = {

.start          = CONFIG_USR_INTR,

.end            = CONFIG_USR_INTR,

.flags          = IORESOURCE_IRQ,

},

};

四、注册平台驱动

platform_driver_register(&usr_mci_driver);

五、填写平台驱动结构体

static struct platform_driver usr_mci_driver= {

.probe = usr_mci_probe,

.remove = usr_mci_remove,

.suspend = usr_mci_suspend,

.resume = usr_mci_resume,

.driver = {

.name = DRIVER_NAME,

},

};

六、重写probe函数

static int __devinit usr_mci_probe(struct platform_device *pdev)

七、创建一个自己的设备结构体

struct usr_host {

struct mmc_host*mmc;

spinlock_tlock;

struct mmc_request*mrq;

struct mmc_command*cmd;

struct mmc_data*data;

void __iomem*base;

unsigned intcard_status;

struct scatterlist*dma_sg;

unsigned intdma_sg_num;

unsigned intdma_alloc_size;

unsigned intdma_dir;

dma_addr_tdma_paddr;

unsigned int*dma_vaddr;

struct timer_listtimer;

unsigned intirq;

unsigned intirq_status;

unsigned intis_tuning;

wait_queue_head_tintr_wait;

unsigned longpending_events;

unsigned intid;

};

struct usr_host *host;

八、分配一个包含了mmc_host的自定义结构体(core需要)

struct mmc_host *mmc;

mmc = mmc_alloc_host(sizeof(struct usr_host), &pdev->dev);

九、初始化mmc_host结构体

mmc->ops

mmc->f_min

mmc->f_max

mmc->caps

mmc->max_blk_count

mmc->max_segs

mmc->max_seg_size

mmc->max_req_size

mmc->ocr_avail

mmc->ocr

十、初始化usr_host

host=mmc->private;

host->dma_vaddr = dma_alloc_coherent(&pdev->dev, PAGE_SIZE,&host->dma_paddr, GFP_KERNEL);

host->mmc = mmc;

host->id

host->base

十一、初始化SDIO的时钟、驱动能力

十二、SDIO复位

十三、SDIO重上电

十四、设置时钟相位

十五、设置阈值

十六、设置中断状态

十七、设置中断屏蔽

十八、设置DMA搬移数据

十九、设置全局中断使能

二十、设置FIFO突发长度与FIFO大小

二十一、卡检测

二十二、初始化定时器,定时处理函数为卡检测

二十三、获取资源结构体的软中断号

二十四、初始化等待队列

init_waitqueue_head(&host->intr_wait);

二十五、request_irq注册中断

二十六、写中断函数(唤醒等待队列)

static irqreturn_t usr_irq(int irq, void *dev_id)

{

wake_up(&host->intr_wait);

}

linux编译mmc驱动,Embeded linux之MMC驱动相关推荐

  1. 修改linux编译配置文件,Porting:linux内核编译、配置、修改配置文件、添加.c文件到内核...

    一.linux内核 $:'uname -a $:'uanme -r // 查看linux内核版本,开发板上进入linux后是一样的命令. 早起常常使用的版本:linux 2.6.x 开发板上使用的版本 ...

  2. linux编译安装的好处,Linux学习—源码安装

    源码安装--可以按照自己的需求安装,这是源码安装的好处,而二进制安装无法选择 大部分的源码安装步骤大致相同,具体细节可以参考解压缩之后的README和INSTALL README: 介绍了软件包的功能 ...

  3. linux编译内核支持pam,linux编译内核make menuconfig报错解决办法

    linux编译内核时 输入make menuconfig命令 *** Unable to find the ncurses libraries or the *** required header f ...

  4. linux编译谷歌浏览器方法,构建Linux版本的谷歌Chrome浏览器

    Chromium编译说明(Linux版) 此页描述如果在Linux操作系统上编译构建Chromium浏览器.假如你对测试chromium或想移植chromium到别的平台请你继续阅读. 小提示:目前还 ...

  5. linux编译内核报错,linux编译内核时出报错;

    因为以前已经编译了,所以就很简单的连接: [root@bache linux-2.6.29]# make defconfig *** Default configuration is based on ...

  6. Linux编译安装qt5.9,Linux CentOS7 安装 Qt 5.9.2

    Linux CentOS7 安装 Qt 5.9.2 参考链接 http://doc.qt.io/qt-5/linux.html sudo yum groupinstall "C Develo ...

  7. linux编译blas,科学网—Linux下安装blas和lapack包小记 - 徐博伦的博文

    系统是centOS6.5,机器上已有gfortran编译器 从网上搜索下载blas.cblas.lapack的tar压缩文件包 1.编译blas 先解压文件 tar xvf blas.tgz cd b ...

  8. linux 编译指cpu内核,linux内核编译与配置

    linux是如何组成的? 答:linux是由用户空间和内核空间组成的 为什么要划分用户空间和内核空间? 答:有关CPU体系结构,各处理器可以有多种模式,而LInux这样的划分是考虑到系统的 安全性,比 ...

  9. 嵌入式linux编译环境搭建,嵌入式Linux开发环境搭建

    整理下嵌入式Linux开发环境搭建过程笔记. 一.制作u-boot.bin文件: tar xjf u-boot-1.1.6.tar.bz2 cd u-boot-1.1.6 patch -p1 < ...

最新文章

  1. css 倒三角_倒三角结构:如何管理大型CSS项目
  2. 直播预告|灵动MM32 MCU助力全国大学生智能汽车竞赛——基础培训第二讲
  3. LeetCode 375. Guess Number Higher or Lower II
  4. 域名解析的记录类型区别
  5. openssl之EVP系列之1---算法封装
  6. Android TabLayout添加自定义分割线并且可以修改分割线高度
  7. 单链表带头结点不带头结点
  8. android检测手机网络连接不上,Android WIFI及手机网络连接情况检查
  9. FFmpeg架构之I/O模块分析
  10. 简约的网络字节序处理
  11. Redis12-事件
  12. Ubuntu 怎么安装AppImage文件 软件
  13. 通达oa2017 数据库表结构
  14. ubuntu 版mysql客户端工具_MySQL GUI工具
  15. Chromium下载地址
  16. jmeterhttp代理服务器_Jmeter使用HTTP代理服务器录制脚本
  17. Koo叔说Shader—果冻效果
  18. 多维尺度分析MDS详解
  19. git删除远程的commit
  20. 登录SSH/winSCP一直显示密码错误

热门文章

  1. JS性能优化之文档碎片-document.createDocumentFragment
  2. 【AtCoder】ARC078
  3. Java处理文件BOM头的方式推荐
  4. 001-Ansible-参考http://www.ansible.com.cn/docs/playbooks_intro.html#about-playbooks
  5. 爬虫系统Lucene分词
  6. AsyncTask与多任务
  7. 我是如何实用:before :after
  8. 简明Vim练级攻略(初学者)
  9. 设计模式系列漫谈之二 - 工厂方法模式
  10. 【vue-router①】router-link跳转页面传递参数 - 进击的前端之路(偶尔爬坑java小路) - SegmentFault 思否