From bafcb38ec935328e38a5ee5aa61da596d2559b0f Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Mon, 17 Aug 2026 11:32:10 +0100 Subject: [PATCH] sdmmc_host: read card SCR register to fill cardinfo struct Change-Id: I2ef8f823d93001f15ea4e794a50f7fc115a55ce6 --- firmware/drivers/sdmmc_host.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/firmware/drivers/sdmmc_host.c b/firmware/drivers/sdmmc_host.c index 5fdf3b0898..1cec921d80 100644 --- a/firmware/drivers/sdmmc_host.c +++ b/firmware/drivers/sdmmc_host.c @@ -466,6 +466,30 @@ static int sdmmc_host_cmd_send_csd(struct sdmmc_host *host) return rc; } +static int sdmmc_host_cmd_send_scr(struct sdmmc_host *host) +{ + struct sdmmc_host_command cmd = { + .command = SD_SEND_SCR, + .buffer = sdmmc_host_get_dc_buffer(host), + .flags = SDMMC_RESP_SHORT | SDMMC_DATA_READ, + .nr_blocks = 1, + .block_len = 8, + }; + + int rc = sdmmc_host_submit_app_cmd(host, &cmd, NULL); + if (rc) + return rc; + + /* + * Card sends the most significant byte first so + * convert the data to native endian. + */ + host->cardinfo.scr[0] = load_be32_aligned(cmd.buffer + 4); + host->cardinfo.scr[1] = load_be32_aligned(cmd.buffer + 0); + + return rc; +} + static int sdmmc_host_cmd_select_card(struct sdmmc_host *host) { struct sdmmc_host_command cmd = { @@ -664,6 +688,13 @@ static int sdmmc_host_device_init(struct sdmmc_host *host) sdmmc_host_set_controller_bus_clock(host, SDMMC_BUS_CLOCK_25MHZ); } + rc = sdmmc_host_cmd_send_scr(host); + if (rc) + { + logf("sdmmc_host_cmd_send_scr: %d", rc); + return rc; + } + host->initialized = true; host->cardinfo.initialized = true; return 0;