Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write SD Card driver in linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces linux how to write SD card driver, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

With the popularity of SD cards, more and more scenarios are used in embedded devices. So let's take a look at how the SD card driver is handled on the linux driver framework.

1. Code directory address

Drivers/mmc

2. Basic structure

From the code structure of mmc, we can see that it is mainly divided into two parts, in which core is the protocol part and host is the adaptation part of each soc.

Host is the code we really need to care about.

3. Take S3c as an example to observe makefile

Obj-$ (CONFIG_MMC_SDHCI_S3C) + = sdhci-s3c.o. Obj-$ (CONFIG_MMC_S3C) + = s3cmci.o

4. Read Kconfig according to S3c and confirm which files the SD card under S3c depends on.

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 and MMC_SDHCI_S3C are the main macro, and then learn the data structure of the corresponding files of the two macro

First take a look at the s3cmci.c file

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,}

Take another look at the sdhci-s3c.c file

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. From the host point of view, with platform driver and the above host driver, the driver process is clear.

But if you go any further, you still need to read the sd protocol, which takes the most time.

Thank you for reading this article carefully. I hope the article "linux how to write SD Card drivers" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report