From patchwork Thu Jul 7 20:27:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 954142 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p67KTBKX025929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 7 Jul 2011 20:29:36 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QevBA-0007B1-4y; Thu, 07 Jul 2011 20:28:08 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QevB9-0004IG-Cp; Thu, 07 Jul 2011 20:28:07 +0000 Received: from mail.df.lth.se ([194.47.250.12]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QevAs-0004F7-J6 for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2011 20:27:51 +0000 Received: from localhost.localdomain (host-78-78-94-93.mobileonline.telia.com [78.78.94.93]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.df.lth.se (Postfix) with ESMTPSA id 6D71D65DA6; Thu, 7 Jul 2011 22:27:43 +0200 (CEST) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] mmci: adjust calculation of f_min Date: Thu, 7 Jul 2011 22:27:35 +0200 Message-Id: <1310070455-26418-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.7.6 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110707_162750_961996_A4A6248E X-CRM114-Status: GOOD ( 12.44 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [194.47.250.12 listed in list.dnswl.org] Cc: Linus Walleij , Ulf Hansson X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 07 Jul 2011 20:29:36 +0000 (UTC) From: Ulf Hansson The ARM version maximum clock divider is 512 whereas for the ST variants it's 257. Let's use DIV_ROUND_UP() for both cases so we can see clearly what's going on here. Signed-off-by: Ulf Hansson Reviewed-by: Sebastian Rasmussen [Use DIV_ROUND_UP to clarify elder code] Signed-off-by: Linus Walleij --- drivers/mmc/host/mmci.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index fe14072..50f4f77 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -1063,7 +1063,15 @@ static int __devinit mmci_probe(struct amba_device *dev, } mmc->ops = &mmci_ops; - mmc->f_min = (host->mclk + 511) / 512; + /* + * The ARM and ST versions of the block have slightly different + * clock divider equations which means that the minimum divider + * differs too. + */ + if (variant->st_clkdiv) + mmc->f_min = DIV_ROUND_UP(host->mclk, 257); + else + mmc->f_min = DIV_ROUND_UP(host->mclk, 512); /* * If the platform data supplies a maximum operating * frequency, this takes precedence. Else, we fall back