Skip to main content

Crate dwmmc_host

Crate dwmmc_host 

Source
Expand description

Synopsys DesignWare Mobile Storage Host Controller (DW_mshc) backend for the sdmmc-protocol driver crate.

Implements sdmmc_protocol::sdio::SdioHost for the IP block known variously as DWC_mobile_storage, dw_mshc, dw_mmc (Linux), or simply the “Synopsys SD/MMC controller” — the same core used in Rockchip RK33xx/RK35xx, Allwinner A-series, StarFive JH7110, and a long tail of mid-range SoCs. Block I/O can be submitted through either the FIFO path or the internal DMAC (IDMAC) path with the same poll contract.

§Scope

  • Implemented: PIO data transfer over the 0x100/0x200/0x400 FIFO (configurable), IDMAC descriptor transfers, 1-bit / 4-bit / 8-bit bus selection, default / high-speed / UHS-I / HS200 clocking, DW_mshc UHS DDR and 1.8 V signaling bits, R1/R1b/R2/R3/R4/R5/R6/R7 response decoding, software reset.
  • Out of scope (for now): external-DMA path, controller-specific DLL/strobe/tuning window setup (CMD19/CMD21).

§Usage

use core::ptr::NonNull;

use dwmmc_host::DwMmc;
use sdmmc_protocol::sdio::{SdioInitScratch, SdioSdmmc};

// SAFETY: 0xFE2B_0000 must point at a valid DW_mshc register file
// the caller has exclusive access to.
let mmio = NonNull::new(0xFE2B_0000 as *mut u8).unwrap();
let mut host = unsafe { DwMmc::new(mmio) };
host.set_reference_clock(50_000_000);
host.reset_and_init().expect("controller reset");

let mut card = SdioSdmmc::new(host);
let mut scratch = SdioInitScratch::new();
let mut request = card.submit_init(&mut scratch)?;
// Poll request here. Runtime code chooses spin, yield, IRQ wait, or timer.

The runtime block queue adapter belongs in OS/platform glue. The reusable driver crate exposes request state and host submit/poll primitives instead:

use dwmmc_host::BlockQueue;

Construction is unsafe because the caller must guarantee that the supplied address is a valid, exclusively-owned DW_mshc register file.

Structs§

BlockBufferConfig
Buffer and address constraints exposed by a host block queue.
BlockRequest
BlockRequestId
Stable identifier returned by a host block queue after submission.
BlockRequestSlot
DataRequest
DwMmc
DesignWare Mobile Storage Host Controller backend.

Enums§

BlockPoll
Result of advancing a submitted transfer without blocking.
BlockTransferDirection
Direction of a block request.
BlockTransferMode
Data engine used by an in-flight block request.
BlockTransferState
Observable state of one host block-transfer state machine.
Event
Stable controller event extracted from DW_mshc raw interrupt status.

Constants§

DEFAULT_FIFO_OFFSET
Default FIFO offset used by Rockchip DWC_mobile_storage variants (RK3399, RK356x, RK35xx). Other SoCs may differ — pass a custom offset to DwMmc::new_with_fifo_offset.
IDMAC_DESC_ALIGN
IDMAC_DESC_SIZE

Type Aliases§

RequestId