[PATCH PATCHSET 4/6] ufs: ufs tool
Neil Armstrong
neil.armstrong at linaro.org
Thu Jun 4 14:48:46 CEST 2026
On 6/4/26 13:25, Raz Ben Yehuda via B4 Relay wrote:
> From: Raz Ben Yehuda <raz.benyehuda at mobileye.com>
>
> The UFS tool provides utilities for querying, displaying, and modifying
> UFS device configuration and descriptor information.
>
> Features:
> - Query and display Device, Geometry, Unit, Configuration, and Power
> Descriptors
> - Display LUN configuration and calculated capacities
> - Modify LUN, Configuration, and Device Descriptor fields
> - Configure WriteBooster-related parameters
> - Query common UFS runtime flags
> - Commit configuration changes or clear all LUN configurations
> - Decode and format descriptor contents for easier debugging
>
> Signed-off-by: Raz Ben Yehuda <raz.benyehuda at mobileye.com>
> ---
> cmd/ufs.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
> 1 file changed, 89 insertions(+), 4 deletions(-)
>
> diff --git a/cmd/ufs.c b/cmd/ufs.c
> index 790dab50f18..c8bafcd5e1d 100644
> --- a/cmd/ufs.c
> +++ b/cmd/ufs.c
> @@ -24,15 +24,100 @@ static int do_ufs(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
> } else {
> ufs_probe();
> }
> -
> return CMD_RET_SUCCESS;
> }
> - }
>
> - return CMD_RET_USAGE;
> +#if IS_ENABLED(CONFIG_UFS_TOOL)
> + if (!strcmp(argv[1], "query")) {
> + int lun = -1;
> + int idn = -1;
> +
> + if (argc <= 3) {
> + printf("usage: lun idn");
> + return CMD_RET_FAILURE;
> + }
> +
> + lun = dectoul(argv[2], NULL);
> + idn = dectoul(argv[3], NULL);
> +
> + return ufs_tool_query(lun, idn);
> + }
> +
> + if (!strcmp(argv[1], "set_lun")) {
> + int lun;
> + u32 val;
> +
> + if (argc <= 4) {
> + ufs_tool_help();
> + return CMD_RET_FAILURE;
> + }
> + lun = dectoul(argv[2], NULL);
> + val = dectoul(argv[4], NULL);
> + return ufs_tool_set_lun(lun, argv[3], val);
> + }
> +
> + if (!strcmp(argv[1], "set_dev_desc")) {
> + const char *name;
> + u32 val;
> +
> + if (argc <= 3) {
> + ufs_tool_help();
> + return CMD_RET_FAILURE;
> + }
> + name = argv[2];
> + val = dectoul(argv[3], NULL);
> + return ufs_tool_set_device_desc(name, val);
> + }
> +
> + if (!strcmp(argv[1], "set_cfg_desc")) {
> + const char *name;
> + u32 val;
> +
> + if (argc <= 3) {
> + ufs_tool_help();
> + return CMD_RET_FAILURE;
> + }
> + name = argv[2];
> + val = dectoul(argv[3], NULL);
> + return ufs_tool_set_config_desc(name, val);
> + }
> +
> + if (!strcmp(argv[1], "getflag")) {
> + if (argc == 2) {
> + printf("usage: getflag [flag name]");
> + ufs_tool_help();
> + return CMD_RET_FAILURE;
> + }
> + return ufs_tool_query_flag(argv[2]);
> + }
> +
> + if (!strcmp(argv[1], "commit"))
> + return ufs_tool_commit();
> +
> + if (!strcmp(argv[1], "clearall"))
> + return ufs_tool_clearall();
> +
> + if (!strcmp(argv[1], "luns")) {
> + ufs_tool_print_luns();
> + return 0;
> + }
> + }
> + ufs_tool_help();
> +#endif
> + return CMD_RET_FAILURE;
> }
>
> -U_BOOT_CMD(ufs, 3, 1, do_ufs,
> +U_BOOT_CMD(ufs, 5, 1, do_ufs,
> "UFS sub-system",
> "init [dev] - init UFS subsystem\n"
> +#if IS_ENABLED(CONFIG_UFS_TOOL)
> + "query [LUN] [IDN]\n"
> + "set_lun [LUN] [parm name] [value]\n"
> + "set_cfg_des [parm name] [value]\n"
> + "set_dev_desc [parm name] [value]\n"
> + "luns - prints luns\n"
> + "clearall - zero out configuration descriptor\n"
> + "getflag [flag name]\n"
> + "commit - writes luns configuration\n"
> +#endif
> );
>
I'm still puzzled on the overall design, I think most of the "tool"
code should be in cmd/ and only the helpers should be in drivers/ufs,
and not in a dedicated ufs-tool.c but either in the core or in a separate
helpers.c file.
Neil
More information about the U-Boot
mailing list