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=-18.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 11F6BC4338F for ; Fri, 30 Jul 2021 09:32:08 +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 4E79060EFD for ; Fri, 30 Jul 2021 09:32:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4E79060EFD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.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 ACEA58322D; Fri, 30 Jul 2021 11:32:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.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=samsung.com header.i=@samsung.com header.b="L/U7no0u"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6572B83259; Fri, 30 Jul 2021 11:32:02 +0200 (CEST) Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) (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 961BA831F7 for ; Fri, 30 Jul 2021 11:31:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jh80.chung@samsung.com Received: from epcas1p4.samsung.com (unknown [182.195.41.48]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20210730093145epoutp04be1784da265d2412c1698cff64b6f99f~Wh7ADIsx11165411654epoutp04D for ; Fri, 30 Jul 2021 09:31:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20210730093145epoutp04be1784da265d2412c1698cff64b6f99f~Wh7ADIsx11165411654epoutp04D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1627637505; bh=MDjb9UkxMBTd887OI5tEqDlpzrq/8o3KkTxCoDjxymk=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=L/U7no0ua/EmNYsoZSUzJ3KMSOruUsquo5zegVwA+YxQeqqQeKTfhL7Ck4FiVAnSv GbiVs44X+k/yEwLm8LDt5B70VR6tewUDOsF6NKK4objcN8rYZxhcn2ejpyWwi94tT/ 8fuPBvfuhn6NEgTZ3kT482RCCyZZVZOxeh9yF8SY= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20210730093144epcas1p18ea3ab52359ee42c80590e8db962cf95~Wh6-Xlu9w2393823938epcas1p1S; Fri, 30 Jul 2021 09:31:44 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.153]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4GbhxB3dr4z4x9Pq; Fri, 30 Jul 2021 09:31:42 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 2D.C7.09952.EF6C3016; Fri, 30 Jul 2021 18:31:42 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas1p3.samsung.com (KnoxPortal) with ESMTPA id 20210730093141epcas1p3b20d0f8388d86d94f46bc35f966d7d79~Wh68mfkxf1440614406epcas1p3d; Fri, 30 Jul 2021 09:31:41 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20210730093141epsmtrp1577b976fa86a32035f2123933985ea12~Wh68koI4Y3077530775epsmtrp1R; Fri, 30 Jul 2021 09:31:41 +0000 (GMT) X-AuditID: b6c32a35-45dff700000026e0-dc-6103c6fee106 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 1A.21.08394.DF6C3016; Fri, 30 Jul 2021 18:31:41 +0900 (KST) Received: from [10.113.113.235] (unknown [10.113.113.235]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20210730093141epsmtip2cb792723ddeda0f293387c2cdecc2a6f~Wh68K_B0x2449824498epsmtip2N; Fri, 30 Jul 2021 09:31:41 +0000 (GMT) Subject: Re: [PATCH] mmc: Add support for enumerating MMC card in a given mode using mmc command To: Aswath Govindraju Cc: Lokesh Vutla , Vignesh Raghavendra , Kishon Vijay Abraham I , Peng Fan , Simon Glass , Heinrich Schuchardt , Bin Meng , Patrick Delaunay , Pragnesh Patel , =?UTF-8?Q?Fr=c3=a9d=c3=a9ric_Danis?= , Reuben Dowle , Yangbo Lu , Stefan Bosch , Ashok Reddy Soma , Nicolas Saenz Julienne , =?UTF-8?Q?Pali_Roh=c3=a1r?= , u-boot@lists.denx.de From: Jaehoon Chung Message-ID: Date: Fri, 30 Jul 2021 18:32:32 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA01TfUxTVxz1vvf6XmGpe5aPXkk2oBl/wCxQaPHBgGxq3NuUBeOSjS0Ib/QF kNJ2LXUi6upIGDCIdMgmFQQ3CAouZFBLwXVKmXQEGIKbMBR1rOiYA8unZCispZDx3/ndc849 OfeDi/JncD9upiKHVSsYuRD3xExdwSLRSjfKhD94KqDO24c4lPWmDqEqSlKoxgcXCOrmRAlO XSycB5TJ0IBTtT/04tSXzbcJaqlxnkP9Zuh0au9/h1KLRhOgFhKpKUsRQa32Owiqq8IBqMoe yet8+pxuEKPNY3WAnjh9haDbDWME7Zg5RLc0FuF0/10zoL+fNiP0n109BD2UP0zQrb15tG2k DaEtc8tYIu+DrNgMlpGx6gBWkaaUZSrS44T7DqbsTpFGhYtF4mhqpzBAwWSzccI9+xNFezPl zoLCgCOMXOtcSmQ0GmFYfKxaqc1hAzKUmpw4IauSyVXRqlANk63RKtJD05TZMeLw8AipU5ia lfFohFD9qjhqvdWH68DK+8XAgwtJCaypnMSLgSeXT5oBrL4yg7oIPjkL4Hi7j5tYBLDY0Uls OEZnLxJuwgJgSccs5h6eAFjXVIm4VF7kR9BkHOa4sDf5Kmwt1nNcIpT8kQMfPXmGuQic3AHb Fm1rBh4ZD+8MVaxlY2QQ7CkdXsM+ZBIcuFqLuTXbYE+lfQ17kDFQd/0G7sIoKYCj9hrEjf1h 21QV6gqDZLkHnLM9dCZzncMeONi5XtoL/m0zrtfxg5OnC9ZxHuzI71v3FgI4avoMcROR8Fp9 OeLaByWDYXNHmHs5ELYvVwN37lY4vVCyHsWDhQV8t+QVOPR4EtmIGrOvctyYhkWXziBlINCw qZlhUxvDpjaG/4NrAdYIfFmVJjud1YhV4s2X3QLW3n6I1Az0U45QK0C4wAogFxV68x4vraby eTIm9xirVqaotXJWYwVS51nrUT+fNKXz8yhyUsTSiMjISEoijpKKxUIBbzF5IZVPpjM5bBbL qlj1hg/hevjpkOjB1zovHC4Y714ZqSiVTMvPKs8U5B8u/+aX+hKVNJb88FSmPfxuUG5x/ZZ9 L0/cxvK8nrWa5fregW798Xe+HUr4NDkjxuFrOVZ34s3d+ucf5zL9NbPl3CPVQbssRbfuZ/l/ Pb/18rJsNPZAyB38iyUT72oYW3fQd1uZLeHtPyxvlPbMNL1r3Lvz54WfsF1ZLY6Gf19sfiGk U5v33sr2vuQDgScNTNSWXMEnE9vZe1ZbZld/k+Cl2tb68ZMT3tc6vjou8rx3dvB3MrIBpbQt h96KSQiOrnr6PCKsLF46IEu69Lkt5lzUiX8C7afm/rpMLCUJRIukv3Fqh9+N61UPj5Z6SBSG MLUQ02Qw4hBUrWH+A4ZyOCOEBAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrAIsWRmVeSWpSXmKPExsWy7bCSvO7fY8yJBs2rZC3mPbnEanHoQgOT xdSeeItVDxayW1x42sNmsaLjC6PFtlnL2SwW7DnNZjFp/TV2ix+rvrBaXJ11EKj2/lpmi29b tjFafA2weLu3k93i/9kP7BaHp35gtJh50sRByGN2w0UWjx13lzB6PO3fyu6xc9Zddo8PH+M8 Nq3qZPM4e2cHo8fGdzuYPB4fPsnucan5OrvH5tPVHsdvbGfy2Pv5N0sAbxSXTUpqTmZZapG+ XQJXxvMb7AVX8ioOXT7D1sD4L6KLkZNDQsBE4tanFexdjFwcQgK7GSUu/OpghkhISXx+OpWt i5EDyBaWOHy4GKLmLaPEpJ41YHFhgSSJH3cMQMpFBLQlNndNZAWpYRY4xCqxY/9bqKHXmCSm be1iAqliE9CR2P7tOJjNK2AncfvSVLBlLAKqEid7r4PZogKREp8XvGKFqBGUODnzCQuIzSlg JdFw4CgbiM0soC7xZ94lZghbXOLWk/lMELa8xPa3c5gnMArNQtI+C0nLLCQts5C0LGBkWcUo mVpQnJueW2xYYJiXWq5XnJhbXJqXrpecn7uJERzpWpo7GLev+qB3iJGJg/EQowQHs5II7+sf /xOEeFMSK6tSi/Lji0pzUosPMUpzsCiJ817oOhkvJJCeWJKanZpakFoEk2Xi4JRqYKqNvznl 9JSPTcfYOD/KHTfwezNp1tkzTj+XLlda9Yvb1HKl8qNXLtragrOlVbaVXP/lqvTxvrnBI+UN Nu/uczP4WHQeO9578raxh5lYO3/om0kiGV+7pvBar1279pil8cwPi1blv50W9vFq5bVT377P +tO6WUJS6WbDujvMQr2yZVUXalYz/58QfEJ+W/ry77ujj6knrHYQ//Pq/sE5nevSnGe9Wcq3 tnHL1wfW05VfTAyf9r1yxnf9P34bmP31Fj90ufrRuUzH4UzD0asTg46larDuWrxbOVq31+1v kZ/+a5f7F5TO8Z9QOc1S/iqJ58mDWKY+R6l9x44774q/uOebT2TcdIcNLRaZPPnODnsElViK MxINtZiLihMBtxix5WMDAAA= X-CMS-MailID: 20210730093141epcas1p3b20d0f8388d86d94f46bc35f966d7d79 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20210729145609epcas1p2cbcf3ea3b79069f62e54e879390a76fd References: <20210729145503.26283-1-a-govindraju@ti.com> <4c596161-e0fd-73ec-a120-5dcba1491f6a@samsung.com> <5dd17830-b6e1-e6e7-4e58-52993db4ab13@ti.com> 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 On 7/30/21 6:20 PM, Aswath Govindraju wrote: > Hi Jaehoon, > > On 30/07/21 2:44 pm, Jaehoon Chung wrote: >> Hi Aswath, >> >> On 7/30/21 2:12 PM, Aswath Govindraju wrote: >>> Hi Jaehoon, >>> >>> On 30/07/21 4:00 am, Jaehoon Chung wrote: >>>> Hi Aswath, >>>> >>>> On 7/29/21 11:55 PM, Aswath Govindraju wrote: >>>>> 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 enabled >>>>> in the device tree. >>>> >>>> Thanks for this patch. It seems that it's useful to develope and debug. >>>> I will test with this patch. >>>> >>>> Could you also update doc/usage/mmc.rst file? >>>> >>> >>> Sure, I'll update it in the respin. >> >> When I have simply tested with this patch, it's not working correct. >> I will test more and share them. Did you test about SD-card? >> > > Yes, I tested with both SD-Card and eMMC. > > Also, please note that MMC_SPEED_MODE_SET has to be enabled in the > defconfig files. I did. :) (enabled MMC_SPEED_MODE_SET). If it's not supported mode, it seems that always set to LEGACY mode. Is it intention behavior? I will test on eMMC and SD. Well it will take a little time. Maybe Next week? Best Regards, Jaehoon Chung > > Thanks, > Aswath > >> Best Regards, >> Jaehoon Chung >> >>> >>> Thanks, >>> Aswath >>> >>>> Best Regards, >>>> Jaehoo Chung >>>> >>>>> >>>>> 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(-) >>>>> >>>>> 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. >>>>> >>>>> +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 = find_mmc_device(dev); >>>>> @@ -134,6 +136,11 @@ static struct mmc *init_mmc_device(int dev, bool force_init) >>>>> >>>>> if (force_init) >>>>> mmc->has_init = 0; >>>>> + >>>>> +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) >>>>> + mmc->user_speed_mode = speed_mode; >>>>> +#endif >>>>> + >>>>> if (mmc_init(mmc)) >>>>> return NULL; >>>>> >>>>> @@ -159,7 +166,7 @@ static int do_mmcinfo(struct cmd_tbl *cmdtp, int flag, int argc, >>>>> } >>>>> } >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -293,7 +300,7 @@ static int do_mmcrpmb(struct cmd_tbl *cmdtp, int flag, >>>>> if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) >>>>> return CMD_RET_SUCCESS; >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -338,7 +345,7 @@ static int do_mmc_read(struct cmd_tbl *cmdtp, int flag, >>>>> blk = simple_strtoul(argv[2], NULL, 16); >>>>> cnt = simple_strtoul(argv[3], NULL, 16); >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -387,7 +394,7 @@ static int do_mmc_sparse_write(struct cmd_tbl *cmdtp, int flag, >>>>> return CMD_RET_FAILURE; >>>>> } >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -431,7 +438,7 @@ static int do_mmc_write(struct cmd_tbl *cmdtp, int flag, >>>>> blk = simple_strtoul(argv[2], NULL, 16); >>>>> cnt = simple_strtoul(argv[3], NULL, 16); >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -460,7 +467,7 @@ static int do_mmc_erase(struct cmd_tbl *cmdtp, int flag, >>>>> blk = simple_strtoul(argv[1], NULL, 16); >>>>> cnt = simple_strtoul(argv[2], NULL, 16); >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -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 = MMC_MODES_END; >>>>> + >>>>> + if (argc == 1) { >>>>> + mmc = init_mmc_device(curr_device, true, MMC_MODES_END); >>>>> + } else if (argc == 2) { >>>>> + /* parse the mode */ >>>>> + speed_mode = simple_strtoul(argv[1], NULL, 10); >>>>> + /* Need to pass the the speed mode required too */ >>>>> + mmc = init_mmc_device(curr_device, true, speed_mode); >>>>> + } else { >>>>> + return CMD_RET_USAGE; >>>>> + } >>>>> >>>>> - mmc = init_mmc_device(curr_device, true); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -496,7 +514,7 @@ static int do_mmc_part(struct cmd_tbl *cmdtp, int flag, >>>>> struct blk_desc *mmc_dev; >>>>> struct mmc *mmc; >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -515,11 +533,14 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag, >>>>> { >>>>> int dev, part = 0, ret; >>>>> struct mmc *mmc; >>>>> + enum bus_mode speed_mode = MMC_MODES_END; >>>>> >>>>> if (argc == 1) { >>>>> dev = curr_device; >>>>> + mmc = init_mmc_device(dev, true, MMC_MODES_END); >>>>> } else if (argc == 2) { >>>>> dev = simple_strtoul(argv[1], NULL, 10); >>>>> + mmc = init_mmc_device(dev, true, MMC_MODES_END); >>>>> } else if (argc == 3) { >>>>> dev = (int)simple_strtoul(argv[1], NULL, 10); >>>>> part = (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 = init_mmc_device(dev, true, MMC_MODES_END); >>>>> + } else if (argc == 4) { >>>>> + dev = (int)simple_strtoul(argv[1], NULL, 10); >>>>> + part = (int)simple_strtoul(argv[2], NULL, 10); >>>>> + speed_mode = simple_strtoul(argv[3], NULL, 10); >>>>> + mmc = init_mmc_device(curr_device, true, speed_mode); >>>>> } else { >>>>> return CMD_RET_USAGE; >>>>> } >>>>> >>>>> - mmc = init_mmc_device(dev, true); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -636,7 +662,7 @@ static int do_mmc_hwpartition(struct cmd_tbl *cmdtp, int flag, >>>>> enum mmc_hwpart_conf_mode mode = MMC_HWPART_CONF_CHECK; >>>>> int i, r, pidx; >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = init_mmc_device(curr_device, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -726,7 +752,7 @@ static int do_mmc_bootbus(struct cmd_tbl *cmdtp, int flag, >>>>> reset = simple_strtoul(argv[3], NULL, 10); >>>>> mode = simple_strtoul(argv[4], NULL, 10); >>>>> >>>>> - mmc = init_mmc_device(dev, false); >>>>> + mmc = init_mmc_device(dev, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -789,7 +815,7 @@ static int do_mmc_boot_resize(struct cmd_tbl *cmdtp, int flag, >>>>> bootsize = simple_strtoul(argv[2], NULL, 10); >>>>> rpmbsize = simple_strtoul(argv[3], NULL, 10); >>>>> >>>>> - mmc = init_mmc_device(dev, false); >>>>> + mmc = init_mmc_device(dev, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -844,7 +870,7 @@ static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag, >>>>> >>>>> dev = simple_strtoul(argv[1], NULL, 10); >>>>> >>>>> - mmc = init_mmc_device(dev, false); >>>>> + mmc = init_mmc_device(dev, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -887,7 +913,7 @@ static int do_mmc_rst_func(struct cmd_tbl *cmdtp, int flag, >>>>> return CMD_RET_USAGE; >>>>> } >>>>> >>>>> - mmc = init_mmc_device(dev, false); >>>>> + mmc = init_mmc_device(dev, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -939,7 +965,7 @@ static int do_mmc_bkops_enable(struct cmd_tbl *cmdtp, int flag, >>>>> >>>>> dev = simple_strtoul(argv[1], NULL, 10); >>>>> >>>>> - mmc = init_mmc_device(dev, false); >>>>> + mmc = init_mmc_device(dev, false, MMC_MODES_END); >>>>> if (!mmc) >>>>> return CMD_RET_FAILURE; >>>>> >>>>> @@ -958,7 +984,7 @@ static int do_mmc_boot_wp(struct cmd_tbl *cmdtp, int flag, >>>>> int err; >>>>> struct mmc *mmc; >>>>> >>>>> - mmc = init_mmc_device(curr_device, false); >>>>> + mmc = 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[] = { >>>>> #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 = cfg->part_type; >>>>> mmc->dev = dev; >>>>> >>>>> +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) >>>>> + mmc->user_speed_mode = MMC_MODES_END; >>>>> +#endif >>>>> return 0; >>>>> } >>>>> >>>>> 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 = mmc->cfg->host_caps | MMC_CAP(MMC_LEGACY) | >>>>> MMC_CAP(MMC_LEGACY) | MMC_MODE_1BIT; >>>>> + >>>>> +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET) >>>>> + if (mmc->user_speed_mode != 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 = MMC_LEGACY; i < MMC_MODES_END; i++) >>>>> + mmc->host_caps &= ~MMC_CAP(i); >>>>> + mmc->host_caps |= (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 >>>>> }; >>>>> >>>>> #if CONFIG_IS_ENABLED(DM_MMC) >>>>> >>>> >>> >>> >> > >