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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 181D9C3F68F for ; Wed, 15 Jan 2020 09:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8B3724671 for ; Wed, 15 Jan 2020 09:54:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=rere.qmqm.pl header.i=@rere.qmqm.pl header.b="ZNbq1c+d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729615AbgAOJyl (ORCPT ); Wed, 15 Jan 2020 04:54:41 -0500 Received: from rere.qmqm.pl ([91.227.64.183]:16904 "EHLO rere.qmqm.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729504AbgAOJyl (ORCPT ); Wed, 15 Jan 2020 04:54:41 -0500 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 47yN325rrnzKt; Wed, 15 Jan 2020 10:54:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1579082079; bh=sxzTUCMMAQefhnz1DPOUyOGPD2XGl5ktWwEOSWo2bj0=; h=Date:From:Subject:To:Cc:From; b=ZNbq1c+dvSJrUfpTUQARYgA/3BdK/p9VWUQ5x7c26GOuNwgV2bxpSM1IVh+7WR0UQ nybo0PAh9YgsqOn8/gbbI3KP/ry+fzXciSnBOexUrl2+S/Hi7s7lxNh3PC40jbUVAA Tc/zIKWvbWpg7grk68YUNjZbrF2joZ44RLisH+UkM9dia7SLSBgEthcfbJdGwIFw7w vBdStuSe8RTWe/gogkupioXUUFFUpGCWjfPB1aMItwtCxA78kKLaSn0dG8yTEuugjG vhuf2Dj0aTJzgZfzGZ9WqdVBJoEfVW2TnbdRzQNxxN9wHRt3hXLXkjo9r2U++hC/6x P3sBiy1pP4veA== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.101.4 at mail Date: Wed, 15 Jan 2020 10:54:35 +0100 Message-Id: From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH v3] mmc: sdhci: fix minimum clock rate for v3 controller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To: Adrian Hunter , Ulf Hansson Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For SDHCIv3+ with programmable clock mode, minimal clock frequency is still base clock / max(divider). Minimal programmable clock frequency is always greater than minimal divided clock frequency. Without this patch, SDHCI uses out-of-spec initial frequency when multiplier is big enough: mmc1: mmc_rescan_try_freq: trying to init card at 468750 Hz [for 480 MHz source clock divided by 1024] The code in sdhci_calc_clk() already chooses a correct SDCLK clock mode. Cc: stable@vger.kernel.org Fixes: c3ed3877625f ("mmc: sdhci: add support for programmable clock mode") Signed-off-by: Michał Mirosław --- v3: commitmsg/comment rewording v2: extend commitmsg and add comment --- drivers/mmc/host/sdhci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 96609c961465..24fb6d710de6 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3903,11 +3903,13 @@ int sdhci_setup_host(struct sdhci_host *host) if (host->ops->get_min_clock) mmc->f_min = host->ops->get_min_clock(host); else if (host->version >= SDHCI_SPEC_300) { - if (host->clk_mul) { - mmc->f_min = (host->max_clk * host->clk_mul) / 1024; + if (host->clk_mul) max_clk = host->max_clk * host->clk_mul; - } else - mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; + /* + * Divided Clock Mode minimum clock rate is always less than + * Programmable Clock Mode minimum clock rate. + */ + mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_300; } else mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; -- 2.20.1