Sdio hot swapping Process

Source: Internet
Author: User

Sdio hot swapping Process

The SD card slot adopts a mechanical switch. During card insertion and removal, the mechanical switch is disconnected and closed.

During system initialization, the switch detection pin is set to the rising and falling edges, so there will be interruptions when the pin level changes. When the hardware is interrupted, the system enters the core ISR, detects the switch detection pin, and returns the corresponding interrupt identification code. If SD is inserted or unplugged, the driverProgram.

Because the SD card slot uses a mechanical switch, there will be jitter when the mechanical switch is disconnected or closed during card insertion and removal, resulting in unstable levels of the SD card detection pin, this may lead to misjudgment of the card status. This will cause the upper-layer driver to be loaded, and initialization failure will cause system instability. In order to make each plugging response only once, the corresponding method must be used to prevent jitter and avoid the jitter time of the mechanical switch.

In the driver ist, the latency sampling method is used to avoid jitter. Latency Sampling: After receiving the SD card detection event, the IST does not judge the pin signal immediately, but delays sampling for a period of time. The delay time depends on the system circuit characteristics, and then detects the pin signal, determine whether the slot is inserted or pulled out.

When the sdio card is removed, the switch on the block will trigger the interruption and execute the interrupt callback function mmc_detect_change.
For a work queue, the lower half is mmc_rescan.
Init_delayed_work (& host-> detect, mmc_rescan );

Mmc_detect_change
==> Mmc_schedule_delayed_work (& host-> detect, delay );
==> Host-> detect is mmc_rescan
==> Mmc_rescan
==> Host-> bus_ops-> detect (host); // mmc_sdio_detect
==> Static const struct mmc_bus_ops mmc_sdio_ops.detect = mmc_sdio_detect;
==> Mmc_sdio_detect // If the card has been removed, run
==> Mmc_sdio_remove (host); // delete files in the/sys/directory and release the memory from kmalloc.
==> Mmc_detach_bus
==> Mmc_bus_put
If (host-> bus_refs = 0) & host-> bus_ops)
_ Mmc_release_bus (host );
==>__ Mmc_release_bus
==> Host-> bus_ops = NULL; // when mmc_rescan is performed, you can re-check the MMC port.

When the card is inserted, the mmc_rescan () function is executed and the card is initialized.

Card initialization process:
A. Send limit 0 to bring the card into the idle status
B. Send Route 8 and check whether the card is sd2.0. Sd1.1 does not support ipv8. Therefore, in sd2.0 spec, we propose to first send ipv8. If the response is invalid, sd1.1 is displayed. Otherwise, sd2.0 is used (see sd2.0 spec ).
C. Send limit 5 to read the OCR register.
D. Send acmd55 and ipv41 to enable the card to work. The mmccard does not support acmd55 or ike41. If this step passes, it indicates that this card is an SD card.
E. If Step D is incorrect, send cmd1 to determine whether the card is MMC. The SD card does not support cmd1, but the mmccard does. This is the basis for SD and MMC types.
F. If both acmd41 and cmd1 fail, the card may be invalid and initialization fails.

 

Acmd41 command. This command can be used to obtain the allowable voltage range value of the sdcard. Because this is an Application Command, the cmd_55 command must be sent before all sdcard commands are sent. After the execution, the card status changes to ready and the obtained voltage range is saved in OCR. Then, call mmc_attach_sd (host, OCR) to check whether the voltage range meets the requirements of the host, then power_off the host.

 

Mmc_attach_sd completes matching and initializes card Functions

Host-> OCR = mmc_select_voltage (host, OCR); check whether it matches. If it matches, perform the following initialization.

Mmc_sd_init_card (host, host-> OCR, null); this function is analyzed.

(1) The mmc_all_send_cid () function generates cmd2, which gets the identity information of the card and enters the identity status.

(2) card = mmc_alloc_card (host, & sd_type); Allocate an SD card structure

(3) Call mmc_send_relative_add to obtain the relative address of the card. Note that the default address is used for communication between the card and the host. Now the address is available and enters the stand_by status.

(4) Send send_csd (Issue 9) to obtain information about the CSD Register, including the block length and card capacity.

(5) mmc_select_card (card) sends Route 7 and selects the current card on the Radd address. At any time, only one card on the bus is selected and enters the transmission status,

(6) Call the mmc_app_send_scr sending command acmd51 to obtain the contents of the SRC register and enter the sending-data status.

The function also decodes the content of each card register and saves it to the corresponding member of the CMD structure.

(7) If (host-> OPS-> get_ro (host)> 0)

Mmc_card_set_readonly (card );

By calling the get_ro (host) function, it is actually the initiai_get_ro function. Whether write protection is enabled. If yes, set the card status to read-only.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.