(GSOC2026) Proper initialization for eMMC device.

[+] Implemented proper initialization and detection for eMMC card at mmc_bus.cpp
[+] Extended SD_COMMANDS enum at mmc.h to support eMMC CMD3. some common commands
	are highlighted removing its specific card type prefix.
[+] Reading eMMC Device CID register attributes for initiating mmc disk node.
[+] added formal register content wrapper classes.
[+] Printing some attrs for debugging and verification.
[+] MMCBus and SDHCIBus are aware of the underlying card type, no problem unless more than one device
	on same mmc bus.
i followed the specs on CID stipping, still asking for your validation.

Built and tested with success for QEMU emulated sdHC eMMC device, also tested with emulated
	SD card to verify nothing backfires.
my reference is JESD84-B51 document.

*log file looks has this:
mmc_bus: Trying MMC CMD1 initialization...
...
mmc_bus: Detected MMC card after CMD1
...
...
mmc_bus: MMC RCA: 1 Status: 500
mmc_bus: MMC CID: MID=0, name="XQEMU!", PSN=31370686, PRV=201, MDT=14/2028

Change-Id: Ia6e93b154548ff7cf2dfae3bcffe85e6b2aa01fb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10641
Reviewed-by: Adrien Destugues <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
unknown rurouni
2026-04-29 07:30:15 +00:00
committed by Adrien Destugues
parent ce845a52d4
commit 4ce5404143
8 changed files with 327 additions and 116 deletions
+19 -13
View File
@@ -17,30 +17,36 @@
struct IOOperation;
enum {
typedef enum card_type {
CARD_TYPE_UNKNOWN,
CARD_TYPE_MMC,
CARD_TYPE_SD,
CARD_TYPE_SDHC,
CARD_TYPE_UHS1,
CARD_TYPE_UHS2,
CARD_TYPE_SDIO
};
} card_type;
// Commands for SD cards defined in SD Specifications Part 1:
// Physical Layer Simplified Specification Version 8.00
// Commands for SD/eMMC cards defined in:
// SD: Physical Layer Simplified Specification Version 8.00
// eMMC: JEDEC Standard No. 84-B51. Sec 6.10.4
// They are in the common .h file for the mmc stack because the SDHCI driver
// currently needs to map them to the corresponding expected response types.
// card type prefix to distinguish non common commands.
enum SD_COMMANDS {
// Basic commands, class 0
SD_GO_IDLE_STATE = 0,
SD_ALL_SEND_CID = 2,
SD_SEND_RELATIVE_ADDR = 3,
SD_SELECT_DESELECT_CARD = 7,
SD_SEND_IF_COND = 8,
SD_SEND_CSD = 9,
SD_STOP_TRANSMISSION = 12,
GO_IDLE_STATE = 0,
MMC_SEND_OP_COND = 1,
// MMC only,reserved in SD.
ALL_SEND_CID = 2,
SD_SEND_RELATIVE_ADDR = 3,
MMC_SET_RELATIVE_ADDR = 3,
SELECT_DESELECT_CARD = 7,
// resp can be R1 per mmc spec,keep R1b for now.
SD_SEND_IF_COND = 8,
SEND_CSD = 9,
SD_STOP_TRANSMISSION = 12,
// Block oriented read and write commands, class 2
SD_READ_SINGLE_BLOCK = 17,
@@ -89,7 +95,7 @@ typedef struct mmc_bus_interface {
void (*set_bus_width)(void* controller, int width);
// Set the data bus width to 1, 4 or 8 bit mode.
void (*terminate_bus)(void* controller);
// Terminate use of the underlying sdhci bus.
void (*set_card_type)(void* controller, card_type type);
} mmc_bus_interface;