Received: by 10.213.65.68 with SMTP id h4csp1403467imn; Wed, 4 Apr 2018 19:10:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Lrd+fXqC3io0zhiwXuHP2+ZfNdfio/IkJzSahtNCHNv2xWyz7caH6ynGn89wbZDsNwrxQ X-Received: by 2002:a17:902:5a4:: with SMTP id f33-v6mr7654489plf.278.1522894225021; Wed, 04 Apr 2018 19:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522894224; cv=none; d=google.com; s=arc-20160816; b=BMzohtabDCyw1Mx3u6HvEPbT/8tXXuyFRgQeVxQcbv65RzHqHL2q5MPhXamn4XtUD8 8sgEXwUntoGpwl9r18wwAZBJEUerlvjOvawfVRj0IhIfSPyYQ9uFMhdt/+jbG+o8C3kq iRmr/iR9NF8+TYCc2fwdsa/miN5k6v6P3hlWofEMuiBZ6kAPOXCzjEZgNNLYAVYhGDua EfiiQx3RO6eXddhRtzNYgQdqwhOnheVsxRxqHUBPs/Z5OLBwwSk+Oc8Px2ZnS0BqCuXN UAAqngGjoMLe07ORFDm1QXsAVY4MQ2pN2Lw0ZWhQqEsC2JXz4TR+kFUMT45+racNrXcc M/kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=BaCgJ8fz+o3aAQTYahOPKX2g6JvzdrkVJaUNslJLjwE=; b=jpGTHiWDM29Y8Gk+oW96xyDCHEm4cy7nhWrF8Ze0VcVTbwq3qWQJRxVOB53kz0choz 87b3ZAZZrExHmEyXTaumk+eiYg+YNfl4eBD5c5QG+g+OzushczEqLzzRJjSQbNUX+3gv rZwpcNBJ0S1IWk5ldUE4imJ+BIKXQ0mgXRsFqR3ui6d1fT4CNGxytIjYZbSrb1+GSnaK kMIvr5R+QAbkCffdHk873Car9Yl0hVW1OediHxcZoRAiyc7oXQWtYjIzk0tj5hxWQXFO WkOGa5uMaBio5+WIQm4Qzk+a6lqhQ//YgaU0dODUXApbnjD0AqbQ0dNsjCF4a5LdYY0O pIyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bx3iaXaJ; 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 f10-v6si4606153pln.359.2018.04.04.19.10.10; Wed, 04 Apr 2018 19:10:24 -0700 (PDT) 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=bx3iaXaJ; 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 S1752791AbeDECJE (ORCPT + 99 others); Wed, 4 Apr 2018 22:09:04 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:43174 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752688AbeDECJC (ORCPT ); Wed, 4 Apr 2018 22:09:02 -0400 Received: by mail-pl0-f66.google.com with SMTP id c21-v6so13344443plz.10 for ; Wed, 04 Apr 2018 19:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=BaCgJ8fz+o3aAQTYahOPKX2g6JvzdrkVJaUNslJLjwE=; b=bx3iaXaJyWDC4xdDbTUw8YuSx69JvitBwbHy7MagpyK41VK3r0Sp/TKovwDbIwOxQl EbcaCzKs8Bnf5DACXAx38fwcLuKVgpnETggbBhpDR5JyE4gMPRyTPPlBmcqL4JNA79NT T8kv8YEFZ1keyiaAwRl5/GKJrDV9EMzEa0AgQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=BaCgJ8fz+o3aAQTYahOPKX2g6JvzdrkVJaUNslJLjwE=; b=ZxZlZ+3RerZVfvgJaccqGz7lztDp+WHU4wfLRmNidJhNWZKgnK8B66dm4TuN01ksmZ OBprWu+OqTqjO6it4OGM5mOnUj/AsPzCoWsFgy7n4E0qJ9brUCEFx63p+qLpFmW5lOzl qzMA9BbCtGdRLCOLX0FU9S3yI6UzJeruPxUMkRPAGZOGrK6nFndECe+U6bcYQM6VkgkS oZUDsRcguLz/HWu7k4sRI6i4CiCkphdBGV34h5VDjkHT7EQaoJlWZtfC+ufjF4uZY6tW ruoxzjVoIvu/H9PFjvuCpJnEJiT8F6ad8zaPkT+l/JWoxg0JhUwI0dv/fOi2zbB8bwi9 78rQ== X-Gm-Message-State: AElRT7ExHLwiAwXhYnsLVv2QH9H/niicDcppnykM6C5RF9ipexeIDrev 1QF9IJXNudDpsUIz/dCaXHw86Q== X-Received: by 10.98.89.200 with SMTP id k69mr15800411pfj.100.1522894141806; Wed, 04 Apr 2018 19:09:01 -0700 (PDT) Received: from [10.188.9.214] ([104.237.91.84]) by smtp.gmail.com with ESMTPSA id 195sm10667152pgd.3.2018.04.04.19.08.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Apr 2018 19:09:00 -0700 (PDT) Subject: Re: [PATCH] mmc: dw_mmc-k3: Fix DDR52 mode by setting required clock divisor To: Shawn Lin , Ryan Grachek Cc: Jaehoon Chung , Ulf Hansson , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, liwei213@huawei.com, Suzhuangluan References: <20180329182423.21201-1-ryan@edited.us> From: zhangfei Message-ID: <00fe2c61-1cb8-d548-2057-9e70ec18df67@linaro.org> Date: Thu, 5 Apr 2018 10:08:57 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + Hisilicon colleague On 2018年04月05日 08:51, Shawn Lin wrote: > [+ Zhangfei Gao who added support for hi6220] > > On 2018/4/4 23:31, Ryan Grachek wrote: >> On Tue, Apr 3, 2018 at 6:31 AM, Shawn Lin > > wrote: >> >>     On 2018/3/30 2:24, oscardagrach wrote: >> >>     Need at least one line commit body. >> >>         Signed-off-by: oscardagrach > > >>         --- >>            drivers/mmc/host/dw_mmc-k3.c | 10 ++++++++-- >>            1 file changed, 8 insertions(+), 2 deletions(-) >> >>         diff --git a/drivers/mmc/host/dw_mmc-k3.c >>         b/drivers/mmc/host/dw_mmc-k3.c >>         index 89cdb3d533bb..efc546cb4db8 100644 >>         --- a/drivers/mmc/host/dw_mmc-k3.c >>         +++ b/drivers/mmc/host/dw_mmc-k3.c >>         @@ -194,8 +194,14 @@ static void dw_mci_hi6220_set_ios(struct >>         dw_mci *host, struct mmc_ios *ios) >>                  int ret; >>                  unsigned int clock; >>            -     clock = (ios->clock <= 25000000) ? 25000000 : >> ios->clock; >>         - >>         +       /* CLKDIV must be 1 for DDR52/8-bit mode */ >>         +       if (ios->bus_width == MMC_BUS_WIDTH_8 && >>         +               ios->timing == MMC_TIMING_MMC_DDR52) { >>         +               mci_writel(host, CLKDIV, 0x1); >>         +               clock = ios->clock; >>         +       } else { >>         +               clock = (ios->clock <= 25000000) ? 25000000 : >>         ios->clock; >>         +       } >> >> >>     I undertand DDR52/8-bit need CLKDIV fixed 1, but shouldn't the >> following >>     change is more sensible? >> >>     if (ios->bus_width == MMC_BUS_WIDTH_8 && ios->timing == >>     MMC_TIMING_MMC_DDR52) >>              clock = ios->clock * 2; >>     else >>              clock = (ios->clock <= 25000000) ? 25000000 : ios->clock; >> >> >>     The reason is ios->clock is 52MHz and you could claim 104MHz from >> the >>     clock provider and let dw_mmc core take care of the divder to be 1. >>     Otherwise, you just force it to be DDR52/8-bit with a clk rate of >> 26MHz. >> >> >>                  ret = clk_set_rate(host->biu_clk, clock); >>                  if (ret) >>                          dev_warn(host->dev, "failed to set rate >>         %uHz\n", clock); >> >> >> > > For future wise, please use plain mode mail, but not HTML format. > >> Your feedback is correct. I see the Rockchip dwmmc driver has a similar >> implementation. After applying your suggested changes, however, my board >> reports "dwmmc_k3 f723d000.dwmmc0: failed to set rate 104000000Hz" >> during intialization of eMMC. In addition, I do not see CLKDIV being >> set to 1. clk_set_rate fails and I wonder if this is out-of-scope of >> the driver. >> >> If I set CLKDIV where I did prior, with your changes, the device fails >> to set the clock and falls back to 52 MHz (26 MHz) and works fine, but >> again, CLKDIV is reported as 0 (even though it is 1.) One thing of >> interest to note is when I manually set the clock by doing: >> (echo 104000000 > /sys/kernel/debug/mmc0/clock) the device reports back >> 'mmc_host mmc0: Bus speed (slot 0) = 198400000Hz (slot req 104000000Hz, >>   actual 99200000HZ div = 1)' which works reliably and clk_set_rate does >> not report any error. >> > > When looking closely into the code, at least dw_mci_hi6220_set_ios > goes wrong with the bus_hz, since it should be ciu_clk but not biu_clk. > "b" stands for bus, and "c" stands for card IMHO, however bus_hz > describs the clock to the card, provided by controller. Does the > following patch help? > > > diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c > index 89cdb3d..9e78cf2 100644 > --- a/drivers/mmc/host/dw_mmc-k3.c > +++ b/drivers/mmc/host/dw_mmc-k3.c > @@ -194,13 +194,21 @@ static void dw_mci_hi6220_set_ios(struct dw_mci > *host, struct mmc_ios *ios) >         int ret; >         unsigned int clock; > > -       clock = (ios->clock <= 25000000) ? 25000000 : ios->clock; > +       if (ios->bus_width == MMC_BUS_WIDTH_8 && > +           ios->timing == MMC_TIMING_MMC_DDR52) > +               clock = ios->clock * 2; > +       else > +               clock = (ios->clock <= 25000000) ? 25000000 : ios->clock; > > -       ret = clk_set_rate(host->biu_clk, clock); > +       ret = clk_set_rate(host->ciu_clk, clock); >         if (ret) >                 dev_warn(host->dev, "failed to set rate %uHz\n", clock); > > -       host->bus_hz = clk_get_rate(host->biu_clk); > +       clock = clk_get_rate(host->ciu_clk); > +       if (clock != host->bus_hz) { > +               host->bus_hz = clock; > +               host->current_speed = 0; > +       } >  } > > >> I am not sure where to begin debugging these clock issues and welcome >> any feedback. >