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: 4808401 Return-Path: X-Original-To: patchwork-linux-rockchip@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 7B3D99F375 for ; Thu, 28 Aug 2014 23:44:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB444200FF for ; Thu, 28 Aug 2014 23:44:29 +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 E1CFB200D0 for ; Thu, 28 Aug 2014 23:44:28 +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 1XN9Mi-0000JY-4C; Thu, 28 Aug 2014 23:44:28 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XN9Mh-0000IX-7Z for linux-rockchip@lists.infradead.org; Thu, 28 Aug 2014 23:44:27 +0000 Received: by mail-pa0-f54.google.com with SMTP id fb1so4611064pad.13 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=X++pkZP4Tl7krWj+GBfFbF4H1cRnB0UWIR9LP65NSL2TfSh/NsjoIL2O52kbi+1l0g 6uLw7cf05OO2sdmLi3ZulzhLUug/BGgrMXNJjqCPywJbkNHR1dF+f+B+RaNH3P8M2saL dRq+GTsEj1LgDKxVAtlj3QTZIL3/+2l1GcIKU+2Ozy28WDuU79tkB3QOEQTlVH/Qfq1Q tLKeiSzA1XDcE0q04ofQaF89KMSY+x2StD0DpI8vGuNA29pAkTZm3QQNkHjvYvKdw8QB m7PWAk4rC1YOyWQogwIzw8L2Uv9kKy6Pyk9xZO2mce0sBWHCH8ADg7RLihvXSmc0g07I To5A== X-Gm-Message-State: ALoCoQnuuto/4wL0+sfW9koWWCM549kVB6ZvlCMHdvz7TrQkNbnIuxQbJhiI1mjGnCdXHYk10G77 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_372536_E42325B8 X-CRM114-Status: GOOD ( 10.26 ) 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-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=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);