Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp5804367ybf; Thu, 5 Mar 2020 07:19:50 -0800 (PST) X-Google-Smtp-Source: ADFU+vvgzIqArleejmgfSwyTByPIPU3WdPCqAlASTLsq08xOsc+0J80A0cyhpXNB6tbVsV+vdTLm X-Received: by 2002:a9d:5a92:: with SMTP id w18mr7224993oth.292.1583421590637; Thu, 05 Mar 2020 07:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583421590; cv=none; d=google.com; s=arc-20160816; b=APvsySSsj7Ag01oE8okPqK1rFS08XyrszRyOF1ut8YFzASStixDFQWja/UpPEr5FUL VYJryororUuUmKyW/mC3WpGKXbxjp2agDRTaIHe1CTWjBgTD7I507Mg7vnPv0SLxWL4q vPVQfcJmqSdhW7KNKXM33s95zd2EKBdyZBAid+J0dYLT0EZCuqss9NhmAqfbzMIFd1h/ hu0c8RpWOqTxvYjWHrH5xRnf3Pop5eab5NNTIRym9XdDWeajeLoRv68LF+o8UyHn8cjp qVmdGUe3Cimw7AxhOo2+VxjRxm0ZhOrYV4ed3l9EIpd64qiGSj32eIE+GbUflSisqnq+ f6Xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=phO1fjFkXHP5aJjwLHsIxyYf9QWL4a+ZWZL5UkWICQE=; b=cy36QlOjMqfbHWPdM4eI5HIaIHTZkF3qq+a4NKam+PcseeUrEWgMBMvQxPo+5qI7L/ h9zD4SmQPIxvTzTDTcv896hVVLI7JuQj/DaXnQn4EZ3Aal1AZeIQ2CVUfTsozVpoGdU9 dU/xs2T/lyaRLHVEVM6KJTwg8Dvsja9qT/q9AHfyFT2yQiSsbqLSGOGeAUoPSOcVmO2U Wp3kIjzauD/hY4BEranlA5rRw9ajwmxSp7EuNTtLd4VKkOTlK4GoEhskdE0+Djt6CJfv O1wcbYLv+ugHuuUHNVGGgyxHWG64smeMInbfleMZ9YebALwiGR5Ale5w2ZkF+Nmk3wn4 N+0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LydZnWZI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1si3818578otf.102.2020.03.05.07.19.35; Thu, 05 Mar 2020 07:19:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LydZnWZI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726970AbgCEPSg (ORCPT + 99 others); Thu, 5 Mar 2020 10:18:36 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:32925 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726947AbgCEPSf (ORCPT ); Thu, 5 Mar 2020 10:18:35 -0500 Received: by mail-vs1-f65.google.com with SMTP id n27so3807099vsa.0 for ; Thu, 05 Mar 2020 07:18:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=phO1fjFkXHP5aJjwLHsIxyYf9QWL4a+ZWZL5UkWICQE=; b=LydZnWZIWOS4wpTtuLtiaYTY/40HZEDPw/0VNCexamYkwKWR5oZWCAAClj/qdG7USz PHIXMsf2PAjSDYO+Msw7jMTytfHZVJhbOV0awiORGVrrBFMlDru1xy6umOiB4UN6lAvJ extns31knyFdUjRiXZQ9LOCDK1BJKtneAcCXwOnDbaVgtayOBeOod4uuEcknP9PTsMx4 6ct7acLNOVCVZSL2mGoen6qeqE+TS48cr7/IQQqwKK7YbfuGqqG5PHJc/VgzpESHk7DF Vmx2TB09ECyaG4+DFTToAITpKV19qFGGY2m4DUUvTA33jvhBitnbm4/rBbSvmwpPE6P0 AHkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=phO1fjFkXHP5aJjwLHsIxyYf9QWL4a+ZWZL5UkWICQE=; b=pBtKTZ0EgsX+PpVShYuyQh5q3lccCZIQJn/1NHxezakDbym1XBCtDkOKbkFJ1uz0TU 4hJOUAJ6ULq0eQJ3lFoOOmEnK1aL9DIHsAsjTId7Xy+LtFPu6WGKJ2U1TjPtXY3gPXdM k5o4W6xQtUYtDwGW6hiIa7AoPNMZYbxbDt2PlnFsHyYamVS62pksCI6WxCxYrRyUIHi0 gJup9QiPeMzo5HMxMmryItU3U6aIp2KqdCY5SWp55qgXsKdr6SQtnmW316sR7/3iJTz/ xJ+x5L35AIqsWbFZIPR9eA2g6CSpYfpp9Y/Oy0S93Q/zjpAPgGsrw0/RwWTxvZQqEuyi TGDg== X-Gm-Message-State: ANhLgQ2ny35bb36y6Zad3ChRbyxmXae+k7aM9z7Q/0w6cwfA7+TQ8hJW aDX0gCNNOWPjzC7f4aRph/DCQp5KRhtH6sLG5kbocg== X-Received: by 2002:a67:f4cf:: with SMTP id s15mr5356964vsn.165.1583421513606; Thu, 05 Mar 2020 07:18:33 -0800 (PST) MIME-Version: 1.0 References: <20200212024220.GA32111@seokyung-mobl1> In-Reply-To: From: Ulf Hansson Date: Thu, 5 Mar 2020 16:17:57 +0100 Message-ID: Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc To: "Seo, Kyungmin" , Adrian Hunter , Chaotian Jing Cc: "linux-mmc@vger.kernel.org" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Adrian, Chaotian On Thu, 5 Mar 2020 at 09:57, Seo, Kyungmin wrote: > > The mmc_hs400_to_hs200 function is called only in HS400 mode. > I saw the clock change from 200MHz to 52MHz via oscilloscope on real platform. > > I think CMD6 is sent in HS400 mode with 200MHz clock, but it's not. > First CMD6 in mmc_hs400_to_hs200 function is sent with 52MHz clock. I had a vague memory that we have discussed a similar problem as your are pointing out on the mailing list already. And I was right. Please read up on the below references, [1], [2] for the earlier discussions. I suggested a solution for Chaotian to try, but it seems like he never managed to give it a go, as I don't recall new patch being posted. Perhaps you can pick up were Chaotian left and see if you can implement the suggested solution(s). My main concern is breaking other host drivers, as that seems quite likely to happen, if we aren't careful about this. Kind regards Uffe [1] https://lore.kernel.org/linux-mmc/1548921212-5219-1-git-send-email-chaotian.jing@mediatek.com/ [2] https://lore.kernel.org/linux-mmc/CAPDyKFquyyXx1MqNLVXuFxcEDB9nKzN8LGGNUP2yxoVMQrWiUg@mail.gmail.com/ > > Thanks > KM > > -----Original Message----- > From: Ulf Hansson > Sent: Wednesday, March 4, 2020 8:09 PM > To: Seo, Kyungmin > Cc: linux-mmc@vger.kernel.org; Linux Kernel Mailing List > Subject: Re: [PATCH] mmc: mmc: Fix the timing for clock changing in mmc > > On Wed, 12 Feb 2020 at 03:40, Kyungmin Seo wrote: > > > > The clock has to be changed after sending CMD6 for HS mode selection > > in > > mmc_hs400_to_hs200() function. > > > > The JEDEC 5.0 and 5.1 said that "High-speed" mode selection has to > > enable the the high speed mode timing in the Device, before chaning > > the clock frequency to a frequency between 26MHz and 52MHz. > > I think that is based upon the assumption that you are using a lower frequency to start with. > > For example, assume that you are running with 400KHz during card initialization, then you want to send the CMD6 to switch to HS mode and that should be done, before updating the clock rate. > > mmc_hs400_to_hs200() goes the opposite direction, so I think the current code looks correct to me. > > Kind regards > Uffe > > > > > Signed-off-by: Kyungmin Seo > > --- > > drivers/mmc/core/mmc.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index > > 3486bc7fbb64..98640b51c73e 100644 > > --- a/drivers/mmc/core/mmc.c > > +++ b/drivers/mmc/core/mmc.c > > @@ -1196,10 +1196,6 @@ int mmc_hs400_to_hs200(struct mmc_card *card) > > int err; > > u8 val; > > > > - /* Reduce frequency to HS */ > > - max_dtr = card->ext_csd.hs_max_dtr; > > - mmc_set_clock(host, max_dtr); > > - > > /* Switch HS400 to HS DDR */ > > val = EXT_CSD_TIMING_HS; > > err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, > > EXT_CSD_HS_TIMING, @@ -1210,6 +1206,10 @@ int > > mmc_hs400_to_hs200(struct mmc_card *card) > > > > mmc_set_timing(host, MMC_TIMING_MMC_DDR52); > > > > + /* Reduce frequency to HS */ > > + max_dtr = card->ext_csd.hs_max_dtr; > > + mmc_set_clock(host, max_dtr); > > + > > err = mmc_switch_status(card); > > if (err) > > goto out_err; > > -- > > 2.17.1 > >