From patchwork Tue Oct 13 14:09:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 7385891 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 60538BEEA4 for ; Tue, 13 Oct 2015 14:10:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 945A42042A for ; Tue, 13 Oct 2015 14:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 99D332077E for ; Tue, 13 Oct 2015 14:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752729AbbJMOKU (ORCPT ); Tue, 13 Oct 2015 10:10:20 -0400 Received: from mga01.intel.com ([192.55.52.88]:40270 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751904AbbJMOKT (ORCPT ); Tue, 13 Oct 2015 10:10:19 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 13 Oct 2015 07:09:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,678,1437462000"; d="scan'208";a="825638680" Received: from black.fi.intel.com ([10.237.72.93]) by orsmga002.jf.intel.com with ESMTP; 13 Oct 2015 07:09:16 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id A7A42B8; Tue, 13 Oct 2015 17:09:14 +0300 (EEST) From: Andy Shevchenko To: Jarkko Nikula , Mark Brown , linux-spi@vger.kernel.org, "Puustinen, Ismo" Cc: Andy Shevchenko Subject: [PATCH v2 1/1] spi-pxa2xx: choose closest lower speed Date: Tue, 13 Oct 2015 17:09:14 +0300 Message-Id: <1444745354-85940-1-git-send-email-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.5.3 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 As per discussion [1] the best choice is to set closest speed which is not going over the asked one. Do the same approach for Intel Quark boards. [1] http://www.spinics.net/lists/linux-spi/msg03389.html Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index dee5b38..82493c2 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -734,7 +734,7 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) mul = (1 << 24) >> 1; /* Calculate initial quot */ - q1 = DIV_ROUND_CLOSEST(fref1, rate); + q1 = DIV_ROUND_UP(fref1, rate); /* Scale q1 if it's too big */ if (q1 > 256) { @@ -759,7 +759,7 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) /* Case 2 */ - q2 = DIV_ROUND_CLOSEST(fref2, rate); + q2 = DIV_ROUND_UP(fref2, rate); r2 = abs(fref2 / q2 - rate); /* @@ -778,13 +778,13 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) mul = (1 << 24) * 2 / 5; } - /* Check case 3 only If the divisor is big enough */ + /* Check case 3 only if the divisor is big enough */ if (fref / rate >= 80) { u64 fssp; u32 m; /* Calculate initial quot */ - q1 = DIV_ROUND_CLOSEST(fref, rate); + q1 = DIV_ROUND_UP(fref, rate); m = (1 << 24) / q1; /* Get the remainder */