Skip to contentSkip to conversation

cmd: mmc: Add mmc reg read command for reading card registers

PATCH Superseded Marek Vasut 2 participants 3 messages Oct 31, 2023

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 cmd: mmc: Add mmc reg read command for reading card registers

Add extension to the 'mmc' command to read out the card registers. Currently, only the eMMC OCR/CID/CSD/EXTCSD/RCA/DSR register are supported. A register value can either be displayed or read into an environment variable.

---
Cc: Abdellatif El Khlifi <[email protected]>
Cc: Heinrich Schuchardt <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: Jaehoon Chung <[email protected]>
Cc: Ramon Fried <[email protected]>
Cc: Roger Knecht <[email protected]>
Cc: Sean Edmond <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tobias Waldekranz <[email protected]>
---
V2: - Update documentation
V3: - Return CMD_RET_FAILURE on failure
- Add RB/TB from Jaehoon

---
 cmd/Kconfig           |  8 ++++
 cmd/mmc.c             | 96 +++++++++++++++++++++++++++++++++++++++++++
 doc/usage/cmd/mmc.rst | 26 ++++++++++++
 3 files changed, 130 insertions(+)
cmd/Kconfig +8 -0
index 60aed2c307c..d8dff42aab7 100644
@@ -1313,6 +1313,14 @@ config CMD_BKOPS_ENABLE
 	  on a eMMC device. The feature is optionally available on eMMC devices
 	  conforming to standard >= 4.41.
 
+config CMD_MMC_REG
+	bool "Enable support for reading card registers in the mmc command"
+	depends on CMD_MMC
+	default n
+	help
+	  Enable the commands for reading card registers. This is useful
+	  mostly for debugging or extracting details from the card.
+
 config CMD_MMC_RPMB
 	bool "Enable support for RPMB in the mmc command"
 	depends on SUPPORT_EMMC_RPMB
cmd/mmc.c +96 -0

114 lines not on this page · raw message

doc/usage/cmd/mmc.rst +26 -0
index 71a0303109c..c0924ba5769 100644
@@ -21,6 +21,7 @@ Synopsis
     mmc bootpart-resize <dev> <dev part size MB> <RPMB part size MB>
     mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]
     mmc rst-function <dev> <value>
+    mmc reg read <reg> <offset> [env]
 
 Description
 -----------
@@ -183,6 +184,31 @@ The 'mmc rst-function' command changes the RST_n_FUNCTION field.
         0x3
             Reserved
 
+The 'mmc reg read <reg> <offset> [env]' reads eMMC card register and
+either print it to standard output, or store the value in environment
+variable.
+
+<reg> with
+optional offset <offset> into the register array, and print it to
+standard output or store it into environment variable [env].
+
+    reg
+        cid
+            The Device IDentification (CID) register. Uses offset.
+        csd
+            The Device-Specific Data (CSD) register. Uses offset.
+        dsr
+            The driver stage register (DSR).
+        ocr
+            The operation conditions register (OCR).
+        rca
+            The relative Device address (RCA) register.
+        extcsd
+            The Extended CSD register. Uses offset.
+    offset
+        For 'cid'/'csd' 128 bit registers '[0..3]' in 32-bit increments. For 'extcsd' 512 bit register '[0..512,all]' in 8-bit increments, or 'all' to read the entire register.
+    env
+        Optional environment variable into which 32-bit value read from register should be stored.
 
 Examples
 --------
Signature · 1 line
2.42.0
#1 lore raw

Hi Marek,

cmd/Kconfig config CMD_BKOPS_ENABLE · line 1319

Quoted 4 lines · Marek Vasut
cmd/Kconfig +4 -0
+config CMD_MMC_REG
+       bool "Enable support for reading card registers in the mmc command"
+       depends on CMD_MMC
+       default n

"default n" could be dropped, since it is already the default.

#2 lore raw
Quoted 10 lines · Fabio Estevam

Hi Marek,

cmd/Kconfig config CMD_BKOPS_ENABLE · line 1319

Quoted 4 lines · Marek Vasut
cmd/Kconfig +4 -0
+config CMD_MMC_REG
+       bool "Enable support for reading card registers in the mmc command"
+       depends on CMD_MMC
+       default n

"default n" could be dropped, since it is already the default.

Should be fixed in v4, thanks