From patchwork Thu Aug 28 23:43:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 4808411 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BE5479F375 for ; Thu, 28 Aug 2014 23:46:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01F022011E for ; Thu, 28 Aug 2014 23:46:54 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F0380200FF for ; Thu, 28 Aug 2014 23:46:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XN9Mj-0000Jh-2P; Thu, 28 Aug 2014 23:44:29 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XN9Mh-0000IW-7J for linux-arm-kernel@lists.infradead.org; Thu, 28 Aug 2014 23:44:27 +0000 Received: by mail-pa0-f41.google.com with SMTP id lj1so4517628pab.28 for ; Thu, 28 Aug 2014 16:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=TB6lfFpWct4NDDw3rzfA3DnUwACzyD1ZeWuuKYUVztE=; b=DJQ7Y6ma4cMogPfK1FckmwheXy6mk5SK98PaBMPuvfN3otXYLC31c6iCCGivn0Ocqg iTX/j+voj/shbq8iBGERtlbXisy65U/ntmTSjVlahcuyFaqrwYw34Ro3998vlOFS4J9l mGBpKxcLV/v0USDZcwjJmfZ8TOlfHNLbnTheY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TB6lfFpWct4NDDw3rzfA3DnUwACzyD1ZeWuuKYUVztE=; b=UtSgGkgqshImf4gmPZTaQ53LG01/BkqIlHSQ5w42CQT195Xhjzmv0ewDJOul+t6kwd T8sNzsek45Hi7y7kSm0dPbVSPlh8JMTNF5JQAmDUWzkiiLvTjynxXD9FirM8ZCrg8dl3 HkPwtv4d0vScCVk/l9bRHgRwtOUuh1Dkyx6T7tdkmRA62+tJtoNnbhKsUmXyttifNQZO 2O21FeD77AfmHqHPwFypaBt05Ej3Iqt5PHpcyk2mwcq8YN8N8ROEH8TXlZT8vWRX44ZW Z/eW7GLvyGRt0Ej1NxY3rcA4/U94dGQtT0dQ8ySZtr2cbgZ22WA5k4RMo1eWwEko4FSf m5AQ== X-Gm-Message-State: ALoCoQmb/ZpAkbyZEOnJmmrQsTQjYRtcx3lS4IHPPYdRshm0b/AZyUN4aLinCfkudHAIi1duvutz X-Received: by 10.68.69.109 with SMTP id d13mr10570859pbu.111.1409269445434; Thu, 28 Aug 2014 16:44:05 -0700 (PDT) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.162.15]) by mx.google.com with ESMTPSA id q13sm7279212pdj.44.2014.08.28.16.44.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 16:44:04 -0700 (PDT) From: Doug Anderson To: Mark Brown , Addy Ke , Heiko Stuebner Subject: [PATCH] spi/rockchip: Avoid accidentally turning off the clock Date: Thu, 28 Aug 2014 16:43:48 -0700 Message-Id: <1409269428-24680-1-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140828_164427_374116_4F4934F8 X-CRM114-Status: GOOD ( 11.76 ) X-Spam-Score: -0.8 (/) Cc: Dmitry Torokhov , amstan@chromium.org, linux-kernel@vger.kernel.org, "Jeffy.Chen" , Doug Anderson , linux-spi@vger.kernel.org, linux-rockchip@lists.infradead.org, Sonny Rao , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If our client is requesting a clock that is above the maximum clock then the following division will result in 0: rs->max_freq / rs->speed We'll then program 0 into the SPI_BAUDR register. The Rockchip TRM says: "If the value is 0, the serial output clock (sclk_out) is disabled." It's much better to end up with the fastest possible clock rather than a clock that is off, so enforce a minimum value. Signed-off-by: Doug Anderson --- drivers/spi/spi-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 6321326..cd0e08b0 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -499,7 +499,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs) } /* div doesn't support odd number */ - div = rs->max_freq / rs->speed; + div = max_t(u32, rs->max_freq / rs->speed, 1); div = (div + 1) & 0xfffe; spi_enable_chip(rs, 0);