Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: sd: Add Extension memory addressing

SDUC memory addressing spans beyond 2TB and up to 128TB. Therefore, 38
bits are required to access the entire memory space of all sectors.
Those extra 6 bits are to be carried by CMD22 prior of sending
read/write/erase commands: CMD17, CMD18, CMD24, CMD25, CMD32, and CMD33.

CMD22 will carry the higher order 6 bits, and must precedes any of the
above commands even if it targets sector < 2TB.

No error related to address or length is indicated in CMD22 but rather
in the read/write command itself.

Tested-by: Ricky WU <ricky_wu@realtek.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Avri Altman <avri.altman@wdc.com>
Link: https://lore.kernel.org/r/20241006051148.160278-3-avri.altman@wdc.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Avri Altman and committed by
Ulf Hansson
375b5359 fce2ce78

+19
+15
drivers/mmc/core/sd_ops.c
··· 16 16 #include <linux/mmc/sd.h> 17 17 18 18 #include "core.h" 19 + #include "card.h" 19 20 #include "sd_ops.h" 20 21 #include "mmc_ops.h" 21 22 ··· 187 186 *rocr = cmd.resp[0]; 188 187 189 188 return 0; 189 + } 190 + 191 + int mmc_send_ext_addr(struct mmc_host *host, u32 addr) 192 + { 193 + struct mmc_command cmd = { 194 + .opcode = SD_ADDR_EXT, 195 + .arg = addr, 196 + .flags = MMC_RSP_R1 | MMC_CMD_AC, 197 + }; 198 + 199 + if (!mmc_card_ult_capacity(host->card)) 200 + return 0; 201 + 202 + return mmc_wait_for_cmd(host, &cmd, 0); 190 203 } 191 204 192 205 static int __mmc_send_if_cond(struct mmc_host *host, u32 ocr, u8 pcie_bits,
+1
drivers/mmc/core/sd_ops.h
··· 21 21 int mmc_app_send_scr(struct mmc_card *card); 22 22 int mmc_app_sd_status(struct mmc_card *card, void *ssr); 23 23 int mmc_app_cmd(struct mmc_host *host, struct mmc_card *card); 24 + int mmc_send_ext_addr(struct mmc_host *host, u32 addr); 24 25 25 26 #endif 26 27
+3
include/linux/mmc/sd.h
··· 15 15 #define SD_SEND_IF_COND 8 /* bcr [11:0] See below R7 */ 16 16 #define SD_SWITCH_VOLTAGE 11 /* ac R1 */ 17 17 18 + /* Class 2 */ 19 + #define SD_ADDR_EXT 22 /* ac [5:0] R1 */ 20 + 18 21 /* class 10 */ 19 22 #define SD_SWITCH 6 /* adtc [31:0] See below R1 */ 20 23