From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDE20C4338F for ; Fri, 30 Jul 2021 04:47:51 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3CC3860F01 for ; Fri, 30 Jul 2021 04:47:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3CC3860F01 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 011A9831BB; Fri, 30 Jul 2021 06:47:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="gidp3l6Z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2FD4D831E6; Fri, 30 Jul 2021 06:47:46 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::61c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 36323831D5 for ; Fri, 30 Jul 2021 06:47:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ashokred@xilinx.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LzPXgZx+YazMTisX6BlIESJIi3/8NHihWxMArQoxSfLrlrbCyaL6d2NonOq1mP6g7BctQ72RTLuBxWHJ+vNQ54y8ycDAbSljuztmqOKmsjqVePaMKvkSx68zxMKcWsYiYO5uKsMXgsJZT8jt9+TGtWzGhauAZE/m54wXWue3E5jvGTxR4WMBjJtjIOTKbVvMdGHcp1dqngY/Wm0jBQl6I7NEP/7iPiHS1eS2PSSW4su9RBME7GXa8OblLxs9oUL2Ziuq7LddoyqcWxp0jXfe8DquLYAvjg1oAn9A3aXso8Up25gWkD8xh/+800iTW3TTGD7zG1ZdEeZo5kJBELxeWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sDssSYKn8d89oM+3CtwniMTqf6I9wx/D6XI0kHuV6NQ=; b=QUtneiZReN5saAaJV6JcVKmG8AeAUPaX3mUEJxCRDLCdG978bzUW98kLUTH0yIFIBtli8VInfGjFMSFgBN0MNlCZVd6w0Lg6wtXExOStaCI1BUNBFlmYoQrKm15PnHdgn4mYHtn9p4RPVjjd44X8WKPwiGTkx4ksItcFmgJYZgv5A8pRM/4wt3fIFVUsrLPm7BcJ74oj5kNOVqMJEQjLBXSe5S4roagPqjDIJQHZL7F7KfS4Pn17wCUS7orUim3bqHc6QWsP3U/Fsj7gBc7vGHQqJlvYPBAStZOtCmXBfmg4KdeClUWimE4p3K1hjJS2LW0TCHuZpdBtoWTJmKl/Qw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=xilinx.com; dmarc=pass action=none header.from=xilinx.com; dkim=pass header.d=xilinx.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sDssSYKn8d89oM+3CtwniMTqf6I9wx/D6XI0kHuV6NQ=; b=gidp3l6Z6dhs3rHpgDuGW5BRPR611F4Oq2cHMZ11o/91BIV56ucb41QcLxxrXXjrktpXLz34IyBeEdE2HsvNuKjWfTnKg2B8EnxuzMWSWW888i/8au67ygYFr9wp9aIbx7AqgSny6Nu9fYYCn+FdipiAK7FfsUV/kPWqDkni408= Received: from BY5PR02MB6913.namprd02.prod.outlook.com (2603:10b6:a03:230::22) by BY5PR02MB6305.namprd02.prod.outlook.com (2603:10b6:a03:1fe::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.17; Fri, 30 Jul 2021 04:47:34 +0000 Received: from BY5PR02MB6913.namprd02.prod.outlook.com ([fe80::f4b3:5aa1:e87b:8a0]) by BY5PR02MB6913.namprd02.prod.outlook.com ([fe80::f4b3:5aa1:e87b:8a0%9]) with mapi id 15.20.4373.025; Fri, 30 Jul 2021 04:47:34 +0000 From: Ashok Reddy Soma To: Aswath Govindraju CC: Lokesh Vutla , Vignesh Raghavendra , Kishon Vijay Abraham I , Peng Fan , Jaehoon Chung , Simon Glass , Heinrich Schuchardt , Bin Meng , Patrick Delaunay , Pragnesh Patel , =?iso-8859-1?Q?Fr=E9d=E9ric_Danis?= , Reuben Dowle , Yangbo Lu , Stefan Bosch , Nicolas Saenz Julienne , =?iso-8859-1?Q?Pali_Roh=E1r?= , "u-boot@lists.denx.de" Subject: RE: [PATCH] mmc: Add support for enumerating MMC card in a given mode using mmc command Thread-Topic: [PATCH] mmc: Add support for enumerating MMC card in a given mode using mmc command Thread-Index: AQHXhInijVyqFvs9rUmLUO93Si5+gata74iw Date: Fri, 30 Jul 2021 04:47:34 +0000 Message-ID: References: <20210729145503.26283-1-a-govindraju@ti.com> In-Reply-To: <20210729145503.26283-1-a-govindraju@ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-TNEF-Correlator: authentication-results: ti.com; dkim=none (message not signed) header.d=none;ti.com; dmarc=none action=none header.from=xilinx.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 03a33bb0-192e-4053-b525-08d9531525b9 x-ms-traffictypediagnostic: BY5PR02MB6305: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: CmGPnRt3pY7Js/uElBWa2A6Jn4aGk9VUPjUKX8EXyjb3PtubE7t6rM+OgSy+tWCZyOn8cMBlJ2Hv0OfuOQrd+qQClqhnU4MTeo219nOxuD/yB4bT5DG9lsuV4wAzqJL4MEp5KUvvUlJY+HLWo0s31PQcoHb5Hr1rp0/OQ+TRN5E09xIXIUq5IE3fFq4fHuefki9Jy4vom9tysktmrROECCxw4OZVipGRmD5YeAG3KbkG3oOI1lIABp/NmDpSxyTXijvneEIGCNpwWdpWlVMDBkP8Uf4LCOrcTP8vcD/cr3PqhzeitAQDcybTUPp1qts1bAeArnzw19VUonXxevuJS7M3FIKnJgO/xMotTQN4AkoRXut4ixpeyFaSshOY0heWeBcbxhvl3erOrMbnGCVYZiQjBaZY84h7Oxu5VcHB+VzDevNPleneDeQta1fuwK++4gZavGI34ZxVc4AjkS5ZwzdKt8gmkzj4j3Iay/4wlFTrv/Cu6vdVYki5IcFNUCpPuWMA+xp8pZfv/JUL49hD5rphhpE4JnN+jh1fvuDDlXf+/jTyHrdU44eZdsYNeGaqO1cq0/vLNiHH8nMVsPoJn6S5l10ZTc07YMK+iKVaQmplmNijtVRoXlDp4OPl47EmZmSSC3Nv88FZr2/Z1ypVF0bFWR6ouObDCNEJM7VNzSXrSSyJ5A8hDoKHEK97Th+QKZJD91owY5jLehj38e8TUw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY5PR02MB6913.namprd02.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(39860400002)(136003)(396003)(376002)(346002)(71200400001)(66556008)(66946007)(6506007)(76116006)(9686003)(66446008)(7696005)(2906002)(66476007)(54906003)(8676002)(6916009)(64756008)(186003)(86362001)(33656002)(478600001)(66574015)(55016002)(83380400001)(26005)(316002)(4326008)(30864003)(52536014)(5660300002)(8936002)(38070700005)(122000001)(38100700002)(7416002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?Ze7ksFhJ+4HYIJVQdjCmejSjUEc7xbgn0voKmcD6WbINLaJXpplElEusBN?= =?iso-8859-1?Q?GLrO7QfpHq8uicfmsujGbMGv5mL9aKoPqgjM3vOi5vtWjvPYfGyO4yM7hT?= =?iso-8859-1?Q?1lYSUhQImr68WWQ+YcPeLDgX9ZlEdB1GGyUQYHopGqEYaxuXuTLwocc9+S?= =?iso-8859-1?Q?dw6hxuO4g0stvhkudlTnoSgd8BEiqy3+ThbdIgE3F2JDPWZZrx9oKXY55O?= =?iso-8859-1?Q?Of/Bs2psb1j74EI0ZIa4+RkeDlv3uIhXjEzA57Gq+xSAsSKTv8ozpDaJRi?= =?iso-8859-1?Q?mXeGX3OMFoIMDkuv/GXrJM9ablVeuDm94b4mDULYmTnLxOrVnbYSgGG1OM?= =?iso-8859-1?Q?E6guSvwo1yOPy9aUETlgex3LsIBzYbsDEkKK8Y5N4+MkkcIeHh09hk/dxS?= =?iso-8859-1?Q?wstKD99J4eeznH8LYV9xsNltyxxHBHng2QPFsi2uBw2XftUtNlpPczbEPG?= =?iso-8859-1?Q?tD7GceBruufYz/Hk9qsePY6bi0UMQmr7S4JA7k9OzwbdF7/CkuDreR4qP/?= =?iso-8859-1?Q?ZzJwG01lzjlolZvyf46YEeOt42yyLt221BBuShOLeP+RLqCZqkokrBa7QK?= =?iso-8859-1?Q?s2iGhmgSx/Rp2WIktuYOFHew0O3Tp+GyylRjqeqa4I5smAO2/ChO+gXt6u?= =?iso-8859-1?Q?DTyercIGYAztcrGAwNzWURg6aJL8B/l9U7EUaEpfkGmWU758T/nIltNxdi?= =?iso-8859-1?Q?G/8/SflGbaxaajeui+lFFdO5PTWSs32Hol9EXc9l+bmT0PCHk0g+u5MSZT?= =?iso-8859-1?Q?QtA6P6BuZONV6dTArXXaCAaGQsEiDEYw9e8Q9T0LaphnYFYk/vUzAl8q/O?= =?iso-8859-1?Q?mda2ItRzvF7Lqzo0jL5V5DhrH9hsXpWpwmmW408VjWUiND0qHftwqbIuh4?= =?iso-8859-1?Q?qWPPzsUeYxu7xLspg8AEI8zsWU5AU6ABEJEP5TAsJD0OLrRDTIjAqXRReo?= =?iso-8859-1?Q?5BVIp0F+GCvaHr8W1lfDfdZ3Dsrw4K2Vx8xMcoNKAIeAOyk1wFY9Pu+irP?= =?iso-8859-1?Q?EhF1WeEP+rW4Bau38EJ7VfqzJxXFDUkoFG/mZKDt8YPs5Bhvjbw0qIr3uc?= =?iso-8859-1?Q?KJnt9SZg+OWkXzDXj9oEHnpFqlxVIHe96rttRNAH6Yc2lzIyeZ3/Byka3m?= =?iso-8859-1?Q?Ln0PP30LUsuK0AojcJ9CIxAxdE+JIiKqm1Vxi9nACzQ+zeLNYeRh8495Oq?= =?iso-8859-1?Q?5+kHUi7KjQOXMJqiTrDfbI3zBXuDmpIIsCGZXilaYbgURK1PrFne3xFm9J?= =?iso-8859-1?Q?b9n8/b/43Q6TE1OW33s6OYxtGWDV/PVOPUR+e1jIg1Sav8VJJlT/O7WYMW?= =?iso-8859-1?Q?ETpo2Btwd6OkGffNT9XAvosDF/Z4gDIpA/TBZ2gE3wQKcRgTqfA8H4JFr4?= =?iso-8859-1?Q?U1wSYC0yPX?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR02MB6913.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 03a33bb0-192e-4053-b525-08d9531525b9 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Jul 2021 04:47:34.1006 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: +kiRr00W5CzmfcMBMSFOLikinoVzIsW7Iwoo5xZr9ml0EutmuysQHWpK4gum138JoWcZOCmcNQwOciM1RwSf9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR02MB6305 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Aswath, > -----Original Message----- > From: Aswath Govindraju > Sent: Thursday, July 29, 2021 8:25 PM > Cc: Lokesh Vutla ; Vignesh Raghavendra > ; Kishon Vijay Abraham I ; Aswath > Govindraju ; Peng Fan ; Jaehoon > Chung ; Simon Glass ; > Heinrich Schuchardt ; Bin Meng > ; Patrick Delaunay ; > Pragnesh Patel ; Fr=E9d=E9ric Danis > ; Reuben Dowle ; > Yangbo Lu ; Stefan Bosch ; Ashok > Reddy Soma ; Nicolas Saenz Julienne > ; Pali Roh=E1r ; u-boot@lists.de= nx.de > Subject: [PATCH] mmc: Add support for enumerating MMC card in a given > mode using mmc command >=20 > Add support for enumerating MMC card in a given mode using mmc rescan > and mmc dev commands. The speed mode is provided as the last argument in > these commands and is indicated using the index from enum bus_mode in > include/mmc.h. A speed mode can be set only if it has already been enable= d in > the device tree. >=20 > Signed-off-by: Aswath Govindraju > --- > cmd/Kconfig | 10 ++++++ > cmd/mmc.c | 71 ++++++++++++++++++++++++++++------------ > drivers/mmc/mmc-uclass.c | 3 ++ > drivers/mmc/mmc.c | 18 ++++++++++ > include/mmc.h | 4 +++ > 5 files changed, 85 insertions(+), 21 deletions(-) >=20 > diff --git a/cmd/Kconfig b/cmd/Kconfig > index ffef3cc76ca4..3a857b3f6e2e 100644 > --- a/cmd/Kconfig > +++ b/cmd/Kconfig > @@ -2389,4 +2389,14 @@ config CMD_UBIFS > help > UBIFS is a file system for flash devices which works on top of UBI. >=20 > +config MMC_SPEED_MODE_SET > + bool "set speed mode using mmc command" > + depends on CMD_MMC > + default n > + help > + Enable setting speed mode using mmc rescan and mmc dev > commands. > + The speed mode is provided as the last argument in these commands > + and is indicated using the index from enum bus_mode in > + include/mmc.h. A speed mode can be set only if it has already > + been enabled in the device tree. > endmenu > diff --git a/cmd/mmc.c b/cmd/mmc.c > index b942576b58ac..073e87d69634 100644 > --- a/cmd/mmc.c > +++ b/cmd/mmc.c > @@ -120,7 +120,9 @@ static void print_mmcinfo(struct mmc *mmc) > } > } > } > -static struct mmc *init_mmc_device(int dev, bool force_init) > + > +static struct mmc *init_mmc_device(int dev, bool force_init, > + enum bus_mode speed_mode) > { > struct mmc *mmc; > mmc =3D find_mmc_device(dev); > @@ -134,6 +136,11 @@ static struct mmc *init_mmc_device(int dev, bool > force_init) >=20 > if (force_init) > mmc->has_init =3D 0; > + > +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) > + mmc->user_speed_mode =3D speed_mode; > +#endif > + Can you please use if (IS_ENABLED(CONFIG_MMC_SPEED_MODE_SET)=20 > if (mmc_init(mmc)) > return NULL; >=20 > @@ -159,7 +166,7 @@ static int do_mmcinfo(struct cmd_tbl *cmdtp, int flag= , > int argc, > } > } >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -293,7 +300,7 @@ static int do_mmcrpmb(struct cmd_tbl *cmdtp, int flag= , > if (flag =3D=3D CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) > return CMD_RET_SUCCESS; >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -338,7 +345,7 @@ static int do_mmc_read(struct cmd_tbl *cmdtp, int > flag, > blk =3D simple_strtoul(argv[2], NULL, 16); > cnt =3D simple_strtoul(argv[3], NULL, 16); >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -387,7 +394,7 @@ static int do_mmc_sparse_write(struct cmd_tbl > *cmdtp, int flag, > return CMD_RET_FAILURE; > } >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -431,7 +438,7 @@ static int do_mmc_write(struct cmd_tbl *cmdtp, int > flag, > blk =3D simple_strtoul(argv[2], NULL, 16); > cnt =3D simple_strtoul(argv[3], NULL, 16); >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -460,7 +467,7 @@ static int do_mmc_erase(struct cmd_tbl *cmdtp, int > flag, > blk =3D simple_strtoul(argv[1], NULL, 16); > cnt =3D simple_strtoul(argv[2], NULL, 16); >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -482,8 +489,19 @@ static int do_mmc_rescan(struct cmd_tbl *cmdtp, int > flag, > int argc, char *const argv[]) > { > struct mmc *mmc; > + enum bus_mode speed_mode =3D MMC_MODES_END; > + > + if (argc =3D=3D 1) { > + mmc =3D init_mmc_device(curr_device, true, > MMC_MODES_END); > + } else if (argc =3D=3D 2) { > + /* parse the mode */ > + speed_mode =3D simple_strtoul(argv[1], NULL, 10); > + /* Need to pass the the speed mode required too */ > + mmc =3D init_mmc_device(curr_device, true, speed_mode); > + } else { > + return CMD_RET_USAGE; > + } >=20 > - mmc =3D init_mmc_device(curr_device, true); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -496,7 +514,7 @@ static int do_mmc_part(struct cmd_tbl *cmdtp, int fla= g, > struct blk_desc *mmc_dev; > struct mmc *mmc; >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -515,11 +533,14 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int > flag, { > int dev, part =3D 0, ret; > struct mmc *mmc; > + enum bus_mode speed_mode =3D MMC_MODES_END; >=20 > if (argc =3D=3D 1) { > dev =3D curr_device; > + mmc =3D init_mmc_device(dev, true, MMC_MODES_END); > } else if (argc =3D=3D 2) { > dev =3D simple_strtoul(argv[1], NULL, 10); > + mmc =3D init_mmc_device(dev, true, MMC_MODES_END); > } else if (argc =3D=3D 3) { > dev =3D (int)simple_strtoul(argv[1], NULL, 10); > part =3D (int)simple_strtoul(argv[2], NULL, 10); @@ -528,11 > +549,16 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag, > PART_ACCESS_MASK); > return CMD_RET_FAILURE; > } > + mmc =3D init_mmc_device(dev, true, MMC_MODES_END); > + } else if (argc =3D=3D 4) { > + dev =3D (int)simple_strtoul(argv[1], NULL, 10); > + part =3D (int)simple_strtoul(argv[2], NULL, 10); > + speed_mode =3D simple_strtoul(argv[3], NULL, 10); > + mmc =3D init_mmc_device(curr_device, true, speed_mode); > } else { > return CMD_RET_USAGE; > } >=20 > - mmc =3D init_mmc_device(dev, true); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -636,7 +662,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, > int flag, > enum mmc_hwpart_conf_mode mode =3D > MMC_HWPART_CONF_CHECK; > int i, r, pidx; >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -726,7 +752,7 @@ static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int > flag, > reset =3D simple_strtoul(argv[3], NULL, 10); > mode =3D simple_strtoul(argv[4], NULL, 10); >=20 > - mmc =3D init_mmc_device(dev, false); > + mmc =3D init_mmc_device(dev, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -789,7 +815,7 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, > int flag, > bootsize =3D simple_strtoul(argv[2], NULL, 10); > rpmbsize =3D simple_strtoul(argv[3], NULL, 10); >=20 > - mmc =3D init_mmc_device(dev, false); > + mmc =3D init_mmc_device(dev, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -844,7 +870,7 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int > flag, >=20 > dev =3D simple_strtoul(argv[1], NULL, 10); >=20 > - mmc =3D init_mmc_device(dev, false); > + mmc =3D init_mmc_device(dev, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -887,7 +913,7 @@ static int do_mmc_rst_func(struct cmd_tbl *cmdtp, int > flag, > return CMD_RET_USAGE; > } >=20 > - mmc =3D init_mmc_device(dev, false); > + mmc =3D init_mmc_device(dev, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -939,7 +965,7 @@ static int do_mmc_bkops_enable(struct cmd_tbl > *cmdtp, int flag, >=20 > dev =3D simple_strtoul(argv[1], NULL, 10); >=20 > - mmc =3D init_mmc_device(dev, false); > + mmc =3D init_mmc_device(dev, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; >=20 > @@ -958,7 +984,7 @@ static int do_mmc_boot_wp(struct cmd_tbl *cmdtp, int > flag, > int err; > struct mmc *mmc; >=20 > - mmc =3D init_mmc_device(curr_device, false); > + mmc =3D init_mmc_device(curr_device, false, MMC_MODES_END); > if (!mmc) > return CMD_RET_FAILURE; > if (IS_SD(mmc)) { > @@ -983,9 +1009,9 @@ static struct cmd_tbl cmd_mmc[] =3D { #if > CONFIG_IS_ENABLED(CMD_MMC_SWRITE) > U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), > #endif > - U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""), > + U_BOOT_CMD_MKENT(rescan, 2, 1, do_mmc_rescan, "", ""), > U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), > - U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""), > + U_BOOT_CMD_MKENT(dev, 4, 0, do_mmc_dev, "", ""), > U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""), #if > CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) > U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", > ""), @@ -1042,9 +1068,12 @@ U_BOOT_CMD( > "mmc swrite addr blk#\n" > #endif > "mmc erase blk# cnt\n" > - "mmc rescan\n" > + "mmc rescan [mode]\n" > "mmc part - lists available partition on current mmc device\n" > - "mmc dev [dev] [part] - show or set current mmc device [partition]\n" > + "mmc dev [dev] [part] [mode] - show or set current mmc device > [partition] and set mode\n" > + " - the required speed mode is passed as the index from the following > list\n" > + " [MMC_LEGACY, MMC_HS, SD_HS, MMC_HS_52, MMC_DDR_52, > UHS_SDR12, UHS_SDR25,\n" > + " UHS_SDR50, UHS_DDR50, UHS_SDR104, MMC_HS_200, > MMC_HS_400, MMC_HS_400_ES]\n" > "mmc list - lists available devices\n" > "mmc wp - power on write protect boot partitions\n" > #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) > diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c index > 0e13238c7e7a..66fe8bed984b 100644 > --- a/drivers/mmc/mmc-uclass.c > +++ b/drivers/mmc/mmc-uclass.c > @@ -415,6 +415,9 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, > const struct mmc_config *cfg) > bdesc->part_type =3D cfg->part_type; > mmc->dev =3D dev; >=20 > +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) > + mmc->user_speed_mode =3D MMC_MODES_END; > +#endif same here > return 0; > } >=20 > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index > 8078a89f18cb..b24a45d458d4 100644 > --- a/drivers/mmc/mmc.c > +++ b/drivers/mmc/mmc.c > @@ -2863,6 +2863,24 @@ int mmc_start_init(struct mmc *mmc) > */ > mmc->host_caps =3D mmc->cfg->host_caps | MMC_CAP(MMC_LEGACY) > | > MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT; > + > +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) here as well Thanks, Ashok > + if (mmc->user_speed_mode !=3D MMC_MODES_END) { > + int i; > + /* set host caps */ > + if (mmc->host_caps & MMC_CAP(mmc->user_speed_mode)) { > + /* Remove all existing speed capabilities */ > + for (i =3D MMC_LEGACY; i < MMC_MODES_END; i++) > + mmc->host_caps &=3D ~MMC_CAP(i); > + mmc->host_caps |=3D (MMC_CAP(mmc- > >user_speed_mode) > + | MMC_CAP(MMC_LEGACY) | > + MMC_CAP(MMC_LEGACY) | > MMC_MODE_1BIT); > + } else { > + pr_err("bus_mode requested is not supported\n"); > + return -EINVAL; > + } > + } > +#endif > #if CONFIG_IS_ENABLED(DM_MMC) > mmc_deferred_probe(mmc); > #endif > diff --git a/include/mmc.h b/include/mmc.h index > 0bf19de20e52..e64ef7611dd7 100644 > --- a/include/mmc.h > +++ b/include/mmc.h > @@ -726,6 +726,10 @@ struct mmc { > */ > u32 quirks; > u8 hs400_tuning; > + > +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) > + enum bus_mode user_speed_mode; > +#endif > }; >=20 > #if CONFIG_IS_ENABLED(DM_MMC) > -- > 2.17.1