Skip to contentSkip to conversation

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

PATCH In review Marek Vasut 3 participants 3 messages Oct 31, 2023 – Nov 1, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v4 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
V4: - Drop default n

---
 cmd/Kconfig           |  7 ++++
 cmd/mmc.c             | 96 +++++++++++++++++++++++++++++++++++++++++++
 doc/usage/cmd/mmc.rst | 26 ++++++++++++
 3 files changed, 129 insertions(+)
cmd/Kconfig +7 -0
index 60aed2c307c..fd16c3a48e5 100644
@@ -1313,6 +1313,13 @@ 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
+	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
Reviewed-by on v4 1/1
#1 lore raw
Quoted 9 lines · Marek Vasut

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.

#2 lore raw
Quoted 20 lines

-----Original Message-----
From: Fabio Estevam <[email protected]>
Sent: Wednesday, November 1, 2023 1:09 AM
To: Marek Vasut <[email protected]>
Cc: [email protected]; Jaehoon Chung <[email protected]>; Abdellatif El Khlifi <[email protected]>; Heinrich Schuchardt <[email protected]>; Ilias Apalodimas <[email protected]>; Ramon Fried <[email protected]>; Roger Knecht <[email protected]>; Sean Edmond <[email protected]>; Simon Glass <[email protected]>; Tobias Waldekranz <[email protected]>
Subject: Re: [PATCH v4] cmd: mmc: Add mmc reg read command for reading card registers

Quoted 6 lines · Marek Vasut

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.

Quoted 5 lines
Quoted 3 lines

Applied to u-boot-mmc/master. Thanks!

Best Regards,
Jaehoon Chung