加入收藏 | 设为首页 | 会员中心 | 我要投稿 我爱资讯网 (https://www.52junxun.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

Linux内核驱动编写---SD卡驱动

发布时间:2022-10-24 12:47:59 所属栏目:Linux 来源:
导读:  Linux驱动框架上是怎么处理sd卡驱动的:

  1、代码目录地址

  drivers/mmc
  2、基本结构

  从mmc的代码结构可以看得出,主要分为两个部分linux 驱动,其中core为协议部分,host为各个soc的
  Linux驱动框架上是怎么处理sd卡驱动的:
 
  1、代码目录地址
 
  drivers/mmc
  2、基本结构
 
  从mmc的代码结构可以看得出,主要分为两个部分linux 驱动,其中core为协议部分,host为各个soc的适配部分host是我们需要真正关心的代码
 
  3、以s3c为例,观察makefile
 
  obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o
  ......
  obj-$(CONFIG_MMC_S3C)    += s3cmci.o
  
  4、根据s3c阅读Kconfig,确认s3c下的sd卡还依赖哪些文件
 
  config MMC_SDHCI_S3C
   tristate "SDHCI support on Samsung S3C SoC"
   depends on MMC_SDHCI && PLAT_SAMSUNG
   help
    This selects the Secure Digital Host Controller Interface (SDHCI)
    often referrered to as the HSMMC block in some of the Samsung S3C
    range of SoC.
    If you have a controller with this interface, say Y or M here.
    If unsure, say N.
  config MMC_SDHCI_S3C_DMA
   bool "DMA support on S3C SDHCI"
   depends on MMC_SDHCI_S3C
   help
    Enable DMA support on the Samsung S3C SDHCI glue. The DMA
    has proved to be problematic if the controller encounters
    certain errors, and thus should be treated with care.
    YMMV.
  config MMC_S3C
   tristate "Samsung S3C SD/MMC Card Interface support"
   depends on ARCH_S3C24XX
   depends on S3C24XX_DMAC
   help
    This selects a driver for the MCI interface found in
   Samsung's S3C2410, S3C2412, S3C2440, S3C2442 CPUs.
    If you have a board based on one of those and a MMC/SD
    slot, say Y or M here.
    If unsure, say N.

  5、MMC_S3C和MMC_SDHCI_S3C是主要的macro,接着了解两个macro对应文件的数据结构首先看一下s3cmci.c文件
 
  static const struct mmc_host_ops s3cmci_ops = {
   .request = s3cmci_request,
   .set_ios = s3cmci_set_ios,,
   .get_ro  = mmc_gpio_get_ro,
   .get_cd  = mmc_gpio_get_cd,
   .enable_sdio_irq = s3cmci_enable_sdio_irq,
  };
  再看一下sdhci-s3c.c文件,
 
  static struct sdhci_ops sdhci_s3c_ops = {
   .get_max_clock  = sdhci_s3c_get_max_clk,
   .set_clock  = sdhci_s3c_set_clock,
   .get_min_clock  = sdhci_s3c_get_min_clock,
   .set_bus_width  = sdhci_set_bus_width,
   .reset   = sdhci_reset,
   .set_uhs_signaling = sdhci_set_uhs_signaling,
  };
  6 、从host角度来说,有platform driver和上面的host driver,驱动流程就算搞清楚
 
  有时间大家可以研究一下sd协议。
 

(编辑:我爱资讯网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!