From patchwork Thu Jun 30 10:13:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Koen Beel X-Patchwork-Id: 932562 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5UA9U51010252 for ; Thu, 30 Jun 2011 10:13:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752118Ab1F3KNg (ORCPT ); Thu, 30 Jun 2011 06:13:36 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:34900 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405Ab1F3KNf convert rfc822-to-8bit (ORCPT ); Thu, 30 Jun 2011 06:13:35 -0400 Received: by wyg8 with SMTP id 8so1431459wyg.19 for ; Thu, 30 Jun 2011 03:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=LJwGrMmAz7IiaTjqSVr7d1BvESae8IVQHQCjaaQ6ddc=; b=SYN+FxbtbGui36BRWixVRXqzWKRp+SDWK/CTZsN2ak/oLyKP///y1huV3mgnkkxFsA pTW22UROFmWBC9xy/6h90UTVhVCcpnbmJGsV8nSQyVulKVNln18QRwbhtNmloe7lmPUr FxyqpmQ4NjgzUsH/tEuLT40+/m3m1rAmGjJYs= MIME-Version: 1.0 Received: by 10.216.28.1 with SMTP id f1mr1667823wea.41.1309428814591; Thu, 30 Jun 2011 03:13:34 -0700 (PDT) Received: by 10.216.166.198 with HTTP; Thu, 30 Jun 2011 03:13:34 -0700 (PDT) In-Reply-To: References: Date: Thu, 30 Jun 2011 12:13:34 +0200 Message-ID: Subject: [PATCH] mxs-mmc: fix clock rate setting From: Koen Beel To: linux-mmc@vger.kernel.org Cc: shawn.guo@freescale.com, w.sang@pengutronix.de Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Jun 2011 10:13:37 +0000 (UTC) Fix clock rate setting on mxs-mmc driver. Previously, if div2 was zero the value for TIMING_CLOCK_RATE would have been 255 instead of 0. Also the limits for div1 (TIMING_CLOCK_DIVIDE) and div2 (TIMING_CLOCK_RATE + 1) where not correctly defined. Can easily be reproduced on mx23evk: default clock for high speed sdio cards is 50 MHz. With a SSP_CLK of 28.8 MHz (default), this resulted in an actual clock rate of about 56 kHz. Signed-off-by: Koen Beel gmail.com> ---  drivers/mmc/host/mxs-mmc.c |   12 ++++++------  1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c index 99d39a6..3575330 100644 --- a/drivers/mmc/host/mxs-mmc.c +++ b/drivers/mmc/host/mxs-mmc.c @@ -570,22 +570,22 @@ static void mxs_mmc_set_clk_rate(struct mxs_mmc_host *host, unsigned int rate)     ssp_rate = clk_get_rate(host->clk); -   for (div1 = 2; div1 < 254; div1 += 2) { +   for (div1 = 2; div1 <= 254; div1 += 2) {         div2 = ssp_rate / rate / div1; -       if (div2 < 0x100) +       if (div2 <= 256)             break;     } -   if (div1 >= 254) { +   if (div1 > 254) {         dev_err(mmc_dev(host->mmc),             "%s: cannot set clock to %d\n", __func__, rate);         return;     }     if (div2 == 0) -       bit_rate = ssp_rate / div1; -   else -       bit_rate = ssp_rate / div1 / div2; +       div2 = 1; + +   bit_rate = ssp_rate / div1 / div2;     val = readl(host->base + HW_SSP_TIMING);     val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE); -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html