mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Model the SDMMC host registers, eMMC HS200 tuning and HS400
The SDHCI power, clock, reset and HOST_CONTROL2 registers and Tegra's vendor block all read 0, whatever was written. bdk picks the eMMC bus mode from them: POWER_CONTROL reading "off" made it fall back to HS52, so the eMMC ran at 51 MHz while its EXT_CSD claimed HS400. - Keep a register file per controller for 0x28-0x3F and 0x100-0x1FF, with the TRM reset values. INTERNAL_CLK_STABLE follows INT_CLK_EN, the SW_RESET bits self-clear (RESET_ALL resets the standard registers, RESET_CMD/RESET_DATA clear their line's status), and the pad auto-calibration and DLL calibration complete at once. - Model the tuning circuit (TRM 32.9.2.14). EXECUTE_TUNING starts it, each CMD19/CMD21 tries one tap against a fixed data eye, and after NUM_TUNING_ITERATIONS commands the final tap is set per MUL_M/DIV_N. The tuning block's BUFFER_READ_READY waits for the card clock to be re-enabled, which is the order bdk waits in. - Keep EXT_CSD as one array per power cycle. CMD6 SWITCH updates its writable bytes, CMD8 reads them back, and CMD0 resets the card fields. BOOT0/BOOT1 and RPMB are 4 MiB, as on a Switch. hwtest now tunes the eMMC in 128 iterations and reports a 199.68 MHz HS400 card clock. The hwtest check asserts both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
This commit is contained in:
3 files changed
+410
-68
No files matched your search
@@ -20,7 +20,7 @@ flowchart TB
|
||||
|
||||
uc -->|MMIO callbacks| mmio["<b>t210/mmio.cpp</b><br/>mmio_bus_read / mmio_bus_write<br/>shared by both masters"]
|
||||
|
||||
mmio --> sdmmc["<b>sdmmc</b><br/>SDMMC1 / SDMMC4<br/>CMD0..18, EXT_CSD, ADMA2"]
|
||||
mmio --> sdmmc["<b>sdmmc</b><br/>SDMMC1 / SDMMC4<br/>CMD0..21, EXT_CSD, ADMA2<br/>HS200 tuning, HS400"]
|
||||
mmio --> se["<b>se_engine</b><br/>AES-128, SHA-256<br/>BIS keyslot override"]
|
||||
mmio --> i2c["<b>i2c3</b><br/>STMFTS / FTS4 touch"]
|
||||
mmio --> i2c1["<b>I2C_1 slaves</b> (inline)<br/>MAX17050, TMP451,<br/>BQ24193, BM92T36"]
|
||||
@@ -106,7 +106,7 @@ of the spec is modelled for the Hekate, Lockpick and TE init paths:
|
||||
- CMD0 GO_IDLE, CMD1 SEND_OP_COND, CMD2 ALL_SEND_CID, CMD3 SEND_RELATIVE_ADDR,
|
||||
CMD6 SWITCH, CMD7 SELECT_CARD, CMD8 SEND_EXT_CSD (eMMC) or SEND_IF_COND (SD),
|
||||
CMD9 SEND_CSD, CMD13 SEND_STATUS, CMD16 SET_BLOCKLEN, CMD17 and CMD18
|
||||
READ_(MULTI_)BLOCK, CMD55 APP_CMD.
|
||||
READ_(MULTI_)BLOCK, CMD19 / CMD21 SEND_TUNING_BLOCK, CMD55 APP_CMD.
|
||||
- ADMA2 (Advanced DMA 2) with 64-bit descriptors, multi-block reads chunked
|
||||
into the host file IO via `pread`-style calls.
|
||||
- `--rawnand` opens the matching `rawnand.bin.NN` chunks and `fstat`s the first
|
||||
@@ -127,6 +127,37 @@ of the spec is modelled for the Hekate, Lockpick and TE init paths:
|
||||
sec_cnt) and writes it via the configured ADMA2 descriptor before raising
|
||||
the IRQ.
|
||||
|
||||
#### Host controller registers and HS400
|
||||
|
||||
Each controller keeps its SDHCI registers (0x28-0x3F: power, clock, software
|
||||
reset, HOST_CONTROL2) and Tegra's vendor block (0x100-0x1FF) in a register
|
||||
file with the TRM's reset values, plus the side effects bdk waits on:
|
||||
|
||||
- CLOCK_CONTROL reports INTERNAL_CLK_STABLE once INT_CLK_EN is set.
|
||||
SOFTWARE_RESET's bits self-clear. RESET_ALL puts the standard registers
|
||||
back to reset and leaves the vendor block alone.
|
||||
- AUTO_CAL_CONFIG.START and DLLCAL_CFG.CALIBRATE self-clear, and the status
|
||||
registers report the calibration done.
|
||||
- Setting HOST_CONTROL2.EXEC_TUNING starts tuning. Each CMD19/CMD21 tries one
|
||||
tap: with TAP_VAL_UPDATED_BY_HW the taps step from TUNING_CNTRL0.START_TAP
|
||||
by TUNING_CNTRL1's step size, otherwise the tap in VENDOR_CLOCK_CNTRL is
|
||||
used. A tap passes when it falls in the modelled data eye, taps 26..82.
|
||||
After NUM_TUNING_ITERATIONS commands EXEC_TUNING clears and TUNED_CLK is
|
||||
set. The pass map lands in TUNING_STATUS0, and the chosen tap, first +
|
||||
(last - first) x (MUL_M + 1) / 2^DIV_N (TRM 32.9.2.14), lands in
|
||||
VENDOR_CLOCK_CNTRL. The tuning block's BUFFER_READ_READY is held until the
|
||||
card clock is re-enabled, the order in which bdk's tuning loop waits.
|
||||
- EXT_CSD is one 512-byte array that lives for a power cycle. CMD6 SWITCH
|
||||
(write byte, set bits or clear bits) changes the bytes eMMC 5.1 makes
|
||||
writable (BUS_WIDTH, HS_TIMING, PARTITION_CONFIG and a few more). CMD8
|
||||
returns the array and CMD0 puts the card-reset fields back. CARD_TYPE
|
||||
advertises HS400 at 1.8 V, so bdk goes 8-bit, then HS200 (tuned), then
|
||||
HS400, and reports a 199.68 MHz card clock. BOOT0, BOOT1 and RPMB are
|
||||
4 MiB each, as on a Switch.
|
||||
|
||||
The SD card stays at High Speed (48 MHz). UHS-I needs ACMD41 to answer with
|
||||
S18A and a CMD11 voltage switch, which the SD model does not do.
|
||||
|
||||
### Security Engine (`t210/se_engine.cpp`)
|
||||
|
||||
Models the SE (Security Engine) register block at `0x70012000`. Supports:
|
||||
|
||||
Reference in new issue
Block a user