SPI and sdio protocols

Source: Internet
Author: User

Serial peripheral interface (SPI: serial peripheral
Interface) is a serial synchronous communication protocol (read and write at the same time), composed of SDI (serial data input), SDO (serial data output), sck (Serial shift clock ), CS (from
Enable signal) composed of four signals. CS determines the only slave device that communicates with the master device. If there is no CS signal, only one slave device can exist. The master device initiates communication by generating a shift clock.

The two parameters that affect SPI communication are clock polarity (cpol) and clock phase (cpha). The highest bit is first transmitted when SPI transmits serial data. Clock polarity (cpol) pair Transmission
The Protocol has no significant impact. If cpol = 0, the idle status of the serial synchronization clock is low. If cpol = 1, the idle status of the serial synchronization clock is high. Clock Phase (cpha) Capability
The configuration is used to select one of the two different transmission protocols for data transmission. If cpha is set to 0, the data in the first hop-on (up or down) of the serial synchronization clock is sampled; if cpha = 1
The second hop (up or down) of the synchronization clock is sampled. The figure is as follows:

The general arm system supports SPI in three ways: polling and interrupt. The SPI interrupt number must be defined ), and DMA (configure the registers corresponding to SPI and DMA, And the Source and Destination addresses of DMA to start DMA transmission ).

========================================================== ======================================

Based on the sdio protocol, the SD card is defined as follows:

It supports three operation modes: SPI, SD first-line, and SD four-line (the interface is configured through the register ). The SPI speed is low. First-line or fourth-line registers are required. In high-speed mode, four-line support is required. Dat is the data line, and dat0 is the default in the first-line mode. CMD transmits serial commands online, which can be single-host addressing or broadcast commands.

6410 platform support for SD card, manifested in ch0 (consumer is used to connect to wifi, and ch0 has a detect foot, namely xmmccdn0), add hsmmc device, and allocate corresponding resources.

(1)

Static struct platform_device * smdk6410_devices [] _ initdata = {

........

& Amp; initi_device_hsmmc0,

........

}

Definition:

Struct platform_device initi_device_hsmmc0 = {
. Name = "s3c-sdhci ",
. ID = 0,
. Num_resources = array_size (initi_hsmmc_resource ),
. Resource = maid,
. Dev = {
. Dma_mask = & jx_device_hsmmc_dmamask,
. Coherent_dma_mask = 0 xfffffffful,
. Platform_data = & jx_hsmmc0_def_platdata,
},
};

The call is as follows:

Static u64 initi_device_hsmmc_dmamask = 0 xfffffffful;

Struct maid = {
. Max_width = 4,
. Host_caps = (mmc_cap_4_bit_data | mmc_cap_mmc_highspeed |
Mmc_cap_sd_highspeed ),
};

(2)

Complete the configuration of the cloud_hsmmc0_def_platdata file.

Static inline void 89c6410_default_sdhci0 (void)
{
Cloud_hsmmc0_def_platdata.clocks = cloud6410_hsmmc_clksrcs;
Cloud_hsmmc0_def_platdata.cfg_gpio = cloud6410_setup_sdhci0_cfg_gpio;
Initi_hsmmc0_def_platdata.0000_card = initi6410_setup_sdhci0_0000_card;
}

The xmmccdn0 has been configured in the function "initi6410_setup_sdhci0_gpi_gpio" so that it can only be used for mmc0 or mmc1 separately. In this function, the SD card hot swapping is detected on mmc0:

Initi_gpio_setpull (initi64xx_gpg (6), initi_gpio_pull_up );
Ap-southeast-1 ));

These things should be blocked in the corresponding "maid" field.

Supplement: in the Void 89c6410_setup_sdhci0_cfg_gpio (struct platform_device
* Dev, int
Width) is used to configure the line 1 or line 4 mode. At the beginning, the MMC Controller did not know what the card was, so the width passed in was 1, so that only
Starting with cmd and CLK, we only ensure that we can identify the card type and then pass in the specific width after identifying the card type, such as 4 or 1 for configuration. This process in sdhci-s3c-
In sdio. C.

(3)

The above is platform device, then dirver calls in the sdhci-s3c.c as follows:

Static struct platform_driver sdhci_initi_driver = {
. Probe = sdhci_cloud_probe,
. Suspend = sdhci_cloud_suspend,
. Resume = sdhci_initi_resume,
. Remove = _ devexit_p (sdhci_cloud_remove ),
. Driver = {
. Owner = this_module,
. Name = "s3c-sdhci ",
},
};

Use platform_driver_register (& sdhci_cloud_driver) to initialize the module.

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.