cmd: mmc: allow 'mmc rst-function' to show the current value
PATCH 1/1 cmd: mmc: allow 'mmc rst-function' to show the current value
Extend the 'mmc rst-function' subcommand so that lacking a value to set, it simply prints the current value, and its interpretation.
Signed-off-by Rasmus Villemoes <[email protected]>
--- cmd/mmc.c | 36 +++++++++++++++++++++++++++--------- doc/usage/cmd/mmc.rst | 4 ++-- 2 files changed, 29 insertions(+), 11 deletions(-)
cmd/mmc.c +27 -9
@@ -1012,16 +1012,10 @@ static int do_mmc_rst_func(struct cmd_tbl *cmdtp, int flag,* The only valid values are 0x0, 0x1 and 0x2 and writing * a value of 0x1 or 0x2 sets the value permanently. */ -if (argc !=3 ) +if (argc <2 || argc >3 )return CMD_RET_USAGE ; dev =dectoul (argv[1 ],NULL ); - enable =dectoul (argv[2 ],NULL ); - -if (enable >2 ) { -puts ("Invalid RST_n_ENABLE value\n" ); -return CMD_RET_USAGE ; - } mmc =init_mmc_device (dev, false);if (!mmc)
@@ -1032,6 +1026,30 @@ static int do_mmc_rst_func(struct cmd_tbl *cmdtp, int flag,return CMD_RET_FAILURE ; } +if (argc ==2 ) { +ALLOC_CACHE_ALIGN_BUFFER (u8, ext_csd,MMC_MAX_BLOCK_LEN ); + ret =mmc_send_ext_csd (mmc, ext_csd); +if (ret) +return CMD_RET_FAILURE ; + +printf ("RST_n_FUNCTION: 0x%x " , ext_csd[EXT_CSD_RST_N_FUNCTION ]); +switch (ext_csd[EXT_CSD_RST_N_FUNCTION ]) { +case 0x0 :puts ("(temporarily disabled)\n" );break ; +case 0x1 :puts ("(permanently enabled)\n" );break ; +case 0x2 :puts ("(permanently disabled)\n" );break ; +default :puts ("(unknown)\n" ); + } + +return CMD_RET_SUCCESS ; + } + + enable =dectoul (argv[2 ],NULL ); + +if (enable >2 ) { +puts ("Invalid RST_n_ENABLE value\n" ); +return CMD_RET_USAGE ; + } + ret =mmc_set_rst_n_function (mmc, enable);if (ret !=0 )return CMD_RET_FAILURE ;
@@ -1344,8 +1362,8 @@ U_BOOT_CMD("mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]\n" " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" " If showing the bits, optionally store the boot_partition field into varname\n" -"mmc rst-function <dev> <value>\n" -" - Change the RST_n_FUNCTION field of the specified device\n" +"mmc rst-function <dev> [<value>]\n" +" - Show or change the RST_n_FUNCTION field of the specified device\n" " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"#endif #if CONFIG_IS_ENABLED (CMD_MMC_RPMB )
doc/usage/cmd/mmc.rst +2 -2
@@ -24,7 +24,7 @@ Synopsis mmc bootbus <dev> <boot_bus_width> <reset_boot_bus_width> <boot_mode> 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 rst-function <dev> [<value>] mmc reg read <reg> <offset> [env] Description
@@ -178,7 +178,7 @@ The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions. RPMB part size MB target size of RPMB partition -The 'mmc rst-function' command changes the RST_n_FUNCTION field. +The 'mmc rst-function' command shows or changes the RST_n_FUNCTION field. **WARNING** : This is a write-once field. (*Refer to eMMC specification*) value
Signature · 1 line
2.53.0
Hi Rasmus,
Quoted 13 lines · Rasmus Villemoes
cmd: mmc: allow 'mmc rst-function' to show the current value
Extend the 'mmc rst-function' subcommand so that lacking a value to set, it simply prints the current value, and its interpretation.
Signed-off-by Rasmus Villemoes <[email protected]>
cmd/mmc.c| 36 +++++++++++++++++++++++++++---------doc/usage/cmd/mmc.rst | 4 ++-- 2 files changed, 29 insertions(+), 11 deletions(-)
cmd/mmc.c static int do_mmc_rst_func(...) · line 1031
Quoted 6 lines
cmd/mmc.c +6
-0@@ -1032,6 +1026,30 @@ static int do_mmc_rst_func(...) +switch (ext_csd[EXT_CSD_RST_N_FUNCTION ]) { +case 0x0 :puts ("(temporarily disabled)\n" );break ; +case 0x1 :puts ("(permanently enabled)\n" );break ; +case 0x2 :puts ("(permanently disabled)\n" );break ; +default :puts ("(unknown)\n" ); + }
We normally put case/default on their own line, as elsewhere in this file.
I'd even suggest putting this code in its own function.
Regards,
Simon